@timluo465/sortablejs
Version:
JavaScript library for reorderable drag-and-drop lists on modern browsers and touch devices. No jQuery required. Supports Meteor, AngularJS, React, Polymer, Vue, Knockout and any CSS library, e.g. Bootstrap.
2 lines • 42.7 kB
JavaScript
/*! Sortable 1.0.0 - MIT | git://github.com/TimLuo465/Sortable.git */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Sortable=e()}(this,function(){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(){return(a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function I(i){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?e(r,!0).forEach(function(t){var e,n,o;e=i,o=r[n=t],n in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(r)):e(r).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(r,t))})}return i}function l(t,e){if(null==t)return{};var n,o,i=function(t,e){if(null==t)return{};var n,o,i={},r=Object.keys(t);for(o=0;o<r.length;o++)n=r[o],0<=e.indexOf(n)||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(o=0;o<r.length;o++)n=r[o],0<=e.indexOf(n)||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function r(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function t(t){return!!navigator.userAgent.match(t)}var y=t(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),E=t(/Edge/i),s=t(/firefox/i),c=t(/safari/i)&&!t(/chrome/i)&&!t(/android/i),n=t(/iP(ad|od|hone)/i),u=t(/chrome/i)&&t(/android/i),d={capture:!1,passive:!1};function h(t,e,n){t.addEventListener(e,n,!y&&d)}function f(t,e,n){t.removeEventListener(e,n,!y&&d)}function p(t,e){if(e){if(">"===e[0]&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return!1}return!1}}function P(t,e,n,o){if(t){n=n||document;do{if(null!=e&&(">"===e[0]?t.parentNode===n&&p(t,e):p(t,e))||o&&t===n)return t;if(t===n)break}while(t=(i=t).host&&i!==document&&i.host.nodeType?i.host:i.parentNode)}var i;return null}var g,v=/\s+/g;function k(t,e,n){if(t&&e)if(t.classList)t.classList[n?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(v," ").replace(" "+e+" "," ");t.className=(o+(n?" "+e:"")).replace(v," ")}}function R(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];e in o||-1!==e.indexOf("webkit")||(e="-webkit-"+e),o[e]=n+("string"==typeof n?"":"px")}}function m(t,e){var n="";do{var o=R(t,"transform");o&&"none"!==o&&(n=o+" "+n)}while(!e&&(t=t.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix;return i&&new i(n)}function b(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i<r;i++)n(o[i],i);return o}return[]}function M(){return y?document.documentElement:document.scrollingElement}function X(t,e,n,o,i){if(t.getBoundingClientRect||t===window){var r,a,l,s,c,u,d;if(d=t!==window&&t!==M()?(a=(r=t.getBoundingClientRect()).top,l=r.left,s=r.bottom,c=r.right,u=r.height,r.width):(l=a=0,s=window.innerHeight,c=window.innerWidth,u=window.innerHeight,window.innerWidth),(e||n)&&t!==window&&(i=i||t.parentNode,!y))do{if(i&&i.getBoundingClientRect&&("none"!==R(i,"transform")||n&&"static"!==R(i,"position"))){var h=i.getBoundingClientRect();a-=h.top+parseInt(R(i,"border-top-width")),l-=h.left+parseInt(R(i,"border-left-width")),s=a+r.height,c=l+r.width;break}}while(i=i.parentNode);if(o&&t!==window){var f=m(i||t),p=f&&f.a,g=f&&f.d;f&&(s=(a/=g)+(u/=g),c=(l/=p)+(d/=p))}return{top:a,left:l,bottom:s,right:c,width:d,height:u}}}function Y(t,e,n,o){for(var i=A(t,!0),r=(e||X(t))[n];i;){var a=X(i)[o];if(!("top"===o||"left"===o?a<=r:r<=a))return i;if(i===M())break;i=A(i,!1)}return!1}function w(t,e,n){for(var o=0,i=0,r=t.children;i<r.length;){if("none"!==r[i].style.display&&r[i]!==It.ghost&&r[i]!==It.dragged&&P(r[i],n.draggable,t,!1)){if(o===e)return r[i];o++}i++}return null}function B(t,e){for(var n=t.lastElementChild;n&&(n===It.ghost||"none"===R(n,"display")||e&&!p(n,e));)n=n.previousElementSibling;return n||null}function F(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)"TEMPLATE"===t.nodeName.toUpperCase()||t===It.clone||e&&!p(t,e)||n++;return n}function D(t){var e=0,n=0,o=M();if(t)do{var i=m(t),r=i.a,a=i.d;e+=t.scrollLeft*r,n+=t.scrollTop*a}while(t!==o&&(t=t.parentNode));return[e,n]}function A(t,e){if(!t||!t.getBoundingClientRect)return M();var n=t,o=!1;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=R(n);if(n.clientWidth<n.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||n.clientHeight<n.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!n.getBoundingClientRect||n===document.body)return M();if(o||e)return n;o=!0}}}while(n=n.parentNode);return M()}function _(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}function S(e,n){return function(){if(!g){var t=arguments;1===t.length?e.call(this,t[0]):e.apply(this,t),g=setTimeout(function(){g=void 0},n)}}}function j(t,e,n){t.scrollLeft+=e,t.scrollTop+=n}function C(t){var e=window.Polymer,n=window.jQuery||window.Zepto;return e&&e.dom?e.dom(t).cloneNode(!0):n?n(t).clone(!0)[0]:t.cloneNode(!0)}function O(t,e){R(t,"position","absolute"),R(t,"top",e.top),R(t,"left",e.left),R(t,"width",e.width),R(t,"height",e.height)}function T(t){R(t,"position",""),R(t,"top",""),R(t,"left",""),R(t,"width",""),R(t,"height","")}var H="Sortable"+(new Date).getTime();function x(){var e,o=[];return{captureAnimationState:function(){o=[],this.options.animation&&[].slice.call(this.el.children).forEach(function(t){if("none"!==R(t,"display")&&t!==It.ghost){o.push({target:t,rect:X(t)});var e=X(t);if(t.thisAnimationDuration){var n=m(t,!0);n&&(e.top-=n.f,e.left-=n.e)}t.fromRect=e}})},addAnimationState:function(t){o.push(t)},removeAnimationState:function(t){o.splice(function(t,e){for(var n in t)if(t.hasOwnProperty(n))for(var o in e)if(e.hasOwnProperty(o)&&e[o]===t[n][o])return Number(n);return-1}(o,{target:t}),1)},animateAll:function(t){var c=this;if(!this.options.animation)return clearTimeout(e),void("function"==typeof t&&t());var u=!1,d=0;o.forEach(function(t){var e=0,n=t.target,o=n.fromRect,i=X(n),r=n.prevFromRect,a=n.prevToRect,l=t.rect,s=m(n,!0);s&&(i.top-=s.f,i.left-=s.e),n.toRect=i,(Y(n,i,"bottom","top")||Y(n,i,"top","bottom")||Y(n,i,"right","left")||Y(n,i,"left","right"))&&(Y(n,l,"bottom","top")||Y(n,l,"top","bottom")||Y(n,l,"right","left")||Y(n,l,"left","right"))&&(Y(n,o,"bottom","top")||Y(n,o,"top","bottom")||Y(n,o,"right","left")||Y(n,o,"left","right"))||(n.thisAnimationDuration&&_(r,i)&&!_(o,i)&&(l.top-i.top)/(l.left-i.left)==(o.top-i.top)/(o.left-i.left)&&(e=function(t,e,n,o){return Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))/Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))*o.animation}(l,r,a,c.options)),_(i,o)||(n.prevFromRect=o,n.prevToRect=i,e=e||c.options.animation,c.animate(n,l,e)),e&&(u=!0,d=Math.max(d,e),clearTimeout(n.animationResetTimer),n.animationResetTimer=setTimeout(function(){n.animationTime=0,n.prevFromRect=null,n.fromRect=null,n.prevToRect=null,n.thisAnimationDuration=null},e),n.thisAnimationDuration=e))}),clearTimeout(e),u?e=setTimeout(function(){"function"==typeof t&&t()},d):"function"==typeof t&&t(),o=[]},animate:function(t,e,n){if(n){R(t,"transition",""),R(t,"transform","");var o=X(t),i=m(this.el),r=i&&i.a,a=i&&i.d,l=(e.left-o.left)/(r||1),s=(e.top-o.top)/(a||1);t.animatingX=!!l,t.animatingY=!!s,R(t,"transform","translate3d("+l+"px,"+s+"px,0)"),function(t){t.offsetWidth}(t),R(t,"transition","transform "+n+"ms"+(this.options.easing?" "+this.options.easing:"")),R(t,"transform","translate3d(0,0,0)"),"number"==typeof t.animated&&clearTimeout(t.animated),t.animated=setTimeout(function(){R(t,"transition",""),R(t,"transform",""),t.animated=!1,t.animatingX=!1,t.animatingY=!1},n)}}}}var N=[],L={initializeByDefault:!0},K={mount:function(t){for(var e in L)!L.hasOwnProperty(e)||e in t||(t[e]=L[e]);N.push(t)},pluginEvent:function(e,n,o){var i=this;this.eventCanceled=!1;var r=e+"Global";N.forEach(function(t){n[t.pluginName]&&(n[t.pluginName][r]&&(i.eventCanceled=!!n[t.pluginName][r](I({sortable:n},o))),n.options[t.pluginName]&&n[t.pluginName][e]&&(i.eventCanceled=i.eventCanceled||!!n[t.pluginName][e](I({sortable:n},o))))})},initializePlugins:function(o,i,r){for(var t in N.forEach(function(t){var e=t.pluginName;if(o.options[e]||t.initializeByDefault){var n=new t(o,i);(n.sortable=o)[e]=n,a(r,n.options)}}),o.options)if(o.options.hasOwnProperty(t)){var e=this.modifyOption(o,t,o.options[t]);void 0!==e&&(o.options[t]=e)}},getEventOptions:function(e,n){var o={};return N.forEach(function(t){"function"==typeof t.eventOptions&&a(o,t.eventOptions.call(n,e))}),o},modifyOption:function(e,n,o){var i;return N.forEach(function(t){e[t.pluginName]&&t.optionListeners&&"function"==typeof t.optionListeners[n]&&(i=t.optionListeners[n].call(e[t.pluginName],o))}),i}};function W(t){var e,n=t.sortable,o=t.rootEl,i=t.name,r=t.targetEl,a=t.cloneEl,l=t.toEl,s=t.fromEl,c=t.oldIndex,u=t.newIndex,d=t.oldDraggableIndex,h=t.newDraggableIndex,f=t.originalEvent,p=t.putSortable,g=t.eventOptions,v=(n=n||o[H]).options,m="on"+i.charAt(0).toUpperCase()+i.substr(1);!window.CustomEvent||y||E?(e=document.createEvent("Event")).initEvent(i,!0,!0):e=new CustomEvent(i,{bubbles:!0,cancelable:!0}),e.to=l||o,e.from=s||o,e.item=r||o,e.clone=a,e.oldIndex=c,e.newIndex=u,e.oldDraggableIndex=d,e.newDraggableIndex=h,e.originalEvent=f,e.pullMode=p?p.lastPutMode:void 0;var b=I({},g,{},K.getEventOptions(i,n));for(var w in b)e[w]=b[w];o&&o.dispatchEvent(e),v[m]&&v[m].call(n,e)}function z(t,e,n){var o=2<arguments.length&&void 0!==n?n:{},i=o.evt,r=l(o,["evt"]);K.pluginEvent.bind(It)(t,e,I({dragEl:U,parentEl:q,ghostEl:V,rootEl:Z,nextEl:Q,lastDownEl:$,cloneEl:J,cloneHidden:tt,dragStarted:ct,putSortable:at,activeSortable:It.active,originalEvent:i,oldIndex:et,oldDraggableIndex:ot,newIndex:nt,newDraggableIndex:it,hideGhostForTarget:xt,unhideGhostForTarget:Mt,cloneNowHidden:function(){tt=!0},cloneNowShown:function(){tt=!1},dispatchSortableEvent:function(t){G({sortable:e,name:t,originalEvent:i})}},r))}function G(t){W(I({putSortable:at,cloneEl:J,targetEl:U,rootEl:Z,oldIndex:et,oldDraggableIndex:ot,newIndex:nt,newDraggableIndex:it},t))}if("undefined"==typeof window||!window.document)throw new Error("Sortable.js requires a window with a document");var U,q,V,Z,Q,$,J,tt,et,nt,ot,it,rt,at,lt,st,ct,ut,dt,ht,ft,pt=!1,gt=!1,vt=[],mt=!1,bt=!1,wt=[],yt=!1,Et=[],Dt=n,_t=E||y?"cssFloat":"float",St=!u&&!n&&"draggable"in document.createElement("div"),Ct=function(){if(y)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents}(),Ot=function(t,e){var n=R(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),i=w(t,0,e),r=w(t,1,e),a=i&&R(i),l=r&&R(r),s=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+X(i).width,c=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+X(r).width;if("flex"===n.display)return"column"===n.flexDirection||"column-reverse"===n.flexDirection?"vertical":"horizontal";if("grid"===n.display)return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&"none"!==a.float){var u="left"===a.float?"left":"right";return!r||"both"!==l.clear&&l.clear!==u?"horizontal":"vertical"}return i&&("block"===a.display||"flex"===a.display||"table"===a.display||"grid"===a.display||o<=s&&"none"===n[_t]||r&&"none"===n[_t]&&o<s+c)?"vertical":"horizontal"},Tt=function(t){function s(a,l){return function(t,e,n,o){var i=t.options.group.name&&e.options.group.name&&t.options.group.name===e.options.group.name;if(null==a&&(l||i))return!0;if(null==a||!1===a)return!1;if(l&&"clone"===a)return a;if("function"==typeof a)return s(a(t,e,n,o),l)(t,e,n,o);var r=(l?t:e).options.group.name;return!0===a||"string"==typeof a&&a===r||a.join&&-1<a.indexOf(r)}}var e={},n=t.group;n&&"object"==o(n)||(n={name:n}),e.name=n.name,e.checkPull=s(n.pull,!0),e.checkPut=s(n.put),e.revertClone=n.revertClone,t.group=e},xt=function(){!Ct&&V&&R(V,"display","none")},Mt=function(){!Ct&&V&&R(V,"display","")};document.addEventListener("click",function(t){if(gt)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),gt=!1},!0);function At(t){if(U){var e=function(r,a){var l;return vt.some(function(t){if(!B(t)){var e=X(t),n=t[H].options.emptyInsertThreshold,o=r>=e.left-n&&r<=e.right+n,i=a>=e.top-n&&a<=e.bottom+n;return n&&o&&i?l=t:void 0}}),l}((t=t.touches?t.touches[0]:t).clientX,t.clientY);if(e){var n={};for(var o in t)t.hasOwnProperty(o)&&(n[o]=t[o]);n.target=n.rootEl=e,n.preventDefault=void 0,n.stopPropagation=void 0,e[H]._onDragOver(n)}}}function Nt(t){U&&U.parentNode[H]._isOutsideThisEl(t.target)}function It(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=a({},e),t[H]=this;var n={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Ot(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==It.supportPointer&&"PointerEvent"in window,emptyInsertThreshold:5};for(var o in K.initializePlugins(this,t,n),n)o in e||(e[o]=n[o]);for(var i in Tt(e),this)"_"===i.charAt(0)&&"function"==typeof this[i]&&(this[i]=this[i].bind(this));this.nativeDraggable=!e.forceFallback&&St,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?h(t,"pointerdown",this._onTapStart):(h(t,"mousedown",this._onTapStart),h(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(h(t,"dragover",this),h(t,"dragenter",this)),vt.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),a(this,x())}function Pt(t,e,n,o,i,r,a,l){var s,c,u=t[H],d=u.options.onMove;return!window.CustomEvent||y||E?(s=document.createEvent("Event")).initEvent("move",!0,!0):s=new CustomEvent("move",{bubbles:!0,cancelable:!0}),s.to=e,s.from=t,s.dragged=n,s.draggedRect=o,s.related=i||e,s.relatedRect=r||X(e),s.willInsertAfter=l,s.originalEvent=a,t.dispatchEvent(s),d&&(c=d.call(u,s,a)),c}function kt(t){t.draggable=!1}function Rt(){yt=!1}function Xt(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,n=e.length,o=0;n--;)o+=e.charCodeAt(n);return o.toString(36)}function Yt(t){return setTimeout(t,0)}function Bt(t){return clearTimeout(t)}It.prototype={constructor:It,_isOutsideThisEl:function(t){this.el.contains(t)||t===this.el||(ut=null)},_getDirection:function(t,e){return"function"==typeof this.options.direction?this.options.direction.call(this,t,e,U):this.options.direction},_onTapStart:function(e){if(e.cancelable){var n=this,o=this.el,t=this.options,i=t.preventOnFilter,r=e.type,a=e.touches&&e.touches[0],l=(a||e).target,s=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,c=t.filter;if(function(t){Et.length=0;var e=t.getElementsByTagName("input"),n=e.length;for(;n--;){var o=e[n];o.checked&&Et.push(o)}}(o),!U&&!(/mousedown|pointerdown/.test(r)&&0!==e.button||t.disabled||s.isContentEditable||(l=P(l,t.draggable,o,!1))&&l.animated||$===l)){if(et=F(l),ot=F(l,t.draggable),"function"==typeof c){if(c.call(this,e,l,this))return G({sortable:n,rootEl:s,name:"filter",targetEl:l,toEl:o,fromEl:o}),z("filter",n,{evt:e}),void(i&&e.cancelable&&e.preventDefault())}else if(c=c&&c.split(",").some(function(t){if(t=P(s,t.trim(),o,!1))return G({sortable:n,rootEl:t,name:"filter",targetEl:l,fromEl:o,toEl:o}),z("filter",n,{evt:e}),!0}))return void(i&&e.cancelable&&e.preventDefault());t.handle&&!P(s,t.handle,o,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(t,e,n){var o,i=this,r=i.el,a=i.options,l=r.ownerDocument;if(n&&!U&&n.parentNode===r)if(Z=r,q=(U=n).parentNode,Q=U.nextSibling,$=n,rt=a.group,lt={target:It.dragged=U,clientX:(e||t).clientX,clientY:(e||t).clientY},this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,U.style["will-change"]="all",o=function(){z("delayEnded",i,{evt:t}),It.eventCanceled?i._onDrop():(i._disableDelayedDragEvents(),!s&&i.nativeDraggable&&(U.draggable=!0),i._triggerDragStart(t,e),G({sortable:i,name:"choose",originalEvent:t}),k(U,a.chosenClass,!0))},a.ignore.split(",").forEach(function(t){b(U,t.trim(),kt)}),h(l,"dragover",At),h(l,"mousemove",At),h(l,"touchmove",At),h(l,"mouseup",i._onDrop),h(l,"touchend",i._onDrop),h(l,"touchcancel",i._onDrop),s&&this.nativeDraggable&&(this.options.touchStartThreshold=4,U.draggable=!0),z("delayStart",this,{evt:t}),!a.delay||a.delayOnTouchOnly&&!e||this.nativeDraggable&&(E||y))o();else{if(It.eventCanceled)return void this._onDrop();h(l,"mouseup",i._disableDelayedDrag),h(l,"touchend",i._disableDelayedDrag),h(l,"touchcancel",i._disableDelayedDrag),h(l,"mousemove",i._delayedDragTouchMoveHandler),h(l,"touchmove",i._delayedDragTouchMoveHandler),a.supportPointer&&h(l,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(o,a.delay)}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){U&&kt(U),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;f(t,"mouseup",this._disableDelayedDrag),f(t,"touchend",this._disableDelayedDrag),f(t,"touchcancel",this._disableDelayedDrag),f(t,"mousemove",this._delayedDragTouchMoveHandler),f(t,"touchmove",this._delayedDragTouchMoveHandler),f(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||"touch"==t.pointerType&&t,!this.nativeDraggable||e?this.options.supportPointer?h(document,"pointermove",this._onTouchMove):h(document,e?"touchmove":"mousemove",this._onTouchMove):(h(U,"dragend",this),h(Z,"dragstart",this._onDragStart));try{document.selection?Yt(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){if(pt=!1,Z&&U){z("dragStarted",this,{evt:e}),this.nativeDraggable&&h(document,"dragover",Nt);var n=this.options;t||k(U,n.dragClass,!1),k(U,n.ghostClass,!0),It.active=this,t&&this._appendGhost(),G({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(st){this._lastX=st.clientX,this._lastY=st.clientY,xt();for(var t=document.elementFromPoint(st.clientX,st.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(st.clientX,st.clientY))!==e;)e=t;if(U.parentNode[H]._isOutsideThisEl(t),e)do{if(e[H]){if(e[H]._onDragOver({clientX:st.clientX,clientY:st.clientY,target:t,rootEl:e})&&!this.options.dragoverBubble)break}t=e}while(e=e.parentNode);Mt()}},_onTouchMove:function(t){if(lt){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,i=t.touches?t.touches[0]:t,r=V&&m(V),a=V&&r&&r.a,l=V&&r&&r.d,s=Dt&&ft&&D(ft),c=(i.clientX-lt.clientX+o.x)/(a||1)+(s?s[0]-wt[0]:0)/(a||1),u=(i.clientY-lt.clientY+o.y)/(l||1)+(s?s[1]-wt[1]:0)/(l||1),d=t.touches?"translate3d("+c+"px,"+u+"px,0)":"translate("+c+"px,"+u+"px)";if(!It.active&&!pt){if(n&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))<n)return;this._onDragStart(t,!0)}st=i,R(V,"webkitTransform",d),R(V,"mozTransform",d),R(V,"msTransform",d),R(V,"transform",d),t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!V){var t=this.options.fallbackOnBody?document.body:Z,e=X(U,!0,Dt,!0,t),n=this.options;if(Dt){for(ft=t;"static"===R(ft,"position")&&"none"===R(ft,"transform")&&ft!==document;)ft=ft.parentNode;ft!==document.body&&ft!==document.documentElement?(ft===document&&(ft=M()),e.top+=ft.scrollTop,e.left+=ft.scrollLeft):ft=M(),wt=D(ft)}k(V=U.cloneNode(!0),n.ghostClass,!1),k(V,n.fallbackClass,!0),k(V,n.dragClass,!0),R(V,"transition",""),R(V,"transform",""),R(V,"box-sizing","border-box"),R(V,"margin",0),R(V,"top",e.top),R(V,"left",e.left),R(V,"width",e.width),R(V,"height",e.height),R(V,"opacity","0.8"),R(V,"position",Dt?"absolute":"fixed"),R(V,"zIndex","100000"),R(V,"pointerEvents","none"),It.ghost=V,t.appendChild(V)}},_onDragStart:function(t,e){var n=this,o=t.dataTransfer,i=n.options;z("dragStart",this,{evt:t}),It.eventCanceled?this._onDrop():(z("setupClone",this),It.eventCanceled||((J=C(U)).draggable=!1,J.style["will-change"]="",this._hideClone(),k(J,this.options.chosenClass,!1),It.clone=J),n.cloneId=Yt(function(){z("clone",n),It.eventCanceled||(n.options.removeCloneOnHide||Z.insertBefore(J,U),n._hideClone(),G({sortable:n,name:"clone"}))}),e||k(U,i.dragClass,!0),e?(gt=!0,n._loopId=setInterval(n._emulateDragOver,50)):(f(document,"mouseup",n._onDrop),f(document,"touchend",n._onDrop),f(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",i.setData&&i.setData.call(n,o,U)),h(document,"drop",n),R(U,"transform","translateZ(0)")),pt=!0,n._dragStartId=Yt(n._dragStarted.bind(n,e,t)),h(document,"selectstart",n),ct=!0,c&&R(document.body,"user-select","none"))},_onDragOver:function(n){var o,i,r,a,l=this.el,s=n.target,e=this.options,t=e.group,c=It.active,u=rt===t,d=e.sort,h=at||c,f=this,p=!1;if(!yt){if(void 0!==n.preventDefault&&n.cancelable&&n.preventDefault(),s=P(s,e.draggable,l,!0),x("dragOver"),It.eventCanceled)return p;if(U.contains(n.target)||s.animated&&s.animatingX&&s.animatingY||f._ignoreWhileAnimating===s)return A(!1);if(gt=!1,c&&!e.disabled&&(u?d||(r=!Z.contains(U)):at===this||(this.lastPutMode=rt.checkPull(this,c,U,n))&&t.checkPut(this,c,U,n))){if(a="vertical"===this._getDirection(n,s),o=X(U),x("dragOverValid"),It.eventCanceled)return p;if(r)return q=Z,M(),this._hideClone(),x("revert"),It.eventCanceled||(Q?Z.insertBefore(U,Q):Z.appendChild(U)),A(!0);var g=B(l,e.draggable);if(!g||function(t,e,n){var o=X(B(n.el,n.options.draggable));return e?t.clientX>o.right+10||t.clientX<=o.right&&t.clientY>o.bottom&&t.clientX>=o.left:t.clientX>o.right&&t.clientY>o.top||t.clientX<=o.right&&t.clientY>o.bottom+10}(n,a,this)&&!g.animated){if(g===U)return A(!1);if(g&&l===n.target&&(s=g),s&&(i=X(s)),!1!==Pt(Z,l,U,o,s,i,n,!!s))return M(),l.appendChild(U),q=l,N(),A(!0)}else if(s.parentNode===l){i=X(s);var v,m,b,w=U.parentNode!==l,y=!function(t,e,n){var o=n?t.left:t.top,i=n?t.right:t.bottom,r=n?t.width:t.height,a=n?e.left:e.top,l=n?e.right:e.bottom,s=n?e.width:e.height;return o===a||i===l||o+r/2===a+s/2}(U.animated&&U.toRect||o,s.animated&&s.toRect||i,a),E=a?"top":"left",D=Y(s,null,"top","top")||Y(U,null,"top","top"),_=D?D.scrollTop:void 0;if(ut!==s&&(m=i[E],mt=!1,bt=!y&&e.invertSwap||w),0!==(v=function(t,e,n,o,i,r,a,l){var s=o?t.clientY:t.clientX,c=o?n.height:n.width,u=o?n.top:n.left,d=o?n.bottom:n.right,h=!1;if(!a)if(l&&ht<c*i){if(!mt&&(1===dt?u+c*r/2<s:s<d-c*r/2)&&(mt=!0),mt)h=!0;else if(1===dt?s<u+ht:d-ht<s)return-dt}else if(u+c*(1-i)/2<s&&s<d-c*(1-i)/2)return function(t){return F(U)<F(t)?1:-1}(e);if((h=h||a)&&(s<u+c*r/2||d-c*r/2<s))return u+c/2<s?1:-1;return 0}(n,s,i,a,y?1:e.swapThreshold,null==e.invertedSwapThreshold?e.swapThreshold:e.invertedSwapThreshold,bt,ut===s)))for(var S=F(U);S-=v,(b=q.children[S])&&("none"===R(b,"display")||b===V););if(0===v||b===s)return A(!1);dt=v;var C=(ut=s).nextElementSibling,O=!1,T=Pt(Z,l,U,o,s,i,n,O=1===v);if(!1!==T)return 1!==T&&-1!==T||(O=1===T),yt=!0,setTimeout(Rt,30),M(),O&&!C?l.appendChild(U):s.parentNode.insertBefore(U,O?C:s),D&&j(D,0,_-D.scrollTop),q=U.parentNode,void 0===m||bt||(ht=Math.abs(m-X(s)[E])),N(),A(!0)}if(l.contains(U))return A(!1)}return!1}function x(t,e){z(t,f,I({evt:n,isOwner:u,axis:a?"vertical":"horizontal",revert:r,dragRect:o,targetRect:i,canSort:d,fromSortable:h,target:s,completed:A,onMove:function(t,e){return Pt(Z,l,U,o,t,X(t),n,e)},changed:N},e))}function M(){x("dragOverAnimationCapture"),f.captureAnimationState(),f!==h&&h.captureAnimationState()}function A(t){return x("dragOverCompleted",{insertion:t}),t&&(u?c._hideClone():c._showClone(f),f!==h&&(k(U,at?at.options.ghostClass:c.options.ghostClass,!1),k(U,e.ghostClass,!0)),at!==f&&f!==It.active?at=f:f===It.active&&at&&(at=null),h===f&&(f._ignoreWhileAnimating=s),f.animateAll(function(){x("dragOverAnimationComplete"),f._ignoreWhileAnimating=null}),f!==h&&(h.animateAll(),h._ignoreWhileAnimating=null)),(s===U&&!U.animated||s===l&&!s.animated)&&(ut=null),e.dragoverBubble||n.rootEl||s===document||(U.parentNode[H]._isOutsideThisEl(n.target),t||At(n)),!e.dragoverBubble&&n.stopPropagation&&n.stopPropagation(),p=!0}function N(){nt=F(U),it=F(U,e.draggable),G({sortable:f,name:"change",toEl:l,newIndex:nt,newDraggableIndex:it,originalEvent:n})}},_ignoreWhileAnimating:null,_offMoveEvents:function(){f(document,"mousemove",this._onTouchMove),f(document,"touchmove",this._onTouchMove),f(document,"pointermove",this._onTouchMove),f(document,"dragover",At),f(document,"mousemove",At),f(document,"touchmove",At)},_offUpEvents:function(){var t=this.el.ownerDocument;f(t,"mouseup",this._onDrop),f(t,"touchend",this._onDrop),f(t,"pointerup",this._onDrop),f(t,"touchcancel",this._onDrop),f(document,"selectstart",this)},_onDrop:function(t){var e=this.el,n=this.options;nt=F(U),it=F(U,n.draggable),z("drop",this,{evt:t}),nt=F(U),it=F(U,n.draggable),It.eventCanceled||(mt=bt=pt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Bt(this.cloneId),Bt(this._dragStartId),this.nativeDraggable&&(f(document,"drop",this),f(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),c&&R(document.body,"user-select",""),t&&(ct&&(t.cancelable&&t.preventDefault(),n.dropBubble||t.stopPropagation()),V&&V.parentNode&&V.parentNode.removeChild(V),(Z===q||at&&"clone"!==at.lastPutMode)&&J&&J.parentNode&&J.parentNode.removeChild(J),U&&(this.nativeDraggable&&f(U,"dragend",this),kt(U),U.style["will-change"]="",ct&&!pt&&k(U,at?at.options.ghostClass:this.options.ghostClass,!1),k(U,this.options.chosenClass,!1),G({sortable:this,name:"unchoose",toEl:q,newIndex:null,newDraggableIndex:null,originalEvent:t}),Z!==q?(0<=nt&&(G({rootEl:q,name:"add",toEl:q,fromEl:Z,originalEvent:t}),G({sortable:this,name:"remove",toEl:q,originalEvent:t}),G({rootEl:q,name:"sort",toEl:q,fromEl:Z,originalEvent:t}),G({sortable:this,name:"sort",toEl:q,originalEvent:t})),at&&at.save()):nt!==et&&0<=nt&&(G({sortable:this,name:"update",toEl:q,originalEvent:t}),G({sortable:this,name:"sort",toEl:q,originalEvent:t})),It.active&&(null!=nt&&-1!==nt||(nt=et,it=ot),G({sortable:this,name:"end",toEl:q,originalEvent:t}),this.save())))),this._nulling()},_nulling:function(){z("nulling",this),Z=U=q=V=Q=J=$=tt=lt=st=ct=nt=it=et=ot=ut=dt=at=rt=It.dragged=It.ghost=It.clone=It.active=null,Et.forEach(function(t){t.checked=!0}),Et.length=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":U&&(this._onDragOver(t),function(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move");t.cancelable&&t.preventDefault()}(t));break;case"selectstart":t.preventDefault()}},toArray:function(){for(var t,e=[],n=this.el.children,o=0,i=n.length,r=this.options;o<i;o++)P(t=n[o],r.draggable,this.el,!1)&&e.push(t.getAttribute(r.dataIdAttr)||Xt(t));return e},sort:function(t){var o={},i=this.el;this.toArray().forEach(function(t,e){var n=i.children[e];P(n,this.options.draggable,i,!1)&&(o[t]=n)},this),t.forEach(function(t){o[t]&&(i.removeChild(o[t]),i.appendChild(o[t]))})},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return P(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var n=this.options;if(void 0===e)return n[t];var o=K.modifyOption(this,t,e);n[t]=void 0!==o?o:e,"group"===t&&Tt(n)},destroy:function(){z("destroy",this);var t=this.el;t[H]=null,f(t,"mousedown",this._onTapStart),f(t,"touchstart",this._onTapStart),f(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(f(t,"dragover",this),f(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),vt.splice(vt.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!tt){if(z("hideClone",this),It.eventCanceled)return;R(J,"display","none"),this.options.removeCloneOnHide&&J.parentNode&&J.parentNode.removeChild(J),tt=!0}},_showClone:function(t){if("clone"===t.lastPutMode){if(tt){if(z("showClone",this),It.eventCanceled)return;Z.contains(U)&&!this.options.group.revertClone?Z.insertBefore(J,U):Q?Z.insertBefore(J,Q):Z.appendChild(J),this.options.group.revertClone&&this._animate(U,J),R(J,"display",""),tt=!1}}else this._hideClone()}},h(document,"touchmove",function(t){(It.active||pt)&&t.cancelable&&t.preventDefault()}),It.utils={on:h,off:f,css:R,find:b,is:function(t,e){return!!P(t,e,t,!1)},extend:function(t,e){if(t&&e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t},throttle:S,closest:P,toggleClass:k,clone:C,index:F,nextTick:Yt,cancelNextTick:Bt,detectDirection:Ot,getChild:w},It.mount=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];e[0].constructor===Array&&(e=e[0]),e.forEach(function(t){if(!t.prototype||!t.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(el));t.utils&&(It.utils=I({},It.utils,{},t.utils)),K.mount(t)})},It.create=function(t,e){return new It(t,e)};var Ft,jt,Ht,Lt,Kt,Wt,zt=[],Gt=!(It.version="1.0.0");function Ut(){zt.forEach(function(t){clearInterval(t.pid)}),zt=[]}function qt(){clearInterval(Wt)}function Vt(t){var e=t.originalEvent,n=t.putSortable,o=t.dragEl,i=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,l=t.unhideGhostForTarget,s=n||i;a();var c=document.elementFromPoint(e.clientX,e.clientY);l(),s&&!s.el.contains(c)&&(r("spill"),this.onSpill(o))}var Zt,Qt=S(function(n,t,e,o){if(t.scroll){var i,r=t.scrollSensitivity,a=t.scrollSpeed,l=M(),s=!1;jt!==e&&(jt=e,Ut(),Ft=t.scroll,i=t.scrollFn,!0===Ft&&(Ft=A(e,!0)));var c=0,u=Ft;do{var d=u,h=X(d),f=h.top,p=h.bottom,g=h.left,v=h.right,m=h.width,b=h.height,w=void 0,y=void 0,E=d.scrollWidth,D=d.scrollHeight,_=R(d),S=d.scrollLeft,C=d.scrollTop;y=d===l?(w=m<E&&("auto"===_.overflowX||"scroll"===_.overflowX||"visible"===_.overflowX),b<D&&("auto"===_.overflowY||"scroll"===_.overflowY||"visible"===_.overflowY)):(w=m<E&&("auto"===_.overflowX||"scroll"===_.overflowX),b<D&&("auto"===_.overflowY||"scroll"===_.overflowY));var O=w&&(Math.abs(v-n.clientX)<=r&&S+m<E)-(Math.abs(g-n.clientX)<=r&&!!S),T=y&&(Math.abs(p-n.clientY)<=r&&C+b<D)-(Math.abs(f-n.clientY)<=r&&!!C);if(!zt[c])for(var x=0;x<=c;x++)zt[x]||(zt[x]={});zt[c].vx==O&&zt[c].vy==T&&zt[c].el===d||(zt[c].el=d,zt[c].vx=O,zt[c].vy=T,clearInterval(zt[c].pid),0==O&&0==T||(s=!0,zt[c].pid=setInterval(function(){o&&0===this.layer&&It.active._onTouchMove(Kt);var t=zt[this.layer].vy?zt[this.layer].vy*a:0,e=zt[this.layer].vx?zt[this.layer].vx*a:0;"function"==typeof i&&"continue"!==i.call(It.dragged.parentNode[H],e,t,n,Kt,zt[this.layer].el)||j(zt[this.layer].el,e,t)}.bind({layer:c}),24))),c++}while(t.bubbleScroll&&u!==l&&(u=A(u,!1)));Gt=s}},30);function $t(){}function Jt(){}$t.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){this.sortable.captureAnimationState();var e=w(this.sortable.el,this.startIndex,this.sortable.options);e?this.sortable.el.insertBefore(t,e):this.sortable.el.appendChild(t),this.sortable.animateAll()},drop:Vt},a($t,{pluginName:"revertOnSpill"}),Jt.prototype={onSpill:function(t){this.sortable.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),this.sortable.animateAll()},drop:Vt},a(Jt,{pluginName:"removeOnSpill"});var te,ee,ne,oe,ie,re=[],ae=[],le=!1,se=!1,ce=!1;function ue(n,o){ae.forEach(function(t){var e=o.children[t.sortableIndex+(n?Number(i):0)];e?o.insertBefore(t,e):o.appendChild(t)})}function de(){re.forEach(function(t){t!==ne&&t.parentNode&&t.parentNode.removeChild(t)})}return It.mount(new function(){function t(){for(var t in this.options={scroll:!0,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0},this)"_"===t.charAt(0)&&"function"==typeof this[t]&&(this[t]=this[t].bind(this))}return t.prototype={dragStarted:function(t){var e=t.originalEvent;this.sortable.nativeDraggable?h(document,"dragover",this._handleAutoScroll):this.sortable.options.supportPointer?h(document,"pointermove",this._handleFallbackAutoScroll):e.touches?h(document,"touchmove",this._handleFallbackAutoScroll):h(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var e=t.originalEvent;this.sortable.options.dragOverBubble||e.rootEl||this._handleAutoScroll(e)},drop:function(){this.sortable.nativeDraggable?f(document,"dragover",this._handleAutoScroll):(f(document,"pointermove",this._handleFallbackAutoScroll),f(document,"touchmove",this._handleFallbackAutoScroll),f(document,"mousemove",this._handleFallbackAutoScroll)),qt(),Ut(),clearTimeout(g),g=void 0},nulling:function(){Kt=jt=Ft=Gt=Wt=Ht=Lt=null,zt.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(e,n){var o=this,i=e.clientX,r=e.clientY,t=document.elementFromPoint(i,r);if(Kt=e,n||E||y||c){Qt(e,this.sortable.options,t,n);var a=A(t,!0);!Gt||Wt&&i===Ht&&r===Lt||(Wt&&qt(),Wt=setInterval(function(){var t=A(document.elementFromPoint(i,r),!0);t!==a&&(a=t,Ut()),Qt(e,o.sortable.options,t,n)},10),Ht=i,Lt=r)}else{if(!this.sortable.options.bubbleScroll||A(t,!0)===M())return void Ut();Qt(e,this.sortable.options,A(t,!1),!1)}}},a(t,{pluginName:"scroll",initializeByDefault:!0})}),It.mount(Jt,$t),It.mount(new function(){function t(){this.options={swapClass:"sortable-swap-highlight"}}return t.prototype={dragStart:function(t){var e=t.dragEl;Zt=e},dragOverValid:function(t){var e=t.completed,n=t.target,o=t.onMove,i=t.activeSortable,r=t.changed;if(i.options.swap){var a=this.sortable.el,l=this.sortable.options;if(n&&n!==a){var s=Zt;Zt=!1!==o(n)?(k(n,l.swapClass,!0),n):null,s&&s!==Zt&&k(s,l.swapClass,!1)}return r(),e(!0)}},drop:function(t){var e=t.activeSortable,n=t.putSortable,o=t.dragEl,i=n||this.sortable,r=this.sortable.options;Zt&&k(Zt,r.swapClass,!1),Zt&&(r.swap||n&&n.options.swap)&&o!==Zt&&(i.captureAnimationState(),i!==e&&e.captureAnimationState(),function(t,e){var n,o,i=t.parentNode,r=e.parentNode;if(!i||!r||i.isEqualNode(e)||r.isEqualNode(t))return;n=F(t),o=F(e),i.isEqualNode(r)&&n<o&&o++;i.insertBefore(e,i.children[n]),r.insertBefore(t,r.children[o])}(o,Zt),i.animateAll(),i!==e&&e.animateAll())},nulling:function(){Zt=null}},a(t,{pluginName:"swap",eventOptions:function(){return{swapItem:Zt}}})}),It.mount(new function(){function t(o){for(var t in this)"_"===t.charAt(0)&&"function"==typeof this[t]&&(this[t]=this[t].bind(this));o.options.supportPointer?h(document,"pointerup",this._deselectMultiDrag):(h(document,"mouseup",this._deselectMultiDrag),h(document,"touchend",this._deselectMultiDrag)),h(document,"keydown",this._checkKeyDown),h(document,"keyup",this._checkKeyUp),this.options={selectedClass:"sortable-selected",multiDragKey:null,setData:function(t,e){var n="";re.length&&ee===o?re.forEach(function(t,e){n+=(e?", ":"")+t.textContent}):n=e.textContent,t.setData("Text",n)}}}return t.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){var e=t.dragEl;ne=e},delayEnded:function(){this.isMultiDrag=~re.indexOf(ne)},setupClone:function(t){var e=t.sortable;if(this.isMultiDrag){for(var n=0;n<re.length;n++)ae.push(C(re[n])),ae[n].sortableIndex=re[n].sortableIndex,ae[n].draggable=!1,ae[n].style["will-change"]="",k(ae[n],e.options.selectedClass,!1),re[n]===ne&&k(ae[n],e.options.chosenClass,!1);return e._hideClone(),!0}},clone:function(t){var e=t.sortable,n=t.rootEl,o=t.dispatchSortableEvent;if(this.isMultiDrag)return!e.options.removeCloneOnHide&&re.length&&ee===e?(ue(!0,n),o("clone"),!0):void 0},showClone:function(t){var e=t.cloneNowShown,n=t.rootEl;if(this.isMultiDrag)return ue(!1,n),ae.forEach(function(t){R(t,"display","")}),e(),!(ie=!1)},hideClone:function(t){var e=t.sortable,n=t.cloneNowHidden;if(this.isMultiDrag)return ae.forEach(function(t){R(t,"display","none"),e.options.removeCloneOnHide&&t.parentNode&&t.parentNode.removeChild(t)}),n(),ie=!0},dragStartGlobal:function(t){t.sortable;!this.isMultiDrag&&ee&&ee.multiDrag._deselectMultiDrag(),re.forEach(function(t){t.sortableIndex=F(t)}),re=re.sort(function(t,e){return t.sortableIndex-e.sortableIndex}),ce=!0},dragStarted:function(t){var e=t.sortable;if(this.isMultiDrag){if(e.options.sort&&(e.captureAnimationState(),e.options.animation)){re.forEach(function(t){t!==ne&&R(t,"position","absolute")});var n=X(ne,!1,!0,!0);re.forEach(function(t){t!==ne&&O(t,n)}),le=se=!0}e.animateAll(function(){le=se=!1,e.options.animation&&re.forEach(function(t){T(t)}),e.options.sort&&de()})}},dragOver:function(t){var e=t.target,n=t.completed;if(se&&~re.indexOf(e))return n(!1)},revert:function(t){var e=t.fromSortable,n=t.rootEl,o=t.sortable,r=t.dragRect;1<re.length&&(re.forEach(function(t){o.addAnimationState({target:t,rect:se?X(t):r}),T(t),t.fromRect=r,e.removeAnimationState(t)}),se=!1,function(n,o){re.forEach(function(t){var e=o.children[t.sortableIndex+(n?Number(i):0)];e?o.insertBefore(t,e):o.appendChild(t)})}(!o.options.removeCloneOnHide,n))},dragOverCompleted:function(t){var e=t.sortable,n=t.isOwner,o=t.insertion,i=t.activeSortable,r=t.parentEl,a=t.putSortable,l=e.options;if(o){if(n&&i._hideClone(),le=!1,l.animation&&1<re.length&&(se||!n&&!i.options.sort&&!a)){var s=X(ne,!1,!0,!0);re.forEach(function(t){t!==ne&&(O(t,s),r.appendChild(t))}),se=!0}if(!n)if(se||de(),1<re.length){var c=ie;i._showClone(e),i.options.animation&&!ie&&c&&ae.forEach(function(t){i.addAnimationState({target:t,rect:oe}),t.fromRect=oe,t.thisAnimationDuration=null})}else i._showClone(e)}},dragOverAnimationCapture:function(t){var e=t.dragRect,n=t.isOwner,o=t.activeSortable;if(re.forEach(function(t){t.thisAnimationDuration=null}),o.options.animation&&!n&&o.multiDrag.isMultiDrag){oe=a({},e);var i=m(ne,!0);oe.top-=i.f,oe.left-=i.e}},dragOverAnimationComplete:function(){se&&(se=!1,de())},drop:function(t){var e=t.originalEvent,n=t.rootEl,o=t.parentEl,i=t.sortable,r=t.dispatchSortableEvent,a=t.oldIndex,l=t.putSortable,s=l||this.sortable;if(e){var c=i.options,u=o.children;if(!ce)if(c.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),k(ne,c.selectedClass,!~re.indexOf(ne)),~re.indexOf(ne))re.splice(re.indexOf(ne),1),te=null,W({sortable:i,rootEl:n,name:"deselect",targetEl:ne,originalEvt:e});else{if(re.push(ne),W({sortable:i,rootEl:n,name:"select",targetEl:ne,originalEvt:e}),(!c.multiDragKey||this.multiDragKeyDown)&&e.shiftKey&&te&&i.el.contains(te)){var d,h,f=F(te),p=F(ne);if(~f&&~p&&f!==p)for(d=f<p?(h=f,p):(h=p,f+1);h<d;h++)~re.indexOf(u[h])||(k(u[h],c.selectedClass,!0),re.push(u[h]),W({sortable:i,rootEl:n,name:"select",targetEl:u[h],originalEvt:e}))}else te=ne;ee=s}if(ce&&this.isMultiDrag){if((o[H].options.sort||o!==n)&&1<re.length){var g=X(ne),v=F(ne,":not(."+i.options.selectedClass+")");if(!le&&c.animation&&(ne.thisAnimationDuration=null),s.captureAnimationState(),!le&&(c.animation&&(ne.fromRect=g,re.forEach(function(t){if(t.thisAnimationDuration=null,t!==ne){var e=se?X(t):g;t.fromRect=e,s.addAnimationState({target:t,rect:e})}})),de(),re.forEach(function(t){u[v]?o.insertBefore(t,u[v]):o.appendChild(t),v++}),a===F(ne))){var m=!1;re.forEach(function(t){t.sortableIndex===F(t)||(m=!0)}),m&&r("update")}re.forEach(function(t){T(t)}),s.animateAll()}ee=s}(n===o||l&&"clone"!==l.lastPutMode)&&ae.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)})}},nullingGlobal:function(){this.isMultiDrag=ce=!1,ae.length=0},destroy:function(){this._deselectMultiDrag(),f(document,"pointerup",this._deselectMultiDrag),f(document,"mouseup",this._deselectMultiDrag),f(document,"touchend",this._deselectMultiDrag),f(document,"keydown",this._checkKeyDown),f(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!ce&&ee===this.sortable&&!(t&&P(t.target,this.sortable.options.draggable,this.sortable.el,!1)||t&&0!==t.button))for(;re.length;){var e=re[0];k(e,this.sortable.options.selectedClass,!1),re.shift(),W({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:e,originalEvt:t})}},_checkKeyDown:function(t){t.key===this.sortable.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(t){t.key===this.sortable.options.multiDragKey&&(this.multiDragKeyDown=!1)}},a(t,{pluginName:"multiDrag",utils:{select:function(t){var e=t.parentNode[H];e&&e.options.multiDrag&&!~re.indexOf(t)&&(ee&&ee!==e&&(ee.multiDrag._deselectMultiDrag(),ee=e),k(t,e.options.selectedClass,!0),re.push(t))},deselect:function(t){var e=t.parentNode[H],n=re.indexOf(t);e&&e.options.multiDrag&&~n&&(k(t,e.options.selectedClass,!1),re.splice(n,1))}},eventOptions:function(){var n=this,o=[],i=[];return re.forEach(function(t){var e;o.push({multiDragElement:t,index:t.sortableIndex}),e=se&&t!==ne?-1:se?F(t,":not(."+n.options.selectedClass+")"):F(t),i.push({multiDragElement:t,index:e})}),{items:r(re),clones:[].concat(ae),oldIndicies:o,newIndicies:i}},optionListeners:{multiDragKey:function(t){return"ctrl"===(t=t.toLowerCase())?t="Control":1<t.length&&(t=t.charAt(0).toUpperCase()+t.substr(1)),t}}})}),It});