Files
mixly3/common/blockly-core/plugins/workspace_multiselect.js
2024-07-19 10:16:00 +08:00

2 lines
86 KiB
JavaScript

/*! For license information please see index.js.LICENSE.txt */
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],t);else{var s="object"==typeof exports?t(require("blockly/core")):t(e.Blockly);for(var n in s)("object"==typeof exports?exports:e)[n]=s[n]}}(this,(e=>(()=>{var t={501:function(e){e.exports=function(){"use strict";function e(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function t(t){for(var s=1;s<arguments.length;s++){var n=null!=arguments[s]?arguments[s]:{};s%2?e(Object(n),!0).forEach((function(e){r(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,m(n.key),n)}}function i(e,t,s){return t&&n(e.prototype,t),s&&n(e,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,t,s){return(t=m(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function u(e,t,s){return u=a()?Reflect.construct.bind():function(e,t,s){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return s&&l(i,s.prototype),i},u.apply(null,arguments)}function d(e){var t="function"==typeof Map?new Map:void 0;return d=function(e){if(null===e||(s=e,-1===Function.toString.call(s).indexOf("[native code]")))return e;var s;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return u(e,arguments,c(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),l(n,e)},d(e)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){var t=a();return function(){var s,n=c(e);if(t){var i=c(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}(this,s)}}function g(){return g="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,s){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=c(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:s):i.value}},g.apply(this,arguments)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var s=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=s){var n,i,r,o,c=[],l=!0,a=!1;try{if(r=(s=s.call(e)).next,0===t){if(Object(s)!==s)return;l=!1}else for(;!(l=(n=r.call(s)).done)&&(c.push(n.value),c.length!==t);l=!0);}catch(e){a=!0,i=e}finally{try{if(!l&&null!=s.return&&(o=s.return(),Object(o)!==o))return}finally{if(a)throw i}}return c}}(e,t)||y(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){if(e){if("string"==typeof e)return b(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);return"Object"===s&&e.constructor&&(s=e.constructor.name),"Map"===s||"Set"===s?Array.from(e):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?b(e,t):void 0}}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var s=0,n=new Array(t);s<t;s++)n[s]=e[s];return n}function m(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var n=s.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var v=function(e,t,s){var n=e.x,i=e.y,r=s.x,o=s.y;return{"+":{x:n+r,y:i+o},"-":{x:n-r,y:i-o},"*":{x:n*r,y:i*o},"/":{x:n/r,y:i/o}}[t]},_=function(e){return{x:e.left,y:e.top}},k=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return{left:e.x,top:e.y,right:e.x,bottom:e.y,width:t,height:t}},D=function(e,t){var s=t;window.addEventListener("resize",s),window.addEventListener("scroll",s);var n=new MutationObserver(s);return e.forEach((function(e,t){n.observe(e,{childList:0!==t,attributes:!0})})),{observer:n,callback:s,cleanup:function(){return N(n,s)}}},C=function(e,t){var s;return function(){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];clearTimeout(s),s=setTimeout((function(){s=null,e.apply(void 0,i)}),t)}},E=function(){var e,t,s,n;return{y:(null===(e=document.body)||void 0===e?void 0:e.scrollTop)||(null===(t=document.documentElement)||void 0===t?void 0:t.scrollTop)||0,x:(null===(s=document.body)||void 0===s?void 0:s.scrollLeft)||(null===(n=document.documentElement)||void 0===n?void 0:n.scrollLeft)||0}},I=function(e){return function e(t){var s,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=null===(s=t[n])||void 0===s?void 0:s.parentNode;return i?(t.push(i),e(t,++n)):t}([e])},M=function(e,t){var s={top:Number.POSITIVE_INFINITY,left:Number.POSITIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,right:Number.NEGATIVE_INFINITY,width:Number.NEGATIVE_INFINITY,height:Number.NEGATIVE_INFINITY};return V(e).forEach((function(e){var n=t.getRect(e);s.top=Math.min(s.top,n.top),s.left=Math.min(s.left,n.left),s.bottom=Math.max(s.bottom,n.bottom),s.right=Math.max(s.right,n.right)})),s.height=s.bottom-s.top,s.width=s.right-s.left,s},w=function(e){return!e||e instanceof Document?E():{x:e.scrollLeft>=0?e.scrollLeft:E().x,y:e.scrollTop>=0?e.scrollTop:E().y}},T=function(e){var t=e.elementRect,s=e.containerRect,n=e.tolerance,i=void 0===n?{x:0,y:0}:n,r=[];return t.top-i.y<s.top&&r.push("top"),t.left-i.x<s.left&&r.push("left"),t.bottom+i.y>s.bottom&&r.push("bottom"),t.right+i.y>s.right&&r.push("right"),r},B=function(e){var t={x:0,y:0},s=window.getComputedStyle(e);if(!s.transform||"none"===s.transform)return t;if(s.transform.indexOf("3d")>=0){var n=s.transform.trim().match(/matrix3d\((.*?)\)/);if(n&&n.length){var i,r=null===(i=n[1])||void 0===i?void 0:i.split(",");t.x=parseInt(r[12])||0,t.y=parseInt(r[13])||0}return t}var o=s.transform.trim().match(/matrix\((.*?)\)/);if(o&&o.length){var c,l=null===(c=o[1])||void 0===c?void 0:c.split(",");t.x=parseInt(l[4])||0,t.y=parseInt(l[5])||0}return t},L=function(e,t){return t?function(e){var t=e.style.transform;if(!t||t.indexOf("translate")<0)return B(e);var s={x:0,y:0},n=t.trim().match(/translate[3dD]*?\(.*?\)/);if(n){var i,r=null===(i=n[0])||void 0===i?void 0:i.split("(");if(r){var o,c=null===(o=r[1])||void 0===o?void 0:o.split(",");s.x=parseInt(c[0])||0,s.y=parseInt(c[1])||0}}return s.x||s.x?s:B(e)}(e):function(e){var t=e.style,s={x:parseInt(t.left)||0,y:parseInt(t.top)||0};if(!s.x&&!s.x){var n=window.getComputedStyle(e);return{x:parseInt(n.left)||0,y:parseInt(n.top)||0}}return s}(e)},P=function(e){var t=e.computedStyle,s=e.node,n=t.position;s instanceof Document||"absolute"===n||"relative"===n||"fixed"===n||(s.style.position="relative")},x=function(e,t,s){return console.warn('[DragSelect] TypeIssue: setting "'.concat(e,'" is not of type "').concat(t,'".'))},A=function(e,t,s,n){if(void 0===t)return s?r({},e,n):{};if(null===t)return r({},e,null);var i=!0,o=!1,c="string"==typeof n;c&&(i="string"==typeof t||t instanceof String),c&&!i&&(o=!0,x(e,"string"));var l=!Number.isNaN(n)&&"number"==typeof n;l&&(i=!Number.isNaN(t)&&"number"==typeof t),l&&!i&&(o=!0,x(e,"number"));var a="[object Object]"===Object.prototype.toString.call(n);a&&(i="[object Object]"===Object.prototype.toString.call(t)),a&&!i&&(o=!0,x(e,"object"));var u="boolean"==typeof n;u&&(i="boolean"==typeof t),u&&!i&&(o=!0,x(e,"boolean"));var d=Array.isArray(n);d&&(i=Array.isArray(t)),d&&!i&&(o=!0,x(e,"array"));var h=o||s;return"dragKeys"===e&&i?r({},e,Object.assign(n,t)):"dragKeys"!==e||i?("dropZones"===e&&i&&new Set(t.map((function(e){return e.id}))).size!==t.length&&console.warn('[DragSelect] UniqueConstraintsIssue: setting "dropZones" contains duplicate ids.'),i?r({},e,t):h?r({},e,n):{}):h?r({},e,n):{}},O=function(e,t){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=e;if(s>0){var i=(e.right-e.left)*s,r=(e.bottom-e.top)*s;n={left:e.left+i,right:e.right-i,top:e.top+r,bottom:e.bottom-r}}return n.left<t.right&&n.right>t.left&&n.top<t.bottom&&n.bottom>t.top},R=function(e){var t=e.element,s=e.posDirection,n=e.containerRect,i=e.useTransform,r=L(t,i),o=v(r,"+",s);K(t,o,i);var c=t.getBoundingClientRect();!function(e){var t=e.element,s=e.edges,n=e.elementRect,i=e.containerRect,r=e.elementPos,o=e.useTransform;s.includes("top")&&K(t,{y:r.y+i.top-n.top,x:r.x},o),s.includes("left")&&K(t,{y:r.y,x:r.x+i.left-n.left},o),s.includes("bottom")&&K(t,{y:r.y+i.bottom-n.bottom,x:r.x},o),s.includes("right")&&K(t,{y:r.y,x:r.x+i.right-n.right},o)}({element:t,edges:T({elementRect:c,containerRect:n}),elementRect:c,containerRect:n,elementPos:o,useTransform:i})},N=function(e,t){window.removeEventListener("resize",t),window.removeEventListener("scroll",t),e.disconnect()},K=function(e,t,s){if(s){var n=e.style.transform;e.style.transform="translate3d(".concat(t.x,"px,").concat(t.y,"px,1px) ").concat(n.replace(/translate.*?\)/g,""))}else e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px");return e},V=function(e){return e?!Array.isArray(e)&&(e instanceof HTMLElement||e instanceof SVGElement)?[e]:f(new Set(f(e))):[]},j=function(e,t){e.style.left="".concat(t.left,"px"),e.style.top="".concat(t.top,"px"),e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px")},z=function(){function e(t){var n=this,i=t.DS;s(this,e),r(this,"DS",void 0),r(this,"_observers",void 0),r(this,"_node",void 0),r(this,"_parentNodes",void 0),r(this,"_computedStyle",void 0),r(this,"_computedBorder",void 0),r(this,"_rect",void 0),r(this,"setArea",(function(e){n.reset(),n._node=e,P({computedStyle:n.computedStyle,node:n._node}),setTimeout((function(){n.DS.PubSub.publish("Area:modified:pre",{item:n}),n.reset(),n.DS.PubSub.publish("Area:modified",{item:n})}))})),r(this,"start",(function(){n._observers=D(n.parentNodes,C((function(e){n.DS.PubSub.publish("Area:modified:pre",{event:e,item:n}),n.reset(),n.DS.PubSub.publish("Area:modified",{event:e,item:n})}),60))})),r(this,"reset",(function(){n._computedStyle=void 0,n._rect=void 0,n._computedBorder=void 0,n._parentNodes=void 0})),r(this,"stop",(function(){n._observers.cleanup(),n.reset()})),r(this,"scroll",(function(e,t){var s={scroll_directions:e,scroll_multiplier:t};n.DS.PubSub.publish("Area:scroll:pre",s),function(e,t,s){if(t.length){var n=document&&document.documentElement&&document.documentElement.scrollTop&&document.documentElement,i=e instanceof Document?n||document.body:e,r=t.includes("top")&&i.scrollTop>0,o=t.includes("bottom")&&i.scrollTop<i.scrollHeight,c=t.includes("left")&&i.scrollLeft>0,l=t.includes("right")&&i.scrollLeft<i.scrollWidth;r&&(i.scrollTop-=1*s),o&&(i.scrollTop+=1*s),c&&(i.scrollLeft-=1*s),l&&(i.scrollLeft+=1*s)}}(n._node,e,t),n.DS.PubSub.publish("Area:scroll",s)})),this.DS=i,this.setArea(this.DS.stores.SettingsStore.s.area),this.DS.PubSub.subscribe("Settings:updated:area",(function(e){var t=e.settings;n.setArea(t.area)})),this.DS.PubSub.subscribe("Interaction:init",this.start),this.DS.PubSub.subscribe("Interaction:end",this.reset)}return i(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 Document?this._computedStyle=window.getComputedStyle(this.HTMLNode.body||this.HTMLNode.documentElement):this._computedStyle=window.getComputedStyle(this.HTMLNode)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=function(e,t){if(e instanceof Document)return{top:0,left:0,bottom:0,right:0,width:window.innerWidth,height:window.innerHeight};var s=e.getBoundingClientRect();return{top:s.top,left:s.left,bottom:s.bottom,right:s.right,width:(e.clientWidth||s.width)*t,height:(e.clientHeight||s.height)*t}}(this.HTMLNode,this.DS.stores.SettingsStore.s.zoom)}},{key:"parentNodes",get:function(){return this._parentNodes?this._parentNodes:this._parentNodes=I(this.HTMLNode)}}]),e}(),G=function(){function e(t){var n=this,i=t.DS;s(this,e),r(this,"_prevCursorPos",void 0),r(this,"_prevScrollPos",void 0),r(this,"_elements",[]),r(this,"_dragKeys",void 0),r(this,"_dragKeysFlat",[]),r(this,"_selectionRect",void 0),r(this,"assignDragkeys",(function(){n._dragKeys={up:n.DS.stores.SettingsStore.s.dragKeys.up.map((function(e){return e.toLowerCase()})),down:n.DS.stores.SettingsStore.s.dragKeys.down.map((function(e){return e.toLowerCase()})),left:n.DS.stores.SettingsStore.s.dragKeys.left.map((function(e){return e.toLowerCase()})),right:n.DS.stores.SettingsStore.s.dragKeys.right.map((function(e){return e.toLowerCase()}))},n._dragKeysFlat=[].concat(f(n._dragKeys.up),f(n._dragKeys.down),f(n._dragKeys.left),f(n._dragKeys.right))})),r(this,"keyboardDrag",(function(e){var t=e.event,s=e.key.toLowerCase();if(n.DS.stores.SettingsStore.s.keyboardDrag&&n._dragKeysFlat.includes(s)&&n.DS.SelectedSet.size&&n.DS.stores.SettingsStore.s.draggability&&!n.DS.continue){var i={event:t,isDragging:!0,isDraggingKeyboard:!0};n.DS.publish(["Interaction:start:pre","Interaction:start"],i),n._elements=n.DS.getSelection(),n.DS.stores.SettingsStore.s.dragAsBlock&&(n._selectionRect=M(n._elements,n.DS.SelectableSet)),n.handleZIndex(!0);var r=function(e){var t=e.shiftKey,s=e.keyboardDragSpeed,n=e.zoom,i=e.key,r=e.dragKeys,o=e.scrollDiff,c=e.canScroll,l=e.scrollCallback,a={x:0,y:0},u=t?4*s*n:s*n;return r.left.includes(i)&&(a.x=o.x||-u,t||o.x||!c||l(["left"],s)),r.right.includes(i)&&(a.x=o.x||u,t||o.x||!c||l(["right"],s)),r.up.includes(i)&&(a.y=o.y||-u,t||o.y||!c||l(["top"],s)),r.down.includes(i)&&(a.y=o.y||u,t||o.y||!c||l(["bottom"],s)),a}({shiftKey:n.DS.stores.KeyStore.currentValues.includes("shift"),keyboardDragSpeed:n.DS.stores.SettingsStore.s.keyboardDragSpeed,zoom:n.DS.stores.SettingsStore.s.zoom,key:s,scrollCallback:n.DS.Area.scroll,scrollDiff:n._scrollDiff,canScroll:n.DS.stores.ScrollStore.canScroll,dragKeys:n._dragKeys});n.DS.stores.SettingsStore.s.dragAsBlock&&(r=n.limitDirection(r)),n._elements.forEach((function(e){return R({element:e,posDirection:r,containerRect:n.DS.SelectorArea.rect,useTransform:n.DS.stores.SettingsStore.s.useTransform})})),n.DS.publish(["Interaction:update:pre","Interaction:update"],i)}})),r(this,"keyboardEnd",(function(e){var t=e.event,s=e.key.toLowerCase();if(n.DS.stores.SettingsStore.s.keyboardDrag&&n._dragKeysFlat.includes(s)&&n.DS.SelectedSet.size&&n.DS.stores.SettingsStore.s.draggability){var i={event:t,isDragging:n.DS.stores.SettingsStore.s.draggability,isDraggingKeyboard:!0};n.DS.publish(["Interaction:end:pre","Interaction:end"],i)}})),r(this,"start",(function(e){var t=e.isDragging,s=e.isDraggingKeyboard;t&&!s&&(n._prevCursorPos=null,n._prevScrollPos=null,n._elements=n.DS.getSelection(),n.DS.stores.SettingsStore.s.dragAsBlock&&(n._selectionRect=M(n._elements,n.DS.SelectableSet)),n.handleZIndex(!0))})),r(this,"stop",(function(e){null!=e&&e.isKeyboard||(n._prevCursorPos=null,n._prevScrollPos=null,n.handleZIndex(!1),n._elements=[])})),r(this,"update",(function(e){var t=e.isDragging,s=e.isDraggingKeyboard;if(t&&n._elements.length&&!s&&!n.DS.continue){var i=v(n._cursorDiff,"+",n._scrollDiff);n.DS.stores.SettingsStore.s.dragAsBlock&&(i=n.limitDirection(i)),n._elements.forEach((function(e){return R({element:e,posDirection:i,containerRect:n.DS.SelectorArea.rect,useTransform:n.DS.stores.SettingsStore.s.useTransform})}))}})),r(this,"limitDirection",(function(e){var t=n.DS.SelectorArea.rect,s=n.DS.stores.ScrollStore.scrollAmount,i={top:t.top-n._selectionRect.top+s.y,left:t.left-n._selectionRect.left+s.x,bottom:t.bottom-n._selectionRect.bottom+s.y,right:t.right-n._selectionRect.right+s.x};return 0===e.x&&0===e.y||(e.y<0&&(e.y=Math.max(e.y,i.top)),e.x<0&&(e.x=Math.max(e.x,i.left)),e.y>0&&(e.y=Math.min(e.y,i.bottom)),e.x>0&&(e.x=Math.min(e.x,i.right)),n._selectionRect.top+=e.y,n._selectionRect.bottom+=e.y,n._selectionRect.left+=e.x,n._selectionRect.right+=e.x),e})),r(this,"handleZIndex",(function(e){n._elements.forEach((function(t){return t.style.zIndex="".concat((parseInt(t.style.zIndex)||0)+e?9999:-9998)}))})),this.DS=i,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 i(e,[{key:"_cursorDiff",get:function(){var e=this.DS.stores.PointerStore.currentVal,t=this._prevCursorPos?v(e,"-",this._prevCursorPos):{x:0,y:0};return this._prevCursorPos=e,t}},{key:"_scrollDiff",get:function(){var e=this.DS.stores.ScrollStore.currentVal,t=this._prevScrollPos?v(e,"-",this._prevScrollPos):{x:0,y:0};return this._prevScrollPos=e,t}}]),e}(),F=function(){function e(t){var n=this,i=t.DS,o=t.id,c=t.element,l=t.droppables;s(this,e),r(this,"id",void 0),r(this,"element",void 0),r(this,"_droppables",void 0),r(this,"_rect",void 0),r(this,"_observers",void 0),r(this,"_timeout",void 0),r(this,"_itemsDropped",[]),r(this,"_itemsInside",void 0),r(this,"setReadyClasses",(function(e){if(!n.isDestroyed){var t=n.droppables.filter((function(e){return n.DS.SelectedSet.has(e)}));t.length&&(t.forEach((function(t){t.classList[e]("".concat(n.Settings.droppableClass)),t.classList[e]("".concat(n.Settings.droppableClass,"-").concat(n.id))})),n.element.classList[e]("".concat(n.Settings.dropZoneReadyClass)))}})),r(this,"handleNoDrop",(function(){var e;n.isDestroyed||(n.DS.SelectedSet.forEach((function(e){e.classList.remove(n.Settings.droppedTargetClass),e.classList.remove("".concat(n.Settings.droppedTargetClass,"-").concat(n.id))})),n._itemsDropped=n._itemsDropped.filter((function(e){return!n.DS.SelectedSet.has(e)})),null!==(e=n._itemsDropped)&&void 0!==e&&e.length||n.element.classList.remove("".concat(n.Settings.dropZoneTargetClass)))})),r(this,"handleDrop",(function(){var e,t,s;n.isDestroyed||(n._itemsDropped=f(new Set([].concat(f(n._itemsDropped),f(null===(e=n.droppables)||void 0===e?void 0:e.filter((function(e){return n.DS.SelectedSet.has(e)})))))),null===(t=n._itemsDropped)||void 0===t||t.forEach((function(e){e.classList.add("".concat(n.Settings.droppedTargetClass)),e.classList.add("".concat(n.Settings.droppedTargetClass,"-").concat(n.id))})),null!==(s=n._itemsDropped)&&void 0!==s&&s.length&&n.element.classList.add("".concat(n.Settings.dropZoneTargetClass)))})),r(this,"handleItemsInsideClasses",(function(){var e=!1;n.droppables.forEach((function(t){n.itemsInside.includes(t)?(t.classList.add("".concat(n.Settings.droppedInsideClass)),t.classList.add("".concat(n.Settings.droppedInsideClass,"-").concat(n.id)),e=!0):(t.classList.remove("".concat(n.Settings.droppedInsideClass,"-").concat(n.id)),t.className.includes("".concat(n.Settings.droppedInsideClass,"-"))||t.classList.remove("".concat(n.Settings.droppedInsideClass)))})),e?n.element.classList.add("".concat(n.Settings.dropZoneInsideClass)):n.element.classList.remove("".concat(n.Settings.dropZoneInsideClass))})),r(this,"start",(function(e){e.isDragging&&!n.isDestroyed&&n.setReadyClasses("add")})),r(this,"stop",(function(e){e.isDragging&&!n.isDestroyed&&(n.setReadyClasses("remove"),n.handleItemsInsideClasses())})),r(this,"toObject",(function(){return{id:n.id,element:n.element,droppables:n.droppables,itemsDropped:n.itemsDropped,itemsInside:n.itemsInside}})),this.DS=i,this.Settings=i.stores.SettingsStore.s,this.id=o,this.element=c,l&&(this.droppables=V(l)),this.element.classList.add("".concat(this.Settings.dropZoneClass)),this.DS.subscribe("Settings:updated:dropZoneClass",(function(e){var t=e.settings;n.element&&(n.element.classList.remove(t["dropZoneClass:pre"]),n.element.classList.add(t.dropZoneClass))})),this._observers=D(this.parentNodes,C((function(){return n._rect=null}),this.Settings.refreshMemoryRate)),this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:end",this.stop)}return i(e,[{key:"destroy",value:function(){var e=this;this._observers.cleanup(),this.element.classList.remove("".concat(this.Settings.dropZoneClass)),this.element.classList.remove("".concat(this.Settings.dropZoneTargetClass)),this.element.classList.remove("".concat(this.Settings.dropZoneReadyClass)),this.droppables.forEach((function(t){t.classList.remove("".concat(e.Settings.droppedTargetClass)),t.classList.remove("".concat(e.Settings.droppedTargetClass,"-").concat(e.id)),t.classList.remove("".concat(e.Settings.droppableClass)),t.classList.remove("".concat(e.Settings.droppableClass,"-").concat(e.id))})),this.DS.unsubscribe("Interaction:start",this.start),this.DS.unsubscribe("Interaction:end",this.stop),this.element=null,this.droppables=null,this.id=null,this._itemsDropped=null,this._itemsInside=null,this.isDestroyed=!0}},{key:"rect",get:function(){return this.isDestroyed?null:this._rect?this._rect:this._rect=this.element.getBoundingClientRect()}},{key:"itemsDropped",get:function(){return this.isDestroyed?null:this._itemsDropped}},{key:"itemsInside",get:function(){var e=this;return this.isDestroyed?null:(this._itemsInside||(this._itemsInside=this.droppables.flatMap((function(t){return O(e.DS.SelectableSet.rects.get(t),e.rect,e.Settings.dropInsideThreshold)?[t]:[]})),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((function(){return e._itemsInside=null}),this.Settings.refreshMemoryRate)),this._itemsInside)}},{key:"parentNodes",get:function(){return this._parentNodes?this._parentNodes:this._parentNodes=I(this.element)}},{key:"droppables",get:function(){return this._droppables?this._droppables:this.DS.SelectableSet.elements},set:function(e){this._droppables=e}}]),e}(),H=i((function e(n){var i=this,o=n.DS;s(this,e),r(this,"_zoneByElement",new Map),r(this,"_zoneById",new Map),r(this,"_zonesByDroppable",new Map),r(this,"_zones",void 0),r(this,"setDropZones",(function(e){var s=e.dropZones;s&&(i._zones&&i._zones.forEach((function(e){return e.destroy()})),i._zones=s.map((function(e){return new F(t({DS:i.DS},e))})),i._zones.forEach((function(e){i._zoneByElement.set(e.element,e),i._zoneById.set(e.id,e),e.droppables.forEach((function(t){var s=i._zonesByDroppable.get(t);if(null==s||!s.length)return i._zonesByDroppable.set(t,[e]);i._zonesByDroppable.set(t,f(new Set([].concat(f(s),[e]))))}))})))})),r(this,"_handleDrop",(function(e){i._zones.forEach((function(t){t!==e&&t.handleNoDrop()})),e&&e.handleDrop()})),r(this,"_getZoneByElementsFromPoint",(function(e,t){for(var s=t.x,n=t.y,r=0,o=e.length;r<o;r++){var c=i._zoneByElement.get(e[r]);if(c&&O(c.rect,{left:s,right:s,top:n,bottom:n},Math.min(i.Settings.dropTargetThreshold,.5)))return c}})),r(this,"stop",(function(e){if(e.isDragging){var t=i.getTarget();i._handleDrop(t)}})),r(this,"getItemsDroppedById",(function(e){var t=i._zoneById.get(e);return t?t.itemsDropped:console.warn("[DragSelect] No zone found (id: ".concat(e,")"))})),r(this,"getItemsInsideById",(function(e,t){var s=i._zoneById.get(e);if(!s)return console.warn("[DragSelect] No zone found (id: ".concat(e,")"));var n=s.itemsInside;return t&&s.handleItemsInsideClasses(),n})),r(this,"getTarget",(function(e){var t;if(null!==(t=i._zones)&&void 0!==t&&t.length){var s=(null==e?void 0:e.x)||i.DS.stores.PointerStore.currentVal.x,n=(null==e?void 0:e.y)||i.DS.stores.PointerStore.currentVal.y,r=document.elementsFromPoint(s,n);return i._getZoneByElementsFromPoint(r,{x:s,y:n})}})),this.DS=o,this.Settings=o.stores.SettingsStore.s,this.DS.subscribe("Settings:updated:dropZones",(function(e){var t=e.settings;return i.setDropZones(t)})),this.setDropZones({dropZones:this.DS.stores.SettingsStore.s.dropZones}),this.DS.subscribe("Interaction:end",this.stop)})),W=function(){function e(t){var n=this,i=t.DS;s(this,e),r(this,"isInteracting",void 0),r(this,"isDragging",void 0),r(this,"init",(function(){return n.DS.publish("Interaction:init:pre",{})})),r(this,"_init",(function(){n.stop(),n.Settings.usePointerEvents?n.DS.Area.HTMLNode.addEventListener("pointerdown",n.start,{passive:!1}):n.DS.Area.HTMLNode.addEventListener("mousedown",n.start),n.DS.Area.HTMLNode.addEventListener("touchstart",n.start,{passive:!1}),n.DS.publish("Interaction:init",{})})),r(this,"start",(function(e){return n.DS.publish("Interaction:start:pre",{event:e,isDragging:n.isDragging})})),r(this,"_start",(function(e){"touchstart"===e.type&&e.preventDefault(),n._canInteract(e)&&(n.isInteracting=!0,n.isDragging=n.isDragEvent(e),n.DS.publish("Interaction:start",{event:e,isDragging:n.isDragging}),n.Settings.usePointerEvents?(document.addEventListener("pointerup",n.reset),document.addEventListener("pointercancel",n.reset)):document.addEventListener("mouseup",n.reset),document.addEventListener("touchend",n.reset))})),r(this,"isDragEvent",(function(e){var t=e.target.closest(".".concat(n.Settings.selectableClass));return!(!n.Settings.draggability||n.DS.stores.KeyStore.isMultiSelectKeyPressed(e)||!t||(n.Settings.immediateDrag&&(n.DS.SelectedSet.size?n.DS.SelectedSet.has(t)||(n.DS.SelectedSet.clear(),n.DS.SelectedSet.add(t)):n.DS.SelectedSet.add(t)),!n.DS.SelectedSet.has(t)))})),r(this,"onClick",(function(e){var t=e.event;if(n._canInteract(t)&&!(t.detail>0)){var s=n.DS,i=s.stores,r=i.PointerStore,o=i.KeyStore,c=s.SelectableSet,l=s.SelectedSet;r.start(t);var a=t.target;c.has(a)&&(o.isMultiSelectKeyPressed(t)||l.clear(),l.toggle(a),n.reset())}})),r(this,"stop",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n.DS.Area.HTMLNode;n.isInteracting=!1,n.isDragging=!1,n.Settings.usePointerEvents?(e.removeEventListener("pointerdown",n.start,{passive:!1}),document.removeEventListener("pointerup",n.reset),document.removeEventListener("pointercancel",n.reset)):(e.removeEventListener("mousedown",n.start),document.removeEventListener("mouseup",n.reset)),e.removeEventListener("touchstart",n.start,{passive:!1}),document.removeEventListener("touchend",n.reset)})),r(this,"update",(function(e){var t=e.event,s=e.scroll_directions,i=e.scroll_multiplier;n.isInteracting&&n.DS.publish(["Interaction:update:pre","Interaction:update"],{event:t,scroll_directions:s,scroll_multiplier:i,isDragging:n.isDragging})})),r(this,"reset",(function(e){return n.DS.publish("Interaction:end:pre",{event:e,isDragging:n.isDragging})})),r(this,"_reset",(function(e){var t=n.isDragging;n.stop(),n.init(),n.DS.publish("Interaction:end",{event:e,isDragging:t})})),this.DS=i,this.Settings=i.stores.SettingsStore.s,this.DS.subscribe("Settings:updated:area",(function(e){var t=e.settings;n.stop(t["area:pre"]),n.init()})),this.DS.subscribe("PointerStore:updated",this.update),this.DS.subscribe("Selectable:click",this.onClick),this.DS.subscribe("Selectable:pointer",(function(e){var t=e.event;return n.start(t)})),this.DS.subscribe("Interaction:start:pre",(function(e){var t=e.event;return n._start(t)})),this.DS.subscribe("Interaction:init:pre",this._init),this.DS.subscribe("Interaction:end:pre",(function(e){var t=e.event;return n._reset(t)})),this.DS.subscribe("Area:scroll",this.update)}return i(e,[{key:"_canInteract",value:function(e){var t=0===e.clientX&&0===e.clientY&&0===e.detail&&e.target;return!(2===e.button||this.isInteracting||e.target&&!this.DS.SelectorArea.isInside(e.target)||!t&&!this.DS.SelectorArea.isClicked(e))}}]),e}(),Z=i((function e(t){var n=this,i=t.DS;s(this,e),r(this,"subscribers",{}),r(this,"subscribe",(function(e,t){return Array.isArray(n.subscribers[e])||(n.subscribers[e]=[]),n.subscribers[e].push(t),n.subscribers[e].length-1})),r(this,"unsubscribe",(function(e,t,s){s>=0?n.subscribers[e].splice(s,1):t&&(n.subscribers[e]=n.subscribers[e].filter((function(e){return e!==t})))})),r(this,"publish",(function(e,t){Array.isArray(e)?e.forEach((function(e){return n._publish(e,t)})):n._publish(e,t)})),r(this,"_publish",(function(e,t){var s=n.subscribers[e];Array.isArray(s)&&(e.includes(":pre")?n._handlePrePublish(s,t):n._handlePublish(s,t))})),r(this,"_handlePublish",(function(e,t){for(var s=0,i=e.length;s<i;s++){if(n.DS.stopped)return;e[s](t)}})),r(this,"_handlePrePublish",(function(e,t){for(var s=e.length;s--;){if(n.DS.stopped)return;e[s](t)}})),this.DS=i})),X=function(e){o(n,e);var t=p(n);function n(e){var i,o=e.DS;return s(this,n),r(h(i=t.call(this)),"_rects",void 0),r(h(i),"_timeout",void 0),r(h(i),"init",(function(){return V(i.Settings.selectables).forEach((function(e){return i.add(e)}))})),r(h(i),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(h(i),"_onClick",(function(e){return i.DS.publish(["Selectable:click:pre","Selectable:click"],{event:e})})),r(h(i),"_onPointer",(function(e){return i.DS.publish(["Selectable:pointer:pre","Selectable:pointer"],{event:e})})),r(h(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(h(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),r(h(i),"getRect",(function(e){return i._rects?i.rects.get(e):e.getBoundingClientRect()})),i.DS=o,i.Settings=o.stores.SettingsStore.s,i.DS.subscribe("Interaction:init",i.init),i.DS.PubSub.subscribe("Settings:updated:selectables",(function(){i.clear(),i.init()})),i.DS.subscribe("Settings:updated:selectableClass",(function(e){var t=e.settings;i.forEach((function(e){e.classList.remove(t["selectableClass:pre"]),e.classList.add(t.selectableClass)}))})),i}return i(n,[{key:"add",value:function(e){if(g(c(n.prototype),"has",this).call(this,e))return this;var t={items:this.elements,item:e};return this.DS.publish("Selectable:added:pre",t),e.classList.add(this.Settings.selectableClass),e.addEventListener("click",this._onClick),this.Settings.usePointerEvents?e.addEventListener("pointerdown",this._onPointer,{passive:!1}):e.addEventListener("mousedown",this._onPointer),e.addEventListener("touchstart",this._onPointer,{passive:!1}),this.Settings.draggability&&!this.Settings.useTransform&&P({computedStyle:window.getComputedStyle(e),node:e}),g(c(n.prototype),"add",this).call(this,e),this.DS.publish("Selectable:added",t),this}},{key:"delete",value:function(e){if(!g(c(n.prototype),"has",this).call(this,e))return!0;var t={items:this.elements,item:e};return this.DS.publish("Selectable:removed:pre",t),e.classList.remove(this.Settings.selectableClass),e.classList.remove(this.Settings.hoverClass),e.removeEventListener("click",this._onClick),this.Settings.usePointerEvents?e.removeEventListener("pointerdown",this._onPointer,{passive:!1}):e.removeEventListener("mousedown",this._onPointer),e.removeEventListener("touchstart",this._onPointer,{passive:!1}),g(c(n.prototype),"delete",this).call(this,e),this.DS.publish("Selectable:removed",t),!0}},{key:"elements",get:function(){return Array.from(this.values())}},{key:"rects",get:function(){var e=this;return this._rects||(this._rects=new Map,this.forEach((function(t){return e._rects.set(t,t.getBoundingClientRect())})),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout((function(){return e._rects=null}),this.Settings.refreshMemoryRate)),this._rects}}]),n}(d(Set)),U=function(e){o(n,e);var t=p(n);function n(e){var i,o=e.DS;return s(this,n),r(h(i=t.call(this)),"clear",(function(){return i.forEach((function(e){return i.delete(e)}))})),r(h(i),"addAll",(function(e){return e.forEach((function(e){return i.add(e)}))})),r(h(i),"deleteAll",(function(e){return e.forEach((function(e){return i.delete(e)}))})),i.DS=o,i}return i(n,[{key:"add",value:function(e){if(g(c(n.prototype),"has",this).call(this,e))return this;var t={items:this.elements,item:e};return this.DS.publish("Selected:added:pre",t),g(c(n.prototype),"add",this).call(this,e),e.classList.add(this.DS.stores.SettingsStore.s.selectedClass),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)+1),this.DS.publish("Selected:added",t),this}},{key:"delete",value:function(e){if(!g(c(n.prototype),"has",this).call(this,e))return!0;var t={items:this.elements,item:e};this.DS.publish("Selected:removed:pre",t);var s=g(c(n.prototype),"delete",this).call(this,e);return e.classList.remove(this.DS.stores.SettingsStore.s.selectedClass),e.style.zIndex="".concat((parseInt(e.style.zIndex)||0)-1),this.DS.publish("Selected:removed",t),s}},{key:"toggle",value:function(e){return this.has(e)?this.delete(e):this.add(e),e}},{key:"elements",get:function(){return Array.from(this.values())}}]),n}(d(Set)),Y=function(){function e(t){var n=this,i=t.DS;s(this,e),r(this,"_prevSelectedSet",void 0),r(this,"start",(function(e){var t=e.event;e.isDragging||(n._storePrevious(t),n._handleInsideSelection(!0,t))})),r(this,"update",(function(e){e.isDragging||n.DS.continue||n._handleInsideSelection()})),r(this,"_handleInsideSelection",(function(e,t){var s,i=n.DS,r=i.SelectableSet,o=i.SelectorArea,c=i.Selector,l=n.DS.stores.KeyStore.isMultiSelectKeyPressed(t)&&n.Settings.multiSelectToggling,a=n.Settings.selectionThreshold,u=r.rects,d=c.rect,h=new Map,p=new Map,g=function(e,t){var s="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!s){if(Array.isArray(e)||(s=y(e))||t&&e&&"number"==typeof e.length){s&&(e=s);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,c=!1;return{s:function(){s=s.call(e)},n:function(){var e=s.next();return o=e.done,e},e:function(e){c=!0,r=e},f:function(){try{o||null==s.return||s.return()}finally{if(c)throw r}}}}(u);try{for(g.s();!(s=g.n()).done;){var f=S(s.value,2),b=f[0],m=f[1];o.isInside(b,m)&&(O(m,d,a)?h.set(b,m):p.set(b,m))}}catch(e){g.e(e)}finally{g.f()}if(!n.DS.continue){var v=n.filterSelected({select:h,unselect:p,selectorRect:d}),_=v.select,k=v.unselect;_.forEach((function(t,s){return function(e){var t=e.element,s=e.force,n=e.multiSelectionToggle,i=e.SelectedSet,r=e.hoverClassName;t.classList.contains(r)&&!s||(i.has(t)?n&&i.delete(t):i.add(t),t.classList.add(r))}({element:s,force:e,multiSelectionToggle:l,SelectedSet:n.DS.SelectedSet,hoverClassName:n.Settings.hoverClass})})),k.forEach((function(t,s){return function(e){var t=e.element,s=e.force,n=e.SelectedSet,i=e.PrevSelectedSet,r=e.hoverClassName;if(!t.classList.contains(r)&&!s)return!1;var o=n.has(t),c=i.has(t);o&&!c?n.delete(t):!o&&c&&n.add(t),t.classList.remove(r)}({element:s,force:e,SelectedSet:n.DS.SelectedSet,hoverClassName:n.Settings.hoverClass,PrevSelectedSet:n._prevSelectedSet})}))}})),r(this,"filterSelected",(function(e){var t=e.select,s=e.unselect;return e.selectorRect,{select:t,unselect:s}})),this.DS=i,this.Settings=this.DS.stores.SettingsStore.s,this.DS.subscribe("Interaction:start",this.start),this.DS.subscribe("Interaction:update",this.update)}return i(e,[{key:"_storePrevious",value:function(e){var t=this.DS,s=t.stores.KeyStore,n=t.SelectedSet;s.isMultiSelectKeyPressed(e)?this._prevSelectedSet=new Set(n):this._prevSelectedSet=new Set}}]),e}(),q=function(){function e(t){var n=this,i=t.DS;s(this,e),r(this,"_rect",void 0),r(this,"attachSelector",(function(){var e,t,s,i;n.HTMLNode&&null!==(e=n.DS.SelectorArea)&&void 0!==e&&e.HTMLNode&&n.DS.SelectorArea.HTMLNode.removeChild(n.HTMLNode),n.HTMLNode=n.DS.stores.SettingsStore.s.selector||(s=n.DS.stores.SettingsStore.s.customStyles,(i=document.createElement("div")).style.position="absolute",s||(i.style.background="rgba(0, 175, 255, 0.2)",i.style.border="1px solid rgba(0, 175, 255, 0.8)",i.style.display="none",i.style.pointerEvents="none"),i),n.HTMLNode.classList.add(n.DS.stores.SettingsStore.s.selectorClass),n.HTMLNode&&null!==(t=n.DS.SelectorArea)&&void 0!==t&&t.HTMLNode&&n.DS.SelectorArea.HTMLNode.appendChild(n.HTMLNode)})),r(this,"start",(function(e){if(!e.isDragging){var t=n.DS.stores.PointerStore.initialValArea;j(n.HTMLNode,k(t,1)),n.HTMLNode.style.display="block",n._rect=null}})),r(this,"stop",(function(){n.HTMLNode.style.width="0",n.HTMLNode.style.height="0",n.HTMLNode.style.display="none"})),r(this,"update",(function(e){if(!e.isDragging&&!n.DS.continue){var t=n.DS.stores,s=t.ScrollStore,i=t.PointerStore,r=function(e){var t=e.scrollAmount,s=e.initialPointerPos,n=e.pointerPos,i={};return n.x>s.x-t.x?(i.left=s.x-t.x,i.width=n.x-s.x+t.x):(i.left=n.x,i.width=s.x-n.x-t.x),n.y>s.y-t.y?(i.top=s.y-t.y,i.height=n.y-s.y+t.y):(i.top=n.y,i.height=s.y-n.y-t.y),i}({scrollAmount:s.scrollAmount,initialPointerPos:i.initialValArea,pointerPos:i.currentValArea});j(n.HTMLNode,r),n._rect=null}})),this.DS=i,this.DS.subscribe("Settings:updated:selectorClass",(function(e){var t=e.settings;n.HTMLNode.classList.remove(t["selectorClass:pre"]),n.HTMLNode.classList.add(t.selectorClass)})),this.DS.subscribe("Settings:updated:selector",this.attachSelector),this.DS.subscribe("Settings:updated:customStyles",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 i(e,[{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),e}(),J=function(){function e(t){var n,i=this,o=t.DS;s(this,e),r(this,"_scrollInterval",void 0),r(this,"_rect",void 0),r(this,"currentEdges",[]),r(this,"start",(function(){i.applyElements("append"),i.updatePos()})),r(this,"applyElements",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"append",t=document.body?"body":"documentElement",s="".concat(e,"Child");i.HTMLNode[s](i.DS.Selector.HTMLNode),document[t][s](i.HTMLNode)})),r(this,"updatePos",(function(){i._rect=null;var e=i.DS.Area.rect,t=i.DS.Area.computedBorder,s=i.HTMLNode.style,n="".concat(e.top+t.top,"px"),r="".concat(e.left+t.left,"px"),o="".concat(e.width,"px"),c="".concat(e.height,"px");s.top!==n&&(s.top=n),s.left!==r&&(s.left=r),s.width!==o&&(s.width=o),s.height!==c&&(s.height=c)})),r(this,"stop",(function(e){i.stopAutoScroll(),e&&i.applyElements("remove")})),r(this,"startAutoScroll",(function(){i.currentEdges=[],i._scrollInterval=setInterval((function(){return i.handleAutoScroll()}),16)})),r(this,"handleAutoScroll",(function(){if(!i.DS.continue){var e=i.DS,t=e.stores.PointerStore,s=e.Area;i.currentEdges=T({elementRect:k(t.currentVal),containerRect:i.rect,tolerance:i.DS.stores.SettingsStore.s.overflowTolerance}),i.currentEdges.length&&s.scroll(i.currentEdges,i.DS.stores.SettingsStore.s.autoScrollSpeed)}})),r(this,"stopAutoScroll",(function(){i.currentEdges=[],clearInterval(i._scrollInterval)})),r(this,"isInside",(function(e,t){return!(!i.DS.Area.HTMLNode.contains(e)||!i.DS.stores.ScrollStore.canScroll)||O(i.rect,t||e.getBoundingClientRect())})),this.DS=o,this.HTMLNode=((n=document.createElement("div")).style.position="fixed",n.style.overflow="hidden",n.style.pointerEvents="none",n.style.zIndex="999999999999999999",n),this.DS.subscribe("Settings:updated:selectorAreaClass",(function(e){var t=e.settings;i.HTMLNode.classList.remove(t["selectorAreaClass:pre"]),i.HTMLNode.classList.add(t.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(){i.updatePos(),i.stopAutoScroll()}))}return i(e,[{key:"isClicked",value:function(e){var t=this.DS.stores.PointerStore,s=e?t.getPointerPosition(e):t.initialVal;return O({left:s.x,top:s.y,right:s.x,bottom:s.y},this.rect)}},{key:"rect",get:function(){return this._rect?this._rect:this._rect=this.HTMLNode.getBoundingClientRect()}}]),e}(),$=function(){function e(t){var n=this,i=t.DS;s(this,e),r(this,"_currentValues",new Set),r(this,"_keyMapping",{control:"ctrlKey",shift:"shiftKey",meta:"metaKey"}),r(this,"init",(function(){document.addEventListener("keydown",n.keydown),document.addEventListener("keyup",n.keyup),window.addEventListener("blur",n.reset)})),r(this,"keydown",(function(e){var t=e.key.toLowerCase();n.DS.publish("KeyStore:down:pre",{event:e,key:t}),n._currentValues.add(t),n.DS.publish("KeyStore:down",{event:e,key:t})})),r(this,"keyup",(function(e){var t=e.key.toLowerCase();n.DS.publish("KeyStore:up:pre",{event:e,key:t}),n._currentValues.delete(t),n.DS.publish("KeyStore:up",{event:e,key:t})})),r(this,"stop",(function(){document.removeEventListener("keydown",n.keydown),document.removeEventListener("keyup",n.reset),window.removeEventListener("blur",n.reset),n.reset()})),r(this,"reset",(function(){return n._currentValues.clear()})),this.DS=i,this.DS.subscribe("Interaction:init",this.init)}return i(e,[{key:"isMultiSelectKeyPressed",value:function(e){var t=this;if(this.DS.stores.SettingsStore.s.multiSelectMode)return!0;var s=this.DS.stores.SettingsStore.s.multiSelectKeys.map((function(e){return e.toLocaleLowerCase()}));return!!this.currentValues.some((function(e){return s.includes(e.toLocaleLowerCase())}))||!(!e||!s.some((function(s){return e[t._keyMapping[s]]})))}},{key:"currentValues",get:function(){return Array.from(this._currentValues.values())}}]),e}(),Q=function(){function e(t){var n=this,i=t.DS;s(this,e),r(this,"_isMouseInteraction",!1),r(this,"_initialValArea",void 0),r(this,"_currentValArea",void 0),r(this,"_lastValArea",void 0),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_lastVal",void 0),r(this,"_lastTouch",void 0),r(this,"init",(function(){n.Settings.usePointerEvents?document.addEventListener("pointermove",n.update,{passive:!1}):document.addEventListener("mousemove",n.update),document.addEventListener("touchmove",n.update,{passive:!1})})),r(this,"getPointerPosition",(function(e){return function(e){var t=e.event;return{x:t.clientX,y:t.clientY}}({event:n._normalizedEvent(e)})})),r(this,"update",(function(e){e&&(n.DS.publish("PointerStore:updated:pre",{event:e}),n.currentVal=n.getPointerPosition(e),n._isMouseInteraction&&n.DS.publish("PointerStore:updated",{event:e}))})),r(this,"stop",(function(){n.Settings.usePointerEvents?document.removeEventListener("pointermove",n.update,{passive:!1}):document.removeEventListener("mousemove",n.update),document.removeEventListener("touchmove",n.update,{passive:!1}),setTimeout((function(){return n._isMouseInteraction=!1}),100)})),r(this,"reset",(function(e){e&&(n.currentVal=n.lastVal=n.getPointerPosition(e),n.stop(),n.init())})),this.DS=i,this.Settings=i.stores.SettingsStore.s,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(e){var t=e.event;return n.start(t)})),this.DS.subscribe("Interaction:end",(function(e){var t=e.event;return n.reset(t)}))}return i(e,[{key:"start",value:function(e){e&&(this._isMouseInteraction=!0,this.currentVal=this.initialVal=this.getPointerPosition(e))}},{key:"_normalizedEvent",value:function(e){return"touches"in e&&"touchend"!==e.type&&(this._lastTouch=e),"touches"in e?this._lastTouch.touches[0]:e}},{key:"initialValArea",get:function(){return this._initialValArea?this._initialValArea:{x:0,y:0}}},{key:"currentValArea",get:function(){return this._currentValArea?this._currentValArea:{x:0,y:0}}},{key:"lastValArea",get:function(){return this._lastValArea?this._lastValArea:{x:0,y:0}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}},set:function(e){this._initialVal=e,this._initialValArea=e&&v(e,"-",v(_(this.DS.Area.rect),"+",_(this.DS.Area.computedBorder)))}},{key:"currentVal",get:function(){return this._currentVal?this._currentVal:{x:0,y:0}},set:function(e){this._currentVal=e,this._currentValArea=e&&v(e,"-",v(_(this.DS.Area.rect),"+",_(this.DS.Area.computedBorder)))}},{key:"lastVal",get:function(){return this._lastVal?this._lastVal:{x:0,y:0}},set:function(e){this._lastVal=e,this._lastValArea=e&&v(e,"-",v(_(this.DS.Area.rect),"+",_(this.DS.Area.computedBorder)))}}]),e}(),ee=function(){function e(t){var n=this,i=t.DS;s(this,e),r(this,"_initialVal",void 0),r(this,"_currentVal",void 0),r(this,"_canScroll",void 0),r(this,"init",(function(){return n.DS.stores.SettingsStore.s.area.addEventListener("scroll",n.update)})),r(this,"start",(function(){n._currentVal=n._initialVal=w(n.DS.stores.SettingsStore.s.area),n.DS.stores.SettingsStore.s.area.addEventListener("scroll",n.update)})),r(this,"update",(function(){return n._currentVal=w(n.DS.stores.SettingsStore.s.area)})),r(this,"stop",(function(){n.DS.stores.SettingsStore.s.area.removeEventListener("scroll",n.update),n._initialVal={x:0,y:0},n._canScroll=null})),r(this,"reset",(function(){n.stop(),n.start()})),this.DS=i,this.DS.subscribe("Interaction:init",this.init),this.DS.subscribe("Interaction:start",(function(){return n.start()})),this.DS.subscribe("Interaction:end",(function(){return n.reset()}))}return i(e,[{key:"canScroll",get:function(){return"boolean"==typeof this._canScroll?this._canScroll:this._canScroll=(e=this.DS.stores.SettingsStore.s.area,!!((t=w(e)).x||t.y||(e instanceof Document?e.body?e.body.scrollTop=1:e.documentElement.scrollTop=1:e.scrollTop=1)));var e,t}},{key:"scrollAmount",get:function(){var e,t=v(this.currentVal,"-",this.initialVal),s={x:e=this.DS.stores.SettingsStore.s.zoom,y:e},n=v(v(t,"*",s),"-",t);return{x:t.x+n.x,y:t.y+n.y}}},{key:"initialVal",get:function(){return this._initialVal?this._initialVal:{x:0,y:0}}},{key:"currentVal",get:function(){return this._currentVal||(this._currentVal=w(this.DS.stores.SettingsStore.s.area)),this._currentVal}}]),e}(),te=i((function e(n){var i=this,o=n.DS,c=n.settings;s(this,e),r(this,"_settings",{}),r(this,"s",{}),r(this,"update",(function(e){var s=e.settings,n=e.init;return i.DS.publish("Settings:updated:pre",t({settings:s},n?{init:n}:{}))})),r(this,"_update",(function(e){for(var s=function(e,s){return t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t({},A("area",e.area,s,document)),A("selectables",e.selectables,s,null)),A("autoScrollSpeed",e.autoScrollSpeed,s,5)),A("overflowTolerance",e.overflowTolerance,s,{x:25,y:25})),A("zoom",e.zoom,s,1)),A("customStyles",e.customStyles,s,!1)),A("multiSelectMode",e.multiSelectMode,s,!1)),A("multiSelectToggling",e.multiSelectToggling,s,!0)),A("multiSelectKeys",e.multiSelectKeys,s,["Control","Shift","Meta"])),A("selector",e.selector,s,null)),A("selectionThreshold",e.selectionThreshold,s,0)),A("draggability",e.draggability,s,!0)),A("immediateDrag",e.immediateDrag,s,!0)),A("keyboardDrag",e.keyboardDrag,s,!0)),A("dragKeys",e.dragKeys,s,{up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]})),A("keyboardDragSpeed",e.keyboardDragSpeed,s,10)),A("useTransform",e.useTransform,s,!0)),A("refreshMemoryRate",e.refreshMemoryRate,s,80)),A("dropZones",e.dropZones,s,[])),A("dropInsideThreshold",e.dropInsideThreshold,s,1)),A("dropTargetThreshold",e.dropTargetThreshold,s,0)),A("usePointerEvents",e.usePointerEvents,s,!1)),A("hoverClass",e.hoverClass,s,"ds-hover")),A("selectableClass",e.selectableClass,s,"ds-selectable")),A("selectedClass",e.selectedClass,s,"ds-selected")),A("selectorClass",e.selectorClass,s,"ds-selector")),A("selectorAreaClass",e.selectorAreaClass,s,"ds-selector-area")),A("droppedTargetClass",e.droppedTargetClass,s,"ds-dropped-target")),A("droppedInsideClass",e.droppedInsideClass,s,"ds-dropped-inside")),A("droppableClass",e.droppableClass,s,"ds-droppable")),A("dropZoneClass",e.dropZoneClass,s,"ds-dropzone")),A("dropZoneReadyClass",e.dropZoneReadyClass,s,"ds-dropzone-ready")),A("dropZoneTargetClass",e.dropZoneTargetClass,s,"ds-dropzone-target")),A("dropZoneInsideClass",e.dropZoneInsideClass,s,"ds-dropzone-inside")),A("dragAsBlock",e.dragAsBlock,s,!1))}(e.settings,e.init),n=function(){var e,t=S(c[o],2),s=t[0],n=t[1];s in i._settings||Object.defineProperty(i.s,s,{get:function(){return i._settings[s]},set:function(e){return i.update({settings:r({},s,e)})}}),i._settings["".concat(s,":pre")]=i._settings[s],i._settings[s]=n;var l={settings:(e={},r(e,s,i._settings[s]),r(e,"".concat(s,":pre"),i._settings["".concat(s,":pre")]),e)};i.DS.publish("Settings:updated",l),i.DS.publish("Settings:updated:".concat(s),l)},o=0,c=Object.entries(s);o<c.length;o++)n()})),this.DS=o,this.DS.subscribe("Settings:updated:pre",this._update),this.update({settings:c,init:!0})})),se=function(){function e(n){var i=this;s(this,e),r(this,"continue",!1),r(this,"start",(function(){i.stopped=!1,i.Interaction.init()})),r(this,"break",(function(){return i.continue=!0})),r(this,"setSettings",(function(e){return i.stores.SettingsStore.update({settings:e})})),r(this,"getSelection",(function(){return i.SelectedSet.elements})),r(this,"getSelectables",(function(){return i.SelectableSet.elements})),r(this,"getInitialCursorPosition",(function(){return i.stores.PointerStore.initialVal})),r(this,"getCurrentCursorPosition",(function(){return i.stores.PointerStore.currentVal})),r(this,"getPreviousCursorPosition",(function(){return i.stores.PointerStore.lastVal})),r(this,"getInitialCursorPositionArea",(function(){return i.stores.PointerStore.initialValArea})),r(this,"getCurrentCursorPositionArea",(function(){return i.stores.PointerStore.currentValArea})),r(this,"getPreviousCursorPositionArea",(function(){return i.stores.PointerStore.lastValArea})),r(this,"isMultiSelect",(function(e){return i.stores.KeyStore.isMultiSelectKeyPressed(e)})),r(this,"isDragging",(function(){return i.Interaction.isDragging})),r(this,"getZoneByCoordinates",(function(e){var t;return null===(t=i.DropZones.getTarget(e))||void 0===t?void 0:t.toObject()})),r(this,"getItemsDroppedByZoneId",(function(e){return i.DropZones.getItemsDroppedById(e)})),r(this,"getItemsInsideByZoneId",(function(e,t){return i.DropZones.getItemsInsideById(e,t)})),this.PubSub=new Z({DS:this}),this.subscribe=this.PubSub.subscribe,this.unsubscribe=this.PubSub.unsubscribe,this.publish=this.PubSub.publish,this.stores={},this.stores.SettingsStore=new te({DS:this,settings:n}),this.stores.PointerStore=new Q({DS:this}),this.stores.ScrollStore=new ee({DS:this}),this.stores.KeyStore=new $({DS:this}),this.Area=new z({DS:this}),this.Selector=new q({DS:this}),this.SelectorArea=new J({DS:this}),this.SelectableSet=new X({DS:this}),this.SelectedSet=new U({DS:this}),this.Selection=new Y({DS:this}),this.Drag=new G({DS:this}),this.DropZones=new H({DS:this}),this.Interaction=new W({DS:this}),function(e){for(var s=e.subscribe,n=e.publish,i=e.Interaction,r=e.SelectedSet,o=e.DropZones,c={"Selected:added":[{name:"elementselect"}],"Selected:removed":[{name:"elementunselect"}],"Area:scroll":[{name:"autoscroll"}],"Interaction:start":[{name:"dragstart"}],"Interaction:update":[{name:"dragmove",condition:function(e){return e.event}}],"Interaction:end":[{name:"callback",extraData:function(){var e=o.getTarget();return t({},e?{dropTarget:e.toObject()}:{})}}]},l=function(){var e=S(u[a],2),o=e[0],c=e[1];["pre",!1].forEach((function(e){return s(e?"".concat(o,":").concat(e):o,(function(s){return c.forEach((function(o){return(!o.condition||o.condition(s))&&n(e?"".concat(e).concat(o.name):o.name,t(t({items:r.elements,isDragging:i.isDragging},s),o.extraData?o.extraData(s):{}))}))}))}))},a=0,u=Object.entries(c);a<u.length;a++)l()}({subscribe:this.subscribe,publish:this.publish,SelectedSet:this.SelectedSet,Interaction:this.Interaction,DropZones:this.DropZones}),this.subscribe("Interaction:end",(function(){return i.continue=!1})),this.start()}return i(e,[{key:"stop",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&this.publish("callback",{items:this.getSelection()}),this.Interaction.stop(),this.Area.stop(),this.Drag.stop(),this.Selector.stop(),this.SelectorArea.stop(e),this.stores.KeyStore.stop(),this.stores.PointerStore.stop(),this.stores.ScrollStore.stop(),e&&this.SelectableSet.clear(),t&&this.SelectedSet.clear(),this.stopped=!0}},{key:"addSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.addAll(V(e)),s||this.addSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"removeSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.SelectedSet.deleteAll(V(e)),s&&this.removeSelectables(e),t&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"toggleSelection",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return V(e).forEach((function(i){return t.SelectedSet.has(i)?t.removeSelection(e,s,n):t.addSelection(e,s,n)})),s&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"setSelection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.clearSelection(),this.addSelection(e,t,s),this.getSelection()}},{key:"clearSelection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.SelectedSet.clear(),e&&this.PubSub.publish("callback",{items:this.getSelection()}),this.getSelection()}},{key:"addSelectables",value:function(e,t,s){var n=V(e);return this.SelectableSet.addAll(n),t&&this.SelectedSet.addAll(n),s&&this.PubSub.publish("callback",{items:this.getSelection()}),e}},{key:"setSelectables",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=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(e,t),this.addSelectables(e,s)}},{key:"removeSelectables",value:function(e,t,s){return this.SelectableSet.deleteAll(V(e)),t&&this.removeSelection(e),s&&this.PubSub.publish("callback",{items:this.getSelection()}),e}}]),e}();return se.isCollision=O,se}()},573:t=>{"use strict";t.exports=e}},s={};function n(e){var i=s[e];if(void 0!==i)return i.exports;var r=s[e]={exports:{}};return t[e].call(r.exports,r,r.exports,n),r.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{"use strict";n.r(i),n.d(i,{Multiselect:()=>b,MultiselectBlockDragger:()=>m,blockSelectionWeakMap:()=>t,inMultipleSelectionModeWeakMap:()=>s});var e=n(573);const t=new WeakMap,s=new WeakMap,r=new WeakMap,o=new Set,c=[];let l=0;const a=function(e,s=!1){for(;e;)if((e=s?e.getParent():e.getSurroundParent())&&t.get(e.workspace).has(e.id))return!0;return!1},u=function(){const e=[];o.forEach((t=>{delete t.source,e.push(t)})),l=Date.now(),localStorage.setItem("blocklyStashMulti",JSON.stringify(e)),localStorage.setItem("blocklyStashConnection",JSON.stringify(c)),localStorage.setItem("blocklyStashTime",l)},d=function(){const e=JSON.parse(localStorage.getItem("blocklyStashMulti")),t=JSON.parse(localStorage.getItem("blocklyStashConnection")),s=localStorage.getItem("blocklyStashTime");e&&parseInt(s)>l&&(l=s,o.clear(),e.forEach((e=>{o.add(e)})),c.length=0,t.forEach((e=>{c.push(e)})))},h=function(e){if(!e)return o.size;const t=JSON.parse(localStorage.getItem("blocklyStashMulti")),s=localStorage.getItem("blocklyStashTime");return t&&parseInt(s)>l?t.length:o.size},p=function(){e.ContextMenuRegistry.registry.unregister("blockDuplicate"),e.ContextMenuRegistry.registry.unregister("blockComment"),e.ContextMenuRegistry.registry.unregister("blockInline"),e.ContextMenuRegistry.registry.unregister("blockCollapseExpand"),e.ContextMenuRegistry.registry.unregister("blockDisable"),e.ContextMenuRegistry.registry.unregister("blockDelete")},g=function(){e.ShortcutRegistry.registry.unregister(e.ShortcutItems.names.DELETE),e.ShortcutRegistry.registry.unregister(e.ShortcutItems.names.COPY),e.ShortcutRegistry.registry.unregister(e.ShortcutItems.names.CUT),e.ShortcutRegistry.registry.unregister(e.ShortcutItems.names.PASTE)};var S=n(501),f=n.n(S);class y{constructor(e,s){this.enabled_img="https://github.com/mit-cml/workspace-multiselect/raw/main/test/media/select.svg",this.disabled_img="https://github.com/mit-cml/workspace-multiselect/raw/main/test/media/unselect.svg",this.workspace_=e,this.enabled=!1,this.id="multiselectControls",this.onMultiselectWrapper_=null,this.multiselectGroup_=null,this.initialized_=!1,this.hasDisableWorkspaceDrag_=!1,this.justUnselectedBlock_=null,s&&s.enabledIcon&&(this.enabled_img=s.enabledIcon),s&&s.disabledIcon&&(this.disabled_img=s.disabledIcon),this.blockSelection=t.get(e)}createDom(){return this.svgGroup_=e.utils.dom.createSvgElement(e.utils.Svg.G,{},null),this.createMultiselectSvg_(),this.svgGroup_}init(){this.workspace_.getComponentManager().addComponent({component:this,weight:3,capabilities:[e.ComponentManager.Capability.POSITIONABLE]}),this.initialized_=!0,this.workspace_.resize()}dispose(){this.disableMultiselect(),this.workspace_.getComponentManager().removeComponent(this.id),this.svgGroup_&&e.utils.dom.removeNode(this.svgGroup_),this.onMultiselectWrapper_&&e.browserEvents.unbind(this.onMultiselectWrapper_)}getBoundingRectangle(){const t=this.top_+32,s=this.left_+32;return new e.utils.Rect(this.top_,t,this.left_,s)}position(t,s){if(!this.initialized_)return;const n=e.uiPosition.getCornerOppositeToolbox(this.workspace_,t),i=e.uiPosition.getStartPositionRect(n,new e.utils.Size(32,32),20,20,t,this.workspace_),r=n.vertical===e.uiPosition.verticalPosition.TOP?e.uiPosition.bumpDirection.DOWN:e.uiPosition.bumpDirection.UP,o=e.uiPosition.bumpPositionRect(i,20,r,s);this.top_=o.top,this.left_=o.left,this.svgGroup_&&this.svgGroup_.setAttribute("transform","translate("+this.left_+","+this.top_+")")}createMultiselectSvg_(){this.multiselectGroup_=e.utils.dom.createSvgElement(e.utils.Svg.G,{class:"blocklyMultiselect"},this.svgGroup_),e.utils.dom.createSvgElement(e.utils.Svg.IMAGE,{width:32,height:32},this.multiselectGroup_).setAttributeNS(e.utils.dom.XLINK_NS,"xlink:href",this.disabled_img),this.onMultiselectWrapper_=e.browserEvents.conditionalBind(this.multiselectGroup_,"mousedown",null,this.switchMultiselect_.bind(this))}switchMultiselect_(t){this.workspace_.markFocused(),this.enabled=!this.enabled,this.enabled?this.enableMultiselect(!0):this.disableMultiselect(!0),e.Touch.clearTouchIdentifier(),t.stopPropagation(),t.preventDefault()}updateBlocks_(e){e&&e.pathObject&&(e.isDeletable()||e.isMovable())&&(this.blockSelection.has(e.id)?(this.blockSelection.delete(e.id),this.justUnselectedBlock_=e,e.pathObject.updateSelected(!1)):(this.blockSelection.add(e.id),this.justUnselectedBlock_=null,e.pathObject.updateSelected(!0),e.bringToFront()))}updateMultiselect(){s.get(this.workspace_)?this.justUnselectedBlock_&&e.getSelected()&&e.getSelected().id===this.justUnselectedBlock_.id&&(this.blockSelection.size?e.common.setSelected(this.workspace_.getBlockById(this.blockSelection.keys().next().value)):e.common.setSelected(null),this.justUnselectedBlock_.pathObject.updateSelected(!1),this.justUnselectedBlock_=null):(!e.getSelected()||e.getSelected()&&!this.blockSelection.has(e.getSelected().id))&&(this.blockSelection.forEach((e=>{const t=this.workspace_.getBlockById(e);t&&t.pathObject.updateSelected(!1)})),this.blockSelection.clear(),this.updateBlocks_(e.getSelected())),this.blockSelection.forEach((e=>{const t=this.workspace_.getBlockById(e);t&&t.pathObject.updateSelected(!0)}))}enableMultiselect(e=!1){!this.hasDisableWorkspaceDrag_&&this.workspace_.options.moveOptions&&this.workspace_.options.moveOptions.drag&&(this.workspace_.options.moveOptions.drag=!1,this.hasDisableWorkspaceDrag_=!0),this.dragSelect_=new(f())({selectables:document.querySelectorAll("g.blocklyDraggable:not(.blocklyInsertionMarker)> path.blocklyPath"),area:document.querySelector(".blocklyWorkspace"),multiselectMode:!0,draggability:!1,usePointerEvents:!0}),this.dragSelect_.Selection.filterSelected=({selectorRect:e,select:t,unselect:s})=>{const n=t,i=s;return((e,t)=>{const s=[];for(const[n,i]of e.entries())for(const[r,o]of e.entries())if(n!==r&&f().isCollision(o,i,0)&&null!==n.parentNode&&null!==r.parentNode&&n.parentNode!==r.parentNode&&n.parentNode.contains(r.parentNode)&&f().isCollision(t,o,1)){s.push(n);break}return s})(n,e).forEach((e=>{const t=n.get(e);n.delete(e),i.set(e,t)})),{select:n,unselect:i}},this.dragSelect_.subscribe("elementselect",(e=>{const t=e.item.parentElement;s.get(this.workspace_)&&t.dataset&&t.dataset.id&&this.updateBlocks_(this.workspace_.getBlockById(t.dataset.id))})),this.dragSelect_.subscribe("elementunselect",(e=>{const t=e.item.parentElement;s.get(this.workspace_)&&t.dataset&&t.dataset.id&&this.updateBlocks_(this.workspace_.getBlockById(t.dataset.id))})),e&&document.dispatchEvent(new KeyboardEvent("keydown",{key:"meta"})),this.updateMultiselectIcon(!0),s.set(this.workspace_,!0)}disableMultiselect(t=!1){s.set(this.workspace_,!1),this.dragSelect_&&(t&&document.dispatchEvent(new KeyboardEvent("keyup",{key:"meta"})),this.dragSelect_.stop(),this.dragSelect_=null),!this.blockSelection.size&&e.getSelected()?e.common.setSelected(null):this.blockSelection.size&&!e.getSelected()&&e.common.setSelected(this.workspace_.getBlockById(this.blockSelection.keys().next().value)),this.hasDisableWorkspaceDrag_&&(this.workspace_.options.moveOptions.drag=!0,this.hasDisableWorkspaceDrag_=!1),this.updateMultiselectIcon(!1)}updateMultiselectIcon(t){this.multiselectGroup_&&(this.enabled=t,t?this.multiselectGroup_.firstElementChild.setAttributeNS(e.utils.dom.XLINK_NS,"xlink:href",this.enabled_img):this.multiselectGroup_.firstElementChild.setAttributeNS(e.utils.dom.XLINK_NS,"xlink:href",this.disabled_img))}}e.Css.register("\n.blocklyMultiselect>image, .blocklyMultiselect>svg>image {\n opacity: .2;\n}\n\n.blocklyMultiselect>image:hover, .blocklyMultiselect>svg>image:hover {\n opacity: .4;\n}\n\n.blocklyMultiselect>image:active, .blocklyMultiselect>svg>image:active {\n opacity: .6;\n}\n");class b{constructor(n){this.workspace_=n,this.origHandleWsStart_=e.Gesture.prototype.handleWsStart,t.set(this.workspace_,new Set),this.blockSelection_=t.get(this.workspace_),s.set(this.workspace_,!1),r.set(this.workspace_,e.BlockDragger),this.useCopyPasteCrossTab_=!0,this.useCopyPasteMenu_=!0}init(s){if(this.onKeyDownWrapper_=e.browserEvents.conditionalBind(this.workspace_.getInjectionDiv(),"keydown",this,this.onKeyDown_),this.onKeyUpWrapper_=e.browserEvents.conditionalBind(globalThis.window,"blur",this,this.onBlur_),this.onKeyUpWrapper_=e.browserEvents.conditionalBind(this.workspace_.getInjectionDiv(),"keyup",this,this.onKeyUp_),this.eventListenerWrapper_=this.eventListener_.bind(this),this.workspace_.addChangeListener(this.eventListenerWrapper_),s.multiselectCopyPaste&&!1===s.multiselectCopyPaste.crossTab&&(this.useCopyPasteCrossTab_=!1),s.multiselectCopyPaste&&!1===s.multiselectCopyPaste.menu&&(this.useCopyPasteMenu_=!1),e.ContextMenuRegistry.registry.registry_.workspaceSelectAll||(p(),n=this.useCopyPasteMenu_,i=this.useCopyPasteCrossTab_,n&&(function(s){const n="blockCopyToStorage",i={displayText:function(s){let n=0;const r=s.block.workspace,o=t.get(r);return o&&o.forEach((function(e){const t=r.getBlockById(e);i.check(t)&&n++})),n<=1?e.Msg.CROSS_TAB_COPY?e.Msg.CROSS_TAB_COPY:"Copy":e.Msg.CROSS_TAB_COPY_X_BLOCKS?e.Msg.CROSS_TAB_COPY_X_BLOCKS.replace("%1",n):(e.Msg.CROSS_TAB_COPY?e.Msg.CROSS_TAB_COPY:"Copy")+" ("+n+")"},preconditionFn:function(n){const r=n.block.workspace;if(r.options.readOnly&&!s)return"hidden";const o=e.common.getSelected(),c=t.get(r);if(!c)return"hidden";if(!c.size)return i.check(o)?"enabled":"disabled";for(const e of c){const t=r.getBlockById(e);if(i.check(t))return"enabled"}return"disabled"},check:function(e){return e&&e.isDeletable()&&e.isMovable()&&!a(e)},callback:function(n){const r=n.block.workspace;o.clear(),r.hideChaff();const l=[],a=function(e){i.check(e)&&(o.add(e.toCopyData()),l.push(e.id))},d=e.common.getSelected(),h=t.get(r);return e.Events.setGroup(!0),h.size||a(d),h.forEach((function(e){const t=r.getBlockById(e);a(t)})),c.length=0,l.forEach((function(e){const t=r.getBlockById(e),s=t.getParent();s&&-1!==l.indexOf(s.id)&&s.getNextBlock()===t&&c.push([l.indexOf(s.id),l.indexOf(t.id)])})),s&&u(),e.Events.setGroup(!1),!0},scopeType:e.ContextMenuRegistry.ScopeType.BLOCK,id:n,weight:2};null!==e.ContextMenuRegistry.registry.getItem(n)&&e.ContextMenuRegistry.registry.unregister(n),e.ContextMenuRegistry.registry.register(i)}(i),function(s){const n="blockPasteFromStorage",i={displayText:function(){const t=h(s);return t<=1?e.Msg.CROSS_TAB_PASTE?e.Msg.CROSS_TAB_PASTE:"Paste":e.Msg.CROSS_TAB_PASTE_X_BLOCKS?e.Msg.CROSS_TAB_PASTE_X_BLOCKS.replace("%1",t):(e.Msg.CROSS_TAB_PASTE?e.Msg.CROSS_TAB_PASTE:"Paste")+" ("+t+")"},preconditionFn:function(e){return t.get(e.workspace)?e.workspace.options.readOnly?"hidden":h(s)<1?"disabled":"enabled":"hidden"},callback:function(n){let i=n.workspace;const r=t.get(i);e.Events.setGroup(!0),r.forEach((function(e){const t=i.getBlockById(e);t&&t.pathObject.updateSelected(!1)})),r.clear();const l=[];return s&&d(),o.forEach((function(e){if(e.source&&(i=e.source),i.isFlyout&&(i=i.targetWorkspace),e.typeCounts&&i.isCapacityAvailable(e.typeCounts)){const s=i.paste(e.blockState);l.push(s),s.pathObject.updateSelected(!0),t.get(s.workspace).add(s.id)}})),c.forEach((function(e){l[e[0]].nextConnection.connect(l[e[1]].previousConnection)})),e.Events.setGroup(!1),!0},scopeType:e.ContextMenuRegistry.ScopeType.WORKSPACE,id:n,weight:0};null!==e.ContextMenuRegistry.registry.getItem(n)&&e.ContextMenuRegistry.registry.unregister(n),e.ContextMenuRegistry.registry.register(i)}(i)),function(){const s={displayText:function(n){let i=0;const r=n.block.workspace;return t.get(r).forEach((function(e){const t=r.getBlockById(e);s.check(t)&&i++})),i<=1?e.Msg.DUPLICATE_BLOCK:e.Msg.DUPLICATE_X_BLOCKS?e.Msg.DUPLICATE_X_BLOCKS.replace("%1",i):e.Msg.DUPLICATE_BLOCK+" ("+i+")"},preconditionFn:function(e){const s=e.block.workspace;if(!t.get(s))return"hidden";const n=e.block;return!n.isInFlyout&&n.isDeletable()&&n.isMovable()?n.isDuplicatable()?"enabled":"disabled":"hidden"},check:function(e){return e&&"enabled"===s.preconditionFn({block:e})&&!a(e)},callback:function(n){const i={},r=[],o=function(t){s.check(t)&&(i[t.id]=e.clipboard.duplicate(t)),t.pathObject.updateSelected(!1)},c=n.block.workspace,l=t.get(c);e.Events.setGroup(!0),l.size||o(n.block),l.forEach((function(e){const t=c.getBlockById(e);o(t)})),l.clear();for(const[e,t]of Object.entries(i)){const s=c.getBlockById(e),n=s.getParent();t.id&&(n&&n.id in i&&n.getNextBlock()===s&&r.push([i[n.id].nextConnection,t.previousConnection]),l.add(t.id),t.pathObject.updateSelected(!0))}r.forEach((function(e){e[0].connect(e[1])})),e.Events.setGroup(!1)},scopeType:e.ContextMenuRegistry.ScopeType.BLOCK,id:"blockDuplicate",weight:1};e.ContextMenuRegistry.registry.register(s)}(),function(){const s={displayText:function(n){let i=0;const r=n.block.hasIcon(e.icons.CommentIcon.TYPE),o=n.block.workspace;return t.get(o).forEach((function(t){const n=o.getBlockById(t);s.check(n)&&r===n.hasIcon(e.icons.CommentIcon.TYPE)&&i++})),r?i<=1?e.Msg.REMOVE_COMMENT:e.Msg.REMOVE_X_COMMENTS?e.Msg.REMOVE_X_COMMENTS.replace("%1",i):e.Msg.REMOVE_COMMENT+" ("+i+")":i<=1?e.Msg.ADD_COMMENT:e.Msg.ADD_X_COMMENTS?e.Msg.ADD_X_COMMENTS.replace("%1",i):e.Msg.ADD_COMMENT+" ("+i+")"},preconditionFn:function(t){const s=t.block;return e.utils.userAgent.IE||s.isInFlyout||!s.workspace.options.comments||s.isCollapsed()||!s.isEditable()?"hidden":"enabled"},check:function(e){return e&&"enabled"===s.preconditionFn({block:e})},callback:function(n){const i=n.block.hasIcon(e.icons.CommentIcon.TYPE),r=function(e){s.check(e)&&(i?e.setCommentText(null):e.setCommentText(""))},o=n.block.workspace,c=t.get(o);e.Events.setGroup(!0),c.size||r(n.block),c.forEach((function(e){const t=o.getBlockById(e);r(t)})),e.Events.setGroup(!1)},scopeType:e.ContextMenuRegistry.ScopeType.BLOCK,id:"blockComment",weight:2};e.ContextMenuRegistry.registry.register(s)}(),function(){const s={displayText:function(n){let i=0;const r=n.block.getInputsInline(),o=n.block.workspace;return t.get(o).forEach((function(e){const t=o.getBlockById(e);s.check(t)&&t.getInputsInline()===r&&i++})),r?i<=1?e.Msg.EXTERNAL_INPUTS:e.Msg.EXTERNAL_X_INPUTS?e.Msg.EXTERNAL_X_INPUTS.replace("%1",i):e.Msg.EXTERNAL_INPUTS+" ("+i+")":i<=1?e.Msg.INLINE_INPUTS:e.Msg.INLINE_X_INPUTS?e.Msg.INLINE_X_INPUTS.replace("%1",i):e.Msg.INLINE_INPUTS+" ("+i+")"},preconditionFn:function(t){const s=t.block;if(!s.isInFlyout&&s.isMovable()&&!s.isCollapsed())for(let t=1;t<s.inputList.length;t++)if(s.inputList[t-1].type!==e.inputTypes.STATEMENT&&s.inputList[t].type!==e.inputTypes.STATEMENT)return"enabled";return"hidden"},check:function(e){return e&&"enabled"===s.preconditionFn({block:e})},callback:function(n){const i=!n.block.getInputsInline(),r=function(e){s.check(e)&&e.setInputsInline(i)},o=n.block.workspace,c=t.get(o);e.Events.setGroup(!0),c.size||r(n.block),c.forEach((function(e){const t=o.getBlockById(e);r(t)})),e.Events.setGroup(!1)},scopeType:e.ContextMenuRegistry.ScopeType.BLOCK,id:"blockInline",weight:3};e.ContextMenuRegistry.registry.register(s)}(),function(){const s={displayText:function(n){let i=0;const r=n.block.isCollapsed(),o=n.block.workspace;return t.get(o).forEach((function(e){const t=o.getBlockById(e);s.check(t)&&t.isCollapsed()===r&&i++})),r?i<=1?e.Msg.EXPAND_BLOCK:e.Msg.EXPAND_X_BLOCKS?e.Msg.EXPAND_X_BLOCKS.replace("%1",i):e.Msg.EXPAND_BLOCK+" ("+i+")":i<=1?e.Msg.COLLAPSE_BLOCK:e.Msg.COLLAPSE_X_BLOCKS?e.Msg.COLLAPSE_X_BLOCKS.replace("%1",i):e.Msg.COLLAPSE_BLOCK+" ("+i+")"},preconditionFn:function(e){const t=e.block;return!t.isInFlyout&&t.isMovable()&&t.workspace.options.collapse?"enabled":"hidden"},check:function(e){return e&&"enabled"===s.preconditionFn({block:e})&&(!a(e)||e.isCollapsed())},callback:function(n){const i=!n.block.isCollapsed(),r=function(e){s.check(e)&&e.setCollapsed(i)},o=n.block.workspace,c=t.get(o);e.Events.setGroup(!0),c.size||r(n.block),c.forEach((function(e){const t=o.getBlockById(e);r(t)})),e.Events.setGroup(!1)},scopeType:e.ContextMenuRegistry.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4};e.ContextMenuRegistry.registry.register(s)}(),function(){const s={displayText:function(n){let i=0;const r=n.block.isEnabled(),o=n.block.workspace;return t.get(o).forEach((function(e){const t=o.getBlockById(e);s.check(t)&&t.isEnabled()===r&&i++})),r?i<=1?e.Msg.DISABLE_BLOCK:e.Msg.DISABLE_X_BLOCKS?e.Msg.DISABLE_X_BLOCKS.replace("%1",i):e.Msg.DISABLE_BLOCK+" ("+i+")":i<=1?e.Msg.ENABLE_BLOCK:e.Msg.ENABLE_X_BLOCKS?e.Msg.ENABLE_X_BLOCKS.replace("%1",i):e.Msg.ENABLE_BLOCK+" ("+i+")"},preconditionFn:function(e){const t=e.block;return!t.isInFlyout&&t.workspace.options.disable&&t.isEditable()?t.getInheritedDisabled()?"disabled":"enabled":"hidden"},check:function(e){return e&&"enabled"===s.preconditionFn({block:e})&&(!a(e)||!e.isEnabled())},callback:function(n){const i=!n.block.isEnabled(),r=function(e){s.check(e)&&e.setEnabled(i)},o=n.block.workspace,c=t.get(o);e.Events.setGroup(!0),c.size||r(n.block),c.forEach((function(e){const t=o.getBlockById(e);r(t)})),e.Events.setGroup(!1)},scopeType:e.ContextMenuRegistry.ScopeType.BLOCK,id:"blockDisable",weight:5};e.ContextMenuRegistry.registry.register(s)}(),function(){const s={displayText:function(s){let n=0;const i=s.block.workspace;return t.get(i).forEach((function(e){const t=i.getBlockById(e);if(t&&!a(t)){n+=t.getDescendants(!1).length;const e=t.getNextBlock();e&&(n-=e.getDescendants(!1).length)}})),1===n?e.Msg.DELETE_BLOCK:e.Msg.DELETE_X_BLOCKS?e.Msg.DELETE_X_BLOCKS.replace("%1",n):e.Msg.DELETE_BLOCK+" ("+n+")"},preconditionFn:function(e){const s=e.block.workspace;return t.get(s)&&!e.block.isInFlyout&&e.block.isDeletable()?"enabled":"hidden"},check:function(e){return e&&!e.workspace.isFlyout&&"enabled"===s.preconditionFn({block:e})&&!a(e)},callback:function(n){const i=function(e){s.check(e)&&(e.workspace.hideChaff(),e.outputConnection?e.dispose(!1,!0):e.dispose(!0,!0))},r=n.block.workspace,o=t.get(r);e.Events.setGroup(!0),o.size||i(n.block),o.forEach((function(e){const t=r.getBlockById(e);i(t)})),e.Events.setGroup(!1)},scopeType:e.ContextMenuRegistry.ScopeType.BLOCK,id:"blockDelete",weight:6};e.ContextMenuRegistry.registry.register(s)}(),function(){const s="workspaceSelectAll",n={displayText:function(){return e.Msg.SELECT_ALL||"Select all Blocks"},preconditionFn:function(e){return t.get(e.workspace)?e.workspace.getTopBlocks().some((e=>n.check(e)))?"enabled":"disabled":"hidden"},check:function(e){return e&&(e.isDeletable()||e.isMovable())&&!e.isInsertionMarker()},callback:function(s){const i=t.get(s.workspace);e.getSelected()&&!i.has(e.getSelected().id)&&(e.getSelected().pathObject.updateSelected(!1),e.common.setSelected(null));const r=[];s.workspace.getTopBlocks().forEach((function(e){if(n.check(e)){r.push(e);let t=e.getNextBlock();for(;t;)r.push(t),t=t.getNextBlock()}})),r.forEach((function(s){t.get(s.workspace).add(s.id),e.common.getSelected()||e.common.setSelected(s),s.pathObject.updateSelected(!0)}))},scopeType:e.ContextMenuRegistry.ScopeType.WORKSPACE,id:s,weight:5};null!==e.ContextMenuRegistry.registry.getItem(s)&&e.ContextMenuRegistry.registry.unregister(s),e.ContextMenuRegistry.registry.register(n)}(),g(),function(s){!function(){const s={name:e.ShortcutItems.names.DELETE,preconditionFn:function(n){if(n.options.readOnly||e.Gesture.inProgress())return!1;const i=e.common.getSelected(),r=t.get(n);if(!r.size)return s.check(i);for(const e of r){const t=n.getBlockById(e);if(s.check(t))return!0}return!1},check:function(e){return e&&e.isDeletable()&&!e.workspace.isFlyout&&!a(e)},callback:function(n,i){i.preventDefault();const r=function(e){s.check(e)&&(e.workspace.hideChaff(),e.outputConnection?e.dispose(!1,!0):e.dispose(!0,!0))},o=e.common.getSelected();e.Events.setGroup(!0);const c=t.get(n);return c.size||r(o),c.forEach((function(e){const t=n.getBlockById(e);r(t)})),e.Events.setGroup(!1),!0}};e.ShortcutRegistry.registry.register(s),e.ShortcutRegistry.registry.addKeyMapping(e.utils.KeyCodes.DELETE,s.name),e.ShortcutRegistry.registry.addKeyMapping(e.utils.KeyCodes.BACKSPACE,s.name)}(),function(s){const n={name:e.ShortcutItems.names.COPY,preconditionFn:function(s){if(s.options.readOnly||e.Gesture.inProgress())return!1;const i=e.common.getSelected(),r=t.get(s);if(!r.size)return n.check(i);for(const e of r){const t=s.getBlockById(e);if(n.check(t))return!0}return!1},check:function(e){return e&&e.isDeletable()&&e.isMovable()&&!a(e)},callback:function(i,r){r.preventDefault(),o.clear(),i.hideChaff();const l=[],a=function(e){n.check(e)&&(o.add(e.toCopyData()),l.push(e.id))},d=e.common.getSelected(),h=t.get(i);return e.Events.setGroup(!0),h.size||a(d),h.forEach((function(e){const t=i.getBlockById(e);a(t)})),c.length=0,l.forEach((function(e){const t=i.getBlockById(e),s=t.getParent();s&&-1!==l.indexOf(s.id)&&s.getNextBlock()===t&&c.push([l.indexOf(s.id),l.indexOf(t.id)])})),s&&u(),e.Events.setGroup(!1),!0}};e.ShortcutRegistry.registry.register(n);const i=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.C,[e.utils.KeyCodes.CTRL]);e.ShortcutRegistry.registry.addKeyMapping(i,e.ShortcutItems.names.COPY);const r=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.C,[e.utils.KeyCodes.ALT]);e.ShortcutRegistry.registry.addKeyMapping(r,e.ShortcutItems.names.COPY);const l=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.C,[e.utils.KeyCodes.META]);e.ShortcutRegistry.registry.addKeyMapping(l,e.ShortcutItems.names.COPY)}(s),function(s){const n={name:e.ShortcutItems.names.CUT,preconditionFn:function(s){if(s.options.readOnly||e.Gesture.inProgress())return!1;const i=e.common.getSelected(),r=t.get(s);if(!r.size)return n.check(i);for(const e of r){const t=s.getBlockById(e);if(n.check(t))return!0}return!1},check:function(e){return e&&e.isDeletable()&&e.isMovable()&&!e.workspace.isFlyout&&!a(e)},callback:function(i){o.clear();const r=[],l=function(e){n.check(e)&&(o.add(e.toCopyData()),r.push(e.id))},a=e.common.getSelected(),d=t.get(i);return e.Events.setGroup(!0),d.size||l(a),d.forEach((function(e){const t=i.getBlockById(e);l(t)})),c.length=0,r.forEach((function(e){const t=i.getBlockById(e),s=t.getParent();s&&-1!==r.indexOf(s.id)&&s.getNextBlock()===t&&c.push([r.indexOf(s.id),r.indexOf(t.id)])})),r.forEach((function(e){var t;(t=i.getBlockById(e))&&(t.workspace.hideChaff(),t.outputConnection?t.dispose(!1,!0):t.dispose(!0,!0))})),s&&u(),e.Events.setGroup(!1),!0}};e.ShortcutRegistry.registry.register(n);const i=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.X,[e.utils.KeyCodes.CTRL]);e.ShortcutRegistry.registry.addKeyMapping(i,n.name);const r=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.X,[e.utils.KeyCodes.ALT]);e.ShortcutRegistry.registry.addKeyMapping(r,n.name);const l=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.X,[e.utils.KeyCodes.META]);e.ShortcutRegistry.registry.addKeyMapping(l,n.name)}(s),function(s){const n={name:e.ShortcutItems.names.PASTE,preconditionFn:function(t){return!t.options.readOnly&&!e.Gesture.inProgress()},callback:function(n){const i=t.get(n);e.Events.setGroup(!0),i.forEach((function(e){const t=n.getBlockById(e);t&&t.pathObject.updateSelected(!1)})),i.clear();const r=[];return s&&d(),o.forEach((function(e){if(e.source&&(n=e.source),n.isFlyout&&(n=n.targetWorkspace),e.typeCounts&&n.isCapacityAvailable(e.typeCounts)){const s=n.paste(e.blockState);r.push(s),s.pathObject.updateSelected(!0),t.get(s.workspace).add(s.id)}})),c.forEach((function(e){r[e[0]].nextConnection.connect(r[e[1]].previousConnection)})),e.Events.setGroup(!1),!0}};e.ShortcutRegistry.registry.register(n);const i=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.V,[e.utils.KeyCodes.CTRL]);e.ShortcutRegistry.registry.addKeyMapping(i,n.name);const r=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.V,[e.utils.KeyCodes.ALT]);e.ShortcutRegistry.registry.addKeyMapping(r,n.name);const l=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.V,[e.utils.KeyCodes.META]);e.ShortcutRegistry.registry.addKeyMapping(l,n.name)}(s),function(){const s="selectall",n={name:s,preconditionFn:function(e){return!!e.getTopBlocks().some((e=>n.check(e)))},check:function(e){return e&&(e.isDeletable()||e.isMovable())&&!e.isInsertionMarker()},callback:function(s,i){i.preventDefault();const r=t.get(s);e.getSelected()&&!r.has(e.getSelected().id)&&(e.getSelected().pathObject.updateSelected(!1),e.common.setSelected(null));const o=[];return s.getTopBlocks().forEach((function(e){if(n.check(e)){o.push(e);let t=e.getNextBlock();for(;t;)o.push(t),t=t.getNextBlock()}})),o.forEach((function(t){r.add(t.id),e.common.getSelected()||e.common.setSelected(t),t.pathObject.updateSelected(!0)})),!0}};s in e.ShortcutRegistry.registry.getRegistry()&&e.ShortcutRegistry.registry.unregister(s),e.ShortcutRegistry.registry.register(n);const i=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.A,[e.utils.KeyCodes.CTRL]);e.ShortcutRegistry.registry.addKeyMapping(i,n.name);const r=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.A,[e.utils.KeyCodes.ALT]);e.ShortcutRegistry.registry.addKeyMapping(r,n.name);const o=e.ShortcutRegistry.registry.createSerializedKey(e.utils.KeyCodes.A,[e.utils.KeyCodes.META]);e.ShortcutRegistry.registry.addKeyMapping(o,n.name)}()}(this.useCopyPasteCrossTab_)),this.controls_=new y(this.workspace_,s.multiselectIcon,this),!s.multiselectIcon||!s.multiselectIcon.hideIcon){const e=this.controls_.createDom();this.workspace_.getParentSvg().appendChild(e)}var n,i;this.controls_.init(),s.useDoubleClick&&this.useDoubleClick_(!0),s.baseBlockDragger&&r.set(this.workspace_,s.baseBlockDragger),s.bumpNeighbours||(this.origBumpNeighbours=e.BlockSvg.prototype.bumpNeighbours,e.BlockSvg.prototype.bumpNeighbours=function(){})}dispose(t=!1){this.onKeyDownWrapper_&&(e.browserEvents.unbind(this.onKeyDownWrapper_),this.onKeyDownWrapper_=null),this.onKeyUpWrapper_&&(e.browserEvents.unbind(this.onKeyUpWrapper_),this.onKeyUpWrapper_=null),this.eventListenerWrapper_&&(this.workspace_.removeChangeListener(this.eventListenerWrapper_),this.eventListenerWrapper_=null),t||(p(),this.useCopyPasteMenu_&&(e.ContextMenuRegistry.registry.unregister("blockCopyToStorage"),e.ContextMenuRegistry.registry.unregister("blockPasteFromStorage")),e.ContextMenuRegistry.registry.unregister("workspaceSelectAll"),e.ContextMenuItems.registerDuplicate(),e.ContextMenuItems.registerComment(),e.ContextMenuItems.registerInline(),e.ContextMenuItems.registerCollapseExpandBlock(),e.ContextMenuItems.registerDisable(),e.ContextMenuItems.registerDelete(),g(),e.ShortcutRegistry.registry.unregister("selectall"),e.ShortcutItems.registerDelete(),e.ShortcutItems.registerCopy(),e.ShortcutItems.registerCut(),e.ShortcutItems.registerPaste()),this.controls_&&(this.controls_.dispose(),this.controls_=null),this.useDoubleClick_(!1),this.origBumpNeighbours&&(e.BlockSvg.prototype.bumpNeighbours=this.origBumpNeighbours)}useDoubleClick_(n){e.Gesture.prototype.handleWsStart=n?function(n){if(n.isWrapped)return n;const i=function(i,r){if(n.call(this,i,r),this.targetBlock&&1===i.buttons&&!s.get(r)){const s=function(e){return!e.isInFlyout&&e.isMovable()&&e.workspace.options.collapse};if(e.getSelected()&&s(e.getSelected())){if(r.doubleClickPid_&&(clearTimeout(r.doubleClickPid_),r.doubleClickPid_=void 0,e.getSelected().id===r.doubleClickBlock_)){const n=!e.getSelected().isCollapsed(),i=function(e){e&&s(e)&&!a(e)&&e.setCollapsed(n)};e.Events.setGroup(!0);const o=t.get(r);return e.getSelected()&&!o.size&&i(e.getSelected()),o.forEach((function(e){const t=r.getBlockById(e);t&&i(t)})),void e.Events.setGroup(!1)}r.doubleClickPid_||(r.doubleClickBlock_=e.getSelected().id,r.doubleClickPid_=setTimeout((function(){r.doubleClickPid_=void 0}),500))}}};return i.isWrapped=!0,i}(e.Gesture.prototype.handleWsStart):this.origHandleWsStart_}eventListener_(t){if(t.type===e.Events.SELECTED)this.controls_.updateMultiselect();else if(t.type===e.Events.CHANGE&&"field"===t.element&&t.recordUndo&&this.blockSelection_.has(t.blockId)){const s=!!t.group;s||(e.Events.setGroup(!0),t.group=e.Events.getGroup());try{const e=this.workspace_.getBlockById(t.blockId).type;this.blockSelection_.forEach((s=>{const n=this.workspace_.getBlockById(s);n.type===e&&n.setFieldValue(t.newValue,t.name)}))}finally{s||e.Events.setGroup(!1)}}}onKeyDown_(t){t.keyCode!==e.utils.KeyCodes.SHIFT||s.get(this.workspace_)||this.controls_.enableMultiselect()}onKeyUp_(t){t.keyCode===e.utils.KeyCodes.SHIFT&&this.controls_.disableMultiselect()}onBlur_(){s.get(this.workspace_)&&this.controls_.disableMultiselect()}}class m extends e.BlockDragger{constructor(s,n){super(s,n),this.block_=s,this.workspace_=n,this.group_="",this.blockDraggers_=new Set,this.origHighlight_=e.RenderedConnection.prototype.highlight,this.BaseBlockDragger=r.get(n),this.origUpdateBlockAfterMove_=this.BaseBlockDragger.prototype.updateBlockAfterMove_,this.blockSelection=t.get(n)}dispose(){super.dispose(),this.blockDraggers_.forEach((e=>{e.dispose()}))}startDrag(t,n){if(s.get(this.workspace_))return;const i=[];this.blockSelection.has(this.block_.id)?this.blockSelection.forEach((e=>{const t=this.workspace_.getBlockById(e);t?a(t,!0)||i.push(new this.BaseBlockDragger(t,this.workspace_)):this.blockSelection.delete(e)})):(this.blockSelection.forEach((e=>{const t=this.workspace_.getBlockById(e);t&&t.pathObject.updateSelected(!1)})),this.blockSelection.clear(),i.push(new this.BaseBlockDragger(this.block_,this.workspace_)),this.block_.pathObject.updateSelected(!0)),i.length>1&&(e.RenderedConnection.prototype.highlight=function(){}),i.forEach((e=>{e.startDrag(t,n),this.blockDraggers_.add(e)}))}drag(e,t){this.blockDraggers_.forEach((function(s){s.drag(e,t)})),e.preventDefault(),e.stopPropagation()}endDrag(t,s){this.blockDraggers_.size>1&&this.patchUpdateBlockAfterMove(!0),this.blockDraggers_.forEach((n=>{e.Events.getGroup()?this.group_=e.Events.getGroup():e.Events.setGroup(this.group_),n.endDrag(t,s)})),this.blockDraggers_.size>1&&(e.RenderedConnection.prototype.highlight=this.origHighlight_,this.patchUpdateBlockAfterMove(!1))}moveBlockWhileDragging(e,t){this.blockDraggers_.forEach((function(s){s.moveBlockWhileDragging(e,t)}))}patchUpdateBlockAfterMove(s){this.BaseBlockDragger.prototype.updateBlockAfterMove_=s?function(){if(this.fireMoveEvent_(),this.draggedConnectionManager_.wouldConnectBlock()){const s=this.draggedConnectionManager_.activeCandidate.closest;t.get(this.workspace_).has(s.sourceBlock_.id)||a(s.sourceBlock_,!0)?(e.Events.disable(),this.draggedConnectionManager_.hidePreview(),e.Events.enable()):this.draggedConnectionManager_.applyConnections()}this.draggingBlock_.getDescendants(!1).forEach((function(e){e.getChildren().length||e.queueRender()})),this.draggingBlock_.scheduleSnapAndBump()}:this.origUpdateBlockAfterMove_}getInsertionMarkers(){const e=[];return this.blockDraggers_.forEach((function(t){e.push(...t.getInsertionMarkers())})),e}}e.registry.register(e.registry.Type.BLOCK_DRAGGER,"MultiselectBlockDragger",m)})(),i})()));