{"version":3,"names":["MousePosition","__SystemJSRewritingHack","_export","setters","_srcClientGraphicsJs","pt","execute","_recorder_","_src_client_mouse_position_js","Object","defineProperty","get","set","thisIsVererySecretVariableName","enumerable","configurable","context","_pt","lively","elementsFromPoint","x","y","checked","Set","elements","document","e","find","has","add","shadowRoot","newElements","difference","splice","indexOf","showPoint","offset","addXY","onPointerMove","clientX","clientY","load","options","capture","passive","removeEventListener","addEventListener","bind"],"sources":["mouse-position.js"],"sourcesContent":["import { pt } from 'src/client/graphics.js';\n\n\nexport default class MousePosition {\n\n  static get context() {\n    return \"mouse position\";\n  }\n\n  static get pt() {\n    return this._pt || (this._pt = lively.pt(0, 0));\n  }\n\n  static elementsFromPoint({ x, y }) {\n    const checked = new Set();\n    const elements = document.elementsFromPoint(x, y);\n    elements;\n\n    let e;\n    while (e = elements.find(e => !checked.has(e))) {\n      checked.add(e);\n      if (e.shadowRoot) {\n        const newElements = e.shadowRoot.elementsFromPoint(x, y).difference(elements);\n        elements.splice(elements.indexOf(e), 0, ...newElements);\n      }\n    }\n    return elements;\n  }\n\n  static set pt(pt) {\n    return this._pt = pt;\n  }\n\n  static showPoint(pt) {\n    const offset = 20;\n    lively.showPoint(pt.addXY(offset, offset));\n    lively.showPoint(pt.addXY(offset, -offset));\n    lively.showPoint(pt.addXY(-offset, offset));\n    lively.showPoint(pt.addXY(-offset, -offset));\n  }\n\n  static onPointerMove(e) {\n    this.pt = pt(e.clientX, e.clientY);\n  }\n  static load() {\n    const options = {\n      capture: true,\n      passive: true\n    };\n    lively.removeEventListener(this.context);\n    lively.addEventListener(this.context, document, \"pointermove\", ::this.onPointerMove, options);\n  }\n}\n\n// $(function() {\n//   // Get the HTML in #hoverText - just a wrapper for convenience\n//   var $hoverText = $(\"#hoverText\");\n\n//   // Get the full word the cursor is over regardless of span breaks\n//   function getFullWord(event) {\n//      var i, begin, end, range, textNode, offset;\n\n//     // Internet Explorer\n//     if (document.body.createTextRange) {\n//        try {\n//          range = document.body.createTextRange();\n//          range.moveToPoint(event.clientX, event.clientY);\n//          range.select();\n//          range = getTextRangeBoundaryPosition(range, true);\n\n//          textNode = range.node;\n//          offset = range.offset;\n//        } catch(e) {\n//          return \"\"; // Sigh, IE\n//        }\n//     }\n\n//     // Firefox, Safari\n//     // REF: https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\n//     else if (document.caretPositionFromPoint) {\n//       range = document.caretPositionFromPoint(event.clientX, event.clientY);\n//       textNode = range.offsetNode;\n//       offset = range.offset;\n\n//       // Chrome\n//       // REF: https://developer.mozilla.org/en-US/docs/Web/API/document/caretRangeFromPoint\n//     } else if (document.caretRangeFromPoint) {\n//       range = document.caretRangeFromPoint(event.clientX, event.clientY);\n//       textNode = range.startContainer;\n//       offset = range.startOffset;\n//     }\n\n//     // Only act on text nodes\n//     if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {\n//       return \"\";\n//     }\n\n//     var data = textNode.textContent;\n\n//     // Sometimes the offset can be at the 'length' of the data.\n//     // It might be a bug with this 'experimental' feature\n//     // Compensate for this below\n//     if (offset >= data.length) {\n//       offset = data.length - 1;\n//     }\n\n//     // Ignore the cursor on spaces - these aren't words\n//     if (isW(data[offset])) {\n//       return \"\";\n//     }\n\n//     // Scan behind the current character until whitespace is found, or beginning\n//     i = begin = end = offset;\n//     while (i > 0 && !isW(data[i - 1])) {\n//       i--;\n//     }\n//     begin = i;\n\n//     // Scan ahead of the current character until whitespace is found, or end\n//     i = offset;\n//     while (i < data.length - 1 && !isW(data[i + 1])) {\n//       i++;\n//     }\n//     end = i;\n\n//     // This is our temporary word\n//     var word = data.substring(begin, end + 1);\n\n//     // Demo only\n//     showBridge(null, null, null);\n\n//     // If at a node boundary, cross over and see what \n//     // the next word is and check if this should be added to our temp word\n//     if (end === data.length - 1 || begin === 0) {\n\n//       var nextNode = getNextNode(textNode);\n//       var prevNode = getPrevNode(textNode);\n\n//       // Get the next node text\n//       if (end == data.length - 1 && nextNode) {\n//         var nextText = nextNode.textContent;\n\n//         // Demo only\n//         showBridge(word, nextText, null);\n\n//         // Add the letters from the next text block until a whitespace, or end\n//         i = 0;\n//         while (i < nextText.length && !isW(nextText[i])) {\n//           word += nextText[i++];\n//         }\n\n//       } else if (begin === 0 && prevNode) {\n//         // Get the previous node text\n//         var prevText = prevNode.textContent;\n\n//         // Demo only\n//         showBridge(word, null, prevText);\n\n//         // Add the letters from the next text block until a whitespace, or end\n//         i = prevText.length - 1;\n//         while (i >= 0 && !isW(prevText[i])) {\n//           word = prevText[i--] + word;\n//         }\n//       }\n//     }\n//     return word;\n//   }\n\n//   // Return the word the cursor is over\n//   $hoverText.mousemove(function(e) {\n//     var word = getFullWord(e);\n//     if (word !== \"\") {\n//       $(\"#result\").text(word);\n//     }\n//   });\n// });\n\n// // Helper functions\n\n// // Whitespace checker\n// function isW(s) {\n//   return /[ \\f\\n\\r\\t\\v\\u00A0\\u2028\\u2029]/.test(s);\n// }\n\n// // Barrier nodes are BR, DIV, P, PRE, TD, TR, ... \n// function isBarrierNode(node) {\n//   return node ? /^(BR|DIV|P|PRE|TD|TR|TABLE)$/i.test(node.nodeName) : true;\n// }\n\n// // Try to find the next adjacent node\n// function getNextNode(node) {\n//   var n = null;\n//   // Does this node have a sibling?\n//   if (node.nextSibling) {\n//     n = node.nextSibling;\n\n//     // Doe this node's container have a sibling?\n//   } else if (node.parentNode && node.parentNode.nextSibling) {\n//     n = node.parentNode.nextSibling;\n//   }\n//   return isBarrierNode(n) ? null : n;\n// }\n\n// // Try to find the prev adjacent node\n// function getPrevNode(node) {\n//   var n = null;\n\n//   // Does this node have a sibling?\n//   if (node.previousSibling) {\n//     n = node.previousSibling;\n\n//     // Doe this node's container have a sibling?\n//   } else if (node.parentNode && node.parentNode.previousSibling) {\n//     n = node.parentNode.previousSibling;\n//   }\n//   return isBarrierNode(n) ? null : n;\n// }\n\n// // REF: http://stackoverflow.com/questions/3127369/how-to-get-selected-textnode-in-contenteditable-div-in-ie\n// function getChildIndex(node) {\n//   var i = 0;\n//   while( (node = node.previousSibling) ) {\n//     i++;\n//   }\n//   return i;\n// }\n\n// // All this code just to make this work with IE, OTL\n// // REF: http://stackoverflow.com/questions/3127369/how-to-get-selected-textnode-in-contenteditable-div-in-ie\n// function getTextRangeBoundaryPosition(textRange, isStart) {\n//   var workingRange = textRange.duplicate();\n//   workingRange.collapse(isStart);\n//   var containerElement = workingRange.parentElement();\n//   var workingNode = document.createElement(\"span\");\n//   var comparison, workingComparisonType = isStart ?\n//     \"StartToStart\" : \"StartToEnd\";\n\n//   var boundaryPosition, boundaryNode;\n\n//   // Move the working range through the container's children, starting at\n//   // the end and working backwards, until the working range reaches or goes\n//   // past the boundary we're interested in\n//   do {\n//     containerElement.insertBefore(workingNode, workingNode.previousSibling);\n//     workingRange.moveToElementText(workingNode);\n//   } while ( (comparison = workingRange.compareEndPoints(\n//     workingComparisonType, textRange)) > 0 && workingNode.previousSibling);\n\n//   // We've now reached or gone past the boundary of the text range we're\n//   // interested in so have identified the node we want\n//   boundaryNode = workingNode.nextSibling;\n//   if (comparison == -1 && boundaryNode) {\n//     // This must be a data node (text, comment, cdata) since we've overshot.\n//     // The working range is collapsed at the start of the node containing\n//     // the text range's boundary, so we move the end of the working range\n//     // to the boundary point and measure the length of its text to get\n//     // the boundary's offset within the node\n//     workingRange.setEndPoint(isStart ? \"EndToStart\" : \"EndToEnd\", textRange);\n\n//     boundaryPosition = {\n//       node: boundaryNode,\n//       offset: workingRange.text.length\n//     };\n//   } else {\n//     // We've hit the boundary exactly, so this must be an element\n//     boundaryPosition = {\n//       node: containerElement,\n//       offset: getChildIndex(workingNode)\n//     };\n//   }\n\n//   // Clean up\n//   workingNode.parentNode.removeChild(workingNode);\n\n//   return boundaryPosition;\n// }\n\n// // DEMO-ONLY code - this shows how the word is recombined across boundaries\n// function showBridge(word, nextText, prevText) {\n//   if (nextText) {\n//     $(\"#bridge\").html(\"<span class=\\\"word\\\">\" + word + \"</span>  |  \" + nextText.substring(0, 20) + \"...\").show();\n//   } else if (prevText) {\n//     $(\"#bridge\").html(\"...\" + prevText.substring(prevText.length - 20, prevText.length) + \"  |  <span class=\\\"word\\\">\" + word + \"</span>\").show();\n//   } else {\n//     $(\"#bridge\").hide();\n//   }\n// }\n\n\nMousePosition.load();"],"mappings":";;;UAGqBA,aAAa,EAAAC,uBAAA;EAAAC,OAAA;EAAA;IAAAC,OAAA,aAAAC,oBAAA;MAHzBC,EAAE,GAAAD,oBAAA,CAAFC,EAAE;IAAA;IAAAC,OAAA,WAAAA,CAAA;MAAAL,uBAAA;MAAAM,UAAA,CAAAC,6BAAA,GAAAD,UAAA,CAAAC,6BAAA;MAAAC,MAAA,CAAAC,cAAA,CAAAH,UAAA,CAAAC,6BAAA;QAAAG,IAAA;UAAA,OAAAN,EAAA;QAAA;QAAAO,IAAAC,8BAAA;UAAFR,EAAA,CAAAA,CAAA,CAAAA,8BAAE;UAAA;QAAA;QAAAS,UAAA;QAAAC,YAAA;MAAA;MAAAb,OAAA,YAGUF,aAAa,GAAnB,MAAMA,aAAa,CAAC;QAEjC,WAAWgB,OAAOA,CAAA,EAAG;UACnB,OAAO,gBAAgB;QACzB;QAEA,WAAWX,EAAEA,CAAA,EAAG;UACd,OAAO,IAAI,CAACY,GAAG,KAAK,IAAI,CAACA,GAAG,GAAGC,MAAM,CAACb,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACjD;QAEA,OAAOc,iBAAiBA,CAAC;UAAEC,CAAC;UAAEC;QAAE,CAAC,EAAE;UACjC,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAAC,CAAC;UACzB,MAAMC,QAAQ,GAAGC,QAAQ,CAACN,iBAAiB,CAACC,CAAC,EAAEC,CAAC,CAAC;UACjDG,QAAQ;UAER,IAAIE,CAAC;UACL,OAAOA,CAAC,GAAGF,QAAQ,CAACG,IAAI,CAACD,CAAC,IAAI,CAACJ,OAAO,CAACM,GAAG,CAACF,CAAC,CAAC,CAAC,EAAE;YAC9CJ,OAAO,CAACO,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gB,CAAC,IAAI,CAAC9B,OAAO,EAAES,QAAQ,EAAE,aAAa,EAAI,IAAI,CAACa,aAAa,CAAAS,IAAA,CAAlB,IAAI,GAAgBL,OAAO,CAAC;QAC/F;MACF,CAAC,GAED;MACA;MACA;MAEA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MAEA;MAEA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MACA;MAEA;MACA;MAEA;MACA;MACA;MAEA;MACA;MAEA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MAEA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MAEA;MAEA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MAEA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MAEA;MAEA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MAEA;MACA;MAEA;MACA;MAEA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MAAAjC,MAAA,CAAAC,cAAA,CAAAH,UAAA,CAAAC,6BAAA;QAAAG,IAAA;UAAA,OAAAX,aAAA;QAAA;QAAAY,IAAAC,8BAAA;UAAAX,OAAA,YA3RqBF,aAAA,CAAAA,CAAA,CAAAA,8BAAa;UAAA;QAAA;QAAAc,UAAA;QAAAC,YAAA;MAAA;MA8RlCf,aAAa,CAACyC,IAAI,CAAC,CAAC;IAAC;EAAA;AAAA"}