/*! * All material copyright ESRI, All Rights Reserved, unless otherwise specified. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details. * v1.0.0-beta.82 */ /**! * Sortable 1.15.0 * @author RubaXa * @author owenm * @license MIT */ function ownKeys(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))}o.push.apply(o,n)}return o}function _objectSpread2(e){for(var t=1;t=0)continue;o[r]=e[r]}return o}function _objectWithoutProperties(e,t){if(e==null)return{};var o=_objectWithoutPropertiesLoose(e,t);var n,r;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;o[n]=e[n]}}return o}var version="1.15.0";function userAgent(e){if(typeof window!=="undefined"&&window.navigator){return!!navigator.userAgent.match(e)}}var IE11OrLess=userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);var Edge=userAgent(/Edge/i);var FireFox=userAgent(/firefox/i);var Safari=userAgent(/safari/i)&&!userAgent(/chrome/i)&&!userAgent(/android/i);var IOS=userAgent(/iP(ad|od|hone)/i);var ChromeForAndroid=userAgent(/chrome/i)&&userAgent(/android/i);var captureMode={capture:false,passive:false};function on(e,t,o){e.addEventListener(t,o,!IE11OrLess&&captureMode)}function off(e,t,o){e.removeEventListener(t,o,!IE11OrLess&&captureMode)}function matches(e,t){if(!t)return;t[0]===">"&&(t=t.substring(1));if(e){try{if(e.matches){return e.matches(t)}else if(e.msMatchesSelector){return e.msMatchesSelector(t)}else if(e.webkitMatchesSelector){return e.webkitMatchesSelector(t)}}catch(e){return false}}return false}function getParentOrHost(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function closest(e,t,o,n){if(e){o=o||document;do{if(t!=null&&(t[0]===">"?e.parentNode===o&&matches(e,t):matches(e,t))||n&&e===o){return e}if(e===o)break}while(e=getParentOrHost(e))}return null}var R_SPACE=/\s+/g;function toggleClass(e,t,o){if(e&&t){if(e.classList){e.classList[o?"add":"remove"](t)}else{var n=(" "+e.className+" ").replace(R_SPACE," ").replace(" "+t+" "," ");e.className=(n+(o?" "+t:"")).replace(R_SPACE," ")}}}function css(e,t,o){var n=e&&e.style;if(n){if(o===void 0){if(document.defaultView&&document.defaultView.getComputedStyle){o=document.defaultView.getComputedStyle(e,"")}else if(e.currentStyle){o=e.currentStyle}return t===void 0?o:o[t]}else{if(!(t in n)&&t.indexOf("webkit")===-1){t="-webkit-"+t}n[t]=o+(typeof o==="string"?"":"px")}}}function matrix(e,t){var o="";if(typeof e==="string"){o=e}else{do{var n=css(e,"transform");if(n&&n!=="none"){o=n+" "+o}}while(!t&&(e=e.parentNode))}var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(o)}function find(e,t,o){if(e){var n=e.getElementsByTagName(t),r=0,l=n.length;if(o){for(;r=l}else{a=r<=l}if(!a)return n;if(n===getWindowScrollingElement())break;n=getParentAutoScrollElement(n,false)}return false}function getChild(e,t,o,n){var r=0,l=0,a=e.children;while(l2&&arguments[2]!==undefined?arguments[2]:{},r=n.evt,l=_objectWithoutProperties(n,_excluded);PluginManager.pluginEvent.bind(Sortable)(t,o,_objectSpread2({dragEl:dragEl,parentEl:parentEl,ghostEl:ghostEl,rootEl:rootEl,nextEl:nextEl,lastDownEl:lastDownEl,cloneEl:cloneEl,cloneHidden:cloneHidden,dragStarted:moved,putSortable:putSortable,activeSortable:Sortable.active,originalEvent:r,oldIndex:oldIndex,oldDraggableIndex:oldDraggableIndex,newIndex:newIndex,newDraggableIndex:newDraggableIndex,hideGhostForTarget:_hideGhostForTarget,unhideGhostForTarget:_unhideGhostForTarget,cloneNowHidden:function e(){cloneHidden=true},cloneNowShown:function e(){cloneHidden=false},dispatchSortableEvent:function e(t){_dispatchEvent({sortable:o,name:t,originalEvent:r})}},l))};function _dispatchEvent(e){dispatchEvent(_objectSpread2({putSortable:putSortable,cloneEl:cloneEl,targetEl:dragEl,rootEl:rootEl,oldIndex:oldIndex,oldDraggableIndex:oldDraggableIndex,newIndex:newIndex,newDraggableIndex:newDraggableIndex},e))}var dragEl,parentEl,ghostEl,rootEl,nextEl,lastDownEl,cloneEl,cloneHidden,oldIndex,newIndex,oldDraggableIndex,newDraggableIndex,activeGroup,putSortable,awaitingDragStarted=false,ignoreNextClick=false,sortables=[],tapEvt,touchEvt,lastDx,lastDy,tapDistanceLeft,tapDistanceTop,moved,lastTarget,lastDirection,pastFirstInvertThresh=false,isCircumstantialInvert=false,targetMoveDistance,ghostRelativeParent,ghostRelativeParentInitialScroll=[],_silent=false,savedInputChecked=[];var documentExists=typeof document!=="undefined",PositionGhostAbsolutely=IOS,CSSFloatProperty=Edge||IE11OrLess?"cssFloat":"float",supportDraggable=documentExists&&!ChromeForAndroid&&!IOS&&"draggable"in document.createElement("div"),supportCssPointerEvents=function(){if(!documentExists)return;if(IE11OrLess){return false}var e=document.createElement("x");e.style.cssText="pointer-events:auto";return e.style.pointerEvents==="auto"}(),_detectDirection=function e(t,o){var n=css(t),r=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),l=getChild(t,0,o),a=getChild(t,1,o),i=l&&css(l),s=a&&css(a),c=i&&parseInt(i.marginLeft)+parseInt(i.marginRight)+getRect(l).width,u=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+getRect(a).width;if(n.display==="flex"){return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal"}if(n.display==="grid"){return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal"}if(l&&i["float"]&&i["float"]!=="none"){var d=i["float"]==="left"?"left":"right";return a&&(s.clear==="both"||s.clear===d)?"vertical":"horizontal"}return l&&(i.display==="block"||i.display==="flex"||i.display==="table"||i.display==="grid"||c>=r&&n[CSSFloatProperty]==="none"||a&&n[CSSFloatProperty]==="none"&&c+u>r)?"vertical":"horizontal"},_dragElInRowColumn=function e(t,o,n){var r=n?t.left:t.top,l=n?t.right:t.bottom,a=n?t.width:t.height,i=n?o.left:o.top,s=n?o.right:o.bottom,c=n?o.width:o.height;return r===i||l===s||r+a/2===i+c/2},_detectNearestEmptySortable=function e(t,o){var n;sortables.some((function(e){var r=e[expando].options.emptyInsertThreshold;if(!r||lastChild(e))return;var l=getRect(e),a=t>=l.left-r&&t<=l.right+r,i=o>=l.top-r&&o<=l.bottom+r;if(a&&i){return n=e}}));return n},_prepareGroup=function e(t){function o(e,t){return function(n,r,l,a){var i=n.options.group.name&&r.options.group.name&&n.options.group.name===r.options.group.name;if(e==null&&(t||i)){return true}else if(e==null||e===false){return false}else if(t&&e==="clone"){return e}else if(typeof e==="function"){return o(e(n,r,l,a),t)(n,r,l,a)}else{var s=(t?n:r).options.group.name;return e===true||typeof e==="string"&&e===s||e.join&&e.indexOf(s)>-1}}}var n={};var r=t.group;if(!r||_typeof(r)!="object"){r={name:r}}n.name=r.name;n.checkPull=o(r.pull,true);n.checkPut=o(r.put);n.revertClone=r.revertClone;t.group=n},_hideGhostForTarget=function e(){if(!supportCssPointerEvents&&ghostEl){css(ghostEl,"display","none")}},_unhideGhostForTarget=function e(){if(!supportCssPointerEvents&&ghostEl){css(ghostEl,"display","")}};if(documentExists&&!ChromeForAndroid){document.addEventListener("click",(function(e){if(ignoreNextClick){e.preventDefault();e.stopPropagation&&e.stopPropagation();e.stopImmediatePropagation&&e.stopImmediatePropagation();ignoreNextClick=false;return false}}),true)}var nearestEmptyInsertDetectEvent=function e(t){if(dragEl){t=t.touches?t.touches[0]:t;var o=_detectNearestEmptySortable(t.clientX,t.clientY);if(o){var n={};for(var r in t){if(t.hasOwnProperty(r)){n[r]=t[r]}}n.target=n.rootEl=o;n.preventDefault=void 0;n.stopPropagation=void 0;o[expando]._onDragOver(n)}}};var _checkOutsideTargetEl=function e(t){if(dragEl){dragEl.parentNode[expando]._isOutsideThisEl(t.target)}};function Sortable(e,t){if(!(e&&e.nodeType&&e.nodeType===1)){throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e))}this.el=e;this.options=t=_extends({},t);e[expando]=this;var o={group:null,sort:true,disabled:false,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:false,invertedSwapThreshold:null,removeCloneOnHide:true,direction:function t(){return _detectDirection(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:true,animation:0,easing:null,setData:function e(t,o){t.setData("Text",o.textContent)},dropBubble:false,dragoverBubble:false,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:false,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:false,fallbackClass:"sortable-fallback",fallbackOnBody:false,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:Sortable.supportPointer!==false&&"PointerEvent"in window&&!Safari,emptyInsertThreshold:5};PluginManager.initializePlugins(this,e,o);for(var n in o){!(n in t)&&(t[n]=o[n])}_prepareGroup(t);for(var r in this){if(r.charAt(0)==="_"&&typeof this[r]==="function"){this[r]=this[r].bind(this)}}this.nativeDraggable=t.forceFallback?false:supportDraggable;if(this.nativeDraggable){this.options.touchStartThreshold=1}if(t.supportPointer){on(e,"pointerdown",this._onTapStart)}else{on(e,"mousedown",this._onTapStart);on(e,"touchstart",this._onTapStart)}if(this.nativeDraggable){on(e,"dragover",this);on(e,"dragenter",this)}sortables.push(this.el);t.store&&t.store.get&&this.sort(t.store.get(this)||[]);_extends(this,AnimationStateManager())}Sortable.prototype={constructor:Sortable,_isOutsideThisEl:function e(t){if(!this.el.contains(t)&&t!==this.el){lastTarget=null}},_getDirection:function e(t,o){return typeof this.options.direction==="function"?this.options.direction.call(this,t,o,dragEl):this.options.direction},_onTapStart:function e(t){if(!t.cancelable)return;var o=this,n=this.el,r=this.options,l=r.preventOnFilter,a=t.type,i=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,s=(i||t).target,c=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||s,u=r.filter;_saveInputCheckedState(n);if(dragEl){return}if(/mousedown|pointerdown/.test(a)&&t.button!==0||r.disabled){return}if(c.isContentEditable){return}if(!this.nativeDraggable&&Safari&&s&&s.tagName.toUpperCase()==="SELECT"){return}s=closest(s,r.draggable,n,false);if(s&&s.animated){return}if(lastDownEl===s){return}oldIndex=index(s);oldDraggableIndex=index(s,r.draggable);if(typeof u==="function"){if(u.call(this,t,s,this)){_dispatchEvent({sortable:o,rootEl:c,name:"filter",targetEl:s,toEl:n,fromEl:n});pluginEvent("filter",o,{evt:t});l&&t.cancelable&&t.preventDefault();return}}else if(u){u=u.split(",").some((function(e){e=closest(c,e.trim(),n,false);if(e){_dispatchEvent({sortable:o,rootEl:e,name:"filter",targetEl:s,fromEl:n,toEl:n});pluginEvent("filter",o,{evt:t});return true}}));if(u){l&&t.cancelable&&t.preventDefault();return}}if(r.handle&&!closest(c,r.handle,n,false)){return}this._prepareDragStart(t,i,s)},_prepareDragStart:function e(t,o,n){var r=this,l=r.el,a=r.options,i=l.ownerDocument,s;if(n&&!dragEl&&n.parentNode===l){var c=getRect(n);rootEl=l;dragEl=n;parentEl=dragEl.parentNode;nextEl=dragEl.nextSibling;lastDownEl=n;activeGroup=a.group;Sortable.dragged=dragEl;tapEvt={target:dragEl,clientX:(o||t).clientX,clientY:(o||t).clientY};tapDistanceLeft=tapEvt.clientX-c.left;tapDistanceTop=tapEvt.clientY-c.top;this._lastX=(o||t).clientX;this._lastY=(o||t).clientY;dragEl.style["will-change"]="all";s=function e(){pluginEvent("delayEnded",r,{evt:t});if(Sortable.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents();if(!FireFox&&r.nativeDraggable){dragEl.draggable=true}r._triggerDragStart(t,o);_dispatchEvent({sortable:r,name:"choose",originalEvent:t});toggleClass(dragEl,a.chosenClass,true)};a.ignore.split(",").forEach((function(e){find(dragEl,e.trim(),_disableDraggable)}));on(i,"dragover",nearestEmptyInsertDetectEvent);on(i,"mousemove",nearestEmptyInsertDetectEvent);on(i,"touchmove",nearestEmptyInsertDetectEvent);on(i,"mouseup",r._onDrop);on(i,"touchend",r._onDrop);on(i,"touchcancel",r._onDrop);if(FireFox&&this.nativeDraggable){this.options.touchStartThreshold=4;dragEl.draggable=true}pluginEvent("delayStart",this,{evt:t});if(a.delay&&(!a.delayOnTouchOnly||o)&&(!this.nativeDraggable||!(Edge||IE11OrLess))){if(Sortable.eventCanceled){this._onDrop();return}on(i,"mouseup",r._disableDelayedDrag);on(i,"touchend",r._disableDelayedDrag);on(i,"touchcancel",r._disableDelayedDrag);on(i,"mousemove",r._delayedDragTouchMoveHandler);on(i,"touchmove",r._delayedDragTouchMoveHandler);a.supportPointer&&on(i,"pointermove",r._delayedDragTouchMoveHandler);r._dragStartTimer=setTimeout(s,a.delay)}else{s()}}},_delayedDragTouchMoveHandler:function e(t){var o=t.touches?t.touches[0]:t;if(Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))){this._disableDelayedDrag()}},_disableDelayedDrag:function e(){dragEl&&_disableDraggable(dragEl);clearTimeout(this._dragStartTimer);this._disableDelayedDragEvents()},_disableDelayedDragEvents:function e(){var t=this.el.ownerDocument;off(t,"mouseup",this._disableDelayedDrag);off(t,"touchend",this._disableDelayedDrag);off(t,"touchcancel",this._disableDelayedDrag);off(t,"mousemove",this._delayedDragTouchMoveHandler);off(t,"touchmove",this._delayedDragTouchMoveHandler);off(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function e(t,o){o=o||t.pointerType=="touch"&&t;if(!this.nativeDraggable||o){if(this.options.supportPointer){on(document,"pointermove",this._onTouchMove)}else if(o){on(document,"touchmove",this._onTouchMove)}else{on(document,"mousemove",this._onTouchMove)}}else{on(dragEl,"dragend",this);on(rootEl,"dragstart",this._onDragStart)}try{if(document.selection){_nextTick((function(){document.selection.empty()}))}else{window.getSelection().removeAllRanges()}}catch(e){}},_dragStarted:function e(t,o){awaitingDragStarted=false;if(rootEl&&dragEl){pluginEvent("dragStarted",this,{evt:o});if(this.nativeDraggable){on(document,"dragover",_checkOutsideTargetEl)}var n=this.options;!t&&toggleClass(dragEl,n.dragClass,false);toggleClass(dragEl,n.ghostClass,true);Sortable.active=this;t&&this._appendGhost();_dispatchEvent({sortable:this,name:"start",originalEvent:o})}else{this._nulling()}},_emulateDragOver:function e(){if(touchEvt){this._lastX=touchEvt.clientX;this._lastY=touchEvt.clientY;_hideGhostForTarget();var t=document.elementFromPoint(touchEvt.clientX,touchEvt.clientY);var o=t;while(t&&t.shadowRoot){t=t.shadowRoot.elementFromPoint(touchEvt.clientX,touchEvt.clientY);if(t===o)break;o=t}dragEl.parentNode[expando]._isOutsideThisEl(t);if(o){do{if(o[expando]){var n=void 0;n=o[expando]._onDragOver({clientX:touchEvt.clientX,clientY:touchEvt.clientY,target:t,rootEl:o});if(n&&!this.options.dragoverBubble){break}}t=o}while(o=o.parentNode)}_unhideGhostForTarget()}},_onTouchMove:function e(t){if(tapEvt){var o=this.options,n=o.fallbackTolerance,r=o.fallbackOffset,l=t.touches?t.touches[0]:t,a=ghostEl&&matrix(ghostEl,true),i=ghostEl&&a&&a.a,s=ghostEl&&a&&a.d,c=PositionGhostAbsolutely&&ghostRelativeParent&&getRelativeScrollOffset(ghostRelativeParent),u=(l.clientX-tapEvt.clientX+r.x)/(i||1)+(c?c[0]-ghostRelativeParentInitialScroll[0]:0)/(i||1),d=(l.clientY-tapEvt.clientY+r.y)/(s||1)+(c?c[1]-ghostRelativeParentInitialScroll[1]:0)/(s||1);if(!Sortable.active&&!awaitingDragStarted){if(n&&Math.max(Math.abs(l.clientX-this._lastX),Math.abs(l.clientY-this._lastY))=0){_dispatchEvent({rootEl:parentEl,name:"add",toEl:parentEl,fromEl:rootEl,originalEvent:t});_dispatchEvent({sortable:this,name:"remove",toEl:parentEl,originalEvent:t});_dispatchEvent({rootEl:parentEl,name:"sort",toEl:parentEl,fromEl:rootEl,originalEvent:t});_dispatchEvent({sortable:this,name:"sort",toEl:parentEl,originalEvent:t})}putSortable&&putSortable.save()}else{if(newIndex!==oldIndex){if(newIndex>=0){_dispatchEvent({sortable:this,name:"update",toEl:parentEl,originalEvent:t});_dispatchEvent({sortable:this,name:"sort",toEl:parentEl,originalEvent:t})}}}if(Sortable.active){if(newIndex==null||newIndex===-1){newIndex=oldIndex;newDraggableIndex=oldDraggableIndex}_dispatchEvent({sortable:this,name:"end",toEl:parentEl,originalEvent:t});this.save()}}}this._nulling()},_nulling:function e(){pluginEvent("nulling",this);rootEl=dragEl=parentEl=ghostEl=nextEl=cloneEl=lastDownEl=cloneHidden=tapEvt=touchEvt=moved=newIndex=newDraggableIndex=oldIndex=oldDraggableIndex=lastTarget=lastDirection=putSortable=activeGroup=Sortable.dragged=Sortable.ghost=Sortable.clone=Sortable.active=null;savedInputChecked.forEach((function(e){e.checked=true}));savedInputChecked.length=lastDx=lastDy=0},handleEvent:function e(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":if(dragEl){this._onDragOver(t);_globalDragOver(t)}break;case"selectstart":t.preventDefault();break}},toArray:function e(){var t=[],o,n=this.el.children,r=0,l=n.length,a=this.options;for(;rn.right+r||e.clientX<=n.right&&e.clientY>n.bottom&&e.clientX>=n.left:e.clientX>n.right&&e.clientY>n.top||e.clientX<=n.right&&e.clientY>n.bottom+r}function _getSwapDirection(e,t,o,n,r,l,a,i){var s=n?e.clientY:e.clientX,c=n?o.height:o.width,u=n?o.top:o.left,d=n?o.bottom:o.right,f=false;if(!a){if(i&&targetMoveDistanceu+c*l/2:sd-targetMoveDistance){return-lastDirection}}else{f=true}}else{if(s>u+c*(1-r)/2&&sd-c*l/2){return s>u+c/2?1:-1}}return 0}function _getInsertDirection(e){if(index(dragEl)