Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dragselect

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dragselect - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

dist/methods/subscriberAliases.d.ts

12

CHANGELOG.md

@@ -0,1 +1,11 @@

# 2.2.0
- Add new possible callback value: `isDraggingKeyboard`
- Add new settings prop `keyboardDrag: false`
- Add `pre` events for all events. i.e. `predragstart`, `predragmove`, etc.
- Add information on 3rd party integration to the README.
- Re-add `break` functionality to give maximum flexibility on 3rd party integration
All these changes solve #80
# 2.1.2

@@ -95,3 +105,3 @@

- `.break` was removed
- `.break` (use `.stop` and `.start` instead) (back in v2.2.0)
- `.getCursorPos`

@@ -98,0 +108,0 @@ - `.getScroll`

20

dist/DragSelect.d.ts

@@ -8,7 +8,12 @@ export default DragSelect;

*/
constructor({ area, selectables, autoScrollSpeed, overflowTolerance, zoom, customStyles, multiSelectMode, multiSelectToggling, multiSelectKeys, selector, draggability, immediateDrag, dragKeys, keyboardDragSpeed, useTransform, hoverClass, selectableClass, selectedClass, selectorClass, selectorAreaClass, callback, onDragMove, onDragStartBegin, onDragStart, onElementSelect, onElementUnselect, }: Settings);
constructor({ area, selectables, autoScrollSpeed, overflowTolerance, zoom, customStyles, multiSelectMode, multiSelectToggling, multiSelectKeys, selector, draggability, immediateDrag, keyboardDrag, dragKeys, keyboardDragSpeed, useTransform, hoverClass, selectableClass, selectedClass, selectorClass, selectorAreaClass, callback, onDragMove, onDragStartBegin, onDragStart, onElementSelect, onElementUnselect, }: Settings);
/**
* used to skip all current Selection and dragNdrop functionality
* @type {boolean}
*/
continue: boolean;
PubSub: PubSub;
subscribe: (eventName: DSCallbackNames, callback: Function) => number;
unsubscribe: (eventName: DSCallbackNames, callback?: Function, id?: number) => void;
publish: (eventName: DSCallbackNames, data: any) => void;
publish: (eventName: DSCallbackNames, data: CallbackObject) => void;
stores: {

@@ -49,2 +54,8 @@ PointerStore: PointerStore;

/**
* Utility to override DragSelect internal functionality:
* Break will skip the selection or dragging functionality but let everything continue to run until after the callback.
* Useful utility to write your own functionality/move/dragNdrop based on DragSelect pointer positions.
*/
break: () => boolean;
/**
* Returns the current selected nodes

@@ -145,8 +156,9 @@ * @return {DSElements}

/**
* Returns the cursor position difference between start and now
* Utility method that returns the cursor position difference between start and now
* @param {boolean} [usePreviousCursorDifference] if true, it will output the cursor position difference between the previous selection and now
* @param {boolean} [useAreaPositions] if true, it will use cursor positions relative to the area
* @return {Vect2}
* @deprecated
*/
getCursorPositionDifference(usePreviousCursorDifference?: boolean): Vect2;
getCursorPositionDifference(usePreviousCursorDifference?: boolean, useAreaPositions?: boolean): Vect2;
/**

@@ -153,0 +165,0 @@ * Whether the user is currently drag n dropping elements (instead of selection)

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

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

@@ -24,4 +24,5 @@ export * as vect2 from "./vect2";

export { default as setStylePosition } from "./setStylePosition";
export { default as subscriberAliases } from "./subscriberAliases";
export { default as toArray } from "./toArray";
export { default as updateElementStylePos } from "./updateElementStylePos";
import "../types"

@@ -8,2 +8,3 @@ export default class Drag {

* @param {DSDragKeys} p.dragKeys
* @param {boolean} p.keyboardDrag
* @param {number} p.keyboardDragSpeed

@@ -13,3 +14,3 @@ * @param {number} p.zoom

*/
constructor({ DS, dragKeys, draggability, keyboardDragSpeed, useTransform, zoom, }: {
constructor({ DS, dragKeys, draggability, keyboardDrag, keyboardDragSpeed, useTransform, zoom, }: {
DS: DragSelect;

@@ -19,2 +20,3 @@ draggability: boolean;

dragKeys: DSDragKeys;
keyboardDrag: boolean;
keyboardDragSpeed: number;

@@ -59,2 +61,7 @@ zoom: number;

/**
* @type {boolean}
* @private
*/
private _keyboardDrag;
/**
* @type {number}

@@ -74,3 +81,2 @@ * @private

}) => void;
_isKeyboard: boolean;
keyboardEnd: ({ event, key }: {

@@ -80,8 +86,10 @@ event: any;

}) => void;
start: ({ isDragging }: {
start: ({ isDragging, isDraggingKeyboard }: {
isDragging: any;
isDraggingKeyboard: any;
}) => void;
stop: () => void;
update: ({ isDragging }: {
stop: (evt: any) => void;
update: ({ isDragging, isDraggingKeyboard }: {
isDragging: any;
isDraggingKeyboard: any;
}) => void;

@@ -88,0 +96,0 @@ handleZIndex: (add: any) => void;

@@ -58,5 +58,6 @@ export default class Interaction {

stop: () => void;
update: ({ event, data }: {
update: ({ event, scroll_directions, scroll_multiplier }: {
event: any;
data: any;
scroll_directions: any;
scroll_multiplier: any;
}) => void;

@@ -63,0 +64,0 @@ reset: (event: any) => void;

@@ -26,6 +26,6 @@ export default class PubSub {

* @param {DSCallbackNames} eventName
* @param {CallbackObject|*} data passed to the subscription method
* @param {CallbackObject} data passed to the subscription method
*/
publish: (eventName: DSCallbackNames, data: CallbackObject | any) => void;
publish: (eventName: DSCallbackNames, data: CallbackObject) => void;
}
import "../types"

@@ -43,2 +43,3 @@ export default class SelectorArea {

updatePos: () => void;
stop: () => void;
startAutoScroll: () => void;

@@ -45,0 +46,0 @@ /** Creates an interval that auto-scrolls while the cursor is near the edge */

@@ -54,2 +54,6 @@ /**

/**
* Whether or not the user can drag with the keyboard (we don't recommend disabling it)
*/
keyboardDrag?: boolean;
/**
* The keys available to drag element using the keyboard.

@@ -122,3 +126,3 @@ */

*/
event?: MouseEvent | TouchEvent | Event;
event?: MouseEvent | TouchEvent | KeyboardEvent | Event;
/**

@@ -132,2 +136,10 @@ * The single item currently interacted with

isDragging?: boolean;
/**
* Whether or not the drag interaction is via keyboard
*/
isDraggingKeyboard?: boolean;
/**
* Pressed key (lowercase)
*/
key?: string;
scroll_directions?: Array<'top' | 'bottom' | 'left' | 'right' | undefined>;

@@ -180,2 +192,3 @@ scroll_multiplier?: number;

type DSInternalEventNames = "Interaction:init" | "Interaction:start" | "Interaction:end" | "Interaction:update" | "Area:modified" | "Area:scroll" | "PointerStore:updated" | "Selected:added" | "Selected:removed" | "Selectable:click" | "Selectable:pointer" | "KeyStore:down" | "KeyStore:up";
type DSInternalEventNamesPre = "Interaction:init:pre" | "Interaction:start:pre" | "Interaction:end:pre" | "Interaction:update:pre" | "Area:modified:pre" | "Area:scroll:pre" | "PointerStore:updated:pre" | "Selected:added:pre" | "Selected:removed:pre" | "Selectable:click:pre" | "Selectable:pointer:pre" | "KeyStore:down:pre" | "KeyStore:up:pre" | "Drag:keyboardDrag:pre";
/**

@@ -182,0 +195,0 @@ * the name of the callback

{
"name": "dragselect",
"version": "2.1.2",
"version": "2.2.0",
"description": "easy javascript drag select functionality for your projects",

@@ -8,14 +8,17 @@ "main": "./dist/DragSelect.js",

"scripts": {
"open": "open __tests__/quicktest.html -a 'Google Chrome'",
"prestart": "npm i",
"start": "npm run open & npm run watch",
"open": "open __tests__/quicktest.html -a 'Google Chrome'",
"watch": "concurrently --kill-others \"npm run checkjs:watch\" \"npm run rollup:watch\" \"npm run test:watch\"",
"\n# TESTING:": "",
"checkjs": "tsc --lib es2019,dom -t es5 --allowJs --checkJs --noEmit src/*.js",
"checkjs:watch": "npm run checkjs -- -w",
"postcheckjs": "npm run docs && rm -rf docs",
"checkjs": "tsc --lib es2019,dom -t es5 --allowJs --checkJs --noEmit src/*.js",
"checkjs:watch": "tsc -w --lib es2019,dom -t es5 --allowJs --checkJs --noEmit src/*.js",
"types": "tsc src/DragSelect.js --lib es2019,dom -t es5 --declaration --allowJs --emitDeclarationOnly --outDir dist",
"test": "npm run checkjs && jest --detectOpenHandles",
"test:watch": "npm run test -- --watch",
"\n# BUILDING:": "",
"build": "npm run rollup",
"docs": "jsdoc -c jsdoc.json",
"premedia": "rm -r docs/media &",
"media": "cp -R .media docs/media",
"premedia": "rm -r docs/media &",
"rm": "rm -rf dist docs",
"prerollup": "npm run types",

@@ -25,4 +28,4 @@ "rollup": "rollup -c",

"rollup:watch": "npm run rollup -- -w",
"test": "npm run checkjs && jest --detectOpenHandles",
"test:watch": "jest --watch",
"types": "tsc src/DragSelect.js --lib es2019,dom -t es5 --declaration --allowJs --emitDeclarationOnly --outDir dist",
"\n## PROD:": "",
"travis:build": "npm run rollup:travis && npm run media && npm run docs",

@@ -29,0 +32,0 @@ "travis:test": "npm run rollup && npm run test"

@@ -12,3 +12,3 @@ ```

[![Build Status](https://travis-ci.com/ThibaultJanBeyer/DragSelect.svg?branch=master)](https://travis-ci.com/ThibaultJanBeyer/DragSelect) ![gzip size](http://img.badgesize.io/https://dragselect.com/v2/ds.min.js?compression=gzip) ![npm downloads count](https://img.shields.io/npm/dt/dragselect.svg) [![No Dependency](https://david-dm.org/ThibaultJanBeyer/DragSelect.svg)](https://david-dm.org/ThibaultJanBeyer/DragSelect)
[![Build Status](https://travis-ci.com/ThibaultJanBeyer/DragSelect.svg?branch=master)](https://travis-ci.com/ThibaultJanBeyer/DragSelect) ![gzip size](https://img.badgesize.io/https://dragselect.com/v2/ds.min.js?compression=gzip) ![npm downloads count](https://img.shields.io/npm/dt/dragselect.svg) [![No Dependency](https://david-dm.org/ThibaultJanBeyer/DragSelect.svg)](https://david-dm.org/ThibaultJanBeyer/DragSelect)

@@ -26,2 +26,8 @@ # DragSelect ![GitHub package.json version](https://img.shields.io/github/package-json/v/ThibaultJanBeyer/DragSelect.svg)

- [Usage](#usage)
- - [Simple](#simple)
- - [Within a scroll-able Area](#within-a-scroll-able-area)
- - [Extended](#extended)
- - [Mobile/Touch usage](#mobile/touch-usage)
- - [Accessibility (a11y)](#accessibility-a11y)
- - [Use your own Drag And Drop](#use-your-own-drag-and-drop)
- [Constructor Properties](#constructor-properties)

@@ -48,3 +54,3 @@ - [Event Callbacks](#event-callbacks)

- Selected elements can be dragged and dropped
- Lightweight, only ![gzip size](http://img.badgesize.io/https://dragselect.com/v2/ds.min.js?compression=gzip)
- Lightweight, only ![gzip size](https://img.badgesize.io/https://dragselect.com/v2/ds.min.js?compression=gzip)
- Popular: ![npm downloads count](https://img.shields.io/npm/dt/dragselect.svg) on npm

@@ -191,2 +197,56 @@ - DragSelect was written with Performance in mind (can easily select >15.000 Elements)

## Use your own Drag And Drop
### Using another plugin/tool (3rd party)
DragSelect comes with a build-in dragNdrop. Before, `.break` was used for this. But with v2, using your own is now very simple: listen to any DragSelect event to `.stop` it. Then, re-`.start` it after your custom dragNdrop was performed. Check for `isDragging`, which indicates when the users drags (moving the element) and `isDraggingKeyboard` for the keyboard drag events. I.e. use `predragstart`.
#### Example
```JavaScript
const ds = new DragSelect({
keyboardDragSpeed: 0,
// keyboardDrag: false, // if your library can not handle keyboard dragging
/* …other settings… */
})
const myCustomDrag = new MyCustomDrag({/* …your settings… */})
ds.subscribe('predragstart', ({ isDragging, isDraggingKeyboard }) =>
isDragging && ds.stop(false, false))
myCustomDrag.subscribe('finished', () => ds.start())
```
Disabling then re-enabling directly can also work (i.e. when your library has no callback):
```JavaScript
ds.subscribe('dragstart', ({ isDragging, isDraggingKeyboard }) => {
if(isDragging) {
ds.stop(false, false)
ds.start()
}
})
```
### Writing a fully custom solution
In case you want to build something completely custom on top of DragSelect, we got you covered! You can use `.break` for this. You heard right, break is back baby :)
This utility to override DragSelects internal functionality allows you to write it all yourself: You can write your own drag and drop but you can also write your own selection:
#### Example
> /!\ only use break when you know what you're doing. Support is limited /!\
```JavaScript
ds.subscribe('predragmove', ({ isDragging, isDraggingKeyboard }) => {
if(isDragging || isDraggingKeyboard) {
ds.break()
/* your custom logic for drag handling here. */
} else {
ds.break()
/* your custom logic for selection handling here. */
}
}
```
# Constructor Properties:

@@ -210,2 +270,3 @@

|immediateDrag |boolean |Whether a selectable element is draggable before being selected or needs to be selected first |`true`
|keyboardDrag |boolean |Whether or not the user can drag with the keyboard (Accessibility). |`true`
|dragKeys |{ up:string[], down:string[], left:string[], righ:string[] } |The keys available to drag element using the keyboard. Any key value is possible ([see MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)). |`{ up:['ArrowUp'], down: ['ArrowDown'], left: ['ArrowLeft'], righ: ['ArrowRight'] }`

@@ -231,9 +292,11 @@ |keyboardDragSpeed |number |The speed at which elements are dragged using the keyboard. In pixels per keyDown. |`10`

|--- |--- |---
|callback |`{ items, event, isDragging }` |Fired after the selection (i.e. on mouse-up).
|dragstart |`{ items, event, isDragging }` |Fired when the selection starts (i.e. on mouse-down).
|dragmove |`{ items, event, isDragging }` |Fired when the mouse moves while dragging (i.e. on mouse-move).
|autoscroll |`{ items, scroll_directions, scroll_multiplier, isDragging }` |Fired when the area is auto-scrolled (i.e. cursor on a corner of the area).
|elementselect |`{ items, item }` |Fired when an element is added to the selection.
|elementunselect |`{ items, item }` |Fired when an element is removed from the selection.
|callback |`{ items, event, isDragging, … }` |Fired after the selection (i.e. on mouse-up).
|dragstart |`{ items, event, isDragging, isDraggingKeyboard, … }` |Fired when the selection starts (i.e. on mouse-down).
|dragmove |`{ items, event, isDragging, isDraggingKeyboard, … }` |Fired when the mouse moves while dragging (i.e. on mouse-move).
|autoscroll |`{ items, isDragging, scroll_directions, scroll_multiplier, … }` |Fired when the area is auto-scrolled (i.e. cursor on a corner of the area).
|elementselect |`{ items, item, … }` |Fired when an element is added to the selection.
|elementunselect |`{ items, item, … }` |Fired when an element is removed from the selection.
> Note: all your callbacks subscribers will run happen after the internal code ran. If you want to run something before everything else, use the `pre` prefix. I.e. `predragstart` is an event that runs before any internal start logic.
### Callback Object Keys

@@ -243,10 +306,11 @@

|--- |--- |---
|event |`MouseEvent|TouchEvent|KeyboardEvent` |The native HTML Event, depending on the situational context
|items |`Array.<HTMLElement|SVGElement|*>` |Current selected elements
|event |`MouseEvent|TouchEvent|KeyboardEvent` |The native HTML Event, depending on the situational context
|isDragging |`boolean` |If true, the user is dragging the selected elements, if false the user is drawing a selection
|isDraggingKeyboard |`boolean` |If true, the user is dragging the selected elements with the keyboard
|scroll_directions |`Array.<'top'|'bottom'|'left'|'right'|undefined>` |The direction in which the event is happening (i.e. scroll direction)
|scroll_multiplier |`number` |Speed
|item |`HTMLElement|SVGElement|*` |The element currently being interacted
|item |`HTMLElement|SVGElement|*` |The single element currently being interacted with if any
*Note: all object keys are optional and might not be available, depending on the event type. So make sure to check for availability first*
> Note: all object keys are optional and might not be available, depending on the event type. So make sure to check for availability first

@@ -280,2 +344,3 @@ # Methods:

|isDragging |/ |Whether the user is currently drag n dropping elements (instead of selection)
|break |/ |Utility to override DragSelect internal functionality. Read [docs](#writing-a-fully-custom-solution) for more info.

@@ -299,3 +364,3 @@ # Classes

[![Typewriter Gif](https://dragselect.com/media/typewriter.gif)](http://thibaultjanbeyer.com/)
[![Typewriter Gif](https://dragselect.com/media/typewriter.gif)](https://thibaultjanbeyer.com/)

@@ -302,0 +367,0 @@

@@ -58,3 +58,3 @@ // @ts-check

import { PointerStore, ScrollStore, KeyStore } from './stores'
import { toArray, vect2 } from './methods'
import { toArray, vect2, subscriberAliases } from './methods'

@@ -66,2 +66,7 @@ // Setup

/**
* used to skip all current Selection and dragNdrop functionality
* @type {boolean}
*/
continue = false
/**
* @class DragSelect

@@ -84,2 +89,3 @@ * @constructor DragSelect

immediateDrag = true,
keyboardDrag = true,
dragKeys,

@@ -159,2 +165,3 @@ keyboardDragSpeed = 10,

useTransform,
keyboardDrag,
dragKeys: Object.assign(

@@ -181,50 +188,11 @@ {

// Subscriber Aliases
this.subscribe('Selected:added', ({ items, item }) =>
this.publish('elementselect', {
items,
item,
isDragging: this.Interaction.isDragging,
})
)
this.subscribe('Selected:removed', ({ items, item }) =>
this.publish('elementunselect', {
items,
item,
isDragging: this.Interaction.isDragging,
})
)
this.subscribe('Interaction:update', ({ event, isDragging }) => {
if (event)
this.publish('dragmove', {
items: this.getSelection(),
event,
isDragging,
})
subscriberAliases({
subscribe: this.subscribe,
publish: this.publish,
SelectedSet: this.SelectedSet,
Interaction: this.Interaction,
})
this.subscribe(
'Area:scroll',
({ scroll_directions, scroll_multiplier }) => {
this.publish('autoscroll', {
items: this.getSelection(),
scroll_directions,
scroll_multiplier,
isDragging: this.Interaction.isDragging,
})
}
)
this.subscribe('Interaction:start', ({ event, isDragging }) =>
this.publish('dragstart', {
items: this.getSelection(),
event,
isDragging,
})
)
this.subscribe('Interaction:end', ({ event, isDragging }) =>
this.publish('callback', {
items: this.getSelection(),
event,
isDragging,
})
)
this.subscribe('Interaction:end', () => (this.continue = false))
this.start()

@@ -302,2 +270,3 @@ }

this.Selector.stop()
this.SelectorArea.stop()
this.stores.KeyStore.stop()

@@ -311,2 +280,8 @@ this.stores.PointerStore.stop()

/**
* Utility to override DragSelect internal functionality:
* Break will skip the selection or dragging functionality but let everything continue to run until after the callback.
* Useful utility to write your own functionality/move/dragNdrop based on DragSelect pointer positions.
*/
break = () => (this.continue = true)
/**
* Returns the current selected nodes

@@ -465,14 +440,24 @@ * @return {DSElements}

/**
* Returns the cursor position difference between start and now
* Utility method that returns the cursor position difference between start and now
* @param {boolean} [usePreviousCursorDifference] if true, it will output the cursor position difference between the previous selection and now
* @param {boolean} [useAreaPositions] if true, it will use cursor positions relative to the area
* @return {Vect2}
* @deprecated
*/
getCursorPositionDifference(usePreviousCursorDifference = false) {
getCursorPositionDifference(
usePreviousCursorDifference = false,
useAreaPositions = false
) {
console.warn(
'[DragSelect] Using .getCursorPositionDifference is deprecated. Calculate yourself instead. i.e. `.getCurrentCursorPosition().x - .getInitialCursorPosition().x`'
)
const posA = this.getCurrentCursorPosition()
const posA = useAreaPositions
? this.getCurrentCursorPositionArea()
: this.getCurrentCursorPosition()
const posB = usePreviousCursorDifference
? this.getPreviousCursorPosition()
? useAreaPositions
? this.getPreviousCursorPositionArea()
: this.getPreviousCursorPosition()
: useAreaPositions
? this.getInitialCursorPositionArea()
: this.getInitialCursorPosition()

@@ -479,0 +464,0 @@ return vect2.calc(posA, '-', posB)

@@ -24,3 +24,4 @@ export * as vect2 from './vect2'

export { default as setStylePosition } from './setStylePosition'
export { default as subscriberAliases } from './subscriberAliases'
export { default as toArray } from './toArray'
export { default as updateElementStylePos } from './updateElementStylePos'

@@ -44,2 +44,7 @@ // @ts-check

/**
* @type {boolean}
* @private
*/
_keyboardDrag
/**
* @type {number}

@@ -61,2 +66,3 @@ * @private

* @param {DSDragKeys} p.dragKeys
* @param {boolean} p.keyboardDrag
* @param {number} p.keyboardDragSpeed

@@ -70,2 +76,3 @@ * @param {number} p.zoom

draggability,
keyboardDrag,
keyboardDragSpeed,

@@ -78,2 +85,3 @@ useTransform,

this._keyboardDragSpeed = keyboardDragSpeed
this._keyboardDrag = keyboardDrag
this._zoom = zoom

@@ -103,12 +111,16 @@ this._draggability = draggability

keyboardDrag = ({ event, key }) => {
console.log(event, key, this._draggability)
if (
!this._keyboardDrag ||
!this._dragKeysFlat.includes(key) ||
!this.DS.SelectedSet.size ||
!this._draggability
!this._draggability ||
this.DS.continue
)
return
this._isKeyboard = true
this.DS.publish('Interaction:start', { event, isDragging: true })
this.DS.publish('Interaction:start', {
event,
isDragging: true,
isDraggingKeyboard: true,
})

@@ -138,4 +150,7 @@ this._elements = this.DS.getSelection()

this.DS.publish('Interaction:update', { event, isDragging: true })
this._isKeyboard = false
this.DS.publish('Interaction:update', {
event,
isDragging: true,
isDraggingKeyboard: true,
})
}

@@ -145,2 +160,3 @@

if (
!this._keyboardDrag ||
!this._dragKeysFlat.includes(key) ||

@@ -151,9 +167,11 @@ !this.DS.SelectedSet.size ||

return
this._isKeyboard = true
this.DS.publish('Interaction:end', { event, isDragging: true })
this._isKeyboard = false
this.DS.publish('Interaction:end', {
event,
isDragging: this._draggability,
isDraggingKeyboard: true,
})
}
start = ({ isDragging }) => {
if (!isDragging || this._isKeyboard) return
start = ({ isDragging, isDraggingKeyboard }) => {
if (!isDragging || isDraggingKeyboard) return
this._prevCursorPos = null

@@ -165,4 +183,4 @@ this._prevScrollPos = null

stop = () => {
if (this._isKeyboard) return
stop = (evt) => {
if (evt?.isKeyboard) return
this._prevCursorPos = null

@@ -174,4 +192,10 @@ this._prevScrollPos = null

update = ({ isDragging }) => {
if (!isDragging || !this._elements.length || this._isKeyboard) return
update = ({ isDragging, isDraggingKeyboard }) => {
if (
!isDragging ||
!this._elements.length ||
isDraggingKeyboard ||
this.DS.continue
)
return

@@ -178,0 +202,0 @@ const posDirection = vect2.calc(this._cursorDiff, '+', this._scrollDiff)

@@ -149,7 +149,8 @@ // @ts-check

update = ({ event, data }) => {
update = ({ event, scroll_directions, scroll_multiplier }) => {
if (this.isInteracting)
this.DS.publish('Interaction:update', {
event,
data,
scroll_directions,
scroll_multiplier,
isDragging: this.isDragging,

@@ -156,0 +157,0 @@ })

@@ -43,8 +43,9 @@ // @ts-check

* @param {DSCallbackNames} eventName
* @param {CallbackObject|*} data passed to the subscription method
* @param {CallbackObject} data passed to the subscription method
*/
publish = (eventName, data) => {
if (!Array.isArray(this.subscribers[eventName])) return
this.subscribers[eventName].forEach((callback) => callback(data))
this.subscribers[`${eventName}:pre`]?.forEach((callback) => callback(data))
this.subscribers[eventName]?.forEach((callback) => callback(data))
}
}

@@ -62,3 +62,3 @@ // @ts-check

update = ({ isDragging }) => {
if (isDragging) return
if (isDragging || this.DS.continue) return
this._handleInsideSelection()

@@ -65,0 +65,0 @@ }

@@ -58,3 +58,3 @@ // @ts-check

update = ({ isDragging }) => {
if (isDragging) return
if (isDragging || this.DS.continue) return
const {

@@ -61,0 +61,0 @@ stores: { ScrollStore, PointerStore },

@@ -78,2 +78,4 @@ // @ts-check

stop = () => this.stopAutoScroll()
//////////////////////////////////////////////////////////////////////////////////////

@@ -89,2 +91,3 @@ // AutoScroll

handleAutoScroll = () => {
if (this.DS.continue) return
const {

@@ -91,0 +94,0 @@ stores: { PointerStore },

@@ -16,2 +16,3 @@ /**

* @property {boolean} [immediateDrag=true] Whether an element is draggable from the start or needs to be selected first
* @property {boolean} [keyboardDrag=true] Whether or not the user can drag with the keyboard (we don't recommend disabling it)
* @property {DSDragKeys} [dragKeys={up:['ArrowUp'],down:['ArrowDown'],left:['ArrowLeft'],righ:['ArrowRight']}] The keys available to drag element using the keyboard.

@@ -37,5 +38,7 @@ * @property {number} [keyboardDragSpeed=10] The speed at which elements are dragged using the keyboard. In pixels per keydown.

* @property {Array<HTMLElement|SVGElement|any>} [items] The items currently selected
* @property {MouseEvent|TouchEvent|Event} [event] The respective event object
* @property {MouseEvent|TouchEvent|KeyboardEvent|Event} [event] The respective event object
* @property {HTMLElement|SVGElement|any} [item] The single item currently interacted with
* @property {boolean} [isDragging] Whether the interaction is a drag or a select
* @property {boolean} [isDraggingKeyboard] Whether or not the drag interaction is via keyboard
* @property {string} [key] Pressed key (lowercase)
* @property {Array.<'top'|'bottom'|'left'|'right'|undefined>} [scroll_directions]

@@ -63,2 +66,3 @@ * @property {number} [scroll_multiplier]

/** @typedef {'Interaction:init'|'Interaction:start'|'Interaction:end'|'Interaction:update'|'Area:modified'|'Area:scroll'|'PointerStore:updated'|'Selected:added'|'Selected:removed'|'Selectable:click'|'Selectable:pointer'|'KeyStore:down'|'KeyStore:up'} DSInternalEventNames */
/** @typedef {'Interaction:init:pre'|'Interaction:start:pre'|'Interaction:end:pre'|'Interaction:update:pre'|'Area:modified:pre'|'Area:scroll:pre'|'PointerStore:updated:pre'|'Selected:added:pre'|'Selected:removed:pre'|'Selectable:click:pre'|'Selectable:pointer:pre'|'KeyStore:down:pre'|'KeyStore:up:pre'|'Drag:keyboardDrag:pre'} DSInternalEventNamesPre */
/** @typedef {DSEventNames|DSInternalEventNames} DSCallbackNames the name of the callback */

@@ -65,0 +69,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc