UNPKG

livewire-sortablejs

Version:
8 lines (7 loc) 35.6 kB
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict"; /**! * Sortable 1.13.0 * @author RubaXa <trash@rubaxa.org> * @author owenm <owen23355@gmail.com> * @license MIT */function t(e){return(t="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})(e)}function e(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n(){return(n=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 o(t){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{},i=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(o).filter((function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable})))),i.forEach((function(n){e(t,n,o[n])}))}return t}function i(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],e.indexOf(n)>=0||(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],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function r(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var a=r(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),l=r(/Edge/i),s=r(/firefox/i),c=r(/safari/i)&&!r(/chrome/i)&&!r(/android/i),u=r(/iP(ad|od|hone)/i),d=r(/chrome/i)&&r(/android/i),h={capture:!1,passive:!1};function f(t,e,n){t.addEventListener(e,n,!a&&h)}function p(t,e,n){t.removeEventListener(e,n,!a&&h)}function g(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 v(t){return t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode}function m(t,e,n,o){if(t){n=n||document;do{if(null!=e&&(">"===e[0]?t.parentNode===n&&g(t,e):g(t,e))||o&&t===n)return t;if(t===n)break}while(t=v(t))}return null}var b,w=/\s+/g;function y(t,e,n){if(t&&e)if(t.classList)t.classList[n?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(w," ").replace(" "+e+" "," ");t.className=(o+(n?" "+e:"")).replace(w," ")}}function E(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 S(t,e){var n="";if("string"==typeof t)n=t;else do{var o=E(t,"transform");o&&"none"!==o&&(n=o+" "+n)}while(!e&&(t=t.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}function D(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 _(){var t=document.scrollingElement;return t||document.documentElement}function T(t,e,n,o,i){if(t.getBoundingClientRect||t===window){var r,l,s,c,u,d,h;if(t!==window&&t.parentNode&&t!==_()?(l=(r=t.getBoundingClientRect()).top,s=r.left,c=r.bottom,u=r.right,d=r.height,h=r.width):(l=0,s=0,c=window.innerHeight,u=window.innerWidth,d=window.innerHeight,h=window.innerWidth),(e||n)&&t!==window&&(i=i||t.parentNode,!a))do{if(i&&i.getBoundingClientRect&&("none"!==E(i,"transform")||n&&"static"!==E(i,"position"))){var f=i.getBoundingClientRect();l-=f.top+parseInt(E(i,"border-top-width")),s-=f.left+parseInt(E(i,"border-left-width")),c=l+r.height,u=s+r.width;break}}while(i=i.parentNode);if(o&&t!==window){var p=S(i||t),g=p&&p.a,v=p&&p.d;p&&(c=(l/=v)+(d/=v),u=(s/=g)+(h/=g))}return{top:l,left:s,bottom:c,right:u,width:h,height:d}}}function C(t,e,n){for(var o=A(t,!0),i=T(t)[e];o;){var r=T(o)[n];if(!("top"===n||"left"===n?i>=r:i<=r))return o;if(o===_())break;o=A(o,!1)}return!1}function x(t,e,n){for(var o=0,i=0,r=t.children;i<r.length;){if("none"!==r[i].style.display&&r[i]!==Pt.ghost&&r[i]!==Pt.dragged&&m(r[i],n.draggable,t,!1)){if(o===e)return r[i];o++}i++}return null}function N(t,e){for(var n=t.lastElementChild;n&&(n===Pt.ghost||"none"===E(n,"display")||e&&!g(n,e));)n=n.previousElementSibling;return n||null}function O(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)"TEMPLATE"===t.nodeName.toUpperCase()||t===Pt.clone||e&&!g(t,e)||n++;return n}function M(t){var e=0,n=0,o=_();if(t)do{var i=S(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 _();var n=t,o=!1;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=E(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 _();if(o||e)return n;o=!0}}}while(n=n.parentNode);return _()}function I(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 P(t,e){return function(){if(!b){var n=arguments,o=this;1===n.length?t.call(o,n[0]):t.apply(o,n),b=setTimeout((function(){b=void 0}),e)}}}function k(t,e,n){t.scrollLeft+=e,t.scrollTop+=n}function X(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)}var R="Sortable"+(new Date).getTime();function Y(){var t,e=[];return{captureAnimationState:function(){(e=[],this.options.animation)&&[].slice.call(this.el.children).forEach((function(t){if("none"!==E(t,"display")&&t!==Pt.ghost){e.push({target:t,rect:T(t)});var n=o({},e[e.length-1].rect);if(t.thisAnimationDuration){var i=S(t,!0);i&&(n.top-=i.f,n.left-=i.e)}t.fromRect=n}}))},addAnimationState:function(t){e.push(t)},removeAnimationState:function(t){e.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}(e,{target:t}),1)},animateAll:function(n){var o=this;if(!this.options.animation)return clearTimeout(t),void("function"==typeof n&&n());var i=!1,r=0;e.forEach((function(t){var e=0,n=t.target,a=n.fromRect,l=T(n),s=n.prevFromRect,c=n.prevToRect,u=t.rect,d=S(n,!0);d&&(l.top-=d.f,l.left-=d.e),n.toRect=l,n.thisAnimationDuration&&I(s,l)&&!I(a,l)&&(u.top-l.top)/(u.left-l.left)==(a.top-l.top)/(a.left-l.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}(u,s,c,o.options)),I(l,a)||(n.prevFromRect=a,n.prevToRect=l,e||(e=o.options.animation),o.animate(n,u,l,e)),e&&(i=!0,r=Math.max(r,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(t),i?t=setTimeout((function(){"function"==typeof n&&n()}),r):"function"==typeof n&&n(),e=[]},animate:function(t,e,n,o){if(o){E(t,"transition",""),E(t,"transform","");var i=S(this.el),r=i&&i.a,a=i&&i.d,l=(e.left-n.left)/(r||1),s=(e.top-n.top)/(a||1);t.animatingX=!!l,t.animatingY=!!s,E(t,"transform","translate3d("+l+"px,"+s+"px,0)"),this.forRepaintDummy=function(t){return t.offsetWidth}(t),E(t,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:"")),E(t,"transform","translate3d(0,0,0)"),"number"==typeof t.animated&&clearTimeout(t.animated),t.animated=setTimeout((function(){E(t,"transition",""),E(t,"transform",""),t.animated=!1,t.animatingX=!1,t.animatingY=!1}),o)}}}}var B=[],F={initializeByDefault:!0},H={mount:function(t){for(var e in F)F.hasOwnProperty(e)&&!(e in t)&&(t[e]=F[e]);B.forEach((function(e){if(e.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")})),B.push(t)},pluginEvent:function(t,e,n){var i=this;this.eventCanceled=!1,n.cancel=function(){i.eventCanceled=!0};var r=t+"Global";B.forEach((function(i){e[i.pluginName]&&(e[i.pluginName][r]&&e[i.pluginName][r](o({sortable:e},n)),e.options[i.pluginName]&&e[i.pluginName][t]&&e[i.pluginName][t](o({sortable:e},n)))}))},initializePlugins:function(t,e,o,i){for(var r in B.forEach((function(i){var r=i.pluginName;if(t.options[r]||i.initializeByDefault){var a=new i(t,e,t.options);a.sortable=t,a.options=t.options,t[r]=a,n(o,a.defaults)}})),t.options)if(t.options.hasOwnProperty(r)){var a=this.modifyOption(t,r,t.options[r]);void 0!==a&&(t.options[r]=a)}},getEventProperties:function(t,e){var o={};return B.forEach((function(i){"function"==typeof i.eventProperties&&n(o,i.eventProperties.call(e[i.pluginName],t))})),o},modifyOption:function(t,e,n){var o;return B.forEach((function(i){t[i.pluginName]&&i.optionListeners&&"function"==typeof i.optionListeners[e]&&(o=i.optionListeners[e].call(t[i.pluginName],n))})),o}};var L=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.evt,a=i(n,["evt"]);H.pluginEvent.bind(Pt)(t,e,o({dragEl:j,parentEl:z,ghostEl:G,rootEl:q,nextEl:U,lastDownEl:$,cloneEl:V,cloneHidden:J,dragStarted:ct,putSortable:nt,activeSortable:Pt.active,originalEvent:r,oldIndex:Z,oldDraggableIndex:Q,newIndex:K,newDraggableIndex:tt,hideGhostForTarget:Ot,unhideGhostForTarget:Mt,cloneNowHidden:function(){J=!0},cloneNowShown:function(){J=!1},dispatchSortableEvent:function(t){W({sortable:e,name:t,originalEvent:r})}},a))};function W(t){!function(t){var e=t.sortable,n=t.rootEl,i=t.name,r=t.targetEl,s=t.cloneEl,c=t.toEl,u=t.fromEl,d=t.oldIndex,h=t.newIndex,f=t.oldDraggableIndex,p=t.newDraggableIndex,g=t.originalEvent,v=t.putSortable,m=t.extraEventProperties;if(e=e||n&&n[R]){var b,w=e.options,y="on"+i.charAt(0).toUpperCase()+i.substr(1);!window.CustomEvent||a||l?(b=document.createEvent("Event")).initEvent(i,!0,!0):b=new CustomEvent(i,{bubbles:!0,cancelable:!0}),b.to=c||n,b.from=u||n,b.item=r||n,b.clone=s,b.oldIndex=d,b.newIndex=h,b.oldDraggableIndex=f,b.newDraggableIndex=p,b.originalEvent=g,b.pullMode=v?v.lastPutMode:void 0;var E=o({},m,H.getEventProperties(i,e));for(var S in E)b[S]=E[S];n&&n.dispatchEvent(b),w[y]&&w[y].call(e,b)}}(o({putSortable:nt,cloneEl:V,targetEl:j,rootEl:q,oldIndex:Z,oldDraggableIndex:Q,newIndex:K,newDraggableIndex:tt},t))}var j,z,G,q,U,$,V,J,Z,K,Q,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=[],St="undefined"!=typeof document,Dt=u,_t=l||a?"cssFloat":"float",Tt=St&&!d&&!u&&"draggable"in document.createElement("div"),Ct=function(){if(St){if(a)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents}}(),xt=function(t,e){var n=E(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),i=x(t,0,e),r=x(t,1,e),a=i&&E(i),l=r&&E(r),s=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+T(i).width,c=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+T(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&&a.float&&"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||s>=o&&"none"===n[_t]||r&&"none"===n[_t]&&s+c>o)?"vertical":"horizontal"},Nt=function(e){function n(t,e){return function(o,i,r,a){var l=o.options.group.name&&i.options.group.name&&o.options.group.name===i.options.group.name;if(null==t&&(e||l))return!0;if(null==t||!1===t)return!1;if(e&&"clone"===t)return t;if("function"==typeof t)return n(t(o,i,r,a),e)(o,i,r,a);var s=(e?o:i).options.group.name;return!0===t||"string"==typeof t&&t===s||t.join&&t.indexOf(s)>-1}}var o={},i=e.group;i&&"object"==t(i)||(i={name:i}),o.name=i.name,o.checkPull=n(i.pull,!0),o.checkPut=n(i.put),o.revertClone=i.revertClone,e.group=o},Ot=function(){!Ct&&G&&E(G,"display","none")},Mt=function(){!Ct&&G&&E(G,"display","")};St&&document.addEventListener("click",(function(t){if(gt)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),gt=!1,!1}),!0);var At=function(t){if(j){t=t.touches?t.touches[0]:t;var e=(i=t.clientX,r=t.clientY,vt.some((function(t){if(!N(t)){var e=T(t),n=t[R].options.emptyInsertThreshold,o=i>=e.left-n&&i<=e.right+n,l=r>=e.top-n&&r<=e.bottom+n;return n&&o&&l?a=t:void 0}})),a);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[R]._onDragOver(n)}}var i,r,a},It=function(t){j&&j.parentNode[R]._isOutsideThisEl(t.target)};function Pt(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=n({},e),t[R]=this;var o={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 xt(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!==Pt.supportPointer&&"PointerEvent"in window&&!c,emptyInsertThreshold:5};for(var i in H.initializePlugins(this,t,o),o)!(i in e)&&(e[i]=o[i]);for(var r in Nt(e),this)"_"===r.charAt(0)&&"function"==typeof this[r]&&(this[r]=this[r].bind(this));this.nativeDraggable=!e.forceFallback&&Tt,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?f(t,"pointerdown",this._onTapStart):(f(t,"mousedown",this._onTapStart),f(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(f(t,"dragover",this),f(t,"dragenter",this)),vt.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),n(this,Y())}function kt(t,e,n,o,i,r,s,c){var u,d,h=t[R],f=h.options.onMove;return!window.CustomEvent||a||l?(u=document.createEvent("Event")).initEvent("move",!0,!0):u=new CustomEvent("move",{bubbles:!0,cancelable:!0}),u.to=e,u.from=t,u.dragged=n,u.draggedRect=o,u.related=i||e,u.relatedRect=r||T(e),u.willInsertAfter=c,u.originalEvent=s,t.dispatchEvent(u),f&&(d=f.call(h,u,s)),d}function Xt(t){t.draggable=!1}function Rt(){yt=!1}function Yt(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 Bt(t){return setTimeout(t,0)}function Ft(t){return clearTimeout(t)}Pt.prototype={constructor:Pt,_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,j):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,n=this.el,o=this.options,i=o.preventOnFilter,r=t.type,a=t.touches&&t.touches[0]||t.pointerType&&"touch"===t.pointerType&&t,l=(a||t).target,s=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||l,u=o.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)}}(n),!j&&!(/mousedown|pointerdown/.test(r)&&0!==t.button||o.disabled)&&!s.isContentEditable&&(this.nativeDraggable||!c||!l||"SELECT"!==l.tagName.toUpperCase())&&!((l=m(l,o.draggable,n,!1))&&l.animated||$===l)){if(Z=O(l),Q=O(l,o.draggable),"function"==typeof u){if(u.call(this,t,l,this))return W({sortable:e,rootEl:s,name:"filter",targetEl:l,toEl:n,fromEl:n}),L("filter",e,{evt:t}),void(i&&t.cancelable&&t.preventDefault())}else if(u&&(u=u.split(",").some((function(o){if(o=m(s,o.trim(),n,!1))return W({sortable:e,rootEl:o,name:"filter",targetEl:l,fromEl:n,toEl:n}),L("filter",e,{evt:t}),!0}))))return void(i&&t.cancelable&&t.preventDefault());o.handle&&!m(s,o.handle,n,!1)||this._prepareDragStart(t,a,l)}}},_prepareDragStart:function(t,e,n){var o,i=this,r=i.el,c=i.options,u=r.ownerDocument;if(n&&!j&&n.parentNode===r){var d=T(n);if(q=r,z=(j=n).parentNode,U=j.nextSibling,$=n,et=c.group,Pt.dragged=j,ot={target:j,clientX:(e||t).clientX,clientY:(e||t).clientY},lt=ot.clientX-d.left,st=ot.clientY-d.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,j.style["will-change"]="all",o=function(){L("delayEnded",i,{evt:t}),Pt.eventCanceled?i._onDrop():(i._disableDelayedDragEvents(),!s&&i.nativeDraggable&&(j.draggable=!0),i._triggerDragStart(t,e),W({sortable:i,name:"choose",originalEvent:t}),y(j,c.chosenClass,!0))},c.ignore.split(",").forEach((function(t){D(j,t.trim(),Xt)})),f(u,"dragover",At),f(u,"mousemove",At),f(u,"touchmove",At),f(u,"mouseup",i._onDrop),f(u,"touchend",i._onDrop),f(u,"touchcancel",i._onDrop),s&&this.nativeDraggable&&(this.options.touchStartThreshold=4,j.draggable=!0),L("delayStart",this,{evt:t}),!c.delay||c.delayOnTouchOnly&&!e||this.nativeDraggable&&(l||a))o();else{if(Pt.eventCanceled)return void this._onDrop();f(u,"mouseup",i._disableDelayedDrag),f(u,"touchend",i._disableDelayedDrag),f(u,"touchcancel",i._disableDelayedDrag),f(u,"mousemove",i._delayedDragTouchMoveHandler),f(u,"touchmove",i._delayedDragTouchMoveHandler),c.supportPointer&&f(u,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(o,c.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(){j&&Xt(j),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;p(t,"mouseup",this._disableDelayedDrag),p(t,"touchend",this._disableDelayedDrag),p(t,"touchcancel",this._disableDelayedDrag),p(t,"mousemove",this._delayedDragTouchMoveHandler),p(t,"touchmove",this._delayedDragTouchMoveHandler),p(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||"touch"==t.pointerType&&t,!this.nativeDraggable||e?this.options.supportPointer?f(document,"pointermove",this._onTouchMove):f(document,e?"touchmove":"mousemove",this._onTouchMove):(f(j,"dragend",this),f(q,"dragstart",this._onDragStart));try{document.selection?Bt((function(){document.selection.empty()})):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){if(pt=!1,q&&j){L("dragStarted",this,{evt:e}),this.nativeDraggable&&f(document,"dragover",It);var n=this.options;!t&&y(j,n.dragClass,!1),y(j,n.ghostClass,!0),Pt.active=this,t&&this._appendGhost(),W({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(it){this._lastX=it.clientX,this._lastY=it.clientY,Ot();for(var t=document.elementFromPoint(it.clientX,it.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(it.clientX,it.clientY))!==e;)e=t;if(j.parentNode[R]._isOutsideThisEl(t),e)do{if(e[R]){if(e[R]._onDragOver({clientX:it.clientX,clientY:it.clientY,target:t,rootEl:e})&&!this.options.dragoverBubble)break}t=e}while(e=e.parentNode);Mt()}},_onTouchMove:function(t){if(ot){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,i=t.touches?t.touches[0]:t,r=G&&S(G,!0),a=G&&r&&r.a,l=G&&r&&r.d,s=Dt&&ft&&M(ft),c=(i.clientX-ot.clientX+o.x)/(a||1)+(s?s[0]-wt[0]:0)/(a||1),u=(i.clientY-ot.clientY+o.y)/(l||1)+(s?s[1]-wt[1]:0)/(l||1);if(!Pt.active&&!pt){if(n&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))<n)return;this._onDragStart(t,!0)}if(G){r?(r.e+=c-(rt||0),r.f+=u-(at||0)):r={a:1,b:0,c:0,d:1,e:c,f:u};var d="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");E(G,"webkitTransform",d),E(G,"mozTransform",d),E(G,"msTransform",d),E(G,"transform",d),rt=c,at=u,it=i}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!G){var t=this.options.fallbackOnBody?document.body:q,e=T(j,!0,Dt,!0,t),n=this.options;if(Dt){for(ft=t;"static"===E(ft,"position")&&"none"===E(ft,"transform")&&ft!==document;)ft=ft.parentNode;ft!==document.body&&ft!==document.documentElement?(ft===document&&(ft=_()),e.top+=ft.scrollTop,e.left+=ft.scrollLeft):ft=_(),wt=M(ft)}y(G=j.cloneNode(!0),n.ghostClass,!1),y(G,n.fallbackClass,!0),y(G,n.dragClass,!0),E(G,"transition",""),E(G,"transform",""),E(G,"box-sizing","border-box"),E(G,"margin",0),E(G,"top",e.top),E(G,"left",e.left),E(G,"width",e.width),E(G,"height",e.height),E(G,"opacity","0.8"),E(G,"position",Dt?"absolute":"fixed"),E(G,"zIndex","100000"),E(G,"pointerEvents","none"),Pt.ghost=G,t.appendChild(G),E(G,"transform-origin",lt/parseInt(G.style.width)*100+"% "+st/parseInt(G.style.height)*100+"%")}},_onDragStart:function(t,e){var n=this,o=t.dataTransfer,i=n.options;L("dragStart",this,{evt:t}),Pt.eventCanceled?this._onDrop():(L("setupClone",this),Pt.eventCanceled||((V=X(j)).draggable=!1,V.style["will-change"]="",this._hideClone(),y(V,this.options.chosenClass,!1),Pt.clone=V),n.cloneId=Bt((function(){L("clone",n),Pt.eventCanceled||(n.options.removeCloneOnHide||q.insertBefore(V,j),n._hideClone(),W({sortable:n,name:"clone"}))})),!e&&y(j,i.dragClass,!0),e?(gt=!0,n._loopId=setInterval(n._emulateDragOver,50)):(p(document,"mouseup",n._onDrop),p(document,"touchend",n._onDrop),p(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",i.setData&&i.setData.call(n,o,j)),f(document,"drop",n),E(j,"transform","translateZ(0)")),pt=!0,n._dragStartId=Bt(n._dragStarted.bind(n,e,t)),f(document,"selectstart",n),ct=!0,c&&E(document.body,"user-select","none"))},_onDragOver:function(t){var e,n,i,r,a=this.el,l=t.target,s=this.options,c=s.group,u=Pt.active,d=et===c,h=s.sort,f=nt||u,p=this,g=!1;if(!yt){if(void 0!==t.preventDefault&&t.cancelable&&t.preventDefault(),l=m(l,s.draggable,a,!0),B("dragOver"),Pt.eventCanceled)return g;if(j.contains(t.target)||l.animated&&l.animatingX&&l.animatingY||p._ignoreWhileAnimating===l)return H(!1);if(gt=!1,u&&!s.disabled&&(d?h||(i=!q.contains(j)):nt===this||(this.lastPutMode=et.checkPull(this,u,j,t))&&c.checkPut(this,u,j,t))){if(r="vertical"===this._getDirection(t,l),e=T(j),B("dragOverValid"),Pt.eventCanceled)return g;if(i)return z=q,F(),this._hideClone(),B("revert"),Pt.eventCanceled||(U?q.insertBefore(j,U):q.appendChild(j)),H(!0);var v=N(a,s.draggable);if(!v||function(t,e,n){var o=T(N(n.el,n.options.draggable)),i=10;return e?t.clientX>o.right+i||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+i}(t,r,this)&&!v.animated){if(v===j)return H(!1);if(v&&a===t.target&&(l=v),l&&(n=T(l)),!1!==kt(q,a,j,e,l,n,t,!!l))return F(),a.appendChild(j),z=a,$(),H(!0)}else if(l.parentNode===a){n=T(l);var b,w,S,D=j.parentNode!==a,_=!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}(j.animated&&j.toRect||e,l.animated&&l.toRect||n,r),x=r?"top":"left",M=C(l,"top","top")||C(j,"top","top"),A=M?M.scrollTop:void 0;if(ut!==l&&(w=n[x],mt=!1,bt=!_&&s.invertSwap||D),0!==(b=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?s>u+c*r/2:s<d-c*r/2)&&(mt=!0),mt)h=!0;else if(1===dt?s<u+ht:s>d-ht)return-dt}else if(s>u+c*(1-i)/2&&s<d-c*(1-i)/2)return function(t){return O(j)<O(t)?1:-1}(e);if((h=h||a)&&(s<u+c*r/2||s>d-c*r/2))return s>u+c/2?1:-1;return 0}(t,l,n,r,_?1:s.swapThreshold,null==s.invertedSwapThreshold?s.swapThreshold:s.invertedSwapThreshold,bt,ut===l))){var I=O(j);do{I-=b,S=z.children[I]}while(S&&("none"===E(S,"display")||S===G))}if(0===b||S===l)return H(!1);ut=l,dt=b;var P=l.nextElementSibling,X=!1,Y=kt(q,a,j,e,l,n,t,X=1===b);if(!1!==Y)return 1!==Y&&-1!==Y||(X=1===Y),yt=!0,setTimeout(Rt,30),F(),X&&!P?a.appendChild(j):l.parentNode.insertBefore(j,X?P:l),M&&k(M,0,A-M.scrollTop),z=j.parentNode,void 0===w||bt||(ht=Math.abs(w-T(l)[x])),$(),H(!0)}if(a.contains(j))return H(!1)}return!1}function B(s,c){L(s,p,o({evt:t,isOwner:d,axis:r?"vertical":"horizontal",revert:i,dragRect:e,targetRect:n,canSort:h,fromSortable:f,target:l,completed:H,onMove:function(n,o){return kt(q,a,j,e,n,T(n),t,o)},changed:$},c))}function F(){B("dragOverAnimationCapture"),p.captureAnimationState(),p!==f&&f.captureAnimationState()}function H(e){return B("dragOverCompleted",{insertion:e}),e&&(d?u._hideClone():u._showClone(p),p!==f&&(y(j,nt?nt.options.ghostClass:u.options.ghostClass,!1),y(j,s.ghostClass,!0)),nt!==p&&p!==Pt.active?nt=p:p===Pt.active&&nt&&(nt=null),f===p&&(p._ignoreWhileAnimating=l),p.animateAll((function(){B("dragOverAnimationComplete"),p._ignoreWhileAnimating=null})),p!==f&&(f.animateAll(),f._ignoreWhileAnimating=null)),(l===j&&!j.animated||l===a&&!l.animated)&&(ut=null),s.dragoverBubble||t.rootEl||l===document||(j.parentNode[R]._isOutsideThisEl(t.target),!e&&At(t)),!s.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),g=!0}function $(){K=O(j),tt=O(j,s.draggable),W({sortable:p,name:"change",toEl:a,newIndex:K,newDraggableIndex:tt,originalEvent:t})}},_ignoreWhileAnimating:null,_offMoveEvents:function(){p(document,"mousemove",this._onTouchMove),p(document,"touchmove",this._onTouchMove),p(document,"pointermove",this._onTouchMove),p(document,"dragover",At),p(document,"mousemove",At),p(document,"touchmove",At)},_offUpEvents:function(){var t=this.el.ownerDocument;p(t,"mouseup",this._onDrop),p(t,"touchend",this._onDrop),p(t,"pointerup",this._onDrop),p(t,"touchcancel",this._onDrop),p(document,"selectstart",this)},_onDrop:function(t){var e=this.el,n=this.options;K=O(j),tt=O(j,n.draggable),L("drop",this,{evt:t}),z=j&&j.parentNode,K=O(j),tt=O(j,n.draggable),Pt.eventCanceled||(pt=!1,bt=!1,mt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ft(this.cloneId),Ft(this._dragStartId),this.nativeDraggable&&(p(document,"drop",this),p(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),c&&E(document.body,"user-select",""),E(j,"transform",""),t&&(ct&&(t.cancelable&&t.preventDefault(),!n.dropBubble&&t.stopPropagation()),G&&G.parentNode&&G.parentNode.removeChild(G),(q===z||nt&&"clone"!==nt.lastPutMode)&&V&&V.parentNode&&V.parentNode.removeChild(V),j&&(this.nativeDraggable&&p(j,"dragend",this),Xt(j),j.style["will-change"]="",ct&&!pt&&y(j,nt?nt.options.ghostClass:this.options.ghostClass,!1),y(j,this.options.chosenClass,!1),W({sortable:this,name:"unchoose",toEl:z,newIndex:null,newDraggableIndex:null,originalEvent:t}),q!==z?(K>=0&&(W({rootEl:z,name:"add",toEl:z,fromEl:q,originalEvent:t}),W({sortable:this,name:"remove",toEl:z,originalEvent:t}),W({rootEl:z,name:"sort",toEl:z,fromEl:q,originalEvent:t}),W({sortable:this,name:"sort",toEl:z,originalEvent:t})),nt&&nt.save()):K!==Z&&K>=0&&(W({sortable:this,name:"update",toEl:z,originalEvent:t}),W({sortable:this,name:"sort",toEl:z,originalEvent:t})),Pt.active&&(null!=K&&-1!==K||(K=Z,tt=Q),W({sortable:this,name:"end",toEl:z,originalEvent:t}),this.save())))),this._nulling()},_nulling:function(){L("nulling",this),q=j=z=G=U=V=$=J=ot=it=ct=K=tt=Z=Q=ut=dt=nt=et=Pt.dragged=Pt.ghost=Pt.clone=Pt.active=null,Et.forEach((function(t){t.checked=!0})),Et.length=rt=at=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":j&&(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++)m(t=n[o],r.draggable,this.el,!1)&&e.push(t.getAttribute(r.dataIdAttr)||Yt(t));return e},sort:function(t,e){var n={},o=this.el;this.toArray().forEach((function(t,e){var i=o.children[e];m(i,this.options.draggable,o,!1)&&(n[t]=i)}),this),e&&this.captureAnimationState(),t.forEach((function(t){n[t]&&(o.removeChild(n[t]),o.appendChild(n[t]))})),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return m(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=H.modifyOption(this,t,e);n[t]=void 0!==o?o:e,"group"===t&&Nt(n)},destroy:function(){L("destroy",this);var t=this.el;t[R]=null,p(t,"mousedown",this._onTapStart),p(t,"touchstart",this._onTapStart),p(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(p(t,"dragover",this),p(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),(function(t){t.removeAttribute("draggable")})),this._onDrop(),this._disableDelayedDragEvents(),vt.splice(vt.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!J){if(L("hideClone",this),Pt.eventCanceled)return;E(V,"display","none"),this.options.removeCloneOnHide&&V.parentNode&&V.parentNode.removeChild(V),J=!0}},_showClone:function(t){if("clone"===t.lastPutMode){if(J){if(L("showClone",this),Pt.eventCanceled)return;j.parentNode!=q||this.options.group.revertClone?U?q.insertBefore(V,U):q.appendChild(V):q.insertBefore(V,j),this.options.group.revertClone&&this.animate(j,V),E(V,"display",""),J=!1}}else this._hideClone()}},St&&f(document,"touchmove",(function(t){(Pt.active||pt)&&t.cancelable&&t.preventDefault()})),Pt.utils={on:f,off:p,css:E,find:D,is:function(t,e){return!!m(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:P,closest:m,toggleClass:y,clone:X,index:O,nextTick:Bt,cancelNextTick:Ft,detectDirection:xt,getChild:x},Pt.get=function(t){return t[R]},Pt.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(t));t.utils&&(Pt.utils=o({},Pt.utils,t.utils)),H.mount(t)}))},Pt.create=function(t,e){return new Pt(t,e)},Pt.version="1.13.0";var Ht,Lt,Wt,jt,zt,Gt,qt=[],Ut=!1;function $t(){qt.forEach((function(t){clearInterval(t.pid)})),qt=[]}function Vt(){clearInterval(Gt)}var Jt=P((function(t,e,n,o){if(e.scroll){var i,r=(t.touches?t.touches[0]:t).clientX,a=(t.touches?t.touches[0]:t).clientY,l=e.scrollSensitivity,s=e.scrollSpeed,c=_(),u=!1;Lt!==n&&(Lt=n,$t(),Ht=e.scroll,i=e.scrollFn,!0===Ht&&(Ht=A(n,!0)));var d=0,h=Ht;do{var f=h,p=T(f),g=p.top,v=p.bottom,m=p.left,b=p.right,w=p.width,y=p.height,S=void 0,D=void 0,C=f.scrollWidth,x=f.scrollHeight,N=E(f),O=f.scrollLeft,M=f.scrollTop;f===c?(S=w<C&&("auto"===N.overflowX||"scroll"===N.overflowX||"visible"===N.overflowX),D=y<x&&("auto"===N.overflowY||"scroll"===N.overflowY||"visible"===N.overflowY)):(S=w<C&&("auto"===N.overflowX||"scroll"===N.overflowX),D=y<x&&("auto"===N.overflowY||"scroll"===N.overflowY));var I=S&&(Math.abs(b-r)<=l&&O+w<C)-(Math.abs(m-r)<=l&&!!O),P=D&&(Math.abs(v-a)<=l&&M+y<x)-(Math.abs(g-a)<=l&&!!M);if(!qt[d])for(var X=0;X<=d;X++)qt[X]||(qt[X]={});qt[d].vx==I&&qt[d].vy==P&&qt[d].el===f||(qt[d].el=f,qt[d].vx=I,qt[d].vy=P,clearInterval(qt[d].pid),0==I&&0==P||(u=!0,qt[d].pid=setInterval(function(){o&&0===this.layer&&Pt.active._onTouchMove(zt);var e=qt[this.layer].vy?qt[this.layer].vy*s:0,n=qt[this.layer].vx?qt[this.layer].vx*s:0;"function"==typeof i&&"continue"!==i.call(Pt.dragged.parentNode[R],n,e,t,zt,qt[this.layer].el)||k(qt[this.layer].el,n,e)}.bind({layer:d}),24))),d++}while(e.bubbleScroll&&h!==c&&(h=A(h,!1)));Ut=u}}),30),Zt=function(t){var e=t.originalEvent,n=t.putSortable,o=t.dragEl,i=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,l=t.unhideGhostForTarget;if(e){var s=n||i;a();var c=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,u=document.elementFromPoint(c.clientX,c.clientY);l(),s&&!s.el.contains(u)&&(r("spill"),this.onSpill({dragEl:o,putSortable:n}))}};function Kt(){}function Qt(){}Kt.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,n=t.putSortable;this.sortable.captureAnimationState(),n&&n.captureAnimationState();var o=x(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(e,o):this.sortable.el.appendChild(e),this.sortable.animateAll(),n&&n.animateAll()},drop:Zt},n(Kt,{pluginName:"revertOnSpill"}),Qt.prototype={onSpill:function(t){var e=t.dragEl,n=t.putSortable||this.sortable;n.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),n.animateAll()},drop:Zt},n(Qt,{pluginName:"removeOnSpill"}),Pt.mount(new function(){function t(){for(var t in this.defaults={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?f(document,"dragover",this._handleAutoScroll):this.options.supportPointer?f(document,"pointermove",this._handleFallbackAutoScroll):e.touches?f(document,"touchmove",this._handleFallbackAutoScroll):f(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var e=t.originalEvent;this.options.dragOverBubble||e.rootEl||this._handleAutoScroll(e)},drop:function(){this.sortable.nativeDraggable?p(document,"dragover",this._handleAutoScroll):(p(document,"pointermove",this._handleFallbackAutoScroll),p(document,"touchmove",this._handleFallbackAutoScroll),p(document,"mousemove",this._handleFallbackAutoScroll)),Vt(),$t(),clearTimeout(b),b=void 0},nulling:function(){zt=Lt=Ht=Ut=Gt=Wt=jt=null,qt.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,e){var n=this,o=(t.touches?t.touches[0]:t).clientX,i=(t.touches?t.touches[0]:t).clientY,r=document.elementFromPoint(o,i);if(zt=t,e||l||a||c){Jt(t,this.options,r,e);var s=A(r,!0);!Ut||Gt&&o===Wt&&i===jt||(Gt&&Vt(),Gt=setInterval((function(){var r=A(document.elementFromPoint(o,i),!0);r!==s&&(s=r,$t()),Jt(t,n.options,r,e)}),10),Wt=o,jt=i)}else{if(!this.options.bubbleScroll||A(r,!0)===_())return void $t();Jt(t,this.options,A(r,!1),!1)}}},n(t,{pluginName:"scroll",initializeByDefault:!0})}),Pt.mount(Qt,Kt);if(void 0===window.livewire)throw"Livewire SortableJS: window.livewire is undefined. Make sure @livewireScripts is placed above this script include";window.livewire.directive("sortable",((t,e,n)=>{if(e.modifiers.length>0)return;const o={};["handle"].forEach((e=>{t.querySelector(`[wire\\:sortable\\.${e}]`)&&(o[e]=`[wire\\:sortable\\.${e}]`)})),["group","animation"].forEach((e=>{if(t.hasAttribute(`wire:sortable.${e}`)){const n=t.getAttribute(`wire:sortable.${e}`);o[e]=(t=>{try{return JSON.parse(t)&&!!t}catch(t){return!1}})(n)?JSON.parse(n):n}})),o.onEnd=()=>{let o=[];t.querySelectorAll("[wire\\:sortable\\.item]").forEach(((t,e)=>{o.push({order:e+1,value:t.getAttribute("wire:sortable.item")})})),n.call(e.method,o)},Pt.create(t,o)}))}));