/** * Muuri v0.9.5 * https://muuri.dev/ * Copyright (c) 2015-present, Haltu Oy * Released under the MIT license * https://github.com/haltu/muuri/blob/master/LICENSE.md * @license MIT * * Muuri Packer * Copyright (c) 2016-present, Niklas Rämö * @license MIT * * Muuri Ticker / Muuri Emitter / Muuri Dragger * Copyright (c) 2018-present, Niklas Rämö * @license MIT * * Muuri AutoScroller * Copyright (c) 2019-present, Niklas Rämö * @license MIT */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Muuri=e()}(this,(function(){"use strict";var t={},e="function"==typeof Map?new Map:null,i="swap",s="move",n="layoutStart",o="layoutEnd",r="layoutAbort",h="remove",a="hideStart",_="filter",l="sort",d="move",u="send",c="beforeSend",f="receive",p="beforeReceive",m="dragReleaseEnd",g="ontouchstart"in window,v=!!window.PointerEvent,y=!!window.navigator.msPointerEnabled;function S(){this._events={},this._queue=[],this._counter=0,this._clearOnEmit=!1}S.prototype.on=function(t,e){if(!this._events||!t||!e)return this;var i=this._events[t];return i||(i=this._events[t]=[]),i.push(e),this},S.prototype.off=function(t,e){if(!this._events||!t||!e)return this;var i,s=this._events[t];if(!s||!s.length)return this;for(;-1!==(i=s.indexOf(e));)s.splice(i,1);return this},S.prototype.clear=function(t){if(!this._events||!t)return this;var e=this._events[t];return e&&(e.length=0,delete this._events[t]),this},S.prototype.emit=function(t){if(!this._events||!t)return this._clearOnEmit=!1,this;var e=this._events[t];if(!e||!e.length)return this._clearOnEmit=!1,this;var i,s=this._queue,n=s.length,o=arguments.length-1;o>3&&((i=[]).push.apply(i,arguments),i.shift()),s.push.apply(s,e),this._clearOnEmit&&(e.length=0,this._clearOnEmit=!1),++this._counter;for(var r=n,h=s.length;r-1,L=x.indexOf("trident")>-1,R=x.indexOf("firefox")>-1,I=x.indexOf("android")>-1,C=!!T()&&{passive:!0},M="touchAction",P=E(document.documentElement.style,M);function X(t,e){this._element=t,this._emitter=new S,this._isDestroyed=!1,this._cssProps={},this._touchAction="",this._isActive=!1,this._pointerId=null,this._startTime=0,this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._onStart=this._onStart.bind(this),this._onMove=this._onMove.bind(this),this._onCancel=this._onCancel.bind(this),this._onEnd=this._onEnd.bind(this),this._edgeHack=null,(k||L)&&(v||y)&&(this._edgeHack=new D(this)),this.setCssProps(e),this._touchAction||this.setTouchAction("auto"),t.addEventListener("dragstart",X._preventDefault,!1),t.addEventListener(X._inputEvents.start,this._onStart,C)}X._pointerEvents={start:"pointerdown",move:"pointermove",cancel:"pointercancel",end:"pointerup"},X._msPointerEvents={start:"MSPointerDown",move:"MSPointerMove",cancel:"MSPointerCancel",end:"MSPointerUp"},X._touchEvents={start:"touchstart",move:"touchmove",cancel:"touchcancel",end:"touchend"},X._mouseEvents={start:"mousedown",move:"mousemove",cancel:"",end:"mouseup"},X._inputEvents=g?X._touchEvents:v?X._pointerEvents:y?X._msPointerEvents:X._mouseEvents,X._emitter=new S,X._emitterEvents={start:"start",move:"move",end:"end",cancel:"cancel"},X._activeInstances=[],X._preventDefault=function(t){t.preventDefault&&!1!==t.cancelable&&t.preventDefault()},X._activateInstance=function(t){X._activeInstances.indexOf(t)>-1||(X._activeInstances.push(t),X._emitter.on(X._emitterEvents.move,t._onMove),X._emitter.on(X._emitterEvents.cancel,t._onCancel),X._emitter.on(X._emitterEvents.end,t._onEnd),1===X._activeInstances.length&&X._bindListeners())},X._deactivateInstance=function(t){var e=X._activeInstances.indexOf(t);-1!==e&&(X._activeInstances.splice(e,1),X._emitter.off(X._emitterEvents.move,t._onMove),X._emitter.off(X._emitterEvents.cancel,t._onCancel),X._emitter.off(X._emitterEvents.end,t._onEnd),X._activeInstances.length||X._unbindListeners())},X._bindListeners=function(){window.addEventListener(X._inputEvents.move,X._onMove,C),window.addEventListener(X._inputEvents.end,X._onEnd,C),X._inputEvents.cancel&&window.addEventListener(X._inputEvents.cancel,X._onCancel,C)},X._unbindListeners=function(){window.removeEventListener(X._inputEvents.move,X._onMove,C),window.removeEventListener(X._inputEvents.end,X._onEnd,C),X._inputEvents.cancel&&window.removeEventListener(X._inputEvents.cancel,X._onCancel,C)},X._getEventPointerId=function(t){return"number"==typeof t.pointerId?t.pointerId:t.changedTouches?t.changedTouches[0]?t.changedTouches[0].identifier:null:1},X._getTouchById=function(t,e){if("number"==typeof t.pointerId)return t.pointerId===e?t:null;if(t.changedTouches){for(var i=0;i=this.maxValue:this.value<=0},kt.prototype.computeCurrentScrollValue=function(){return null===this.value?1&this.direction?St(this.element):wt(this.element):Math.max(0,Math.min(this.value,this.maxValue))},kt.prototype.computeNextScrollValue=function(t){var e=this.speed*(t/1e3),i=4&this.direction?this.value+e:this.value-e;return Math.max(0,Math.min(i,this.maxValue))},kt.prototype.computeSpeed=(pt={direction:null,threshold:0,distance:0,value:0,maxValue:0,deltaTime:0,duration:0,isEnding:!1},function(t){var e=this.item,i=Et(e).speed;return dt(i)?(pt.direction=this.direction,pt.threshold=this.threshold,pt.distance=this.distance,pt.value=this.value,pt.maxValue=this.maxValue,pt.duration=this.duration,pt.speed=this.speed,pt.deltaTime=t,pt.isEnding=this.isEnding,i(e,this.element,pt)):i}),kt.prototype.tick=function(t){return this.isActive||(this.isActive=!0,this.onStart()),this.value=this.computeCurrentScrollValue(),this.speed=this.computeSpeed(t),this.value=this.computeNextScrollValue(t),this.duration+=t,this.value},kt.prototype.onStart=function(){var t=this.item,e=Et(t).onStart;dt(e)&&e(t,this.element,this.direction)},kt.prototype.onStop=function(){var t=this.item,e=Et(t).onStop;dt(e)&&e(t,this.element,this.direction),t._drag&&t._drag.sort()},Lt.prototype.reset=function(){this.requestX&&(this.requestX.action=null),this.requestY&&(this.requestY.action=null),this.element=null,this.requestX=null,this.requestY=null,this.scrollLeft=0,this.scrollTop=0},Lt.prototype.addRequest=function(t){1&t.direction?(this.removeRequest(this.requestX),this.requestX=t):(this.removeRequest(this.requestY),this.requestY=t),t.action=this},Lt.prototype.removeRequest=function(t){t&&(this.requestX===t?(this.requestX=null,t.action=null):this.requestY===t&&(this.requestY=null,t.action=null))},Lt.prototype.computeScrollValues=function(){this.scrollLeft=this.requestX?this.requestX.value:St(this.element),this.scrollTop=this.requestY?this.requestY.value:wt(this.element)},Lt.prototype.scroll=function(){var t=this.element;t&&(t.scrollTo?t.scrollTo(this.scrollLeft,this.scrollTop):(t.scrollLeft=this.scrollLeft,t.scrollTop=this.scrollTop))},Rt.prototype.pick=function(){return this.pool.pop()||this.createItem()},Rt.prototype.release=function(t){this.releaseItem(t),-1===this.pool.indexOf(t)&&this.pool.push(t)},Rt.prototype.reset=function(){this.pool.length=0};var Ct={width:0,height:0,left:0,right:0,top:0,bottom:0},Mt={width:0,height:0,left:0,right:0,top:0,bottom:0};function Pt(){this._isDestroyed=!1,this._isTicking=!1,this._tickTime=0,this._tickDeltaTime=0,this._items=[],this._actions=[],this._requests={},this._requests[1]={},this._requests[2]={},this._requestOverlapCheck={},this._dragPositions={},this._dragDirections={},this._overlapCheckInterval=150,this._requestPool=new Rt((function(){return new kt}),(function(t){t.reset()})),this._actionPool=new Rt((function(){return new Lt}),(function(t){t.reset()})),this._readTick=this._readTick.bind(this),this._writeTick=this._writeTick.bind(this)}Pt.AXIS_X=1,Pt.AXIS_Y=2,Pt.FORWARD=4,Pt.BACKWARD=8,Pt.LEFT=9,Pt.RIGHT=5,Pt.UP=10,Pt.DOWN=6,Pt.smoothSpeed=function(t,e,i){return function(s,n,o){var r=0;if(!o.isEnding)if(o.threshold>0){var h=o.threshold-Math.max(0,o.distance);r=t/o.threshold*h}else r=t;var a=o.speed,_=r;return a===r?_:a=A&&w>0&&(g>A||m>T)&&(y=null,v=xt("number"==typeof u.threshold?u.threshold:o,r,l.width,d.width),5===a?(S=d.right+v.offset-l.right)<=v.value&&St(c)0&&(y=9),null!==y&&(b=c,A=g,E=v.value,T=m,x=y,k=S,L=w)),p&&g>=I&&D>0&&(g>I||m>M)&&(y=null,v=xt("number"==typeof u.threshold?u.threshold:o,r,l.height,d.height),6===_?(S=d.bottom+v.offset-l.bottom)<=v.value&&wt(c)0&&(y=10),null!==y&&(R=c,I=g,C=v.value,M=m,P=y,X=S,Y=D)))));e&&(b?this._requestItemScroll(t,1,b,x,E,k,L):this._cancelItemScroll(t,1)),i&&(R?this._requestItemScroll(t,2,R,P,C,X,Y):this._cancelItemScroll(t,2))},Pt.prototype._updateScrollRequest=function(t){for(var e=t.item,i=Et(e),s=dt(i.targets)?i.targets(e):i.targets,n=s&&s.length||0,o=i.threshold,r=i.safeZone,h=this._getItemHandleRect(e,i.handle,Ct),a=Mt,_=null,l=null,d=!1,u=null,c=null,f=null,p=null,m=null,g=0;gu.value)break;if(f=d?St(l):wt(l),m=4&t.direction?f>=p:f<=0)break;return t.maxValue=p,t.threshold=u.value,t.distance=c,t.isEnding=!1,!0}return!0===i.smoothStop&&t.speed>0?(null===m&&(m=t.hasReachedEnd()),t.isEnding=!m):t.isEnding=!1,t.isEnding},Pt.prototype._updateRequests=function(){for(var t,e,i,s,n,o,r,h=this._items,a=this._requests[1],_=this._requests[2],l=0;l0&&this._tickTime-s>this._overlapCheckInterval,o=!0,(e=a[t._id])&&e.isActive&&(o=!this._updateScrollRequest(e))&&(n=!0,this._cancelItemScroll(t,1)),r=!0,(i=_[t._id])&&i.isActive&&(r=!this._updateScrollRequest(i))&&(n=!0,this._cancelItemScroll(t,2)),n&&(this._requestOverlapCheck[t._id]=0,this._checkItemOverlap(t,o,r))},Pt.prototype._requestAction=function(t,e){for(var i=this._actions,s=1===e,n=null,o=0;oo?5:sr?6:ns?s:e<0?Math.max(s+e+1,0):e}function Bt(t,e,i){if(!(t.length<2)){var s=Wt(t,e),n=Wt(t,i);s!==n&&t.splice(n,0,t.splice(s,1)[0])}}function Nt(t,e,i){if(!(t.length<2)){var s,n=Wt(t,e),o=Wt(t,i);n!==o&&(s=t[n],t[n]=t[o],t[o]=s)}}var Ft=E(document.documentElement.style,"transform")||"transform",zt=/([A-Z])/g,Vt=/^(webkit-|moz-|ms-|o-)/,jt=/^(-m-s-)/;function Qt(t){var e=t.replace(zt,"-$1").toLowerCase();return e=(e=e.replace(Vt,"-$1")).replace(jt,"-ms-")}var Ut=Qt(Ft);function Zt(t){var e=ct(t,Ut);if(!e||"none"===e)return!1;var i=ct(t,"display");return"inline"!==i&&"none"!==i}function Jt(t){for(var e=document,i=t||e;i&&i!==e&&"static"===ct(i,"position")&&!Zt(i);)i=i.parentElement||e;return i}var $t={},Kt={},te={};function ee(t,e){var i,s=e||{};return s.left=0,s.top=0,t===document?s:(s.left=window.pageXOffset||0,s.top=window.pageYOffset||0,t.self===window.self||(i=t.getBoundingClientRect(),s.left+=i.left,s.top+=i.top,s.left+=ft(t,"border-left-width"),s.top+=ft(t,"border-top-width")),s)}function ie(t,e,i){return te.left=0,te.top=0,t===e||i&&(t=Jt(t))===(e=Jt(e))||(ee(t,$t),ee(e,Kt),te.left=Kt.left-$t.left,te.top=Kt.top-$t.top),te}function se(t){return"auto"===t||"scroll"===t||"overlay"===t}function ne(t){return se(ct(t,"overflow"))||se(ct(t,"overflow-x"))||se(ct(t,"overflow-y"))}function oe(t,e){for(e=e||[];t&&t!==document;)t.getRootNode&&t instanceof DocumentFragment?t=t.getRootNode().host:(ne(t)&&e.push(t),t=t.parentNode);return e.push(window),e}var re={},he=/^matrix3d/,ae=/([^,]*,){4}/,_e=/([^,]*,){12}/,le=/[^,]*,/;function de(t){re.x=0,re.y=0;var e=ct(t,Ut);if(!e||"none"===e)return re;var i=he.test(e),s=e.replace(i?_e:ae,""),n=s.replace(le,"");return re.x=parseFloat(s)||0,re.y=parseFloat(n)||0,re}function ue(t,e){e&&(t.classList?t.classList.remove(e):qt(t,"."+e)&&(t.className=(" "+t.className+" ").replace(" "+e+" "," ").trim()))}var ce,fe,pe,me,ge=/^(iPad|iPhone|iPod)/.test(window.navigator.platform)||/^Mac/.test(window.navigator.platform)&&window.navigator.maxTouchPoints>1,ve=!!T()&&{passive:!0};function ye(t){var e=t._element,i=t.getGrid(),s=i._settings;this._item=t,this._gridId=i._id,this._isDestroyed=!1,this._isMigrating=!1,this._startPredicate=dt(s.dragStartPredicate)?s.dragStartPredicate:ye.defaultStartPredicate,this._startPredicateState=0,this._startPredicateResult=void 0,this._isSortNeeded=!1,this._sortTimer=void 0,this._blockedSortIndex=null,this._sortX1=0,this._sortX2=0,this._sortY1=0,this._sortY2=0,this._reset(),this._preStartCheck=this._preStartCheck.bind(this),this._preEndCheck=this._preEndCheck.bind(this),this._onScroll=this._onScroll.bind(this),this._prepareStart=this._prepareStart.bind(this),this._applyStart=this._applyStart.bind(this),this._prepareMove=this._prepareMove.bind(this),this._applyMove=this._applyMove.bind(this),this._prepareScroll=this._prepareScroll.bind(this),this._applyScroll=this._applyScroll.bind(this),this._handleSort=this._handleSort.bind(this),this._handleSortDelayed=this._handleSortDelayed.bind(this),this._handle=s.dragHandle&&e.querySelector(s.dragHandle)||e,this._dragger=new X(this._handle,s.dragCssProps),this._dragger.on("start",this._preStartCheck),this._dragger.on("move",this._preStartCheck),this._dragger.on("cancel",this._preEndCheck),this._dragger.on("end",this._preEndCheck)}function Se(t,e){var i,s,n={};if(Array.isArray(e))for(s=0;s=l||_>=d||(fe.left=a,fe.top=_,fe.width=l-a,fe.height=d-_,(s=It(ce,fe))>i&&s>p&&(p=s,c=o))}return me.length=0,c}(t,o,r);if(!_)return null;var l,d,u,c=t.getGrid()!==_,f=0,p=0,m=0,g=-1,v=!1;for(_===o?(ce.left=n._gridX+t._marginLeft,ce.top=n._gridY+t._marginTop):(_._updateBorders(1,0,1,0),f=_._left+_._borderLeft,p=_._top+_._borderTop),u=0;u<_._items.length;u++)(l=_._items[u])._isActive&&l!==t&&(v=!0,fe.width=l._width,fe.height=l._height,fe.left=l._left+l._marginLeft+f,fe.top=l._top+l._marginTop+p,(d=It(ce,fe))>m&&(g=u,m=d));return c&&m=r?(pe.grid=_,pe.index=g,pe.action=c?a:h,pe):null}),ye.prototype.stop=function(){if(this._isActive)if(this._isMigrating)this._finishMigration();else{var t=this._item,e=t._id;if(ye.autoScroller.removeItem(t),ot(e),rt(e),ht(e),this._cancelSort(),this._isStarted){this._unbindScrollListeners();var i=t._element,s=this._getGrid(),n=s._settings.itemDraggingClass;i.parentNode!==s._element&&(s._element.appendChild(i),t._setTranslate(this._gridX,this._gridY),n&&i.clientWidth),ue(i,n)}this._reset()}},ye.prototype.sort=function(t){var e=this._item;this._isActive&&e._isActive&&this._dragMoveEvent&&(!0===t?this._handleSort():at(e._id,this._handleSort))},ye.prototype.destroy=function(){this._isDestroyed||(this.stop(),this._dragger.destroy(),ye.autoScroller.removeItem(this._item),this._isDestroyed=!0)},ye.prototype._getGrid=function(){return t[this._gridId]||null},ye.prototype._reset=function(){this._isActive=!1,this._isStarted=!1,this._container=null,this._containingBlock=null,this._dragStartEvent=null,this._dragMoveEvent=null,this._dragPrevMoveEvent=null,this._scrollEvent=null,this._scrollers=[],this._left=0,this._top=0,this._gridX=0,this._gridY=0,this._clientX=0,this._clientY=0,this._scrollDiffX=0,this._scrollDiffY=0,this._moveDiffX=0,this._moveDiffY=0,this._containerDiffX=0,this._containerDiffY=0},ye.prototype._bindScrollListeners=function(){var t,e,i=this._getGrid()._element,s=this._container,n=this._scrollers;if(n.length=0,oe(this._item._element.parentNode,n),s!==i)for(oe(i,t=[]),e=0;e3&&i.minBounceBackAngle>0;if(r||(this._blockedSortIndex=null),Math.abs(n)>s||Math.abs(o)>s){if(r){var h=Math.atan2(n,o),a=Math.atan2(this._sortX2-this._sortX1,this._sortY2-this._sortY1),_=Math.atan2(Math.sin(h-a),Math.cos(h-a));Math.abs(_)>i.minBounceBackAngle&&(this._blockedSortIndex=null)}return this._sortX1=this._sortX2,this._sortY1=this._sortY2,this._sortX2=t,this._sortY2=e,!0}return!1},ye.prototype._resetStartPredicate=function(){var t=this._startPredicateData;t&&(t.delayTimer&&(t.delayTimer=window.clearTimeout(t.delayTimer)),this._startPredicateData=null)},ye.prototype._handleSort=function(){if(this._isActive){var t=this._getGrid()._settings;if(!t.dragSort||!t.dragAutoScroll.sortDuringScroll&&ye.autoScroller.isItemScrolling(this._item))return this._sortX1=this._sortX2=this._gridX,this._sortY1=this._sortY2=this._gridY,this._isSortNeeded=!0,void(void 0!==this._sortTimer&&(this._sortTimer=window.clearTimeout(this._sortTimer)));var e=this._checkHeuristics(this._gridX,this._gridY);if(this._isSortNeeded||e){var i=t.dragSortHeuristics.sortInterval;i<=0||this._isSortNeeded?(this._isSortNeeded=!1,void 0!==this._sortTimer&&(this._sortTimer=window.clearTimeout(this._sortTimer)),this._checkOverlap()):void 0===this._sortTimer&&(this._sortTimer=window.setTimeout(this._handleSortDelayed,i))}}},ye.prototype._handleSortDelayed=function(){this._isSortNeeded=!0,this._sortTimer=void 0,at(this._item._id,this._handleSort)},ye.prototype._cancelSort=function(){var t;this._isSortNeeded=!1,void 0!==this._sortTimer&&(this._sortTimer=window.clearTimeout(this._sortTimer)),t=this._item._id,it.remove(1,U+t)},ye.prototype._finishSort=function(){var t=this._getGrid()._settings.dragSort&&(this._isSortNeeded||void 0!==this._sortTimer);this._cancelSort(),t&&this._checkOverlap()},ye.prototype._checkOverlap=function(){if(this._isActive){var t,e,n,o,r,h,a,_,l=this._item,m=this._getGrid()._settings;(t=dt(m.dragSortPredicate)?m.dragSortPredicate(l,this._dragMoveEvent):ye.defaultSortPredicate(l,m.dragSortPredicate))&&"number"==typeof t.index&&(a=t.action===i?i:s,_=(e=l.getGrid())!==(o=t.grid||e),n=e._items.indexOf(l),r=Wt(o._items,t.index,_&&a===s?1:0),(_||r!==this._blockedSortIndex)&&(_?(this._blockedSortIndex=null,h=o._items[r],e._hasListeners(c)&&e._emit(c,{item:l,fromGrid:e,fromIndex:n,toGrid:o,toIndex:r}),o._hasListeners(p)&&o._emit(p,{item:l,fromGrid:e,fromIndex:n,toGrid:o,toIndex:r}),l._gridId=o._id,this._isMigrating=l._gridId!==this._gridId,e._items.splice(n,1),Gt(o._items,l,r),l._sortData=null,e._hasListeners(u)&&e._emit(u,{item:l,fromGrid:e,fromIndex:n,toGrid:o,toIndex:r}),o._hasListeners(f)&&o._emit(f,{item:l,fromGrid:e,fromIndex:n,toGrid:o,toIndex:r}),a===i&&h&&h.isActive()&&o._items.indexOf(h)>-1&&o.send(h,e,n,{appendTo:this._container||document.body,layoutSender:!1,layoutReceiver:!1}),e.layout(),o.layout()):n!==r&&(this._blockedSortIndex=n,(a===i?Nt:Bt)(e._items,n,r),e._hasListeners(d)&&e._emit(d,{item:l,fromIndex:n,toIndex:r,action:a}),e.layout())))}},ye.prototype._finishMigration=function(){var t,e,i=this._item,s=i._dragRelease,n=i._element,o=i._isActive,r=i.getGrid(),h=r._element,a=r._settings,_=a.dragContainer||h,l=this._getGrid()._settings,d=n.parentNode,u=o?l.itemVisibleClass:l.itemHiddenClass,c=o?a.itemVisibleClass:a.itemHiddenClass;this._isMigrating=!1,this.destroy(),l.itemClass!==a.itemClass&&(ue(n,l.itemClass),Ot(n,a.itemClass)),u!==c&&(ue(n,u),Ot(n,c)),_!==d&&(_.appendChild(n),e=ie(d,_,!0),(t=de(n)).x-=e.left,t.y-=e.top),i._refreshDimensions(),e=ie(_,h,!0),s._containerDiffX=e.left,s._containerDiffY=e.top,i._drag=a.dragEnabled?new ye(i):null,_!==d&&i._setTranslate(t.x,t.y),i._visibility.setStyles(o?a.visibleStyles:a.hiddenStyles),s.start()},ye.prototype._preStartCheck=function(t){0===this._startPredicateState&&(this._startPredicateState=1),1===this._startPredicateState?(this._startPredicateResult=this._startPredicate(this._item,t),!0===this._startPredicateResult?(this._startPredicateState=2,this._onStart(t)):!1===this._startPredicateResult&&(this._resetStartPredicate(t),this._dragger._reset(),this._startPredicateState=0)):2===this._startPredicateState&&this._isActive&&this._onMove(t)},ye.prototype._preEndCheck=function(t){var e=2===this._startPredicateState;this._startPredicate(this._item,t),this._startPredicateState=0,e&&this._isActive&&(this._isStarted?this._onEnd(t):this.stop())},ye.prototype._onStart=function(t){var e,i,s,n=this._item;n._isActive&&(this._isActive=!0,this._dragStartEvent=t,ye.autoScroller.addItem(n),e=n._id,i=this._prepareStart,s=this._applyStart,it.add(0,N+e,i),it.add(2,F+e,s))},ye.prototype._prepareStart=function(){if(this._isActive){var t=this._item;if(t._isActive){var e=t._element,i=this._getGrid(),s=i._settings,n=i._element,o=s.dragContainer||n,r=Jt(o),h=de(e),a=e.getBoundingClientRect(),_=o!==n;if(this._container=o,this._containingBlock=r,this._clientX=a.left,this._clientY=a.top,this._left=this._gridX=h.x,this._top=this._gridY=h.y,this._scrollDiffX=this._scrollDiffY=0,this._moveDiffX=this._moveDiffY=0,this._resetHeuristics(this._gridX,this._gridY),_){var l=ie(r,n);this._containerDiffX=l.left,this._containerDiffY=l.top}}}},ye.prototype._applyStart=function(){if(this._isActive){var t=this._item;if(t._isActive){var e=this._getGrid(),i=t._element,s=t._dragRelease,n=t._migrate,o=this._container!==e._element;t.isPositioning()&&t._layout.stop(!0,this._left,this._top),n._isActive&&(this._left-=n._containerDiffX,this._top-=n._containerDiffY,this._gridX-=n._containerDiffX,this._gridY-=n._containerDiffY,n.stop(!0,this._left,this._top)),t.isReleasing()&&s._reset(),e._settings.dragPlaceholder.enabled&&t._dragPlaceholder.create(),this._isStarted=!0,e._emit("dragInit",t,this._dragStartEvent),o&&(i.parentNode===this._container?(this._gridX-=this._containerDiffX,this._gridY-=this._containerDiffY):(this._left+=this._containerDiffX,this._top+=this._containerDiffY,this._container.appendChild(i),t._setTranslate(this._left,this._top))),Ot(i,e._settings.itemDraggingClass),this._bindScrollListeners(),e._emit("dragStart",t,this._dragStartEvent)}}},ye.prototype._onMove=function(t){var e,i,s,n=this._item;n._isActive?(this._dragMoveEvent=t,e=n._id,i=this._prepareMove,s=this._applyMove,it.add(0,z+e,i),it.add(2,V+e,s),at(n._id,this._handleSort)):this.stop()},ye.prototype._prepareMove=function(){if(this._isActive&&this._item._isActive){var t=this._getGrid()._settings.dragAxis,e=this._dragMoveEvent,i=this._dragPrevMoveEvent||this._dragStartEvent||e;if("y"!==t){var s=e.clientX-i.clientX;this._left=this._left-this._moveDiffX+s,this._gridX=this._gridX-this._moveDiffX+s,this._clientX=this._clientX-this._moveDiffX+s,this._moveDiffX=s}if("x"!==t){var n=e.clientY-i.clientY;this._top=this._top-this._moveDiffY+n,this._gridY=this._gridY-this._moveDiffY+n,this._clientY=this._clientY-this._moveDiffY+n,this._moveDiffY=n}this._dragPrevMoveEvent=e}},ye.prototype._applyMove=function(){if(this._isActive){var t=this._item;t._isActive&&(this._moveDiffX=this._moveDiffY=0,t._setTranslate(this._left,this._top),this._getGrid()._emit("dragMove",t,this._dragMoveEvent),ye.autoScroller.updateItem(t))}},ye.prototype._onScroll=function(t){var e,i,s,n=this._item;n._isActive?(this._scrollEvent=t,e=n._id,i=this._prepareScroll,s=this._applyScroll,it.add(0,j+e,i),it.add(2,Q+e,s),at(n._id,this._handleSort)):this.stop()},ye.prototype._prepareScroll=function(){if(this._isActive){var t=this._item;if(t._isActive){var e=t._element,i=this._getGrid()._element,s=e.getBoundingClientRect();if(this._container!==i){var n=ie(this._containingBlock,i);this._containerDiffX=n.left,this._containerDiffY=n.top}var o=this._clientX-this._moveDiffX-s.left;this._left=this._left-this._scrollDiffX+o,this._scrollDiffX=o;var r=this._clientY-this._moveDiffY-s.top;this._top=this._top-this._scrollDiffY+r,this._scrollDiffY=r,this._gridX=this._left-this._containerDiffX,this._gridY=this._top-this._containerDiffY}}},ye.prototype._applyScroll=function(){if(this._isActive){var t=this._item;t._isActive&&(this._scrollDiffX=this._scrollDiffY=0,t._setTranslate(this._left,this._top),this._getGrid()._emit("dragScroll",t,this._scrollEvent))}},ye.prototype._onEnd=function(t){var e=this._item,i=e._element,s=this._getGrid(),n=s._settings,o=e._dragRelease;e._isActive?(ot(e._id),rt(e._id),ht(e._id),this._finishSort(),this._unbindScrollListeners(),o._containerDiffX=this._containerDiffX,o._containerDiffY=this._containerDiffY,this._reset(),ue(i,n.itemDraggingClass),ye.autoScroller.removeItem(e),s._emit("dragEnd",e,t),this._isMigrating?this._finishMigration():o.start()):this.stop()};var we=/^(webkit|moz|ms|o|Webkit|Moz|MS|O)(?=[A-Z])/,De={};function be(t){var e=De[t];return e||((e=t.replace(we,""))!==t&&(e=e[0].toLowerCase()+e.slice(1)),De[t]=e,e)}function Ae(t,e){for(var i in e)t.style[i]=e[i]}var Ee,Te,xe=!(!Element||!dt(Element.prototype.animate)),ke=!!(Element&&(Ee=Element.prototype.animate,Te=window.Symbol,Ee&&dt(Te)&&dt(Te.toString)&&Te(Ee).toString().indexOf("[native code]")>-1));function Le(t){this._element=t,this._animation=null,this._duration=0,this._easing="",this._callback=null,this._props=[],this._values=[],this._isDestroyed=!1,this._onFinish=this._onFinish.bind(this)}function Re(t,e){var i={};for(var s in t)i[e?s:be(s)]=t[s];return i}function Ie(t,e){return"translateX("+t+"px) translateY("+e+"px)"}function Ce(t){this._item=t,this._animation=new Le,this._element=null,this._className="",this._didMigrate=!1,this._resetAfterLayout=!1,this._left=0,this._top=0,this._transX=0,this._transY=0,this._nextTransX=0,this._nextTransY=0,this._setupAnimation=this._setupAnimation.bind(this),this._startAnimation=this._startAnimation.bind(this),this._updateDimensions=this._updateDimensions.bind(this),this._onLayoutStart=this._onLayoutStart.bind(this),this._onLayoutEnd=this._onLayoutEnd.bind(this),this._onReleaseEnd=this._onReleaseEnd.bind(this),this._onMigrate=this._onMigrate.bind(this),this._onHide=this._onHide.bind(this)}function Me(t){this._item=t,this._isActive=!1,this._isDestroyed=!1,this._isPositioningStarted=!1,this._containerDiffX=0,this._containerDiffY=0}Le.prototype.start=function(t,e,i){if(!this._isDestroyed){var s=this._element,n=i||{};if(!xe)return Ae(s,e),this._callback=dt(n.onFinish)?n.onFinish:null,void this._onFinish();var o,r,h,a=this._animation,_=this._props,l=this._values,d=n.duration||300,u=n.easing||"ease",c=!1;if(a&&(r=0,d===this._duration&&u===this._easing||(c=!0),!c)){for(o in e)if(++r,-1===(h=_.indexOf(o))||e[o]!==l[h]){c=!0;break}r!==_.length&&(c=!0)}if(c&&a.cancel(),this._callback=dt(n.onFinish)?n.onFinish:null,!a||c){for(o in _.length=l.length=0,e)_.push(o),l.push(e[o]);this._duration=d,this._easing=u,this._animation=s.animate([Re(t,ke),Re(e,ke)],{duration:d,easing:u}),this._animation.onfinish=this._onFinish,Ae(s,e)}}},Le.prototype.stop=function(){!this._isDestroyed&&this._animation&&(this._animation.cancel(),this._animation=this._callback=null,this._props.length=this._values.length=0)},Le.prototype.getCurrentStyles=function(){return Se(element,currentProps)},Le.prototype.isAnimating=function(){return!!this._animation},Le.prototype.destroy=function(){this._isDestroyed||(this.stop(),this._element=null,this._isDestroyed=!0)},Le.prototype._onFinish=function(){var t=this._callback;this._animation=this._callback=null,this._props.length=this._values.length=0,t&&t()},Ce.prototype._updateDimensions=function(){this.isActive()&&Ae(this._element,{width:this._item._width+"px",height:this._item._height+"px"})},Ce.prototype._onLayoutStart=function(t,e){var i=this._item;if(-1!==t.indexOf(i)){var s=i._left,n=i._top,o=this._left,r=this._top;if(this._left=s,this._top=n,e||this._didMigrate||o!==s||r!==n){var h,a,_,l=s+i._marginLeft,d=n+i._marginTop,u=i.getGrid();if(!(!e&&u._settings.layoutDuration>0)||this._didMigrate)return _t(i._id),this._element.style[Ft]=Ie(l,d),this._animation.stop(),void(this._didMigrate&&(u.getElement().appendChild(this._element),this._didMigrate=!1));this._nextTransX=l,this._nextTransY=d,h=i._id,a=this._setupAnimation,_=this._startAnimation,it.add(0,Z+h,a),it.add(2,J+h,_)}}else this.reset()},Ce.prototype._setupAnimation=function(){if(this.isActive()){var t=de(this._element);this._transX=t.x,this._transY=t.y}},Ce.prototype._startAnimation=function(){if(this.isActive()){var t=this._animation,e=this._transX,i=this._transY,s=this._nextTransX,n=this._nextTransY;if(e!==s||i!==n){var o=this._item.getGrid()._settings,r={},h={};r[Ft]=Ie(e,i),h[Ft]=Ie(s,n),t.start(r,h,{duration:o.layoutDuration,easing:o.layoutEasing,onFinish:this._onLayoutEnd})}else t.isAnimating()&&(this._element.style[Ft]=Ie(s,n),t.stop())}},Ce.prototype._onLayoutEnd=function(){this._resetAfterLayout&&this.reset()},Ce.prototype._onReleaseEnd=function(t){if(t._id===this._item._id){if(!this._animation.isAnimating())return void this.reset();this._resetAfterLayout=!0}},Ce.prototype._onMigrate=function(t){if(t.item===this._item){var e=this._item.getGrid(),i=t.toGrid;e.off(m,this._onReleaseEnd),e.off(n,this._onLayoutStart),e.off(c,this._onMigrate),e.off(a,this._onHide),i.on(m,this._onReleaseEnd),i.on(n,this._onLayoutStart),i.on(c,this._onMigrate),i.on(a,this._onHide),this._didMigrate=!0}},Ce.prototype._onHide=function(t){t.indexOf(this._item)>-1&&this.reset()},Ce.prototype.create=function(){if(this.isActive())this._resetAfterLayout=!1;else{var t,e=this._item,i=e.getGrid(),s=i._settings,o=this._animation;this._left=e._left,this._top=e._top,t=dt(s.dragPlaceholder.createElement)?s.dragPlaceholder.createElement(e):document.createElement("div"),this._element=t,o._element=t,this._className=s.itemPlaceholderClass||"",this._className&&Ot(t,this._className),Ae(t,{position:"absolute",left:"0px",top:"0px",width:e._width+"px",height:e._height+"px"}),t.style[Ft]=Ie(e._left+e._marginLeft,e._top+e._marginTop),i.on(n,this._onLayoutStart),i.on(m,this._onReleaseEnd),i.on(c,this._onMigrate),i.on(a,this._onHide),dt(s.dragPlaceholder.onCreate)&&s.dragPlaceholder.onCreate(e,t),i.getElement().appendChild(t)}},Ce.prototype.reset=function(){if(this.isActive()){var t,e=this._element,i=this._item,s=i.getGrid(),o=s._settings,r=this._animation;this._resetAfterLayout=!1,_t(i._id),t=i._id,it.remove(2,$+t),r.stop(),r._element=null,s.off(m,this._onReleaseEnd),s.off(n,this._onLayoutStart),s.off(c,this._onMigrate),s.off(a,this._onHide),this._className&&(ue(e,this._className),this._className=""),e.parentNode.removeChild(e),this._element=null,dt(o.dragPlaceholder.onRemove)&&o.dragPlaceholder.onRemove(i,e)}},Ce.prototype.isActive=function(){return!!this._element},Ce.prototype.getElement=function(){return this._element},Ce.prototype.updateDimensions=function(){var t,e;this.isActive()&&(t=this._item._id,e=this._updateDimensions,it.add(2,$+t,e))},Ce.prototype.destroy=function(){this.reset(),this._animation.destroy(),this._item=this._animation=null},Me.prototype.start=function(){if(!this._isDestroyed&&!this._isActive){var t=this._item,e=t.getGrid(),i=e._settings;this._isActive=!0,Ot(t._element,i.itemReleasingClass),i.dragRelease.useDragContainer||this._placeToGrid(),e._emit("dragReleaseStart",t),e._nextLayoutData||t._layout.start(!1)}},Me.prototype.stop=function(t,e,i){if(!this._isDestroyed&&this._isActive){var s=this._item,n=s.getGrid();t||void 0!==e&&void 0!==i||(e=s._left,i=s._top);var o=this._placeToGrid(e,i);this._reset(o),t||n._emit(m,s)}},Me.prototype.isJustReleased=function(){return this._isActive&&!1===this._isPositioningStarted},Me.prototype.destroy=function(){this._isDestroyed||(this.stop(!0),this._item=null,this._isDestroyed=!0)},Me.prototype._placeToGrid=function(t,e){if(!this._isDestroyed){var i=this._item,s=i._element,n=i.getGrid()._element,o=!1;if(s.parentNode!==n){if(void 0===t||void 0===e){var r=de(s);t=r.x-this._containerDiffX,e=r.y-this._containerDiffY}n.appendChild(s),i._setTranslate(t,e),o=!0}return this._containerDiffX=0,this._containerDiffY=0,o}},Me.prototype._reset=function(t){if(!this._isDestroyed){var e=this._item,i=e.getGrid()._settings.itemReleasingClass;this._isActive=!1,this._isPositioningStarted=!1,this._containerDiffX=0,this._containerDiffY=0,i&&(t&&e._element.clientWidth,ue(e._element,i))}};function Pe(t){var e=t._element,i=e.style;this._item=t,this._isActive=!1,this._isDestroyed=!1,this._isInterrupted=!1,this._currentStyles={},this._targetStyles={},this._nextLeft=0,this._nextTop=0,this._offsetLeft=0,this._offsetTop=0,this._skipNextAnimation=!1,this._animOptions={onFinish:this._finish.bind(this),duration:0,easing:0},i.left="0px",i.top="0px",t._setTranslate(0,0),this._animation=new Le(e),this._queue="layout-"+t._id,this._setupAnimation=this._setupAnimation.bind(this),this._startAnimation=this._startAnimation.bind(this)}function Xe(t){this._item=t,this._isActive=!1,this._isDestroyed=!1,this._container=!1,this._containerDiffX=0,this._containerDiffY=0}function Ye(t){var e=t._isActive,i=t._element,s=i.children[0],n=t.getGrid()._settings;if(!s)throw new Error("No valid child element found within item element.");this._item=t,this._isDestroyed=!1,this._isHidden=!e,this._isHiding=!1,this._isShowing=!1,this._childElement=s,this._currentStyleProps=[],this._animation=new Le(s),this._queue="visibility-"+t._id,this._finishShow=this._finishShow.bind(this),this._finishHide=this._finishHide.bind(this),i.style.display=e?"":"none",Ot(i,e?n.itemVisibleClass:n.itemHiddenClass),this.setStyles(e?n.visibleStyles:n.hiddenStyles)}Pe.prototype.start=function(t,e){if(!this._isDestroyed){var i,s,n,o=this._item,r=o._dragRelease,h=o.getGrid()._settings,a=this._isActive,_=r.isJustReleased(),l=_?h.dragRelease.duration:h.layoutDuration,d=_?h.dragRelease.easing:h.layoutEasing,u=!t&&!this._skipNextAnimation&&l>0;if(a&&(st(o._id),o._emitter.burst(this._queue,!0,o)),_&&(r._isPositioningStarted=!0),dt(e)&&o._emitter.on(this._queue,e),this._skipNextAnimation=!1,!u)return this._updateOffsets(),o._setTranslate(this._nextLeft,this._nextTop),this._animation.stop(),void this._finish();this._animation.isAnimating()&&(this._animation._animation.onfinish=null),this._isActive=!0,this._animOptions.easing=d,this._animOptions.duration=l,this._isInterrupted=a,i=o._id,s=this._setupAnimation,n=this._startAnimation,it.add(0,H+i,s),it.add(2,G+i,n)}},Pe.prototype.stop=function(t,e,i){if(!this._isDestroyed&&this._isActive){var s=this._item;if(st(s._id),this._animation.isAnimating()){if(void 0===e||void 0===i){var n=de(s._element);e=n.x,i=n.y}s._setTranslate(e,i),this._animation.stop()}ue(s._element,s.getGrid()._settings.itemPositioningClass),this._isActive=!1,t&&s._emitter.burst(this._queue,!0,s)}},Pe.prototype.destroy=function(){if(!this._isDestroyed){var t=this._item._element.style;this.stop(!0,0,0),this._item._emitter.clear(this._queue),this._animation.destroy(),t[Ft]="",t.left="",t.top="",this._item=null,this._currentStyles=null,this._targetStyles=null,this._animOptions=null,this._isDestroyed=!0}},Pe.prototype._updateOffsets=function(){if(!this._isDestroyed){var t=this._item,e=t._migrate,i=t._dragRelease;this._offsetLeft=i._isActive?i._containerDiffX:e._isActive?e._containerDiffX:0,this._offsetTop=i._isActive?i._containerDiffY:e._isActive?e._containerDiffY:0,this._nextLeft=this._item._left+this._offsetLeft,this._nextTop=this._item._top+this._offsetTop}},Pe.prototype._finish=function(){if(!this._isDestroyed){var t=this._item,e=t._migrate,i=t._dragRelease;t._tX=this._nextLeft,t._tY=this._nextTop,this._isActive&&(this._isActive=!1,ue(t._element,t.getGrid()._settings.itemPositioningClass)),i._isActive&&i.stop(),e._isActive&&e.stop(),t._emitter.burst(this._queue,!1,t)}},Pe.prototype._setupAnimation=function(){var t=this._item;if(void 0===t._tX||void 0===t._tY){var e=de(t._element);t._tX=e.x,t._tY=e.y}},Pe.prototype._startAnimation=function(){var t=this._item,e=t.getGrid()._settings,i=this._animOptions.duration<=0;this._updateOffsets();var s=Math.abs(t._left-(t._tX-this._offsetLeft)),n=Math.abs(t._top-(t._tY-this._offsetTop));if(i||s<2&&n<2)return(s||n||this._isInterrupted)&&t._setTranslate(this._nextLeft,this._nextTop),this._animation.stop(),void this._finish();this._isInterrupted||Ot(t._element,e.itemPositioningClass),this._currentStyles[Ft]=Ie(t._tX,t._tY),this._targetStyles[Ft]=Ie(this._nextLeft,this._nextTop),t._tX=t._tY=void 0,this._animation.start(this._currentStyles,this._targetStyles,this._animOptions)},Xe.prototype.start=function(t,e,i){if(!this._isDestroyed){var s,n,o,r,h,a,_,l,d,m,g=this._item,v=g._element,y=g.isActive(),S=g.isVisible(),w=g.getGrid(),D=w._settings,b=t._settings,A=t._element,E=t._items,T=w._items.indexOf(g),x=i||document.body;if("number"==typeof e)s=Wt(E,e,1);else{if(!(n=t.getItem(e)))return;s=E.indexOf(n)}(g.isPositioning()||this._isActive||g.isReleasing())&&(_=(a=de(v)).x,l=a.y),g.isPositioning()&&g._layout.stop(!0,_,l),this._isActive&&(_-=this._containerDiffX,l-=this._containerDiffY,this.stop(!0,_,l)),g.isReleasing()&&(_-=g._dragRelease._containerDiffX,l-=g._dragRelease._containerDiffY,g._dragRelease.stop(!0,_,l)),g._visibility.stop(!0),g._drag&&g._drag.destroy(),w._hasListeners(c)&&w._emit(c,{item:g,fromGrid:w,fromIndex:T,toGrid:t,toIndex:s}),t._hasListeners(p)&&t._emit(p,{item:g,fromGrid:w,fromIndex:T,toGrid:t,toIndex:s}),D.itemClass!==b.itemClass&&(ue(v,D.itemClass),Ot(v,b.itemClass)),(d=S?D.itemVisibleClass:D.itemHiddenClass)!==(m=S?b.itemVisibleClass:b.itemHiddenClass)&&(ue(v,d),Ot(v,m)),w._items.splice(T,1),Gt(E,g,s),g._gridId=t._id,y?x!==(o=v.parentNode)&&(x.appendChild(v),r=ie(x,o,!0),a||(_=(a=de(v)).x,l=a.y),g._setTranslate(_+r.left,l+r.top)):A.appendChild(v),g._visibility.setStyles(S?b.visibleStyles:b.hiddenStyles),y&&(h=ie(x,A,!0)),g._refreshDimensions(),g._sortData=null,g._drag=b.dragEnabled?new ye(g):null,y?(this._isActive=!0,this._container=x,this._containerDiffX=h.left,this._containerDiffY=h.top):(this._isActive=!1,this._container=null,this._containerDiffX=0,this._containerDiffY=0),w._hasListeners(u)&&w._emit(u,{item:g,fromGrid:w,fromIndex:T,toGrid:t,toIndex:s}),t._hasListeners(f)&&t._emit(f,{item:g,fromGrid:w,fromIndex:T,toGrid:t,toIndex:s})}},Xe.prototype.stop=function(t,e,i){if(!this._isDestroyed&&this._isActive){var s,n=this._item,o=n._element,r=n.getGrid()._element;this._container!==r&&(void 0!==e&&void 0!==i||(t?(e=(s=de(o)).x-this._containerDiffX,i=s.y-this._containerDiffY):(e=n._left,i=n._top)),r.appendChild(o),n._setTranslate(e,i)),this._isActive=!1,this._container=null,this._containerDiffX=0,this._containerDiffY=0}},Xe.prototype.destroy=function(){this._isDestroyed||(this.stop(!0),this._item=null,this._isDestroyed=!0)},Ye.prototype.show=function(t,e){if(!this._isDestroyed){var i=this._item,s=i._element,n=dt(e)?e:null,o=i.getGrid()._settings;this._isShowing||this._isHidden?!this._isShowing||t?(this._isShowing||(i._emitter.burst(this._queue,!0,i),ue(s,o.itemHiddenClass),Ot(s,o.itemVisibleClass),this._isHiding||(s.style.display="")),n&&i._emitter.on(this._queue,n),this._isShowing=!0,this._isHiding=this._isHidden=!1,this._startAnimation(!0,t,this._finishShow)):n&&i._emitter.on(this._queue,n):n&&n(!1,i)}},Ye.prototype.hide=function(t,e){if(!this._isDestroyed){var i=this._item,s=i._element,n=dt(e)?e:null,o=i.getGrid()._settings;this._isHiding||!this._isHidden?!this._isHiding||t?(this._isHiding||(i._emitter.burst(this._queue,!0,i),Ot(s,o.itemHiddenClass),ue(s,o.itemVisibleClass)),n&&i._emitter.on(this._queue,n),this._isHidden=this._isHiding=!0,this._isShowing=!1,this._startAnimation(!1,t,this._finishHide)):n&&i._emitter.on(this._queue,n):n&&n(!1,i)}},Ye.prototype.stop=function(t){if(!this._isDestroyed&&(this._isHiding||this._isShowing)){var e=this._item;nt(e._id),this._animation.stop(),t&&e._emitter.burst(this._queue,!0,e)}},Ye.prototype.setStyles=function(t){var e=this._childElement,i=this._currentStyleProps;for(var s in this._removeCurrentStyles(),t)i.push(s),e.style[s]=t[s]},Ye.prototype.destroy=function(){if(!this._isDestroyed){var t=this._item,e=t._element,i=t.getGrid()._settings;this.stop(!0),t._emitter.clear(this._queue),this._animation.destroy(),this._removeCurrentStyles(),ue(e,i.itemVisibleClass),ue(e,i.itemHiddenClass),e.style.display="",this._isHiding=this._isShowing=!1,this._isDestroyed=this._isHidden=!0}},Ye.prototype._startAnimation=function(t,e,i){if(!this._isDestroyed){var s,n=this._item,o=this._animation,r=this._childElement,h=n.getGrid()._settings,a=t?h.visibleStyles:h.hiddenStyles,_=t?h.showDuration:h.hideDuration,l=t?h.showEasing:h.hideEasing,d=e||_<=0;if(a){if(nt(n._id),d)return Ae(r,a),o.stop(),void(i&&i());var u,c,f;o.isAnimating()&&(o._animation.onfinish=null),u=n._id,c=function(){s=Se(r,a)},f=function(){o.start(s,a,{duration:_,easing:l,onFinish:i})},it.add(0,W+u,c),it.add(2,B+u,f)}else i&&i()}},Ye.prototype._finishShow=function(){this._isHidden||(this._isShowing=!1,this._item._emitter.burst(this._queue,!1,this._item))},Ye.prototype._finishHide=function(){if(this._isHidden){var t=this._item;this._isHiding=!1,t._layout.stop(!0,0,0),t._element.style.display="none",t._emitter.burst(this._queue,!1,t)}},Ye.prototype._removeCurrentStyles=function(){for(var t=this._childElement,e=this._currentStyleProps,i=0;it.width&&(t.width=h.left+h.width):h.top+h.height>t.height&&(t.height=h.top+h.height),l[++this.slotIndex]=h.left,l[++this.slotIndex]=h.top,(c||f)&&this.slotSizes.push(h.width,h.height);if(c)for(i=0;it.height+r&&(u.left>h&&f.push(this.addRect(0,t.height,u.left,1/0)),u.left+u.widtht.width+r&&(u.top>h&&f.push(this.addRect(t.width,0,1/0,u.top)),u.top+u.height1&&this.purgeRects(f).sort(n?this.sortRectsLeftTop:this.sortRectsTopLeft),this.currentRects=f,this.nextRects=c,u},_.prototype.addRect=function(t,e,i,s){var n=++this.rectId;return this.rectStore[n]=t||0,this.rectStore[++this.rectId]=e||0,this.rectStore[++this.rectId]=i||0,this.rectStore[++this.rectId]=s||0,n},_.prototype.getRect=function(t,e){return e||(e=this.rectTarget),e.left=this.rectStore[t]||0,e.top=this.rectStore[++t]||0,e.width=this.rectStore[++t]||0,e.height=this.rectStore[++t]||0,e},_.prototype.splitRect=(e=[],i=0,s=0,function(t,n){return e.length=0,t.left+t.width<=n.left+r||n.left+n.width<=t.left+r||t.top+t.height<=n.top+r||n.top+n.height<=t.top+r?(e.push(this.addRect(t.left,t.top,t.width,t.height)),e):((i=n.left-t.left)>=h&&e.push(this.addRect(t.left,t.top,i,t.height)),(i=t.left+t.width-(n.left+n.width))>=h&&e.push(this.addRect(n.left+n.width,t.top,i,t.height)),(s=n.top-t.top)>=h&&e.push(this.addRect(t.left,t.top,t.width,s)),(s=t.top+t.height-(n.top+n.height))>=h&&e.push(this.addRect(t.left,n.top+n.height,t.width,s)),e)}),_.prototype.isRectAWithinRectB=function(t,e){return t.left+r>=e.left&&t.top+r>=e.top&&t.left+t.width-r<=e.left+e.width&&t.top+t.height-r<=e.top+e.height},_.prototype.purgeRects=(n={},o={},function(t){for(var e,i=t.length;i--;)if(e=t.length,t[i])for(this.getRect(t[i],n);e--;)if(t[e]&&i!==e&&(this.getRect(t[e],o),this.isRectAWithinRectB(n,o))){t[i]=0;break}return t}),_.prototype.sortRectsTopLeft=function(){var t={},e={};return function(i,s){return this.getRect(i,t),this.getRect(s,e),t.tope.top&&t.top-r>e.top?1:t.lefte.left&&t.left-r>e.left?1:0}}(),_.prototype.sortRectsLeftTop=function(){var t={},e={};return function(i,s){return this.getRect(i,t),this.getRect(s,e),t.lefte.left&&t.left-re.top&&t.top-r>e.top?1:0}}(),t){var l=new _;self.onmessage=function(t){var e=new Float32Array(t.data),i=e.subarray(4,e.length),s=new Float32Array(i.length),n=e[3],o={items:i,slots:s,width:e[1],height:e[2]};l.computeLayout(o,n),e[1]=o.width,e[2]=o.height,e.set(o.slots,4),postMessage(e.buffer,[e.buffer])}}return _}He.prototype.getGrid=function(){return t[this._gridId]},He.prototype.getElement=function(){return this._element},He.prototype.getWidth=function(){return this._width},He.prototype.getHeight=function(){return this._height},He.prototype.getMargin=function(){return{left:this._marginLeft,right:this._marginRight,top:this._marginTop,bottom:this._marginBottom}},He.prototype.getPosition=function(){return{left:this._left,top:this._top}},He.prototype.isActive=function(){return this._isActive},He.prototype.isVisible=function(){return!!this._visibility&&!this._visibility._isHidden},He.prototype.isShowing=function(){return!(!this._visibility||!this._visibility._isShowing)},He.prototype.isHiding=function(){return!(!this._visibility||!this._visibility._isHiding)},He.prototype.isPositioning=function(){return!(!this._layout||!this._layout._isActive)},He.prototype.isDragging=function(){return!(!this._drag||!this._drag._isActive)},He.prototype.isReleasing=function(){return!(!this._dragRelease||!this._dragRelease._isActive)},He.prototype.isDestroyed=function(){return this._isDestroyed},He.prototype._refreshDimensions=function(t){if(!(this._isDestroyed||!0!==t&&this._visibility._isHidden)){var e=this._element,i=this._dragPlaceholder,s=e.getBoundingClientRect();this._width=s.width,this._height=s.height,this._marginLeft=Math.max(0,ft(e,"margin-left")),this._marginRight=Math.max(0,ft(e,"margin-right")),this._marginTop=Math.max(0,ft(e,"margin-top")),this._marginBottom=Math.max(0,ft(e,"margin-bottom")),i&&i.updateDimensions()}},He.prototype._refreshSortData=function(){if(!this._isDestroyed){var t,e=this._sortData={},i=this.getGrid()._settings.sortData;for(t in i)e[t]=i[t](this,this._element)}},He.prototype._addToLayout=function(t,e){!0!==this._isActive&&(this._isActive=!0,this._left=t||0,this._top=e||0)},He.prototype._removeFromLayout=function(){!1!==this._isActive&&(this._isActive=!1,this._left=0,this._top=0)},He.prototype._canSkipLayout=function(t,e){return this._left===t&&this._top===e&&!this._migrate._isActive&&!this._layout._skipNextAnimation&&!this._dragRelease.isJustReleased()},He.prototype._setTranslate=function(t,e){return(this._tX!==t||this._tY!==e)&&(this._tX=t,this._tY=e,this._element.style[Ft]=Ie(t,e),!0)},He.prototype._destroy=function(t){if(!this._isDestroyed){var i=this._element,s=this.getGrid()._settings;this._dragPlaceholder.destroy(),this._dragRelease.destroy(),this._migrate.destroy(),this._layout.destroy(),this._visibility.destroy(),this._drag&&this._drag.destroy(),this._emitter.destroy(),ue(i,s.itemClass),t&&i.parentNode.removeChild(i),e&&e.delete(i),this._isActive=!1,this._isDestroyed=!0}};var We=Ge(),Be=null,Ne=[];function Fe(t,e){if(this._options=0,this._processor=null,this._layoutQueue=[],this._layouts={},this._layoutCallbacks={},this._layoutWorkers={},this._layoutWorkerData={},this._workers=[],this._onWorkerMessage=this._onWorkerMessage.bind(this),this.setOptions(e),(t="number"==typeof t?Math.max(0,t):0)&&window.Worker&&window.URL&&window.Blob)try{this._workers=function(t,e){var i=[];if(t>0){Be||(Be=URL.createObjectURL(new Blob(["("+Ge.toString()+")(true)"],{type:"application/javascript"})));for(var s,n=0;n-1&&this._layoutQueue.splice(e,1)}},Fe.prototype.destroy=function(){for(var t in this._layoutWorkers)this._workers.push(this._layoutWorkers[t]);!function(t){for(var e,i,s=0;s-1&&Ne.splice(i,1);Be&&!Ne.length&&(URL.revokeObjectURL(Be),Be=null)}(this._workers),this._workers.length=0,this._layoutQueue.length=0,this._layouts={},this._layoutCallbacks={},this._layoutWorkers={},this._layoutWorkerData={}};var ze=0;function Ve(t,e){var i=++ze,s=0,n=0,o=!1,r=function(e){o||(n&&(s-=e-n),n=e,s>0?function(t,e){it.add(0,et+t,e)}(i,r):(s=n=0,t()))};return function(h){if(!o){if(!(e<=0))return!0===h?(o=!0,s=n=0,r=void 0,void function(t){it.remove(0,et+t)}(i)):void(s<=0?(s=e,r(0)):s=e);!0!==h&&t()}}}function je(t){var e=Object.prototype.toString.call(t);return"[object HTMLCollection]"===e||"[object NodeList]"===e}var Qe=Object.prototype.toString;function Ue(t){return"object"==typeof t&&"[object Object]"===Qe.call(t)}function Ze(){}var Je,$e="number",Ke="string",ti="instant",ei=0;function ii(e,i){if(typeof e===Ke&&(e=document.querySelector(e)),!(e.getRootNode?e.getRootNode({composed:!0})===document:document.body.contains(e))||e===document.documentElement)throw new Error("Container element must be an existing DOM element.");var s=function(t,e){var i=si({},t);e&&(i=si(i,e));e&&e.visibleStyles?i.visibleStyles=e.visibleStyles:t&&t.visibleStyles&&(i.visibleStyles=t.visibleStyles);e&&e.hiddenStyles?i.hiddenStyles=e.hiddenStyles:t&&t.hiddenStyles&&(i.hiddenStyles=t.hiddenStyles);return i}(ii.defaultOptions,i);s.visibleStyles=ni(s.visibleStyles),s.hiddenStyles=ni(s.hiddenStyles),dt(s.dragSort)||(s.dragSort=!!s.dragSort),this._id=Oe(),this._element=e,this._settings=s,this._isDestroyed=!1,this._items=[],this._layout={id:0,items:[],slots:[]},this._isLayoutFinished=!0,this._nextLayoutData=null,this._emitter=new S,this._onLayoutDataReceived=this._onLayoutDataReceived.bind(this),t[this._id]=this,Ot(e,s.containerClass),function(t,e){typeof e!==$e&&(e=!0===e?0:-1);e>=0&&(t._resizeHandler=Ve((function(){t.refreshItems().layout()}),e),window.addEventListener("resize",t._resizeHandler))}(this,s.layoutOnResize),this.add(function(t,e){if("*"===e)return t.children;if(typeof e===Ke){for(var i=[],s=t.children,n=0;n-1?t:this._items.length+t]||null;if(t instanceof He)return t._gridId===this._id?t:null;if(e){var i=e.get(t);return i&&i._gridId===this._id?i:null}for(var s=0;sa?1:0:a<_?-1:a>_?1:0)return l;return l||(s||(s=oi(i)),l=e?ri(s,o,n):ri(s,n,o)),l}function o(n,o){var r=e?-t(n,o):t(n,o);return r||(s||(s=oi(i)),r=e?ri(s,o,n):ri(s,n,o)),r}return function(r,h){if(this._isDestroyed||this._items.length<2)return this;var a=this._items,_=h||{},d=_.layout?_.layout:void 0===_.layout;if(e=!!_.descending,i=a.slice(0),s=null,dt(r))t=r,a.sort(o);else if(typeof r===Ke)t=r.trim().split(" ").filter((function(t){return t})).map((function(t){return t.split(":")})),a.sort(n);else{if(!Array.isArray(r))throw t=e=i=s=null,new Error("Invalid comparer argument provided.");a.length=0,a.push.apply(a,r)}return this._hasListeners(l)&&this._emit(l,a.slice(0),i),d&&this.layout(d===ti,dt(d)?d:void 0),t=e=i=s=null,this}}(),ii.prototype.move=function(t,e,n){if(this._isDestroyed||this._items.length<2)return this;var o,r,h=this._items,a=n||{},_=a.layout?a.layout:void 0===a.layout,l=a.action===i,u=l?i:s,c=this.getItem(t),f=this.getItem(e);return c&&f&&c!==f&&(o=h.indexOf(c),r=h.indexOf(f),l?Nt(h,o,r):Bt(h,o,r),this._hasListeners(d)&&this._emit(d,{item:c,fromIndex:o,toIndex:r,action:u}),_&&this.layout(_===ti,dt(_)?_:void 0)),this},ii.prototype.send=function(t,e,i,s){if(this._isDestroyed||e._isDestroyed||this===e)return this;if(!(t=this.getItem(t)))return this;var n=s||{},o=n.appendTo||document.body,r=n.layoutSender?n.layoutSender:void 0===n.layoutSender,h=n.layoutReceiver?n.layoutReceiver:void 0===n.layoutReceiver;return t._migrate.start(e,i,o),t._migrate._isActive&&t._isActive&&(r&&this.layout(r===ti,dt(r)?r:void 0),h&&e.layout(h===ti,dt(h)?h:void 0)),this},ii.prototype.destroy=function(e){if(this._isDestroyed)return this;var i,s,n,o=this._element,r=this._items.slice(0),h=this._layout&&this._layout.styles||{};for((n=this)._resizeHandler&&(n._resizeHandler(!0),window.removeEventListener("resize",n._resizeHandler),n._resizeHandler=null),i=0;i0},ii.prototype._updateBoundingRect=function(){var t=this._element.getBoundingClientRect();this._width=t.width,this._height=t.height,this._left=t.left,this._top=t.top,this._right=t.right,this._bottom=t.bottom},ii.prototype._updateBorders=function(t,e,i,s){var n=this._element;t&&(this._borderLeft=ft(n,"border-left-width")),e&&(this._borderRight=ft(n,"border-right-width")),i&&(this._borderTop=ft(n,"border-top-width")),s&&(this._borderBottom=ft(n,"border-bottom-width"))},ii.prototype._refreshDimensions=function(){this._updateBoundingRect(),this._updateBorders(1,1,1,1),this._boxSizing=ct(this._element,"box-sizing")},ii.prototype._onLayoutDataReceived=(Je=[],function(t){if(!this._isDestroyed&&this._nextLayoutData&&this._nextLayoutData.id===t.id){var e,i,s,h,a=this,_=this._nextLayoutData.instant,l=this._nextLayoutData.onFinish,d=t.items.length,u=d;for(this._nextLayoutData=null,!this._isLayoutFinished&&this._hasListeners(r)&&this._emit(r,this._layout.items.slice(0)),this._layout=t,Je.length=0,h=0;h0)){var e=a._layout.id!==t.id,i=dt(_)?_:l;e||(a._isLayoutFinished=!0),dt(i)&&i(t.items.slice(0),e),!e&&a._hasListeners(o)&&a._emit(o,t.items.slice(0))}};if(!Je.length)return c(),this;for(this._isLayoutFinished=!1,h=0;h