dragselect
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -0,1 +1,6 @@ | ||
# 2.2.2 | ||
- Add a check whether the initial click was issued within the area | ||
- Fixes [#105](https://github.com/ThibaultJanBeyer/DragSelect/issues/105) | ||
# 2.2.1 | ||
@@ -2,0 +7,0 @@ |
@@ -1,1 +0,1 @@ | ||
function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function c(e,t,r){return(c=l()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&a(i,r.prototype),i}).apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return c(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)})(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?d(e):t}function f(e){var t=l();return function(){var r,n=s(e);if(t){var i=s(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return h(this,r)}}function v(e,t,r){return(v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}return r}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var y=function(e,t,r){var n=e.x,i=e.y,o=r.x,s=r.y;return{"+":{x:n+o,y:i+s},"-":{x:n-o,y:i-s},"*":{x:n*o,y:i*s},"/":{x:n/o,y:i/s}}[t]},b=function(e){return{x:e.left,y:e.top}},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}},D=function(){var e,t,r,n;return{y:(null===(e=document.body)||void 0===e?void 0:e.scrollTop)||(null===(t=document.documentElement)||void 0===t?void 0:t.scrollTop)||0,x:(null===(r=document.body)||void 0===r?void 0:r.scrollLeft)||(null===(n=document.documentElement)||void 0===n?void 0:n.scrollLeft)||0}},w=function(e){return!e||e instanceof Document?D():{x:e.scrollLeft>=0?e.scrollLeft:D().x,y:e.scrollTop>=0?e.scrollTop:D().y}},k=function(e){var t=e.elementRect,r=e.containerRect,n=e.tolerance,i=void 0===n?{x:0,y:0}:n,o=[];return t.top-i.y<r.top&&o.push("top"),t.left-i.x<r.left&&o.push("left"),t.bottom+i.y>r.bottom&&o.push("bottom"),t.right+i.y>r.right&&o.push("right"),o},E=function(e){var t=e.event;return{x:t.clientX,y:t.clientY}},x=function(e){var t={x:0,y:0},r=window.getComputedStyle(e);if(!r.transform||"none"===r.transform)return t;if(r.transform.indexOf("3d")>=0){var n=r.transform.trim().match(/matrix3d\((.*?)\)/);if(n&&n.length){var i,o=null===(i=n[1])||void 0===i?void 0:i.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=r.transform.trim().match(/matrix\((.*?)\)/);if(s&&s.length){var a,l=null===(a=s[1])||void 0===a?void 0:a.split(",");t.x=parseInt(l[4])||0,t.y=parseInt(l[5])||0}return t},P=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return x(e);var r={x:0,y:0},n=t.trim().match(/translate[3dD]*?\(.*?\)/);if(n){var i,o=null===(i=n[0])||void 0===i?void 0:i.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");r.x=parseInt(a[0])||0,r.y=parseInt(a[1])||0}}return r.x||r.x?r:x(e)}(e):function(e){var t=e.style,r={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!r.x&&!r.x){var n=window.getComputedStyle(e);return{x:parseInt(n.left)||0,y:parseInt(n.top)||0}}return r}(e)},I=function(e){var t=e.computedStyle,r=e.node,n=t.position;r instanceof HTMLDocument||("absolute"===n||"relative"===n||"fixed"===n)||(r.style.position="relative")},A=function(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top},C=function(e){var t=e.element,r=e.posDirection,n=e.containerRect,i=e.useTransform,o=P(t,i),s=y(o,"+",r);L(t,s,i);var a=t.getBoundingClientRect();!function(e){var t=e.element,r=e.edges,n=e.elementRect,i=e.containerRect,o=e.elementPos,s=e.useTransform;r.includes("top")&&L(t,{y:o.y+i.top-n.top,x:o.x},s),r.includes("left")&&L(t,{y:o.y,x:o.x+i.left-n.left},s),r.includes("bottom")&&L(t,{y:o.y+i.bottom-n.bottom,x:o.x},s),r.includes("right")&&L(t,{y:o.y,x:o.x+i.right-n.right},s)}({element:t,edges:k({elementRect:a,containerRect:n}),elementRect:a,containerRect:n,elementPos:s,useTransform:i})},L=function(e,t,r){if(r){var n=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(n.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},T=function(e){for(var t=e.subscribe,r=e.publish,o=e.Interaction,s=e.SelectedSet,a=function(){var e=S(c[l],2),a=e[0],u=e[1];["pre",!1].forEach((function(e){return t(e?"".concat(a,":").concat(e):a,(function(t){return u.forEach((function(a){return(!a.condition||a.condition(t))&&r(e?"".concat(e).concat(a.name):a.name,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({items:s.elements,isDragging:o.isDragging},t))}))}))}))},l=0,c=Object.entries({"Selected:added":[{name:"elementselect"}],"Selected:removed":[{name:"elementunselect"}],"Area:scroll":[{name:"autoscroll"}],"Interaction:start":[{name:"dragstart"}],"Interaction:update":[{name:"dragmove",condition:function(e){return e.event}}],"Interaction:end":[{name:"callback"}],"Drag:keyboardDrag":[{name:"dragstart"},{name:"dragmove"}]});l<c.length;l++)a()},V=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:m(e):[]},N=function(e,t){e.style.left="".concat(t.left,"px"),e.style.top="".concat(t.top,"px"),e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px")},M=function(){function t(r){var i,o,s,a=this,l=r.area,c=r.PS,u=r.zoom;e(this,t),n(this,"_modificationCallback",void 0),n(this,"_modificationObserver",void 0),n(this,"_zoom",void 0),n(this,"_node",void 0),n(this,"_parentNodes",void 0),n(this,"_computedStyle",void 0),n(this,"_computedBorder",void 0),n(this,"_rect",void 0),n(this,"start",(function(){var e,t,r;e=a.parentNodes,t=a._modificationCallback,r=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){r.observe(e,{childList:0!==t,attributes:!0})}))})),n(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),n(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),n(this,"scroll",(function(e,t){!function(e,t,r){if(t.length){var n=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,i=e instanceof HTMLDocument?n||document.body:e,o=t.includes("top")&&i.scrollTop>0,s=t.includes("bottom")&&i.scrollTop<i.scrollHeight,a=t.includes("left")&&i.scrollLeft>0,l=t.includes("right")&&i.scrollLeft<i.scrollWidth;o&&(i.scrollTop-=1*r),s&&(i.scrollTop+=1*r),a&&(i.scrollLeft-=1*r),l&&(i.scrollLeft+=1*r)}}(a._node,e,t),a.PubSub.publish("Area:scroll",{scroll_directions:e,scroll_multiplier:t})})),this._node=l,this._zoom=u,this.PubSub=c,I({computedStyle:this.computedStyle,node:this._node}),this._modificationCallback=(i=function(e){a.reset(),a.PubSub.publish("Area:modified",{event:e,item:a})},o=60,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=function(){s=null,i.apply(void 0,t)};clearTimeout(s),s=setTimeout(n,o)}),this._modificationObserver=new MutationObserver(this._modificationCallback),setTimeout((function(){a.reset(),a.PubSub.publish("Area:modified",{event:event,item:a})})),this.PubSub.subscribe("Interaction:init",this.start),this.PubSub.subscribe("Interaction:end",this.reset)}return r(t,[{key:"HTMLNode",get:function(){return this._node}},{key:"computedBorder",get:function(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}},{key:"computedStyle",get:function(){return this._computedStyle?this._computedStyle:this.HTMLNode instanceof HTMLDocument?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=function(e,t){if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var r=e.getBoundingClientRect();return{top:r.top,left:r.left,bottom:r.bottom,right:r.right,width:(e.clientWidth||r.width)*t,height:(e.clientHeight||r.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=null===(r=t[n])||void 0===r?void 0:r.parentNode;return i?(t.push(i),e(t,++n)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),K=function(){function t(r){var i=this,o=r.DS,s=r.dragKeys,a=r.draggability,l=r.keyboardDrag,c=r.keyboardDragSpeed,u=r.useTransform,d=r.zoom;e(this,t),n(this,"_useTransform",void 0),n(this,"_prevCursorPos",void 0),n(this,"_prevScrollPos",void 0),n(this,"_elements",[]),n(this,"_draggability",void 0),n(this,"_dragKeys",void 0),n(this,"_dragKeysFlat",void 0),n(this,"_keyboardDrag",void 0),n(this,"_keyboardDragSpeed",void 0),n(this,"_zoom",void 0),n(this,"keyboardDrag",(function(e){var t=e.event,r=e.key;if(i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability&&!i.DS.continue){i.DS.publish("Interaction:start",{event:t,isDragging:!0,isDraggingKeyboard:!0}),i._elements=i.DS.getSelection(),i.handleZIndex(!0);var n=function(e){var t=e.shiftKey,r=e.keyboardDragSpeed,n=e.zoom,i=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*r*n:r*n;return o.left.includes(i)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],r)),o.right.includes(i)&&(c.x=s.x||u,t||s.x||!a||l(["right"],r)),o.up.includes(i)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],r)),o.down.includes(i)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],r)),c}({shiftKey:i.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:i._keyboardDragSpeed,zoom:i._zoom,key:r,scrollCallback:i.DS.Area.scroll,scrollDiff:i._scrollDiff,canScroll:i.DS.stores.ScrollStore.canScroll,dragKeys:i._dragKeys});i._elements.forEach((function(e){return C({element:e,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})})),i.DS.publish("Interaction:update",{event:t,isDragging:!0,isDraggingKeyboard:!0})}})),n(this,"keyboardEnd",(function(e){var t=e.event,r=e.key;i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability&&i.DS.publish("Interaction:end",{event:t,isDragging:i._draggability,isDraggingKeyboard:!0})})),n(this,"start",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;t&&!r&&(i._prevCursorPos=null,i._prevScrollPos=null,i._elements=i.DS.getSelection(),i.handleZIndex(!0))})),n(this,"stop",(function(e){null!=e&&e.isKeyboard||(i._prevCursorPos=null,i._prevScrollPos=null,i.handleZIndex(!1),i._elements=[])})),n(this,"update",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;if(t&&i._elements.length&&!r&&!i.DS.continue){var n=y(i._cursorDiff,"+",i._scrollDiff);i._elements.forEach((function(e){return C({element:e,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})}))}})),n(this,"handleZIndex",(function(e){i._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=u,this._keyboardDragSpeed=c,this._keyboardDrag=l,this._zoom=d,this._draggability=a,this._dragKeys={up:s.up.map((function(e){return e.toLowerCase()})),down:s.down.map((function(e){return e.toLowerCase()})),left:s.left.map((function(e){return e.toLowerCase()})),right:s.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(m(this._dragKeys.up),m(this._dragKeys.down),m(this._dragKeys.left),m(this._dragKeys.right)),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:end",this.stop),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("KeyStore:down",this.keyboardDrag),this.DS.subscribe("KeyStore:up",this.keyboardEnd)}return r(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?y(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}},{key:"_scrollDiff",get:function(){var e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?y(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),O=function(){function t(r){var i=this,o=r.areaElement,s=r.DS,a=r.draggability,l=r.immediateDrag;e(this,t),n(this,"_areaElement",void 0),n(this,"_draggability",void 0),n(this,"_immediateDrag",void 0),n(this,"isInteracting",void 0),n(this,"isDragging",void 0),n(this,"init",(function(){i.stop(),i._areaElement.addEventListener("mousedown",i.start),i._areaElement.addEventListener("touchstart",i.start,{passive:!1}),i.DS.publish("Interaction:init",{})})),n(this,"start",(function(e){"touchstart"===e.type&&e.preventDefault(),i._canInteract(e)&&(i.isInteracting=!0,i.isDragging=i.isDragEvent(e),i.DS.publish("Interaction:start",{event:e,isDragging:i.isDragging}),document.addEventListener("mouseup",i.reset),document.addEventListener("touchend",i.reset))})),n(this,"isDragEvent",(function(e){return!(!i._draggability||i.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!i.DS.SelectableSet.has(e.target))&&(i._immediateDrag&&(i.DS.SelectedSet.size?i.DS.SelectedSet.has(e.target)||(i.DS.SelectedSet.clear(),i.DS.SelectedSet.add(e.target)):i.DS.SelectedSet.add(e.target)),!!i.DS.SelectedSet.has(e.target))})),n(this,"onClick",(function(e){var t=e.event;if(i._canInteract(t)&&!(t.detail>0)){var r=i.DS,n=r.stores,o=n.PointerStore,s=n.KeyStore,a=r.SelectableSet,l=r.SelectedSet,c=r.publish;o.start(t);var u=t.target;a.has(u)&&(s.isMultiSelectKeyPressed(t)||l.clear(),l.toggle(u),c("Interaction:end",{event:t,isDragging:i.isDragging}))}})),n(this,"stop",(function(){i.isInteracting=!1,i.isDragging=!1,i._areaElement.removeEventListener("mousedown",i.start),i._areaElement.removeEventListener("touchstart",i.start,{passive:!1}),document.removeEventListener("mouseup",i.reset),document.removeEventListener("touchend",i.reset)})),n(this,"update",(function(e){var t=e.event,r=e.scroll_directions,n=e.scroll_multiplier;i.isInteracting&&i.DS.publish("Interaction:update",{event:t,scroll_directions:r,scroll_multiplier:n,isDragging:i.isDragging})})),n(this,"reset",(function(e){var t=i.isDragging;i.stop(),i.init(),i.DS.publish("Interaction:end",{event:e,isDragging:t})})),this._areaElement=o,this._draggability=a,this._immediateDrag=l,this.DS=s,this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Area:scroll",this.update)}return r(t,[{key:"_canInteract",value:function(e){return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target))}}]),t}(),z=function t(){var r=this;e(this,t),n(this,"subscribers",{}),n(this,"subscribe",(function(e,t){return Array.isArray(r.subscribers[e])||(r.subscribers[e]=[]),r.subscribers[e].push(t),r.subscribers[e].length-1})),n(this,"unsubscribe",(function(e,t,n){n>=0?r.subscribers[e].splice(n,1):t&&(r.subscribers[e]=r.subscribers[e].filter((function(e){return e!==t})))})),n(this,"publish",(function(e,t){var n,i;Array.isArray(r.subscribers[e])&&(null===(n=r.subscribers["".concat(e,":pre")])||void 0===n||n.forEach((function(e){return e(t)})),null===(i=r.subscribers[e])||void 0===i||i.forEach((function(e){return e(t)})))}))},j=function(t){o(a,u(Set));var i=f(a);function a(t){var r,o=t.elements,s=t.className,l=t.hoverClassName,c=t.draggability,u=t.useTransform,h=t.DS;return e(this,a),n(d(r=i.call(this)),"_initElements",void 0),n(d(r),"_className",void 0),n(d(r),"_hoverClassName",void 0),n(d(r),"_useTransform",void 0),n(d(r),"_draggability",void 0),n(d(r),"init",(function(){return r._initElements.forEach((function(e){return r.add(e)}))})),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"_onClick",(function(e){return r.DS.publish("Selectable:click",{event:e})})),n(d(r),"_onPointer",(function(e){return r.DS.publish("Selectable:pointer",{event:e})})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=h,r._initElements=V(o),r._className=s,r._hoverClassName=l,r._useTransform=u,r._draggability=c,r.DS.subscribe("Interaction:init",r.init),r}return r(a,[{key:"add",value:function(e){return e.classList.add(this._className),e.addEventListener("click",this._onClick),e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this._draggability&&!this._useTransform&&I({computedStyle:window.getComputedStyle(e),node:e}),v(s(a.prototype),"add",this).call(this,e)}},{key:"delete",value:function(e){return e.classList.remove(this._className),e.classList.remove(this._hoverClassName),e.removeEventListener("click",this._onClick),e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),v(s(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(),H=function(t){o(a,u(Set));var i=f(a);function a(t){var r,o=t.className,s=t.DS;return e(this,a),n(d(r=i.call(this)),"_className",void 0),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=s,r._className=o,r}return r(a,[{key:"add",value:function(e){if(!v(s(a.prototype),"has",this).call(this,e))return v(s(a.prototype),"add",this).call(this,e),e.classList.add(this._className),this.DS.publish("Selected:added",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+1),this}},{key:"delete",value:function(e){if(v(s(a.prototype),"has",this).call(this,e)){var t=v(s(a.prototype),"delete",this).call(this,e);return e.classList.remove(this._className),this.DS.publish("Selected:removed",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)-1),t}}},{key:"toggle",value:function(e){return this.has(e)?this.delete(e):this.add(e),e}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(),R=function(){function t(r){var i=this,o=r.DS,s=r.hoverClassName,a=r.multiSelectToggling;e(this,t),n(this,"_prevSelectedSet",void 0),n(this,"_hoverClassName",void 0),n(this,"_multiSelectToggling",void 0),n(this,"start",(function(e){var t=e.event;e.isDragging||(i._storePrevious(t),i._handleInsideSelection(!0,t))})),n(this,"update",(function(e){e.isDragging||i.DS.continue||i._handleInsideSelection()})),n(this,"_handleInsideSelection",(function(e,t){for(var r=i.DS,n=r.SelectableSet,o=r.SelectorArea,s=r.Selector,a=n.elements.map((function(e){return[e,e.getBoundingClientRect()]})),l=[],c=[],u=0,d=a.length;u<d;u++)o.isInside(a[u][0],a[u][1])&&(A(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=i.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&i._multiSelectToggling;l.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.multiSelectionToggle,i=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!r||(i.has(t)?n&&i.delete(t):i.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.SelectedSet,i=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!r)return!1;var s=n.has(t),a=i.has(t);s&&!a?n.delete(t):!s&&a&&n.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName,PrevSelectedSet:i._prevSelectedSet})}))})),this._hoverClassName=s,this._multiSelectToggling=a,this.DS=o,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return r(t,[{key:"_storePrevious",value:function(e){var t=this.DS,r=t.stores.KeyStore,n=t.SelectedSet;r.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(n):this._prevSelectedSet=new Set}}]),t}(),B=function(){function t(r){var i=this,o=r.DS,s=r.selector,a=r.selectorClass,l=r.customStyles;e(this,t),n(this,"_rect",void 0),n(this,"start",(function(e){if(!e.isDragging){var t=i.DS.stores.PointerStore.initialValArea;N(i.HTMLNode,_(t,1)),i.HTMLNode.style.display="block",i._rect=null}})),n(this,"stop",(function(){i.HTMLNode.style.width="0",i.HTMLNode.style.height="0",i.HTMLNode.style.display="none"})),n(this,"update",(function(e){if(!e.isDragging&&!i.DS.continue){var t=i.DS.stores,r=t.ScrollStore,n=t.PointerStore,o=function(e){var t=e.scrollAmount,r=e.initialPointerPos,n=e.pointerPos,i={};return n.x>r.x-t.x?(i.left=r.x-t.x,i.width=n.x-r.x+t.x):(i.left=n.x,i.width=r.x-n.x-t.x),n.y>r.y-t.y?(i.top=r.y-t.y,i.height=n.y-r.y+t.y):(i.top=n.y,i.height=r.y-n.y-t.y),i}({scrollAmount:r.scrollAmount,initialPointerPos:n.initialValArea,pointerPos:n.currentValArea});N(i.HTMLNode,o),i._rect=null}})),this.DS=o,this.HTMLNode=s||function(e){var t=document.createElement("div");return t.style.position="absolute",e||(t.style.background="rgba(0, 0, 255, 0.1)",t.style.border="1px solid rgba(0, 0, 255, 0.45)",t.style.display="none",t.style.pointerEvents="none"),t}(l),this.HTMLNode.classList.add(a),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return r(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),U=function(){function t(r){var i=this,o=r.DS,s=r.selectorAreaClass,a=r.autoScrollSpeed,l=r.overflowTolerance;e(this,t),n(this,"_autoScrollSpeed",void 0),n(this,"_scrollInterval",void 0),n(this,"_rect",void 0),n(this,"currentEdges",[]),n(this,"_overflowTolerance",void 0),n(this,"start",(function(){return i.applyElements("append")})),n(this,"applyElements",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",t=document.body?"body":"documentElement",r="".concat(e,"Child");i.HTMLNode[r](i.DS.Selector.HTMLNode),document[t][r](i.HTMLNode)})),n(this,"updatePos",(function(){i._rect=null;var e=i.DS.Area.rect,t=i.DS.Area.computedBorder,r=i.HTMLNode.style,n="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");r.top!==n&&(r.top=n),r.left!==o&&(r.left=o),r.width!==s&&(r.width=s),r.height!==a&&(r.height=a)})),n(this,"stop",(function(e){i.stopAutoScroll(),e&&i.applyElements("remove")})),n(this,"startAutoScroll",(function(){i.currentEdges=[],i._scrollInterval=setInterval((function(){return i.handleAutoScroll()}),16)})),n(this,"handleAutoScroll",(function(){if(!i.DS.continue){var e=i.DS,t=e.stores.PointerStore,r=e.Area;i.currentEdges=k({elementRect:_(t.currentVal),containerRect:i.rect,tolerance:i._overflowTolerance}),i.currentEdges.length&&r.scroll(i.currentEdges,i._autoScrollSpeed)}})),n(this,"stopAutoScroll",(function(){i.currentEdges=[],clearInterval(i._scrollInterval)})),n(this,"isInside",(function(e,t){return!(!i.DS.Area.HTMLNode.contains(e)||!i.DS.stores.ScrollStore.canScroll)||A(i.rect,t||e.getBoundingClientRect())})),this._autoScrollSpeed=a,this._overflowTolerance=l,this.DS=o,this.HTMLNode=function(e){var t=document.createElement("div");return t.style.position="fixed",t.style.overflow="hidden",t.style.pointerEvents="none",t.style.zIndex="999999999999999999",t.classList.add(e),t}(s),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:init",this.start),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){i.updatePos(),i.stopAutoScroll()}))}return r(t,[{key:"isClicked",value:function(){var e=this.DS.stores.PointerStore;return A({left:e.initialVal.x,top:e.initialVal.y,right:e.initialVal.x,bottom:e.initialVal.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),W=function(){function t(r){var i=this,o=r.DS,s=r.multiSelectKeys,a=r.multiSelectMode;e(this,t),n(this,"_multiSelectMode",void 0),n(this,"_multiSelectKeys",void 0),n(this,"_currentValues",new Set),n(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),n(this,"init",(function(){document.addEventListener("keydown",i.keydown),document.addEventListener("keyup",i.keyup),window.addEventListener("blur",i.reset)})),n(this,"keydown",(function(e){var t=e.key.toLowerCase();i._currentValues.add(t),i.DS.publish("KeyStore:down",{event:e,key:t})})),n(this,"keyup",(function(e){var t=e.key.toLowerCase();i._currentValues.delete(t),i.DS.publish("KeyStore:up",{event:e,key:t})})),n(this,"stop",(function(){document.removeEventListener("keydown",i.keydown),document.removeEventListener("keyup",i.reset),window.removeEventListener("blur",i.reset),i.reset()})),n(this,"reset",(function(){return i._currentValues.clear()})),this.DS=o,this._multiSelectMode=a,this._multiSelectKeys=s.map((function(e){var t={ctrlKey:"Control",shiftKey:"Shift",metaKey:"Meta"}[e];return t?(console.warn("[DragSelect] ".concat(e,' is deprecated. Use "').concat(t,'" instead. Act Now!. See docs for more info')),t.toLowerCase()):e.toLowerCase()})),this.DS.subscribe("Interaction:init",this.init)}return r(t,[{key:"isMultiSelectKeyPressed",value:function(e){var t=this;return!!this._multiSelectMode||(!!this.currentValues.some((function(e){return t._multiSelectKeys.includes(e)}))||!(!e||!this._multiSelectKeys.some((function(r){return e[t._keyMapping[r]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),F=function(){function t(r){var i=this,o=r.DS;e(this,t),n(this,"_isMouseInteraction",!1),n(this,"_initialValArea",void 0),n(this,"_currentValArea",void 0),n(this,"_lastValArea",void 0),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_lastVal",void 0),n(this,"_lastTouch",void 0),n(this,"init",(function(){document.addEventListener("mousemove",i.update),document.addEventListener("touchmove",i.update,{passive:!1})})),n(this,"update",(function(e){e&&(i.currentVal=E({event:i._normalizedEvent(e)}),i._isMouseInteraction&&i.DS.publish("PointerStore:updated",{event:e}))})),n(this,"stop",(function(){document.removeEventListener("mousemove",i.update),document.removeEventListener("touchmove",i.update,{passive:!1}),setTimeout((function(){return i._isMouseInteraction=!1}),100)})),n(this,"reset",(function(e){e&&(i.currentVal=i.lastVal=E({event:i._normalizedEvent(e)}),i.stop(),i.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return i.reset(t)}))}return r(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=E({event:this._normalizedEvent(e)}))}},{key:"_normalizedEvent",value:function(e){return"touches"in e&&"touchend"!==e.type&&(this._lastTouch=e),"touches"in e?this._lastTouch.touches[0]:e}},{key:"initialValArea",get:function(){return this._initialValArea?this._initialValArea:{x:0,y:0}}},{key:"currentValArea",get:function(){return this._currentValArea?this._currentValArea:{x:0,y:0}}},{key:"lastValArea",get:function(){return this._lastValArea?this._lastValArea:{x:0,y:0}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}},set:function(e){this._initialVal=e,this._initialValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(e){this._currentVal=e,this._currentValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(e){this._lastVal=e,this._lastValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}}]),t}(),Z=function(){function t(r){var i=this,o=r.DS,s=r.areaElement,a=r.zoom;e(this,t),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_areaElement",void 0),n(this,"_canScroll",void 0),n(this,"init",(function(){return i._areaElement.addEventListener("scroll",i.update)})),n(this,"start",(function(){i._currentVal=i._initialVal=w(i._areaElement),i._areaElement.addEventListener("scroll",i.update)})),n(this,"update",(function(){return i._currentVal=w(i._areaElement)})),n(this,"stop",(function(){i._areaElement.removeEventListener("scroll",i.update),i._initialVal={x:0,y:0},i._canScroll=null})),n(this,"reset",(function(){i.stop(),i.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return i.start()})),this.DS.subscribe("Interaction:end",(function(){return i.reset()}))}return r(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=w(e)).x||t.y||(e instanceof HTMLDocument?e.body?e.body.scrollTop=1:e.documentElement.scrollTop=1:e.scrollTop=1)));var e,t}},{key:"scrollAmount",get:function(){var e,t=y(this.currentVal,"-",this.initialVal),r={x:e=this.zoom,y:e},n=y(y(t,"*",r),"-",t);return{x:t.x+n.x,y:t.y+n.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=w(this._areaElement)),this._currentVal}}]),t}(),G=function(){function t(r){var i=this,o=r.area,s=void 0===o?document:o,a=r.selectables,l=void 0===a?[]:a,c=r.autoScrollSpeed,u=void 0===c?5:c,d=r.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=r.zoom,v=void 0===f?1:f,S=r.customStyles,m=void 0!==S&&S,g=r.multiSelectMode,p=void 0!==g&&g,y=r.multiSelectToggling,b=void 0===y||y,_=r.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,w=r.selector,k=void 0===w?void 0:w,E=r.draggability,x=void 0===E||E,P=r.immediateDrag,I=void 0===P||P,A=r.keyboardDrag,C=void 0===A||A,L=r.dragKeys,V=r.keyboardDragSpeed,N=void 0===V?10:V,G=r.useTransform,X=void 0===G||G,Y=r.hoverClass,$=void 0===Y?"ds-hover":Y,q=r.selectableClass,J=void 0===q?"ds-selectable":q,Q=r.selectedClass,ee=void 0===Q?"ds-selected":Q,te=r.selectorClass,re=void 0===te?"ds-selector":te,ne=r.selectorAreaClass,ie=void 0===ne?"ds-selector-area":ne,oe=r.callback,se=r.onDragMove,ae=r.onDragStartBegin,le=r.onDragStart,ce=r.onElementSelect,ue=r.onElementUnselect;e(this,t),n(this,"continue",!1),n(this,"start",(function(){return i.Interaction.init()})),n(this,"break",(function(){return i.continue=!0})),n(this,"getSelection",(function(){return i.SelectedSet.elements})),n(this,"getSelectables",(function(){return i.SelectableSet.elements})),n(this,"getInitialCursorPosition",(function(){return i.stores.PointerStore.initialVal})),n(this,"getCurrentCursorPosition",(function(){return i.stores.PointerStore.currentVal})),n(this,"getPreviousCursorPosition",(function(){return i.stores.PointerStore.lastVal})),n(this,"getInitialCursorPositionArea",(function(){return i.stores.PointerStore.initialValArea})),n(this,"getCurrentCursorPositionArea",(function(){return i.stores.PointerStore.currentValArea})),n(this,"getPreviousCursorPositionArea",(function(){return i.stores.PointerStore.lastValArea})),n(this,"isMultiSelect",(function(e){return i.stores.KeyStore.isMultiSelectKeyPressed(e)})),n(this,"isDragging",(function(){return i.Interaction.isDragging})),this.PubSub=new z,this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:oe,onDragMove:se,onDragStart:le,onDragStartBegin:ae,onElementSelect:ce,onElementUnselect:ue}),this.stores={PointerStore:new F({DS:this}),ScrollStore:new Z({DS:this,areaElement:s,zoom:v}),KeyStore:new W({DS:this,multiSelectKeys:D,multiSelectMode:p})},this.Area=new M({area:s,PS:this.PubSub,zoom:v}),this.Selector=new B({DS:this,selector:k,selectorClass:re,customStyles:m}),this.SelectorArea=new U({DS:this,selectorAreaClass:ie,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new j({elements:l,DS:this,className:J,hoverClassName:$,useTransform:X,draggability:x}),this.SelectedSet=new H({DS:this,className:ee}),this.Selection=new R({DS:this,hoverClassName:$,multiSelectToggling:b}),this.Drag=new K({DS:this,draggability:x,useTransform:X,keyboardDrag:C,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},L),zoom:v,keyboardDragSpeed:N}),this.Interaction=new O({areaElement:s,DS:this,draggability:x,immediateDrag:I}),T({subscribe:this.subscribe,publish:this.publish,SelectedSet:this.SelectedSet,Interaction:this.Interaction}),this.subscribe("Interaction:end",(function(){return i.continue=!1})),this.start()}return r(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,r=e.onDragMove,n=e.onDragStart,i=e.onDragStartBegin,o=e.onElementSelect,s=e.onElementUnselect,a=function(e,t){return console.warn("[DragSelect] ".concat(e,' is deprecated. Use DragSelect.subscribe("').concat(t,'", (callbackObject) => {}) instead. Act Now! See docs for more info'))};t&&(a("callback","callback"),this.subscribe("callback",(function(e){var r=e.items,n=(e.item,e.event);return t(r,n)}))),r&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),i&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return i(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,r=e.event;return o(t,r)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,r=e.event;return s(t,r)})))}},{key:"stop",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(e),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear()}},{key:"addSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(V(e)),r||this.addSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(V(e)),r&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return V(e).forEach((function(i){return t.SelectedSet.has(i)?t.removeSelection(e,r,n):t.addSelection(e,r,n)})),r&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,r),this.getSelection()}},{key:"clearSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=V(e);return this.SelectableSet.addAll(r),t&&this.SelectedSet.addAll(r),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,r)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(V(e)),t&&this.removeSelection(e),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var r=t?this.getCurrentCursorPositionArea():this.getCurrentCursorPosition(),n=e?t?this.getPreviousCursorPositionArea():this.getPreviousCursorPosition():t?this.getInitialCursorPositionArea():this.getInitialCursorPosition();return y(r,"-",n)}}]),t}();export default G; | ||
function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function c(e,t,r){return(c=l()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&a(i,r.prototype),i}).apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return c(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)})(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?d(e):t}function f(e){var t=l();return function(){var r,n=s(e);if(t){var i=s(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return h(this,r)}}function v(e,t,r){return(v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}return r}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var y=function(e,t,r){var n=e.x,i=e.y,o=r.x,s=r.y;return{"+":{x:n+o,y:i+s},"-":{x:n-o,y:i-s},"*":{x:n*o,y:i*s},"/":{x:n/o,y:i/s}}[t]},b=function(e){return{x:e.left,y:e.top}},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}},D=function(){var e,t,r,n;return{y:(null===(e=document.body)||void 0===e?void 0:e.scrollTop)||(null===(t=document.documentElement)||void 0===t?void 0:t.scrollTop)||0,x:(null===(r=document.body)||void 0===r?void 0:r.scrollLeft)||(null===(n=document.documentElement)||void 0===n?void 0:n.scrollLeft)||0}},w=function(e){return!e||e instanceof Document?D():{x:e.scrollLeft>=0?e.scrollLeft:D().x,y:e.scrollTop>=0?e.scrollTop:D().y}},k=function(e){var t=e.elementRect,r=e.containerRect,n=e.tolerance,i=void 0===n?{x:0,y:0}:n,o=[];return t.top-i.y<r.top&&o.push("top"),t.left-i.x<r.left&&o.push("left"),t.bottom+i.y>r.bottom&&o.push("bottom"),t.right+i.y>r.right&&o.push("right"),o},P=function(e){var t={x:0,y:0},r=window.getComputedStyle(e);if(!r.transform||"none"===r.transform)return t;if(r.transform.indexOf("3d")>=0){var n=r.transform.trim().match(/matrix3d\((.*?)\)/);if(n&&n.length){var i,o=null===(i=n[1])||void 0===i?void 0:i.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=r.transform.trim().match(/matrix\((.*?)\)/);if(s&&s.length){var a,l=null===(a=s[1])||void 0===a?void 0:a.split(",");t.x=parseInt(l[4])||0,t.y=parseInt(l[5])||0}return t},E=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return P(e);var r={x:0,y:0},n=t.trim().match(/translate[3dD]*?\(.*?\)/);if(n){var i,o=null===(i=n[0])||void 0===i?void 0:i.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");r.x=parseInt(a[0])||0,r.y=parseInt(a[1])||0}}return r.x||r.x?r:P(e)}(e):function(e){var t=e.style,r={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!r.x&&!r.x){var n=window.getComputedStyle(e);return{x:parseInt(n.left)||0,y:parseInt(n.top)||0}}return r}(e)},x=function(e){var t=e.computedStyle,r=e.node,n=t.position;r instanceof HTMLDocument||("absolute"===n||"relative"===n||"fixed"===n)||(r.style.position="relative")},A=function(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top},I=function(e){var t=e.element,r=e.posDirection,n=e.containerRect,i=e.useTransform,o=E(t,i),s=y(o,"+",r);C(t,s,i);var a=t.getBoundingClientRect();!function(e){var t=e.element,r=e.edges,n=e.elementRect,i=e.containerRect,o=e.elementPos,s=e.useTransform;r.includes("top")&&C(t,{y:o.y+i.top-n.top,x:o.x},s),r.includes("left")&&C(t,{y:o.y,x:o.x+i.left-n.left},s),r.includes("bottom")&&C(t,{y:o.y+i.bottom-n.bottom,x:o.x},s),r.includes("right")&&C(t,{y:o.y,x:o.x+i.right-n.right},s)}({element:t,edges:k({elementRect:a,containerRect:n}),elementRect:a,containerRect:n,elementPos:s,useTransform:i})},C=function(e,t,r){if(r){var n=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(n.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},L=function(e){for(var t=e.subscribe,r=e.publish,o=e.Interaction,s=e.SelectedSet,a=function(){var e=S(c[l],2),a=e[0],u=e[1];["pre",!1].forEach((function(e){return t(e?"".concat(a,":").concat(e):a,(function(t){return u.forEach((function(a){return(!a.condition||a.condition(t))&&r(e?"".concat(e).concat(a.name):a.name,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({items:s.elements,isDragging:o.isDragging},t))}))}))}))},l=0,c=Object.entries({"Selected:added":[{name:"elementselect"}],"Selected:removed":[{name:"elementunselect"}],"Area:scroll":[{name:"autoscroll"}],"Interaction:start":[{name:"dragstart"}],"Interaction:update":[{name:"dragmove",condition:function(e){return e.event}}],"Interaction:end":[{name:"callback"}],"Drag:keyboardDrag":[{name:"dragstart"},{name:"dragmove"}]});l<c.length;l++)a()},T=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:m(e):[]},V=function(e,t){e.style.left="".concat(t.left,"px"),e.style.top="".concat(t.top,"px"),e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px")},N=function(){function t(r){var i,o,s,a=this,l=r.area,c=r.PS,u=r.zoom;e(this,t),n(this,"_modificationCallback",void 0),n(this,"_modificationObserver",void 0),n(this,"_zoom",void 0),n(this,"_node",void 0),n(this,"_parentNodes",void 0),n(this,"_computedStyle",void 0),n(this,"_computedBorder",void 0),n(this,"_rect",void 0),n(this,"start",(function(){var e,t,r;e=a.parentNodes,t=a._modificationCallback,r=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){r.observe(e,{childList:0!==t,attributes:!0})}))})),n(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),n(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),n(this,"scroll",(function(e,t){!function(e,t,r){if(t.length){var n=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,i=e instanceof HTMLDocument?n||document.body:e,o=t.includes("top")&&i.scrollTop>0,s=t.includes("bottom")&&i.scrollTop<i.scrollHeight,a=t.includes("left")&&i.scrollLeft>0,l=t.includes("right")&&i.scrollLeft<i.scrollWidth;o&&(i.scrollTop-=1*r),s&&(i.scrollTop+=1*r),a&&(i.scrollLeft-=1*r),l&&(i.scrollLeft+=1*r)}}(a._node,e,t),a.PubSub.publish("Area:scroll",{scroll_directions:e,scroll_multiplier:t})})),this._node=l,this._zoom=u,this.PubSub=c,x({computedStyle:this.computedStyle,node:this._node}),this._modificationCallback=(i=function(e){a.reset(),a.PubSub.publish("Area:modified",{event:e,item:a})},o=60,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=function(){s=null,i.apply(void 0,t)};clearTimeout(s),s=setTimeout(n,o)}),this._modificationObserver=new MutationObserver(this._modificationCallback),setTimeout((function(){a.reset(),a.PubSub.publish("Area:modified",{event:event,item:a})})),this.PubSub.subscribe("Interaction:init",this.start),this.PubSub.subscribe("Interaction:end",this.reset)}return r(t,[{key:"HTMLNode",get:function(){return this._node}},{key:"computedBorder",get:function(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}},{key:"computedStyle",get:function(){return this._computedStyle?this._computedStyle:this.HTMLNode instanceof HTMLDocument?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=function(e,t){if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var r=e.getBoundingClientRect();return{top:r.top,left:r.left,bottom:r.bottom,right:r.right,width:(e.clientWidth||r.width)*t,height:(e.clientHeight||r.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=null===(r=t[n])||void 0===r?void 0:r.parentNode;return i?(t.push(i),e(t,++n)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),M=function(){function t(r){var i=this,o=r.DS,s=r.dragKeys,a=r.draggability,l=r.keyboardDrag,c=r.keyboardDragSpeed,u=r.useTransform,d=r.zoom;e(this,t),n(this,"_useTransform",void 0),n(this,"_prevCursorPos",void 0),n(this,"_prevScrollPos",void 0),n(this,"_elements",[]),n(this,"_draggability",void 0),n(this,"_dragKeys",void 0),n(this,"_dragKeysFlat",void 0),n(this,"_keyboardDrag",void 0),n(this,"_keyboardDragSpeed",void 0),n(this,"_zoom",void 0),n(this,"keyboardDrag",(function(e){var t=e.event,r=e.key;if(i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability&&!i.DS.continue){i.DS.publish("Interaction:start",{event:t,isDragging:!0,isDraggingKeyboard:!0}),i._elements=i.DS.getSelection(),i.handleZIndex(!0);var n=function(e){var t=e.shiftKey,r=e.keyboardDragSpeed,n=e.zoom,i=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*r*n:r*n;return o.left.includes(i)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],r)),o.right.includes(i)&&(c.x=s.x||u,t||s.x||!a||l(["right"],r)),o.up.includes(i)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],r)),o.down.includes(i)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],r)),c}({shiftKey:i.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:i._keyboardDragSpeed,zoom:i._zoom,key:r,scrollCallback:i.DS.Area.scroll,scrollDiff:i._scrollDiff,canScroll:i.DS.stores.ScrollStore.canScroll,dragKeys:i._dragKeys});i._elements.forEach((function(e){return I({element:e,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})})),i.DS.publish("Interaction:update",{event:t,isDragging:!0,isDraggingKeyboard:!0})}})),n(this,"keyboardEnd",(function(e){var t=e.event,r=e.key;i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability&&i.DS.publish("Interaction:end",{event:t,isDragging:i._draggability,isDraggingKeyboard:!0})})),n(this,"start",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;t&&!r&&(i._prevCursorPos=null,i._prevScrollPos=null,i._elements=i.DS.getSelection(),i.handleZIndex(!0))})),n(this,"stop",(function(e){null!=e&&e.isKeyboard||(i._prevCursorPos=null,i._prevScrollPos=null,i.handleZIndex(!1),i._elements=[])})),n(this,"update",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;if(t&&i._elements.length&&!r&&!i.DS.continue){var n=y(i._cursorDiff,"+",i._scrollDiff);i._elements.forEach((function(e){return I({element:e,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})}))}})),n(this,"handleZIndex",(function(e){i._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=u,this._keyboardDragSpeed=c,this._keyboardDrag=l,this._zoom=d,this._draggability=a,this._dragKeys={up:s.up.map((function(e){return e.toLowerCase()})),down:s.down.map((function(e){return e.toLowerCase()})),left:s.left.map((function(e){return e.toLowerCase()})),right:s.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(m(this._dragKeys.up),m(this._dragKeys.down),m(this._dragKeys.left),m(this._dragKeys.right)),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:end",this.stop),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("KeyStore:down",this.keyboardDrag),this.DS.subscribe("KeyStore:up",this.keyboardEnd)}return r(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?y(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}},{key:"_scrollDiff",get:function(){var e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?y(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),K=function(){function t(r){var i=this,o=r.areaElement,s=r.DS,a=r.draggability,l=r.immediateDrag;e(this,t),n(this,"_areaElement",void 0),n(this,"_draggability",void 0),n(this,"_immediateDrag",void 0),n(this,"isInteracting",void 0),n(this,"isDragging",void 0),n(this,"init",(function(){i.stop(),i._areaElement.addEventListener("mousedown",i.start),i._areaElement.addEventListener("touchstart",i.start,{passive:!1}),i.DS.publish("Interaction:init",{})})),n(this,"start",(function(e){"touchstart"===e.type&&e.preventDefault(),i._canInteract(e)&&(i.isInteracting=!0,i.isDragging=i.isDragEvent(e),i.DS.publish("Interaction:start",{event:e,isDragging:i.isDragging}),document.addEventListener("mouseup",i.reset),document.addEventListener("touchend",i.reset))})),n(this,"isDragEvent",(function(e){return!(!i._draggability||i.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!i.DS.SelectableSet.has(e.target))&&(i._immediateDrag&&(i.DS.SelectedSet.size?i.DS.SelectedSet.has(e.target)||(i.DS.SelectedSet.clear(),i.DS.SelectedSet.add(e.target)):i.DS.SelectedSet.add(e.target)),!!i.DS.SelectedSet.has(e.target))})),n(this,"onClick",(function(e){var t=e.event;if(i._canInteract(t)&&!(t.detail>0)){var r=i.DS,n=r.stores,o=n.PointerStore,s=n.KeyStore,a=r.SelectableSet,l=r.SelectedSet,c=r.publish;o.start(t);var u=t.target;a.has(u)&&(s.isMultiSelectKeyPressed(t)||l.clear(),l.toggle(u),c("Interaction:end",{event:t,isDragging:i.isDragging}))}})),n(this,"stop",(function(){i.isInteracting=!1,i.isDragging=!1,i._areaElement.removeEventListener("mousedown",i.start),i._areaElement.removeEventListener("touchstart",i.start,{passive:!1}),document.removeEventListener("mouseup",i.reset),document.removeEventListener("touchend",i.reset)})),n(this,"update",(function(e){var t=e.event,r=e.scroll_directions,n=e.scroll_multiplier;i.isInteracting&&i.DS.publish("Interaction:update",{event:t,scroll_directions:r,scroll_multiplier:n,isDragging:i.isDragging})})),n(this,"reset",(function(e){var t=i.isDragging;i.stop(),i.init(),i.DS.publish("Interaction:end",{event:e,isDragging:t})})),this._areaElement=o,this._draggability=a,this._immediateDrag=l,this.DS=s,this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Area:scroll",this.update)}return r(t,[{key:"_canInteract",value:function(e){var t=0===e.clientX&&0===e.clientY&&0===e.detail&&e.target;return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target)||!t&&!this.DS.SelectorArea.isClicked(e))}}]),t}(),O=function t(){var r=this;e(this,t),n(this,"subscribers",{}),n(this,"subscribe",(function(e,t){return Array.isArray(r.subscribers[e])||(r.subscribers[e]=[]),r.subscribers[e].push(t),r.subscribers[e].length-1})),n(this,"unsubscribe",(function(e,t,n){n>=0?r.subscribers[e].splice(n,1):t&&(r.subscribers[e]=r.subscribers[e].filter((function(e){return e!==t})))})),n(this,"publish",(function(e,t){var n,i;Array.isArray(r.subscribers[e])&&(null===(n=r.subscribers["".concat(e,":pre")])||void 0===n||n.forEach((function(e){return e(t)})),null===(i=r.subscribers[e])||void 0===i||i.forEach((function(e){return e(t)})))}))},j=function(t){o(a,u(Set));var i=f(a);function a(t){var r,o=t.elements,s=t.className,l=t.hoverClassName,c=t.draggability,u=t.useTransform,h=t.DS;return e(this,a),n(d(r=i.call(this)),"_initElements",void 0),n(d(r),"_className",void 0),n(d(r),"_hoverClassName",void 0),n(d(r),"_useTransform",void 0),n(d(r),"_draggability",void 0),n(d(r),"init",(function(){return r._initElements.forEach((function(e){return r.add(e)}))})),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"_onClick",(function(e){return r.DS.publish("Selectable:click",{event:e})})),n(d(r),"_onPointer",(function(e){return r.DS.publish("Selectable:pointer",{event:e})})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=h,r._initElements=T(o),r._className=s,r._hoverClassName=l,r._useTransform=u,r._draggability=c,r.DS.subscribe("Interaction:init",r.init),r}return r(a,[{key:"add",value:function(e){return e.classList.add(this._className),e.addEventListener("click",this._onClick),e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this._draggability&&!this._useTransform&&x({computedStyle:window.getComputedStyle(e),node:e}),v(s(a.prototype),"add",this).call(this,e)}},{key:"delete",value:function(e){return e.classList.remove(this._className),e.classList.remove(this._hoverClassName),e.removeEventListener("click",this._onClick),e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),v(s(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(),z=function(t){o(a,u(Set));var i=f(a);function a(t){var r,o=t.className,s=t.DS;return e(this,a),n(d(r=i.call(this)),"_className",void 0),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=s,r._className=o,r}return r(a,[{key:"add",value:function(e){if(!v(s(a.prototype),"has",this).call(this,e))return v(s(a.prototype),"add",this).call(this,e),e.classList.add(this._className),this.DS.publish("Selected:added",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+1),this}},{key:"delete",value:function(e){if(v(s(a.prototype),"has",this).call(this,e)){var t=v(s(a.prototype),"delete",this).call(this,e);return e.classList.remove(this._className),this.DS.publish("Selected:removed",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)-1),t}}},{key:"toggle",value:function(e){return this.has(e)?this.delete(e):this.add(e),e}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(),H=function(){function t(r){var i=this,o=r.DS,s=r.hoverClassName,a=r.multiSelectToggling;e(this,t),n(this,"_prevSelectedSet",void 0),n(this,"_hoverClassName",void 0),n(this,"_multiSelectToggling",void 0),n(this,"start",(function(e){var t=e.event;e.isDragging||(i._storePrevious(t),i._handleInsideSelection(!0,t))})),n(this,"update",(function(e){e.isDragging||i.DS.continue||i._handleInsideSelection()})),n(this,"_handleInsideSelection",(function(e,t){for(var r=i.DS,n=r.SelectableSet,o=r.SelectorArea,s=r.Selector,a=n.elements.map((function(e){return[e,e.getBoundingClientRect()]})),l=[],c=[],u=0,d=a.length;u<d;u++)o.isInside(a[u][0],a[u][1])&&(A(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=i.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&i._multiSelectToggling;l.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.multiSelectionToggle,i=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!r||(i.has(t)?n&&i.delete(t):i.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.SelectedSet,i=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!r)return!1;var s=n.has(t),a=i.has(t);s&&!a?n.delete(t):!s&&a&&n.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName,PrevSelectedSet:i._prevSelectedSet})}))})),this._hoverClassName=s,this._multiSelectToggling=a,this.DS=o,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return r(t,[{key:"_storePrevious",value:function(e){var t=this.DS,r=t.stores.KeyStore,n=t.SelectedSet;r.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(n):this._prevSelectedSet=new Set}}]),t}(),R=function(){function t(r){var i=this,o=r.DS,s=r.selector,a=r.selectorClass,l=r.customStyles;e(this,t),n(this,"_rect",void 0),n(this,"start",(function(e){if(!e.isDragging){var t=i.DS.stores.PointerStore.initialValArea;V(i.HTMLNode,_(t,1)),i.HTMLNode.style.display="block",i._rect=null}})),n(this,"stop",(function(){i.HTMLNode.style.width="0",i.HTMLNode.style.height="0",i.HTMLNode.style.display="none"})),n(this,"update",(function(e){if(!e.isDragging&&!i.DS.continue){var t=i.DS.stores,r=t.ScrollStore,n=t.PointerStore,o=function(e){var t=e.scrollAmount,r=e.initialPointerPos,n=e.pointerPos,i={};return n.x>r.x-t.x?(i.left=r.x-t.x,i.width=n.x-r.x+t.x):(i.left=n.x,i.width=r.x-n.x-t.x),n.y>r.y-t.y?(i.top=r.y-t.y,i.height=n.y-r.y+t.y):(i.top=n.y,i.height=r.y-n.y-t.y),i}({scrollAmount:r.scrollAmount,initialPointerPos:n.initialValArea,pointerPos:n.currentValArea});V(i.HTMLNode,o),i._rect=null}})),this.DS=o,this.HTMLNode=s||function(e){var t=document.createElement("div");return t.style.position="absolute",e||(t.style.background="rgba(0, 0, 255, 0.1)",t.style.border="1px solid rgba(0, 0, 255, 0.45)",t.style.display="none",t.style.pointerEvents="none"),t}(l),this.HTMLNode.classList.add(a),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return r(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),B=function(){function t(r){var i=this,o=r.DS,s=r.selectorAreaClass,a=r.autoScrollSpeed,l=r.overflowTolerance;e(this,t),n(this,"_autoScrollSpeed",void 0),n(this,"_scrollInterval",void 0),n(this,"_rect",void 0),n(this,"currentEdges",[]),n(this,"_overflowTolerance",void 0),n(this,"start",(function(){return i.applyElements("append")})),n(this,"applyElements",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",t=document.body?"body":"documentElement",r="".concat(e,"Child");i.HTMLNode[r](i.DS.Selector.HTMLNode),document[t][r](i.HTMLNode)})),n(this,"updatePos",(function(){i._rect=null;var e=i.DS.Area.rect,t=i.DS.Area.computedBorder,r=i.HTMLNode.style,n="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");r.top!==n&&(r.top=n),r.left!==o&&(r.left=o),r.width!==s&&(r.width=s),r.height!==a&&(r.height=a)})),n(this,"stop",(function(e){i.stopAutoScroll(),e&&i.applyElements("remove")})),n(this,"startAutoScroll",(function(){i.currentEdges=[],i._scrollInterval=setInterval((function(){return i.handleAutoScroll()}),16)})),n(this,"handleAutoScroll",(function(){if(!i.DS.continue){var e=i.DS,t=e.stores.PointerStore,r=e.Area;i.currentEdges=k({elementRect:_(t.currentVal),containerRect:i.rect,tolerance:i._overflowTolerance}),i.currentEdges.length&&r.scroll(i.currentEdges,i._autoScrollSpeed)}})),n(this,"stopAutoScroll",(function(){i.currentEdges=[],clearInterval(i._scrollInterval)})),n(this,"isInside",(function(e,t){return!(!i.DS.Area.HTMLNode.contains(e)||!i.DS.stores.ScrollStore.canScroll)||A(i.rect,t||e.getBoundingClientRect())})),this._autoScrollSpeed=a,this._overflowTolerance=l,this.DS=o,this.HTMLNode=function(e){var t=document.createElement("div");return t.style.position="fixed",t.style.overflow="hidden",t.style.pointerEvents="none",t.style.zIndex="999999999999999999",t.classList.add(e),t}(s),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:init",this.start),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){i.updatePos(),i.stopAutoScroll()}))}return r(t,[{key:"isClicked",value:function(e){var t=this.DS.stores.PointerStore,r=e?t.getPointerPosition(e):t.initialVal;return A({left:r.x,top:r.y,right:r.x,bottom:r.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),U=function(){function t(r){var i=this,o=r.DS,s=r.multiSelectKeys,a=r.multiSelectMode;e(this,t),n(this,"_multiSelectMode",void 0),n(this,"_multiSelectKeys",void 0),n(this,"_currentValues",new Set),n(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),n(this,"init",(function(){document.addEventListener("keydown",i.keydown),document.addEventListener("keyup",i.keyup),window.addEventListener("blur",i.reset)})),n(this,"keydown",(function(e){var t=e.key.toLowerCase();i._currentValues.add(t),i.DS.publish("KeyStore:down",{event:e,key:t})})),n(this,"keyup",(function(e){var t=e.key.toLowerCase();i._currentValues.delete(t),i.DS.publish("KeyStore:up",{event:e,key:t})})),n(this,"stop",(function(){document.removeEventListener("keydown",i.keydown),document.removeEventListener("keyup",i.reset),window.removeEventListener("blur",i.reset),i.reset()})),n(this,"reset",(function(){return i._currentValues.clear()})),this.DS=o,this._multiSelectMode=a,this._multiSelectKeys=s.map((function(e){var t={ctrlKey:"Control",shiftKey:"Shift",metaKey:"Meta"}[e];return t?(console.warn("[DragSelect] ".concat(e,' is deprecated. Use "').concat(t,'" instead. Act Now!. See docs for more info')),t.toLowerCase()):e.toLowerCase()})),this.DS.subscribe("Interaction:init",this.init)}return r(t,[{key:"isMultiSelectKeyPressed",value:function(e){var t=this;return!!this._multiSelectMode||(!!this.currentValues.some((function(e){return t._multiSelectKeys.includes(e)}))||!(!e||!this._multiSelectKeys.some((function(r){return e[t._keyMapping[r]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),W=function(){function t(r){var i=this,o=r.DS;e(this,t),n(this,"_isMouseInteraction",!1),n(this,"_initialValArea",void 0),n(this,"_currentValArea",void 0),n(this,"_lastValArea",void 0),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_lastVal",void 0),n(this,"_lastTouch",void 0),n(this,"init",(function(){document.addEventListener("mousemove",i.update),document.addEventListener("touchmove",i.update,{passive:!1})})),n(this,"getPointerPosition",(function(e){return function(e){var t=e.event;return{x:t.clientX,y:t.clientY}}({event:i._normalizedEvent(e)})})),n(this,"update",(function(e){e&&(i.currentVal=i.getPointerPosition(e),i._isMouseInteraction&&i.DS.publish("PointerStore:updated",{event:e}))})),n(this,"stop",(function(){document.removeEventListener("mousemove",i.update),document.removeEventListener("touchmove",i.update,{passive:!1}),setTimeout((function(){return i._isMouseInteraction=!1}),100)})),n(this,"reset",(function(e){e&&(i.currentVal=i.lastVal=i.getPointerPosition(e),i.stop(),i.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return i.reset(t)}))}return r(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(e))}},{key:"_normalizedEvent",value:function(e){return"touches"in e&&"touchend"!==e.type&&(this._lastTouch=e),"touches"in e?this._lastTouch.touches[0]:e}},{key:"initialValArea",get:function(){return this._initialValArea?this._initialValArea:{x:0,y:0}}},{key:"currentValArea",get:function(){return this._currentValArea?this._currentValArea:{x:0,y:0}}},{key:"lastValArea",get:function(){return this._lastValArea?this._lastValArea:{x:0,y:0}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}},set:function(e){this._initialVal=e,this._initialValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(e){this._currentVal=e,this._currentValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(e){this._lastVal=e,this._lastValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}}]),t}(),F=function(){function t(r){var i=this,o=r.DS,s=r.areaElement,a=r.zoom;e(this,t),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_areaElement",void 0),n(this,"_canScroll",void 0),n(this,"init",(function(){return i._areaElement.addEventListener("scroll",i.update)})),n(this,"start",(function(){i._currentVal=i._initialVal=w(i._areaElement),i._areaElement.addEventListener("scroll",i.update)})),n(this,"update",(function(){return i._currentVal=w(i._areaElement)})),n(this,"stop",(function(){i._areaElement.removeEventListener("scroll",i.update),i._initialVal={x:0,y:0},i._canScroll=null})),n(this,"reset",(function(){i.stop(),i.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return i.start()})),this.DS.subscribe("Interaction:end",(function(){return i.reset()}))}return r(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=w(e)).x||t.y||(e instanceof HTMLDocument?e.body?e.body.scrollTop=1:e.documentElement.scrollTop=1:e.scrollTop=1)));var e,t}},{key:"scrollAmount",get:function(){var e,t=y(this.currentVal,"-",this.initialVal),r={x:e=this.zoom,y:e},n=y(y(t,"*",r),"-",t);return{x:t.x+n.x,y:t.y+n.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=w(this._areaElement)),this._currentVal}}]),t}(),Z=function(){function t(r){var i=this,o=r.area,s=void 0===o?document:o,a=r.selectables,l=void 0===a?[]:a,c=r.autoScrollSpeed,u=void 0===c?5:c,d=r.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=r.zoom,v=void 0===f?1:f,S=r.customStyles,m=void 0!==S&&S,g=r.multiSelectMode,p=void 0!==g&&g,y=r.multiSelectToggling,b=void 0===y||y,_=r.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,w=r.selector,k=void 0===w?void 0:w,P=r.draggability,E=void 0===P||P,x=r.immediateDrag,A=void 0===x||x,I=r.keyboardDrag,C=void 0===I||I,T=r.dragKeys,V=r.keyboardDragSpeed,Z=void 0===V?10:V,X=r.useTransform,Y=void 0===X||X,G=r.hoverClass,$=void 0===G?"ds-hover":G,q=r.selectableClass,J=void 0===q?"ds-selectable":q,Q=r.selectedClass,ee=void 0===Q?"ds-selected":Q,te=r.selectorClass,re=void 0===te?"ds-selector":te,ne=r.selectorAreaClass,ie=void 0===ne?"ds-selector-area":ne,oe=r.callback,se=r.onDragMove,ae=r.onDragStartBegin,le=r.onDragStart,ce=r.onElementSelect,ue=r.onElementUnselect;e(this,t),n(this,"continue",!1),n(this,"start",(function(){return i.Interaction.init()})),n(this,"break",(function(){return i.continue=!0})),n(this,"getSelection",(function(){return i.SelectedSet.elements})),n(this,"getSelectables",(function(){return i.SelectableSet.elements})),n(this,"getInitialCursorPosition",(function(){return i.stores.PointerStore.initialVal})),n(this,"getCurrentCursorPosition",(function(){return i.stores.PointerStore.currentVal})),n(this,"getPreviousCursorPosition",(function(){return i.stores.PointerStore.lastVal})),n(this,"getInitialCursorPositionArea",(function(){return i.stores.PointerStore.initialValArea})),n(this,"getCurrentCursorPositionArea",(function(){return i.stores.PointerStore.currentValArea})),n(this,"getPreviousCursorPositionArea",(function(){return i.stores.PointerStore.lastValArea})),n(this,"isMultiSelect",(function(e){return i.stores.KeyStore.isMultiSelectKeyPressed(e)})),n(this,"isDragging",(function(){return i.Interaction.isDragging})),this.PubSub=new O,this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:oe,onDragMove:se,onDragStart:le,onDragStartBegin:ae,onElementSelect:ce,onElementUnselect:ue}),this.stores={PointerStore:new W({DS:this}),ScrollStore:new F({DS:this,areaElement:s,zoom:v}),KeyStore:new U({DS:this,multiSelectKeys:D,multiSelectMode:p})},this.Area=new N({area:s,PS:this.PubSub,zoom:v}),this.Selector=new R({DS:this,selector:k,selectorClass:re,customStyles:m}),this.SelectorArea=new B({DS:this,selectorAreaClass:ie,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new j({elements:l,DS:this,className:J,hoverClassName:$,useTransform:Y,draggability:E}),this.SelectedSet=new z({DS:this,className:ee}),this.Selection=new H({DS:this,hoverClassName:$,multiSelectToggling:b}),this.Drag=new M({DS:this,draggability:E,useTransform:Y,keyboardDrag:C,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},T),zoom:v,keyboardDragSpeed:Z}),this.Interaction=new K({areaElement:s,DS:this,draggability:E,immediateDrag:A}),L({subscribe:this.subscribe,publish:this.publish,SelectedSet:this.SelectedSet,Interaction:this.Interaction}),this.subscribe("Interaction:end",(function(){return i.continue=!1})),this.start()}return r(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,r=e.onDragMove,n=e.onDragStart,i=e.onDragStartBegin,o=e.onElementSelect,s=e.onElementUnselect,a=function(e,t){return console.warn("[DragSelect] ".concat(e,' is deprecated. Use DragSelect.subscribe("').concat(t,'", (callbackObject) => {}) instead. Act Now! See docs for more info'))};t&&(a("callback","callback"),this.subscribe("callback",(function(e){var r=e.items,n=(e.item,e.event);return t(r,n)}))),r&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),i&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return i(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,r=e.event;return o(t,r)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,r=e.event;return s(t,r)})))}},{key:"stop",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(e),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear()}},{key:"addSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(T(e)),r||this.addSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(T(e)),r&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return T(e).forEach((function(i){return t.SelectedSet.has(i)?t.removeSelection(e,r,n):t.addSelection(e,r,n)})),r&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,r),this.getSelection()}},{key:"clearSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=T(e);return this.SelectableSet.addAll(r),t&&this.SelectedSet.addAll(r),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,r)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(T(e)),t&&this.removeSelection(e),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var r=t?this.getCurrentCursorPositionArea():this.getCurrentCursorPosition(),n=e?t?this.getPreviousCursorPositionArea():this.getPreviousCursorPosition():t?this.getInitialCursorPositionArea():this.getInitialCursorPosition();return y(r,"-",n)}}]),t}();export default Z; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DragSelect=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function c(e,t,r){return(c=l()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&a(i,r.prototype),i}).apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return c(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)})(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?d(e):t}function f(e){var t=l();return function(){var r,n=s(e);if(t){var i=s(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return h(this,r)}}function v(e,t,r){return(v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}return r}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var y=function(e,t,r){var n=e.x,i=e.y,o=r.x,s=r.y;return{"+":{x:n+o,y:i+s},"-":{x:n-o,y:i-s},"*":{x:n*o,y:i*s},"/":{x:n/o,y:i/s}}[t]},b=function(e){return{x:e.left,y:e.top}},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}},D=function(){var e,t,r,n;return{y:(null===(e=document.body)||void 0===e?void 0:e.scrollTop)||(null===(t=document.documentElement)||void 0===t?void 0:t.scrollTop)||0,x:(null===(r=document.body)||void 0===r?void 0:r.scrollLeft)||(null===(n=document.documentElement)||void 0===n?void 0:n.scrollLeft)||0}},w=function(e){return!e||e instanceof Document?D():{x:e.scrollLeft>=0?e.scrollLeft:D().x,y:e.scrollTop>=0?e.scrollTop:D().y}},k=function(e){var t=e.elementRect,r=e.containerRect,n=e.tolerance,i=void 0===n?{x:0,y:0}:n,o=[];return t.top-i.y<r.top&&o.push("top"),t.left-i.x<r.left&&o.push("left"),t.bottom+i.y>r.bottom&&o.push("bottom"),t.right+i.y>r.right&&o.push("right"),o},E=function(e){var t=e.event;return{x:t.clientX,y:t.clientY}},x=function(e){var t={x:0,y:0},r=window.getComputedStyle(e);if(!r.transform||"none"===r.transform)return t;if(r.transform.indexOf("3d")>=0){var n=r.transform.trim().match(/matrix3d\((.*?)\)/);if(n&&n.length){var i,o=null===(i=n[1])||void 0===i?void 0:i.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=r.transform.trim().match(/matrix\((.*?)\)/);if(s&&s.length){var a,l=null===(a=s[1])||void 0===a?void 0:a.split(",");t.x=parseInt(l[4])||0,t.y=parseInt(l[5])||0}return t},P=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return x(e);var r={x:0,y:0},n=t.trim().match(/translate[3dD]*?\(.*?\)/);if(n){var i,o=null===(i=n[0])||void 0===i?void 0:i.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");r.x=parseInt(a[0])||0,r.y=parseInt(a[1])||0}}return r.x||r.x?r:x(e)}(e):function(e){var t=e.style,r={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!r.x&&!r.x){var n=window.getComputedStyle(e);return{x:parseInt(n.left)||0,y:parseInt(n.top)||0}}return r}(e)},I=function(e){var t=e.computedStyle,r=e.node,n=t.position;r instanceof HTMLDocument||("absolute"===n||"relative"===n||"fixed"===n)||(r.style.position="relative")},A=function(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top},C=function(e){var t=e.element,r=e.posDirection,n=e.containerRect,i=e.useTransform,o=P(t,i),s=y(o,"+",r);L(t,s,i);var a=t.getBoundingClientRect();!function(e){var t=e.element,r=e.edges,n=e.elementRect,i=e.containerRect,o=e.elementPos,s=e.useTransform;r.includes("top")&&L(t,{y:o.y+i.top-n.top,x:o.x},s),r.includes("left")&&L(t,{y:o.y,x:o.x+i.left-n.left},s),r.includes("bottom")&&L(t,{y:o.y+i.bottom-n.bottom,x:o.x},s),r.includes("right")&&L(t,{y:o.y,x:o.x+i.right-n.right},s)}({element:t,edges:k({elementRect:a,containerRect:n}),elementRect:a,containerRect:n,elementPos:s,useTransform:i})},L=function(e,t,r){if(r){var n=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(n.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},T=function(e){for(var t=e.subscribe,r=e.publish,o=e.Interaction,s=e.SelectedSet,a=function(){var e=S(c[l],2),a=e[0],u=e[1];["pre",!1].forEach((function(e){return t(e?"".concat(a,":").concat(e):a,(function(t){return u.forEach((function(a){return(!a.condition||a.condition(t))&&r(e?"".concat(e).concat(a.name):a.name,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({items:s.elements,isDragging:o.isDragging},t))}))}))}))},l=0,c=Object.entries({"Selected:added":[{name:"elementselect"}],"Selected:removed":[{name:"elementunselect"}],"Area:scroll":[{name:"autoscroll"}],"Interaction:start":[{name:"dragstart"}],"Interaction:update":[{name:"dragmove",condition:function(e){return e.event}}],"Interaction:end":[{name:"callback"}],"Drag:keyboardDrag":[{name:"dragstart"},{name:"dragmove"}]});l<c.length;l++)a()},V=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:m(e):[]},N=function(e,t){e.style.left="".concat(t.left,"px"),e.style.top="".concat(t.top,"px"),e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px")},M=function(){function t(r){var i,o,s,a=this,l=r.area,c=r.PS,u=r.zoom;e(this,t),n(this,"_modificationCallback",void 0),n(this,"_modificationObserver",void 0),n(this,"_zoom",void 0),n(this,"_node",void 0),n(this,"_parentNodes",void 0),n(this,"_computedStyle",void 0),n(this,"_computedBorder",void 0),n(this,"_rect",void 0),n(this,"start",(function(){var e,t,r;e=a.parentNodes,t=a._modificationCallback,r=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){r.observe(e,{childList:0!==t,attributes:!0})}))})),n(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),n(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),n(this,"scroll",(function(e,t){!function(e,t,r){if(t.length){var n=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,i=e instanceof HTMLDocument?n||document.body:e,o=t.includes("top")&&i.scrollTop>0,s=t.includes("bottom")&&i.scrollTop<i.scrollHeight,a=t.includes("left")&&i.scrollLeft>0,l=t.includes("right")&&i.scrollLeft<i.scrollWidth;o&&(i.scrollTop-=1*r),s&&(i.scrollTop+=1*r),a&&(i.scrollLeft-=1*r),l&&(i.scrollLeft+=1*r)}}(a._node,e,t),a.PubSub.publish("Area:scroll",{scroll_directions:e,scroll_multiplier:t})})),this._node=l,this._zoom=u,this.PubSub=c,I({computedStyle:this.computedStyle,node:this._node}),this._modificationCallback=(i=function(e){a.reset(),a.PubSub.publish("Area:modified",{event:e,item:a})},o=60,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=function(){s=null,i.apply(void 0,t)};clearTimeout(s),s=setTimeout(n,o)}),this._modificationObserver=new MutationObserver(this._modificationCallback),setTimeout((function(){a.reset(),a.PubSub.publish("Area:modified",{event:event,item:a})})),this.PubSub.subscribe("Interaction:init",this.start),this.PubSub.subscribe("Interaction:end",this.reset)}return r(t,[{key:"HTMLNode",get:function(){return this._node}},{key:"computedBorder",get:function(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}},{key:"computedStyle",get:function(){return this._computedStyle?this._computedStyle:this.HTMLNode instanceof HTMLDocument?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=function(e,t){if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var r=e.getBoundingClientRect();return{top:r.top,left:r.left,bottom:r.bottom,right:r.right,width:(e.clientWidth||r.width)*t,height:(e.clientHeight||r.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=null===(r=t[n])||void 0===r?void 0:r.parentNode;return i?(t.push(i),e(t,++n)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),K=function(){function t(r){var i=this,o=r.DS,s=r.dragKeys,a=r.draggability,l=r.keyboardDrag,c=r.keyboardDragSpeed,u=r.useTransform,d=r.zoom;e(this,t),n(this,"_useTransform",void 0),n(this,"_prevCursorPos",void 0),n(this,"_prevScrollPos",void 0),n(this,"_elements",[]),n(this,"_draggability",void 0),n(this,"_dragKeys",void 0),n(this,"_dragKeysFlat",void 0),n(this,"_keyboardDrag",void 0),n(this,"_keyboardDragSpeed",void 0),n(this,"_zoom",void 0),n(this,"keyboardDrag",(function(e){var t=e.event,r=e.key;if(i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability&&!i.DS.continue){i.DS.publish("Interaction:start",{event:t,isDragging:!0,isDraggingKeyboard:!0}),i._elements=i.DS.getSelection(),i.handleZIndex(!0);var n=function(e){var t=e.shiftKey,r=e.keyboardDragSpeed,n=e.zoom,i=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*r*n:r*n;return o.left.includes(i)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],r)),o.right.includes(i)&&(c.x=s.x||u,t||s.x||!a||l(["right"],r)),o.up.includes(i)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],r)),o.down.includes(i)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],r)),c}({shiftKey:i.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:i._keyboardDragSpeed,zoom:i._zoom,key:r,scrollCallback:i.DS.Area.scroll,scrollDiff:i._scrollDiff,canScroll:i.DS.stores.ScrollStore.canScroll,dragKeys:i._dragKeys});i._elements.forEach((function(e){return C({element:e,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})})),i.DS.publish("Interaction:update",{event:t,isDragging:!0,isDraggingKeyboard:!0})}})),n(this,"keyboardEnd",(function(e){var t=e.event,r=e.key;i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability&&i.DS.publish("Interaction:end",{event:t,isDragging:i._draggability,isDraggingKeyboard:!0})})),n(this,"start",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;t&&!r&&(i._prevCursorPos=null,i._prevScrollPos=null,i._elements=i.DS.getSelection(),i.handleZIndex(!0))})),n(this,"stop",(function(e){null!=e&&e.isKeyboard||(i._prevCursorPos=null,i._prevScrollPos=null,i.handleZIndex(!1),i._elements=[])})),n(this,"update",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;if(t&&i._elements.length&&!r&&!i.DS.continue){var n=y(i._cursorDiff,"+",i._scrollDiff);i._elements.forEach((function(e){return C({element:e,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})}))}})),n(this,"handleZIndex",(function(e){i._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=u,this._keyboardDragSpeed=c,this._keyboardDrag=l,this._zoom=d,this._draggability=a,this._dragKeys={up:s.up.map((function(e){return e.toLowerCase()})),down:s.down.map((function(e){return e.toLowerCase()})),left:s.left.map((function(e){return e.toLowerCase()})),right:s.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(m(this._dragKeys.up),m(this._dragKeys.down),m(this._dragKeys.left),m(this._dragKeys.right)),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:end",this.stop),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("KeyStore:down",this.keyboardDrag),this.DS.subscribe("KeyStore:up",this.keyboardEnd)}return r(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?y(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}},{key:"_scrollDiff",get:function(){var e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?y(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),O=function(){function t(r){var i=this,o=r.areaElement,s=r.DS,a=r.draggability,l=r.immediateDrag;e(this,t),n(this,"_areaElement",void 0),n(this,"_draggability",void 0),n(this,"_immediateDrag",void 0),n(this,"isInteracting",void 0),n(this,"isDragging",void 0),n(this,"init",(function(){i.stop(),i._areaElement.addEventListener("mousedown",i.start),i._areaElement.addEventListener("touchstart",i.start,{passive:!1}),i.DS.publish("Interaction:init",{})})),n(this,"start",(function(e){"touchstart"===e.type&&e.preventDefault(),i._canInteract(e)&&(i.isInteracting=!0,i.isDragging=i.isDragEvent(e),i.DS.publish("Interaction:start",{event:e,isDragging:i.isDragging}),document.addEventListener("mouseup",i.reset),document.addEventListener("touchend",i.reset))})),n(this,"isDragEvent",(function(e){return!(!i._draggability||i.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!i.DS.SelectableSet.has(e.target))&&(i._immediateDrag&&(i.DS.SelectedSet.size?i.DS.SelectedSet.has(e.target)||(i.DS.SelectedSet.clear(),i.DS.SelectedSet.add(e.target)):i.DS.SelectedSet.add(e.target)),!!i.DS.SelectedSet.has(e.target))})),n(this,"onClick",(function(e){var t=e.event;if(i._canInteract(t)&&!(t.detail>0)){var r=i.DS,n=r.stores,o=n.PointerStore,s=n.KeyStore,a=r.SelectableSet,l=r.SelectedSet,c=r.publish;o.start(t);var u=t.target;a.has(u)&&(s.isMultiSelectKeyPressed(t)||l.clear(),l.toggle(u),c("Interaction:end",{event:t,isDragging:i.isDragging}))}})),n(this,"stop",(function(){i.isInteracting=!1,i.isDragging=!1,i._areaElement.removeEventListener("mousedown",i.start),i._areaElement.removeEventListener("touchstart",i.start,{passive:!1}),document.removeEventListener("mouseup",i.reset),document.removeEventListener("touchend",i.reset)})),n(this,"update",(function(e){var t=e.event,r=e.scroll_directions,n=e.scroll_multiplier;i.isInteracting&&i.DS.publish("Interaction:update",{event:t,scroll_directions:r,scroll_multiplier:n,isDragging:i.isDragging})})),n(this,"reset",(function(e){var t=i.isDragging;i.stop(),i.init(),i.DS.publish("Interaction:end",{event:e,isDragging:t})})),this._areaElement=o,this._draggability=a,this._immediateDrag=l,this.DS=s,this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Area:scroll",this.update)}return r(t,[{key:"_canInteract",value:function(e){return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target))}}]),t}(),z=function t(){var r=this;e(this,t),n(this,"subscribers",{}),n(this,"subscribe",(function(e,t){return Array.isArray(r.subscribers[e])||(r.subscribers[e]=[]),r.subscribers[e].push(t),r.subscribers[e].length-1})),n(this,"unsubscribe",(function(e,t,n){n>=0?r.subscribers[e].splice(n,1):t&&(r.subscribers[e]=r.subscribers[e].filter((function(e){return e!==t})))})),n(this,"publish",(function(e,t){var n,i;Array.isArray(r.subscribers[e])&&(null===(n=r.subscribers["".concat(e,":pre")])||void 0===n||n.forEach((function(e){return e(t)})),null===(i=r.subscribers[e])||void 0===i||i.forEach((function(e){return e(t)})))}))},j=function(t){o(a,t);var i=f(a);function a(t){var r,o=t.elements,s=t.className,l=t.hoverClassName,c=t.draggability,u=t.useTransform,h=t.DS;return e(this,a),n(d(r=i.call(this)),"_initElements",void 0),n(d(r),"_className",void 0),n(d(r),"_hoverClassName",void 0),n(d(r),"_useTransform",void 0),n(d(r),"_draggability",void 0),n(d(r),"init",(function(){return r._initElements.forEach((function(e){return r.add(e)}))})),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"_onClick",(function(e){return r.DS.publish("Selectable:click",{event:e})})),n(d(r),"_onPointer",(function(e){return r.DS.publish("Selectable:pointer",{event:e})})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=h,r._initElements=V(o),r._className=s,r._hoverClassName=l,r._useTransform=u,r._draggability=c,r.DS.subscribe("Interaction:init",r.init),r}return r(a,[{key:"add",value:function(e){return e.classList.add(this._className),e.addEventListener("click",this._onClick),e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this._draggability&&!this._useTransform&&I({computedStyle:window.getComputedStyle(e),node:e}),v(s(a.prototype),"add",this).call(this,e)}},{key:"delete",value:function(e){return e.classList.remove(this._className),e.classList.remove(this._hoverClassName),e.removeEventListener("click",this._onClick),e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),v(s(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(u(Set)),H=function(t){o(a,t);var i=f(a);function a(t){var r,o=t.className,s=t.DS;return e(this,a),n(d(r=i.call(this)),"_className",void 0),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=s,r._className=o,r}return r(a,[{key:"add",value:function(e){if(!v(s(a.prototype),"has",this).call(this,e))return v(s(a.prototype),"add",this).call(this,e),e.classList.add(this._className),this.DS.publish("Selected:added",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+1),this}},{key:"delete",value:function(e){if(v(s(a.prototype),"has",this).call(this,e)){var t=v(s(a.prototype),"delete",this).call(this,e);return e.classList.remove(this._className),this.DS.publish("Selected:removed",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)-1),t}}},{key:"toggle",value:function(e){return this.has(e)?this.delete(e):this.add(e),e}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(u(Set)),R=function(){function t(r){var i=this,o=r.DS,s=r.hoverClassName,a=r.multiSelectToggling;e(this,t),n(this,"_prevSelectedSet",void 0),n(this,"_hoverClassName",void 0),n(this,"_multiSelectToggling",void 0),n(this,"start",(function(e){var t=e.event;e.isDragging||(i._storePrevious(t),i._handleInsideSelection(!0,t))})),n(this,"update",(function(e){e.isDragging||i.DS.continue||i._handleInsideSelection()})),n(this,"_handleInsideSelection",(function(e,t){for(var r=i.DS,n=r.SelectableSet,o=r.SelectorArea,s=r.Selector,a=n.elements.map((function(e){return[e,e.getBoundingClientRect()]})),l=[],c=[],u=0,d=a.length;u<d;u++)o.isInside(a[u][0],a[u][1])&&(A(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=i.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&i._multiSelectToggling;l.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.multiSelectionToggle,i=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!r||(i.has(t)?n&&i.delete(t):i.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.SelectedSet,i=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!r)return!1;var s=n.has(t),a=i.has(t);s&&!a?n.delete(t):!s&&a&&n.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName,PrevSelectedSet:i._prevSelectedSet})}))})),this._hoverClassName=s,this._multiSelectToggling=a,this.DS=o,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return r(t,[{key:"_storePrevious",value:function(e){var t=this.DS,r=t.stores.KeyStore,n=t.SelectedSet;r.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(n):this._prevSelectedSet=new Set}}]),t}(),B=function(){function t(r){var i=this,o=r.DS,s=r.selector,a=r.selectorClass,l=r.customStyles;e(this,t),n(this,"_rect",void 0),n(this,"start",(function(e){if(!e.isDragging){var t=i.DS.stores.PointerStore.initialValArea;N(i.HTMLNode,_(t,1)),i.HTMLNode.style.display="block",i._rect=null}})),n(this,"stop",(function(){i.HTMLNode.style.width="0",i.HTMLNode.style.height="0",i.HTMLNode.style.display="none"})),n(this,"update",(function(e){if(!e.isDragging&&!i.DS.continue){var t=i.DS.stores,r=t.ScrollStore,n=t.PointerStore,o=function(e){var t=e.scrollAmount,r=e.initialPointerPos,n=e.pointerPos,i={};return n.x>r.x-t.x?(i.left=r.x-t.x,i.width=n.x-r.x+t.x):(i.left=n.x,i.width=r.x-n.x-t.x),n.y>r.y-t.y?(i.top=r.y-t.y,i.height=n.y-r.y+t.y):(i.top=n.y,i.height=r.y-n.y-t.y),i}({scrollAmount:r.scrollAmount,initialPointerPos:n.initialValArea,pointerPos:n.currentValArea});N(i.HTMLNode,o),i._rect=null}})),this.DS=o,this.HTMLNode=s||function(e){var t=document.createElement("div");return t.style.position="absolute",e||(t.style.background="rgba(0, 0, 255, 0.1)",t.style.border="1px solid rgba(0, 0, 255, 0.45)",t.style.display="none",t.style.pointerEvents="none"),t}(l),this.HTMLNode.classList.add(a),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return r(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),U=function(){function t(r){var i=this,o=r.DS,s=r.selectorAreaClass,a=r.autoScrollSpeed,l=r.overflowTolerance;e(this,t),n(this,"_autoScrollSpeed",void 0),n(this,"_scrollInterval",void 0),n(this,"_rect",void 0),n(this,"currentEdges",[]),n(this,"_overflowTolerance",void 0),n(this,"start",(function(){return i.applyElements("append")})),n(this,"applyElements",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",t=document.body?"body":"documentElement",r="".concat(e,"Child");i.HTMLNode[r](i.DS.Selector.HTMLNode),document[t][r](i.HTMLNode)})),n(this,"updatePos",(function(){i._rect=null;var e=i.DS.Area.rect,t=i.DS.Area.computedBorder,r=i.HTMLNode.style,n="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");r.top!==n&&(r.top=n),r.left!==o&&(r.left=o),r.width!==s&&(r.width=s),r.height!==a&&(r.height=a)})),n(this,"stop",(function(e){i.stopAutoScroll(),e&&i.applyElements("remove")})),n(this,"startAutoScroll",(function(){i.currentEdges=[],i._scrollInterval=setInterval((function(){return i.handleAutoScroll()}),16)})),n(this,"handleAutoScroll",(function(){if(!i.DS.continue){var e=i.DS,t=e.stores.PointerStore,r=e.Area;i.currentEdges=k({elementRect:_(t.currentVal),containerRect:i.rect,tolerance:i._overflowTolerance}),i.currentEdges.length&&r.scroll(i.currentEdges,i._autoScrollSpeed)}})),n(this,"stopAutoScroll",(function(){i.currentEdges=[],clearInterval(i._scrollInterval)})),n(this,"isInside",(function(e,t){return!(!i.DS.Area.HTMLNode.contains(e)||!i.DS.stores.ScrollStore.canScroll)||A(i.rect,t||e.getBoundingClientRect())})),this._autoScrollSpeed=a,this._overflowTolerance=l,this.DS=o,this.HTMLNode=function(e){var t=document.createElement("div");return t.style.position="fixed",t.style.overflow="hidden",t.style.pointerEvents="none",t.style.zIndex="999999999999999999",t.classList.add(e),t}(s),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:init",this.start),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){i.updatePos(),i.stopAutoScroll()}))}return r(t,[{key:"isClicked",value:function(){var e=this.DS.stores.PointerStore;return A({left:e.initialVal.x,top:e.initialVal.y,right:e.initialVal.x,bottom:e.initialVal.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),W=function(){function t(r){var i=this,o=r.DS,s=r.multiSelectKeys,a=r.multiSelectMode;e(this,t),n(this,"_multiSelectMode",void 0),n(this,"_multiSelectKeys",void 0),n(this,"_currentValues",new Set),n(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),n(this,"init",(function(){document.addEventListener("keydown",i.keydown),document.addEventListener("keyup",i.keyup),window.addEventListener("blur",i.reset)})),n(this,"keydown",(function(e){var t=e.key.toLowerCase();i._currentValues.add(t),i.DS.publish("KeyStore:down",{event:e,key:t})})),n(this,"keyup",(function(e){var t=e.key.toLowerCase();i._currentValues.delete(t),i.DS.publish("KeyStore:up",{event:e,key:t})})),n(this,"stop",(function(){document.removeEventListener("keydown",i.keydown),document.removeEventListener("keyup",i.reset),window.removeEventListener("blur",i.reset),i.reset()})),n(this,"reset",(function(){return i._currentValues.clear()})),this.DS=o,this._multiSelectMode=a,this._multiSelectKeys=s.map((function(e){var t={ctrlKey:"Control",shiftKey:"Shift",metaKey:"Meta"}[e];return t?(console.warn("[DragSelect] ".concat(e,' is deprecated. Use "').concat(t,'" instead. Act Now!. See docs for more info')),t.toLowerCase()):e.toLowerCase()})),this.DS.subscribe("Interaction:init",this.init)}return r(t,[{key:"isMultiSelectKeyPressed",value:function(e){var t=this;return!!this._multiSelectMode||(!!this.currentValues.some((function(e){return t._multiSelectKeys.includes(e)}))||!(!e||!this._multiSelectKeys.some((function(r){return e[t._keyMapping[r]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),F=function(){function t(r){var i=this,o=r.DS;e(this,t),n(this,"_isMouseInteraction",!1),n(this,"_initialValArea",void 0),n(this,"_currentValArea",void 0),n(this,"_lastValArea",void 0),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_lastVal",void 0),n(this,"_lastTouch",void 0),n(this,"init",(function(){document.addEventListener("mousemove",i.update),document.addEventListener("touchmove",i.update,{passive:!1})})),n(this,"update",(function(e){e&&(i.currentVal=E({event:i._normalizedEvent(e)}),i._isMouseInteraction&&i.DS.publish("PointerStore:updated",{event:e}))})),n(this,"stop",(function(){document.removeEventListener("mousemove",i.update),document.removeEventListener("touchmove",i.update,{passive:!1}),setTimeout((function(){return i._isMouseInteraction=!1}),100)})),n(this,"reset",(function(e){e&&(i.currentVal=i.lastVal=E({event:i._normalizedEvent(e)}),i.stop(),i.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return i.reset(t)}))}return r(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=E({event:this._normalizedEvent(e)}))}},{key:"_normalizedEvent",value:function(e){return"touches"in e&&"touchend"!==e.type&&(this._lastTouch=e),"touches"in e?this._lastTouch.touches[0]:e}},{key:"initialValArea",get:function(){return this._initialValArea?this._initialValArea:{x:0,y:0}}},{key:"currentValArea",get:function(){return this._currentValArea?this._currentValArea:{x:0,y:0}}},{key:"lastValArea",get:function(){return this._lastValArea?this._lastValArea:{x:0,y:0}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}},set:function(e){this._initialVal=e,this._initialValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(e){this._currentVal=e,this._currentValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(e){this._lastVal=e,this._lastValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}}]),t}(),Z=function(){function t(r){var i=this,o=r.DS,s=r.areaElement,a=r.zoom;e(this,t),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_areaElement",void 0),n(this,"_canScroll",void 0),n(this,"init",(function(){return i._areaElement.addEventListener("scroll",i.update)})),n(this,"start",(function(){i._currentVal=i._initialVal=w(i._areaElement),i._areaElement.addEventListener("scroll",i.update)})),n(this,"update",(function(){return i._currentVal=w(i._areaElement)})),n(this,"stop",(function(){i._areaElement.removeEventListener("scroll",i.update),i._initialVal={x:0,y:0},i._canScroll=null})),n(this,"reset",(function(){i.stop(),i.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return i.start()})),this.DS.subscribe("Interaction:end",(function(){return i.reset()}))}return r(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=w(e)).x||t.y||(e instanceof HTMLDocument?e.body?e.body.scrollTop=1:e.documentElement.scrollTop=1:e.scrollTop=1)));var e,t}},{key:"scrollAmount",get:function(){var e,t=y(this.currentVal,"-",this.initialVal),r={x:e=this.zoom,y:e},n=y(y(t,"*",r),"-",t);return{x:t.x+n.x,y:t.y+n.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=w(this._areaElement)),this._currentVal}}]),t}();return function(){function t(r){var i=this,o=r.area,s=void 0===o?document:o,a=r.selectables,l=void 0===a?[]:a,c=r.autoScrollSpeed,u=void 0===c?5:c,d=r.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=r.zoom,v=void 0===f?1:f,S=r.customStyles,m=void 0!==S&&S,g=r.multiSelectMode,p=void 0!==g&&g,y=r.multiSelectToggling,b=void 0===y||y,_=r.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,w=r.selector,k=void 0===w?void 0:w,E=r.draggability,x=void 0===E||E,P=r.immediateDrag,I=void 0===P||P,A=r.keyboardDrag,C=void 0===A||A,L=r.dragKeys,V=r.keyboardDragSpeed,N=void 0===V?10:V,G=r.useTransform,X=void 0===G||G,Y=r.hoverClass,$=void 0===Y?"ds-hover":Y,q=r.selectableClass,J=void 0===q?"ds-selectable":q,Q=r.selectedClass,ee=void 0===Q?"ds-selected":Q,te=r.selectorClass,re=void 0===te?"ds-selector":te,ne=r.selectorAreaClass,ie=void 0===ne?"ds-selector-area":ne,oe=r.callback,se=r.onDragMove,ae=r.onDragStartBegin,le=r.onDragStart,ce=r.onElementSelect,ue=r.onElementUnselect;e(this,t),n(this,"continue",!1),n(this,"start",(function(){return i.Interaction.init()})),n(this,"break",(function(){return i.continue=!0})),n(this,"getSelection",(function(){return i.SelectedSet.elements})),n(this,"getSelectables",(function(){return i.SelectableSet.elements})),n(this,"getInitialCursorPosition",(function(){return i.stores.PointerStore.initialVal})),n(this,"getCurrentCursorPosition",(function(){return i.stores.PointerStore.currentVal})),n(this,"getPreviousCursorPosition",(function(){return i.stores.PointerStore.lastVal})),n(this,"getInitialCursorPositionArea",(function(){return i.stores.PointerStore.initialValArea})),n(this,"getCurrentCursorPositionArea",(function(){return i.stores.PointerStore.currentValArea})),n(this,"getPreviousCursorPositionArea",(function(){return i.stores.PointerStore.lastValArea})),n(this,"isMultiSelect",(function(e){return i.stores.KeyStore.isMultiSelectKeyPressed(e)})),n(this,"isDragging",(function(){return i.Interaction.isDragging})),this.PubSub=new z,this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:oe,onDragMove:se,onDragStart:le,onDragStartBegin:ae,onElementSelect:ce,onElementUnselect:ue}),this.stores={PointerStore:new F({DS:this}),ScrollStore:new Z({DS:this,areaElement:s,zoom:v}),KeyStore:new W({DS:this,multiSelectKeys:D,multiSelectMode:p})},this.Area=new M({area:s,PS:this.PubSub,zoom:v}),this.Selector=new B({DS:this,selector:k,selectorClass:re,customStyles:m}),this.SelectorArea=new U({DS:this,selectorAreaClass:ie,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new j({elements:l,DS:this,className:J,hoverClassName:$,useTransform:X,draggability:x}),this.SelectedSet=new H({DS:this,className:ee}),this.Selection=new R({DS:this,hoverClassName:$,multiSelectToggling:b}),this.Drag=new K({DS:this,draggability:x,useTransform:X,keyboardDrag:C,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},L),zoom:v,keyboardDragSpeed:N}),this.Interaction=new O({areaElement:s,DS:this,draggability:x,immediateDrag:I}),T({subscribe:this.subscribe,publish:this.publish,SelectedSet:this.SelectedSet,Interaction:this.Interaction}),this.subscribe("Interaction:end",(function(){return i.continue=!1})),this.start()}return r(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,r=e.onDragMove,n=e.onDragStart,i=e.onDragStartBegin,o=e.onElementSelect,s=e.onElementUnselect,a=function(e,t){return console.warn("[DragSelect] ".concat(e,' is deprecated. Use DragSelect.subscribe("').concat(t,'", (callbackObject) => {}) instead. Act Now! See docs for more info'))};t&&(a("callback","callback"),this.subscribe("callback",(function(e){var r=e.items,n=(e.item,e.event);return t(r,n)}))),r&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),i&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return i(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,r=e.event;return o(t,r)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,r=e.event;return s(t,r)})))}},{key:"stop",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(e),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear()}},{key:"addSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(V(e)),r||this.addSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(V(e)),r&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return V(e).forEach((function(i){return t.SelectedSet.has(i)?t.removeSelection(e,r,n):t.addSelection(e,r,n)})),r&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,r),this.getSelection()}},{key:"clearSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=V(e);return this.SelectableSet.addAll(r),t&&this.SelectedSet.addAll(r),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,r)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(V(e)),t&&this.removeSelection(e),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var r=t?this.getCurrentCursorPositionArea():this.getCurrentCursorPosition(),n=e?t?this.getPreviousCursorPositionArea():this.getPreviousCursorPosition():t?this.getInitialCursorPositionArea():this.getInitialCursorPosition();return y(r,"-",n)}}]),t}()})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DragSelect=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function c(e,t,r){return(c=l()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&a(i,r.prototype),i}).apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return(u=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return c(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)})(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?d(e):t}function f(e){var t=l();return function(){var r,n=s(e);if(t){var i=s(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return h(this,r)}}function v(e,t,r){return(v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}return r}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||g(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var y=function(e,t,r){var n=e.x,i=e.y,o=r.x,s=r.y;return{"+":{x:n+o,y:i+s},"-":{x:n-o,y:i-s},"*":{x:n*o,y:i*s},"/":{x:n/o,y:i/s}}[t]},b=function(e){return{x:e.left,y:e.top}},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}},D=function(){var e,t,r,n;return{y:(null===(e=document.body)||void 0===e?void 0:e.scrollTop)||(null===(t=document.documentElement)||void 0===t?void 0:t.scrollTop)||0,x:(null===(r=document.body)||void 0===r?void 0:r.scrollLeft)||(null===(n=document.documentElement)||void 0===n?void 0:n.scrollLeft)||0}},w=function(e){return!e||e instanceof Document?D():{x:e.scrollLeft>=0?e.scrollLeft:D().x,y:e.scrollTop>=0?e.scrollTop:D().y}},k=function(e){var t=e.elementRect,r=e.containerRect,n=e.tolerance,i=void 0===n?{x:0,y:0}:n,o=[];return t.top-i.y<r.top&&o.push("top"),t.left-i.x<r.left&&o.push("left"),t.bottom+i.y>r.bottom&&o.push("bottom"),t.right+i.y>r.right&&o.push("right"),o},P=function(e){var t={x:0,y:0},r=window.getComputedStyle(e);if(!r.transform||"none"===r.transform)return t;if(r.transform.indexOf("3d")>=0){var n=r.transform.trim().match(/matrix3d\((.*?)\)/);if(n&&n.length){var i,o=null===(i=n[1])||void 0===i?void 0:i.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=r.transform.trim().match(/matrix\((.*?)\)/);if(s&&s.length){var a,l=null===(a=s[1])||void 0===a?void 0:a.split(",");t.x=parseInt(l[4])||0,t.y=parseInt(l[5])||0}return t},E=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return P(e);var r={x:0,y:0},n=t.trim().match(/translate[3dD]*?\(.*?\)/);if(n){var i,o=null===(i=n[0])||void 0===i?void 0:i.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");r.x=parseInt(a[0])||0,r.y=parseInt(a[1])||0}}return r.x||r.x?r:P(e)}(e):function(e){var t=e.style,r={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!r.x&&!r.x){var n=window.getComputedStyle(e);return{x:parseInt(n.left)||0,y:parseInt(n.top)||0}}return r}(e)},x=function(e){var t=e.computedStyle,r=e.node,n=t.position;r instanceof HTMLDocument||("absolute"===n||"relative"===n||"fixed"===n)||(r.style.position="relative")},A=function(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top},I=function(e){var t=e.element,r=e.posDirection,n=e.containerRect,i=e.useTransform,o=E(t,i),s=y(o,"+",r);C(t,s,i);var a=t.getBoundingClientRect();!function(e){var t=e.element,r=e.edges,n=e.elementRect,i=e.containerRect,o=e.elementPos,s=e.useTransform;r.includes("top")&&C(t,{y:o.y+i.top-n.top,x:o.x},s),r.includes("left")&&C(t,{y:o.y,x:o.x+i.left-n.left},s),r.includes("bottom")&&C(t,{y:o.y+i.bottom-n.bottom,x:o.x},s),r.includes("right")&&C(t,{y:o.y,x:o.x+i.right-n.right},s)}({element:t,edges:k({elementRect:a,containerRect:n}),elementRect:a,containerRect:n,elementPos:s,useTransform:i})},C=function(e,t,r){if(r){var n=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(n.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},L=function(e){for(var t=e.subscribe,r=e.publish,o=e.Interaction,s=e.SelectedSet,a=function(){var e=S(c[l],2),a=e[0],u=e[1];["pre",!1].forEach((function(e){return t(e?"".concat(a,":").concat(e):a,(function(t){return u.forEach((function(a){return(!a.condition||a.condition(t))&&r(e?"".concat(e).concat(a.name):a.name,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({items:s.elements,isDragging:o.isDragging},t))}))}))}))},l=0,c=Object.entries({"Selected:added":[{name:"elementselect"}],"Selected:removed":[{name:"elementunselect"}],"Area:scroll":[{name:"autoscroll"}],"Interaction:start":[{name:"dragstart"}],"Interaction:update":[{name:"dragmove",condition:function(e){return e.event}}],"Interaction:end":[{name:"callback"}],"Drag:keyboardDrag":[{name:"dragstart"},{name:"dragmove"}]});l<c.length;l++)a()},T=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:m(e):[]},V=function(e,t){e.style.left="".concat(t.left,"px"),e.style.top="".concat(t.top,"px"),e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px")},N=function(){function t(r){var i,o,s,a=this,l=r.area,c=r.PS,u=r.zoom;e(this,t),n(this,"_modificationCallback",void 0),n(this,"_modificationObserver",void 0),n(this,"_zoom",void 0),n(this,"_node",void 0),n(this,"_parentNodes",void 0),n(this,"_computedStyle",void 0),n(this,"_computedBorder",void 0),n(this,"_rect",void 0),n(this,"start",(function(){var e,t,r;e=a.parentNodes,t=a._modificationCallback,r=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){r.observe(e,{childList:0!==t,attributes:!0})}))})),n(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),n(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),n(this,"scroll",(function(e,t){!function(e,t,r){if(t.length){var n=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,i=e instanceof HTMLDocument?n||document.body:e,o=t.includes("top")&&i.scrollTop>0,s=t.includes("bottom")&&i.scrollTop<i.scrollHeight,a=t.includes("left")&&i.scrollLeft>0,l=t.includes("right")&&i.scrollLeft<i.scrollWidth;o&&(i.scrollTop-=1*r),s&&(i.scrollTop+=1*r),a&&(i.scrollLeft-=1*r),l&&(i.scrollLeft+=1*r)}}(a._node,e,t),a.PubSub.publish("Area:scroll",{scroll_directions:e,scroll_multiplier:t})})),this._node=l,this._zoom=u,this.PubSub=c,x({computedStyle:this.computedStyle,node:this._node}),this._modificationCallback=(i=function(e){a.reset(),a.PubSub.publish("Area:modified",{event:e,item:a})},o=60,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=function(){s=null,i.apply(void 0,t)};clearTimeout(s),s=setTimeout(n,o)}),this._modificationObserver=new MutationObserver(this._modificationCallback),setTimeout((function(){a.reset(),a.PubSub.publish("Area:modified",{event:event,item:a})})),this.PubSub.subscribe("Interaction:init",this.start),this.PubSub.subscribe("Interaction:end",this.reset)}return r(t,[{key:"HTMLNode",get:function(){return this._node}},{key:"computedBorder",get:function(){return this._computedBorder?this._computedBorder:{top:parseInt(this.computedStyle.borderTopWidth),bottom:parseInt(this.computedStyle.borderBottomWidth),left:parseInt(this.computedStyle.borderLeftWidth),right:parseInt(this.computedStyle.borderRightWidth)}}},{key:"computedStyle",get:function(){return this._computedStyle?this._computedStyle:this.HTMLNode instanceof HTMLDocument?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=function(e,t){if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var r=e.getBoundingClientRect();return{top:r.top,left:r.left,bottom:r.bottom,right:r.right,width:(e.clientWidth||r.width)*t,height:(e.clientHeight||r.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=null===(r=t[n])||void 0===r?void 0:r.parentNode;return i?(t.push(i),e(t,++n)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),M=function(){function t(r){var i=this,o=r.DS,s=r.dragKeys,a=r.draggability,l=r.keyboardDrag,c=r.keyboardDragSpeed,u=r.useTransform,d=r.zoom;e(this,t),n(this,"_useTransform",void 0),n(this,"_prevCursorPos",void 0),n(this,"_prevScrollPos",void 0),n(this,"_elements",[]),n(this,"_draggability",void 0),n(this,"_dragKeys",void 0),n(this,"_dragKeysFlat",void 0),n(this,"_keyboardDrag",void 0),n(this,"_keyboardDragSpeed",void 0),n(this,"_zoom",void 0),n(this,"keyboardDrag",(function(e){var t=e.event,r=e.key;if(i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability&&!i.DS.continue){i.DS.publish("Interaction:start",{event:t,isDragging:!0,isDraggingKeyboard:!0}),i._elements=i.DS.getSelection(),i.handleZIndex(!0);var n=function(e){var t=e.shiftKey,r=e.keyboardDragSpeed,n=e.zoom,i=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*r*n:r*n;return o.left.includes(i)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],r)),o.right.includes(i)&&(c.x=s.x||u,t||s.x||!a||l(["right"],r)),o.up.includes(i)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],r)),o.down.includes(i)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],r)),c}({shiftKey:i.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:i._keyboardDragSpeed,zoom:i._zoom,key:r,scrollCallback:i.DS.Area.scroll,scrollDiff:i._scrollDiff,canScroll:i.DS.stores.ScrollStore.canScroll,dragKeys:i._dragKeys});i._elements.forEach((function(e){return I({element:e,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})})),i.DS.publish("Interaction:update",{event:t,isDragging:!0,isDraggingKeyboard:!0})}})),n(this,"keyboardEnd",(function(e){var t=e.event,r=e.key;i._keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i._draggability&&i.DS.publish("Interaction:end",{event:t,isDragging:i._draggability,isDraggingKeyboard:!0})})),n(this,"start",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;t&&!r&&(i._prevCursorPos=null,i._prevScrollPos=null,i._elements=i.DS.getSelection(),i.handleZIndex(!0))})),n(this,"stop",(function(e){null!=e&&e.isKeyboard||(i._prevCursorPos=null,i._prevScrollPos=null,i.handleZIndex(!1),i._elements=[])})),n(this,"update",(function(e){var t=e.isDragging,r=e.isDraggingKeyboard;if(t&&i._elements.length&&!r&&!i.DS.continue){var n=y(i._cursorDiff,"+",i._scrollDiff);i._elements.forEach((function(e){return I({element:e,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i._useTransform})}))}})),n(this,"handleZIndex",(function(e){i._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=u,this._keyboardDragSpeed=c,this._keyboardDrag=l,this._zoom=d,this._draggability=a,this._dragKeys={up:s.up.map((function(e){return e.toLowerCase()})),down:s.down.map((function(e){return e.toLowerCase()})),left:s.left.map((function(e){return e.toLowerCase()})),right:s.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(m(this._dragKeys.up),m(this._dragKeys.down),m(this._dragKeys.left),m(this._dragKeys.right)),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:end",this.stop),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("KeyStore:down",this.keyboardDrag),this.DS.subscribe("KeyStore:up",this.keyboardEnd)}return r(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?y(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}},{key:"_scrollDiff",get:function(){var e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?y(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),K=function(){function t(r){var i=this,o=r.areaElement,s=r.DS,a=r.draggability,l=r.immediateDrag;e(this,t),n(this,"_areaElement",void 0),n(this,"_draggability",void 0),n(this,"_immediateDrag",void 0),n(this,"isInteracting",void 0),n(this,"isDragging",void 0),n(this,"init",(function(){i.stop(),i._areaElement.addEventListener("mousedown",i.start),i._areaElement.addEventListener("touchstart",i.start,{passive:!1}),i.DS.publish("Interaction:init",{})})),n(this,"start",(function(e){"touchstart"===e.type&&e.preventDefault(),i._canInteract(e)&&(i.isInteracting=!0,i.isDragging=i.isDragEvent(e),i.DS.publish("Interaction:start",{event:e,isDragging:i.isDragging}),document.addEventListener("mouseup",i.reset),document.addEventListener("touchend",i.reset))})),n(this,"isDragEvent",(function(e){return!(!i._draggability||i.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!i.DS.SelectableSet.has(e.target))&&(i._immediateDrag&&(i.DS.SelectedSet.size?i.DS.SelectedSet.has(e.target)||(i.DS.SelectedSet.clear(),i.DS.SelectedSet.add(e.target)):i.DS.SelectedSet.add(e.target)),!!i.DS.SelectedSet.has(e.target))})),n(this,"onClick",(function(e){var t=e.event;if(i._canInteract(t)&&!(t.detail>0)){var r=i.DS,n=r.stores,o=n.PointerStore,s=n.KeyStore,a=r.SelectableSet,l=r.SelectedSet,c=r.publish;o.start(t);var u=t.target;a.has(u)&&(s.isMultiSelectKeyPressed(t)||l.clear(),l.toggle(u),c("Interaction:end",{event:t,isDragging:i.isDragging}))}})),n(this,"stop",(function(){i.isInteracting=!1,i.isDragging=!1,i._areaElement.removeEventListener("mousedown",i.start),i._areaElement.removeEventListener("touchstart",i.start,{passive:!1}),document.removeEventListener("mouseup",i.reset),document.removeEventListener("touchend",i.reset)})),n(this,"update",(function(e){var t=e.event,r=e.scroll_directions,n=e.scroll_multiplier;i.isInteracting&&i.DS.publish("Interaction:update",{event:t,scroll_directions:r,scroll_multiplier:n,isDragging:i.isDragging})})),n(this,"reset",(function(e){var t=i.isDragging;i.stop(),i.init(),i.DS.publish("Interaction:end",{event:e,isDragging:t})})),this._areaElement=o,this._draggability=a,this._immediateDrag=l,this.DS=s,this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Area:scroll",this.update)}return r(t,[{key:"_canInteract",value:function(e){var t=0===e.clientX&&0===e.clientY&&0===e.detail&&e.target;return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target)||!t&&!this.DS.SelectorArea.isClicked(e))}}]),t}(),O=function t(){var r=this;e(this,t),n(this,"subscribers",{}),n(this,"subscribe",(function(e,t){return Array.isArray(r.subscribers[e])||(r.subscribers[e]=[]),r.subscribers[e].push(t),r.subscribers[e].length-1})),n(this,"unsubscribe",(function(e,t,n){n>=0?r.subscribers[e].splice(n,1):t&&(r.subscribers[e]=r.subscribers[e].filter((function(e){return e!==t})))})),n(this,"publish",(function(e,t){var n,i;Array.isArray(r.subscribers[e])&&(null===(n=r.subscribers["".concat(e,":pre")])||void 0===n||n.forEach((function(e){return e(t)})),null===(i=r.subscribers[e])||void 0===i||i.forEach((function(e){return e(t)})))}))},j=function(t){o(a,t);var i=f(a);function a(t){var r,o=t.elements,s=t.className,l=t.hoverClassName,c=t.draggability,u=t.useTransform,h=t.DS;return e(this,a),n(d(r=i.call(this)),"_initElements",void 0),n(d(r),"_className",void 0),n(d(r),"_hoverClassName",void 0),n(d(r),"_useTransform",void 0),n(d(r),"_draggability",void 0),n(d(r),"init",(function(){return r._initElements.forEach((function(e){return r.add(e)}))})),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"_onClick",(function(e){return r.DS.publish("Selectable:click",{event:e})})),n(d(r),"_onPointer",(function(e){return r.DS.publish("Selectable:pointer",{event:e})})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=h,r._initElements=T(o),r._className=s,r._hoverClassName=l,r._useTransform=u,r._draggability=c,r.DS.subscribe("Interaction:init",r.init),r}return r(a,[{key:"add",value:function(e){return e.classList.add(this._className),e.addEventListener("click",this._onClick),e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this._draggability&&!this._useTransform&&x({computedStyle:window.getComputedStyle(e),node:e}),v(s(a.prototype),"add",this).call(this,e)}},{key:"delete",value:function(e){return e.classList.remove(this._className),e.classList.remove(this._hoverClassName),e.removeEventListener("click",this._onClick),e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),v(s(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(u(Set)),z=function(t){o(a,t);var i=f(a);function a(t){var r,o=t.className,s=t.DS;return e(this,a),n(d(r=i.call(this)),"_className",void 0),n(d(r),"clear",(function(){return r.forEach((function(e){return r.delete(e)}))})),n(d(r),"addAll",(function(e){return e.forEach((function(e){return r.add(e)}))})),n(d(r),"deleteAll",(function(e){return e.forEach((function(e){return r.delete(e)}))})),r.DS=s,r._className=o,r}return r(a,[{key:"add",value:function(e){if(!v(s(a.prototype),"has",this).call(this,e))return v(s(a.prototype),"add",this).call(this,e),e.classList.add(this._className),this.DS.publish("Selected:added",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+1),this}},{key:"delete",value:function(e){if(v(s(a.prototype),"has",this).call(this,e)){var t=v(s(a.prototype),"delete",this).call(this,e);return e.classList.remove(this._className),this.DS.publish("Selected:removed",{items:this.elements,item:e}),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)-1),t}}},{key:"toggle",value:function(e){return this.has(e)?this.delete(e):this.add(e),e}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(u(Set)),H=function(){function t(r){var i=this,o=r.DS,s=r.hoverClassName,a=r.multiSelectToggling;e(this,t),n(this,"_prevSelectedSet",void 0),n(this,"_hoverClassName",void 0),n(this,"_multiSelectToggling",void 0),n(this,"start",(function(e){var t=e.event;e.isDragging||(i._storePrevious(t),i._handleInsideSelection(!0,t))})),n(this,"update",(function(e){e.isDragging||i.DS.continue||i._handleInsideSelection()})),n(this,"_handleInsideSelection",(function(e,t){for(var r=i.DS,n=r.SelectableSet,o=r.SelectorArea,s=r.Selector,a=n.elements.map((function(e){return[e,e.getBoundingClientRect()]})),l=[],c=[],u=0,d=a.length;u<d;u++)o.isInside(a[u][0],a[u][1])&&(A(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=i.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&i._multiSelectToggling;l.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.multiSelectionToggle,i=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!r||(i.has(t)?n&&i.delete(t):i.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,r=e.force,n=e.SelectedSet,i=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!r)return!1;var s=n.has(t),a=i.has(t);s&&!a?n.delete(t):!s&&a&&n.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:i.DS.SelectedSet,hoverClassName:i._hoverClassName,PrevSelectedSet:i._prevSelectedSet})}))})),this._hoverClassName=s,this._multiSelectToggling=a,this.DS=o,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return r(t,[{key:"_storePrevious",value:function(e){var t=this.DS,r=t.stores.KeyStore,n=t.SelectedSet;r.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(n):this._prevSelectedSet=new Set}}]),t}(),R=function(){function t(r){var i=this,o=r.DS,s=r.selector,a=r.selectorClass,l=r.customStyles;e(this,t),n(this,"_rect",void 0),n(this,"start",(function(e){if(!e.isDragging){var t=i.DS.stores.PointerStore.initialValArea;V(i.HTMLNode,_(t,1)),i.HTMLNode.style.display="block",i._rect=null}})),n(this,"stop",(function(){i.HTMLNode.style.width="0",i.HTMLNode.style.height="0",i.HTMLNode.style.display="none"})),n(this,"update",(function(e){if(!e.isDragging&&!i.DS.continue){var t=i.DS.stores,r=t.ScrollStore,n=t.PointerStore,o=function(e){var t=e.scrollAmount,r=e.initialPointerPos,n=e.pointerPos,i={};return n.x>r.x-t.x?(i.left=r.x-t.x,i.width=n.x-r.x+t.x):(i.left=n.x,i.width=r.x-n.x-t.x),n.y>r.y-t.y?(i.top=r.y-t.y,i.height=n.y-r.y+t.y):(i.top=n.y,i.height=r.y-n.y-t.y),i}({scrollAmount:r.scrollAmount,initialPointerPos:n.initialValArea,pointerPos:n.currentValArea});V(i.HTMLNode,o),i._rect=null}})),this.DS=o,this.HTMLNode=s||function(e){var t=document.createElement("div");return t.style.position="absolute",e||(t.style.background="rgba(0, 0, 255, 0.1)",t.style.border="1px solid rgba(0, 0, 255, 0.45)",t.style.display="none",t.style.pointerEvents="none"),t}(l),this.HTMLNode.classList.add(a),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return r(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),B=function(){function t(r){var i=this,o=r.DS,s=r.selectorAreaClass,a=r.autoScrollSpeed,l=r.overflowTolerance;e(this,t),n(this,"_autoScrollSpeed",void 0),n(this,"_scrollInterval",void 0),n(this,"_rect",void 0),n(this,"currentEdges",[]),n(this,"_overflowTolerance",void 0),n(this,"start",(function(){return i.applyElements("append")})),n(this,"applyElements",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",t=document.body?"body":"documentElement",r="".concat(e,"Child");i.HTMLNode[r](i.DS.Selector.HTMLNode),document[t][r](i.HTMLNode)})),n(this,"updatePos",(function(){i._rect=null;var e=i.DS.Area.rect,t=i.DS.Area.computedBorder,r=i.HTMLNode.style,n="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");r.top!==n&&(r.top=n),r.left!==o&&(r.left=o),r.width!==s&&(r.width=s),r.height!==a&&(r.height=a)})),n(this,"stop",(function(e){i.stopAutoScroll(),e&&i.applyElements("remove")})),n(this,"startAutoScroll",(function(){i.currentEdges=[],i._scrollInterval=setInterval((function(){return i.handleAutoScroll()}),16)})),n(this,"handleAutoScroll",(function(){if(!i.DS.continue){var e=i.DS,t=e.stores.PointerStore,r=e.Area;i.currentEdges=k({elementRect:_(t.currentVal),containerRect:i.rect,tolerance:i._overflowTolerance}),i.currentEdges.length&&r.scroll(i.currentEdges,i._autoScrollSpeed)}})),n(this,"stopAutoScroll",(function(){i.currentEdges=[],clearInterval(i._scrollInterval)})),n(this,"isInside",(function(e,t){return!(!i.DS.Area.HTMLNode.contains(e)||!i.DS.stores.ScrollStore.canScroll)||A(i.rect,t||e.getBoundingClientRect())})),this._autoScrollSpeed=a,this._overflowTolerance=l,this.DS=o,this.HTMLNode=function(e){var t=document.createElement("div");return t.style.position="fixed",t.style.overflow="hidden",t.style.pointerEvents="none",t.style.zIndex="999999999999999999",t.classList.add(e),t}(s),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:init",this.start),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){i.updatePos(),i.stopAutoScroll()}))}return r(t,[{key:"isClicked",value:function(e){var t=this.DS.stores.PointerStore,r=e?t.getPointerPosition(e):t.initialVal;return A({left:r.x,top:r.y,right:r.x,bottom:r.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),U=function(){function t(r){var i=this,o=r.DS,s=r.multiSelectKeys,a=r.multiSelectMode;e(this,t),n(this,"_multiSelectMode",void 0),n(this,"_multiSelectKeys",void 0),n(this,"_currentValues",new Set),n(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),n(this,"init",(function(){document.addEventListener("keydown",i.keydown),document.addEventListener("keyup",i.keyup),window.addEventListener("blur",i.reset)})),n(this,"keydown",(function(e){var t=e.key.toLowerCase();i._currentValues.add(t),i.DS.publish("KeyStore:down",{event:e,key:t})})),n(this,"keyup",(function(e){var t=e.key.toLowerCase();i._currentValues.delete(t),i.DS.publish("KeyStore:up",{event:e,key:t})})),n(this,"stop",(function(){document.removeEventListener("keydown",i.keydown),document.removeEventListener("keyup",i.reset),window.removeEventListener("blur",i.reset),i.reset()})),n(this,"reset",(function(){return i._currentValues.clear()})),this.DS=o,this._multiSelectMode=a,this._multiSelectKeys=s.map((function(e){var t={ctrlKey:"Control",shiftKey:"Shift",metaKey:"Meta"}[e];return t?(console.warn("[DragSelect] ".concat(e,' is deprecated. Use "').concat(t,'" instead. Act Now!. See docs for more info')),t.toLowerCase()):e.toLowerCase()})),this.DS.subscribe("Interaction:init",this.init)}return r(t,[{key:"isMultiSelectKeyPressed",value:function(e){var t=this;return!!this._multiSelectMode||(!!this.currentValues.some((function(e){return t._multiSelectKeys.includes(e)}))||!(!e||!this._multiSelectKeys.some((function(r){return e[t._keyMapping[r]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),W=function(){function t(r){var i=this,o=r.DS;e(this,t),n(this,"_isMouseInteraction",!1),n(this,"_initialValArea",void 0),n(this,"_currentValArea",void 0),n(this,"_lastValArea",void 0),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_lastVal",void 0),n(this,"_lastTouch",void 0),n(this,"init",(function(){document.addEventListener("mousemove",i.update),document.addEventListener("touchmove",i.update,{passive:!1})})),n(this,"getPointerPosition",(function(e){return function(e){var t=e.event;return{x:t.clientX,y:t.clientY}}({event:i._normalizedEvent(e)})})),n(this,"update",(function(e){e&&(i.currentVal=i.getPointerPosition(e),i._isMouseInteraction&&i.DS.publish("PointerStore:updated",{event:e}))})),n(this,"stop",(function(){document.removeEventListener("mousemove",i.update),document.removeEventListener("touchmove",i.update,{passive:!1}),setTimeout((function(){return i._isMouseInteraction=!1}),100)})),n(this,"reset",(function(e){e&&(i.currentVal=i.lastVal=i.getPointerPosition(e),i.stop(),i.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return i.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return i.reset(t)}))}return r(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(e))}},{key:"_normalizedEvent",value:function(e){return"touches"in e&&"touchend"!==e.type&&(this._lastTouch=e),"touches"in e?this._lastTouch.touches[0]:e}},{key:"initialValArea",get:function(){return this._initialValArea?this._initialValArea:{x:0,y:0}}},{key:"currentValArea",get:function(){return this._currentValArea?this._currentValArea:{x:0,y:0}}},{key:"lastValArea",get:function(){return this._lastValArea?this._lastValArea:{x:0,y:0}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}},set:function(e){this._initialVal=e,this._initialValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(e){this._currentVal=e,this._currentValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(e){this._lastVal=e,this._lastValArea=e&&y(e,"-",y(b(this.DS.Area.rect),"+",b(this.DS.Area.computedBorder)))}}]),t}(),F=function(){function t(r){var i=this,o=r.DS,s=r.areaElement,a=r.zoom;e(this,t),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_areaElement",void 0),n(this,"_canScroll",void 0),n(this,"init",(function(){return i._areaElement.addEventListener("scroll",i.update)})),n(this,"start",(function(){i._currentVal=i._initialVal=w(i._areaElement),i._areaElement.addEventListener("scroll",i.update)})),n(this,"update",(function(){return i._currentVal=w(i._areaElement)})),n(this,"stop",(function(){i._areaElement.removeEventListener("scroll",i.update),i._initialVal={x:0,y:0},i._canScroll=null})),n(this,"reset",(function(){i.stop(),i.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return i.start()})),this.DS.subscribe("Interaction:end",(function(){return i.reset()}))}return r(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=w(e)).x||t.y||(e instanceof HTMLDocument?e.body?e.body.scrollTop=1:e.documentElement.scrollTop=1:e.scrollTop=1)));var e,t}},{key:"scrollAmount",get:function(){var e,t=y(this.currentVal,"-",this.initialVal),r={x:e=this.zoom,y:e},n=y(y(t,"*",r),"-",t);return{x:t.x+n.x,y:t.y+n.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=w(this._areaElement)),this._currentVal}}]),t}();return function(){function t(r){var i=this,o=r.area,s=void 0===o?document:o,a=r.selectables,l=void 0===a?[]:a,c=r.autoScrollSpeed,u=void 0===c?5:c,d=r.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=r.zoom,v=void 0===f?1:f,S=r.customStyles,m=void 0!==S&&S,g=r.multiSelectMode,p=void 0!==g&&g,y=r.multiSelectToggling,b=void 0===y||y,_=r.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,w=r.selector,k=void 0===w?void 0:w,P=r.draggability,E=void 0===P||P,x=r.immediateDrag,A=void 0===x||x,I=r.keyboardDrag,C=void 0===I||I,T=r.dragKeys,V=r.keyboardDragSpeed,Z=void 0===V?10:V,X=r.useTransform,Y=void 0===X||X,G=r.hoverClass,$=void 0===G?"ds-hover":G,q=r.selectableClass,J=void 0===q?"ds-selectable":q,Q=r.selectedClass,ee=void 0===Q?"ds-selected":Q,te=r.selectorClass,re=void 0===te?"ds-selector":te,ne=r.selectorAreaClass,ie=void 0===ne?"ds-selector-area":ne,oe=r.callback,se=r.onDragMove,ae=r.onDragStartBegin,le=r.onDragStart,ce=r.onElementSelect,ue=r.onElementUnselect;e(this,t),n(this,"continue",!1),n(this,"start",(function(){return i.Interaction.init()})),n(this,"break",(function(){return i.continue=!0})),n(this,"getSelection",(function(){return i.SelectedSet.elements})),n(this,"getSelectables",(function(){return i.SelectableSet.elements})),n(this,"getInitialCursorPosition",(function(){return i.stores.PointerStore.initialVal})),n(this,"getCurrentCursorPosition",(function(){return i.stores.PointerStore.currentVal})),n(this,"getPreviousCursorPosition",(function(){return i.stores.PointerStore.lastVal})),n(this,"getInitialCursorPositionArea",(function(){return i.stores.PointerStore.initialValArea})),n(this,"getCurrentCursorPositionArea",(function(){return i.stores.PointerStore.currentValArea})),n(this,"getPreviousCursorPositionArea",(function(){return i.stores.PointerStore.lastValArea})),n(this,"isMultiSelect",(function(e){return i.stores.KeyStore.isMultiSelectKeyPressed(e)})),n(this,"isDragging",(function(){return i.Interaction.isDragging})),this.PubSub=new O,this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:oe,onDragMove:se,onDragStart:le,onDragStartBegin:ae,onElementSelect:ce,onElementUnselect:ue}),this.stores={PointerStore:new W({DS:this}),ScrollStore:new F({DS:this,areaElement:s,zoom:v}),KeyStore:new U({DS:this,multiSelectKeys:D,multiSelectMode:p})},this.Area=new N({area:s,PS:this.PubSub,zoom:v}),this.Selector=new R({DS:this,selector:k,selectorClass:re,customStyles:m}),this.SelectorArea=new B({DS:this,selectorAreaClass:ie,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new j({elements:l,DS:this,className:J,hoverClassName:$,useTransform:Y,draggability:E}),this.SelectedSet=new z({DS:this,className:ee}),this.Selection=new H({DS:this,hoverClassName:$,multiSelectToggling:b}),this.Drag=new M({DS:this,draggability:E,useTransform:Y,keyboardDrag:C,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},T),zoom:v,keyboardDragSpeed:Z}),this.Interaction=new K({areaElement:s,DS:this,draggability:E,immediateDrag:A}),L({subscribe:this.subscribe,publish:this.publish,SelectedSet:this.SelectedSet,Interaction:this.Interaction}),this.subscribe("Interaction:end",(function(){return i.continue=!1})),this.start()}return r(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,r=e.onDragMove,n=e.onDragStart,i=e.onDragStartBegin,o=e.onElementSelect,s=e.onElementUnselect,a=function(e,t){return console.warn("[DragSelect] ".concat(e,' is deprecated. Use DragSelect.subscribe("').concat(t,'", (callbackObject) => {}) instead. Act Now! See docs for more info'))};t&&(a("callback","callback"),this.subscribe("callback",(function(e){var r=e.items,n=(e.item,e.event);return t(r,n)}))),r&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),i&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return i(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,r=e.event;return o(t,r)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,r=e.event;return s(t,r)})))}},{key:"stop",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(e),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear()}},{key:"addSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(T(e)),r||this.addSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(T(e)),r&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return T(e).forEach((function(i){return t.SelectedSet.has(i)?t.removeSelection(e,r,n):t.addSelection(e,r,n)})),r&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,r),this.getSelection()}},{key:"clearSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=T(e);return this.SelectableSet.addAll(r),t&&this.SelectedSet.addAll(r),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,r)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(T(e)),t&&this.removeSelection(e),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var r=t?this.getCurrentCursorPositionArea():this.getCurrentCursorPosition(),n=e?t?this.getPreviousCursorPositionArea():this.getPreviousCursorPosition():t?this.getInitialCursorPositionArea():this.getInitialCursorPosition();return y(r,"-",n)}}]),t}()})); |
@@ -38,6 +38,9 @@ export default class Interaction { | ||
init: () => void; | ||
_canInteract(event: any): boolean; | ||
/** | ||
* @param {DSEvent} event | ||
*/ | ||
_canInteract(event: DSEvent): boolean; | ||
/** | ||
* @param {DSEvent} event | ||
*/ | ||
start: (event: DSEvent) => void; | ||
@@ -44,0 +47,0 @@ /** |
@@ -64,5 +64,6 @@ export default class SelectorArea { | ||
* checks if the click was triggered on the area. | ||
* @param {DSEvent} [event] | ||
* @returns {boolean} | ||
*/ | ||
isClicked(): boolean; | ||
isClicked(event?: DSEvent): boolean; | ||
get rect(): DSBoundingRect; | ||
@@ -69,0 +70,0 @@ } |
@@ -58,2 +58,4 @@ export default class PointerStore { | ||
get initialVal(): Vect2; | ||
/** @param {DSEvent} event */ | ||
getPointerPosition: (event: DSEvent) => Vect2; | ||
/** @param {DSEvent} [event] */ | ||
@@ -60,0 +62,0 @@ update: (event?: DSEvent) => void; |
{ | ||
"name": "dragselect", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "easy javascript drag select functionality for your projects", | ||
@@ -5,0 +5,0 @@ "main": "./dist/DragSelect.js", |
@@ -55,8 +55,20 @@ // @ts-check | ||
/** | ||
* @param {DSEvent} event | ||
*/ | ||
_canInteract(event) { | ||
const isKeyboardClick = | ||
/** @type {MouseEvent} */ (event).clientX === 0 && | ||
/** @type {MouseEvent} */ (event).clientY === 0 && | ||
/** @type {MouseEvent} */ (event).detail === 0 && | ||
event.target | ||
if ( | ||
/* right-clicks */ event.button === 2 || | ||
/* fix double-click issues */ this.isInteracting || | ||
/* fix outside elements issue */ (event.target && | ||
!this.DS.SelectorArea.isInside(event.target)) | ||
/** @type {MouseEvent} */ (event).button === 2 || // right-clicks | ||
this.isInteracting || // fix double-click issues | ||
(event.target && | ||
!this.DS.SelectorArea.isInside( | ||
/** @type {DSElement} */ (event.target) | ||
)) || //fix outside elements issue | ||
(!isKeyboardClick && !this.DS.SelectorArea.isClicked(event)) // make sure the mouse click is inside the area | ||
) | ||
@@ -63,0 +75,0 @@ return false |
@@ -149,5 +149,6 @@ // @ts-check | ||
* checks if the click was triggered on the area. | ||
* @param {DSEvent} [event] | ||
* @returns {boolean} | ||
*/ | ||
isClicked() { | ||
isClicked(event) { | ||
const { | ||
@@ -157,8 +158,12 @@ stores: { PointerStore }, | ||
const initialVal = event | ||
? PointerStore.getPointerPosition(event) | ||
: PointerStore.initialVal | ||
return isCollision( | ||
{ | ||
left: PointerStore.initialVal.x, | ||
top: PointerStore.initialVal.y, | ||
right: PointerStore.initialVal.x, | ||
bottom: PointerStore.initialVal.y, | ||
left: initialVal.x, | ||
top: initialVal.y, | ||
right: initialVal.x, | ||
bottom: initialVal.y, | ||
}, | ||
@@ -165,0 +170,0 @@ this.rect |
@@ -73,6 +73,10 @@ import DragSelect from '../DragSelect' | ||
this._isMouseInteraction = true | ||
this.currentVal = this.initialVal = getPointerPos({ | ||
this.currentVal = this.initialVal = this.getPointerPosition(event) | ||
} | ||
/** @param {DSEvent} event */ | ||
getPointerPosition = (event) => | ||
getPointerPos({ | ||
event: this._normalizedEvent(event), | ||
}) | ||
} | ||
@@ -82,5 +86,3 @@ /** @param {DSEvent} [event] */ | ||
if (!event) return | ||
this.currentVal = getPointerPos({ | ||
event: this._normalizedEvent(event), | ||
}) | ||
this.currentVal = this.getPointerPosition(event) | ||
if (!this._isMouseInteraction) return | ||
@@ -104,5 +106,3 @@ this.DS.publish('PointerStore:updated', { event }) | ||
this.currentVal = this.lastVal = getPointerPos({ | ||
event: this._normalizedEvent(event), | ||
}) | ||
this.currentVal = this.lastVal = this.getPointerPosition(event) | ||
@@ -109,0 +109,0 @@ this.stop() |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
498379
105
10458