dragselect
Advanced tools
Comparing version 2.4.2 to 2.4.3
@@ -0,4 +1,8 @@ | ||
# 2.4.3 | ||
- add `triggerCallback` option to `removeSelectables` and `addSelectables` | ||
# 2.4.2 | ||
- Add Selecrables events/topics for add/delete | ||
- Add Selecrables events/topics for add/delete: `Selectable:added` & `Selectable:added:pre` & `Selectable:removed` & `Selectable:removed:pre` | ||
@@ -5,0 +9,0 @@ # 2.4.0-1 |
@@ -104,5 +104,6 @@ export default DragSelect; | ||
* @param {boolean} [addToSelection] if elements should also be added to current selection | ||
* @param {boolean} [triggerCallback] - if callback should be called | ||
* @return {DSInputElements} the added element(s) | ||
*/ | ||
addSelectables(elements: DSInputElements, addToSelection?: boolean): DSInputElements; | ||
addSelectables(elements: DSInputElements, addToSelection?: boolean, triggerCallback?: boolean): DSInputElements; | ||
/** | ||
@@ -127,5 +128,6 @@ * Gets all nodes that can potentially be selected | ||
* @param {boolean} [removeFromSelection] if elements should also be removed from current selection | ||
* @param {boolean} [triggerCallback] - if callback should be called | ||
* @return {DSInputElements} the removed element(s) | ||
*/ | ||
removeSelectables(elements: DSInputElements, removeFromSelection?: boolean): DSInputElements; | ||
removeSelectables(elements: DSInputElements, removeFromSelection?: boolean, triggerCallback?: boolean): DSInputElements; | ||
/** The starting/initial position of the cursor/selector @return {Vect2} */ | ||
@@ -132,0 +134,0 @@ getInitialCursorPosition: () => Vect2; |
@@ -1,1 +0,1 @@ | ||
function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}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(t){return!1}}function u(t,e,r){return u=l()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&c(i,r.prototype),i},u.apply(null,arguments)}function d(t){var e="function"==typeof Map?new Map:void 0;return d=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return u(t,arguments,a(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)},d(t)}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function S(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?h(t):e}function f(t){var e=l();return function(){var r,n=a(t);if(e){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return S(this,r)}}function p(t,e,r){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=a(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},p(t,e,r||t)}function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,i=!1,s=void 0;try{for(var o,a=t[Symbol.iterator]();!(n=(o=a.next()).done)&&(r.push(o.value),!e||r.length!==e);n=!0);}catch(t){i=!0,s=t}finally{try{n||null==a.return||a.return()}finally{if(i)throw s}}return r}(t,e)||b(t,e)||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 v(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||b(t)||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 b(t,e){if(t){if("string"==typeof t)return y(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var m=function(t,e,r){var n=t.x,i=t.y,s=r.x,o=r.y;return{"+":{x:n+s,y:i+o},"-":{x:n-s,y:i-o},"*":{x:n*s,y:i*o},"/":{x:n/s,y:i/o}}[e]},D=function(t){return{x:t.left,y:t.top}},_=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:t.x,top:t.y,right:t.x,bottom:t.y,width:e,height:e}},w=function(){var t,e,r,n;return{y:(null===(t=document.body)||void 0===t?void 0:t.scrollTop)||(null===(e=document.documentElement)||void 0===e?void 0:e.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}},A=function(t){return!t||t instanceof Document?w():{x:t.scrollLeft>=0?t.scrollLeft:w().x,y:t.scrollTop>=0?t.scrollTop:w().y}},P=function(t){var e=t.elementRect,r=t.containerRect,n=t.tolerance,i=void 0===n?{x:0,y:0}:n,s=[];return e.top-i.y<r.top&&s.push("top"),e.left-i.x<r.left&&s.push("left"),e.bottom+i.y>r.bottom&&s.push("bottom"),e.right+i.y>r.right&&s.push("right"),s},L=function(t){var e={x:0,y:0},r=window.getComputedStyle(t);if(!r.transform||"none"===r.transform)return e;if(r.transform.indexOf("3d")>=0){var n=r.transform.trim().match(/matrix3d\((.*?)\)/);if(n&&n.length){var i,s=null===(i=n[1])||void 0===i?void 0:i.split(",");e.x=parseInt(s[12])||0,e.y=parseInt(s[13])||0}return e}var o=r.transform.trim().match(/matrix\((.*?)\)/);if(o&&o.length){var a,c=null===(a=o[1])||void 0===a?void 0:a.split(",");e.x=parseInt(c[4])||0,e.y=parseInt(c[5])||0}return e},x=function(t,e){return e?function(t){var e=t.style.transform;if(!e||e.indexOf("translate")<0)return L(t);var r={x:0,y:0},n=e.trim().match(/translate[3dD]*?\(.*?\)/);if(n){var i,s=null===(i=n[0])||void 0===i?void 0:i.split("(");if(s){var o,a=null===(o=s[1])||void 0===o?void 0:o.split(",");r.x=parseInt(a[0])||0,r.y=parseInt(a[1])||0}}return r.x||r.x?r:L(t)}(t):function(t){var e=t.style,r={x:parseInt(e.left)||0,y:parseInt(e.top)||0};if(!r.x&&!r.x){var n=window.getComputedStyle(t);return{x:parseInt(n.left)||0,y:parseInt(n.top)||0}}return r}(t)},k=function(t){var e=t.computedStyle,r=t.node,n=e.position;r instanceof HTMLDocument||("absolute"===n||"relative"===n||"fixed"===n)||(r.style.position="relative")},I=function(t,e,r){return console.warn('[DragSelect] TypeIssue: setting "'.concat(t,'" is not of type "').concat(e,'".'))},T=function(t,e,r,i){if(void 0===e)return r?n({},t,i):{};if(null===e)return n({},t,null);var s=!0,o=!1,a="string"==typeof i;a&&(s="string"==typeof e||e instanceof String),a&&!s&&(o=!0,I(t,"string"));var c=!isNaN(i)&&"number"==typeof i;c&&(s=!isNaN(e)&&"number"==typeof e),c&&!s&&(o=!0,I(t,"number"));var l="[object Object]"===Object.prototype.toString.call(i);l&&(s="[object Object]"===Object.prototype.toString.call(e)),l&&!s&&(o=!0,I(t,"object"));var u="boolean"==typeof i;u&&(s="boolean"==typeof e),u&&!s&&(o=!0,I(t,"boolean"));var d=Array.isArray(i);d&&(s=Array.isArray(e)),d&&!s&&(o=!0,I(t,"array"));var h=o||r;return"dragKeys"===t&&s?n({},t,Object.assign(i,e)):("dragKeys"!==t||s)&&s?n({},t,e):h?n({},t,i):{}},C=function(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top},E=function(t){var e=t.element,r=t.posDirection,n=t.containerRect,i=t.useTransform,s=x(e,i),o=m(s,"+",r);V(e,o,i);var a=e.getBoundingClientRect();!function(t){var e=t.element,r=t.edges,n=t.elementRect,i=t.containerRect,s=t.elementPos,o=t.useTransform;r.includes("top")&&V(e,{y:s.y+i.top-n.top,x:s.x},o),r.includes("left")&&V(e,{y:s.y,x:s.x+i.left-n.left},o),r.includes("bottom")&&V(e,{y:s.y+i.bottom-n.bottom,x:s.x},o),r.includes("right")&&V(e,{y:s.y,x:s.x+i.right-n.right},o)}({element:e,edges:P({elementRect:a,containerRect:n}),elementRect:a,containerRect:n,elementPos:o,useTransform:i})},V=function(t,e,r){if(r){var n=t.style.transform;t.style.transform="translate3d(".concat(e.x,"px,").concat(e.y,"px,1px) ").concat(n.replace(/translate.*?\)/g,""))}else t.style.left="".concat(e.x,"px"),t.style.top="".concat(e.y,"px");return t},M=function(t){return t?!Array.isArray(t)&&(t instanceof HTMLElement||t instanceof SVGElement)?[t]:v(t):[]},N=function(t,e){t.style.left="".concat(e.left,"px"),t.style.top="".concat(e.top,"px"),t.style.width="".concat(e.width,"px"),t.style.height="".concat(e.height,"px")},K=function(){function e(r){var i,s,o,a=this,c=r.DS;t(this,e),n(this,"DS",void 0),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,"setArea",(function(t){a._node=t,k({computedStyle:a.computedStyle,node:a._node}),setTimeout((function(){a.DS.PubSub.publish("Area:modified:pre",{item:a}),a.reset(),a.DS.PubSub.publish("Area:modified",{item:a})}))})),n(this,"start",(function(){var t,e,r;t=a.parentNodes,e=a._modificationCallback,r=a._modificationObserver,window.addEventListener("resize",e),window.addEventListener("scroll",e),t.forEach((function(t,e){r.observe(t,{childList:0!==e,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 t,e;t=a._modificationObserver,e=a._modificationCallback,window.removeEventListener("resize",e),window.removeEventListener("scroll",e),t.disconnect(),a.reset()})),n(this,"scroll",(function(t,e){var r={scroll_directions:t,scroll_multiplier:e};a.DS.PubSub.publish("Area:scroll:pre",r),function(t,e,r){if(e.length){var n=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,i=t instanceof HTMLDocument?n||document.body:t,s=e.includes("top")&&i.scrollTop>0,o=e.includes("bottom")&&i.scrollTop<i.scrollHeight,a=e.includes("left")&&i.scrollLeft>0,c=e.includes("right")&&i.scrollLeft<i.scrollWidth;s&&(i.scrollTop-=1*r),o&&(i.scrollTop+=1*r),a&&(i.scrollLeft-=1*r),c&&(i.scrollLeft+=1*r)}}(a._node,t,e),a.DS.PubSub.publish("Area:scroll",r)})),this.DS=c,this.setArea(this.DS.stores.SettingsStore.s.area),this.DS.PubSub.subscribe("Settings:updated:area",(function(t){var e=t.settings;return a.setArea(e.area)})),this._modificationCallback=(i=function(t){a.DS.PubSub.publish("Area:modified:pre",{event:t,item:a}),a.reset(),a.DS.PubSub.publish("Area:modified",{event:t,item:a})},s=60,function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=function(){o=null,i.apply(void 0,e)};clearTimeout(o),o=setTimeout(n,s)}),this._modificationObserver=new MutationObserver(this._modificationCallback),this.DS.PubSub.subscribe("Interaction:init",this.start),this.DS.PubSub.subscribe("Interaction:end",this.reset)}return r(e,[{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(t,e){if(t instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var r=t.getBoundingClientRect();return{top:r.top,left:r.left,bottom:r.bottom,right:r.right,width:(t.clientWidth||r.width)*e,height:(t.clientHeight||r.height)*e}}(this.HTMLNode,this.DS.stores.SettingsStore.s.zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=null===(r=e[n])||void 0===r?void 0:r.parentNode;return i?(e.push(i),t(e,++n)):e}([this.HTMLNode]),this._parentNodes}}]),e}(),O=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_prevCursorPos",void 0),n(this,"_prevScrollPos",void 0),n(this,"_elements",[]),n(this,"_dragKeys",void 0),n(this,"_dragKeysFlat",[]),n(this,"assignDragkeys",(function(){i._dragKeys={up:i.DS.stores.SettingsStore.s.dragKeys.up.map((function(t){return t.toLowerCase()})),down:i.DS.stores.SettingsStore.s.dragKeys.down.map((function(t){return t.toLowerCase()})),left:i.DS.stores.SettingsStore.s.dragKeys.left.map((function(t){return t.toLowerCase()})),right:i.DS.stores.SettingsStore.s.dragKeys.right.map((function(t){return t.toLowerCase()}))},i._dragKeysFlat=[].concat(v(i._dragKeys.up),v(i._dragKeys.down),v(i._dragKeys.left),v(i._dragKeys.right))})),n(this,"keyboardDrag",(function(t){var e=t.event,r=t.key.toLowerCase();if(i.DS.stores.SettingsStore.s.keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i.DS.stores.SettingsStore.s.draggability&&!i.DS.continue){var n={event:e,isDragging:!0,isDraggingKeyboard:!0};i.DS.publish(["Interaction:start:pre","Interaction:start"],n),i._elements=i.DS.getSelection(),i.handleZIndex(!0);var s=function(t){var e=t.shiftKey,r=t.keyboardDragSpeed,n=t.zoom,i=t.key,s=t.dragKeys,o=t.scrollDiff,a=t.canScroll,c=t.scrollCallback,l={x:0,y:0},u=e?4*r*n:r*n;return s.left.includes(i)&&(l.x=o.x||-u,e||o.x||!a||c(["left"],r)),s.right.includes(i)&&(l.x=o.x||u,e||o.x||!a||c(["right"],r)),s.up.includes(i)&&(l.y=o.y||-u,e||o.y||!a||c(["top"],r)),s.down.includes(i)&&(l.y=o.y||u,e||o.y||!a||c(["bottom"],r)),l}({shiftKey:i.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:i.DS.stores.SettingsStore.s.keyboardDragSpeed,zoom:i.DS.stores.SettingsStore.s.zoom,key:r,scrollCallback:i.DS.Area.scroll,scrollDiff:i._scrollDiff,canScroll:i.DS.stores.ScrollStore.canScroll,dragKeys:i._dragKeys});i._elements.forEach((function(t){return E({element:t,posDirection:s,containerRect:i.DS.SelectorArea.rect,useTransform:i.DS.stores.SettingsStore.s.useTransform})})),i.DS.publish(["Interaction:update:pre","Interaction:update"],n)}})),n(this,"keyboardEnd",(function(t){var e=t.event,r=t.key.toLowerCase();if(i.DS.stores.SettingsStore.s.keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i.DS.stores.SettingsStore.s.draggability){var n={event:e,isDragging:i.DS.stores.SettingsStore.s.draggability,isDraggingKeyboard:!0};i.DS.publish(["Interaction:end:pre","Interaction:end"],n)}})),n(this,"start",(function(t){var e=t.isDragging,r=t.isDraggingKeyboard;e&&!r&&(i._prevCursorPos=null,i._prevScrollPos=null,i._elements=i.DS.getSelection(),i.handleZIndex(!0))})),n(this,"stop",(function(t){null!=t&&t.isKeyboard||(i._prevCursorPos=null,i._prevScrollPos=null,i.handleZIndex(!1),i._elements=[])})),n(this,"update",(function(t){var e=t.isDragging,r=t.isDraggingKeyboard;if(e&&i._elements.length&&!r&&!i.DS.continue){var n=m(i._cursorDiff,"+",i._scrollDiff);i._elements.forEach((function(t){return E({element:t,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i.DS.stores.SettingsStore.s.useTransform})}))}})),n(this,"handleZIndex",(function(t){i._elements.forEach((function(e){return e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+t?9999:-9998)}))})),this.DS=s,this.DS.subscribe("Settings:updated:dragKeys",this.assignDragkeys),this.assignDragkeys(),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(e,[{key:"_cursorDiff",get:function(){var t=this.DS.stores.PointerStore.currentVal,e=this._prevCursorPos?m(t,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=t,e}},{key:"_scrollDiff",get:function(){var t=this.DS.stores.ScrollStore.currentVal,e=this._prevScrollPos?m(t,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=t,e}}]),e}(),H=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"isInteracting",void 0),n(this,"isDragging",void 0),n(this,"init",(function(){return i.DS.publish("Interaction:init:pre",{})})),n(this,"_init",(function(){i.stop(),i.DS.Area.HTMLNode.addEventListener("mousedown",i.start),i.DS.Area.HTMLNode.addEventListener("touchstart",i.start,{passive:!1}),i.DS.publish("Interaction:init",{})})),n(this,"start",(function(t){return i.DS.publish("Interaction:start:pre",{event:t,isDragging:i.isDragging})})),n(this,"_start",(function(t){"touchstart"===t.type&&t.preventDefault(),i._canInteract(t)&&(i.isInteracting=!0,i.isDragging=i.isDragEvent(t),i.DS.publish("Interaction:start",{event:t,isDragging:i.isDragging}),document.addEventListener("mouseup",i.reset),document.addEventListener("touchend",i.reset))})),n(this,"isDragEvent",(function(t){var e=t.target.closest(".".concat(i.DS.stores.SettingsStore.s.selectableClass));return!(!i.DS.stores.SettingsStore.s.draggability||i.DS.stores.KeyStore.isMultiSelectKeyPressed(t)||!e)&&(i.DS.stores.SettingsStore.s.immediateDrag&&(i.DS.SelectedSet.size?i.DS.SelectedSet.has(e)||(i.DS.SelectedSet.clear(),i.DS.SelectedSet.add(e)):i.DS.SelectedSet.add(e)),!!i.DS.SelectedSet.has(e))})),n(this,"onClick",(function(t){var e=t.event;if(i._canInteract(e)&&!(e.detail>0)){var r=i.DS,n=r.stores,s=n.PointerStore,o=n.KeyStore,a=r.SelectableSet,c=r.SelectedSet;s.start(e);var l=e.target;a.has(l)&&(o.isMultiSelectKeyPressed(e)||c.clear(),c.toggle(l),i.reset())}})),n(this,"stop",(function(){i.isInteracting=!1,i.isDragging=!1,i.DS.Area.HTMLNode.removeEventListener("mousedown",i.start),i.DS.Area.HTMLNode.removeEventListener("touchstart",i.start,{passive:!1}),document.removeEventListener("mouseup",i.reset),document.removeEventListener("touchend",i.reset)})),n(this,"update",(function(t){var e=t.event,r=t.scroll_directions,n=t.scroll_multiplier;i.isInteracting&&i.DS.publish(["Interaction:update:pre","Interaction:update"],{event:e,scroll_directions:r,scroll_multiplier:n,isDragging:i.isDragging})})),n(this,"reset",(function(t){return i.DS.publish("Interaction:end:pre",{event:t,isDragging:i.isDragging})})),n(this,"_reset",(function(t){var e=i.isDragging;i.stop(),i.init(),i.DS.publish("Interaction:end",{event:t,isDragging:e})})),this.DS=s,this.DS.subscribe("Settings:updated:area",this.init),this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(t){var e=t.event;return i.start(e)})),this.DS.subscribe("Interaction:start:pre",(function(t){var e=t.event;return i._start(e)})),this.DS.subscribe("Interaction:init:pre",this._init),this.DS.subscribe("Interaction:end:pre",(function(t){var e=t.event;return i._reset(e)})),this.DS.subscribe("Area:scroll",this.update)}return r(e,[{key:"_canInteract",value:function(t){var e=0===t.clientX&&0===t.clientY&&0===t.detail&&t.target;return!(2===t.button||this.isInteracting||t.target&&!this.DS.SelectorArea.isInside(t.target)||!e&&!this.DS.SelectorArea.isClicked(t))}}]),e}(),j=function e(r){var i=this,s=r.DS;t(this,e),n(this,"subscribers",{}),n(this,"subscribe",(function(t,e){return Array.isArray(i.subscribers[t])||(i.subscribers[t]=[]),i.subscribers[t].push(e),i.subscribers[t].length-1})),n(this,"unsubscribe",(function(t,e,r){r>=0?i.subscribers[t].splice(r,1):e&&(i.subscribers[t]=i.subscribers[t].filter((function(t){return t!==e})))})),n(this,"publish",(function(t,e){Array.isArray(t)?t.forEach((function(t){return i._publish(t,e)})):i._publish(t,e)})),n(this,"_publish",(function(t,e){var r=i.subscribers[t];Array.isArray(r)&&(t.includes(":pre")?i._handlePrePublish(r,e):i._handlePublish(r,e))})),n(this,"_handlePublish",(function(t,e){for(var r=0,n=t.length;r<n;r++){if(i.DS.stopped)return;t[r](e)}})),n(this,"_handlePrePublish",(function(t,e){for(var r=t.length;r--;){if(i.DS.stopped)return;t[r](e)}})),this.DS=s},R=function(e){o(s,d(Set));var i=f(s);function s(e){var r,o=e.DS;return t(this,s),n(h(r=i.call(this)),"init",(function(){return M(r.DS.stores.SettingsStore.s.selectables).forEach((function(t){return r.add(t)}))})),n(h(r),"clear",(function(){return r.forEach((function(t){return r.delete(t)}))})),n(h(r),"_onClick",(function(t){return r.DS.publish(["Selectable:click:pre","Selectable:click"],{event:t})})),n(h(r),"_onPointer",(function(t){return r.DS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:t})})),n(h(r),"addAll",(function(t){return t.forEach((function(t){return r.add(t)}))})),n(h(r),"deleteAll",(function(t){return t.forEach((function(t){return r.delete(t)}))})),r.DS=o,r.DS.subscribe("Interaction:init",r.init),r.DS.PubSub.subscribe("Settings:updated:selectables",(function(){r.clear(),r.init()})),r.DS.subscribe("Settings:updated:selectableClass",(function(t){var e=t.settings;r.forEach((function(t){t.classList.remove(e["selectableClass:pre"]),t.classList.add(e.selectableClass)}))})),r}return r(s,[{key:"add",value:function(t){if(!p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selectable:added:pre",e),t.classList.add(this.DS.stores.SettingsStore.s.selectableClass),t.addEventListener("click",this._onClick),t.addEventListener("mousedown",this._onPointer),t.addEventListener("touchstart",this._onPointer,{passive:!1}),this.DS.stores.SettingsStore.s.draggability&&!this.DS.stores.SettingsStore.s.useTransform&&k({computedStyle:window.getComputedStyle(t),node:t}),this.DS.publish("Selectable:added",e),p(a(s.prototype),"add",this).call(this,t)}}},{key:"delete",value:function(t){if(p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selectable:removed:pre",e),t.classList.remove(this.DS.stores.SettingsStore.s.selectableClass),t.classList.remove(this.DS.stores.SettingsStore.s.hoverClass),t.removeEventListener("click",this._onClick),t.removeEventListener("mousedown",this._onPointer),t.removeEventListener("touchstart",this._onPointer,{passive:!1}),this.DS.publish("Selectable:removed",e),p(a(s.prototype),"delete",this).call(this,t)}}},{key:"elements",get:function(){return Array.from(this.values())}}]),s}(),z=function(e){o(s,d(Set));var i=f(s);function s(e){var r,o=e.DS;return t(this,s),n(h(r=i.call(this)),"clear",(function(){return r.forEach((function(t){return r.delete(t)}))})),n(h(r),"addAll",(function(t){return t.forEach((function(t){return r.add(t)}))})),n(h(r),"deleteAll",(function(t){return t.forEach((function(t){return r.delete(t)}))})),r.DS=o,r}return r(s,[{key:"add",value:function(t){if(!p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selected:added:pre",e),p(a(s.prototype),"add",this).call(this,t),t.classList.add(this.DS.stores.SettingsStore.s.selectedClass),t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+1),this.DS.publish("Selected:added",e),this}}},{key:"delete",value:function(t){if(p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};this.DS.publish("Selected:removed:pre",e);var r=p(a(s.prototype),"delete",this).call(this,t);return t.classList.remove(this.DS.stores.SettingsStore.s.selectedClass),t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)-1),this.DS.publish("Selected:removed",e),r}}},{key:"toggle",value:function(t){return this.has(t)?this.delete(t):this.add(t),t}},{key:"elements",get:function(){return Array.from(this.values())}}]),s}(),B=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_prevSelectedSet",void 0),n(this,"start",(function(t){var e=t.event;t.isDragging||(i._storePrevious(e),i._handleInsideSelection(!0,e))})),n(this,"update",(function(t){t.isDragging||i.DS.continue||i._handleInsideSelection()})),n(this,"_handleInsideSelection",(function(t,e){for(var r=i.DS,n=r.SelectableSet,s=r.SelectorArea,o=r.Selector,a=n.elements.map((function(t){return[t,t.getBoundingClientRect()]})),c=[],l=[],u=0,d=a.length;u<d;u++)s.isInside(a[u][0],a[u][1])&&(C(a[u][1],o.rect)?c.push(a[u][0]):l.push(a[u][0]));var h=i.DS.stores.KeyStore.isMultiSelectKeyPressed(e)&&i.DS.stores.SettingsStore.s.multiSelectToggling;i.DS.continue||(c.forEach((function(e){return function(t){var e=t.element,r=t.force,n=t.multiSelectionToggle,i=t.SelectedSet,s=t.hoverClassName;e.classList.contains(s)&&!r||(i.has(e)?n&&i.delete(e):i.add(e),e.classList.add(s))}({element:e,force:t,multiSelectionToggle:h,SelectedSet:i.DS.SelectedSet,hoverClassName:i.DS.stores.SettingsStore.s.hoverClass})})),l.forEach((function(e){return function(t){var e=t.element,r=t.force,n=t.SelectedSet,i=t.PrevSelectedSet,s=t.hoverClassName;if(!e.classList.contains(s)&&!r)return!1;var o=n.has(e),a=i.has(e);o&&!a?n.delete(e):!o&&a&&n.add(e),e.classList.remove(s)}({element:e,force:t,SelectedSet:i.DS.SelectedSet,hoverClassName:i.DS.stores.SettingsStore.s.hoverClass,PrevSelectedSet:i._prevSelectedSet})})))})),this.DS=s,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return r(e,[{key:"_storePrevious",value:function(t){var e=this.DS,r=e.stores.KeyStore,n=e.SelectedSet;r.isMultiSelectKeyPressed(t)?this._prevSelectedSet=new Set(n):this._prevSelectedSet=new Set}}]),e}(),W=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_rect",void 0),n(this,"attachSelector",(function(){var t,e,r,n;i.HTMLNode&&null!==(t=i.DS.SelectorArea)&&void 0!==t&&t.HTMLNode&&i.DS.SelectorArea.HTMLNode.removeChild(i.HTMLNode),i.HTMLNode=i.DS.stores.SettingsStore.s.selector||(r=i.DS.stores.SettingsStore.s.customStyles,(n=document.createElement("div")).style.position="absolute",r||(n.style.background="rgba(0, 0, 255, 0.1)",n.style.border="1px solid rgba(0, 0, 255, 0.45)",n.style.display="none",n.style.pointerEvents="none"),n),i.HTMLNode.classList.add(i.DS.stores.SettingsStore.s.selectorClass),i.HTMLNode&&null!==(e=i.DS.SelectorArea)&&void 0!==e&&e.HTMLNode&&i.DS.SelectorArea.HTMLNode.appendChild(i.HTMLNode)})),n(this,"start",(function(t){if(!t.isDragging){var e=i.DS.stores.PointerStore.initialValArea;N(i.HTMLNode,_(e,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(t){if(!t.isDragging&&!i.DS.continue){var e=i.DS.stores,r=e.ScrollStore,n=e.PointerStore,s=function(t){var e=t.scrollAmount,r=t.initialPointerPos,n=t.pointerPos,i={};return n.x>r.x-e.x?(i.left=r.x-e.x,i.width=n.x-r.x+e.x):(i.left=n.x,i.width=r.x-n.x-e.x),n.y>r.y-e.y?(i.top=r.y-e.y,i.height=n.y-r.y+e.y):(i.top=n.y,i.height=r.y-n.y-e.y),i}({scrollAmount:r.scrollAmount,initialPointerPos:n.initialValArea,pointerPos:n.currentValArea});N(i.HTMLNode,s),i._rect=null}})),this.DS=s,this.DS.subscribe("Settings:updated:selectorClass",(function(t){var e=t.settings;i.HTMLNode.classList.remove(e["selectorClass:pre"]),i.HTMLNode.classList.add(e.selectorClass)})),this.DS.subscribe("Settings:updated:selector",this.attachSelector),this.attachSelector(),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return r(e,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),e}(),F=function(){function e(r){var i,s=this,o=r.DS;t(this,e),n(this,"_scrollInterval",void 0),n(this,"_rect",void 0),n(this,"currentEdges",[]),n(this,"start",(function(){return s.applyElements("append")})),n(this,"applyElements",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",e=document.body?"body":"documentElement",r="".concat(t,"Child");s.HTMLNode[r](s.DS.Selector.HTMLNode),document[e][r](s.HTMLNode)})),n(this,"updatePos",(function(){s._rect=null;var t=s.DS.Area.rect,e=s.DS.Area.computedBorder,r=s.HTMLNode.style,n="".concat(t.top+e.top,"px"),i="".concat(t.left+e.left,"px"),o="".concat(t.width,"px"),a="".concat(t.height,"px");r.top!==n&&(r.top=n),r.left!==i&&(r.left=i),r.width!==o&&(r.width=o),r.height!==a&&(r.height=a)})),n(this,"stop",(function(t){s.stopAutoScroll(),t&&s.applyElements("remove")})),n(this,"startAutoScroll",(function(){s.currentEdges=[],s._scrollInterval=setInterval((function(){return s.handleAutoScroll()}),16)})),n(this,"handleAutoScroll",(function(){if(!s.DS.continue){var t=s.DS,e=t.stores.PointerStore,r=t.Area;s.currentEdges=P({elementRect:_(e.currentVal),containerRect:s.rect,tolerance:s.DS.stores.SettingsStore.s.overflowTolerance}),s.currentEdges.length&&r.scroll(s.currentEdges,s.DS.stores.SettingsStore.s.autoScrollSpeed)}})),n(this,"stopAutoScroll",(function(){s.currentEdges=[],clearInterval(s._scrollInterval)})),n(this,"isInside",(function(t,e){return!(!s.DS.Area.HTMLNode.contains(t)||!s.DS.stores.ScrollStore.canScroll)||C(s.rect,e||t.getBoundingClientRect())})),this.DS=o,this.HTMLNode=((i=document.createElement("div")).style.position="fixed",i.style.overflow="hidden",i.style.pointerEvents="none",i.style.zIndex="999999999999999999",i),this.DS.subscribe("Settings:updated:selectorAreaClass",(function(t){var e=t.settings;s.HTMLNode.classList.remove(e["selectorAreaClass:pre"]),s.HTMLNode.classList.add(e.selectorAreaClass)})),this.HTMLNode.classList.add(this.DS.stores.SettingsStore.s.selectorAreaClass),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:init",this.start),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){s.updatePos(),s.stopAutoScroll()}))}return r(e,[{key:"isClicked",value:function(t){var e=this.DS.stores.PointerStore,r=t?e.getPointerPosition(t):e.initialVal;return C({left:r.x,top:r.y,right:r.x,bottom:r.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),e}(),Z=function(){function e(r){var i=this,s=r.DS;t(this,e),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(t){var e=t.key.toLowerCase();i.DS.publish("KeyStore:down:pre",{event:t,key:e}),i._currentValues.add(e),i.DS.publish("KeyStore:down",{event:t,key:e})})),n(this,"keyup",(function(t){var e=t.key.toLowerCase();i.DS.publish("KeyStore:up:pre",{event:t,key:e}),i._currentValues.delete(e),i.DS.publish("KeyStore:up",{event:t,key:e})})),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=s,this.DS.subscribe("Interaction:init",this.init)}return r(e,[{key:"isMultiSelectKeyPressed",value:function(t){var e=this;if(this.DS.stores.SettingsStore.s.multiSelectMode)return!0;var r=this.DS.stores.SettingsStore.s.multiSelectKeys.map((function(t){return t.toLocaleLowerCase()}));return!!this.currentValues.some((function(t){return r.includes(t.toLocaleLowerCase())}))||!(!t||!r.some((function(r){return t[e._keyMapping[r]]})))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),e}(),U=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_isMouseInteraction",!1),n(this,"_initialValArea",void 0),n(this,"_currentValArea",void 0),n(this,"_lastValArea",void 0),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_lastVal",void 0),n(this,"_lastTouch",void 0),n(this,"init",(function(){document.addEventListener("mousemove",i.update),document.addEventListener("touchmove",i.update,{passive:!1})})),n(this,"getPointerPosition",(function(t){return function(t){var e=t.event;return{x:e.clientX,y:e.clientY}}({event:i._normalizedEvent(t)})})),n(this,"update",(function(t){t&&(i.DS.publish("PointerStore:updated:pre",{event:t}),i.currentVal=i.getPointerPosition(t),i._isMouseInteraction&&i.DS.publish("PointerStore:updated",{event:t}))})),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(t){t&&(i.currentVal=i.lastVal=i.getPointerPosition(t),i.stop(),i.init())})),this.DS=s,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(t){var e=t.event;return i.start(e)})),this.DS.subscribe("Interaction:end",(function(t){var e=t.event;return i.reset(e)}))}return r(e,[{key:"start",value:function(t){t&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(t))}},{key:"_normalizedEvent",value:function(t){return"touches"in t&&"touchend"!==t.type&&(this._lastTouch=t),"touches"in t?this._lastTouch.touches[0]:t}},{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(t){this._initialVal=t,this._initialValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(t){this._currentVal=t,this._currentValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(t){this._lastVal=t,this._lastValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}}]),e}(),X=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_canScroll",void 0),n(this,"init",(function(){return i.DS.stores.SettingsStore.s.area.addEventListener("scroll",i.update)})),n(this,"start",(function(){i._currentVal=i._initialVal=A(i.DS.stores.SettingsStore.s.area),i.DS.stores.SettingsStore.s.area.addEventListener("scroll",i.update)})),n(this,"update",(function(){return i._currentVal=A(i.DS.stores.SettingsStore.s.area)})),n(this,"stop",(function(){i.DS.stores.SettingsStore.s.area.removeEventListener("scroll",i.update),i._initialVal={x:0,y:0},i._canScroll=null})),n(this,"reset",(function(){i.stop(),i.start()})),this.DS=s,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(e,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(t=this.DS.stores.SettingsStore.s.area,!!((e=A(t)).x||e.y||(t instanceof HTMLDocument?t.body?t.body.scrollTop=1:t.documentElement.scrollTop=1:t.scrollTop=1)));var t,e}},{key:"scrollAmount",get:function(){var t,e=m(this.currentVal,"-",this.initialVal),r={x:t=this.DS.stores.SettingsStore.s.zoom,y:t},n=m(m(e,"*",r),"-",e);return{x:e.x+n.x,y:e.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=A(this.DS.stores.SettingsStore.s.area)),this._currentVal}}]),e}(),Y=function e(r){var i=this,o=r.DS,a=r.settings;t(this,e),n(this,"_settings",{}),n(this,"s",{}),n(this,"update",(function(t){var e=t.settings,r=t.init;return i.DS.publish("Settings:updated:pre",s({settings:e},r?{init:r}:{}))})),n(this,"_update",(function(t){for(var e=function(t,e){return s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s({},T("area",t.area,e,document)),T("selectables",t.selectables,e,null)),T("autoScrollSpeed",t.autoScrollSpeed,e,5)),T("overflowTolerance",t.overflowTolerance,e,{x:25,y:25})),T("zoom",t.zoom,e,1)),T("customStyles",t.customStyles,e,!1)),T("multiSelectMode",t.multiSelectMode,e,!1)),T("multiSelectToggling",t.multiSelectToggling,e,!0)),T("multiSelectKeys",t.multiSelectKeys,e,["Control","Shift","Meta"])),T("selector",t.selector,e,null)),T("draggability",t.draggability,e,!0)),T("immediateDrag",t.immediateDrag,e,!0)),T("keyboardDrag",t.keyboardDrag,e,!0)),T("dragKeys",t.dragKeys,e,{up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]})),T("keyboardDragSpeed",t.keyboardDragSpeed,e,10)),T("useTransform",t.useTransform,e,!0)),T("hoverClass",t.hoverClass,e,"ds-hover")),T("selectableClass",t.selectableClass,e,"ds-selectable")),T("selectedClass",t.selectedClass,e,"ds-selected")),T("selectorClass",t.selectorClass,e,"ds-selector")),T("selectorAreaClass",t.selectorAreaClass,e,"ds-selector-area"))}(t.settings,t.init),r=function(){var t,e=g(a[o],2),r=e[0],s=e[1];r in i._settings||Object.defineProperty(i.s,r,{get:function(){return i._settings[r]},set:function(t){return i.update({settings:n({},r,t)})}}),i._settings["".concat(r,":pre")]=i._settings[r],i._settings[r]=s;var c={settings:(t={},n(t,r,i._settings[r]),n(t,"".concat(r,":pre"),i._settings["".concat(r,":pre")]),t)};i.DS.publish("Settings:updated",c),i.DS.publish("Settings:updated:".concat(r),c)},o=0,a=Object.entries(e);o<a.length;o++)r()})),this.DS=o,this.DS.subscribe("Settings:updated:pre",this._update),this.update({settings:a,init:!0})},G=function(){function e(r){var i=this;t(this,e),n(this,"continue",!1),n(this,"start",(function(){i.stopped=!1,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(t){return i.stores.KeyStore.isMultiSelectKeyPressed(t)})),n(this,"isDragging",(function(){return i.Interaction.isDragging})),n(this,"setSettings",(function(t){return i.stores.SettingsStore.update({settings:t})})),this.PubSub=new j({DS:this}),this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this.stores={},this.stores.SettingsStore=new Y({DS:this,settings:r}),this.stores.PointerStore=new U({DS:this}),this.stores.ScrollStore=new X({DS:this}),this.stores.KeyStore=new Z({DS:this}),this.Area=new K({DS:this}),this.Selector=new W({DS:this}),this.SelectorArea=new F({DS:this}),this.SelectableSet=new R({DS:this}),this.SelectedSet=new z({DS:this}),this.Selection=new B({DS:this}),this.Drag=new O({DS:this}),this.Interaction=new H({DS:this}),function(t){for(var e=t.subscribe,r=t.publish,n=t.Interaction,i=t.SelectedSet,o=function(){var t=g(c[a],2),o=t[0],l=t[1];["pre",!1].forEach((function(t){return e(t?"".concat(o,":").concat(t):o,(function(e){return l.forEach((function(o){return(!o.condition||o.condition(e))&&r(t?"".concat(t).concat(o.name):o.name,s({items:i.elements,isDragging:n.isDragging},e))}))}))}))},a=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(t){return t.event}}],"Interaction:end":[{name:"callback"}]});a<c.length;a++)o()}({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(e,[{key:"stop",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=!(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(t),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),t&&this.SelectableSet.clear(),e&&this.SelectedSet.clear(),this.stopped=!0}},{key:"addSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(M(t)),r||this.addSelectables(t),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(M(t)),r&&this.removeSelectables(t),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return M(t).forEach((function(i){return e.SelectedSet.has(i)?e.removeSelection(t,r,n):e.addSelection(t,r,n)})),r&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(t,e,r),this.getSelection()}},{key:"clearSelection",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=M(t);return this.SelectableSet.addAll(r),e&&this.SelectedSet.addAll(r),t}},{key:"setSelectables",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return console.warn('[DragSelect] DEPRECATION ".setSelectables" is deprecated and will be removed soon. Please use "ds.setSettings({ selectables: << new dom elements >> })" instead (see docs)'),this.removeSelectables(t,e),this.addSelectables(t,r)}},{key:"removeSelectables",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(M(t)),e&&this.removeSelection(t),t}}]),e}();export default G; | ||
function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}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(t){return!1}}function u(t,e,r){return u=l()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&c(i,r.prototype),i},u.apply(null,arguments)}function d(t){var e="function"==typeof Map?new Map:void 0;return d=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return u(t,arguments,a(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)},d(t)}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function S(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?h(t):e}function f(t){var e=l();return function(){var r,n=a(t);if(e){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return S(this,r)}}function p(t,e,r){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=a(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},p(t,e,r||t)}function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,i=!1,s=void 0;try{for(var o,a=t[Symbol.iterator]();!(n=(o=a.next()).done)&&(r.push(o.value),!e||r.length!==e);n=!0);}catch(t){i=!0,s=t}finally{try{n||null==a.return||a.return()}finally{if(i)throw s}}return r}(t,e)||v(t,e)||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 b(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||v(t)||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 v(t,e){if(t){if("string"==typeof t)return y(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var m=function(t,e,r){var n=t.x,i=t.y,s=r.x,o=r.y;return{"+":{x:n+s,y:i+o},"-":{x:n-s,y:i-o},"*":{x:n*s,y:i*o},"/":{x:n/s,y:i/o}}[e]},D=function(t){return{x:t.left,y:t.top}},_=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:t.x,top:t.y,right:t.x,bottom:t.y,width:e,height:e}},w=function(){var t,e,r,n;return{y:(null===(t=document.body)||void 0===t?void 0:t.scrollTop)||(null===(e=document.documentElement)||void 0===e?void 0:e.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}},A=function(t){return!t||t instanceof Document?w():{x:t.scrollLeft>=0?t.scrollLeft:w().x,y:t.scrollTop>=0?t.scrollTop:w().y}},P=function(t){var e=t.elementRect,r=t.containerRect,n=t.tolerance,i=void 0===n?{x:0,y:0}:n,s=[];return e.top-i.y<r.top&&s.push("top"),e.left-i.x<r.left&&s.push("left"),e.bottom+i.y>r.bottom&&s.push("bottom"),e.right+i.y>r.right&&s.push("right"),s},L=function(t){var e={x:0,y:0},r=window.getComputedStyle(t);if(!r.transform||"none"===r.transform)return e;if(r.transform.indexOf("3d")>=0){var n=r.transform.trim().match(/matrix3d\((.*?)\)/);if(n&&n.length){var i,s=null===(i=n[1])||void 0===i?void 0:i.split(",");e.x=parseInt(s[12])||0,e.y=parseInt(s[13])||0}return e}var o=r.transform.trim().match(/matrix\((.*?)\)/);if(o&&o.length){var a,c=null===(a=o[1])||void 0===a?void 0:a.split(",");e.x=parseInt(c[4])||0,e.y=parseInt(c[5])||0}return e},k=function(t,e){return e?function(t){var e=t.style.transform;if(!e||e.indexOf("translate")<0)return L(t);var r={x:0,y:0},n=e.trim().match(/translate[3dD]*?\(.*?\)/);if(n){var i,s=null===(i=n[0])||void 0===i?void 0:i.split("(");if(s){var o,a=null===(o=s[1])||void 0===o?void 0:o.split(",");r.x=parseInt(a[0])||0,r.y=parseInt(a[1])||0}}return r.x||r.x?r:L(t)}(t):function(t){var e=t.style,r={x:parseInt(e.left)||0,y:parseInt(e.top)||0};if(!r.x&&!r.x){var n=window.getComputedStyle(t);return{x:parseInt(n.left)||0,y:parseInt(n.top)||0}}return r}(t)},x=function(t){var e=t.computedStyle,r=t.node,n=e.position;r instanceof HTMLDocument||("absolute"===n||"relative"===n||"fixed"===n)||(r.style.position="relative")},I=function(t,e,r){return console.warn('[DragSelect] TypeIssue: setting "'.concat(t,'" is not of type "').concat(e,'".'))},T=function(t,e,r,i){if(void 0===e)return r?n({},t,i):{};if(null===e)return n({},t,null);var s=!0,o=!1,a="string"==typeof i;a&&(s="string"==typeof e||e instanceof String),a&&!s&&(o=!0,I(t,"string"));var c=!isNaN(i)&&"number"==typeof i;c&&(s=!isNaN(e)&&"number"==typeof e),c&&!s&&(o=!0,I(t,"number"));var l="[object Object]"===Object.prototype.toString.call(i);l&&(s="[object Object]"===Object.prototype.toString.call(e)),l&&!s&&(o=!0,I(t,"object"));var u="boolean"==typeof i;u&&(s="boolean"==typeof e),u&&!s&&(o=!0,I(t,"boolean"));var d=Array.isArray(i);d&&(s=Array.isArray(e)),d&&!s&&(o=!0,I(t,"array"));var h=o||r;return"dragKeys"===t&&s?n({},t,Object.assign(i,e)):("dragKeys"!==t||s)&&s?n({},t,e):h?n({},t,i):{}},C=function(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top},E=function(t){var e=t.element,r=t.posDirection,n=t.containerRect,i=t.useTransform,s=k(e,i),o=m(s,"+",r);V(e,o,i);var a=e.getBoundingClientRect();!function(t){var e=t.element,r=t.edges,n=t.elementRect,i=t.containerRect,s=t.elementPos,o=t.useTransform;r.includes("top")&&V(e,{y:s.y+i.top-n.top,x:s.x},o),r.includes("left")&&V(e,{y:s.y,x:s.x+i.left-n.left},o),r.includes("bottom")&&V(e,{y:s.y+i.bottom-n.bottom,x:s.x},o),r.includes("right")&&V(e,{y:s.y,x:s.x+i.right-n.right},o)}({element:e,edges:P({elementRect:a,containerRect:n}),elementRect:a,containerRect:n,elementPos:o,useTransform:i})},V=function(t,e,r){if(r){var n=t.style.transform;t.style.transform="translate3d(".concat(e.x,"px,").concat(e.y,"px,1px) ").concat(n.replace(/translate.*?\)/g,""))}else t.style.left="".concat(e.x,"px"),t.style.top="".concat(e.y,"px");return t},M=function(t){return t?!Array.isArray(t)&&(t instanceof HTMLElement||t instanceof SVGElement)?[t]:b(t):[]},N=function(t,e){t.style.left="".concat(e.left,"px"),t.style.top="".concat(e.top,"px"),t.style.width="".concat(e.width,"px"),t.style.height="".concat(e.height,"px")},K=function(){function e(r){var i,s,o,a=this,c=r.DS;t(this,e),n(this,"DS",void 0),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,"setArea",(function(t){a._node=t,x({computedStyle:a.computedStyle,node:a._node}),setTimeout((function(){a.DS.PubSub.publish("Area:modified:pre",{item:a}),a.reset(),a.DS.PubSub.publish("Area:modified",{item:a})}))})),n(this,"start",(function(){var t,e,r;t=a.parentNodes,e=a._modificationCallback,r=a._modificationObserver,window.addEventListener("resize",e),window.addEventListener("scroll",e),t.forEach((function(t,e){r.observe(t,{childList:0!==e,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 t,e;t=a._modificationObserver,e=a._modificationCallback,window.removeEventListener("resize",e),window.removeEventListener("scroll",e),t.disconnect(),a.reset()})),n(this,"scroll",(function(t,e){var r={scroll_directions:t,scroll_multiplier:e};a.DS.PubSub.publish("Area:scroll:pre",r),function(t,e,r){if(e.length){var n=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,i=t instanceof HTMLDocument?n||document.body:t,s=e.includes("top")&&i.scrollTop>0,o=e.includes("bottom")&&i.scrollTop<i.scrollHeight,a=e.includes("left")&&i.scrollLeft>0,c=e.includes("right")&&i.scrollLeft<i.scrollWidth;s&&(i.scrollTop-=1*r),o&&(i.scrollTop+=1*r),a&&(i.scrollLeft-=1*r),c&&(i.scrollLeft+=1*r)}}(a._node,t,e),a.DS.PubSub.publish("Area:scroll",r)})),this.DS=c,this.setArea(this.DS.stores.SettingsStore.s.area),this.DS.PubSub.subscribe("Settings:updated:area",(function(t){var e=t.settings;return a.setArea(e.area)})),this._modificationCallback=(i=function(t){a.DS.PubSub.publish("Area:modified:pre",{event:t,item:a}),a.reset(),a.DS.PubSub.publish("Area:modified",{event:t,item:a})},s=60,function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=function(){o=null,i.apply(void 0,e)};clearTimeout(o),o=setTimeout(n,s)}),this._modificationObserver=new MutationObserver(this._modificationCallback),this.DS.PubSub.subscribe("Interaction:init",this.start),this.DS.PubSub.subscribe("Interaction:end",this.reset)}return r(e,[{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(t,e){if(t instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var r=t.getBoundingClientRect();return{top:r.top,left:r.left,bottom:r.bottom,right:r.right,width:(t.clientWidth||r.width)*e,height:(t.clientHeight||r.height)*e}}(this.HTMLNode,this.DS.stores.SettingsStore.s.zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=null===(r=e[n])||void 0===r?void 0:r.parentNode;return i?(e.push(i),t(e,++n)):e}([this.HTMLNode]),this._parentNodes}}]),e}(),O=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_prevCursorPos",void 0),n(this,"_prevScrollPos",void 0),n(this,"_elements",[]),n(this,"_dragKeys",void 0),n(this,"_dragKeysFlat",[]),n(this,"assignDragkeys",(function(){i._dragKeys={up:i.DS.stores.SettingsStore.s.dragKeys.up.map((function(t){return t.toLowerCase()})),down:i.DS.stores.SettingsStore.s.dragKeys.down.map((function(t){return t.toLowerCase()})),left:i.DS.stores.SettingsStore.s.dragKeys.left.map((function(t){return t.toLowerCase()})),right:i.DS.stores.SettingsStore.s.dragKeys.right.map((function(t){return t.toLowerCase()}))},i._dragKeysFlat=[].concat(b(i._dragKeys.up),b(i._dragKeys.down),b(i._dragKeys.left),b(i._dragKeys.right))})),n(this,"keyboardDrag",(function(t){var e=t.event,r=t.key.toLowerCase();if(i.DS.stores.SettingsStore.s.keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i.DS.stores.SettingsStore.s.draggability&&!i.DS.continue){var n={event:e,isDragging:!0,isDraggingKeyboard:!0};i.DS.publish(["Interaction:start:pre","Interaction:start"],n),i._elements=i.DS.getSelection(),i.handleZIndex(!0);var s=function(t){var e=t.shiftKey,r=t.keyboardDragSpeed,n=t.zoom,i=t.key,s=t.dragKeys,o=t.scrollDiff,a=t.canScroll,c=t.scrollCallback,l={x:0,y:0},u=e?4*r*n:r*n;return s.left.includes(i)&&(l.x=o.x||-u,e||o.x||!a||c(["left"],r)),s.right.includes(i)&&(l.x=o.x||u,e||o.x||!a||c(["right"],r)),s.up.includes(i)&&(l.y=o.y||-u,e||o.y||!a||c(["top"],r)),s.down.includes(i)&&(l.y=o.y||u,e||o.y||!a||c(["bottom"],r)),l}({shiftKey:i.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:i.DS.stores.SettingsStore.s.keyboardDragSpeed,zoom:i.DS.stores.SettingsStore.s.zoom,key:r,scrollCallback:i.DS.Area.scroll,scrollDiff:i._scrollDiff,canScroll:i.DS.stores.ScrollStore.canScroll,dragKeys:i._dragKeys});i._elements.forEach((function(t){return E({element:t,posDirection:s,containerRect:i.DS.SelectorArea.rect,useTransform:i.DS.stores.SettingsStore.s.useTransform})})),i.DS.publish(["Interaction:update:pre","Interaction:update"],n)}})),n(this,"keyboardEnd",(function(t){var e=t.event,r=t.key.toLowerCase();if(i.DS.stores.SettingsStore.s.keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i.DS.stores.SettingsStore.s.draggability){var n={event:e,isDragging:i.DS.stores.SettingsStore.s.draggability,isDraggingKeyboard:!0};i.DS.publish(["Interaction:end:pre","Interaction:end"],n)}})),n(this,"start",(function(t){var e=t.isDragging,r=t.isDraggingKeyboard;e&&!r&&(i._prevCursorPos=null,i._prevScrollPos=null,i._elements=i.DS.getSelection(),i.handleZIndex(!0))})),n(this,"stop",(function(t){null!=t&&t.isKeyboard||(i._prevCursorPos=null,i._prevScrollPos=null,i.handleZIndex(!1),i._elements=[])})),n(this,"update",(function(t){var e=t.isDragging,r=t.isDraggingKeyboard;if(e&&i._elements.length&&!r&&!i.DS.continue){var n=m(i._cursorDiff,"+",i._scrollDiff);i._elements.forEach((function(t){return E({element:t,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i.DS.stores.SettingsStore.s.useTransform})}))}})),n(this,"handleZIndex",(function(t){i._elements.forEach((function(e){return e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+t?9999:-9998)}))})),this.DS=s,this.DS.subscribe("Settings:updated:dragKeys",this.assignDragkeys),this.assignDragkeys(),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(e,[{key:"_cursorDiff",get:function(){var t=this.DS.stores.PointerStore.currentVal,e=this._prevCursorPos?m(t,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=t,e}},{key:"_scrollDiff",get:function(){var t=this.DS.stores.ScrollStore.currentVal,e=this._prevScrollPos?m(t,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=t,e}}]),e}(),H=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"isInteracting",void 0),n(this,"isDragging",void 0),n(this,"init",(function(){return i.DS.publish("Interaction:init:pre",{})})),n(this,"_init",(function(){i.stop(),i.DS.Area.HTMLNode.addEventListener("mousedown",i.start),i.DS.Area.HTMLNode.addEventListener("touchstart",i.start,{passive:!1}),i.DS.publish("Interaction:init",{})})),n(this,"start",(function(t){return i.DS.publish("Interaction:start:pre",{event:t,isDragging:i.isDragging})})),n(this,"_start",(function(t){"touchstart"===t.type&&t.preventDefault(),i._canInteract(t)&&(i.isInteracting=!0,i.isDragging=i.isDragEvent(t),i.DS.publish("Interaction:start",{event:t,isDragging:i.isDragging}),document.addEventListener("mouseup",i.reset),document.addEventListener("touchend",i.reset))})),n(this,"isDragEvent",(function(t){var e=t.target.closest(".".concat(i.DS.stores.SettingsStore.s.selectableClass));return!(!i.DS.stores.SettingsStore.s.draggability||i.DS.stores.KeyStore.isMultiSelectKeyPressed(t)||!e)&&(i.DS.stores.SettingsStore.s.immediateDrag&&(i.DS.SelectedSet.size?i.DS.SelectedSet.has(e)||(i.DS.SelectedSet.clear(),i.DS.SelectedSet.add(e)):i.DS.SelectedSet.add(e)),!!i.DS.SelectedSet.has(e))})),n(this,"onClick",(function(t){var e=t.event;if(i._canInteract(e)&&!(e.detail>0)){var r=i.DS,n=r.stores,s=n.PointerStore,o=n.KeyStore,a=r.SelectableSet,c=r.SelectedSet;s.start(e);var l=e.target;a.has(l)&&(o.isMultiSelectKeyPressed(e)||c.clear(),c.toggle(l),i.reset())}})),n(this,"stop",(function(){i.isInteracting=!1,i.isDragging=!1,i.DS.Area.HTMLNode.removeEventListener("mousedown",i.start),i.DS.Area.HTMLNode.removeEventListener("touchstart",i.start,{passive:!1}),document.removeEventListener("mouseup",i.reset),document.removeEventListener("touchend",i.reset)})),n(this,"update",(function(t){var e=t.event,r=t.scroll_directions,n=t.scroll_multiplier;i.isInteracting&&i.DS.publish(["Interaction:update:pre","Interaction:update"],{event:e,scroll_directions:r,scroll_multiplier:n,isDragging:i.isDragging})})),n(this,"reset",(function(t){return i.DS.publish("Interaction:end:pre",{event:t,isDragging:i.isDragging})})),n(this,"_reset",(function(t){var e=i.isDragging;i.stop(),i.init(),i.DS.publish("Interaction:end",{event:t,isDragging:e})})),this.DS=s,this.DS.subscribe("Settings:updated:area",this.init),this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(t){var e=t.event;return i.start(e)})),this.DS.subscribe("Interaction:start:pre",(function(t){var e=t.event;return i._start(e)})),this.DS.subscribe("Interaction:init:pre",this._init),this.DS.subscribe("Interaction:end:pre",(function(t){var e=t.event;return i._reset(e)})),this.DS.subscribe("Area:scroll",this.update)}return r(e,[{key:"_canInteract",value:function(t){var e=0===t.clientX&&0===t.clientY&&0===t.detail&&t.target;return!(2===t.button||this.isInteracting||t.target&&!this.DS.SelectorArea.isInside(t.target)||!e&&!this.DS.SelectorArea.isClicked(t))}}]),e}(),j=function e(r){var i=this,s=r.DS;t(this,e),n(this,"subscribers",{}),n(this,"subscribe",(function(t,e){return Array.isArray(i.subscribers[t])||(i.subscribers[t]=[]),i.subscribers[t].push(e),i.subscribers[t].length-1})),n(this,"unsubscribe",(function(t,e,r){r>=0?i.subscribers[t].splice(r,1):e&&(i.subscribers[t]=i.subscribers[t].filter((function(t){return t!==e})))})),n(this,"publish",(function(t,e){Array.isArray(t)?t.forEach((function(t){return i._publish(t,e)})):i._publish(t,e)})),n(this,"_publish",(function(t,e){var r=i.subscribers[t];Array.isArray(r)&&(t.includes(":pre")?i._handlePrePublish(r,e):i._handlePublish(r,e))})),n(this,"_handlePublish",(function(t,e){for(var r=0,n=t.length;r<n;r++){if(i.DS.stopped)return;t[r](e)}})),n(this,"_handlePrePublish",(function(t,e){for(var r=t.length;r--;){if(i.DS.stopped)return;t[r](e)}})),this.DS=s},R=function(e){o(s,d(Set));var i=f(s);function s(e){var r,o=e.DS;return t(this,s),n(h(r=i.call(this)),"init",(function(){return M(r.DS.stores.SettingsStore.s.selectables).forEach((function(t){return r.add(t)}))})),n(h(r),"clear",(function(){return r.forEach((function(t){return r.delete(t)}))})),n(h(r),"_onClick",(function(t){return r.DS.publish(["Selectable:click:pre","Selectable:click"],{event:t})})),n(h(r),"_onPointer",(function(t){return r.DS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:t})})),n(h(r),"addAll",(function(t){return t.forEach((function(t){return r.add(t)}))})),n(h(r),"deleteAll",(function(t){return t.forEach((function(t){return r.delete(t)}))})),r.DS=o,r.DS.subscribe("Interaction:init",r.init),r.DS.PubSub.subscribe("Settings:updated:selectables",(function(){r.clear(),r.init()})),r.DS.subscribe("Settings:updated:selectableClass",(function(t){var e=t.settings;r.forEach((function(t){t.classList.remove(e["selectableClass:pre"]),t.classList.add(e.selectableClass)}))})),r}return r(s,[{key:"add",value:function(t){if(!p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selectable:added:pre",e),t.classList.add(this.DS.stores.SettingsStore.s.selectableClass),t.addEventListener("click",this._onClick),t.addEventListener("mousedown",this._onPointer),t.addEventListener("touchstart",this._onPointer,{passive:!1}),this.DS.stores.SettingsStore.s.draggability&&!this.DS.stores.SettingsStore.s.useTransform&&x({computedStyle:window.getComputedStyle(t),node:t}),this.DS.publish("Selectable:added",e),p(a(s.prototype),"add",this).call(this,t)}}},{key:"delete",value:function(t){if(p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selectable:removed:pre",e),t.classList.remove(this.DS.stores.SettingsStore.s.selectableClass),t.classList.remove(this.DS.stores.SettingsStore.s.hoverClass),t.removeEventListener("click",this._onClick),t.removeEventListener("mousedown",this._onPointer),t.removeEventListener("touchstart",this._onPointer,{passive:!1}),this.DS.publish("Selectable:removed",e),p(a(s.prototype),"delete",this).call(this,t)}}},{key:"elements",get:function(){return Array.from(this.values())}}]),s}(),z=function(e){o(s,d(Set));var i=f(s);function s(e){var r,o=e.DS;return t(this,s),n(h(r=i.call(this)),"clear",(function(){return r.forEach((function(t){return r.delete(t)}))})),n(h(r),"addAll",(function(t){return t.forEach((function(t){return r.add(t)}))})),n(h(r),"deleteAll",(function(t){return t.forEach((function(t){return r.delete(t)}))})),r.DS=o,r}return r(s,[{key:"add",value:function(t){if(!p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selected:added:pre",e),p(a(s.prototype),"add",this).call(this,t),t.classList.add(this.DS.stores.SettingsStore.s.selectedClass),t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+1),this.DS.publish("Selected:added",e),this}}},{key:"delete",value:function(t){if(p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};this.DS.publish("Selected:removed:pre",e);var r=p(a(s.prototype),"delete",this).call(this,t);return t.classList.remove(this.DS.stores.SettingsStore.s.selectedClass),t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)-1),this.DS.publish("Selected:removed",e),r}}},{key:"toggle",value:function(t){return this.has(t)?this.delete(t):this.add(t),t}},{key:"elements",get:function(){return Array.from(this.values())}}]),s}(),B=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_prevSelectedSet",void 0),n(this,"start",(function(t){var e=t.event;t.isDragging||(i._storePrevious(e),i._handleInsideSelection(!0,e))})),n(this,"update",(function(t){t.isDragging||i.DS.continue||i._handleInsideSelection()})),n(this,"_handleInsideSelection",(function(t,e){for(var r=i.DS,n=r.SelectableSet,s=r.SelectorArea,o=r.Selector,a=n.elements.map((function(t){return[t,t.getBoundingClientRect()]})),c=[],l=[],u=0,d=a.length;u<d;u++)s.isInside(a[u][0],a[u][1])&&(C(a[u][1],o.rect)?c.push(a[u][0]):l.push(a[u][0]));var h=i.DS.stores.KeyStore.isMultiSelectKeyPressed(e)&&i.DS.stores.SettingsStore.s.multiSelectToggling;i.DS.continue||(c.forEach((function(e){return function(t){var e=t.element,r=t.force,n=t.multiSelectionToggle,i=t.SelectedSet,s=t.hoverClassName;e.classList.contains(s)&&!r||(i.has(e)?n&&i.delete(e):i.add(e),e.classList.add(s))}({element:e,force:t,multiSelectionToggle:h,SelectedSet:i.DS.SelectedSet,hoverClassName:i.DS.stores.SettingsStore.s.hoverClass})})),l.forEach((function(e){return function(t){var e=t.element,r=t.force,n=t.SelectedSet,i=t.PrevSelectedSet,s=t.hoverClassName;if(!e.classList.contains(s)&&!r)return!1;var o=n.has(e),a=i.has(e);o&&!a?n.delete(e):!o&&a&&n.add(e),e.classList.remove(s)}({element:e,force:t,SelectedSet:i.DS.SelectedSet,hoverClassName:i.DS.stores.SettingsStore.s.hoverClass,PrevSelectedSet:i._prevSelectedSet})})))})),this.DS=s,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return r(e,[{key:"_storePrevious",value:function(t){var e=this.DS,r=e.stores.KeyStore,n=e.SelectedSet;r.isMultiSelectKeyPressed(t)?this._prevSelectedSet=new Set(n):this._prevSelectedSet=new Set}}]),e}(),W=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_rect",void 0),n(this,"attachSelector",(function(){var t,e,r,n;i.HTMLNode&&null!==(t=i.DS.SelectorArea)&&void 0!==t&&t.HTMLNode&&i.DS.SelectorArea.HTMLNode.removeChild(i.HTMLNode),i.HTMLNode=i.DS.stores.SettingsStore.s.selector||(r=i.DS.stores.SettingsStore.s.customStyles,(n=document.createElement("div")).style.position="absolute",r||(n.style.background="rgba(0, 0, 255, 0.1)",n.style.border="1px solid rgba(0, 0, 255, 0.45)",n.style.display="none",n.style.pointerEvents="none"),n),i.HTMLNode.classList.add(i.DS.stores.SettingsStore.s.selectorClass),i.HTMLNode&&null!==(e=i.DS.SelectorArea)&&void 0!==e&&e.HTMLNode&&i.DS.SelectorArea.HTMLNode.appendChild(i.HTMLNode)})),n(this,"start",(function(t){if(!t.isDragging){var e=i.DS.stores.PointerStore.initialValArea;N(i.HTMLNode,_(e,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(t){if(!t.isDragging&&!i.DS.continue){var e=i.DS.stores,r=e.ScrollStore,n=e.PointerStore,s=function(t){var e=t.scrollAmount,r=t.initialPointerPos,n=t.pointerPos,i={};return n.x>r.x-e.x?(i.left=r.x-e.x,i.width=n.x-r.x+e.x):(i.left=n.x,i.width=r.x-n.x-e.x),n.y>r.y-e.y?(i.top=r.y-e.y,i.height=n.y-r.y+e.y):(i.top=n.y,i.height=r.y-n.y-e.y),i}({scrollAmount:r.scrollAmount,initialPointerPos:n.initialValArea,pointerPos:n.currentValArea});N(i.HTMLNode,s),i._rect=null}})),this.DS=s,this.DS.subscribe("Settings:updated:selectorClass",(function(t){var e=t.settings;i.HTMLNode.classList.remove(e["selectorClass:pre"]),i.HTMLNode.classList.add(e.selectorClass)})),this.DS.subscribe("Settings:updated:selector",this.attachSelector),this.attachSelector(),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return r(e,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),e}(),F=function(){function e(r){var i,s=this,o=r.DS;t(this,e),n(this,"_scrollInterval",void 0),n(this,"_rect",void 0),n(this,"currentEdges",[]),n(this,"start",(function(){return s.applyElements("append")})),n(this,"applyElements",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",e=document.body?"body":"documentElement",r="".concat(t,"Child");s.HTMLNode[r](s.DS.Selector.HTMLNode),document[e][r](s.HTMLNode)})),n(this,"updatePos",(function(){s._rect=null;var t=s.DS.Area.rect,e=s.DS.Area.computedBorder,r=s.HTMLNode.style,n="".concat(t.top+e.top,"px"),i="".concat(t.left+e.left,"px"),o="".concat(t.width,"px"),a="".concat(t.height,"px");r.top!==n&&(r.top=n),r.left!==i&&(r.left=i),r.width!==o&&(r.width=o),r.height!==a&&(r.height=a)})),n(this,"stop",(function(t){s.stopAutoScroll(),t&&s.applyElements("remove")})),n(this,"startAutoScroll",(function(){s.currentEdges=[],s._scrollInterval=setInterval((function(){return s.handleAutoScroll()}),16)})),n(this,"handleAutoScroll",(function(){if(!s.DS.continue){var t=s.DS,e=t.stores.PointerStore,r=t.Area;s.currentEdges=P({elementRect:_(e.currentVal),containerRect:s.rect,tolerance:s.DS.stores.SettingsStore.s.overflowTolerance}),s.currentEdges.length&&r.scroll(s.currentEdges,s.DS.stores.SettingsStore.s.autoScrollSpeed)}})),n(this,"stopAutoScroll",(function(){s.currentEdges=[],clearInterval(s._scrollInterval)})),n(this,"isInside",(function(t,e){return!(!s.DS.Area.HTMLNode.contains(t)||!s.DS.stores.ScrollStore.canScroll)||C(s.rect,e||t.getBoundingClientRect())})),this.DS=o,this.HTMLNode=((i=document.createElement("div")).style.position="fixed",i.style.overflow="hidden",i.style.pointerEvents="none",i.style.zIndex="999999999999999999",i),this.DS.subscribe("Settings:updated:selectorAreaClass",(function(t){var e=t.settings;s.HTMLNode.classList.remove(e["selectorAreaClass:pre"]),s.HTMLNode.classList.add(e.selectorAreaClass)})),this.HTMLNode.classList.add(this.DS.stores.SettingsStore.s.selectorAreaClass),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:init",this.start),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){s.updatePos(),s.stopAutoScroll()}))}return r(e,[{key:"isClicked",value:function(t){var e=this.DS.stores.PointerStore,r=t?e.getPointerPosition(t):e.initialVal;return C({left:r.x,top:r.y,right:r.x,bottom:r.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),e}(),Z=function(){function e(r){var i=this,s=r.DS;t(this,e),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(t){var e=t.key.toLowerCase();i.DS.publish("KeyStore:down:pre",{event:t,key:e}),i._currentValues.add(e),i.DS.publish("KeyStore:down",{event:t,key:e})})),n(this,"keyup",(function(t){var e=t.key.toLowerCase();i.DS.publish("KeyStore:up:pre",{event:t,key:e}),i._currentValues.delete(e),i.DS.publish("KeyStore:up",{event:t,key:e})})),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=s,this.DS.subscribe("Interaction:init",this.init)}return r(e,[{key:"isMultiSelectKeyPressed",value:function(t){var e=this;if(this.DS.stores.SettingsStore.s.multiSelectMode)return!0;var r=this.DS.stores.SettingsStore.s.multiSelectKeys.map((function(t){return t.toLocaleLowerCase()}));return!!this.currentValues.some((function(t){return r.includes(t.toLocaleLowerCase())}))||!(!t||!r.some((function(r){return t[e._keyMapping[r]]})))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),e}(),U=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_isMouseInteraction",!1),n(this,"_initialValArea",void 0),n(this,"_currentValArea",void 0),n(this,"_lastValArea",void 0),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_lastVal",void 0),n(this,"_lastTouch",void 0),n(this,"init",(function(){document.addEventListener("mousemove",i.update),document.addEventListener("touchmove",i.update,{passive:!1})})),n(this,"getPointerPosition",(function(t){return function(t){var e=t.event;return{x:e.clientX,y:e.clientY}}({event:i._normalizedEvent(t)})})),n(this,"update",(function(t){t&&(i.DS.publish("PointerStore:updated:pre",{event:t}),i.currentVal=i.getPointerPosition(t),i._isMouseInteraction&&i.DS.publish("PointerStore:updated",{event:t}))})),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(t){t&&(i.currentVal=i.lastVal=i.getPointerPosition(t),i.stop(),i.init())})),this.DS=s,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(t){var e=t.event;return i.start(e)})),this.DS.subscribe("Interaction:end",(function(t){var e=t.event;return i.reset(e)}))}return r(e,[{key:"start",value:function(t){t&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(t))}},{key:"_normalizedEvent",value:function(t){return"touches"in t&&"touchend"!==t.type&&(this._lastTouch=t),"touches"in t?this._lastTouch.touches[0]:t}},{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(t){this._initialVal=t,this._initialValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(t){this._currentVal=t,this._currentValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(t){this._lastVal=t,this._lastValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}}]),e}(),X=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_canScroll",void 0),n(this,"init",(function(){return i.DS.stores.SettingsStore.s.area.addEventListener("scroll",i.update)})),n(this,"start",(function(){i._currentVal=i._initialVal=A(i.DS.stores.SettingsStore.s.area),i.DS.stores.SettingsStore.s.area.addEventListener("scroll",i.update)})),n(this,"update",(function(){return i._currentVal=A(i.DS.stores.SettingsStore.s.area)})),n(this,"stop",(function(){i.DS.stores.SettingsStore.s.area.removeEventListener("scroll",i.update),i._initialVal={x:0,y:0},i._canScroll=null})),n(this,"reset",(function(){i.stop(),i.start()})),this.DS=s,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(e,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(t=this.DS.stores.SettingsStore.s.area,!!((e=A(t)).x||e.y||(t instanceof HTMLDocument?t.body?t.body.scrollTop=1:t.documentElement.scrollTop=1:t.scrollTop=1)));var t,e}},{key:"scrollAmount",get:function(){var t,e=m(this.currentVal,"-",this.initialVal),r={x:t=this.DS.stores.SettingsStore.s.zoom,y:t},n=m(m(e,"*",r),"-",e);return{x:e.x+n.x,y:e.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=A(this.DS.stores.SettingsStore.s.area)),this._currentVal}}]),e}(),Y=function e(r){var i=this,o=r.DS,a=r.settings;t(this,e),n(this,"_settings",{}),n(this,"s",{}),n(this,"update",(function(t){var e=t.settings,r=t.init;return i.DS.publish("Settings:updated:pre",s({settings:e},r?{init:r}:{}))})),n(this,"_update",(function(t){for(var e=function(t,e){return s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s({},T("area",t.area,e,document)),T("selectables",t.selectables,e,null)),T("autoScrollSpeed",t.autoScrollSpeed,e,5)),T("overflowTolerance",t.overflowTolerance,e,{x:25,y:25})),T("zoom",t.zoom,e,1)),T("customStyles",t.customStyles,e,!1)),T("multiSelectMode",t.multiSelectMode,e,!1)),T("multiSelectToggling",t.multiSelectToggling,e,!0)),T("multiSelectKeys",t.multiSelectKeys,e,["Control","Shift","Meta"])),T("selector",t.selector,e,null)),T("draggability",t.draggability,e,!0)),T("immediateDrag",t.immediateDrag,e,!0)),T("keyboardDrag",t.keyboardDrag,e,!0)),T("dragKeys",t.dragKeys,e,{up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]})),T("keyboardDragSpeed",t.keyboardDragSpeed,e,10)),T("useTransform",t.useTransform,e,!0)),T("hoverClass",t.hoverClass,e,"ds-hover")),T("selectableClass",t.selectableClass,e,"ds-selectable")),T("selectedClass",t.selectedClass,e,"ds-selected")),T("selectorClass",t.selectorClass,e,"ds-selector")),T("selectorAreaClass",t.selectorAreaClass,e,"ds-selector-area"))}(t.settings,t.init),r=function(){var t,e=g(a[o],2),r=e[0],s=e[1];r in i._settings||Object.defineProperty(i.s,r,{get:function(){return i._settings[r]},set:function(t){return i.update({settings:n({},r,t)})}}),i._settings["".concat(r,":pre")]=i._settings[r],i._settings[r]=s;var c={settings:(t={},n(t,r,i._settings[r]),n(t,"".concat(r,":pre"),i._settings["".concat(r,":pre")]),t)};i.DS.publish("Settings:updated",c),i.DS.publish("Settings:updated:".concat(r),c)},o=0,a=Object.entries(e);o<a.length;o++)r()})),this.DS=o,this.DS.subscribe("Settings:updated:pre",this._update),this.update({settings:a,init:!0})},G=function(){function e(r){var i=this;t(this,e),n(this,"continue",!1),n(this,"start",(function(){i.stopped=!1,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(t){return i.stores.KeyStore.isMultiSelectKeyPressed(t)})),n(this,"isDragging",(function(){return i.Interaction.isDragging})),n(this,"setSettings",(function(t){return i.stores.SettingsStore.update({settings:t})})),this.PubSub=new j({DS:this}),this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this.stores={},this.stores.SettingsStore=new Y({DS:this,settings:r}),this.stores.PointerStore=new U({DS:this}),this.stores.ScrollStore=new X({DS:this}),this.stores.KeyStore=new Z({DS:this}),this.Area=new K({DS:this}),this.Selector=new W({DS:this}),this.SelectorArea=new F({DS:this}),this.SelectableSet=new R({DS:this}),this.SelectedSet=new z({DS:this}),this.Selection=new B({DS:this}),this.Drag=new O({DS:this}),this.Interaction=new H({DS:this}),function(t){for(var e=t.subscribe,r=t.publish,n=t.Interaction,i=t.SelectedSet,o=function(){var t=g(c[a],2),o=t[0],l=t[1];["pre",!1].forEach((function(t){return e(t?"".concat(o,":").concat(t):o,(function(e){return l.forEach((function(o){return(!o.condition||o.condition(e))&&r(t?"".concat(t).concat(o.name):o.name,s({items:i.elements,isDragging:n.isDragging},e))}))}))}))},a=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(t){return t.event}}],"Interaction:end":[{name:"callback"}]});a<c.length;a++)o()}({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(e,[{key:"stop",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=!(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(t),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),t&&this.SelectableSet.clear(),e&&this.SelectedSet.clear(),this.stopped=!0}},{key:"addSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(M(t)),r||this.addSelectables(t),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(M(t)),r&&this.removeSelectables(t),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return M(t).forEach((function(i){return e.SelectedSet.has(i)?e.removeSelection(t,r,n):e.addSelection(t,r,n)})),r&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(t,e,r),this.getSelection()}},{key:"clearSelection",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(t,e,r){var n=M(t);return this.SelectableSet.addAll(n),e&&this.SelectedSet.addAll(n),r&&this.PubSub.publish("callback",{items:this.getSelection()}),t}},{key:"setSelectables",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return console.warn('[DragSelect] DEPRECATION ".setSelectables" is deprecated and will be removed soon. Please use "ds.setSettings({ selectables: << new dom elements >> })" instead (see docs)'),this.removeSelectables(t,e),this.addSelectables(t,r)}},{key:"removeSelectables",value:function(t,e,r){return this.SelectableSet.deleteAll(M(t)),e&&this.removeSelection(t),r&&this.PubSub.publish("callback",{items:this.getSelection()}),t}}]),e}();export default G; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).DragSelect=e()}(this,(function(){"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}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(t){return!1}}function u(t,e,r){return u=l()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&c(i,r.prototype),i},u.apply(null,arguments)}function d(t){var e="function"==typeof Map?new Map:void 0;return d=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return u(t,arguments,a(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)},d(t)}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function S(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?h(t):e}function f(t){var e=l();return function(){var r,n=a(t);if(e){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return S(this,r)}}function p(t,e,r){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=a(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},p(t,e,r||t)}function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,i=!1,s=void 0;try{for(var o,a=t[Symbol.iterator]();!(n=(o=a.next()).done)&&(r.push(o.value),!e||r.length!==e);n=!0);}catch(t){i=!0,s=t}finally{try{n||null==a.return||a.return()}finally{if(i)throw s}}return r}(t,e)||b(t,e)||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 v(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||b(t)||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 b(t,e){if(t){if("string"==typeof t)return y(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var m=function(t,e,r){var n=t.x,i=t.y,s=r.x,o=r.y;return{"+":{x:n+s,y:i+o},"-":{x:n-s,y:i-o},"*":{x:n*s,y:i*o},"/":{x:n/s,y:i/o}}[e]},D=function(t){return{x:t.left,y:t.top}},_=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:t.x,top:t.y,right:t.x,bottom:t.y,width:e,height:e}},w=function(){var t,e,r,n;return{y:(null===(t=document.body)||void 0===t?void 0:t.scrollTop)||(null===(e=document.documentElement)||void 0===e?void 0:e.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}},A=function(t){return!t||t instanceof Document?w():{x:t.scrollLeft>=0?t.scrollLeft:w().x,y:t.scrollTop>=0?t.scrollTop:w().y}},P=function(t){var e=t.elementRect,r=t.containerRect,n=t.tolerance,i=void 0===n?{x:0,y:0}:n,s=[];return e.top-i.y<r.top&&s.push("top"),e.left-i.x<r.left&&s.push("left"),e.bottom+i.y>r.bottom&&s.push("bottom"),e.right+i.y>r.right&&s.push("right"),s},L=function(t){var e={x:0,y:0},r=window.getComputedStyle(t);if(!r.transform||"none"===r.transform)return e;if(r.transform.indexOf("3d")>=0){var n=r.transform.trim().match(/matrix3d\((.*?)\)/);if(n&&n.length){var i,s=null===(i=n[1])||void 0===i?void 0:i.split(",");e.x=parseInt(s[12])||0,e.y=parseInt(s[13])||0}return e}var o=r.transform.trim().match(/matrix\((.*?)\)/);if(o&&o.length){var a,c=null===(a=o[1])||void 0===a?void 0:a.split(",");e.x=parseInt(c[4])||0,e.y=parseInt(c[5])||0}return e},x=function(t,e){return e?function(t){var e=t.style.transform;if(!e||e.indexOf("translate")<0)return L(t);var r={x:0,y:0},n=e.trim().match(/translate[3dD]*?\(.*?\)/);if(n){var i,s=null===(i=n[0])||void 0===i?void 0:i.split("(");if(s){var o,a=null===(o=s[1])||void 0===o?void 0:o.split(",");r.x=parseInt(a[0])||0,r.y=parseInt(a[1])||0}}return r.x||r.x?r:L(t)}(t):function(t){var e=t.style,r={x:parseInt(e.left)||0,y:parseInt(e.top)||0};if(!r.x&&!r.x){var n=window.getComputedStyle(t);return{x:parseInt(n.left)||0,y:parseInt(n.top)||0}}return r}(t)},k=function(t){var e=t.computedStyle,r=t.node,n=e.position;r instanceof HTMLDocument||("absolute"===n||"relative"===n||"fixed"===n)||(r.style.position="relative")},I=function(t,e,r){return console.warn('[DragSelect] TypeIssue: setting "'.concat(t,'" is not of type "').concat(e,'".'))},T=function(t,e,r,i){if(void 0===e)return r?n({},t,i):{};if(null===e)return n({},t,null);var s=!0,o=!1,a="string"==typeof i;a&&(s="string"==typeof e||e instanceof String),a&&!s&&(o=!0,I(t,"string"));var c=!isNaN(i)&&"number"==typeof i;c&&(s=!isNaN(e)&&"number"==typeof e),c&&!s&&(o=!0,I(t,"number"));var l="[object Object]"===Object.prototype.toString.call(i);l&&(s="[object Object]"===Object.prototype.toString.call(e)),l&&!s&&(o=!0,I(t,"object"));var u="boolean"==typeof i;u&&(s="boolean"==typeof e),u&&!s&&(o=!0,I(t,"boolean"));var d=Array.isArray(i);d&&(s=Array.isArray(e)),d&&!s&&(o=!0,I(t,"array"));var h=o||r;return"dragKeys"===t&&s?n({},t,Object.assign(i,e)):("dragKeys"!==t||s)&&s?n({},t,e):h?n({},t,i):{}},C=function(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top},E=function(t){var e=t.element,r=t.posDirection,n=t.containerRect,i=t.useTransform,s=x(e,i),o=m(s,"+",r);V(e,o,i);var a=e.getBoundingClientRect();!function(t){var e=t.element,r=t.edges,n=t.elementRect,i=t.containerRect,s=t.elementPos,o=t.useTransform;r.includes("top")&&V(e,{y:s.y+i.top-n.top,x:s.x},o),r.includes("left")&&V(e,{y:s.y,x:s.x+i.left-n.left},o),r.includes("bottom")&&V(e,{y:s.y+i.bottom-n.bottom,x:s.x},o),r.includes("right")&&V(e,{y:s.y,x:s.x+i.right-n.right},o)}({element:e,edges:P({elementRect:a,containerRect:n}),elementRect:a,containerRect:n,elementPos:o,useTransform:i})},V=function(t,e,r){if(r){var n=t.style.transform;t.style.transform="translate3d(".concat(e.x,"px,").concat(e.y,"px,1px) ").concat(n.replace(/translate.*?\)/g,""))}else t.style.left="".concat(e.x,"px"),t.style.top="".concat(e.y,"px");return t},M=function(t){return t?!Array.isArray(t)&&(t instanceof HTMLElement||t instanceof SVGElement)?[t]:v(t):[]},N=function(t,e){t.style.left="".concat(e.left,"px"),t.style.top="".concat(e.top,"px"),t.style.width="".concat(e.width,"px"),t.style.height="".concat(e.height,"px")},K=function(){function e(r){var i,s,o,a=this,c=r.DS;t(this,e),n(this,"DS",void 0),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,"setArea",(function(t){a._node=t,k({computedStyle:a.computedStyle,node:a._node}),setTimeout((function(){a.DS.PubSub.publish("Area:modified:pre",{item:a}),a.reset(),a.DS.PubSub.publish("Area:modified",{item:a})}))})),n(this,"start",(function(){var t,e,r;t=a.parentNodes,e=a._modificationCallback,r=a._modificationObserver,window.addEventListener("resize",e),window.addEventListener("scroll",e),t.forEach((function(t,e){r.observe(t,{childList:0!==e,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 t,e;t=a._modificationObserver,e=a._modificationCallback,window.removeEventListener("resize",e),window.removeEventListener("scroll",e),t.disconnect(),a.reset()})),n(this,"scroll",(function(t,e){var r={scroll_directions:t,scroll_multiplier:e};a.DS.PubSub.publish("Area:scroll:pre",r),function(t,e,r){if(e.length){var n=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,i=t instanceof HTMLDocument?n||document.body:t,s=e.includes("top")&&i.scrollTop>0,o=e.includes("bottom")&&i.scrollTop<i.scrollHeight,a=e.includes("left")&&i.scrollLeft>0,c=e.includes("right")&&i.scrollLeft<i.scrollWidth;s&&(i.scrollTop-=1*r),o&&(i.scrollTop+=1*r),a&&(i.scrollLeft-=1*r),c&&(i.scrollLeft+=1*r)}}(a._node,t,e),a.DS.PubSub.publish("Area:scroll",r)})),this.DS=c,this.setArea(this.DS.stores.SettingsStore.s.area),this.DS.PubSub.subscribe("Settings:updated:area",(function(t){var e=t.settings;return a.setArea(e.area)})),this._modificationCallback=(i=function(t){a.DS.PubSub.publish("Area:modified:pre",{event:t,item:a}),a.reset(),a.DS.PubSub.publish("Area:modified",{event:t,item:a})},s=60,function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=function(){o=null,i.apply(void 0,e)};clearTimeout(o),o=setTimeout(n,s)}),this._modificationObserver=new MutationObserver(this._modificationCallback),this.DS.PubSub.subscribe("Interaction:init",this.start),this.DS.PubSub.subscribe("Interaction:end",this.reset)}return r(e,[{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(t,e){if(t instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var r=t.getBoundingClientRect();return{top:r.top,left:r.left,bottom:r.bottom,right:r.right,width:(t.clientWidth||r.width)*e,height:(t.clientHeight||r.height)*e}}(this.HTMLNode,this.DS.stores.SettingsStore.s.zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=null===(r=e[n])||void 0===r?void 0:r.parentNode;return i?(e.push(i),t(e,++n)):e}([this.HTMLNode]),this._parentNodes}}]),e}(),O=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_prevCursorPos",void 0),n(this,"_prevScrollPos",void 0),n(this,"_elements",[]),n(this,"_dragKeys",void 0),n(this,"_dragKeysFlat",[]),n(this,"assignDragkeys",(function(){i._dragKeys={up:i.DS.stores.SettingsStore.s.dragKeys.up.map((function(t){return t.toLowerCase()})),down:i.DS.stores.SettingsStore.s.dragKeys.down.map((function(t){return t.toLowerCase()})),left:i.DS.stores.SettingsStore.s.dragKeys.left.map((function(t){return t.toLowerCase()})),right:i.DS.stores.SettingsStore.s.dragKeys.right.map((function(t){return t.toLowerCase()}))},i._dragKeysFlat=[].concat(v(i._dragKeys.up),v(i._dragKeys.down),v(i._dragKeys.left),v(i._dragKeys.right))})),n(this,"keyboardDrag",(function(t){var e=t.event,r=t.key.toLowerCase();if(i.DS.stores.SettingsStore.s.keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i.DS.stores.SettingsStore.s.draggability&&!i.DS.continue){var n={event:e,isDragging:!0,isDraggingKeyboard:!0};i.DS.publish(["Interaction:start:pre","Interaction:start"],n),i._elements=i.DS.getSelection(),i.handleZIndex(!0);var s=function(t){var e=t.shiftKey,r=t.keyboardDragSpeed,n=t.zoom,i=t.key,s=t.dragKeys,o=t.scrollDiff,a=t.canScroll,c=t.scrollCallback,l={x:0,y:0},u=e?4*r*n:r*n;return s.left.includes(i)&&(l.x=o.x||-u,e||o.x||!a||c(["left"],r)),s.right.includes(i)&&(l.x=o.x||u,e||o.x||!a||c(["right"],r)),s.up.includes(i)&&(l.y=o.y||-u,e||o.y||!a||c(["top"],r)),s.down.includes(i)&&(l.y=o.y||u,e||o.y||!a||c(["bottom"],r)),l}({shiftKey:i.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:i.DS.stores.SettingsStore.s.keyboardDragSpeed,zoom:i.DS.stores.SettingsStore.s.zoom,key:r,scrollCallback:i.DS.Area.scroll,scrollDiff:i._scrollDiff,canScroll:i.DS.stores.ScrollStore.canScroll,dragKeys:i._dragKeys});i._elements.forEach((function(t){return E({element:t,posDirection:s,containerRect:i.DS.SelectorArea.rect,useTransform:i.DS.stores.SettingsStore.s.useTransform})})),i.DS.publish(["Interaction:update:pre","Interaction:update"],n)}})),n(this,"keyboardEnd",(function(t){var e=t.event,r=t.key.toLowerCase();if(i.DS.stores.SettingsStore.s.keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i.DS.stores.SettingsStore.s.draggability){var n={event:e,isDragging:i.DS.stores.SettingsStore.s.draggability,isDraggingKeyboard:!0};i.DS.publish(["Interaction:end:pre","Interaction:end"],n)}})),n(this,"start",(function(t){var e=t.isDragging,r=t.isDraggingKeyboard;e&&!r&&(i._prevCursorPos=null,i._prevScrollPos=null,i._elements=i.DS.getSelection(),i.handleZIndex(!0))})),n(this,"stop",(function(t){null!=t&&t.isKeyboard||(i._prevCursorPos=null,i._prevScrollPos=null,i.handleZIndex(!1),i._elements=[])})),n(this,"update",(function(t){var e=t.isDragging,r=t.isDraggingKeyboard;if(e&&i._elements.length&&!r&&!i.DS.continue){var n=m(i._cursorDiff,"+",i._scrollDiff);i._elements.forEach((function(t){return E({element:t,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i.DS.stores.SettingsStore.s.useTransform})}))}})),n(this,"handleZIndex",(function(t){i._elements.forEach((function(e){return e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+t?9999:-9998)}))})),this.DS=s,this.DS.subscribe("Settings:updated:dragKeys",this.assignDragkeys),this.assignDragkeys(),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(e,[{key:"_cursorDiff",get:function(){var t=this.DS.stores.PointerStore.currentVal,e=this._prevCursorPos?m(t,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=t,e}},{key:"_scrollDiff",get:function(){var t=this.DS.stores.ScrollStore.currentVal,e=this._prevScrollPos?m(t,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=t,e}}]),e}(),H=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"isInteracting",void 0),n(this,"isDragging",void 0),n(this,"init",(function(){return i.DS.publish("Interaction:init:pre",{})})),n(this,"_init",(function(){i.stop(),i.DS.Area.HTMLNode.addEventListener("mousedown",i.start),i.DS.Area.HTMLNode.addEventListener("touchstart",i.start,{passive:!1}),i.DS.publish("Interaction:init",{})})),n(this,"start",(function(t){return i.DS.publish("Interaction:start:pre",{event:t,isDragging:i.isDragging})})),n(this,"_start",(function(t){"touchstart"===t.type&&t.preventDefault(),i._canInteract(t)&&(i.isInteracting=!0,i.isDragging=i.isDragEvent(t),i.DS.publish("Interaction:start",{event:t,isDragging:i.isDragging}),document.addEventListener("mouseup",i.reset),document.addEventListener("touchend",i.reset))})),n(this,"isDragEvent",(function(t){var e=t.target.closest(".".concat(i.DS.stores.SettingsStore.s.selectableClass));return!(!i.DS.stores.SettingsStore.s.draggability||i.DS.stores.KeyStore.isMultiSelectKeyPressed(t)||!e)&&(i.DS.stores.SettingsStore.s.immediateDrag&&(i.DS.SelectedSet.size?i.DS.SelectedSet.has(e)||(i.DS.SelectedSet.clear(),i.DS.SelectedSet.add(e)):i.DS.SelectedSet.add(e)),!!i.DS.SelectedSet.has(e))})),n(this,"onClick",(function(t){var e=t.event;if(i._canInteract(e)&&!(e.detail>0)){var r=i.DS,n=r.stores,s=n.PointerStore,o=n.KeyStore,a=r.SelectableSet,c=r.SelectedSet;s.start(e);var l=e.target;a.has(l)&&(o.isMultiSelectKeyPressed(e)||c.clear(),c.toggle(l),i.reset())}})),n(this,"stop",(function(){i.isInteracting=!1,i.isDragging=!1,i.DS.Area.HTMLNode.removeEventListener("mousedown",i.start),i.DS.Area.HTMLNode.removeEventListener("touchstart",i.start,{passive:!1}),document.removeEventListener("mouseup",i.reset),document.removeEventListener("touchend",i.reset)})),n(this,"update",(function(t){var e=t.event,r=t.scroll_directions,n=t.scroll_multiplier;i.isInteracting&&i.DS.publish(["Interaction:update:pre","Interaction:update"],{event:e,scroll_directions:r,scroll_multiplier:n,isDragging:i.isDragging})})),n(this,"reset",(function(t){return i.DS.publish("Interaction:end:pre",{event:t,isDragging:i.isDragging})})),n(this,"_reset",(function(t){var e=i.isDragging;i.stop(),i.init(),i.DS.publish("Interaction:end",{event:t,isDragging:e})})),this.DS=s,this.DS.subscribe("Settings:updated:area",this.init),this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(t){var e=t.event;return i.start(e)})),this.DS.subscribe("Interaction:start:pre",(function(t){var e=t.event;return i._start(e)})),this.DS.subscribe("Interaction:init:pre",this._init),this.DS.subscribe("Interaction:end:pre",(function(t){var e=t.event;return i._reset(e)})),this.DS.subscribe("Area:scroll",this.update)}return r(e,[{key:"_canInteract",value:function(t){var e=0===t.clientX&&0===t.clientY&&0===t.detail&&t.target;return!(2===t.button||this.isInteracting||t.target&&!this.DS.SelectorArea.isInside(t.target)||!e&&!this.DS.SelectorArea.isClicked(t))}}]),e}(),j=function e(r){var i=this,s=r.DS;t(this,e),n(this,"subscribers",{}),n(this,"subscribe",(function(t,e){return Array.isArray(i.subscribers[t])||(i.subscribers[t]=[]),i.subscribers[t].push(e),i.subscribers[t].length-1})),n(this,"unsubscribe",(function(t,e,r){r>=0?i.subscribers[t].splice(r,1):e&&(i.subscribers[t]=i.subscribers[t].filter((function(t){return t!==e})))})),n(this,"publish",(function(t,e){Array.isArray(t)?t.forEach((function(t){return i._publish(t,e)})):i._publish(t,e)})),n(this,"_publish",(function(t,e){var r=i.subscribers[t];Array.isArray(r)&&(t.includes(":pre")?i._handlePrePublish(r,e):i._handlePublish(r,e))})),n(this,"_handlePublish",(function(t,e){for(var r=0,n=t.length;r<n;r++){if(i.DS.stopped)return;t[r](e)}})),n(this,"_handlePrePublish",(function(t,e){for(var r=t.length;r--;){if(i.DS.stopped)return;t[r](e)}})),this.DS=s},R=function(e){o(s,e);var i=f(s);function s(e){var r,o=e.DS;return t(this,s),n(h(r=i.call(this)),"init",(function(){return M(r.DS.stores.SettingsStore.s.selectables).forEach((function(t){return r.add(t)}))})),n(h(r),"clear",(function(){return r.forEach((function(t){return r.delete(t)}))})),n(h(r),"_onClick",(function(t){return r.DS.publish(["Selectable:click:pre","Selectable:click"],{event:t})})),n(h(r),"_onPointer",(function(t){return r.DS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:t})})),n(h(r),"addAll",(function(t){return t.forEach((function(t){return r.add(t)}))})),n(h(r),"deleteAll",(function(t){return t.forEach((function(t){return r.delete(t)}))})),r.DS=o,r.DS.subscribe("Interaction:init",r.init),r.DS.PubSub.subscribe("Settings:updated:selectables",(function(){r.clear(),r.init()})),r.DS.subscribe("Settings:updated:selectableClass",(function(t){var e=t.settings;r.forEach((function(t){t.classList.remove(e["selectableClass:pre"]),t.classList.add(e.selectableClass)}))})),r}return r(s,[{key:"add",value:function(t){if(!p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selectable:added:pre",e),t.classList.add(this.DS.stores.SettingsStore.s.selectableClass),t.addEventListener("click",this._onClick),t.addEventListener("mousedown",this._onPointer),t.addEventListener("touchstart",this._onPointer,{passive:!1}),this.DS.stores.SettingsStore.s.draggability&&!this.DS.stores.SettingsStore.s.useTransform&&k({computedStyle:window.getComputedStyle(t),node:t}),this.DS.publish("Selectable:added",e),p(a(s.prototype),"add",this).call(this,t)}}},{key:"delete",value:function(t){if(p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selectable:removed:pre",e),t.classList.remove(this.DS.stores.SettingsStore.s.selectableClass),t.classList.remove(this.DS.stores.SettingsStore.s.hoverClass),t.removeEventListener("click",this._onClick),t.removeEventListener("mousedown",this._onPointer),t.removeEventListener("touchstart",this._onPointer,{passive:!1}),this.DS.publish("Selectable:removed",e),p(a(s.prototype),"delete",this).call(this,t)}}},{key:"elements",get:function(){return Array.from(this.values())}}]),s}(d(Set)),z=function(e){o(s,e);var i=f(s);function s(e){var r,o=e.DS;return t(this,s),n(h(r=i.call(this)),"clear",(function(){return r.forEach((function(t){return r.delete(t)}))})),n(h(r),"addAll",(function(t){return t.forEach((function(t){return r.add(t)}))})),n(h(r),"deleteAll",(function(t){return t.forEach((function(t){return r.delete(t)}))})),r.DS=o,r}return r(s,[{key:"add",value:function(t){if(!p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selected:added:pre",e),p(a(s.prototype),"add",this).call(this,t),t.classList.add(this.DS.stores.SettingsStore.s.selectedClass),t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+1),this.DS.publish("Selected:added",e),this}}},{key:"delete",value:function(t){if(p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};this.DS.publish("Selected:removed:pre",e);var r=p(a(s.prototype),"delete",this).call(this,t);return t.classList.remove(this.DS.stores.SettingsStore.s.selectedClass),t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)-1),this.DS.publish("Selected:removed",e),r}}},{key:"toggle",value:function(t){return this.has(t)?this.delete(t):this.add(t),t}},{key:"elements",get:function(){return Array.from(this.values())}}]),s}(d(Set)),B=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_prevSelectedSet",void 0),n(this,"start",(function(t){var e=t.event;t.isDragging||(i._storePrevious(e),i._handleInsideSelection(!0,e))})),n(this,"update",(function(t){t.isDragging||i.DS.continue||i._handleInsideSelection()})),n(this,"_handleInsideSelection",(function(t,e){for(var r=i.DS,n=r.SelectableSet,s=r.SelectorArea,o=r.Selector,a=n.elements.map((function(t){return[t,t.getBoundingClientRect()]})),c=[],l=[],u=0,d=a.length;u<d;u++)s.isInside(a[u][0],a[u][1])&&(C(a[u][1],o.rect)?c.push(a[u][0]):l.push(a[u][0]));var h=i.DS.stores.KeyStore.isMultiSelectKeyPressed(e)&&i.DS.stores.SettingsStore.s.multiSelectToggling;i.DS.continue||(c.forEach((function(e){return function(t){var e=t.element,r=t.force,n=t.multiSelectionToggle,i=t.SelectedSet,s=t.hoverClassName;e.classList.contains(s)&&!r||(i.has(e)?n&&i.delete(e):i.add(e),e.classList.add(s))}({element:e,force:t,multiSelectionToggle:h,SelectedSet:i.DS.SelectedSet,hoverClassName:i.DS.stores.SettingsStore.s.hoverClass})})),l.forEach((function(e){return function(t){var e=t.element,r=t.force,n=t.SelectedSet,i=t.PrevSelectedSet,s=t.hoverClassName;if(!e.classList.contains(s)&&!r)return!1;var o=n.has(e),a=i.has(e);o&&!a?n.delete(e):!o&&a&&n.add(e),e.classList.remove(s)}({element:e,force:t,SelectedSet:i.DS.SelectedSet,hoverClassName:i.DS.stores.SettingsStore.s.hoverClass,PrevSelectedSet:i._prevSelectedSet})})))})),this.DS=s,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return r(e,[{key:"_storePrevious",value:function(t){var e=this.DS,r=e.stores.KeyStore,n=e.SelectedSet;r.isMultiSelectKeyPressed(t)?this._prevSelectedSet=new Set(n):this._prevSelectedSet=new Set}}]),e}(),W=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_rect",void 0),n(this,"attachSelector",(function(){var t,e,r,n;i.HTMLNode&&null!==(t=i.DS.SelectorArea)&&void 0!==t&&t.HTMLNode&&i.DS.SelectorArea.HTMLNode.removeChild(i.HTMLNode),i.HTMLNode=i.DS.stores.SettingsStore.s.selector||(r=i.DS.stores.SettingsStore.s.customStyles,(n=document.createElement("div")).style.position="absolute",r||(n.style.background="rgba(0, 0, 255, 0.1)",n.style.border="1px solid rgba(0, 0, 255, 0.45)",n.style.display="none",n.style.pointerEvents="none"),n),i.HTMLNode.classList.add(i.DS.stores.SettingsStore.s.selectorClass),i.HTMLNode&&null!==(e=i.DS.SelectorArea)&&void 0!==e&&e.HTMLNode&&i.DS.SelectorArea.HTMLNode.appendChild(i.HTMLNode)})),n(this,"start",(function(t){if(!t.isDragging){var e=i.DS.stores.PointerStore.initialValArea;N(i.HTMLNode,_(e,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(t){if(!t.isDragging&&!i.DS.continue){var e=i.DS.stores,r=e.ScrollStore,n=e.PointerStore,s=function(t){var e=t.scrollAmount,r=t.initialPointerPos,n=t.pointerPos,i={};return n.x>r.x-e.x?(i.left=r.x-e.x,i.width=n.x-r.x+e.x):(i.left=n.x,i.width=r.x-n.x-e.x),n.y>r.y-e.y?(i.top=r.y-e.y,i.height=n.y-r.y+e.y):(i.top=n.y,i.height=r.y-n.y-e.y),i}({scrollAmount:r.scrollAmount,initialPointerPos:n.initialValArea,pointerPos:n.currentValArea});N(i.HTMLNode,s),i._rect=null}})),this.DS=s,this.DS.subscribe("Settings:updated:selectorClass",(function(t){var e=t.settings;i.HTMLNode.classList.remove(e["selectorClass:pre"]),i.HTMLNode.classList.add(e.selectorClass)})),this.DS.subscribe("Settings:updated:selector",this.attachSelector),this.attachSelector(),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return r(e,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),e}(),F=function(){function e(r){var i,s=this,o=r.DS;t(this,e),n(this,"_scrollInterval",void 0),n(this,"_rect",void 0),n(this,"currentEdges",[]),n(this,"start",(function(){return s.applyElements("append")})),n(this,"applyElements",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",e=document.body?"body":"documentElement",r="".concat(t,"Child");s.HTMLNode[r](s.DS.Selector.HTMLNode),document[e][r](s.HTMLNode)})),n(this,"updatePos",(function(){s._rect=null;var t=s.DS.Area.rect,e=s.DS.Area.computedBorder,r=s.HTMLNode.style,n="".concat(t.top+e.top,"px"),i="".concat(t.left+e.left,"px"),o="".concat(t.width,"px"),a="".concat(t.height,"px");r.top!==n&&(r.top=n),r.left!==i&&(r.left=i),r.width!==o&&(r.width=o),r.height!==a&&(r.height=a)})),n(this,"stop",(function(t){s.stopAutoScroll(),t&&s.applyElements("remove")})),n(this,"startAutoScroll",(function(){s.currentEdges=[],s._scrollInterval=setInterval((function(){return s.handleAutoScroll()}),16)})),n(this,"handleAutoScroll",(function(){if(!s.DS.continue){var t=s.DS,e=t.stores.PointerStore,r=t.Area;s.currentEdges=P({elementRect:_(e.currentVal),containerRect:s.rect,tolerance:s.DS.stores.SettingsStore.s.overflowTolerance}),s.currentEdges.length&&r.scroll(s.currentEdges,s.DS.stores.SettingsStore.s.autoScrollSpeed)}})),n(this,"stopAutoScroll",(function(){s.currentEdges=[],clearInterval(s._scrollInterval)})),n(this,"isInside",(function(t,e){return!(!s.DS.Area.HTMLNode.contains(t)||!s.DS.stores.ScrollStore.canScroll)||C(s.rect,e||t.getBoundingClientRect())})),this.DS=o,this.HTMLNode=((i=document.createElement("div")).style.position="fixed",i.style.overflow="hidden",i.style.pointerEvents="none",i.style.zIndex="999999999999999999",i),this.DS.subscribe("Settings:updated:selectorAreaClass",(function(t){var e=t.settings;s.HTMLNode.classList.remove(e["selectorAreaClass:pre"]),s.HTMLNode.classList.add(e.selectorAreaClass)})),this.HTMLNode.classList.add(this.DS.stores.SettingsStore.s.selectorAreaClass),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:init",this.start),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){s.updatePos(),s.stopAutoScroll()}))}return r(e,[{key:"isClicked",value:function(t){var e=this.DS.stores.PointerStore,r=t?e.getPointerPosition(t):e.initialVal;return C({left:r.x,top:r.y,right:r.x,bottom:r.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),e}(),Z=function(){function e(r){var i=this,s=r.DS;t(this,e),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(t){var e=t.key.toLowerCase();i.DS.publish("KeyStore:down:pre",{event:t,key:e}),i._currentValues.add(e),i.DS.publish("KeyStore:down",{event:t,key:e})})),n(this,"keyup",(function(t){var e=t.key.toLowerCase();i.DS.publish("KeyStore:up:pre",{event:t,key:e}),i._currentValues.delete(e),i.DS.publish("KeyStore:up",{event:t,key:e})})),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=s,this.DS.subscribe("Interaction:init",this.init)}return r(e,[{key:"isMultiSelectKeyPressed",value:function(t){var e=this;if(this.DS.stores.SettingsStore.s.multiSelectMode)return!0;var r=this.DS.stores.SettingsStore.s.multiSelectKeys.map((function(t){return t.toLocaleLowerCase()}));return!!this.currentValues.some((function(t){return r.includes(t.toLocaleLowerCase())}))||!(!t||!r.some((function(r){return t[e._keyMapping[r]]})))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),e}(),U=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_isMouseInteraction",!1),n(this,"_initialValArea",void 0),n(this,"_currentValArea",void 0),n(this,"_lastValArea",void 0),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_lastVal",void 0),n(this,"_lastTouch",void 0),n(this,"init",(function(){document.addEventListener("mousemove",i.update),document.addEventListener("touchmove",i.update,{passive:!1})})),n(this,"getPointerPosition",(function(t){return function(t){var e=t.event;return{x:e.clientX,y:e.clientY}}({event:i._normalizedEvent(t)})})),n(this,"update",(function(t){t&&(i.DS.publish("PointerStore:updated:pre",{event:t}),i.currentVal=i.getPointerPosition(t),i._isMouseInteraction&&i.DS.publish("PointerStore:updated",{event:t}))})),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(t){t&&(i.currentVal=i.lastVal=i.getPointerPosition(t),i.stop(),i.init())})),this.DS=s,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(t){var e=t.event;return i.start(e)})),this.DS.subscribe("Interaction:end",(function(t){var e=t.event;return i.reset(e)}))}return r(e,[{key:"start",value:function(t){t&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(t))}},{key:"_normalizedEvent",value:function(t){return"touches"in t&&"touchend"!==t.type&&(this._lastTouch=t),"touches"in t?this._lastTouch.touches[0]:t}},{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(t){this._initialVal=t,this._initialValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(t){this._currentVal=t,this._currentValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(t){this._lastVal=t,this._lastValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}}]),e}(),X=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_canScroll",void 0),n(this,"init",(function(){return i.DS.stores.SettingsStore.s.area.addEventListener("scroll",i.update)})),n(this,"start",(function(){i._currentVal=i._initialVal=A(i.DS.stores.SettingsStore.s.area),i.DS.stores.SettingsStore.s.area.addEventListener("scroll",i.update)})),n(this,"update",(function(){return i._currentVal=A(i.DS.stores.SettingsStore.s.area)})),n(this,"stop",(function(){i.DS.stores.SettingsStore.s.area.removeEventListener("scroll",i.update),i._initialVal={x:0,y:0},i._canScroll=null})),n(this,"reset",(function(){i.stop(),i.start()})),this.DS=s,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(e,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(t=this.DS.stores.SettingsStore.s.area,!!((e=A(t)).x||e.y||(t instanceof HTMLDocument?t.body?t.body.scrollTop=1:t.documentElement.scrollTop=1:t.scrollTop=1)));var t,e}},{key:"scrollAmount",get:function(){var t,e=m(this.currentVal,"-",this.initialVal),r={x:t=this.DS.stores.SettingsStore.s.zoom,y:t},n=m(m(e,"*",r),"-",e);return{x:e.x+n.x,y:e.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=A(this.DS.stores.SettingsStore.s.area)),this._currentVal}}]),e}(),Y=function e(r){var i=this,o=r.DS,a=r.settings;t(this,e),n(this,"_settings",{}),n(this,"s",{}),n(this,"update",(function(t){var e=t.settings,r=t.init;return i.DS.publish("Settings:updated:pre",s({settings:e},r?{init:r}:{}))})),n(this,"_update",(function(t){for(var e=function(t,e){return s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s({},T("area",t.area,e,document)),T("selectables",t.selectables,e,null)),T("autoScrollSpeed",t.autoScrollSpeed,e,5)),T("overflowTolerance",t.overflowTolerance,e,{x:25,y:25})),T("zoom",t.zoom,e,1)),T("customStyles",t.customStyles,e,!1)),T("multiSelectMode",t.multiSelectMode,e,!1)),T("multiSelectToggling",t.multiSelectToggling,e,!0)),T("multiSelectKeys",t.multiSelectKeys,e,["Control","Shift","Meta"])),T("selector",t.selector,e,null)),T("draggability",t.draggability,e,!0)),T("immediateDrag",t.immediateDrag,e,!0)),T("keyboardDrag",t.keyboardDrag,e,!0)),T("dragKeys",t.dragKeys,e,{up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]})),T("keyboardDragSpeed",t.keyboardDragSpeed,e,10)),T("useTransform",t.useTransform,e,!0)),T("hoverClass",t.hoverClass,e,"ds-hover")),T("selectableClass",t.selectableClass,e,"ds-selectable")),T("selectedClass",t.selectedClass,e,"ds-selected")),T("selectorClass",t.selectorClass,e,"ds-selector")),T("selectorAreaClass",t.selectorAreaClass,e,"ds-selector-area"))}(t.settings,t.init),r=function(){var t,e=g(a[o],2),r=e[0],s=e[1];r in i._settings||Object.defineProperty(i.s,r,{get:function(){return i._settings[r]},set:function(t){return i.update({settings:n({},r,t)})}}),i._settings["".concat(r,":pre")]=i._settings[r],i._settings[r]=s;var c={settings:(t={},n(t,r,i._settings[r]),n(t,"".concat(r,":pre"),i._settings["".concat(r,":pre")]),t)};i.DS.publish("Settings:updated",c),i.DS.publish("Settings:updated:".concat(r),c)},o=0,a=Object.entries(e);o<a.length;o++)r()})),this.DS=o,this.DS.subscribe("Settings:updated:pre",this._update),this.update({settings:a,init:!0})},G=function(){function e(r){var i=this;t(this,e),n(this,"continue",!1),n(this,"start",(function(){i.stopped=!1,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(t){return i.stores.KeyStore.isMultiSelectKeyPressed(t)})),n(this,"isDragging",(function(){return i.Interaction.isDragging})),n(this,"setSettings",(function(t){return i.stores.SettingsStore.update({settings:t})})),this.PubSub=new j({DS:this}),this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this.stores={},this.stores.SettingsStore=new Y({DS:this,settings:r}),this.stores.PointerStore=new U({DS:this}),this.stores.ScrollStore=new X({DS:this}),this.stores.KeyStore=new Z({DS:this}),this.Area=new K({DS:this}),this.Selector=new W({DS:this}),this.SelectorArea=new F({DS:this}),this.SelectableSet=new R({DS:this}),this.SelectedSet=new z({DS:this}),this.Selection=new B({DS:this}),this.Drag=new O({DS:this}),this.Interaction=new H({DS:this}),function(t){for(var e=t.subscribe,r=t.publish,n=t.Interaction,i=t.SelectedSet,o=function(){var t=g(c[a],2),o=t[0],l=t[1];["pre",!1].forEach((function(t){return e(t?"".concat(o,":").concat(t):o,(function(e){return l.forEach((function(o){return(!o.condition||o.condition(e))&&r(t?"".concat(t).concat(o.name):o.name,s({items:i.elements,isDragging:n.isDragging},e))}))}))}))},a=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(t){return t.event}}],"Interaction:end":[{name:"callback"}]});a<c.length;a++)o()}({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(e,[{key:"stop",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=!(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(t),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),t&&this.SelectableSet.clear(),e&&this.SelectedSet.clear(),this.stopped=!0}},{key:"addSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(M(t)),r||this.addSelectables(t),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(M(t)),r&&this.removeSelectables(t),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return M(t).forEach((function(i){return e.SelectedSet.has(i)?e.removeSelection(t,r,n):e.addSelection(t,r,n)})),r&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(t,e,r),this.getSelection()}},{key:"clearSelection",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=M(t);return this.SelectableSet.addAll(r),e&&this.SelectedSet.addAll(r),t}},{key:"setSelectables",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return console.warn('[DragSelect] DEPRECATION ".setSelectables" is deprecated and will be removed soon. Please use "ds.setSettings({ selectables: << new dom elements >> })" instead (see docs)'),this.removeSelectables(t,e),this.addSelectables(t,r)}},{key:"removeSelectables",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.SelectableSet.deleteAll(M(t)),e&&this.removeSelection(t),t}}]),e}();return G})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).DragSelect=e()}(this,(function(){"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function r(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}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(t){return!1}}function u(t,e,r){return u=l()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&c(i,r.prototype),i},u.apply(null,arguments)}function d(t){var e="function"==typeof Map?new Map:void 0;return d=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return u(t,arguments,a(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)},d(t)}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function S(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?h(t):e}function f(t){var e=l();return function(){var r,n=a(t);if(e){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return S(this,r)}}function p(t,e,r){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=a(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},p(t,e,r||t)}function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,i=!1,s=void 0;try{for(var o,a=t[Symbol.iterator]();!(n=(o=a.next()).done)&&(r.push(o.value),!e||r.length!==e);n=!0);}catch(t){i=!0,s=t}finally{try{n||null==a.return||a.return()}finally{if(i)throw s}}return r}(t,e)||v(t,e)||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 b(t){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||v(t)||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 v(t,e){if(t){if("string"==typeof t)return y(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var m=function(t,e,r){var n=t.x,i=t.y,s=r.x,o=r.y;return{"+":{x:n+s,y:i+o},"-":{x:n-s,y:i-o},"*":{x:n*s,y:i*o},"/":{x:n/s,y:i/o}}[e]},D=function(t){return{x:t.left,y:t.top}},_=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:t.x,top:t.y,right:t.x,bottom:t.y,width:e,height:e}},w=function(){var t,e,r,n;return{y:(null===(t=document.body)||void 0===t?void 0:t.scrollTop)||(null===(e=document.documentElement)||void 0===e?void 0:e.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}},A=function(t){return!t||t instanceof Document?w():{x:t.scrollLeft>=0?t.scrollLeft:w().x,y:t.scrollTop>=0?t.scrollTop:w().y}},P=function(t){var e=t.elementRect,r=t.containerRect,n=t.tolerance,i=void 0===n?{x:0,y:0}:n,s=[];return e.top-i.y<r.top&&s.push("top"),e.left-i.x<r.left&&s.push("left"),e.bottom+i.y>r.bottom&&s.push("bottom"),e.right+i.y>r.right&&s.push("right"),s},L=function(t){var e={x:0,y:0},r=window.getComputedStyle(t);if(!r.transform||"none"===r.transform)return e;if(r.transform.indexOf("3d")>=0){var n=r.transform.trim().match(/matrix3d\((.*?)\)/);if(n&&n.length){var i,s=null===(i=n[1])||void 0===i?void 0:i.split(",");e.x=parseInt(s[12])||0,e.y=parseInt(s[13])||0}return e}var o=r.transform.trim().match(/matrix\((.*?)\)/);if(o&&o.length){var a,c=null===(a=o[1])||void 0===a?void 0:a.split(",");e.x=parseInt(c[4])||0,e.y=parseInt(c[5])||0}return e},k=function(t,e){return e?function(t){var e=t.style.transform;if(!e||e.indexOf("translate")<0)return L(t);var r={x:0,y:0},n=e.trim().match(/translate[3dD]*?\(.*?\)/);if(n){var i,s=null===(i=n[0])||void 0===i?void 0:i.split("(");if(s){var o,a=null===(o=s[1])||void 0===o?void 0:o.split(",");r.x=parseInt(a[0])||0,r.y=parseInt(a[1])||0}}return r.x||r.x?r:L(t)}(t):function(t){var e=t.style,r={x:parseInt(e.left)||0,y:parseInt(e.top)||0};if(!r.x&&!r.x){var n=window.getComputedStyle(t);return{x:parseInt(n.left)||0,y:parseInt(n.top)||0}}return r}(t)},x=function(t){var e=t.computedStyle,r=t.node,n=e.position;r instanceof HTMLDocument||("absolute"===n||"relative"===n||"fixed"===n)||(r.style.position="relative")},I=function(t,e,r){return console.warn('[DragSelect] TypeIssue: setting "'.concat(t,'" is not of type "').concat(e,'".'))},T=function(t,e,r,i){if(void 0===e)return r?n({},t,i):{};if(null===e)return n({},t,null);var s=!0,o=!1,a="string"==typeof i;a&&(s="string"==typeof e||e instanceof String),a&&!s&&(o=!0,I(t,"string"));var c=!isNaN(i)&&"number"==typeof i;c&&(s=!isNaN(e)&&"number"==typeof e),c&&!s&&(o=!0,I(t,"number"));var l="[object Object]"===Object.prototype.toString.call(i);l&&(s="[object Object]"===Object.prototype.toString.call(e)),l&&!s&&(o=!0,I(t,"object"));var u="boolean"==typeof i;u&&(s="boolean"==typeof e),u&&!s&&(o=!0,I(t,"boolean"));var d=Array.isArray(i);d&&(s=Array.isArray(e)),d&&!s&&(o=!0,I(t,"array"));var h=o||r;return"dragKeys"===t&&s?n({},t,Object.assign(i,e)):("dragKeys"!==t||s)&&s?n({},t,e):h?n({},t,i):{}},C=function(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top},E=function(t){var e=t.element,r=t.posDirection,n=t.containerRect,i=t.useTransform,s=k(e,i),o=m(s,"+",r);V(e,o,i);var a=e.getBoundingClientRect();!function(t){var e=t.element,r=t.edges,n=t.elementRect,i=t.containerRect,s=t.elementPos,o=t.useTransform;r.includes("top")&&V(e,{y:s.y+i.top-n.top,x:s.x},o),r.includes("left")&&V(e,{y:s.y,x:s.x+i.left-n.left},o),r.includes("bottom")&&V(e,{y:s.y+i.bottom-n.bottom,x:s.x},o),r.includes("right")&&V(e,{y:s.y,x:s.x+i.right-n.right},o)}({element:e,edges:P({elementRect:a,containerRect:n}),elementRect:a,containerRect:n,elementPos:o,useTransform:i})},V=function(t,e,r){if(r){var n=t.style.transform;t.style.transform="translate3d(".concat(e.x,"px,").concat(e.y,"px,1px) ").concat(n.replace(/translate.*?\)/g,""))}else t.style.left="".concat(e.x,"px"),t.style.top="".concat(e.y,"px");return t},M=function(t){return t?!Array.isArray(t)&&(t instanceof HTMLElement||t instanceof SVGElement)?[t]:b(t):[]},N=function(t,e){t.style.left="".concat(e.left,"px"),t.style.top="".concat(e.top,"px"),t.style.width="".concat(e.width,"px"),t.style.height="".concat(e.height,"px")},K=function(){function e(r){var i,s,o,a=this,c=r.DS;t(this,e),n(this,"DS",void 0),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,"setArea",(function(t){a._node=t,x({computedStyle:a.computedStyle,node:a._node}),setTimeout((function(){a.DS.PubSub.publish("Area:modified:pre",{item:a}),a.reset(),a.DS.PubSub.publish("Area:modified",{item:a})}))})),n(this,"start",(function(){var t,e,r;t=a.parentNodes,e=a._modificationCallback,r=a._modificationObserver,window.addEventListener("resize",e),window.addEventListener("scroll",e),t.forEach((function(t,e){r.observe(t,{childList:0!==e,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 t,e;t=a._modificationObserver,e=a._modificationCallback,window.removeEventListener("resize",e),window.removeEventListener("scroll",e),t.disconnect(),a.reset()})),n(this,"scroll",(function(t,e){var r={scroll_directions:t,scroll_multiplier:e};a.DS.PubSub.publish("Area:scroll:pre",r),function(t,e,r){if(e.length){var n=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,i=t instanceof HTMLDocument?n||document.body:t,s=e.includes("top")&&i.scrollTop>0,o=e.includes("bottom")&&i.scrollTop<i.scrollHeight,a=e.includes("left")&&i.scrollLeft>0,c=e.includes("right")&&i.scrollLeft<i.scrollWidth;s&&(i.scrollTop-=1*r),o&&(i.scrollTop+=1*r),a&&(i.scrollLeft-=1*r),c&&(i.scrollLeft+=1*r)}}(a._node,t,e),a.DS.PubSub.publish("Area:scroll",r)})),this.DS=c,this.setArea(this.DS.stores.SettingsStore.s.area),this.DS.PubSub.subscribe("Settings:updated:area",(function(t){var e=t.settings;return a.setArea(e.area)})),this._modificationCallback=(i=function(t){a.DS.PubSub.publish("Area:modified:pre",{event:t,item:a}),a.reset(),a.DS.PubSub.publish("Area:modified",{event:t,item:a})},s=60,function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=function(){o=null,i.apply(void 0,e)};clearTimeout(o),o=setTimeout(n,s)}),this._modificationObserver=new MutationObserver(this._modificationCallback),this.DS.PubSub.subscribe("Interaction:init",this.start),this.DS.PubSub.subscribe("Interaction:end",this.reset)}return r(e,[{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(t,e){if(t instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var r=t.getBoundingClientRect();return{top:r.top,left:r.left,bottom:r.bottom,right:r.right,width:(t.clientWidth||r.width)*e,height:(t.clientHeight||r.height)*e}}(this.HTMLNode,this.DS.stores.SettingsStore.s.zoom)}},{key:"parentNodes",get:function(){if(this._parentNodes)return this._parentNodes;return this._parentNodes=function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=null===(r=e[n])||void 0===r?void 0:r.parentNode;return i?(e.push(i),t(e,++n)):e}([this.HTMLNode]),this._parentNodes}}]),e}(),O=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_prevCursorPos",void 0),n(this,"_prevScrollPos",void 0),n(this,"_elements",[]),n(this,"_dragKeys",void 0),n(this,"_dragKeysFlat",[]),n(this,"assignDragkeys",(function(){i._dragKeys={up:i.DS.stores.SettingsStore.s.dragKeys.up.map((function(t){return t.toLowerCase()})),down:i.DS.stores.SettingsStore.s.dragKeys.down.map((function(t){return t.toLowerCase()})),left:i.DS.stores.SettingsStore.s.dragKeys.left.map((function(t){return t.toLowerCase()})),right:i.DS.stores.SettingsStore.s.dragKeys.right.map((function(t){return t.toLowerCase()}))},i._dragKeysFlat=[].concat(b(i._dragKeys.up),b(i._dragKeys.down),b(i._dragKeys.left),b(i._dragKeys.right))})),n(this,"keyboardDrag",(function(t){var e=t.event,r=t.key.toLowerCase();if(i.DS.stores.SettingsStore.s.keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i.DS.stores.SettingsStore.s.draggability&&!i.DS.continue){var n={event:e,isDragging:!0,isDraggingKeyboard:!0};i.DS.publish(["Interaction:start:pre","Interaction:start"],n),i._elements=i.DS.getSelection(),i.handleZIndex(!0);var s=function(t){var e=t.shiftKey,r=t.keyboardDragSpeed,n=t.zoom,i=t.key,s=t.dragKeys,o=t.scrollDiff,a=t.canScroll,c=t.scrollCallback,l={x:0,y:0},u=e?4*r*n:r*n;return s.left.includes(i)&&(l.x=o.x||-u,e||o.x||!a||c(["left"],r)),s.right.includes(i)&&(l.x=o.x||u,e||o.x||!a||c(["right"],r)),s.up.includes(i)&&(l.y=o.y||-u,e||o.y||!a||c(["top"],r)),s.down.includes(i)&&(l.y=o.y||u,e||o.y||!a||c(["bottom"],r)),l}({shiftKey:i.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:i.DS.stores.SettingsStore.s.keyboardDragSpeed,zoom:i.DS.stores.SettingsStore.s.zoom,key:r,scrollCallback:i.DS.Area.scroll,scrollDiff:i._scrollDiff,canScroll:i.DS.stores.ScrollStore.canScroll,dragKeys:i._dragKeys});i._elements.forEach((function(t){return E({element:t,posDirection:s,containerRect:i.DS.SelectorArea.rect,useTransform:i.DS.stores.SettingsStore.s.useTransform})})),i.DS.publish(["Interaction:update:pre","Interaction:update"],n)}})),n(this,"keyboardEnd",(function(t){var e=t.event,r=t.key.toLowerCase();if(i.DS.stores.SettingsStore.s.keyboardDrag&&i._dragKeysFlat.includes(r)&&i.DS.SelectedSet.size&&i.DS.stores.SettingsStore.s.draggability){var n={event:e,isDragging:i.DS.stores.SettingsStore.s.draggability,isDraggingKeyboard:!0};i.DS.publish(["Interaction:end:pre","Interaction:end"],n)}})),n(this,"start",(function(t){var e=t.isDragging,r=t.isDraggingKeyboard;e&&!r&&(i._prevCursorPos=null,i._prevScrollPos=null,i._elements=i.DS.getSelection(),i.handleZIndex(!0))})),n(this,"stop",(function(t){null!=t&&t.isKeyboard||(i._prevCursorPos=null,i._prevScrollPos=null,i.handleZIndex(!1),i._elements=[])})),n(this,"update",(function(t){var e=t.isDragging,r=t.isDraggingKeyboard;if(e&&i._elements.length&&!r&&!i.DS.continue){var n=m(i._cursorDiff,"+",i._scrollDiff);i._elements.forEach((function(t){return E({element:t,posDirection:n,containerRect:i.DS.SelectorArea.rect,useTransform:i.DS.stores.SettingsStore.s.useTransform})}))}})),n(this,"handleZIndex",(function(t){i._elements.forEach((function(e){return e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+t?9999:-9998)}))})),this.DS=s,this.DS.subscribe("Settings:updated:dragKeys",this.assignDragkeys),this.assignDragkeys(),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(e,[{key:"_cursorDiff",get:function(){var t=this.DS.stores.PointerStore.currentVal,e=this._prevCursorPos?m(t,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=t,e}},{key:"_scrollDiff",get:function(){var t=this.DS.stores.ScrollStore.currentVal,e=this._prevScrollPos?m(t,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=t,e}}]),e}(),H=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"isInteracting",void 0),n(this,"isDragging",void 0),n(this,"init",(function(){return i.DS.publish("Interaction:init:pre",{})})),n(this,"_init",(function(){i.stop(),i.DS.Area.HTMLNode.addEventListener("mousedown",i.start),i.DS.Area.HTMLNode.addEventListener("touchstart",i.start,{passive:!1}),i.DS.publish("Interaction:init",{})})),n(this,"start",(function(t){return i.DS.publish("Interaction:start:pre",{event:t,isDragging:i.isDragging})})),n(this,"_start",(function(t){"touchstart"===t.type&&t.preventDefault(),i._canInteract(t)&&(i.isInteracting=!0,i.isDragging=i.isDragEvent(t),i.DS.publish("Interaction:start",{event:t,isDragging:i.isDragging}),document.addEventListener("mouseup",i.reset),document.addEventListener("touchend",i.reset))})),n(this,"isDragEvent",(function(t){var e=t.target.closest(".".concat(i.DS.stores.SettingsStore.s.selectableClass));return!(!i.DS.stores.SettingsStore.s.draggability||i.DS.stores.KeyStore.isMultiSelectKeyPressed(t)||!e)&&(i.DS.stores.SettingsStore.s.immediateDrag&&(i.DS.SelectedSet.size?i.DS.SelectedSet.has(e)||(i.DS.SelectedSet.clear(),i.DS.SelectedSet.add(e)):i.DS.SelectedSet.add(e)),!!i.DS.SelectedSet.has(e))})),n(this,"onClick",(function(t){var e=t.event;if(i._canInteract(e)&&!(e.detail>0)){var r=i.DS,n=r.stores,s=n.PointerStore,o=n.KeyStore,a=r.SelectableSet,c=r.SelectedSet;s.start(e);var l=e.target;a.has(l)&&(o.isMultiSelectKeyPressed(e)||c.clear(),c.toggle(l),i.reset())}})),n(this,"stop",(function(){i.isInteracting=!1,i.isDragging=!1,i.DS.Area.HTMLNode.removeEventListener("mousedown",i.start),i.DS.Area.HTMLNode.removeEventListener("touchstart",i.start,{passive:!1}),document.removeEventListener("mouseup",i.reset),document.removeEventListener("touchend",i.reset)})),n(this,"update",(function(t){var e=t.event,r=t.scroll_directions,n=t.scroll_multiplier;i.isInteracting&&i.DS.publish(["Interaction:update:pre","Interaction:update"],{event:e,scroll_directions:r,scroll_multiplier:n,isDragging:i.isDragging})})),n(this,"reset",(function(t){return i.DS.publish("Interaction:end:pre",{event:t,isDragging:i.isDragging})})),n(this,"_reset",(function(t){var e=i.isDragging;i.stop(),i.init(),i.DS.publish("Interaction:end",{event:t,isDragging:e})})),this.DS=s,this.DS.subscribe("Settings:updated:area",this.init),this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(t){var e=t.event;return i.start(e)})),this.DS.subscribe("Interaction:start:pre",(function(t){var e=t.event;return i._start(e)})),this.DS.subscribe("Interaction:init:pre",this._init),this.DS.subscribe("Interaction:end:pre",(function(t){var e=t.event;return i._reset(e)})),this.DS.subscribe("Area:scroll",this.update)}return r(e,[{key:"_canInteract",value:function(t){var e=0===t.clientX&&0===t.clientY&&0===t.detail&&t.target;return!(2===t.button||this.isInteracting||t.target&&!this.DS.SelectorArea.isInside(t.target)||!e&&!this.DS.SelectorArea.isClicked(t))}}]),e}(),j=function e(r){var i=this,s=r.DS;t(this,e),n(this,"subscribers",{}),n(this,"subscribe",(function(t,e){return Array.isArray(i.subscribers[t])||(i.subscribers[t]=[]),i.subscribers[t].push(e),i.subscribers[t].length-1})),n(this,"unsubscribe",(function(t,e,r){r>=0?i.subscribers[t].splice(r,1):e&&(i.subscribers[t]=i.subscribers[t].filter((function(t){return t!==e})))})),n(this,"publish",(function(t,e){Array.isArray(t)?t.forEach((function(t){return i._publish(t,e)})):i._publish(t,e)})),n(this,"_publish",(function(t,e){var r=i.subscribers[t];Array.isArray(r)&&(t.includes(":pre")?i._handlePrePublish(r,e):i._handlePublish(r,e))})),n(this,"_handlePublish",(function(t,e){for(var r=0,n=t.length;r<n;r++){if(i.DS.stopped)return;t[r](e)}})),n(this,"_handlePrePublish",(function(t,e){for(var r=t.length;r--;){if(i.DS.stopped)return;t[r](e)}})),this.DS=s},R=function(e){o(s,e);var i=f(s);function s(e){var r,o=e.DS;return t(this,s),n(h(r=i.call(this)),"init",(function(){return M(r.DS.stores.SettingsStore.s.selectables).forEach((function(t){return r.add(t)}))})),n(h(r),"clear",(function(){return r.forEach((function(t){return r.delete(t)}))})),n(h(r),"_onClick",(function(t){return r.DS.publish(["Selectable:click:pre","Selectable:click"],{event:t})})),n(h(r),"_onPointer",(function(t){return r.DS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:t})})),n(h(r),"addAll",(function(t){return t.forEach((function(t){return r.add(t)}))})),n(h(r),"deleteAll",(function(t){return t.forEach((function(t){return r.delete(t)}))})),r.DS=o,r.DS.subscribe("Interaction:init",r.init),r.DS.PubSub.subscribe("Settings:updated:selectables",(function(){r.clear(),r.init()})),r.DS.subscribe("Settings:updated:selectableClass",(function(t){var e=t.settings;r.forEach((function(t){t.classList.remove(e["selectableClass:pre"]),t.classList.add(e.selectableClass)}))})),r}return r(s,[{key:"add",value:function(t){if(!p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selectable:added:pre",e),t.classList.add(this.DS.stores.SettingsStore.s.selectableClass),t.addEventListener("click",this._onClick),t.addEventListener("mousedown",this._onPointer),t.addEventListener("touchstart",this._onPointer,{passive:!1}),this.DS.stores.SettingsStore.s.draggability&&!this.DS.stores.SettingsStore.s.useTransform&&x({computedStyle:window.getComputedStyle(t),node:t}),this.DS.publish("Selectable:added",e),p(a(s.prototype),"add",this).call(this,t)}}},{key:"delete",value:function(t){if(p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selectable:removed:pre",e),t.classList.remove(this.DS.stores.SettingsStore.s.selectableClass),t.classList.remove(this.DS.stores.SettingsStore.s.hoverClass),t.removeEventListener("click",this._onClick),t.removeEventListener("mousedown",this._onPointer),t.removeEventListener("touchstart",this._onPointer,{passive:!1}),this.DS.publish("Selectable:removed",e),p(a(s.prototype),"delete",this).call(this,t)}}},{key:"elements",get:function(){return Array.from(this.values())}}]),s}(d(Set)),z=function(e){o(s,e);var i=f(s);function s(e){var r,o=e.DS;return t(this,s),n(h(r=i.call(this)),"clear",(function(){return r.forEach((function(t){return r.delete(t)}))})),n(h(r),"addAll",(function(t){return t.forEach((function(t){return r.add(t)}))})),n(h(r),"deleteAll",(function(t){return t.forEach((function(t){return r.delete(t)}))})),r.DS=o,r}return r(s,[{key:"add",value:function(t){if(!p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};return this.DS.publish("Selected:added:pre",e),p(a(s.prototype),"add",this).call(this,t),t.classList.add(this.DS.stores.SettingsStore.s.selectedClass),t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+1),this.DS.publish("Selected:added",e),this}}},{key:"delete",value:function(t){if(p(a(s.prototype),"has",this).call(this,t)){var e={items:this.elements,item:t};this.DS.publish("Selected:removed:pre",e);var r=p(a(s.prototype),"delete",this).call(this,t);return t.classList.remove(this.DS.stores.SettingsStore.s.selectedClass),t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)-1),this.DS.publish("Selected:removed",e),r}}},{key:"toggle",value:function(t){return this.has(t)?this.delete(t):this.add(t),t}},{key:"elements",get:function(){return Array.from(this.values())}}]),s}(d(Set)),B=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_prevSelectedSet",void 0),n(this,"start",(function(t){var e=t.event;t.isDragging||(i._storePrevious(e),i._handleInsideSelection(!0,e))})),n(this,"update",(function(t){t.isDragging||i.DS.continue||i._handleInsideSelection()})),n(this,"_handleInsideSelection",(function(t,e){for(var r=i.DS,n=r.SelectableSet,s=r.SelectorArea,o=r.Selector,a=n.elements.map((function(t){return[t,t.getBoundingClientRect()]})),c=[],l=[],u=0,d=a.length;u<d;u++)s.isInside(a[u][0],a[u][1])&&(C(a[u][1],o.rect)?c.push(a[u][0]):l.push(a[u][0]));var h=i.DS.stores.KeyStore.isMultiSelectKeyPressed(e)&&i.DS.stores.SettingsStore.s.multiSelectToggling;i.DS.continue||(c.forEach((function(e){return function(t){var e=t.element,r=t.force,n=t.multiSelectionToggle,i=t.SelectedSet,s=t.hoverClassName;e.classList.contains(s)&&!r||(i.has(e)?n&&i.delete(e):i.add(e),e.classList.add(s))}({element:e,force:t,multiSelectionToggle:h,SelectedSet:i.DS.SelectedSet,hoverClassName:i.DS.stores.SettingsStore.s.hoverClass})})),l.forEach((function(e){return function(t){var e=t.element,r=t.force,n=t.SelectedSet,i=t.PrevSelectedSet,s=t.hoverClassName;if(!e.classList.contains(s)&&!r)return!1;var o=n.has(e),a=i.has(e);o&&!a?n.delete(e):!o&&a&&n.add(e),e.classList.remove(s)}({element:e,force:t,SelectedSet:i.DS.SelectedSet,hoverClassName:i.DS.stores.SettingsStore.s.hoverClass,PrevSelectedSet:i._prevSelectedSet})})))})),this.DS=s,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return r(e,[{key:"_storePrevious",value:function(t){var e=this.DS,r=e.stores.KeyStore,n=e.SelectedSet;r.isMultiSelectKeyPressed(t)?this._prevSelectedSet=new Set(n):this._prevSelectedSet=new Set}}]),e}(),W=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_rect",void 0),n(this,"attachSelector",(function(){var t,e,r,n;i.HTMLNode&&null!==(t=i.DS.SelectorArea)&&void 0!==t&&t.HTMLNode&&i.DS.SelectorArea.HTMLNode.removeChild(i.HTMLNode),i.HTMLNode=i.DS.stores.SettingsStore.s.selector||(r=i.DS.stores.SettingsStore.s.customStyles,(n=document.createElement("div")).style.position="absolute",r||(n.style.background="rgba(0, 0, 255, 0.1)",n.style.border="1px solid rgba(0, 0, 255, 0.45)",n.style.display="none",n.style.pointerEvents="none"),n),i.HTMLNode.classList.add(i.DS.stores.SettingsStore.s.selectorClass),i.HTMLNode&&null!==(e=i.DS.SelectorArea)&&void 0!==e&&e.HTMLNode&&i.DS.SelectorArea.HTMLNode.appendChild(i.HTMLNode)})),n(this,"start",(function(t){if(!t.isDragging){var e=i.DS.stores.PointerStore.initialValArea;N(i.HTMLNode,_(e,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(t){if(!t.isDragging&&!i.DS.continue){var e=i.DS.stores,r=e.ScrollStore,n=e.PointerStore,s=function(t){var e=t.scrollAmount,r=t.initialPointerPos,n=t.pointerPos,i={};return n.x>r.x-e.x?(i.left=r.x-e.x,i.width=n.x-r.x+e.x):(i.left=n.x,i.width=r.x-n.x-e.x),n.y>r.y-e.y?(i.top=r.y-e.y,i.height=n.y-r.y+e.y):(i.top=n.y,i.height=r.y-n.y-e.y),i}({scrollAmount:r.scrollAmount,initialPointerPos:n.initialValArea,pointerPos:n.currentValArea});N(i.HTMLNode,s),i._rect=null}})),this.DS=s,this.DS.subscribe("Settings:updated:selectorClass",(function(t){var e=t.settings;i.HTMLNode.classList.remove(e["selectorClass:pre"]),i.HTMLNode.classList.add(e.selectorClass)})),this.DS.subscribe("Settings:updated:selector",this.attachSelector),this.attachSelector(),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update),this.DS.subscribe("Interaction:end",this.stop)}return r(e,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),e}(),F=function(){function e(r){var i,s=this,o=r.DS;t(this,e),n(this,"_scrollInterval",void 0),n(this,"_rect",void 0),n(this,"currentEdges",[]),n(this,"start",(function(){return s.applyElements("append")})),n(this,"applyElements",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",e=document.body?"body":"documentElement",r="".concat(t,"Child");s.HTMLNode[r](s.DS.Selector.HTMLNode),document[e][r](s.HTMLNode)})),n(this,"updatePos",(function(){s._rect=null;var t=s.DS.Area.rect,e=s.DS.Area.computedBorder,r=s.HTMLNode.style,n="".concat(t.top+e.top,"px"),i="".concat(t.left+e.left,"px"),o="".concat(t.width,"px"),a="".concat(t.height,"px");r.top!==n&&(r.top=n),r.left!==i&&(r.left=i),r.width!==o&&(r.width=o),r.height!==a&&(r.height=a)})),n(this,"stop",(function(t){s.stopAutoScroll(),t&&s.applyElements("remove")})),n(this,"startAutoScroll",(function(){s.currentEdges=[],s._scrollInterval=setInterval((function(){return s.handleAutoScroll()}),16)})),n(this,"handleAutoScroll",(function(){if(!s.DS.continue){var t=s.DS,e=t.stores.PointerStore,r=t.Area;s.currentEdges=P({elementRect:_(e.currentVal),containerRect:s.rect,tolerance:s.DS.stores.SettingsStore.s.overflowTolerance}),s.currentEdges.length&&r.scroll(s.currentEdges,s.DS.stores.SettingsStore.s.autoScrollSpeed)}})),n(this,"stopAutoScroll",(function(){s.currentEdges=[],clearInterval(s._scrollInterval)})),n(this,"isInside",(function(t,e){return!(!s.DS.Area.HTMLNode.contains(t)||!s.DS.stores.ScrollStore.canScroll)||C(s.rect,e||t.getBoundingClientRect())})),this.DS=o,this.HTMLNode=((i=document.createElement("div")).style.position="fixed",i.style.overflow="hidden",i.style.pointerEvents="none",i.style.zIndex="999999999999999999",i),this.DS.subscribe("Settings:updated:selectorAreaClass",(function(t){var e=t.settings;s.HTMLNode.classList.remove(e["selectorAreaClass:pre"]),s.HTMLNode.classList.add(e.selectorAreaClass)})),this.HTMLNode.classList.add(this.DS.stores.SettingsStore.s.selectorAreaClass),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Area:modified",this.updatePos),this.DS.subscribe("Interaction:init",this.start),this.DS.subscribe("Interaction:start",this.startAutoScroll),this.DS.subscribe("Interaction:end",(function(){s.updatePos(),s.stopAutoScroll()}))}return r(e,[{key:"isClicked",value:function(t){var e=this.DS.stores.PointerStore,r=t?e.getPointerPosition(t):e.initialVal;return C({left:r.x,top:r.y,right:r.x,bottom:r.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),e}(),Z=function(){function e(r){var i=this,s=r.DS;t(this,e),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(t){var e=t.key.toLowerCase();i.DS.publish("KeyStore:down:pre",{event:t,key:e}),i._currentValues.add(e),i.DS.publish("KeyStore:down",{event:t,key:e})})),n(this,"keyup",(function(t){var e=t.key.toLowerCase();i.DS.publish("KeyStore:up:pre",{event:t,key:e}),i._currentValues.delete(e),i.DS.publish("KeyStore:up",{event:t,key:e})})),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=s,this.DS.subscribe("Interaction:init",this.init)}return r(e,[{key:"isMultiSelectKeyPressed",value:function(t){var e=this;if(this.DS.stores.SettingsStore.s.multiSelectMode)return!0;var r=this.DS.stores.SettingsStore.s.multiSelectKeys.map((function(t){return t.toLocaleLowerCase()}));return!!this.currentValues.some((function(t){return r.includes(t.toLocaleLowerCase())}))||!(!t||!r.some((function(r){return t[e._keyMapping[r]]})))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),e}(),U=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_isMouseInteraction",!1),n(this,"_initialValArea",void 0),n(this,"_currentValArea",void 0),n(this,"_lastValArea",void 0),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_lastVal",void 0),n(this,"_lastTouch",void 0),n(this,"init",(function(){document.addEventListener("mousemove",i.update),document.addEventListener("touchmove",i.update,{passive:!1})})),n(this,"getPointerPosition",(function(t){return function(t){var e=t.event;return{x:e.clientX,y:e.clientY}}({event:i._normalizedEvent(t)})})),n(this,"update",(function(t){t&&(i.DS.publish("PointerStore:updated:pre",{event:t}),i.currentVal=i.getPointerPosition(t),i._isMouseInteraction&&i.DS.publish("PointerStore:updated",{event:t}))})),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(t){t&&(i.currentVal=i.lastVal=i.getPointerPosition(t),i.stop(),i.init())})),this.DS=s,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(t){var e=t.event;return i.start(e)})),this.DS.subscribe("Interaction:end",(function(t){var e=t.event;return i.reset(e)}))}return r(e,[{key:"start",value:function(t){t&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(t))}},{key:"_normalizedEvent",value:function(t){return"touches"in t&&"touchend"!==t.type&&(this._lastTouch=t),"touches"in t?this._lastTouch.touches[0]:t}},{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(t){this._initialVal=t,this._initialValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(t){this._currentVal=t,this._currentValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(t){this._lastVal=t,this._lastValArea=t&&m(t,"-",m(D(this.DS.Area.rect),"+",D(this.DS.Area.computedBorder)))}}]),e}(),X=function(){function e(r){var i=this,s=r.DS;t(this,e),n(this,"_initialVal",void 0),n(this,"_currentVal",void 0),n(this,"_canScroll",void 0),n(this,"init",(function(){return i.DS.stores.SettingsStore.s.area.addEventListener("scroll",i.update)})),n(this,"start",(function(){i._currentVal=i._initialVal=A(i.DS.stores.SettingsStore.s.area),i.DS.stores.SettingsStore.s.area.addEventListener("scroll",i.update)})),n(this,"update",(function(){return i._currentVal=A(i.DS.stores.SettingsStore.s.area)})),n(this,"stop",(function(){i.DS.stores.SettingsStore.s.area.removeEventListener("scroll",i.update),i._initialVal={x:0,y:0},i._canScroll=null})),n(this,"reset",(function(){i.stop(),i.start()})),this.DS=s,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(e,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(t=this.DS.stores.SettingsStore.s.area,!!((e=A(t)).x||e.y||(t instanceof HTMLDocument?t.body?t.body.scrollTop=1:t.documentElement.scrollTop=1:t.scrollTop=1)));var t,e}},{key:"scrollAmount",get:function(){var t,e=m(this.currentVal,"-",this.initialVal),r={x:t=this.DS.stores.SettingsStore.s.zoom,y:t},n=m(m(e,"*",r),"-",e);return{x:e.x+n.x,y:e.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=A(this.DS.stores.SettingsStore.s.area)),this._currentVal}}]),e}(),Y=function e(r){var i=this,o=r.DS,a=r.settings;t(this,e),n(this,"_settings",{}),n(this,"s",{}),n(this,"update",(function(t){var e=t.settings,r=t.init;return i.DS.publish("Settings:updated:pre",s({settings:e},r?{init:r}:{}))})),n(this,"_update",(function(t){for(var e=function(t,e){return s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s({},T("area",t.area,e,document)),T("selectables",t.selectables,e,null)),T("autoScrollSpeed",t.autoScrollSpeed,e,5)),T("overflowTolerance",t.overflowTolerance,e,{x:25,y:25})),T("zoom",t.zoom,e,1)),T("customStyles",t.customStyles,e,!1)),T("multiSelectMode",t.multiSelectMode,e,!1)),T("multiSelectToggling",t.multiSelectToggling,e,!0)),T("multiSelectKeys",t.multiSelectKeys,e,["Control","Shift","Meta"])),T("selector",t.selector,e,null)),T("draggability",t.draggability,e,!0)),T("immediateDrag",t.immediateDrag,e,!0)),T("keyboardDrag",t.keyboardDrag,e,!0)),T("dragKeys",t.dragKeys,e,{up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]})),T("keyboardDragSpeed",t.keyboardDragSpeed,e,10)),T("useTransform",t.useTransform,e,!0)),T("hoverClass",t.hoverClass,e,"ds-hover")),T("selectableClass",t.selectableClass,e,"ds-selectable")),T("selectedClass",t.selectedClass,e,"ds-selected")),T("selectorClass",t.selectorClass,e,"ds-selector")),T("selectorAreaClass",t.selectorAreaClass,e,"ds-selector-area"))}(t.settings,t.init),r=function(){var t,e=g(a[o],2),r=e[0],s=e[1];r in i._settings||Object.defineProperty(i.s,r,{get:function(){return i._settings[r]},set:function(t){return i.update({settings:n({},r,t)})}}),i._settings["".concat(r,":pre")]=i._settings[r],i._settings[r]=s;var c={settings:(t={},n(t,r,i._settings[r]),n(t,"".concat(r,":pre"),i._settings["".concat(r,":pre")]),t)};i.DS.publish("Settings:updated",c),i.DS.publish("Settings:updated:".concat(r),c)},o=0,a=Object.entries(e);o<a.length;o++)r()})),this.DS=o,this.DS.subscribe("Settings:updated:pre",this._update),this.update({settings:a,init:!0})},G=function(){function e(r){var i=this;t(this,e),n(this,"continue",!1),n(this,"start",(function(){i.stopped=!1,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(t){return i.stores.KeyStore.isMultiSelectKeyPressed(t)})),n(this,"isDragging",(function(){return i.Interaction.isDragging})),n(this,"setSettings",(function(t){return i.stores.SettingsStore.update({settings:t})})),this.PubSub=new j({DS:this}),this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this.stores={},this.stores.SettingsStore=new Y({DS:this,settings:r}),this.stores.PointerStore=new U({DS:this}),this.stores.ScrollStore=new X({DS:this}),this.stores.KeyStore=new Z({DS:this}),this.Area=new K({DS:this}),this.Selector=new W({DS:this}),this.SelectorArea=new F({DS:this}),this.SelectableSet=new R({DS:this}),this.SelectedSet=new z({DS:this}),this.Selection=new B({DS:this}),this.Drag=new O({DS:this}),this.Interaction=new H({DS:this}),function(t){for(var e=t.subscribe,r=t.publish,n=t.Interaction,i=t.SelectedSet,o=function(){var t=g(c[a],2),o=t[0],l=t[1];["pre",!1].forEach((function(t){return e(t?"".concat(o,":").concat(t):o,(function(e){return l.forEach((function(o){return(!o.condition||o.condition(e))&&r(t?"".concat(t).concat(o.name):o.name,s({items:i.elements,isDragging:n.isDragging},e))}))}))}))},a=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(t){return t.event}}],"Interaction:end":[{name:"callback"}]});a<c.length;a++)o()}({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(e,[{key:"stop",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=!(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(t),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),t&&this.SelectableSet.clear(),e&&this.SelectedSet.clear(),this.stopped=!0}},{key:"addSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(M(t)),r||this.addSelectables(t),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(M(t)),r&&this.removeSelectables(t),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return M(t).forEach((function(i){return e.SelectedSet.has(i)?e.removeSelection(t,r,n):e.addSelection(t,r,n)})),r&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(t,e,r),this.getSelection()}},{key:"clearSelection",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(t,e,r){var n=M(t);return this.SelectableSet.addAll(n),e&&this.SelectedSet.addAll(n),r&&this.PubSub.publish("callback",{items:this.getSelection()}),t}},{key:"setSelectables",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return console.warn('[DragSelect] DEPRECATION ".setSelectables" is deprecated and will be removed soon. Please use "ds.setSettings({ selectables: << new dom elements >> })" instead (see docs)'),this.removeSelectables(t,e),this.addSelectables(t,r)}},{key:"removeSelectables",value:function(t,e,r){return this.SelectableSet.deleteAll(M(t)),e&&this.removeSelection(t),r&&this.PubSub.publish("callback",{items:this.getSelection()}),t}}]),e}();return G})); |
{ | ||
"name": "dragselect", | ||
"version": "2.4.2", | ||
"version": "2.4.3", | ||
"description": "easy javascript drag select functionality for your projects", | ||
@@ -5,0 +5,0 @@ "main": "./dist/DragSelect.js", |
@@ -245,8 +245,11 @@ // @ts-check | ||
* @param {boolean} [addToSelection] if elements should also be added to current selection | ||
* @param {boolean} [triggerCallback] - if callback should be called | ||
* @return {DSInputElements} the added element(s) | ||
*/ | ||
addSelectables(elements, addToSelection = false) { | ||
addSelectables(elements, addToSelection, triggerCallback) { | ||
const els = toArray(elements) | ||
this.SelectableSet.addAll(els) | ||
if (addToSelection) this.SelectedSet.addAll(els) | ||
if (triggerCallback) | ||
this.PubSub.publish('callback', { items: this.getSelection() }) | ||
return elements | ||
@@ -281,7 +284,10 @@ } | ||
* @param {boolean} [removeFromSelection] if elements should also be removed from current selection | ||
* @param {boolean} [triggerCallback] - if callback should be called | ||
* @return {DSInputElements} the removed element(s) | ||
*/ | ||
removeSelectables(elements, removeFromSelection = false) { | ||
removeSelectables(elements, removeFromSelection, triggerCallback) { | ||
this.SelectableSet.deleteAll(toArray(elements)) | ||
if (removeFromSelection) this.removeSelection(elements) | ||
if (triggerCallback) | ||
this.PubSub.publish('callback', { items: this.getSelection() }) | ||
return elements | ||
@@ -288,0 +294,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
510829
10189