dragselect
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -0,1 +1,5 @@ | ||
# 2.0.3 | ||
- Correct the behavior of modules/SelectableSet.removeSelectables method, solves #90 thanks to @lchtao26 for the contribution! | ||
# 2.0.2 | ||
@@ -2,0 +6,0 @@ |
@@ -18,7 +18,5 @@ # Don‘t do this if you are not project owner! | ||
1. do thorough testing | ||
2. bump version in .js file | ||
3. run `npm run build` | ||
4. you can deploy a new version by pushing to github | ||
2. `npm run rollup` | ||
3. you can deploy a new version by pushing to github (gh-pages will be build by travis) | ||
Since it uses the `docs/` folder for hosting on `github pages`. | ||
If this was successful, the next step is to publish the new version on `npm`: | ||
@@ -25,0 +23,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 i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(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&&s(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){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 l(e,t,i){return(l=a()?Reflect.construct:function(e,t,i){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return i&&s(n,i.prototype),n}).apply(null,arguments)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;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,r)}function r(){return l(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function h(e){var t=a();return function(){var i,r=o(e);if(t){var n=o(this).constructor;i=Reflect.construct(r,arguments,n)}else i=r.apply(this,arguments);return d(this,i)}}function f(e,t,i){return(f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=o(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(i):n.value}})(e,t,i||e)}function v(e){return function(e){if(Array.isArray(e))return S(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return S(e,t)}(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 S(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}var m=function(e,t,i){var r=e.x,n=e.y,o=i.x,s=i.y;return{"+":{x:r+o,y:n+s},"-":{x:r-o,y:n-s},"*":{x:r*o,y:n*s},"/":{x:r/o,y:n/s}}[t]},g=function(e){return{x:e.left,y:e.top}},p=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}},y=function(){var e,t,i,r;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===(i=document.body)||void 0===i?void 0:i.scrollLeft)||(null===(r=document.documentElement)||void 0===r?void 0:r.scrollLeft)||0}},b=function(e){return!e||e instanceof Document?y():{x:e.scrollLeft>=0?e.scrollLeft:y().x,y:e.scrollTop>=0?e.scrollTop:y().y}},_=function(e){var t=e.elementRect,i=e.containerRect,r=e.tolerance,n=void 0===r?{x:0,y:0}:r,o=[];return t.top-n.y<i.top&&o.push("top"),t.left-n.x<i.left&&o.push("left"),t.bottom+n.y>i.bottom&&o.push("bottom"),t.right+n.y>i.right&&o.push("right"),o},D=function(e){var t=e.event;return{x:t.clientX,y:t.clientY}},w=function(e){var t={x:0,y:0},i=window.getComputedStyle(e);if(!i.transform||"none"===i.transform)return t;if(i.transform.indexOf("3d")>=0){var r=i.transform.trim().match(/matrix3d\((.*?)\)/);if(r&&r.length){var n,o=null===(n=r[1])||void 0===n?void 0:n.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=i.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},x=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return w(e);var i={x:0,y:0},r=t.trim().match(/translate[3dD]*?\(.*?\)/);if(r){var n,o=null===(n=r[0])||void 0===n?void 0:n.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");i.x=parseInt(a[0])||0,i.y=parseInt(a[1])||0}}return i.x||i.x?i:w(e)}(e):function(e){var t=e.style,i={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!i.x&&!i.x){var r=window.getComputedStyle(e);return{x:parseInt(r.left)||0,y:parseInt(r.top)||0}}return i}(e)},k=function(e){var t=e.computedStyle,i=e.node,r=t.position;i instanceof HTMLDocument||("absolute"===r||"relative"===r||"fixed"===r)||(i.style.position="relative")},E=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,i=e.posDirection,r=e.containerRect,n=e.useTransform,o=x(t,n),s=m(o,"+",i);P(t,s,n);var a=t.getBoundingClientRect();!function(e){var t=e.element,i=e.edges,r=e.elementRect,n=e.containerRect,o=e.elementPos,s=e.useTransform;i.includes("top")&&P(t,{y:o.y+n.top-r.top,x:o.x},s),i.includes("left")&&P(t,{y:o.y,x:o.x+n.left-r.left},s),i.includes("bottom")&&P(t,{y:o.y+n.bottom-r.bottom,x:o.x},s),i.includes("right")&&P(t,{y:o.y,x:o.x+n.right-r.right},s)}({element:t,edges:_({elementRect:a,containerRect:r}),elementRect:a,containerRect:r,elementPos:s,useTransform:n})},P=function(e,t,i){if(i){var r=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(r.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},A=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:v(e):[]},L=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")},C=function(){function t(i){var n,o,s,a=this,l=i.area,c=i.PS,u=i.zoom;e(this,t),r(this,"_modificationCallback",void 0),r(this,"_modificationObserver",void 0),r(this,"_zoom",void 0),r(this,"_node",void 0),r(this,"_parentNodes",void 0),r(this,"_computedStyle",void 0),r(this,"_computedBorder",void 0),r(this,"_rect",void 0),r(this,"start",(function(){var e,t,i;e=a.parentNodes,t=a._modificationCallback,i=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){i.observe(e,{childList:0!==t,attributes:!0})}))})),r(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),r(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),r(this,"scroll",(function(e,t){!function(e,t,i){if(t.length){var r=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,n=e instanceof HTMLDocument?r||document.body:e,o=t.includes("top")&&n.scrollTop>0,s=t.includes("bottom")&&n.scrollTop<n.scrollHeight,a=t.includes("left")&&n.scrollLeft>0,l=t.includes("right")&&n.scrollLeft<n.scrollWidth;o&&(n.scrollTop-=1*i),s&&(n.scrollTop+=1*i),a&&(n.scrollLeft-=1*i),l&&(n.scrollLeft+=1*i)}}(a._node,e,t),a.PubSub.publish("Area:scroll",{scroll_directions:e,scroll_multiplier:t})})),this._node=l,this._zoom=u,this.PubSub=c,k({computedStyle:this.computedStyle,node:this._node}),this._modificationCallback=(n=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),i=0;i<e;i++)t[i]=arguments[i];var r=function(){s=null,n.apply(void 0,t)};clearTimeout(s),s=setTimeout(r,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 i(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 i=e.getBoundingClientRect();return{top:i.top,left:i.left,bottom:i.bottom,right:i.right,width:(e.clientWidth||i.width)*t,height:(e.clientHeight||i.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=null===(i=t[r])||void 0===i?void 0:i.parentNode;return n?(t.push(n),e(t,++r)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),T=function(){function t(i){var n=this,o=i.DS,s=i.useTransform,a=i.dragKeys,l=i.keyboardDragSpeed,c=i.zoom;e(this,t),r(this,"_useTransform",void 0),r(this,"_prevCursorPos",void 0),r(this,"_prevScrollPos",void 0),r(this,"_elements",[]),r(this,"_dragKeys",void 0),r(this,"_dragKeysFlat",void 0),r(this,"_keyboardDragSpeed",void 0),r(this,"_zoom",void 0),r(this,"keyboardDrag",(function(e){var t=e.event,i=e.key;if(n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size){n._isKeyboard=!0,n.DS.publish("Interaction:start",{event:t,isDragging:!0}),n._elements=n.DS.getSelection(),n.handleZIndex(!0);var r=function(e){var t=e.shiftKey,i=e.keyboardDragSpeed,r=e.zoom,n=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*i*r:i*r;return o.left.includes(n)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],i)),o.right.includes(n)&&(c.x=s.x||u,t||s.x||!a||l(["right"],i)),o.up.includes(n)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],i)),o.down.includes(n)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],i)),c}({shiftKey:n.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:n._keyboardDragSpeed,zoom:n._zoom,key:i,scrollCallback:n.DS.Area.scroll,scrollDiff:n._scrollDiff,canScroll:n.DS.stores.ScrollStore.canScroll,dragKeys:n._dragKeys});n._elements.forEach((function(e){return I({element:e,posDirection:r,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})})),n.DS.publish("Interaction:update",{event:t,isDragging:!0}),n._isKeyboard=!1}})),r(this,"keyboardEnd",(function(e){var t=e.event,i=e.key;n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size&&(n._isKeyboard=!0,n.DS.publish("Interaction:end",{event:t,isDragging:!0}),n._isKeyboard=!1)})),r(this,"start",(function(e){e.isDragging&&!n._isKeyboard&&(n._prevCursorPos=null,n._prevScrollPos=null,n._elements=n.DS.getSelection(),n.handleZIndex(!0))})),r(this,"stop",(function(){n._isKeyboard||(n._prevCursorPos=null,n._prevScrollPos=null,n.handleZIndex(!1),n._elements=[])})),r(this,"update",(function(e){if(e.isDragging&&n._elements.length&&!n._isKeyboard){var t=m(n._cursorDiff,"+",n._scrollDiff);n._elements.forEach((function(e){return I({element:e,posDirection:t,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})}))}})),r(this,"handleZIndex",(function(e){n._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=s,this._keyboardDragSpeed=l,this._zoom=c,this._dragKeys={up:a.up.map((function(e){return e.toLowerCase()})),down:a.down.map((function(e){return e.toLowerCase()})),left:a.left.map((function(e){return e.toLowerCase()})),right:a.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(v(this._dragKeys.up),v(this._dragKeys.down),v(this._dragKeys.left),v(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 i(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?m(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?m(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),V=function(){function t(i){var n=this,o=i.areaElement,s=i.DS,a=i.draggability,l=i.immediateDrag;e(this,t),r(this,"_areaElement",void 0),r(this,"_draggability",void 0),r(this,"_immediateDrag",void 0),r(this,"isInteracting",void 0),r(this,"isDragging",void 0),r(this,"init",(function(){n.stop(),n._areaElement.addEventListener("mousedown",n.start),n._areaElement.addEventListener("touchstart",n.start,{passive:!1}),n.DS.publish("Interaction:init",{})})),r(this,"start",(function(e){"touchstart"===e.type&&e.preventDefault(),n._canInteract(e)&&(n.isInteracting=!0,n.isDragging=n.isDragEvent(e),n.DS.publish("Interaction:start",{event:e,isDragging:n.isDragging}),document.addEventListener("mouseup",n.reset),document.addEventListener("touchend",n.reset))})),r(this,"isDragEvent",(function(e){return!(!n._draggability||n.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!n.DS.SelectableSet.has(e.target))&&(n._immediateDrag&&(n.DS.SelectedSet.size?n.DS.SelectedSet.has(e.target)||(n.DS.SelectedSet.clear(),n.DS.SelectedSet.add(e.target)):n.DS.SelectedSet.add(e.target)),!!n.DS.SelectedSet.has(e.target))})),r(this,"onClick",(function(e){var t=e.event;if(n._canInteract(t)&&!(t.detail>0)){var i=n.DS,r=i.stores,o=r.PointerStore,s=r.KeyStore,a=i.SelectableSet,l=i.SelectedSet,c=i.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:n.isDragging}))}})),r(this,"stop",(function(){n.isInteracting=!1,n.isDragging=!1,n._areaElement.removeEventListener("mousedown",n.start),n._areaElement.removeEventListener("touchstart",n.start,{passive:!1}),document.removeEventListener("mouseup",n.reset),document.removeEventListener("touchend",n.reset)})),r(this,"update",(function(e){var t=e.event,i=e.data;n.isInteracting&&n.DS.publish("Interaction:update",{event:t,data:i,isDragging:n.isDragging})})),r(this,"reset",(function(e){var t=n.isDragging;n.stop(),n.init(),n.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 n.start(t)})),this.DS.subscribe("Area:scroll",this.update)}return i(t,[{key:"_canInteract",value:function(e){return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target))}}]),t}(),N=function t(){var i=this;e(this,t),r(this,"subscribers",{}),r(this,"subscribe",(function(e,t){return Array.isArray(i.subscribers[e])||(i.subscribers[e]=[]),i.subscribers[e].push(t),i.subscribers[e].length-1})),r(this,"unsubscribe",(function(e,t,r){r>=0?i.subscribers[e].splice(r,1):t&&(i.subscribers[e]=i.subscribers[e].filter((function(e){return e!==t})))})),r(this,"publish",(function(e,t){Array.isArray(i.subscribers[e])&&i.subscribers[e].forEach((function(e){return e(t)}))}))},M=function(t){n(a,c(Set));var s=h(a);function a(t){var i,n=t.elements,o=t.className,l=t.hoverClassName,c=t.draggability,d=t.useTransform,h=t.DS;return e(this,a),r(u(i=s.call(this)),"_initElements",void 0),r(u(i),"_className",void 0),r(u(i),"_hoverClassName",void 0),r(u(i),"_useTransform",void 0),r(u(i),"_draggability",void 0),r(u(i),"init",(function(){return i._initElements.forEach((function(e){return i.add(e)}))})),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"_onClick",(function(e){return i.DS.publish("Selectable:click",{event:e})})),r(u(i),"_onPointer",(function(e){return i.DS.publish("Selectable:pointer",{event:e})})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=h,i._initElements=A(n),i._className=o,i._hoverClassName=l,i._useTransform=d,i._draggability=c,i.DS.subscribe("Interaction:init",i.init),i}return i(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&&k({computedStyle:window.getComputedStyle(e),node:e}),f(o(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}),f(o(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(),K=function(t){n(a,c(Set));var s=h(a);function a(t){var i,n=t.className,o=t.DS;return e(this,a),r(u(i=s.call(this)),"_className",void 0),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=o,i._className=n,i}return i(a,[{key:"add",value:function(e){if(!f(o(a.prototype),"has",this).call(this,e))return f(o(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(f(o(a.prototype),"has",this).call(this,e)){var t=f(o(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}(),z=function(){function t(i){var n=this,o=i.DS,s=i.hoverClassName,a=i.multiSelectToggling;e(this,t),r(this,"_prevSelectedSet",void 0),r(this,"_hoverClassName",void 0),r(this,"_multiSelectToggling",void 0),r(this,"start",(function(e){var t=e.event;e.isDragging||(n._storePrevious(t),n._handleInsideSelection(!0,t))})),r(this,"update",(function(e){e.isDragging||n._handleInsideSelection()})),r(this,"_handleInsideSelection",(function(e,t){for(var i=n.DS,r=i.SelectableSet,o=i.SelectorArea,s=i.Selector,a=r.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])&&(E(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=n.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&n._multiSelectToggling;l.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.multiSelectionToggle,n=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!i||(n.has(t)?r&&n.delete(t):n.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.SelectedSet,n=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!i)return!1;var s=r.has(t),a=n.has(t);s&&!a?r.delete(t):!s&&a&&r.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName,PrevSelectedSet:n._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 i(t,[{key:"_storePrevious",value:function(e){var t=this.DS,i=t.stores.KeyStore,r=t.SelectedSet;i.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(r):this._prevSelectedSet=new Set}}]),t}(),H=function(){function t(i){var n=this,o=i.DS,s=i.selector,a=i.selectorClass,l=i.customStyles;e(this,t),r(this,"_rect",void 0),r(this,"start",(function(e){if(!e.isDragging){var t=n.DS.stores.PointerStore.initialValArea;L(n.HTMLNode,p(t,1)),n.HTMLNode.style.display="block",n._rect=null}})),r(this,"stop",(function(){n.HTMLNode.style.width="0",n.HTMLNode.style.height="0",n.HTMLNode.style.display="none"})),r(this,"update",(function(e){if(!e.isDragging){var t=n.DS.stores,i=t.ScrollStore,r=t.PointerStore,o=function(e){var t=e.scrollAmount,i=e.initialPointerPos,r=e.pointerPos,n={};return r.x>i.x-t.x?(n.left=i.x-t.x,n.width=r.x-i.x+t.x):(n.left=r.x,n.width=i.x-r.x-t.x),r.y>i.y-t.y?(n.top=i.y-t.y,n.height=r.y-i.y+t.y):(n.top=r.y,n.height=i.y-r.y-t.y),n}({scrollAmount:i.scrollAmount,initialPointerPos:r.initialValArea,pointerPos:r.currentValArea});L(n.HTMLNode,o),n._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 i(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),R=function(){function t(i){var n=this,o=i.DS,s=i.selectorAreaClass,a=i.autoScrollSpeed,l=i.overflowTolerance;e(this,t),r(this,"_autoScrollSpeed",void 0),r(this,"_scrollInterval",void 0),r(this,"_rect",void 0),r(this,"currentEdges",[]),r(this,"_overflowTolerance",void 0),r(this,"updatePos",(function(){n._rect=null;var e=n.DS.Area.rect,t=n.DS.Area.computedBorder,i=n.HTMLNode.style,r="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");i.top!==r&&(i.top=r),i.left!==o&&(i.left=o),i.width!==s&&(i.width=s),i.height!==a&&(i.height=a)})),r(this,"startAutoScroll",(function(){n.currentEdges=[],n._scrollInterval=setInterval((function(){return n.handleAutoScroll()}),16)})),r(this,"handleAutoScroll",(function(){var e=n.DS,t=e.stores.PointerStore,i=e.Area;n.currentEdges=_({elementRect:p(t.currentVal),containerRect:n.rect,tolerance:n._overflowTolerance}),n.currentEdges.length&&i.scroll(n.currentEdges,n._autoScrollSpeed)})),r(this,"stopAutoScroll",(function(){n.currentEdges=[],clearInterval(n._scrollInterval)})),r(this,"isInside",(function(e,t){return!(!n.DS.Area.HTMLNode.contains(e)||!n.DS.stores.ScrollStore.canScroll)||E(n.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.HTMLNode.appendChild(this.DS.Selector.HTMLNode);var c=document.body?"body":"documentElement";document[c].appendChild(this.HTMLNode),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){n.updatePos(),n.stopAutoScroll()}))}return i(t,[{key:"isClicked",value:function(){var e=this.DS.stores.PointerStore;return E({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}(),O=function(){function t(i){var n=this,o=i.DS,s=i.multiSelectKeys,a=i.multiSelectMode;e(this,t),r(this,"_multiSelectMode",void 0),r(this,"_multiSelectKeys",void 0),r(this,"_currentValues",new Set),r(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),r(this,"init",(function(){document.addEventListener("keydown",n.keydown),document.addEventListener("keyup",n.keyup),window.addEventListener("blur",n.reset)})),r(this,"keydown",(function(e){var t=e.key.toLowerCase();n._currentValues.add(t),n.DS.publish("KeyStore:down",{event:e,key:t})})),r(this,"keyup",(function(e){var t=e.key.toLowerCase();n._currentValues.delete(t),n.DS.publish("KeyStore:up",{event:e,key:t})})),r(this,"stop",(function(){document.removeEventListener("keydown",n.keydown),document.removeEventListener("keyup",n.reset),window.removeEventListener("blur",n.reset),n.reset()})),r(this,"reset",(function(){return n._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 i(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(i){return e[t._keyMapping[i]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),B=function(){function t(i){var n=this,o=i.DS;e(this,t),r(this,"_isMouseInteraction",!1),r(this,"_initialValArea",void 0),r(this,"_currentValArea",void 0),r(this,"_lastValArea",void 0),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_lastVal",void 0),r(this,"_lastTouch",void 0),r(this,"init",(function(){document.addEventListener("mousemove",n.update),document.addEventListener("touchmove",n.update,{passive:!1})})),r(this,"update",(function(e){e&&(n.currentVal=D({event:n._normalizedEvent(e)}),n._isMouseInteraction&&n.DS.publish("PointerStore:updated",{event:e}))})),r(this,"stop",(function(){document.removeEventListener("mousemove",n.update),document.removeEventListener("touchmove",n.update,{passive:!1}),setTimeout((function(){return n._isMouseInteraction=!1}),100)})),r(this,"reset",(function(e){e&&(n.currentVal=n.lastVal=D({event:n._normalizedEvent(e)}),n.stop(),n.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return n.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return n.reset(t)}))}return i(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=D({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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(this.DS.Area.computedBorder)))}}]),t}(),j=function(){function t(i){var n=this,o=i.DS,s=i.areaElement,a=i.zoom;e(this,t),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_areaElement",void 0),r(this,"_canScroll",void 0),r(this,"init",(function(){return n._areaElement.addEventListener("scroll",n.update)})),r(this,"start",(function(){n._currentVal=n._initialVal=b(n._areaElement),n._areaElement.addEventListener("scroll",n.update)})),r(this,"update",(function(){return n._currentVal=b(n._areaElement)})),r(this,"stop",(function(){n._areaElement.removeEventListener("scroll",n.update),n._initialVal={x:0,y:0},n._canScroll=null})),r(this,"reset",(function(){n.stop(),n.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return n.start()})),this.DS.subscribe("Interaction:end",(function(){return n.reset()}))}return i(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=b(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=m(this.currentVal,"-",this.initialVal),i={x:e=this.zoom,y:e},r=m(m(t,"*",i),"-",t);return{x:t.x+r.x,y:t.y+r.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=b(this._areaElement)),this._currentVal}}]),t}(),U=function(){function t(i){var n=this,o=i.area,s=void 0===o?document:o,a=i.selectables,l=void 0===a?[]:a,c=i.autoScrollSpeed,u=void 0===c?5:c,d=i.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=i.zoom,v=void 0===f?1:f,S=i.customStyles,m=void 0!==S&&S,g=i.multiSelectMode,p=void 0!==g&&g,y=i.multiSelectToggling,b=void 0===y||y,_=i.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,w=i.selector,x=void 0===w?void 0:w,k=i.draggability,E=void 0===k||k,I=i.immediateDrag,P=void 0===I||I,A=i.dragKeys,L=i.keyboardDragSpeed,U=void 0===L?10:L,W=i.useTransform,F=void 0===W||W,Z=i.hoverClass,G=void 0===Z?"ds-hover":Z,X=i.selectableClass,Y=void 0===X?"ds-selectable":X,$=i.selectedClass,q=void 0===$?"ds-selected":$,J=i.selectorClass,Q=void 0===J?"ds-selector":J,ee=i.selectorAreaClass,te=void 0===ee?"ds-selector-area":ee,ie=i.callback,re=i.onDragMove,ne=i.onDragStartBegin,oe=i.onDragStart,se=i.onElementSelect,ae=i.onElementUnselect;e(this,t),r(this,"start",(function(){return n.Interaction.init()})),r(this,"getSelection",(function(){return n.SelectedSet.elements})),r(this,"getSelectables",(function(){return n.SelectableSet.elements})),r(this,"getInitialCursorPosition",(function(){return n.stores.PointerStore.initialVal})),r(this,"getCurrentCursorPosition",(function(){return n.stores.PointerStore.currentVal})),r(this,"getPreviousCursorPosition",(function(){return n.stores.PointerStore.lastVal})),r(this,"getInitialCursorPositionArea",(function(){return n.stores.PointerStore.initialValArea})),r(this,"getCurrentCursorPositionArea",(function(){return n.stores.PointerStore.currentValArea})),r(this,"getPreviousCursorPositionArea",(function(){return n.stores.PointerStore.lastValArea})),r(this,"isMultiSelect",(function(e){return n.stores.KeyStore.isMultiSelectKeyPressed(e)})),r(this,"isDragging",(function(){return n.Interaction.isDragging})),this.PubSub=new N,this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:ie,onDragMove:re,onDragStart:oe,onDragStartBegin:ne,onElementSelect:se,onElementUnselect:ae}),this.stores={PointerStore:new B({DS:this}),ScrollStore:new j({DS:this,areaElement:s,zoom:v}),KeyStore:new O({DS:this,multiSelectKeys:D,multiSelectMode:p})},this.Area=new C({area:s,PS:this.PubSub,zoom:v}),this.Selector=new H({DS:this,selector:x,selectorClass:Q,customStyles:m}),this.SelectorArea=new R({DS:this,selectorAreaClass:te,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new M({elements:l,DS:this,className:Y,hoverClassName:G,useTransform:F,draggability:E}),this.SelectedSet=new K({DS:this,className:q}),this.Selection=new z({DS:this,hoverClassName:G,multiSelectToggling:b}),this.Drag=new T({DS:this,useTransform:F,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},A),zoom:v,keyboardDragSpeed:U}),this.Interaction=new V({areaElement:s,DS:this,draggability:E,immediateDrag:P}),this.subscribe("Selected:added",(function(e){var t=e.items,i=e.item;return n.publish("elementselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Selected:removed",(function(e){var t=e.items,i=e.item;return n.publish("elementunselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:update",(function(e){var t=e.event,i=e.isDragging;t&&n.publish("dragmove",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Area:scroll",(function(e){var t=e.scroll_directions,i=e.scroll_multiplier;n.publish("autoscroll",{items:n.getSelection(),scroll_directions:t,scroll_multiplier:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:start",(function(e){var t=e.event,i=e.isDragging;return n.publish("dragstart",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Interaction:end",(function(e){var t=e.event,i=e.isDragging;return n.publish("callback",{items:n.getSelection(),event:t,isDragging:i})})),this.start()}return i(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,i=e.onDragMove,r=e.onDragStart,n=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 i=e.items,r=(e.item,e.event);return t(i,r)}))),i&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return i(t)}))),r&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,i=e.event;return o(t,i)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,i=e.event;return s(t,i)})))}},{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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(A(e)),i||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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(A(e)),i&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return A(e).forEach((function(n){return t.SelectedSet.has(n)?t.removeSelection(e,i,r):t.addSelection(e,i,r)})),i&&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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,i),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],i=A(e);return this.SelectableSet.addAll(i),t&&this.SelectedSet.addAll(i),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,i)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectedSet.clear(),t&&this.SelectedSet.clear(),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var t=this.getCurrentCursorPosition(),i=e?this.getPreviousCursorPosition():this.getInitialCursorPosition();return m(t,"-",i)}}]),t}();export default U; | ||
function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(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&&s(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){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 l(e,t,i){return(l=a()?Reflect.construct:function(e,t,i){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return i&&s(n,i.prototype),n}).apply(null,arguments)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;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,r)}function r(){return l(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function h(e){var t=a();return function(){var i,r=o(e);if(t){var n=o(this).constructor;i=Reflect.construct(r,arguments,n)}else i=r.apply(this,arguments);return d(this,i)}}function f(e,t,i){return(f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=o(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(i):n.value}})(e,t,i||e)}function v(e){return function(e){if(Array.isArray(e))return S(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return S(e,t)}(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 S(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}var m=function(e,t,i){var r=e.x,n=e.y,o=i.x,s=i.y;return{"+":{x:r+o,y:n+s},"-":{x:r-o,y:n-s},"*":{x:r*o,y:n*s},"/":{x:r/o,y:n/s}}[t]},g=function(e){return{x:e.left,y:e.top}},p=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}},y=function(){var e,t,i,r;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===(i=document.body)||void 0===i?void 0:i.scrollLeft)||(null===(r=document.documentElement)||void 0===r?void 0:r.scrollLeft)||0}},b=function(e){return!e||e instanceof Document?y():{x:e.scrollLeft>=0?e.scrollLeft:y().x,y:e.scrollTop>=0?e.scrollTop:y().y}},_=function(e){var t=e.elementRect,i=e.containerRect,r=e.tolerance,n=void 0===r?{x:0,y:0}:r,o=[];return t.top-n.y<i.top&&o.push("top"),t.left-n.x<i.left&&o.push("left"),t.bottom+n.y>i.bottom&&o.push("bottom"),t.right+n.y>i.right&&o.push("right"),o},D=function(e){var t=e.event;return{x:t.clientX,y:t.clientY}},w=function(e){var t={x:0,y:0},i=window.getComputedStyle(e);if(!i.transform||"none"===i.transform)return t;if(i.transform.indexOf("3d")>=0){var r=i.transform.trim().match(/matrix3d\((.*?)\)/);if(r&&r.length){var n,o=null===(n=r[1])||void 0===n?void 0:n.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=i.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},x=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return w(e);var i={x:0,y:0},r=t.trim().match(/translate[3dD]*?\(.*?\)/);if(r){var n,o=null===(n=r[0])||void 0===n?void 0:n.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");i.x=parseInt(a[0])||0,i.y=parseInt(a[1])||0}}return i.x||i.x?i:w(e)}(e):function(e){var t=e.style,i={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!i.x&&!i.x){var r=window.getComputedStyle(e);return{x:parseInt(r.left)||0,y:parseInt(r.top)||0}}return i}(e)},k=function(e){var t=e.computedStyle,i=e.node,r=t.position;i instanceof HTMLDocument||("absolute"===r||"relative"===r||"fixed"===r)||(i.style.position="relative")},E=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,i=e.posDirection,r=e.containerRect,n=e.useTransform,o=x(t,n),s=m(o,"+",i);P(t,s,n);var a=t.getBoundingClientRect();!function(e){var t=e.element,i=e.edges,r=e.elementRect,n=e.containerRect,o=e.elementPos,s=e.useTransform;i.includes("top")&&P(t,{y:o.y+n.top-r.top,x:o.x},s),i.includes("left")&&P(t,{y:o.y,x:o.x+n.left-r.left},s),i.includes("bottom")&&P(t,{y:o.y+n.bottom-r.bottom,x:o.x},s),i.includes("right")&&P(t,{y:o.y,x:o.x+n.right-r.right},s)}({element:t,edges:_({elementRect:a,containerRect:r}),elementRect:a,containerRect:r,elementPos:s,useTransform:n})},P=function(e,t,i){if(i){var r=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(r.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},A=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:v(e):[]},L=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")},C=function(){function t(i){var n,o,s,a=this,l=i.area,c=i.PS,u=i.zoom;e(this,t),r(this,"_modificationCallback",void 0),r(this,"_modificationObserver",void 0),r(this,"_zoom",void 0),r(this,"_node",void 0),r(this,"_parentNodes",void 0),r(this,"_computedStyle",void 0),r(this,"_computedBorder",void 0),r(this,"_rect",void 0),r(this,"start",(function(){var e,t,i;e=a.parentNodes,t=a._modificationCallback,i=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){i.observe(e,{childList:0!==t,attributes:!0})}))})),r(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),r(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),r(this,"scroll",(function(e,t){!function(e,t,i){if(t.length){var r=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,n=e instanceof HTMLDocument?r||document.body:e,o=t.includes("top")&&n.scrollTop>0,s=t.includes("bottom")&&n.scrollTop<n.scrollHeight,a=t.includes("left")&&n.scrollLeft>0,l=t.includes("right")&&n.scrollLeft<n.scrollWidth;o&&(n.scrollTop-=1*i),s&&(n.scrollTop+=1*i),a&&(n.scrollLeft-=1*i),l&&(n.scrollLeft+=1*i)}}(a._node,e,t),a.PubSub.publish("Area:scroll",{scroll_directions:e,scroll_multiplier:t})})),this._node=l,this._zoom=u,this.PubSub=c,k({computedStyle:this.computedStyle,node:this._node}),this._modificationCallback=(n=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),i=0;i<e;i++)t[i]=arguments[i];var r=function(){s=null,n.apply(void 0,t)};clearTimeout(s),s=setTimeout(r,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 i(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 i=e.getBoundingClientRect();return{top:i.top,left:i.left,bottom:i.bottom,right:i.right,width:(e.clientWidth||i.width)*t,height:(e.clientHeight||i.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=null===(i=t[r])||void 0===i?void 0:i.parentNode;return n?(t.push(n),e(t,++r)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),T=function(){function t(i){var n=this,o=i.DS,s=i.useTransform,a=i.dragKeys,l=i.keyboardDragSpeed,c=i.zoom;e(this,t),r(this,"_useTransform",void 0),r(this,"_prevCursorPos",void 0),r(this,"_prevScrollPos",void 0),r(this,"_elements",[]),r(this,"_dragKeys",void 0),r(this,"_dragKeysFlat",void 0),r(this,"_keyboardDragSpeed",void 0),r(this,"_zoom",void 0),r(this,"keyboardDrag",(function(e){var t=e.event,i=e.key;if(n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size){n._isKeyboard=!0,n.DS.publish("Interaction:start",{event:t,isDragging:!0}),n._elements=n.DS.getSelection(),n.handleZIndex(!0);var r=function(e){var t=e.shiftKey,i=e.keyboardDragSpeed,r=e.zoom,n=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*i*r:i*r;return o.left.includes(n)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],i)),o.right.includes(n)&&(c.x=s.x||u,t||s.x||!a||l(["right"],i)),o.up.includes(n)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],i)),o.down.includes(n)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],i)),c}({shiftKey:n.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:n._keyboardDragSpeed,zoom:n._zoom,key:i,scrollCallback:n.DS.Area.scroll,scrollDiff:n._scrollDiff,canScroll:n.DS.stores.ScrollStore.canScroll,dragKeys:n._dragKeys});n._elements.forEach((function(e){return I({element:e,posDirection:r,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})})),n.DS.publish("Interaction:update",{event:t,isDragging:!0}),n._isKeyboard=!1}})),r(this,"keyboardEnd",(function(e){var t=e.event,i=e.key;n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size&&(n._isKeyboard=!0,n.DS.publish("Interaction:end",{event:t,isDragging:!0}),n._isKeyboard=!1)})),r(this,"start",(function(e){e.isDragging&&!n._isKeyboard&&(n._prevCursorPos=null,n._prevScrollPos=null,n._elements=n.DS.getSelection(),n.handleZIndex(!0))})),r(this,"stop",(function(){n._isKeyboard||(n._prevCursorPos=null,n._prevScrollPos=null,n.handleZIndex(!1),n._elements=[])})),r(this,"update",(function(e){if(e.isDragging&&n._elements.length&&!n._isKeyboard){var t=m(n._cursorDiff,"+",n._scrollDiff);n._elements.forEach((function(e){return I({element:e,posDirection:t,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})}))}})),r(this,"handleZIndex",(function(e){n._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=s,this._keyboardDragSpeed=l,this._zoom=c,this._dragKeys={up:a.up.map((function(e){return e.toLowerCase()})),down:a.down.map((function(e){return e.toLowerCase()})),left:a.left.map((function(e){return e.toLowerCase()})),right:a.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(v(this._dragKeys.up),v(this._dragKeys.down),v(this._dragKeys.left),v(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 i(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?m(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?m(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),V=function(){function t(i){var n=this,o=i.areaElement,s=i.DS,a=i.draggability,l=i.immediateDrag;e(this,t),r(this,"_areaElement",void 0),r(this,"_draggability",void 0),r(this,"_immediateDrag",void 0),r(this,"isInteracting",void 0),r(this,"isDragging",void 0),r(this,"init",(function(){n.stop(),n._areaElement.addEventListener("mousedown",n.start),n._areaElement.addEventListener("touchstart",n.start,{passive:!1}),n.DS.publish("Interaction:init",{})})),r(this,"start",(function(e){"touchstart"===e.type&&e.preventDefault(),n._canInteract(e)&&(n.isInteracting=!0,n.isDragging=n.isDragEvent(e),n.DS.publish("Interaction:start",{event:e,isDragging:n.isDragging}),document.addEventListener("mouseup",n.reset),document.addEventListener("touchend",n.reset))})),r(this,"isDragEvent",(function(e){return!(!n._draggability||n.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!n.DS.SelectableSet.has(e.target))&&(n._immediateDrag&&(n.DS.SelectedSet.size?n.DS.SelectedSet.has(e.target)||(n.DS.SelectedSet.clear(),n.DS.SelectedSet.add(e.target)):n.DS.SelectedSet.add(e.target)),!!n.DS.SelectedSet.has(e.target))})),r(this,"onClick",(function(e){var t=e.event;if(n._canInteract(t)&&!(t.detail>0)){var i=n.DS,r=i.stores,o=r.PointerStore,s=r.KeyStore,a=i.SelectableSet,l=i.SelectedSet,c=i.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:n.isDragging}))}})),r(this,"stop",(function(){n.isInteracting=!1,n.isDragging=!1,n._areaElement.removeEventListener("mousedown",n.start),n._areaElement.removeEventListener("touchstart",n.start,{passive:!1}),document.removeEventListener("mouseup",n.reset),document.removeEventListener("touchend",n.reset)})),r(this,"update",(function(e){var t=e.event,i=e.data;n.isInteracting&&n.DS.publish("Interaction:update",{event:t,data:i,isDragging:n.isDragging})})),r(this,"reset",(function(e){var t=n.isDragging;n.stop(),n.init(),n.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 n.start(t)})),this.DS.subscribe("Area:scroll",this.update)}return i(t,[{key:"_canInteract",value:function(e){return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target))}}]),t}(),N=function t(){var i=this;e(this,t),r(this,"subscribers",{}),r(this,"subscribe",(function(e,t){return Array.isArray(i.subscribers[e])||(i.subscribers[e]=[]),i.subscribers[e].push(t),i.subscribers[e].length-1})),r(this,"unsubscribe",(function(e,t,r){r>=0?i.subscribers[e].splice(r,1):t&&(i.subscribers[e]=i.subscribers[e].filter((function(e){return e!==t})))})),r(this,"publish",(function(e,t){Array.isArray(i.subscribers[e])&&i.subscribers[e].forEach((function(e){return e(t)}))}))},M=function(t){n(a,c(Set));var s=h(a);function a(t){var i,n=t.elements,o=t.className,l=t.hoverClassName,c=t.draggability,d=t.useTransform,h=t.DS;return e(this,a),r(u(i=s.call(this)),"_initElements",void 0),r(u(i),"_className",void 0),r(u(i),"_hoverClassName",void 0),r(u(i),"_useTransform",void 0),r(u(i),"_draggability",void 0),r(u(i),"init",(function(){return i._initElements.forEach((function(e){return i.add(e)}))})),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"_onClick",(function(e){return i.DS.publish("Selectable:click",{event:e})})),r(u(i),"_onPointer",(function(e){return i.DS.publish("Selectable:pointer",{event:e})})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=h,i._initElements=A(n),i._className=o,i._hoverClassName=l,i._useTransform=d,i._draggability=c,i.DS.subscribe("Interaction:init",i.init),i}return i(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&&k({computedStyle:window.getComputedStyle(e),node:e}),f(o(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}),f(o(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(),K=function(t){n(a,c(Set));var s=h(a);function a(t){var i,n=t.className,o=t.DS;return e(this,a),r(u(i=s.call(this)),"_className",void 0),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=o,i._className=n,i}return i(a,[{key:"add",value:function(e){if(!f(o(a.prototype),"has",this).call(this,e))return f(o(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(f(o(a.prototype),"has",this).call(this,e)){var t=f(o(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}(),z=function(){function t(i){var n=this,o=i.DS,s=i.hoverClassName,a=i.multiSelectToggling;e(this,t),r(this,"_prevSelectedSet",void 0),r(this,"_hoverClassName",void 0),r(this,"_multiSelectToggling",void 0),r(this,"start",(function(e){var t=e.event;e.isDragging||(n._storePrevious(t),n._handleInsideSelection(!0,t))})),r(this,"update",(function(e){e.isDragging||n._handleInsideSelection()})),r(this,"_handleInsideSelection",(function(e,t){for(var i=n.DS,r=i.SelectableSet,o=i.SelectorArea,s=i.Selector,a=r.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])&&(E(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=n.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&n._multiSelectToggling;l.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.multiSelectionToggle,n=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!i||(n.has(t)?r&&n.delete(t):n.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.SelectedSet,n=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!i)return!1;var s=r.has(t),a=n.has(t);s&&!a?r.delete(t):!s&&a&&r.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName,PrevSelectedSet:n._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 i(t,[{key:"_storePrevious",value:function(e){var t=this.DS,i=t.stores.KeyStore,r=t.SelectedSet;i.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(r):this._prevSelectedSet=new Set}}]),t}(),H=function(){function t(i){var n=this,o=i.DS,s=i.selector,a=i.selectorClass,l=i.customStyles;e(this,t),r(this,"_rect",void 0),r(this,"start",(function(e){if(!e.isDragging){var t=n.DS.stores.PointerStore.initialValArea;L(n.HTMLNode,p(t,1)),n.HTMLNode.style.display="block",n._rect=null}})),r(this,"stop",(function(){n.HTMLNode.style.width="0",n.HTMLNode.style.height="0",n.HTMLNode.style.display="none"})),r(this,"update",(function(e){if(!e.isDragging){var t=n.DS.stores,i=t.ScrollStore,r=t.PointerStore,o=function(e){var t=e.scrollAmount,i=e.initialPointerPos,r=e.pointerPos,n={};return r.x>i.x-t.x?(n.left=i.x-t.x,n.width=r.x-i.x+t.x):(n.left=r.x,n.width=i.x-r.x-t.x),r.y>i.y-t.y?(n.top=i.y-t.y,n.height=r.y-i.y+t.y):(n.top=r.y,n.height=i.y-r.y-t.y),n}({scrollAmount:i.scrollAmount,initialPointerPos:r.initialValArea,pointerPos:r.currentValArea});L(n.HTMLNode,o),n._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 i(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),R=function(){function t(i){var n=this,o=i.DS,s=i.selectorAreaClass,a=i.autoScrollSpeed,l=i.overflowTolerance;e(this,t),r(this,"_autoScrollSpeed",void 0),r(this,"_scrollInterval",void 0),r(this,"_rect",void 0),r(this,"currentEdges",[]),r(this,"_overflowTolerance",void 0),r(this,"updatePos",(function(){n._rect=null;var e=n.DS.Area.rect,t=n.DS.Area.computedBorder,i=n.HTMLNode.style,r="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");i.top!==r&&(i.top=r),i.left!==o&&(i.left=o),i.width!==s&&(i.width=s),i.height!==a&&(i.height=a)})),r(this,"startAutoScroll",(function(){n.currentEdges=[],n._scrollInterval=setInterval((function(){return n.handleAutoScroll()}),16)})),r(this,"handleAutoScroll",(function(){var e=n.DS,t=e.stores.PointerStore,i=e.Area;n.currentEdges=_({elementRect:p(t.currentVal),containerRect:n.rect,tolerance:n._overflowTolerance}),n.currentEdges.length&&i.scroll(n.currentEdges,n._autoScrollSpeed)})),r(this,"stopAutoScroll",(function(){n.currentEdges=[],clearInterval(n._scrollInterval)})),r(this,"isInside",(function(e,t){return!(!n.DS.Area.HTMLNode.contains(e)||!n.DS.stores.ScrollStore.canScroll)||E(n.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.HTMLNode.appendChild(this.DS.Selector.HTMLNode);var c=document.body?"body":"documentElement";document[c].appendChild(this.HTMLNode),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){n.updatePos(),n.stopAutoScroll()}))}return i(t,[{key:"isClicked",value:function(){var e=this.DS.stores.PointerStore;return E({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}(),O=function(){function t(i){var n=this,o=i.DS,s=i.multiSelectKeys,a=i.multiSelectMode;e(this,t),r(this,"_multiSelectMode",void 0),r(this,"_multiSelectKeys",void 0),r(this,"_currentValues",new Set),r(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),r(this,"init",(function(){document.addEventListener("keydown",n.keydown),document.addEventListener("keyup",n.keyup),window.addEventListener("blur",n.reset)})),r(this,"keydown",(function(e){var t=e.key.toLowerCase();n._currentValues.add(t),n.DS.publish("KeyStore:down",{event:e,key:t})})),r(this,"keyup",(function(e){var t=e.key.toLowerCase();n._currentValues.delete(t),n.DS.publish("KeyStore:up",{event:e,key:t})})),r(this,"stop",(function(){document.removeEventListener("keydown",n.keydown),document.removeEventListener("keyup",n.reset),window.removeEventListener("blur",n.reset),n.reset()})),r(this,"reset",(function(){return n._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 i(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(i){return e[t._keyMapping[i]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),B=function(){function t(i){var n=this,o=i.DS;e(this,t),r(this,"_isMouseInteraction",!1),r(this,"_initialValArea",void 0),r(this,"_currentValArea",void 0),r(this,"_lastValArea",void 0),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_lastVal",void 0),r(this,"_lastTouch",void 0),r(this,"init",(function(){document.addEventListener("mousemove",n.update),document.addEventListener("touchmove",n.update,{passive:!1})})),r(this,"update",(function(e){e&&(n.currentVal=D({event:n._normalizedEvent(e)}),n._isMouseInteraction&&n.DS.publish("PointerStore:updated",{event:e}))})),r(this,"stop",(function(){document.removeEventListener("mousemove",n.update),document.removeEventListener("touchmove",n.update,{passive:!1}),setTimeout((function(){return n._isMouseInteraction=!1}),100)})),r(this,"reset",(function(e){e&&(n.currentVal=n.lastVal=D({event:n._normalizedEvent(e)}),n.stop(),n.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return n.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return n.reset(t)}))}return i(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=D({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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(this.DS.Area.computedBorder)))}}]),t}(),j=function(){function t(i){var n=this,o=i.DS,s=i.areaElement,a=i.zoom;e(this,t),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_areaElement",void 0),r(this,"_canScroll",void 0),r(this,"init",(function(){return n._areaElement.addEventListener("scroll",n.update)})),r(this,"start",(function(){n._currentVal=n._initialVal=b(n._areaElement),n._areaElement.addEventListener("scroll",n.update)})),r(this,"update",(function(){return n._currentVal=b(n._areaElement)})),r(this,"stop",(function(){n._areaElement.removeEventListener("scroll",n.update),n._initialVal={x:0,y:0},n._canScroll=null})),r(this,"reset",(function(){n.stop(),n.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return n.start()})),this.DS.subscribe("Interaction:end",(function(){return n.reset()}))}return i(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=b(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=m(this.currentVal,"-",this.initialVal),i={x:e=this.zoom,y:e},r=m(m(t,"*",i),"-",t);return{x:t.x+r.x,y:t.y+r.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=b(this._areaElement)),this._currentVal}}]),t}(),U=function(){function t(i){var n=this,o=i.area,s=void 0===o?document:o,a=i.selectables,l=void 0===a?[]:a,c=i.autoScrollSpeed,u=void 0===c?5:c,d=i.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=i.zoom,v=void 0===f?1:f,S=i.customStyles,m=void 0!==S&&S,g=i.multiSelectMode,p=void 0!==g&&g,y=i.multiSelectToggling,b=void 0===y||y,_=i.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,w=i.selector,x=void 0===w?void 0:w,k=i.draggability,E=void 0===k||k,I=i.immediateDrag,P=void 0===I||I,A=i.dragKeys,L=i.keyboardDragSpeed,U=void 0===L?10:L,W=i.useTransform,F=void 0===W||W,Z=i.hoverClass,G=void 0===Z?"ds-hover":Z,X=i.selectableClass,Y=void 0===X?"ds-selectable":X,$=i.selectedClass,q=void 0===$?"ds-selected":$,J=i.selectorClass,Q=void 0===J?"ds-selector":J,ee=i.selectorAreaClass,te=void 0===ee?"ds-selector-area":ee,ie=i.callback,re=i.onDragMove,ne=i.onDragStartBegin,oe=i.onDragStart,se=i.onElementSelect,ae=i.onElementUnselect;e(this,t),r(this,"start",(function(){return n.Interaction.init()})),r(this,"getSelection",(function(){return n.SelectedSet.elements})),r(this,"getSelectables",(function(){return n.SelectableSet.elements})),r(this,"getInitialCursorPosition",(function(){return n.stores.PointerStore.initialVal})),r(this,"getCurrentCursorPosition",(function(){return n.stores.PointerStore.currentVal})),r(this,"getPreviousCursorPosition",(function(){return n.stores.PointerStore.lastVal})),r(this,"getInitialCursorPositionArea",(function(){return n.stores.PointerStore.initialValArea})),r(this,"getCurrentCursorPositionArea",(function(){return n.stores.PointerStore.currentValArea})),r(this,"getPreviousCursorPositionArea",(function(){return n.stores.PointerStore.lastValArea})),r(this,"isMultiSelect",(function(e){return n.stores.KeyStore.isMultiSelectKeyPressed(e)})),r(this,"isDragging",(function(){return n.Interaction.isDragging})),this.PubSub=new N,this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:ie,onDragMove:re,onDragStart:oe,onDragStartBegin:ne,onElementSelect:se,onElementUnselect:ae}),this.stores={PointerStore:new B({DS:this}),ScrollStore:new j({DS:this,areaElement:s,zoom:v}),KeyStore:new O({DS:this,multiSelectKeys:D,multiSelectMode:p})},this.Area=new C({area:s,PS:this.PubSub,zoom:v}),this.Selector=new H({DS:this,selector:x,selectorClass:Q,customStyles:m}),this.SelectorArea=new R({DS:this,selectorAreaClass:te,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new M({elements:l,DS:this,className:Y,hoverClassName:G,useTransform:F,draggability:E}),this.SelectedSet=new K({DS:this,className:q}),this.Selection=new z({DS:this,hoverClassName:G,multiSelectToggling:b}),this.Drag=new T({DS:this,useTransform:F,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},A),zoom:v,keyboardDragSpeed:U}),this.Interaction=new V({areaElement:s,DS:this,draggability:E,immediateDrag:P}),this.subscribe("Selected:added",(function(e){var t=e.items,i=e.item;return n.publish("elementselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Selected:removed",(function(e){var t=e.items,i=e.item;return n.publish("elementunselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:update",(function(e){var t=e.event,i=e.isDragging;t&&n.publish("dragmove",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Area:scroll",(function(e){var t=e.scroll_directions,i=e.scroll_multiplier;n.publish("autoscroll",{items:n.getSelection(),scroll_directions:t,scroll_multiplier:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:start",(function(e){var t=e.event,i=e.isDragging;return n.publish("dragstart",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Interaction:end",(function(e){var t=e.event,i=e.isDragging;return n.publish("callback",{items:n.getSelection(),event:t,isDragging:i})})),this.start()}return i(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,i=e.onDragMove,r=e.onDragStart,n=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 i=e.items,r=(e.item,e.event);return t(i,r)}))),i&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return i(t)}))),r&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,i=e.event;return o(t,i)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,i=e.event;return s(t,i)})))}},{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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(A(e)),i||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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(A(e)),i&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return A(e).forEach((function(n){return t.SelectedSet.has(n)?t.removeSelection(e,i,r):t.addSelection(e,i,r)})),i&&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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,i),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],i=A(e);return this.SelectableSet.addAll(i),t&&this.SelectedSet.addAll(i),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,i)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(A(e)),t&&this.removeSelection(e),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var t=this.getCurrentCursorPosition(),i=e?this.getPreviousCursorPosition():this.getInitialCursorPosition();return m(t,"-",i)}}]),t}();export default U; |
@@ -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 i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(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&&s(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){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 l(e,t,i){return(l=a()?Reflect.construct:function(e,t,i){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return i&&s(n,i.prototype),n}).apply(null,arguments)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;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,r)}function r(){return l(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function h(e){var t=a();return function(){var i,r=o(e);if(t){var n=o(this).constructor;i=Reflect.construct(r,arguments,n)}else i=r.apply(this,arguments);return d(this,i)}}function f(e,t,i){return(f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=o(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(i):n.value}})(e,t,i||e)}function v(e){return function(e){if(Array.isArray(e))return S(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return S(e,t)}(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 S(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}var m=function(e,t,i){var r=e.x,n=e.y,o=i.x,s=i.y;return{"+":{x:r+o,y:n+s},"-":{x:r-o,y:n-s},"*":{x:r*o,y:n*s},"/":{x:r/o,y:n/s}}[t]},g=function(e){return{x:e.left,y:e.top}},p=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}},y=function(){var e,t,i,r;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===(i=document.body)||void 0===i?void 0:i.scrollLeft)||(null===(r=document.documentElement)||void 0===r?void 0:r.scrollLeft)||0}},b=function(e){return!e||e instanceof Document?y():{x:e.scrollLeft>=0?e.scrollLeft:y().x,y:e.scrollTop>=0?e.scrollTop:y().y}},_=function(e){var t=e.elementRect,i=e.containerRect,r=e.tolerance,n=void 0===r?{x:0,y:0}:r,o=[];return t.top-n.y<i.top&&o.push("top"),t.left-n.x<i.left&&o.push("left"),t.bottom+n.y>i.bottom&&o.push("bottom"),t.right+n.y>i.right&&o.push("right"),o},D=function(e){var t=e.event;return{x:t.clientX,y:t.clientY}},w=function(e){var t={x:0,y:0},i=window.getComputedStyle(e);if(!i.transform||"none"===i.transform)return t;if(i.transform.indexOf("3d")>=0){var r=i.transform.trim().match(/matrix3d\((.*?)\)/);if(r&&r.length){var n,o=null===(n=r[1])||void 0===n?void 0:n.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=i.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},x=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return w(e);var i={x:0,y:0},r=t.trim().match(/translate[3dD]*?\(.*?\)/);if(r){var n,o=null===(n=r[0])||void 0===n?void 0:n.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");i.x=parseInt(a[0])||0,i.y=parseInt(a[1])||0}}return i.x||i.x?i:w(e)}(e):function(e){var t=e.style,i={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!i.x&&!i.x){var r=window.getComputedStyle(e);return{x:parseInt(r.left)||0,y:parseInt(r.top)||0}}return i}(e)},k=function(e){var t=e.computedStyle,i=e.node,r=t.position;i instanceof HTMLDocument||("absolute"===r||"relative"===r||"fixed"===r)||(i.style.position="relative")},E=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,i=e.posDirection,r=e.containerRect,n=e.useTransform,o=x(t,n),s=m(o,"+",i);P(t,s,n);var a=t.getBoundingClientRect();!function(e){var t=e.element,i=e.edges,r=e.elementRect,n=e.containerRect,o=e.elementPos,s=e.useTransform;i.includes("top")&&P(t,{y:o.y+n.top-r.top,x:o.x},s),i.includes("left")&&P(t,{y:o.y,x:o.x+n.left-r.left},s),i.includes("bottom")&&P(t,{y:o.y+n.bottom-r.bottom,x:o.x},s),i.includes("right")&&P(t,{y:o.y,x:o.x+n.right-r.right},s)}({element:t,edges:_({elementRect:a,containerRect:r}),elementRect:a,containerRect:r,elementPos:s,useTransform:n})},P=function(e,t,i){if(i){var r=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(r.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},A=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:v(e):[]},L=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")},T=function(){function t(i){var n,o,s,a=this,l=i.area,c=i.PS,u=i.zoom;e(this,t),r(this,"_modificationCallback",void 0),r(this,"_modificationObserver",void 0),r(this,"_zoom",void 0),r(this,"_node",void 0),r(this,"_parentNodes",void 0),r(this,"_computedStyle",void 0),r(this,"_computedBorder",void 0),r(this,"_rect",void 0),r(this,"start",(function(){var e,t,i;e=a.parentNodes,t=a._modificationCallback,i=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){i.observe(e,{childList:0!==t,attributes:!0})}))})),r(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),r(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),r(this,"scroll",(function(e,t){!function(e,t,i){if(t.length){var r=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,n=e instanceof HTMLDocument?r||document.body:e,o=t.includes("top")&&n.scrollTop>0,s=t.includes("bottom")&&n.scrollTop<n.scrollHeight,a=t.includes("left")&&n.scrollLeft>0,l=t.includes("right")&&n.scrollLeft<n.scrollWidth;o&&(n.scrollTop-=1*i),s&&(n.scrollTop+=1*i),a&&(n.scrollLeft-=1*i),l&&(n.scrollLeft+=1*i)}}(a._node,e,t),a.PubSub.publish("Area:scroll",{scroll_directions:e,scroll_multiplier:t})})),this._node=l,this._zoom=u,this.PubSub=c,k({computedStyle:this.computedStyle,node:this._node}),this._modificationCallback=(n=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),i=0;i<e;i++)t[i]=arguments[i];var r=function(){s=null,n.apply(void 0,t)};clearTimeout(s),s=setTimeout(r,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 i(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 i=e.getBoundingClientRect();return{top:i.top,left:i.left,bottom:i.bottom,right:i.right,width:(e.clientWidth||i.width)*t,height:(e.clientHeight||i.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=null===(i=t[r])||void 0===i?void 0:i.parentNode;return n?(t.push(n),e(t,++r)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),C=function(){function t(i){var n=this,o=i.DS,s=i.useTransform,a=i.dragKeys,l=i.keyboardDragSpeed,c=i.zoom;e(this,t),r(this,"_useTransform",void 0),r(this,"_prevCursorPos",void 0),r(this,"_prevScrollPos",void 0),r(this,"_elements",[]),r(this,"_dragKeys",void 0),r(this,"_dragKeysFlat",void 0),r(this,"_keyboardDragSpeed",void 0),r(this,"_zoom",void 0),r(this,"keyboardDrag",(function(e){var t=e.event,i=e.key;if(n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size){n._isKeyboard=!0,n.DS.publish("Interaction:start",{event:t,isDragging:!0}),n._elements=n.DS.getSelection(),n.handleZIndex(!0);var r=function(e){var t=e.shiftKey,i=e.keyboardDragSpeed,r=e.zoom,n=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*i*r:i*r;return o.left.includes(n)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],i)),o.right.includes(n)&&(c.x=s.x||u,t||s.x||!a||l(["right"],i)),o.up.includes(n)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],i)),o.down.includes(n)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],i)),c}({shiftKey:n.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:n._keyboardDragSpeed,zoom:n._zoom,key:i,scrollCallback:n.DS.Area.scroll,scrollDiff:n._scrollDiff,canScroll:n.DS.stores.ScrollStore.canScroll,dragKeys:n._dragKeys});n._elements.forEach((function(e){return I({element:e,posDirection:r,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})})),n.DS.publish("Interaction:update",{event:t,isDragging:!0}),n._isKeyboard=!1}})),r(this,"keyboardEnd",(function(e){var t=e.event,i=e.key;n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size&&(n._isKeyboard=!0,n.DS.publish("Interaction:end",{event:t,isDragging:!0}),n._isKeyboard=!1)})),r(this,"start",(function(e){e.isDragging&&!n._isKeyboard&&(n._prevCursorPos=null,n._prevScrollPos=null,n._elements=n.DS.getSelection(),n.handleZIndex(!0))})),r(this,"stop",(function(){n._isKeyboard||(n._prevCursorPos=null,n._prevScrollPos=null,n.handleZIndex(!1),n._elements=[])})),r(this,"update",(function(e){if(e.isDragging&&n._elements.length&&!n._isKeyboard){var t=m(n._cursorDiff,"+",n._scrollDiff);n._elements.forEach((function(e){return I({element:e,posDirection:t,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})}))}})),r(this,"handleZIndex",(function(e){n._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=s,this._keyboardDragSpeed=l,this._zoom=c,this._dragKeys={up:a.up.map((function(e){return e.toLowerCase()})),down:a.down.map((function(e){return e.toLowerCase()})),left:a.left.map((function(e){return e.toLowerCase()})),right:a.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(v(this._dragKeys.up),v(this._dragKeys.down),v(this._dragKeys.left),v(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 i(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?m(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?m(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),V=function(){function t(i){var n=this,o=i.areaElement,s=i.DS,a=i.draggability,l=i.immediateDrag;e(this,t),r(this,"_areaElement",void 0),r(this,"_draggability",void 0),r(this,"_immediateDrag",void 0),r(this,"isInteracting",void 0),r(this,"isDragging",void 0),r(this,"init",(function(){n.stop(),n._areaElement.addEventListener("mousedown",n.start),n._areaElement.addEventListener("touchstart",n.start,{passive:!1}),n.DS.publish("Interaction:init",{})})),r(this,"start",(function(e){"touchstart"===e.type&&e.preventDefault(),n._canInteract(e)&&(n.isInteracting=!0,n.isDragging=n.isDragEvent(e),n.DS.publish("Interaction:start",{event:e,isDragging:n.isDragging}),document.addEventListener("mouseup",n.reset),document.addEventListener("touchend",n.reset))})),r(this,"isDragEvent",(function(e){return!(!n._draggability||n.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!n.DS.SelectableSet.has(e.target))&&(n._immediateDrag&&(n.DS.SelectedSet.size?n.DS.SelectedSet.has(e.target)||(n.DS.SelectedSet.clear(),n.DS.SelectedSet.add(e.target)):n.DS.SelectedSet.add(e.target)),!!n.DS.SelectedSet.has(e.target))})),r(this,"onClick",(function(e){var t=e.event;if(n._canInteract(t)&&!(t.detail>0)){var i=n.DS,r=i.stores,o=r.PointerStore,s=r.KeyStore,a=i.SelectableSet,l=i.SelectedSet,c=i.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:n.isDragging}))}})),r(this,"stop",(function(){n.isInteracting=!1,n.isDragging=!1,n._areaElement.removeEventListener("mousedown",n.start),n._areaElement.removeEventListener("touchstart",n.start,{passive:!1}),document.removeEventListener("mouseup",n.reset),document.removeEventListener("touchend",n.reset)})),r(this,"update",(function(e){var t=e.event,i=e.data;n.isInteracting&&n.DS.publish("Interaction:update",{event:t,data:i,isDragging:n.isDragging})})),r(this,"reset",(function(e){var t=n.isDragging;n.stop(),n.init(),n.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 n.start(t)})),this.DS.subscribe("Area:scroll",this.update)}return i(t,[{key:"_canInteract",value:function(e){return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target))}}]),t}(),N=function t(){var i=this;e(this,t),r(this,"subscribers",{}),r(this,"subscribe",(function(e,t){return Array.isArray(i.subscribers[e])||(i.subscribers[e]=[]),i.subscribers[e].push(t),i.subscribers[e].length-1})),r(this,"unsubscribe",(function(e,t,r){r>=0?i.subscribers[e].splice(r,1):t&&(i.subscribers[e]=i.subscribers[e].filter((function(e){return e!==t})))})),r(this,"publish",(function(e,t){Array.isArray(i.subscribers[e])&&i.subscribers[e].forEach((function(e){return e(t)}))}))},M=function(t){n(a,t);var s=h(a);function a(t){var i,n=t.elements,o=t.className,l=t.hoverClassName,c=t.draggability,d=t.useTransform,h=t.DS;return e(this,a),r(u(i=s.call(this)),"_initElements",void 0),r(u(i),"_className",void 0),r(u(i),"_hoverClassName",void 0),r(u(i),"_useTransform",void 0),r(u(i),"_draggability",void 0),r(u(i),"init",(function(){return i._initElements.forEach((function(e){return i.add(e)}))})),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"_onClick",(function(e){return i.DS.publish("Selectable:click",{event:e})})),r(u(i),"_onPointer",(function(e){return i.DS.publish("Selectable:pointer",{event:e})})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=h,i._initElements=A(n),i._className=o,i._hoverClassName=l,i._useTransform=d,i._draggability=c,i.DS.subscribe("Interaction:init",i.init),i}return i(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&&k({computedStyle:window.getComputedStyle(e),node:e}),f(o(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}),f(o(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(c(Set)),K=function(t){n(a,t);var s=h(a);function a(t){var i,n=t.className,o=t.DS;return e(this,a),r(u(i=s.call(this)),"_className",void 0),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=o,i._className=n,i}return i(a,[{key:"add",value:function(e){if(!f(o(a.prototype),"has",this).call(this,e))return f(o(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(f(o(a.prototype),"has",this).call(this,e)){var t=f(o(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}(c(Set)),z=function(){function t(i){var n=this,o=i.DS,s=i.hoverClassName,a=i.multiSelectToggling;e(this,t),r(this,"_prevSelectedSet",void 0),r(this,"_hoverClassName",void 0),r(this,"_multiSelectToggling",void 0),r(this,"start",(function(e){var t=e.event;e.isDragging||(n._storePrevious(t),n._handleInsideSelection(!0,t))})),r(this,"update",(function(e){e.isDragging||n._handleInsideSelection()})),r(this,"_handleInsideSelection",(function(e,t){for(var i=n.DS,r=i.SelectableSet,o=i.SelectorArea,s=i.Selector,a=r.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])&&(E(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=n.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&n._multiSelectToggling;l.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.multiSelectionToggle,n=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!i||(n.has(t)?r&&n.delete(t):n.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.SelectedSet,n=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!i)return!1;var s=r.has(t),a=n.has(t);s&&!a?r.delete(t):!s&&a&&r.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName,PrevSelectedSet:n._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 i(t,[{key:"_storePrevious",value:function(e){var t=this.DS,i=t.stores.KeyStore,r=t.SelectedSet;i.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(r):this._prevSelectedSet=new Set}}]),t}(),H=function(){function t(i){var n=this,o=i.DS,s=i.selector,a=i.selectorClass,l=i.customStyles;e(this,t),r(this,"_rect",void 0),r(this,"start",(function(e){if(!e.isDragging){var t=n.DS.stores.PointerStore.initialValArea;L(n.HTMLNode,p(t,1)),n.HTMLNode.style.display="block",n._rect=null}})),r(this,"stop",(function(){n.HTMLNode.style.width="0",n.HTMLNode.style.height="0",n.HTMLNode.style.display="none"})),r(this,"update",(function(e){if(!e.isDragging){var t=n.DS.stores,i=t.ScrollStore,r=t.PointerStore,o=function(e){var t=e.scrollAmount,i=e.initialPointerPos,r=e.pointerPos,n={};return r.x>i.x-t.x?(n.left=i.x-t.x,n.width=r.x-i.x+t.x):(n.left=r.x,n.width=i.x-r.x-t.x),r.y>i.y-t.y?(n.top=i.y-t.y,n.height=r.y-i.y+t.y):(n.top=r.y,n.height=i.y-r.y-t.y),n}({scrollAmount:i.scrollAmount,initialPointerPos:r.initialValArea,pointerPos:r.currentValArea});L(n.HTMLNode,o),n._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 i(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),R=function(){function t(i){var n=this,o=i.DS,s=i.selectorAreaClass,a=i.autoScrollSpeed,l=i.overflowTolerance;e(this,t),r(this,"_autoScrollSpeed",void 0),r(this,"_scrollInterval",void 0),r(this,"_rect",void 0),r(this,"currentEdges",[]),r(this,"_overflowTolerance",void 0),r(this,"updatePos",(function(){n._rect=null;var e=n.DS.Area.rect,t=n.DS.Area.computedBorder,i=n.HTMLNode.style,r="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");i.top!==r&&(i.top=r),i.left!==o&&(i.left=o),i.width!==s&&(i.width=s),i.height!==a&&(i.height=a)})),r(this,"startAutoScroll",(function(){n.currentEdges=[],n._scrollInterval=setInterval((function(){return n.handleAutoScroll()}),16)})),r(this,"handleAutoScroll",(function(){var e=n.DS,t=e.stores.PointerStore,i=e.Area;n.currentEdges=_({elementRect:p(t.currentVal),containerRect:n.rect,tolerance:n._overflowTolerance}),n.currentEdges.length&&i.scroll(n.currentEdges,n._autoScrollSpeed)})),r(this,"stopAutoScroll",(function(){n.currentEdges=[],clearInterval(n._scrollInterval)})),r(this,"isInside",(function(e,t){return!(!n.DS.Area.HTMLNode.contains(e)||!n.DS.stores.ScrollStore.canScroll)||E(n.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.HTMLNode.appendChild(this.DS.Selector.HTMLNode);var c=document.body?"body":"documentElement";document[c].appendChild(this.HTMLNode),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){n.updatePos(),n.stopAutoScroll()}))}return i(t,[{key:"isClicked",value:function(){var e=this.DS.stores.PointerStore;return E({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}(),O=function(){function t(i){var n=this,o=i.DS,s=i.multiSelectKeys,a=i.multiSelectMode;e(this,t),r(this,"_multiSelectMode",void 0),r(this,"_multiSelectKeys",void 0),r(this,"_currentValues",new Set),r(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),r(this,"init",(function(){document.addEventListener("keydown",n.keydown),document.addEventListener("keyup",n.keyup),window.addEventListener("blur",n.reset)})),r(this,"keydown",(function(e){var t=e.key.toLowerCase();n._currentValues.add(t),n.DS.publish("KeyStore:down",{event:e,key:t})})),r(this,"keyup",(function(e){var t=e.key.toLowerCase();n._currentValues.delete(t),n.DS.publish("KeyStore:up",{event:e,key:t})})),r(this,"stop",(function(){document.removeEventListener("keydown",n.keydown),document.removeEventListener("keyup",n.reset),window.removeEventListener("blur",n.reset),n.reset()})),r(this,"reset",(function(){return n._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 i(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(i){return e[t._keyMapping[i]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),B=function(){function t(i){var n=this,o=i.DS;e(this,t),r(this,"_isMouseInteraction",!1),r(this,"_initialValArea",void 0),r(this,"_currentValArea",void 0),r(this,"_lastValArea",void 0),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_lastVal",void 0),r(this,"_lastTouch",void 0),r(this,"init",(function(){document.addEventListener("mousemove",n.update),document.addEventListener("touchmove",n.update,{passive:!1})})),r(this,"update",(function(e){e&&(n.currentVal=D({event:n._normalizedEvent(e)}),n._isMouseInteraction&&n.DS.publish("PointerStore:updated",{event:e}))})),r(this,"stop",(function(){document.removeEventListener("mousemove",n.update),document.removeEventListener("touchmove",n.update,{passive:!1}),setTimeout((function(){return n._isMouseInteraction=!1}),100)})),r(this,"reset",(function(e){e&&(n.currentVal=n.lastVal=D({event:n._normalizedEvent(e)}),n.stop(),n.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return n.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return n.reset(t)}))}return i(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=D({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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(this.DS.Area.computedBorder)))}}]),t}(),j=function(){function t(i){var n=this,o=i.DS,s=i.areaElement,a=i.zoom;e(this,t),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_areaElement",void 0),r(this,"_canScroll",void 0),r(this,"init",(function(){return n._areaElement.addEventListener("scroll",n.update)})),r(this,"start",(function(){n._currentVal=n._initialVal=b(n._areaElement),n._areaElement.addEventListener("scroll",n.update)})),r(this,"update",(function(){return n._currentVal=b(n._areaElement)})),r(this,"stop",(function(){n._areaElement.removeEventListener("scroll",n.update),n._initialVal={x:0,y:0},n._canScroll=null})),r(this,"reset",(function(){n.stop(),n.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return n.start()})),this.DS.subscribe("Interaction:end",(function(){return n.reset()}))}return i(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=b(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=m(this.currentVal,"-",this.initialVal),i={x:e=this.zoom,y:e},r=m(m(t,"*",i),"-",t);return{x:t.x+r.x,y:t.y+r.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=b(this._areaElement)),this._currentVal}}]),t}();return function(){function t(i){var n=this,o=i.area,s=void 0===o?document:o,a=i.selectables,l=void 0===a?[]:a,c=i.autoScrollSpeed,u=void 0===c?5:c,d=i.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=i.zoom,v=void 0===f?1:f,S=i.customStyles,m=void 0!==S&&S,g=i.multiSelectMode,p=void 0!==g&&g,y=i.multiSelectToggling,b=void 0===y||y,_=i.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,w=i.selector,x=void 0===w?void 0:w,k=i.draggability,E=void 0===k||k,I=i.immediateDrag,P=void 0===I||I,A=i.dragKeys,L=i.keyboardDragSpeed,U=void 0===L?10:L,W=i.useTransform,F=void 0===W||W,Z=i.hoverClass,G=void 0===Z?"ds-hover":Z,X=i.selectableClass,Y=void 0===X?"ds-selectable":X,$=i.selectedClass,q=void 0===$?"ds-selected":$,J=i.selectorClass,Q=void 0===J?"ds-selector":J,ee=i.selectorAreaClass,te=void 0===ee?"ds-selector-area":ee,ie=i.callback,re=i.onDragMove,ne=i.onDragStartBegin,oe=i.onDragStart,se=i.onElementSelect,ae=i.onElementUnselect;e(this,t),r(this,"start",(function(){return n.Interaction.init()})),r(this,"getSelection",(function(){return n.SelectedSet.elements})),r(this,"getSelectables",(function(){return n.SelectableSet.elements})),r(this,"getInitialCursorPosition",(function(){return n.stores.PointerStore.initialVal})),r(this,"getCurrentCursorPosition",(function(){return n.stores.PointerStore.currentVal})),r(this,"getPreviousCursorPosition",(function(){return n.stores.PointerStore.lastVal})),r(this,"getInitialCursorPositionArea",(function(){return n.stores.PointerStore.initialValArea})),r(this,"getCurrentCursorPositionArea",(function(){return n.stores.PointerStore.currentValArea})),r(this,"getPreviousCursorPositionArea",(function(){return n.stores.PointerStore.lastValArea})),r(this,"isMultiSelect",(function(e){return n.stores.KeyStore.isMultiSelectKeyPressed(e)})),r(this,"isDragging",(function(){return n.Interaction.isDragging})),this.PubSub=new N,this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:ie,onDragMove:re,onDragStart:oe,onDragStartBegin:ne,onElementSelect:se,onElementUnselect:ae}),this.stores={PointerStore:new B({DS:this}),ScrollStore:new j({DS:this,areaElement:s,zoom:v}),KeyStore:new O({DS:this,multiSelectKeys:D,multiSelectMode:p})},this.Area=new T({area:s,PS:this.PubSub,zoom:v}),this.Selector=new H({DS:this,selector:x,selectorClass:Q,customStyles:m}),this.SelectorArea=new R({DS:this,selectorAreaClass:te,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new M({elements:l,DS:this,className:Y,hoverClassName:G,useTransform:F,draggability:E}),this.SelectedSet=new K({DS:this,className:q}),this.Selection=new z({DS:this,hoverClassName:G,multiSelectToggling:b}),this.Drag=new C({DS:this,useTransform:F,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},A),zoom:v,keyboardDragSpeed:U}),this.Interaction=new V({areaElement:s,DS:this,draggability:E,immediateDrag:P}),this.subscribe("Selected:added",(function(e){var t=e.items,i=e.item;return n.publish("elementselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Selected:removed",(function(e){var t=e.items,i=e.item;return n.publish("elementunselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:update",(function(e){var t=e.event,i=e.isDragging;t&&n.publish("dragmove",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Area:scroll",(function(e){var t=e.scroll_directions,i=e.scroll_multiplier;n.publish("autoscroll",{items:n.getSelection(),scroll_directions:t,scroll_multiplier:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:start",(function(e){var t=e.event,i=e.isDragging;return n.publish("dragstart",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Interaction:end",(function(e){var t=e.event,i=e.isDragging;return n.publish("callback",{items:n.getSelection(),event:t,isDragging:i})})),this.start()}return i(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,i=e.onDragMove,r=e.onDragStart,n=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 i=e.items,r=(e.item,e.event);return t(i,r)}))),i&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return i(t)}))),r&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,i=e.event;return o(t,i)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,i=e.event;return s(t,i)})))}},{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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(A(e)),i||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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(A(e)),i&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return A(e).forEach((function(n){return t.SelectedSet.has(n)?t.removeSelection(e,i,r):t.addSelection(e,i,r)})),i&&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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,i),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],i=A(e);return this.SelectableSet.addAll(i),t&&this.SelectedSet.addAll(i),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,i)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectedSet.clear(),t&&this.SelectedSet.clear(),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var t=this.getCurrentCursorPosition(),i=e?this.getPreviousCursorPosition():this.getInitialCursorPosition();return m(t,"-",i)}}]),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 i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(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&&s(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){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 l(e,t,i){return(l=a()?Reflect.construct:function(e,t,i){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return i&&s(n,i.prototype),n}).apply(null,arguments)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;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,r)}function r(){return l(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?u(e):t}function h(e){var t=a();return function(){var i,r=o(e);if(t){var n=o(this).constructor;i=Reflect.construct(r,arguments,n)}else i=r.apply(this,arguments);return d(this,i)}}function f(e,t,i){return(f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=o(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(i):n.value}})(e,t,i||e)}function v(e){return function(e){if(Array.isArray(e))return S(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return S(e,t)}(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 S(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}var m=function(e,t,i){var r=e.x,n=e.y,o=i.x,s=i.y;return{"+":{x:r+o,y:n+s},"-":{x:r-o,y:n-s},"*":{x:r*o,y:n*s},"/":{x:r/o,y:n/s}}[t]},g=function(e){return{x:e.left,y:e.top}},p=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}},y=function(){var e,t,i,r;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===(i=document.body)||void 0===i?void 0:i.scrollLeft)||(null===(r=document.documentElement)||void 0===r?void 0:r.scrollLeft)||0}},b=function(e){return!e||e instanceof Document?y():{x:e.scrollLeft>=0?e.scrollLeft:y().x,y:e.scrollTop>=0?e.scrollTop:y().y}},_=function(e){var t=e.elementRect,i=e.containerRect,r=e.tolerance,n=void 0===r?{x:0,y:0}:r,o=[];return t.top-n.y<i.top&&o.push("top"),t.left-n.x<i.left&&o.push("left"),t.bottom+n.y>i.bottom&&o.push("bottom"),t.right+n.y>i.right&&o.push("right"),o},D=function(e){var t=e.event;return{x:t.clientX,y:t.clientY}},w=function(e){var t={x:0,y:0},i=window.getComputedStyle(e);if(!i.transform||"none"===i.transform)return t;if(i.transform.indexOf("3d")>=0){var r=i.transform.trim().match(/matrix3d\((.*?)\)/);if(r&&r.length){var n,o=null===(n=r[1])||void 0===n?void 0:n.split(",");t.x=parseInt(o[12])||0,t.y=parseInt(o[13])||0}return t}var s=i.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},x=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return w(e);var i={x:0,y:0},r=t.trim().match(/translate[3dD]*?\(.*?\)/);if(r){var n,o=null===(n=r[0])||void 0===n?void 0:n.split("(");if(o){var s,a=null===(s=o[1])||void 0===s?void 0:s.split(",");i.x=parseInt(a[0])||0,i.y=parseInt(a[1])||0}}return i.x||i.x?i:w(e)}(e):function(e){var t=e.style,i={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!i.x&&!i.x){var r=window.getComputedStyle(e);return{x:parseInt(r.left)||0,y:parseInt(r.top)||0}}return i}(e)},k=function(e){var t=e.computedStyle,i=e.node,r=t.position;i instanceof HTMLDocument||("absolute"===r||"relative"===r||"fixed"===r)||(i.style.position="relative")},E=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,i=e.posDirection,r=e.containerRect,n=e.useTransform,o=x(t,n),s=m(o,"+",i);P(t,s,n);var a=t.getBoundingClientRect();!function(e){var t=e.element,i=e.edges,r=e.elementRect,n=e.containerRect,o=e.elementPos,s=e.useTransform;i.includes("top")&&P(t,{y:o.y+n.top-r.top,x:o.x},s),i.includes("left")&&P(t,{y:o.y,x:o.x+n.left-r.left},s),i.includes("bottom")&&P(t,{y:o.y+n.bottom-r.bottom,x:o.x},s),i.includes("right")&&P(t,{y:o.y,x:o.x+n.right-r.right},s)}({element:t,edges:_({elementRect:a,containerRect:r}),elementRect:a,containerRect:r,elementPos:s,useTransform:n})},P=function(e,t,i){if(i){var r=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(r.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},A=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:v(e):[]},L=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")},T=function(){function t(i){var n,o,s,a=this,l=i.area,c=i.PS,u=i.zoom;e(this,t),r(this,"_modificationCallback",void 0),r(this,"_modificationObserver",void 0),r(this,"_zoom",void 0),r(this,"_node",void 0),r(this,"_parentNodes",void 0),r(this,"_computedStyle",void 0),r(this,"_computedBorder",void 0),r(this,"_rect",void 0),r(this,"start",(function(){var e,t,i;e=a.parentNodes,t=a._modificationCallback,i=a._modificationObserver,window.addEventListener("resize",t),window.addEventListener("scroll",t),e.forEach((function(e,t){i.observe(e,{childList:0!==t,attributes:!0})}))})),r(this,"reset",(function(){a._computedStyle=void 0,a._rect=void 0,a._computedBorder=void 0,a._parentNodes=void 0})),r(this,"stop",(function(){var e,t;e=a._modificationObserver,t=a._modificationCallback,window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect(),a.reset()})),r(this,"scroll",(function(e,t){!function(e,t,i){if(t.length){var r=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,n=e instanceof HTMLDocument?r||document.body:e,o=t.includes("top")&&n.scrollTop>0,s=t.includes("bottom")&&n.scrollTop<n.scrollHeight,a=t.includes("left")&&n.scrollLeft>0,l=t.includes("right")&&n.scrollLeft<n.scrollWidth;o&&(n.scrollTop-=1*i),s&&(n.scrollTop+=1*i),a&&(n.scrollLeft-=1*i),l&&(n.scrollLeft+=1*i)}}(a._node,e,t),a.PubSub.publish("Area:scroll",{scroll_directions:e,scroll_multiplier:t})})),this._node=l,this._zoom=u,this.PubSub=c,k({computedStyle:this.computedStyle,node:this._node}),this._modificationCallback=(n=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),i=0;i<e;i++)t[i]=arguments[i];var r=function(){s=null,n.apply(void 0,t)};clearTimeout(s),s=setTimeout(r,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 i(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 i=e.getBoundingClientRect();return{top:i.top,left:i.left,bottom:i.bottom,right:i.right,width:(e.clientWidth||i.width)*t,height:(e.clientHeight||i.height)*t}}(this.HTMLNode,this._zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function e(t){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=null===(i=t[r])||void 0===i?void 0:i.parentNode;return n?(t.push(n),e(t,++r)):t}([this.HTMLNode]),this._parentNodes}}]),t}(),C=function(){function t(i){var n=this,o=i.DS,s=i.useTransform,a=i.dragKeys,l=i.keyboardDragSpeed,c=i.zoom;e(this,t),r(this,"_useTransform",void 0),r(this,"_prevCursorPos",void 0),r(this,"_prevScrollPos",void 0),r(this,"_elements",[]),r(this,"_dragKeys",void 0),r(this,"_dragKeysFlat",void 0),r(this,"_keyboardDragSpeed",void 0),r(this,"_zoom",void 0),r(this,"keyboardDrag",(function(e){var t=e.event,i=e.key;if(n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size){n._isKeyboard=!0,n.DS.publish("Interaction:start",{event:t,isDragging:!0}),n._elements=n.DS.getSelection(),n.handleZIndex(!0);var r=function(e){var t=e.shiftKey,i=e.keyboardDragSpeed,r=e.zoom,n=e.key,o=e.dragKeys,s=e.scrollDiff,a=e.canScroll,l=e.scrollCallback,c={x:0,y:0},u=t?4*i*r:i*r;return o.left.includes(n)&&(c.x=s.x||-u,t||s.x||!a||l(["left"],i)),o.right.includes(n)&&(c.x=s.x||u,t||s.x||!a||l(["right"],i)),o.up.includes(n)&&(c.y=s.y||-u,t||s.y||!a||l(["top"],i)),o.down.includes(n)&&(c.y=s.y||u,t||s.y||!a||l(["bottom"],i)),c}({shiftKey:n.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:n._keyboardDragSpeed,zoom:n._zoom,key:i,scrollCallback:n.DS.Area.scroll,scrollDiff:n._scrollDiff,canScroll:n.DS.stores.ScrollStore.canScroll,dragKeys:n._dragKeys});n._elements.forEach((function(e){return I({element:e,posDirection:r,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})})),n.DS.publish("Interaction:update",{event:t,isDragging:!0}),n._isKeyboard=!1}})),r(this,"keyboardEnd",(function(e){var t=e.event,i=e.key;n._dragKeysFlat.includes(i)&&n.DS.SelectedSet.size&&(n._isKeyboard=!0,n.DS.publish("Interaction:end",{event:t,isDragging:!0}),n._isKeyboard=!1)})),r(this,"start",(function(e){e.isDragging&&!n._isKeyboard&&(n._prevCursorPos=null,n._prevScrollPos=null,n._elements=n.DS.getSelection(),n.handleZIndex(!0))})),r(this,"stop",(function(){n._isKeyboard||(n._prevCursorPos=null,n._prevScrollPos=null,n.handleZIndex(!1),n._elements=[])})),r(this,"update",(function(e){if(e.isDragging&&n._elements.length&&!n._isKeyboard){var t=m(n._cursorDiff,"+",n._scrollDiff);n._elements.forEach((function(e){return I({element:e,posDirection:t,containerRect:n.DS.SelectorArea.rect,useTransform:n._useTransform})}))}})),r(this,"handleZIndex",(function(e){n._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=o,this._useTransform=s,this._keyboardDragSpeed=l,this._zoom=c,this._dragKeys={up:a.up.map((function(e){return e.toLowerCase()})),down:a.down.map((function(e){return e.toLowerCase()})),left:a.left.map((function(e){return e.toLowerCase()})),right:a.right.map((function(e){return e.toLowerCase()}))},this._dragKeysFlat=[].concat(v(this._dragKeys.up),v(this._dragKeys.down),v(this._dragKeys.left),v(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 i(t,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?m(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?m(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),t}(),V=function(){function t(i){var n=this,o=i.areaElement,s=i.DS,a=i.draggability,l=i.immediateDrag;e(this,t),r(this,"_areaElement",void 0),r(this,"_draggability",void 0),r(this,"_immediateDrag",void 0),r(this,"isInteracting",void 0),r(this,"isDragging",void 0),r(this,"init",(function(){n.stop(),n._areaElement.addEventListener("mousedown",n.start),n._areaElement.addEventListener("touchstart",n.start,{passive:!1}),n.DS.publish("Interaction:init",{})})),r(this,"start",(function(e){"touchstart"===e.type&&e.preventDefault(),n._canInteract(e)&&(n.isInteracting=!0,n.isDragging=n.isDragEvent(e),n.DS.publish("Interaction:start",{event:e,isDragging:n.isDragging}),document.addEventListener("mouseup",n.reset),document.addEventListener("touchend",n.reset))})),r(this,"isDragEvent",(function(e){return!(!n._draggability||n.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!n.DS.SelectableSet.has(e.target))&&(n._immediateDrag&&(n.DS.SelectedSet.size?n.DS.SelectedSet.has(e.target)||(n.DS.SelectedSet.clear(),n.DS.SelectedSet.add(e.target)):n.DS.SelectedSet.add(e.target)),!!n.DS.SelectedSet.has(e.target))})),r(this,"onClick",(function(e){var t=e.event;if(n._canInteract(t)&&!(t.detail>0)){var i=n.DS,r=i.stores,o=r.PointerStore,s=r.KeyStore,a=i.SelectableSet,l=i.SelectedSet,c=i.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:n.isDragging}))}})),r(this,"stop",(function(){n.isInteracting=!1,n.isDragging=!1,n._areaElement.removeEventListener("mousedown",n.start),n._areaElement.removeEventListener("touchstart",n.start,{passive:!1}),document.removeEventListener("mouseup",n.reset),document.removeEventListener("touchend",n.reset)})),r(this,"update",(function(e){var t=e.event,i=e.data;n.isInteracting&&n.DS.publish("Interaction:update",{event:t,data:i,isDragging:n.isDragging})})),r(this,"reset",(function(e){var t=n.isDragging;n.stop(),n.init(),n.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 n.start(t)})),this.DS.subscribe("Area:scroll",this.update)}return i(t,[{key:"_canInteract",value:function(e){return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target))}}]),t}(),N=function t(){var i=this;e(this,t),r(this,"subscribers",{}),r(this,"subscribe",(function(e,t){return Array.isArray(i.subscribers[e])||(i.subscribers[e]=[]),i.subscribers[e].push(t),i.subscribers[e].length-1})),r(this,"unsubscribe",(function(e,t,r){r>=0?i.subscribers[e].splice(r,1):t&&(i.subscribers[e]=i.subscribers[e].filter((function(e){return e!==t})))})),r(this,"publish",(function(e,t){Array.isArray(i.subscribers[e])&&i.subscribers[e].forEach((function(e){return e(t)}))}))},M=function(t){n(a,t);var s=h(a);function a(t){var i,n=t.elements,o=t.className,l=t.hoverClassName,c=t.draggability,d=t.useTransform,h=t.DS;return e(this,a),r(u(i=s.call(this)),"_initElements",void 0),r(u(i),"_className",void 0),r(u(i),"_hoverClassName",void 0),r(u(i),"_useTransform",void 0),r(u(i),"_draggability",void 0),r(u(i),"init",(function(){return i._initElements.forEach((function(e){return i.add(e)}))})),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"_onClick",(function(e){return i.DS.publish("Selectable:click",{event:e})})),r(u(i),"_onPointer",(function(e){return i.DS.publish("Selectable:pointer",{event:e})})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=h,i._initElements=A(n),i._className=o,i._hoverClassName=l,i._useTransform=d,i._draggability=c,i.DS.subscribe("Interaction:init",i.init),i}return i(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&&k({computedStyle:window.getComputedStyle(e),node:e}),f(o(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}),f(o(a.prototype),"delete",this).call(this,e)}},{key:"elements",get:function(){return Array.from(this.values())}}]),a}(c(Set)),K=function(t){n(a,t);var s=h(a);function a(t){var i,n=t.className,o=t.DS;return e(this,a),r(u(i=s.call(this)),"_className",void 0),r(u(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(u(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(u(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=o,i._className=n,i}return i(a,[{key:"add",value:function(e){if(!f(o(a.prototype),"has",this).call(this,e))return f(o(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(f(o(a.prototype),"has",this).call(this,e)){var t=f(o(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}(c(Set)),z=function(){function t(i){var n=this,o=i.DS,s=i.hoverClassName,a=i.multiSelectToggling;e(this,t),r(this,"_prevSelectedSet",void 0),r(this,"_hoverClassName",void 0),r(this,"_multiSelectToggling",void 0),r(this,"start",(function(e){var t=e.event;e.isDragging||(n._storePrevious(t),n._handleInsideSelection(!0,t))})),r(this,"update",(function(e){e.isDragging||n._handleInsideSelection()})),r(this,"_handleInsideSelection",(function(e,t){for(var i=n.DS,r=i.SelectableSet,o=i.SelectorArea,s=i.Selector,a=r.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])&&(E(a[u][1],s.rect)?l.push(a[u][0]):c.push(a[u][0]));var h=n.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&n._multiSelectToggling;l.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.multiSelectionToggle,n=e.SelectedSet,o=e.hoverClassName;t.classList.contains(o)&&!i||(n.has(t)?r&&n.delete(t):n.add(t),t.classList.add(o))}({element:t,force:e,multiSelectionToggle:h,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName})})),c.forEach((function(t){return function(e){var t=e.element,i=e.force,r=e.SelectedSet,n=e.PrevSelectedSet,o=e.hoverClassName;if(!t.classList.contains(o)&&!i)return!1;var s=r.has(t),a=n.has(t);s&&!a?r.delete(t):!s&&a&&r.add(t),t.classList.remove(o)}({element:t,force:e,SelectedSet:n.DS.SelectedSet,hoverClassName:n._hoverClassName,PrevSelectedSet:n._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 i(t,[{key:"_storePrevious",value:function(e){var t=this.DS,i=t.stores.KeyStore,r=t.SelectedSet;i.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(r):this._prevSelectedSet=new Set}}]),t}(),H=function(){function t(i){var n=this,o=i.DS,s=i.selector,a=i.selectorClass,l=i.customStyles;e(this,t),r(this,"_rect",void 0),r(this,"start",(function(e){if(!e.isDragging){var t=n.DS.stores.PointerStore.initialValArea;L(n.HTMLNode,p(t,1)),n.HTMLNode.style.display="block",n._rect=null}})),r(this,"stop",(function(){n.HTMLNode.style.width="0",n.HTMLNode.style.height="0",n.HTMLNode.style.display="none"})),r(this,"update",(function(e){if(!e.isDragging){var t=n.DS.stores,i=t.ScrollStore,r=t.PointerStore,o=function(e){var t=e.scrollAmount,i=e.initialPointerPos,r=e.pointerPos,n={};return r.x>i.x-t.x?(n.left=i.x-t.x,n.width=r.x-i.x+t.x):(n.left=r.x,n.width=i.x-r.x-t.x),r.y>i.y-t.y?(n.top=i.y-t.y,n.height=r.y-i.y+t.y):(n.top=r.y,n.height=i.y-r.y-t.y),n}({scrollAmount:i.scrollAmount,initialPointerPos:r.initialValArea,pointerPos:r.currentValArea});L(n.HTMLNode,o),n._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 i(t,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),t}(),R=function(){function t(i){var n=this,o=i.DS,s=i.selectorAreaClass,a=i.autoScrollSpeed,l=i.overflowTolerance;e(this,t),r(this,"_autoScrollSpeed",void 0),r(this,"_scrollInterval",void 0),r(this,"_rect",void 0),r(this,"currentEdges",[]),r(this,"_overflowTolerance",void 0),r(this,"updatePos",(function(){n._rect=null;var e=n.DS.Area.rect,t=n.DS.Area.computedBorder,i=n.HTMLNode.style,r="".concat(e.top+t.top,"px"),o="".concat(e.left+t.left,"px"),s="".concat(e.width,"px"),a="".concat(e.height,"px");i.top!==r&&(i.top=r),i.left!==o&&(i.left=o),i.width!==s&&(i.width=s),i.height!==a&&(i.height=a)})),r(this,"startAutoScroll",(function(){n.currentEdges=[],n._scrollInterval=setInterval((function(){return n.handleAutoScroll()}),16)})),r(this,"handleAutoScroll",(function(){var e=n.DS,t=e.stores.PointerStore,i=e.Area;n.currentEdges=_({elementRect:p(t.currentVal),containerRect:n.rect,tolerance:n._overflowTolerance}),n.currentEdges.length&&i.scroll(n.currentEdges,n._autoScrollSpeed)})),r(this,"stopAutoScroll",(function(){n.currentEdges=[],clearInterval(n._scrollInterval)})),r(this,"isInside",(function(e,t){return!(!n.DS.Area.HTMLNode.contains(e)||!n.DS.stores.ScrollStore.canScroll)||E(n.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.HTMLNode.appendChild(this.DS.Selector.HTMLNode);var c=document.body?"body":"documentElement";document[c].appendChild(this.HTMLNode),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){n.updatePos(),n.stopAutoScroll()}))}return i(t,[{key:"isClicked",value:function(){var e=this.DS.stores.PointerStore;return E({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}(),O=function(){function t(i){var n=this,o=i.DS,s=i.multiSelectKeys,a=i.multiSelectMode;e(this,t),r(this,"_multiSelectMode",void 0),r(this,"_multiSelectKeys",void 0),r(this,"_currentValues",new Set),r(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),r(this,"init",(function(){document.addEventListener("keydown",n.keydown),document.addEventListener("keyup",n.keyup),window.addEventListener("blur",n.reset)})),r(this,"keydown",(function(e){var t=e.key.toLowerCase();n._currentValues.add(t),n.DS.publish("KeyStore:down",{event:e,key:t})})),r(this,"keyup",(function(e){var t=e.key.toLowerCase();n._currentValues.delete(t),n.DS.publish("KeyStore:up",{event:e,key:t})})),r(this,"stop",(function(){document.removeEventListener("keydown",n.keydown),document.removeEventListener("keyup",n.reset),window.removeEventListener("blur",n.reset),n.reset()})),r(this,"reset",(function(){return n._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 i(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(i){return e[t._keyMapping[i]]}))))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),t}(),B=function(){function t(i){var n=this,o=i.DS;e(this,t),r(this,"_isMouseInteraction",!1),r(this,"_initialValArea",void 0),r(this,"_currentValArea",void 0),r(this,"_lastValArea",void 0),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_lastVal",void 0),r(this,"_lastTouch",void 0),r(this,"init",(function(){document.addEventListener("mousemove",n.update),document.addEventListener("touchmove",n.update,{passive:!1})})),r(this,"update",(function(e){e&&(n.currentVal=D({event:n._normalizedEvent(e)}),n._isMouseInteraction&&n.DS.publish("PointerStore:updated",{event:e}))})),r(this,"stop",(function(){document.removeEventListener("mousemove",n.update),document.removeEventListener("touchmove",n.update,{passive:!1}),setTimeout((function(){return n._isMouseInteraction=!1}),100)})),r(this,"reset",(function(e){e&&(n.currentVal=n.lastVal=D({event:n._normalizedEvent(e)}),n.stop(),n.init())})),this.DS=o,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return n.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return n.reset(t)}))}return i(t,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=D({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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(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&&m(e,"-",m(g(this.DS.Area.rect),"+",g(this.DS.Area.computedBorder)))}}]),t}(),j=function(){function t(i){var n=this,o=i.DS,s=i.areaElement,a=i.zoom;e(this,t),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_areaElement",void 0),r(this,"_canScroll",void 0),r(this,"init",(function(){return n._areaElement.addEventListener("scroll",n.update)})),r(this,"start",(function(){n._currentVal=n._initialVal=b(n._areaElement),n._areaElement.addEventListener("scroll",n.update)})),r(this,"update",(function(){return n._currentVal=b(n._areaElement)})),r(this,"stop",(function(){n._areaElement.removeEventListener("scroll",n.update),n._initialVal={x:0,y:0},n._canScroll=null})),r(this,"reset",(function(){n.stop(),n.start()})),this._areaElement=s,this.DS=o,this.zoom=a,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return n.start()})),this.DS.subscribe("Interaction:end",(function(){return n.reset()}))}return i(t,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this._areaElement,!!((t=b(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=m(this.currentVal,"-",this.initialVal),i={x:e=this.zoom,y:e},r=m(m(t,"*",i),"-",t);return{x:t.x+r.x,y:t.y+r.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=b(this._areaElement)),this._currentVal}}]),t}();return function(){function t(i){var n=this,o=i.area,s=void 0===o?document:o,a=i.selectables,l=void 0===a?[]:a,c=i.autoScrollSpeed,u=void 0===c?5:c,d=i.overflowTolerance,h=void 0===d?{x:25,y:25}:d,f=i.zoom,v=void 0===f?1:f,S=i.customStyles,m=void 0!==S&&S,g=i.multiSelectMode,p=void 0!==g&&g,y=i.multiSelectToggling,b=void 0===y||y,_=i.multiSelectKeys,D=void 0===_?["Control","Shift","Meta"]:_,w=i.selector,x=void 0===w?void 0:w,k=i.draggability,E=void 0===k||k,I=i.immediateDrag,P=void 0===I||I,A=i.dragKeys,L=i.keyboardDragSpeed,U=void 0===L?10:L,W=i.useTransform,F=void 0===W||W,Z=i.hoverClass,G=void 0===Z?"ds-hover":Z,X=i.selectableClass,Y=void 0===X?"ds-selectable":X,$=i.selectedClass,q=void 0===$?"ds-selected":$,J=i.selectorClass,Q=void 0===J?"ds-selector":J,ee=i.selectorAreaClass,te=void 0===ee?"ds-selector-area":ee,ie=i.callback,re=i.onDragMove,ne=i.onDragStartBegin,oe=i.onDragStart,se=i.onElementSelect,ae=i.onElementUnselect;e(this,t),r(this,"start",(function(){return n.Interaction.init()})),r(this,"getSelection",(function(){return n.SelectedSet.elements})),r(this,"getSelectables",(function(){return n.SelectableSet.elements})),r(this,"getInitialCursorPosition",(function(){return n.stores.PointerStore.initialVal})),r(this,"getCurrentCursorPosition",(function(){return n.stores.PointerStore.currentVal})),r(this,"getPreviousCursorPosition",(function(){return n.stores.PointerStore.lastVal})),r(this,"getInitialCursorPositionArea",(function(){return n.stores.PointerStore.initialValArea})),r(this,"getCurrentCursorPositionArea",(function(){return n.stores.PointerStore.currentValArea})),r(this,"getPreviousCursorPositionArea",(function(){return n.stores.PointerStore.lastValArea})),r(this,"isMultiSelect",(function(e){return n.stores.KeyStore.isMultiSelectKeyPressed(e)})),r(this,"isDragging",(function(){return n.Interaction.isDragging})),this.PubSub=new N,this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this._callbacksTemp({callback:ie,onDragMove:re,onDragStart:oe,onDragStartBegin:ne,onElementSelect:se,onElementUnselect:ae}),this.stores={PointerStore:new B({DS:this}),ScrollStore:new j({DS:this,areaElement:s,zoom:v}),KeyStore:new O({DS:this,multiSelectKeys:D,multiSelectMode:p})},this.Area=new T({area:s,PS:this.PubSub,zoom:v}),this.Selector=new H({DS:this,selector:x,selectorClass:Q,customStyles:m}),this.SelectorArea=new R({DS:this,selectorAreaClass:te,autoScrollSpeed:u,overflowTolerance:h}),this.SelectableSet=new M({elements:l,DS:this,className:Y,hoverClassName:G,useTransform:F,draggability:E}),this.SelectedSet=new K({DS:this,className:q}),this.Selection=new z({DS:this,hoverClassName:G,multiSelectToggling:b}),this.Drag=new C({DS:this,useTransform:F,dragKeys:Object.assign({up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},A),zoom:v,keyboardDragSpeed:U}),this.Interaction=new V({areaElement:s,DS:this,draggability:E,immediateDrag:P}),this.subscribe("Selected:added",(function(e){var t=e.items,i=e.item;return n.publish("elementselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Selected:removed",(function(e){var t=e.items,i=e.item;return n.publish("elementunselect",{items:t,item:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:update",(function(e){var t=e.event,i=e.isDragging;t&&n.publish("dragmove",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Area:scroll",(function(e){var t=e.scroll_directions,i=e.scroll_multiplier;n.publish("autoscroll",{items:n.getSelection(),scroll_directions:t,scroll_multiplier:i,isDragging:n.Interaction.isDragging})})),this.subscribe("Interaction:start",(function(e){var t=e.event,i=e.isDragging;return n.publish("dragstart",{items:n.getSelection(),event:t,isDragging:i})})),this.subscribe("Interaction:end",(function(e){var t=e.event,i=e.isDragging;return n.publish("callback",{items:n.getSelection(),event:t,isDragging:i})})),this.start()}return i(t,[{key:"_callbacksTemp",value:function(e){var t=e.callback,i=e.onDragMove,r=e.onDragStart,n=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 i=e.items,r=(e.item,e.event);return t(i,r)}))),i&&(a("onDragMove","dragmove"),this.subscribe("dragmove",(function(e){e.items,e.item;var t=e.event;return i(t)}))),r&&(a("onDragStart","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return r(t)}))),n&&(a("onDragStartBegin","dragstart"),this.subscribe("dragstart",(function(e){e.items,e.item;var t=e.event;return n(t)}))),o&&(a("onElementSelect","elementselect"),this.subscribe("elementselect",(function(e){e.items;var t=e.item,i=e.event;return o(t,i)}))),s&&(a("onElementUnselect","elementunselect"),this.subscribe("elementunselect",(function(e){e.items;var t=e.item,i=e.event;return s(t,i)})))}},{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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(A(e)),i||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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(A(e)),i&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return A(e).forEach((function(n){return t.SelectedSet.has(n)?t.removeSelection(e,i,r):t.addSelection(e,i,r)})),i&&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],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,i),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],i=A(e);return this.SelectableSet.addAll(i),t&&this.SelectedSet.addAll(i),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.removeSelectables(e,t),this.addSelectables(e,i)}},{key:"removeSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(A(e)),t&&this.removeSelection(e),e}},{key:"getCursorPositionDifference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];console.warn("[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`");var t=this.getCurrentCursorPosition(),i=e?this.getPreviousCursorPosition():this.getInitialCursorPosition();return m(t,"-",i)}}]),t}()})); |
{ | ||
"name": "dragselect", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "easy javascript drag select functionality for your projects", | ||
"main": "./dist/DragSelect.js", | ||
"dependencies": {}, | ||
"scripts": { | ||
@@ -8,0 +7,0 @@ "prestart": "npm i", |
@@ -434,4 +434,4 @@ // @ts-check | ||
removeSelectables(elements, removeFromSelection = false) { | ||
this.SelectedSet.clear() | ||
if (removeFromSelection) this.SelectedSet.clear() | ||
this.SelectableSet.deleteAll(toArray(elements)) | ||
if (removeFromSelection) this.removeSelection(elements) | ||
return elements | ||
@@ -438,0 +438,0 @@ } |
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
423443