UNPKG

47.1 kBJavaScriptView Raw
1/*
2Copyright (c) 2021-present NAVER Corp.
3name: @egjs/grid
4license: MIT
5author: NAVER Corp.
6repository: https://github.com/naver/egjs-grid
7version: 1.6.0
8*/
9!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Grid=e()}(this,function(){"use strict";var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var f=function(){return(f=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function o(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;0<=a;a--)(r=t[a])&&(s=(o<3?r(s):3<o?r(e,n,s):r(e,n))||s);return 3<o&&s&&Object.defineProperty(e,n,s),s}function g(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var i=Array(t),r=0,e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)i[r]=o[s];return i}function h(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&i>=t.length?void 0:t)&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(i=o.next()).done;)s.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}(arguments[e]));return t}function l(t){return void 0===t}var a,c,d,u=function(){function t(t,e){var n,i;if(this.eventType=t,this._canceled=!1,e)try{for(var r=h(Object.keys(e)),o=r.next();!o.done;o=r.next()){var s=o.value;this[s]=e[s]}}catch(t){n={error:t}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}}var e=t.prototype;return e.stop=function(){this._canceled=!0},e.isCanceled=function(){return this._canceled},t}(),t=function(){function t(){this._eventHandler={}}var e=t.prototype;return e.trigger=function(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];var i=e instanceof u?e.eventType:e,i=s(this._eventHandler[i]||[]);return i.length<=0||(e instanceof u?(e.currentTarget=this,i.forEach(function(t){t(e)})):i.forEach(function(t){t.apply(void 0,s(n))})),this},e.once=function(n,i){var r,o=this;if("object"==typeof n&&l(i)){var t,e=n;for(t in e)this.once(t,e[t]);return this}return"string"==typeof n&&"function"==typeof i&&this.on(n,r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];i.apply(void 0,s(t)),o.off(n,r)}),this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&l(e)){var n,i=t;for(n in i)this.on(n,i[n]);return this}var r;return"string"==typeof t&&"function"==typeof e&&(r=this._eventHandler[t],l(r)&&(this._eventHandler[t]=[],r=this._eventHandler[t]),r.push(e)),this},e.off=function(t,e){var n,i;if(l(t))return this._eventHandler={},this;if(l(e)){if("string"==typeof t)return delete this._eventHandler[t],this;var r,o=t;for(r in o)this.off(r,o[r]);return this}var s=this._eventHandler[t];if(s){var a=0;try{for(var u=h(s),c=u.next();!c.done;c=u.next()){if(c.value===e){s.splice(a,1),s.length<=0&&delete this._eventHandler[t];break}a++}}catch(t){n={error:t}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}return this},t.VERSION="3.0.1",t}(),p={horizontal:!1,useTransform:!1,percentage:!1,isEqualSize:!1,isConstantSize:!1,gap:0,attributePrefix:"data-grid-",resizeDebounce:100,maxResizeDebounce:0,autoResize:!0,preserveUIOnDestroy:!1,defaultDirection:"end",externalContainerManager:null,externalItemRenderer:null,renderOnPropertyChange:!0,useFit:!0};(R=a=a||{})[R.PROPERTY=1]="PROPERTY",R[R.RENDER_PROPERTY=2]="RENDER_PROPERTY",(_=c=c||{})[_.UNCHECKED=1]="UNCHECKED",_[_.UNMOUNTED=2]="UNMOUNTED",_[_.MOUNTED=3]="MOUNTED",(P=d=d||{})[P.NEED_UPDATE=1]="NEED_UPDATE",P[P.WAIT_LOADING=2]="WAIT_LOADING",P[P.UPDATED=3]="UPDATED";var n={gap:a.RENDER_PROPERTY,defaultDirection:a.PROPERTY,renderOnPropertyChange:a.PROPERTY,preserveUIOnDestroy:a.PROPERTY,useFit:a.PROPERTY},e=["syncElements","updateItems","getItems","setItems","renderItems","getContainerInlineSize","getContainerElement"],m={horizontal:{inlinePos:"top",contentPos:"left",inlineSize:"height",contentSize:"width"},vertical:{inlinePos:"left",contentPos:"top",inlineSize:"width",contentSize:"height"}},v=function(i){function t(t,e){var n=i.call(this)||this;return n.container=t,n._resizeTimer=0,n._maxResizeDebounceTimer=0,n._onResize=function(){clearTimeout(n._resizeTimer),clearTimeout(n._maxResizeDebounceTimer),n._maxResizeDebounceTimer=0,n._resizeTimer=0,n.trigger("resize")},n._scheduleResize=function(){var t=n.options,e=t.resizeDebounce,t=t.maxResizeDebounce;!n._maxResizeDebounceTimer&&e<=t&&(n._maxResizeDebounceTimer=window.setTimeout(n._onResize,t)),n._resizeTimer&&(clearTimeout(n._resizeTimer),n._resizeTimer=0),n._resizeTimer=window.setTimeout(n._onResize,e)},n.options=f({horizontal:p.horizontal,autoResize:p.autoResize,resizeDebounce:p.resizeDebounce,maxResizeDebounce:p.maxResizeDebounce},e),n._init(),n}r(t,i);var e=t.prototype;return e.resize=function(){var t=this.container;this.setRect({width:t.clientWidth,height:t.clientHeight})},e.getRect=function(){return this.rect},e.setRect=function(t){this.rect=f({},t)},e.getInlineSize=function(){return this.rect[this.options.horizontal?"height":"width"]},e.getContentSize=function(){return this.rect[this.options.horizontal?"width":"height"]},e.getStatus=function(){return{rect:f({},this.rect)}},e.setStatus=function(t){this.rect=f({},t.rect),this.setContentSize(this.getContentSize())},e.setContentSize=function(t){var e=this.options.horizontal?"width":"height";this.rect[e]=t,this.container.style[e]=t+"px"},e.destroy=function(t){void 0===t&&(t={}),window.removeEventListener("resize",this._scheduleResize),t.preserveUI||(this.container.style.cssText=this.orgCSSText)},e._init=function(){var t=this.container,e=window.getComputedStyle(t);this.orgCSSText=t.style.cssText,"static"===e.position&&(t.style.position="relative"),this.options.autoResize&&window.addEventListener("resize",this._scheduleResize)},t}(t);function y(t){return void 0===t}var R=function(){function t(){this.options={},this._eventHandler={}}var e=t.prototype;return e.trigger=function(t){for(var e=this,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];if(!(0<(s=this._eventHandler[t]||[]).length))return!0;var r=n[0]||{},o=n.slice(1),s=s.concat(),a=!1;r.eventType=t,r.stop=function(){a=!0},r.currentTarget=this;var u=[r];return 1<=o.length&&(u=u.concat(o)),s.forEach(function(t){t.apply(e,u)}),!a},e.once=function(n,i){var r,o=this;if("object"==typeof n&&y(i)){var t,e=n;for(t in e)this.once(t,e[t]);return this}return"string"==typeof n&&"function"==typeof i&&this.on(n,r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];i.apply(o,t),o.off(n,r)}),this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&y(e)){var n,i=t;for(n in i)this.on(n,i[n]);return this}var r;return"string"==typeof t&&"function"==typeof e&&(y(r=this._eventHandler[t])&&(this._eventHandler[t]=[],r=this._eventHandler[t]),r.push(e)),this},e.off=function(t,e){var n,i;if(y(t))return this._eventHandler={},this;if(y(e)){if("string"==typeof t)return delete this._eventHandler[t],this;var r,o=t;for(r in o)this.off(r,o[r]);return this}var s=this._eventHandler[t];if(s){var a=0;try{for(var u=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&i>=t.length?void 0:t)&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(s),c=u.next();!c.done;c=u.next()){if(c.value===e){s.splice(a,1);break}a++}}catch(t){n={error:t}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}return this},t.VERSION="2.2.2",t}(),S=function(t,e){return(S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function z(t,e){function n(){this.constructor=t}S(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var E=function(){return(E=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};var _="undefined"!=typeof window,P=_?window.navigator.userAgent:"",C=_&&!!("getComputedStyle"in window),T=/MSIE|Trident|Windows Phone|Edge/.test(P),O=_&&!!("addEventListener"in document),b="width",w="height";function I(t,e){return t.getAttribute(e)||""}function x(t){return[].slice.call(t)}function D(t){return"loading"in t&&"lazy"===t.getAttribute("loading")}function M(t,e,n){O?t.addEventListener(e,n,!1):t.attachEvent?t.attachEvent("on"+e,n):t["on"+e]=n}function k(t,e,n){t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent?t.detachEvent("on"+e,n):t["on"+e]=null}function N(t,e){var n=t["client"+e]||t["offset"+e];return parseFloat(n||(t=t,((C?window.getComputedStyle(t):t.currentStyle)||{})[e.toLowerCase()]))||0}function A(t,e,n){var i=x(t.querySelectorAll(function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var i=Array(t),r=0,e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)i[r]=o[s];return i}(["["+n+"skip] ["+n+"width]"],e.map(function(t){return["["+n+"skip] "+t,t+"["+n+"skip]","["+n+"width] "+t].join(", ")})).join(", ")));return x(t.querySelectorAll("["+n+"width], "+e.join(", "))).filter(function(t){return-1===i.indexOf(t)})}var F=[];function j(t,e){F.length||M(window,"resize",L),t.__PREFIX__=e,F.push(t),U(t)}function U(t,e){void 0===e&&(e="data-");var n,i=t.__PREFIX__||e,r=parseInt(I(t,""+i+b),10)||0,e=parseInt(I(t,""+i+w),10)||0;I(t,i+"fixed")===w?(n=N(t,"Height")||e,t.style[b]=r/e*n+"px"):(n=N(t,"Width")||r,t.style[w]=e/r*n+"px")}function L(){F.forEach(function(t){U(t)})}var P=function(r){function t(t,e){void 0===e&&(e={});var n=r.call(this)||this;n.isReady=!1,n.isPreReady=!1,n.hasDataSize=!1,n.hasLoading=!1,n.isSkip=!1,n.onCheck=function(t){n.clear(),t&&"error"===t.type&&n.onError(n.element);t=!n.hasDataSize&&!n.hasLoading;n.onReady(t)},n.options=E({prefix:"data-"},e),n.element=t;var i=n.options.prefix;return n.hasDataSize=(e=i,!!t.getAttribute((e=void 0===e?"data-":e)+"width")),n.isSkip=(i=i,!!t.getAttribute((i=void 0===i?"data-":i)+"skip")),n.hasLoading=D(t),n}z(t,r);var e=t.prototype;return e.check=function(){return this.isSkip||!this.checkElement()?(this.onAlreadyReady(!0),!1):(this.hasDataSize&&j(this.element,this.options.prefix),(this.hasDataSize||this.hasLoading)&&this.onAlreadyPreReady(),!0)},e.addEvents=function(){var e=this,n=this.element;this.constructor.EVENTS.forEach(function(t){M(n,t,e.onCheck)})},e.clear=function(){var e=this,n=this.element;this.constructor.EVENTS.forEach(function(t){k(n,t,e.onCheck)}),this.removeAutoSizer()},e.destroy=function(){this.clear(),this.off()},e.removeAutoSizer=function(){var t,e,n;this.hasDataSize&&(n=this.options.prefix,t=this.element,e=n,(n=F.indexOf(t))<0||(e=I(t,e+"fixed"),delete t.__PREFIX__,t.style[e===w?b:w]="",F.splice(n,1),F.length||k(window,"resize",L)))},e.onError=function(t){this.trigger("error",{element:this.element,target:t})},e.onPreReady=function(){this.isPreReady||(this.isPreReady=!0,this.trigger("preReady",{element:this.element,hasLoading:this.hasLoading,isSkip:this.isSkip}))},e.onReady=function(t){this.isReady||((t=!this.isPreReady&&t)&&(this.isPreReady=!0),this.removeAutoSizer(),this.isReady=!0,this.trigger("ready",{element:this.element,withPreReady:t,hasLoading:this.hasLoading,isSkip:this.isSkip}))},e.onAlreadyError=function(t){var e=this;setTimeout(function(){e.onError(t)})},e.onAlreadyPreReady=function(){var t=this;setTimeout(function(){t.onPreReady()})},e.onAlreadyReady=function(t){var e=this;setTimeout(function(){e.onReady(t)})},t.EVENTS=[],t}(R),H=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}z(e,t);var n=e.prototype;return n.setHasLoading=function(t){this.hasLoading=t},n.check=function(){return this.isSkip?(this.onAlreadyReady(!0),!1):(this.hasDataSize?(j(this.element,this.options.prefix),this.onAlreadyPreReady()):this.trigger("requestChildren"),!0)},n.checkElement=function(){return!0},n.destroy=function(){this.clear(),this.trigger("requestDestroy"),this.off()},n.onAlreadyPreReady=function(){t.prototype.onAlreadyPreReady.call(this),this.trigger("reqeustReadyChildren")},e.EVENTS=[],e}(P),_=function(n){function t(t){void 0===t&&(t={});var e=n.call(this)||this;return e.readyCount=0,e.preReadyCount=0,e.totalCount=0,e.totalErrorCount=0,e.isPreReadyOver=!0,e.elementInfos=[],e.options=E({loaders:{},prefix:"data-"},t),e}z(t,n);var e=t.prototype;return e.check=function(t){var o=this,n=this.options.prefix;this.clear(),this.elementInfos=x(t).map(function(t,r){var e=o.getLoader(t,{prefix:n});return e.check(),e.on("error",function(t){o.onError(r,t.target)}).on("preReady",function(t){var e=o.elementInfos[r];e.hasLoading=t.hasLoading,e.isSkip=t.isSkip;t=o.checkPreReady(r);o.onPreReadyElement(r),t&&o.onPreReady()}).on("ready",function(t){var e=t.withPreReady,n=t.hasLoading,i=t.isSkip,t=o.elementInfos[r];t.hasLoading=n,t.isSkip=i;t=e&&o.checkPreReady(r),i=o.checkReady(r);e&&o.onPreReadyElement(r),o.onReadyElement(r),t&&o.onPreReady(),i&&o.onReady()}),{loader:e,element:t,hasLoading:!1,hasError:!1,isPreReady:!1,isReady:!1,isSkip:!1}});t=this.elementInfos.length;return(this.totalCount=t)||setTimeout(function(){o.onPreReady(),o.onReady()}),this},e.getTotalCount=function(){return this.totalCount},e.isPreReady=function(){return this.elementInfos.every(function(t){return t.isPreReady})},e.isReady=function(){return this.elementInfos.every(function(t){return t.isReady})},e.hasError=function(){return 0<this.totalErrorCount},e.clear=function(){this.isPreReadyOver=!1,this.totalCount=0,this.preReadyCount=0,this.readyCount=0,this.totalErrorCount=0,this.elementInfos.forEach(function(t){!t.isReady&&t.loader&&t.loader.destroy()}),this.elementInfos=[]},e.destroy=function(){this.clear(),this.off()},e.getLoader=function(e,t){var n=this,i=e.tagName.toLowerCase(),r=this.options.loaders,o=Object.keys(r);if(r[i])return new r[i](e,t);var s=new H(e,t),a=x(e.querySelectorAll(o.join(", ")));s.setHasLoading(a.some(D));var u=!1,c=this.clone().on("error",function(t){s.onError(t.target)}).on("ready",function(){s.onReady(u)});return s.on("requestChildren",function(){var t=A(e,o,n.options.prefix);c.check(t).on("preReady",function(t){(u=t.isReady)||s.onPreReady()})}).on("reqeustReadyChildren",function(){c.check(a)}).on("requestDestroy",function(){c.destroy()}),s},e.clone=function(){return new t(E({},this.options))},e.checkPreReady=function(t){return this.elementInfos[t].isPreReady=!0,++this.preReadyCount,!(this.preReadyCount<this.totalCount)},e.checkReady=function(t){return this.elementInfos[t].isReady=!0,++this.readyCount,!(this.readyCount<this.totalCount)},e.onError=function(t,e){var n=this.elementInfos[t];n.hasError=!0,this.trigger("error",{element:n.element,index:t,target:e,errorCount:this.getErrorCount(),totalErrorCount:++this.totalErrorCount})},e.onPreReadyElement=function(t){var e=this.elementInfos[t];this.trigger("preReadyElement",{element:e.element,index:t,preReadyCount:this.preReadyCount,readyCount:this.readyCount,totalCount:this.totalCount,isPreReady:this.isPreReady(),isReady:this.isReady(),hasLoading:e.hasLoading,isSkip:e.isSkip})},e.onPreReady=function(){this.isPreReadyOver=!0,this.trigger("preReady",{readyCount:this.readyCount,totalCount:this.totalCount,isReady:this.isReady(),hasLoading:this.hasLoading()})},e.onReadyElement=function(t){var e=this.elementInfos[t];this.trigger("readyElement",{index:t,element:e.element,hasError:e.hasError,errorCount:this.getErrorCount(),totalErrorCount:this.totalErrorCount,preReadyCount:this.preReadyCount,readyCount:this.readyCount,totalCount:this.totalCount,isPreReady:this.isPreReady(),isReady:this.isReady(),hasLoading:e.hasLoading,isPreReadyOver:this.isPreReadyOver,isSkip:e.isSkip})},e.onReady=function(){this.trigger("ready",{errorCount:this.getErrorCount(),totalErrorCount:this.totalErrorCount,totalCount:this.totalCount})},e.getErrorCount=function(){return this.elementInfos.filter(function(t){return t.hasError}).length},e.hasLoading=function(){return this.elementInfos.some(function(t){return t.hasLoading})},t}(R),Y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return z(e,t),e.prototype.checkElement=function(){var t=this.element,e=t.getAttribute("src");if(t.complete){if(e)return t.naturalWidth||this.onAlreadyError(t),!1;this.onAlreadyPreReady()}return this.addEvents(),T&&t.setAttribute("src",e),!0},e.EVENTS=["load","error"],e}(P),G=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return z(e,t),e.prototype.checkElement=function(){var t=this.element;return!(1<=t.readyState)&&(t.error?(this.onAlreadyError(t),!1):(this.addEvents(),!0))},e.EVENTS=["loadedmetadata","error"],e}(P),W=function(e){function t(t){return e.call(this,E({loaders:{img:Y,video:G}},t=void 0===t?{}:t))||this}return z(t,e),t}(_);function q(t){return"object"==typeof t}function V(t){var e,r=t.prototype,o=t.propertyTypes;for(e in o)!function(n){var i=o[n]===a.RENDER_PROPERTY,t=Object.getOwnPropertyDescriptor(r,n)||{};Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:t.get||function(){return this.options[n]},set:t.set||function(t){var e=this.options;e[n]!==t&&(e[n]=t,i&&e.renderOnPropertyChange&&this.scheduleRender())}})}(e)}function K(e){return function(t,r){e.forEach(function(i){i in t||(t[i]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=(n=this[r])[i].apply(n,t);return n===this[r]?this:n})})}}function B(t){for(var e=[],n=0;n<t;++n)e.push(n);return e}function X(t,e){return Math.max(t-e[1],e[0]-t,0)+1}var R=K(e),J=function(){function t(t){this.initialRect=null,this.sizePercetage=!1,this.posPercetage=!1,this.options=f({attributePrefix:p.attributePrefix,useTransform:p.useTransform,horizontal:p.horizontal,percentage:p.percentage,isEqualSize:p.isEqualSize,isConstantSize:p.isConstantSize},t),this._init()}var e=t.prototype;return e.resize=function(){this.initialRect=null},e.renderItems=function(t){var e=this;t.forEach(function(t){e._renderItem(t)})},e.getInlineSize=function(){return this.containerRect[this.options.horizontal?"height":"width"]},e.setContainerRect=function(t){this.containerRect=t},e.updateItems=function(t){var e=this;t.forEach(function(t){e._updateItem(t)})},e.getStatus=function(){return{initialRect:this.initialRect}},e.setStatus=function(t){this.initialRect=t.initialRect},e._init=function(){var t=this.options.percentage,e=!1,n=!1;!0===t?n=e=!0:t&&(-1<t.indexOf("position")&&(n=!0),-1<t.indexOf("size")&&(e=!0)),this.posPercetage=n,this.sizePercetage=e},e._updateItem=function(t){var e,n=this.options,i=n.isEqualSize,r=n.isConstantSize,o=this.initialRect,s=t.orgRect,a=t.element,u=t.updateState===d.WAIT_LOADING,n=s&&s.width&&s.height;if(i&&o)e=o;else if(r&&n&&!u)e=s;else{if(!a)return;e={left:a.offsetLeft,top:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight}}return t.isFirstUpdate||(t.orgRect=f({},e)),t.rect=f({},e),t.element&&(t.mountState=c.MOUNTED),t.updateState===d.NEED_UPDATE&&(t.updateState=d.UPDATED,t.isFirstUpdate=!0),t.attributes=a?function(t,e){for(var n={},i=t.attributes,r=i.length,o=0;o<r;++o){var s=i[o],a=s.name,s=s.value;-1!==a.indexOf(e)&&(n[a.replace(e,"").replace(/[\s-_]([a-z])/g,function(t,e){return e.toUpperCase()})]=s)}return n}(a,this.options.attributePrefix):{},u||(this.initialRect=f({},e)),e},e._renderItem=function(t){var n,i,e,r,o,s,a,u=t.element,c=t.cssRect;u&&c&&(a=(e=this.options).horizontal,t=e.useTransform,n=this.posPercetage,i=this.sizePercetage,e=["position: absolute;"],r=(a=m[a?"horizontal":"vertical"]).inlineSize,o=a.inlinePos,s=this.getInlineSize(),a=c,a=Object.keys(a),t&&(a=a.filter(function(t){return"top"!==t&&"left"!==t}),e.push("transform: translate("+(c.left||0)+"px, "+(c.top||0)+"px);")),e.push.apply(e,a.map(function(t){var e=c[t];return t===r&&i||t===o&&n?t+": "+e/s*100+"%;":t+": "+e+"px;"})),u.style.cssText+=e.join(""))},t}(),Q=function(){function t(){this.keys=[],this.values=[]}var e=t.prototype;return e.get=function(t){return this.values[this.keys.indexOf(t)]},e.set=function(t,e){var n=this.keys,i=this.values,r=n.indexOf(t),r=-1===r?n.length:r;n[r]=t,i[r]=e},t}(),Z=function(){function t(){this.object={}}var e=t.prototype;return e.get=function(t){return this.object[t]},e.set=function(t,e){this.object[t]=e},t}(),$="function"==typeof Map,tt=function(){function t(){}var e=t.prototype;return e.connect=function(t,e){this.prev=t,this.next=e,t&&(t.next=this),e&&(e.prev=this)},e.disconnect=function(){var t=this.prev,e=this.next;t&&(t.next=e),e&&(e.prev=t)},e.getIndex=function(){for(var t=this,e=-1;t;)t=t.prev,++e;return e},t}();var et=function(){function t(t,e,n,i,r,o,s,a){this.prevList=t,this.list=e,this.added=n,this.removed=i,this.changed=r,this.maintained=o,this.changedBeforeAdded=s,this.fixed=a}var e=t.prototype;return Object.defineProperty(e,"ordered",{get:function(){return this.cacheOrdered||this.caculateOrdered(),this.cacheOrdered},enumerable:!0,configurable:!0}),Object.defineProperty(e,"pureChanged",{get:function(){return this.cachePureChanged||this.caculateOrdered(),this.cachePureChanged},enumerable:!0,configurable:!0}),e.caculateOrdered=function(){var t,n,r,o,t=(t=this.changedBeforeAdded,n=this.fixed,r=[],o=[],t.forEach(function(t){var e=t[0],n=t[1],t=new tt;r[e]=t,o[n]=t}),r.forEach(function(t,e){t.connect(r[e-1])}),t.filter(function(t,e){return!n[e]}).map(function(t,e){var n=t[0],i=t[1];if(n===i)return[0,0];t=r[n],n=o[i-1],i=t.getIndex();return t.disconnect(),n?t.connect(n,n.next):t.connect(void 0,r[0]),[i,t.getIndex()]})),s=this.changed,a=[];this.cacheOrdered=t.filter(function(t,e){var n=t[0],i=t[1],t=s[e],e=t[0],t=t[1];if(n!==i)return a.push([e,t]),!0}),this.cachePureChanged=a},t}();var nt,it="function"==typeof Map?void 0:(nt=0,function(t){return t.__DIFF_KEY__||(t.__DIFF_KEY__=++nt)});function rt(t,e){return n=t,i=e,r=it,t=$?Map:r?Z:Q,e=r||function(t){return t},o=[],s=[],a=[],r=n.map(e),e=i.map(e),u=new t,c=new t,h=[],l=[],f={},d=[],g=p=0,r.forEach(function(t,e){u.set(t,e)}),e.forEach(function(t,e){c.set(t,e)}),r.forEach(function(t,e){t=c.get(t);void 0===t?(++g,s.push(e)):f[t]=g}),e.forEach(function(t,e){t=u.get(t);void 0===t?(o.push(e),++p):(a.push([t,e]),g=f[e]||0,h.push([t-g,e-p]),l.push(e===t),t!==e&&d.push([t,e]))}),s.reverse(),new et(n,i,o,s,d,a,h,l);var n,i,r,o,s,a,u,c,h,l,f,d,p,g}var ot=function(){function t(t,e){void 0===e&&(e={}),this.horizontal=t,this.isUpdate=!1,this.hasTransition=!1,this.transitionDuration="";var n,t=e.element,i=f({key:"",orgRect:{left:0,top:0,width:0,height:0},rect:{left:0,top:0,width:0,height:0},cssRect:{},attributes:{},data:{},isFirstUpdate:!1,mountState:c.UNCHECKED,updateState:d.NEED_UPDATE,element:t||null,orgCSSText:null!==(t=null==t?void 0:t.style.cssText)&&void 0!==t?t:"",gridData:{}},e);for(n in i)this[n]=i[n]}var e=t.prototype;return Object.defineProperty(e,"orgInlineSize",{get:function(){var t=this.orgRect||this.rect;return this.horizontal?t.height:t.width},enumerable:!1,configurable:!0}),Object.defineProperty(e,"orgContentSize",{get:function(){var t=this.orgRect||this.rect;return this.horizontal?t.width:t.height},enumerable:!1,configurable:!0}),Object.defineProperty(e,"inlineSize",{get:function(){var t=this.rect;return this.horizontal?t.height:t.width},enumerable:!1,configurable:!0}),Object.defineProperty(e,"contentSize",{get:function(){var t=this.rect;return this.horizontal?t.width:t.height},enumerable:!1,configurable:!0}),Object.defineProperty(e,"cssInlineSize",{get:function(){var t=this.cssRect;return this.horizontal?t.height:t.width},set:function(t){this.cssRect[this.horizontal?"height":"width"]=t},enumerable:!1,configurable:!0}),Object.defineProperty(e,"cssContentSize",{get:function(){var t=this.cssRect;return this.horizontal?t.width:t.height},set:function(t){this.cssRect[this.horizontal?"width":"height"]=t},enumerable:!1,configurable:!0}),Object.defineProperty(e,"cssInlinePos",{get:function(){var t=this.cssRect;return this.horizontal?t.top:t.left},set:function(t){this.cssRect[this.horizontal?"top":"left"]=t},enumerable:!1,configurable:!0}),Object.defineProperty(e,"cssContentPos",{get:function(){var t=this.cssRect;return this.horizontal?t.left:t.top},set:function(t){this.cssRect[this.horizontal?"left":"top"]=t},enumerable:!1,configurable:!0}),e.setCSSGridRect=function(t){var e,n=m[this.horizontal?"horizontal":"vertical"],i={};for(e in t)i[n[e]]=t[e];this.cssRect=i},e.getStatus=function(){return{mountState:this.mountState,updateState:this.updateState,attributes:this.attributes,orgCSSText:this.orgCSSText,isFirstUpdate:this.isFirstUpdate,element:null,key:this.key,orgRect:this.orgRect,rect:this.rect,cssRect:this.cssRect,gridData:this.gridData,data:this.data}},e.getMinimizedStatus=function(){var t={orgRect:this.orgRect,rect:this.rect,cssRect:this.cssRect,attributes:this.attributes,gridData:this.gridData};return void 0!==this.key&&(t.key=this.key),this.mountState!==c.UNCHECKED&&(t.mountState=this.mountState),this.updateState!==d.NEED_UPDATE&&(t.updateState=this.updateState),this.isFirstUpdate&&(t.isFirstUpdate=!0),this.orgCSSText&&(t.orgCSSText=this.orgCSSText),t},t}(),st=function(l){function t(t,e){void 0===e&&(e={});var n=l.call(this)||this;n.items=[],n.outlines={start:[],end:[]},n._renderTimer=0,n._onResize=function(){n.renderItems({useResize:!0})},n.options=f(f({},n.constructor.defaultOptions),e),n.containerElement="string"==typeof t?document.querySelector(t):t;var i=n.options,r=i.isEqualSize,o=i.isConstantSize,s=i.useTransform,a=i.horizontal,u=i.percentage,c=i.externalContainerManager,h=i.externalItemRenderer,e=i.resizeDebounce,t=i.maxResizeDebounce,i=i.autoResize;return n.containerManager=c||new v(n.containerElement,{horizontal:a,resizeDebounce:e,maxResizeDebounce:t,autoResize:i}).on("resize",n._onResize),n.itemRenderer=h||new J({useTransform:s,isEqualSize:r,isConstantSize:o,percentage:u}),n._init(),n}r(t,l);var e=t.prototype;return e.getContainerElement=function(){return this.containerElement},e.getItems=function(){return this.items},e.getChildren=function(){return[].slice.call(this.containerElement.children)},e.setItems=function(t){return this.items=t,this},e.getContainerInlineSize=function(){return this.containerManager.getInlineSize()},e.getOutlines=function(){return this.outlines},e.setOutlines=function(t){return this.outlines=t,this},e.syncElements=function(t){void 0===t&&(t={});var n=this.items,e=this.options.horizontal,i=this.getChildren(),r=rt(this.items.map(function(t){return t.element}),i),o=r.added,s=r.maintained,a=r.changed,r=r.removed,u=[];return s.forEach(function(t){var e=t[0],t=t[1];u[t]=n[e]}),o.forEach(function(t){u[t]=new ot(e,{element:i[t]})}),this.setItems(u),(o.length||r.length||a.length)&&this.renderItems(t),this},e.updateItems=function(t,e){return void 0===e&&(e={}),(t=void 0===t?this.items:t).forEach(function(t){t.updateState=d.NEED_UPDATE}),this.checkReady(e),this},e.renderItems=function(t){return void 0===t&&(t={}),this._clearRenderTimer(),!this.getItems().length&&this.getChildren().length?this.syncElements(t):t.useResize?(this._resizeContainer(),this.updateItems(this.items,t)):this.checkReady(t),this},e.getStatus=function(e){return{outlines:this.outlines,items:this.items.map(function(t){return e?t.getMinimizedStatus():t.getStatus()}),containerManager:this.containerManager.getStatus(),itemRenderer:this.itemRenderer.getStatus()}},e.setStatus=function(t){var e=this,n=this.options.horizontal,i=this.containerManager,r=i.getInlineSize(),o=this.getChildren();return this.itemRenderer.setStatus(t.itemRenderer),i.setStatus(t.containerManager),this.outlines=t.outlines,this.items=t.items.map(function(t,e){return new ot(n,f(f({},t),{element:o[e]}))}),this.itemRenderer.renderItems(this.items),r!==i.getInlineSize()?this.renderItems({useResize:!0}):window.setTimeout(function(){e._renderComplete({direction:e.defaultDirection,mounted:e.items,updated:[],isResize:!1})}),this},e.destroy=function(t){var t=(t=void 0===t?{}:t).preserveUI,t=void 0===t?this.options.preserveUIOnDestroy:t;this.containerManager.destroy({preserveUI:t}),t||this.items.forEach(function(t){var e=t.element,t=t.orgCSSText;e&&(e.style.cssText=t)}),null!==(t=this._im)&&void 0!==t&&t.destroy()},e.checkReady=function(n){var t,i=this;void 0===n&&(n={});var r=this.items,o=r.filter(function(t){var e;return(null===(e=t.element)||void 0===e?void 0:e.parentNode)&&t.updateState!==d.UPDATED}),e=o.filter(function(t){return t.mountState!==c.MOUNTED}),s=[];e.filter(function(t){if(t.hasTransition)return!0;var e=t.element;return 0<parseFloat(getComputedStyle(e).transitionDuration)&&(t.hasTransition=!0,t.transitionDuration=e.style.transitionDuration,!0)}).forEach(function(t){t.element.style.transitionDuration="0s"}),null!==(t=this._im)&&void 0!==t&&t.destroy(),this._im=new W({prefix:this.options.attributePrefix}).on("preReadyElement",function(t){o[t.index].updateState=d.WAIT_LOADING}).on("preReady",function(){i.itemRenderer.updateItems(o),i.readyItems(e,o,n)}).on("readyElement",function(t){var e=o[t.index];e.updateState=d.NEED_UPDATE,t.isPreReadyOver&&(e.element.style.cssText=e.orgCSSText,i.itemRenderer.updateItems([e]),i.readyItems([],[e],n))}).on("error",function(t){var e=r[t.index];i.trigger("contentError",{element:t.element,target:t.target,item:e,update:function(){s.push(e)}})}).on("ready",function(){s.length&&i.updateItems(s)}).check(o.map(function(t){return t.element}))},e.scheduleRender=function(){var t=this;this._clearRenderTimer(),this._renderTimer=window.setTimeout(function(){t.renderItems()})},e.fitOutlines=function(t){void 0===t&&(t=this.useFit);var e=this.outlines,n=e.start,i=e.end,r=n.length?Math.min.apply(Math,n):0;!t&&0<r||(e.start=n.map(function(t){return t-r}),e.end=i.map(function(t){return t-r}),this.items.forEach(function(t){var e=t.cssContentPos;"number"==typeof e&&(t.cssContentPos=e-r)}))},e.readyItems=function(t,e,n){var i=this.outlines,r=n.direction||this.options.defaultDirection,o=n.outline||i["end"===r?"start":"end"],s=this.items,i={start:g(o),end:g(o)};e.forEach(function(t){t.isUpdate=!0}),s.length&&(i=this.applyGrid(this.items,r,o)),e.forEach(function(t){t.isUpdate=!1}),this.setOutlines(i),this.fitOutlines(),this.itemRenderer.renderItems(this.items),this._refreshContainerContentSize();i=t.filter(function(t){return t.hasTransition});i.length&&(this.containerManager.resize(),i.forEach(function(t){t.element.style.transitionDuration=t.transitionDuration})),this._renderComplete({direction:r,mounted:t,updated:e,isResize:!!n.useResize})},e._renderComplete=function(t){this.trigger("renderComplete",t)},e._clearRenderTimer=function(){clearTimeout(this._renderTimer),this._renderTimer=0},e._refreshContainerContentSize=function(){var t=this.outlines,e=t.start,n=t.end,t=this.options.gap,n=n.length?Math.max.apply(Math,n):0,e=e.length?Math.max.apply(Math,e):0,t=Math.max(e,n-t);this.containerManager.setContentSize(t)},e._resizeContainer=function(){this.containerManager.resize(),this.itemRenderer.setContainerRect(this.containerManager.getRect())},e._init=function(){this._resizeContainer()},t.defaultOptions=p,t.propertyTypes=n,o([V],t)}(t);function at(t,e,n,i){return Math[i].apply(Math,t.slice(e,e+n))}P=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._columnSize=0,t._column=1,t}r(t,e);var n=t.prototype;return n.applyGrid=function(v,t,e){this._calculateColumnSize(v),this._calculateColumn(v);for(var n,y=this._column,R=this._columnSize,i=this.options,S=i.gap,r=i.align,z=i.columnSizeRatio,E=i.columnSize,i=e.length,_=v.length,P=this._getAlignPoses(),C="end"===t,T=C?"min":"max",O=C?"max":"min",t=[0],b=(t=i===y?e.slice():(n=i?Math[O].apply(Math,e):0,B(y).map(function(){return n}))).slice(),w=1<y?P[1]-P[0]:0,I="stretch"===r,o=function(t){for(var e,n,i,r,o=v[C?t:_-1-t],s=parseInt(o.attributes.column||"1",10),a=parseInt(o.attributes.maxColumn||"1",10),u=o.inlineSize,c=o.contentSize,h=Math.min(y,s||Math.max(1,Math.ceil((u+S)/w))),l=Math.min(y,Math.max(h,a)),f=(n=h,i=T,t=(e=b).length-n+1,r="max"===i?"min":"max",a="max"===i?"lastIndexOf":"indexOf",(t=B(t).map(function(t){return at(e,t,n,r)}))[a](Math[i].apply(Math,t))),d=at(b,f,h,O);h<l;){var p=f+h,g=f-1;if(C&&(y<=p||b[p]>d))break;if(!C&&(g<0||b[g])<d)break;C||--f,++h}f=Math.max(0,f),h=Math.min(y-f,h),0<s&&(1<h||I||E)&&(o.cssInlineSize=u=(h-1)*w+R),0<z&&(o.cssContentSize=c=u/z);u=P[f],d=C?d:d-S-c;o.cssInlinePos=u,o.cssContentPos=d;var m=C?d+c+S:d;B(h).forEach(function(t){b[f+t]=m})},s=0;s<_;++s)o(s);return{start:C?t:b,end:C?b:t}},n._calculateColumnSize=function(t){var e=this.options,n=e.columnSize,i=e.gap;if("stretch"===e.align){e=this.column;n&&(e=Math.max(1,Math.floor((this.getContainerInlineSize()+i)/(n+i)))),this._columnSize=(this.getContainerInlineSize()+i)/(e||1)-i}else if(n)this._columnSize=n;else if(t.length){for(var r=t[0],o=0,s=t;o<s.length;o++){var a=s[o],u=a.attributes;if(a.updateState===d.UPDATED&&a.inlineSize&&!u.column&&!u.maxColumnCount){r=a;break}}t=r.inlineSize||0;return this._columnSize=t}return this._columnSize=this._columnSize||0,this._columnSize},n._calculateColumn=function(t){var e=this.options,n=e.gap,i=e.column,r=this._columnSize,e=1,e=i||(r?Math.min(t.length,Math.max(1,Math.floor((this.getContainerInlineSize()+n)/(r+n)))):1);return this._column=e},n._getAlignPoses=function(){var t=this._columnSize,e=this._column,n=this.options,i=n.align,r=n.gap,o=this.getContainerInlineSize(),s=B(e),a=0,u=0;return"justify"===i||"stretch"===i?(u=(n=e-1)?Math.max((o-t)/n,t+r):0,a=Math.min(0,o/2-(n*u+t)/2)):(t=(e-1)*(u=t+r)+t,"center"===i?a=(o-t)/2:"end"===i&&(a=o-t)),s.map(function(t){return a+t*u})},t.propertyTypes=f(f({},st.propertyTypes),{column:a.RENDER_PROPERTY,columnSize:a.RENDER_PROPERTY,columnSizeRatio:a.RENDER_PROPERTY,align:a.RENDER_PROPERTY}),t.defaultOptions=f(f({},st.defaultOptions),{align:"justify",column:0,columnSize:0,columnSizeRatio:0}),o([V],t)}(st);function ut(t,e,n){return function(t,e){for(var n=[],i=e;i;)n.push(i),i=t[i];return n.reverse(),n}(function(t,e,n){var i={},r={};r[e]=0;var o,s,a,u,c,h,l=new ct(function(t){return t.cost});for(l.push({value:e,cost:0});l.size();)for(var f in s=(o=l.pop()).value,a=o.cost,u=t(s)||{})c=a+u[f],h=r[f],(void 0===r[f]||c<h)&&(r[f]=c,l.push({value:f,cost:c}),i[f]=s);if(void 0!==r[n])return i;throw n=["Could not find a path from ",e," to ",n,"."].join(""),new Error(n)}(t,e,n),n)}var ct=function(){function t(t){this.content=[],this.scoreFunction=t}var e=t.prototype;return e.push=function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},e.pop=function(){var t=this.content[0],e=this.content.pop();return 0<this.content.length&&(this.content[0]=e,this.sinkDown(0)),t},e.size=function(){return this.content.length},e.bubbleUp=function(t){for(var e=t,n=this.content[e];0<e;){var i=Math.floor((e+1)/2)-1,r=this.content[i];if(!(this.scoreFunction(n)<this.scoreFunction(r)))break;this.content[i]=n,this.content[e]=r,e=i}},e.sinkDown=function(t){for(var e=this.content.length,n=this.content[t],i=this.scoreFunction(n);;){var r,o=2*(t+1),s=o-1,a=null;if(s<e&&(r=this.content[s],(r=this.scoreFunction(r))<i&&(a=s)),o<e&&(s=this.content[o],this.scoreFunction(s)<(null==a?i:r)&&(a=o)),null===a)break;this.content[t]=this.content[a],this.content[a]=n,t=a}},t}();function ht(t,e){var n=t.orgInlineSize,i=t.orgContentSize;if(!n||!i)return 0;var r=parseFloat(t.gridData.inlineOffset)||0,t=parseFloat(t.gridData.contentOffset)||0;return(n-r)/(i-t)*(e-t)+r}_=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.applyGrid=function(t,e,n){var i=this.options,s=i.attributePrefix,a=i.horizontal;t.forEach(function(t){var e,n,i,r,o;t.isUpdate&&(e=t.element,r=t.attributes,n=t.gridData,i=parseFloat(r.inlineOffset)||n.inlineOffset||0,o=parseFloat(r.contentOffset)||0|n.contentOffset,!e||"inlineOffset"in r||"contentOffset"in r||t.mountState!==c.MOUNTED||(r=e.querySelector("["+s+"maintained-target]"))&&(t=e.offsetWidth-e.clientWidth+e.scrollWidth-r.clientWidth,r=e.offsetHeight-e.clientHeight+e.scrollHeight-r.clientHeight,o=a?(i=r,t):(i=t,r)),n.inlineOffset=i,n.contentOffset=o)});var r=this.options.rowRange,i=[];return t.length&&(i=r?this._getRowPath(t):this._getPath(t)),this._setStyle(t,i,n,"end"===e)},n._getRowPath=function(t){var e=this._getColumnRange(),n=this._getRowRange(),n=this._getRowLink(t,{path:[0],cost:0,length:0,currentNode:0},e,n);return null!==(n=null==n?void 0:n.path.map(function(t){return""+t}))&&void 0!==n?n:[]},n._getRowLink=function(t,e,n,i){var r=n[0],o=i[0],s=i[1],a=t.length,u=e.path,c=e.length,h=e.cost,l=e.currentNode;if(l<a&&(s<=c||a<l+r)){r=X(a-l,n)*Math.abs(this._getCost(t,l,a));return f(f({},e),{length:c+1,path:g(u,[a]),currentNode:a,cost:h+r,isOver:!0})}return a<=l?f(f({},e),{currentNode:a,isOver:c<o||s<c}):this._searchRowLink(t,e,a,n,i)},n._searchRowLink=function(t,e,n,i,r){for(var o,s=i[0],a=i[1],u=e.currentNode,c=e.path,h=e.length,l=e.cost,f=Math.min(n,u+a),d=[],p=u+s;p<=f;++p)p!==u&&(o=Math.abs(this._getCost(t,u,p)),(o=this._getRowLink(t,{path:g(c,[p]),length:h+1,cost:l+o,currentNode:p},i,r))&&d.push(o));return d.sort(function(t,e){var n=t.isOver;return n!==e.isOver?n?1:-1:X(t.length,r)-X(e.length,r)||t.cost-e.cost}),d[0]},n._getExpectedRowSize=function(t){var e=this.options.gap,r=this.getContainerInlineSize()-e*(t.length-1),o=0,s=0;return t.forEach(function(t){var e,n=t.orgInlineSize,i=t.orgContentSize;n&&i&&(e=parseFloat(t.gridData.inlineOffset)||0,t=parseFloat(t.gridData.contentOffset)||0,o+=i=(n-e)/(i-t),s+=t*i,r-=e)}),o?(r+s)/o:0},n._getExpectedInlineSize=function(t,n){var e=this.options.gap,i=t.reduce(function(t,e){return t+ht(e,n)},0);return i?i+e*(t.length-1):0},n._getCost=function(t,e,n){var i=t.slice(e,n),t=this._getExpectedRowSize(i),e=this._getSizeRange(),n=e[0],e=e[1];if(this.isCroppedSize){if(n<=t&&t<=e)return 0;i=this._getExpectedInlineSize(i,t<n?n:e);return Math.pow(i-this.getContainerInlineSize(),2)}if(isFinite(e)){if(t<n)return Math.pow(t-n,2)+Math.pow(e,2);if(e<t)return Math.pow(t-e,2)+Math.pow(e,2)}else if(t<n)return Math.max(Math.pow(n,2),Math.pow(t,2))+Math.pow(e,2);return t-n},n._getPath=function(o){var s=this,a=o.length,t=this.options.columnRange,t=q(t)?t:[t,t],u=t[0],c=t[1];return ut(function(t){for(var e={},n=parseInt(t,10),i=Math.min(n+u,a);i<=a&&!(c<i-n);++i){var r=s._getCost(o,n,i);r<0&&i===a&&(r=0),e[""+i]=Math.pow(r,2)}return e},"0",""+a)},n._setStyle=function(t,e,n,i){var s=this;void 0===n&&(n=[]);var r=this.options,a=r.gap,u=r.isCroppedSize,c=r.displayedRow,h=this._getSizeRange(),n=n[0]||0,l=this.getContainerInlineSize(),e=function(t,e){for(var n=e.length,i=[],r=0;r<n-1;++r){var o=parseInt(e[r],10),s=parseInt(e[r+1],10);i.push(t.slice(o,s))}return i}(t,e),f=n,d=0;if(e.forEach(function(i,t){var e=i.length,r=s._getExpectedRowSize(i);u&&(r=Math.max(h[0],Math.min(r,h[1])));var n=s._getExpectedInlineSize(i,r),e=a*(e-1),o=(l-e)/(n-e);i.forEach(function(t,e){var n=ht(t,r),e=i[e-1],e=e?e.cssInlinePos+e.cssInlineSize+a:0;u&&(n*=o),t.setCSSGridRect({inlinePos:e,contentPos:f,inlineSize:n,contentSize:r})}),f+=a+r,(c<0||t<c)&&(d=f)}),i)return{start:[n],end:[d]};var o=f-n;return t.forEach(function(t){t.cssContentPos-=o}),{start:[n-o],end:[n]}},n._getRowRange=function(){var t=this.rowRange;return q(t)?t:[t,t]},n._getColumnRange=function(){var t=this.columnRange;return q(t)?t:[t,t]},n._getSizeRange=function(){var t=this.sizeRange;return q(t)?t:[t,t]},e.propertyTypes=f(f({},st.propertyTypes),{columnRange:a.RENDER_PROPERTY,rowRange:a.RENDER_PROPERTY,sizeRange:a.RENDER_PROPERTY,isCroppedSize:a.RENDER_PROPERTY,displayedRow:a.RENDER_PROPERTY}),e.defaultOptions=f(f({},st.defaultOptions),{columnRange:[1,8],rowRange:0,sizeRange:[0,1/0],displayedRow:-1,isCroppedSize:!1}),o([V],e)}(st);function lt(t){var e=-1/0;return t.forEach(function(t){isFinite(t)&&(e=Math.max(e,t))}),isFinite(e)?e:0}function ft(t,e,n){return lt(t)+function(t,e,n){var i=t.length;if(!i)return 0;var r=function(t){var e=1/0;return t.forEach(function(t){isFinite(t)&&(e=Math.min(e,t))}),isFinite(e)?e:0}(e),o=lt(t),s=0;if(!n)return 0;for(var a=0;a<i;++a){var u=t[a],c=e[a];isFinite(u)&&isFinite(c)&&(u=u-o,c=c-r,s=a?Math.max(s,s+u-c):u-c)}return s}(t,e,n)}function dt(t,e,n){for(var i=n.inlinePos,r=n.inlineSize,o=n.contentPos,s=n.contentSize,a=i;a<i+r;++a)t[a]=Math.min(t[a],o),e[a]=Math.max(e[a],o+s)}var t=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.applyGrid=function(t,e,n){var i=this._getFrame(),r=i.inlineSize,o=i.contentSize,s=i.rects,a=this.options,u=a.gap,c=a.useFrameFill,a=this.getRectSize(r),h=a.inlineSize,l=a.contentSize,f=t.length;if(!f||!r||!o)return{start:n,end:n};for(var d=s.length,p=B(r).map(function(){return 1/0}),g=B(r).map(function(){return-1/0}),m=i.outline.map(function(t){return t*(l+u)}),v=0;v<f;v+=d)for(var y=ft(g,m,c),R=0;R<d&&v+R<f;++R){var S=t[v+R],z=s[R],E=z.contentPos,_=z.inlinePos,P=z.contentSize,C=z.inlineSize,T=y+E*(l+u),z=_*(h+u),E=P*(l+u)-u,P=C*(h+u)-u;dt(p,g,{inlinePos:_,inlineSize:C,contentPos:T,contentSize:E+u}),S.setCSSGridRect({inlinePos:z,contentPos:T,inlineSize:P,contentSize:E})}var O,e="end"===e,n=n.length?n:[0];n.length!==r&&(O=(e?Math.max:Math.min).apply(Math,n),n=B(r).map(function(){return O}));var p=p.map(function(t){return isFinite(t)?t:0}),g=g.map(function(t){return isFinite(t)?t:0}),b=e?ft(n,p,c):ft(g,n,c);return t.forEach(function(t){t.cssContentPos+=b}),{start:p.map(function(t){return t+b}),end:g.map(function(t){return t+b})}},n.getRectSize=function(t){var e=this.options,n=e.gap,e=e.rectSize;if("object"==typeof e)return e;n=e||(this.getContainerInlineSize()+n)/t-n;return{inlineSize:n,contentSize:n}},n._getFrame=function(){for(var t=this.options.frame,e=t.length,n=e?t[0].length:0,i=[],r={},o=B(n).map(function(){return 1/0}),s=B(n).map(function(){return-1/0}),a=0;a<e;++a)for(var u=0;u<n;++u){var c=t[a][u];c&&(r[a+","+u]||(dt(o,s,c=this._findRect(r,c,a,u,n,e)),i.push(c)))}return i.sort(function(t,e){return t.type<e.type?-1:1}),{rects:i,inlineSize:n,contentSize:e,outline:o}},n._findRect=function(t,e,n,i,r,o){for(var s=this.options.frame,a=1,u=1,c=i;c<r&&s[n][c]===e;++c)u=c-i+1;for(var h=n;h<o&&s[h][i]===e;++h)a=h-n+1;for(var l=n;l<n+a;++l)for(var f=i;f<i+u;++f)t[l+","+f]=!0;return{type:e,inlinePos:i,contentPos:n,inlineSize:u,contentSize:a}},e.propertyTypes=f(f({},st.propertyTypes),{frame:a.RENDER_PROPERTY,useFrameFill:a.RENDER_PROPERTY,rectSize:a.RENDER_PROPERTY}),e.defaultOptions=f(f({},st.defaultOptions),{frame:[],rectSize:0,useFrameFill:!0}),o([V],e)}(st),pt=function(){function t(t){var e,n=f({orgInlineSize:0,orgContentSize:0,inlineSize:0,contentSize:0,inlinePos:0,contentPos:0,items:[]},t);for(e in n)this[e]=n[e]}var e=t.prototype;return e.scaleTo=function(t,e){var n=this.inlineSize?t/this.inlineSize:0,i=this.contentSize?e/this.contentSize:0;this.items.forEach(function(t){0!=n&&(t.inlinePos*=n,t.inlineSize*=n),0!=i&&(t.contentPos*=i,t.contentSize*=i)}),this.inlineSize=t,this.contentSize=e},e.push=function(t){this.items.push(t)},e.getOrgSizeWeight=function(){return this.orgInlineSize*this.orgContentSize},e.getSize=function(){return this.inlineSize*this.contentSize},e.getOrgRatio=function(){return 0===this.orgContentSize?0:this.orgInlineSize/this.orgContentSize},e.getRatio=function(){return 0===this.contentSize?0:this.inlineSize/this.contentSize},t}();function gt(t,e){e=t/e;return(e=e<1?1/e:e)-1}var mt,vt={__proto__:null,default:st,GetterSetter:V,withGridMethods:R,withMethods:K,MasonryGrid:P,JustifiedGrid:_,FrameGrid:t,PackingGrid:function(t){function e(){return null!==t&&t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.applyGrid=function(t,e,n){var i=this,r=this.options,o=r.aspectRatio,s=r.gap,a=this.getContainerInlineSize(),u=a/o,n=n.length?n:[0],c="end"===e?Math.max.apply(Math,n):Math.min.apply(Math,n)-u-s,n=c+u+s,h=new pt({});return t.forEach(function(t){t=new pt({inlineSize:t.orgInlineSize,contentSize:t.orgContentSize,orgInlineSize:t.orgInlineSize,orgContentSize:t.orgContentSize});i._findBestFitArea(h,t),h.push(t),h.scaleTo(a+s,u+s)}),t.forEach(function(t,e){var n=h.items[e],i=n.inlineSize-s,r=n.contentSize-s,e=c+n.contentPos,n=n.inlinePos;t.setCSSGridRect({inlinePos:n,contentPos:e,inlineSize:i,contentSize:r})}),{start:[c],end:[n]}},n._findBestFitArea=function(t,p){if(0===t.getRatio())return t.orgInlineSize=p.inlineSize,t.orgContentSize=p.contentSize,t.inlineSize=p.inlineSize,void(t.contentSize=p.contentSize);var g,e,n,i,r,m=1/0,v=!1,y={inlineSize:0,contentSize:0},R={inlineSize:0,contentSize:0},S=this._getWeight("size"),z=this._getWeight("ratio");t.items.forEach(function(t){for(var e=gt(t.getOrgSizeWeight(),t.getSize())*S,n=gt(t.getOrgRatio(),t.getRatio())*z,i=t.inlineSize,r=t.contentSize,o=0;o<2;++o){var s=void 0,a=void 0,u=void 0,c=void 0;0===o?(u=s=i,c=r-(a=r*(p.contentSize/(t.orgContentSize+p.contentSize)))):(c=a=r,u=i-(s=i*(p.inlineSize/(t.orgInlineSize+p.inlineSize))));var h=s*a,l=s/a,f=u*c,d=c/c,h=gt(p.getSize(),h)*S;h+=gt(p.getRatio(),l)*z,h+=gt(t.getOrgSizeWeight(),f)*S-e,(h+=gt(t.getOrgRatio(),d)*z-n)===Math.min(h,m)&&(m=h,g=t,v=0===o,y.inlineSize=s,y.contentSize=a,R.inlineSize=u,R.contentSize=c)}}),e=g,n=y,i=R,r=v,(t=p).contentSize=n.contentSize,t.inlineSize=n.inlineSize,e.contentSize=i.contentSize,e.inlineSize=i.inlineSize,r?(t.contentPos=e.contentPos+e.contentSize,t.inlinePos=e.inlinePos):(t.inlinePos=e.inlinePos+e.inlineSize,t.contentPos=e.contentPos)},n._getWeight=function(t){var e=this.options,n=e.weightPriority;return n===t?100:"custom"===n?e[t+"Weight"]:1},e.propertyTypes=f(f({},st.propertyTypes),{aspectRatio:a.RENDER_PROPERTY,sizeWeight:a.RENDER_PROPERTY,ratioWeight:a.RENDER_PROPERTY,weightPriority:a.RENDER_PROPERTY}),e.defaultOptions=f(f({},st.defaultOptions),{aspectRatio:1,sizeWeight:1,ratioWeight:1,weightPriority:"custom"}),o([V],e)}(st),ItemRenderer:J,GridItem:ot,ContainerManager:v,DEFAULT_GRID_OPTIONS:p,get PROPERTY_TYPE(){return a},get MOUNT_STATE(){return c},get UPDATE_STATE(){return d},GRID_PROPERTY_TYPES:n,GRID_METHODS:e,GRID_EVENTS:["renderComplete","contentError"],RECT_NAMES:m};for(mt in vt)st[mt]=vt[mt];return st});
10//# sourceMappingURL=grid.min.js.map