!function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r3?(i=v===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=m&&((i=r<2&&mn||n>v)&&(o[4]=r,o[5]=n,f.n=v,s=0))}if(i||r>1)return a;throw c=!0,n}return function(i,l,v){if(h>1)throw TypeError("Generator is already running");for(c&&1===l&&m(l,v),s=l,u=v;(e=s<2?t:u)||!c;){o||(s?s<3?(s>1&&(f.n=-1),m(s,u)):f.n=u:f.v=u);try{if(h=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,s<2&&(s=0)}else 1===s&&(e=o["return"])&&e.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(c=f.n<0)?u:r.call(n,f))!==a)break}catch(e){o=t,s=1,u=e}finally{h=1}}return{value:e,done:c}}}(r,o,s),!0),l}var a={};function h(){}function l(){}function c(){}e=Object.getPrototypeOf;var f=[][o]?e(e([][o]())):(i(e={},o,function(){return this}),e),m=c.prototype=h.prototype=Object.create(f);function v(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,i(t,s,"GeneratorFunction")),t.prototype=Object.create(m),t}return l.prototype=c,i(m,"constructor",c),i(c,"constructor",l),l.displayName="GeneratorFunction",i(c,s,"GeneratorFunction"),i(m),i(m,s,"Generator"),i(m,o,function(){return this}),i(m,"toString",function(){return"[object Generator]"}),(n=function(){return{w:u,m:v}})()}function i(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}i=function(t,e,r,n){function s(e,r){i(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(s("next",0),s("throw",1),s("return",2))},i(t,e,r,n)}function o(t,e,r,n,i,o,s){try{var u=t[o](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,i)}function s(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function u(t){o(s,n,i,u,a,"next",t)}function a(t){o(s,n,i,u,a,"throw",t)}u(void 0)})}}function u(t,e){for(var r=0;r0&&arguments[0]!==undefined?arguments[0]:{};if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,h),this.options={container:null,itemSelector:null,baseWidth:255,column:null,responsive:null,gutter:10,gutterX:null,gutterY:null,ultimateGutter:5,surroundingGutter:!0,minify:!0,direction:"ltr",wedge:!1,waitForImages:!0,observeMutations:!1},this.option(e),this.container=this._resolveContainer(this.options.container),!this.container)throw new Error("EkitMasonry: container not found");this.items=[],this._width=0,this._count=0,this._columns=[],this._sizes=[],this._currentGutterX=this.options.gutterX,this._currentGutterY=this.options.gutterY,this._resizeObserver=null,this._mutationObserver=null,this._lastObservedWidth=null,this._imageListeners=[],this.reloadItems(),this._createObservers(),this.options.waitForImages?this._waitForImages().then(function(){return t.layout()}):this.layout()},r=[{key:"layout",value:function(){if(this.container)if(this._reset(),this.items.length){this._count||(this._count=this._getCount());var t,e=this._computeWidth();this._columns=new Array(this._count).fill(0),this._sizes=[];for(var r=0;rthis.items.length){var n=this.items.length*(e+this._currentGutterX)-this._currentGutterX;this.options.wedge?"ltr"!==this.options.direction&&(t=this._width-(this.options.surroundingGutter?this._currentGutterX:0)):t="ltr"===this.options.direction?(this._width-n)/2:this._width-(this._width-n)/2}for(var i=0;i1?this._currentGutterY:this.options.ultimateGutter;this._columns[s]+=this._sizes[i]+l}var c=this._getLongestColumn();this.container.style.height="".concat(this._columns[c]-this._currentGutterY,"px")}else this.container.style.height="0px"}},{key:"reloadItems",value:function(){return this.items=this.options.itemSelector?Array.from(this.container.querySelectorAll(this.options.itemSelector)):Array.from(this.container.children),this.items}},{key:"appended",value:(a=s(n().m(function l(t){var e;return n().w(function(r){for(;;)switch(r.n){case 0:if(e=this._normalizeElements(t),!this.options.waitForImages){r.n=1;break}return r.n=1,this._waitForImages(e);case 1:this.reloadItems(),this.layout();case 2:return r.a(2)}},l,this)})),function(t){return a.apply(this,arguments)})},{key:"prepended",value:(o=s(n().m(function c(t){var e;return n().w(function(r){for(;;)switch(r.n){case 0:if(e=this._normalizeElements(t),!this.options.waitForImages){r.n=1;break}return r.n=1,this._waitForImages(e);case 1:this.reloadItems(),this.layout();case 2:return r.a(2)}},c,this)})),function(t){return o.apply(this,arguments)})},{key:"remove",value:function(t){this._normalizeElements(t).forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)}),this.reloadItems(),this.layout()}},{key:"option",value:function(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return Object.assign(this.options,t),null==this.options.gutterX&&(this.options.gutterX=this.options.gutter),null==this.options.gutterY&&(this.options.gutterY=this.options.gutter),this._currentGutterX=this.options.gutterX,this._currentGutterY=this.options.gutterY,this}},{key:"getItemElements",value:function(){return e(this.items)}},{key:"destroy",value:function(){this._resizeObserver&&this._resizeObserver.disconnect(),this._mutationObserver&&this._mutationObserver.disconnect(),this._imageListeners.forEach(function(t){return t()}),this._imageListeners=[],this.items.forEach(function(t){t.style.removeProperty("width"),t.style.removeProperty("transform")}),this.container.style.removeProperty("height"),this.container.style.removeProperty("min-width"),this.items=[],this._columns=[],this._sizes=[]}},{key:"_resolveContainer",value:function(t){return t?t instanceof HTMLElement?t:document.querySelector(t):null}},{key:"_reset",value:function(){this._sizes=[],this._columns=[],this._count=0;var t=this.container.clientWidth,e=tthis._columns[t]&&(t=e);return t}},{key:"_createObservers",value:function(){var t=this;"undefined"!=typeof ResizeObserver&&(this._lastObservedWidth=this.container.clientWidth,this._resizeObserver=new ResizeObserver(function(){var e=t.container.clientWidth;e!==t._lastObservedWidth&&(t._lastObservedWidth=e,t.layout())}),this._resizeObserver.observe(this.container)),this.options.observeMutations&&"undefined"!=typeof MutationObserver&&(this._mutationObserver=new MutationObserver(function(){t.reloadItems(),t.layout()}),this._mutationObserver.observe(this.container,{childList:!0,subtree:!1}))}},{key:"_waitForImages",value:function(){var t=(arguments.length>0&&arguments[0]!==undefined?arguments[0]:null)||this.items,r=[];return t.forEach(function(t){"IMG"===t.tagName&&r.push(t),r.push.apply(r,e(t.querySelectorAll("img")))}),r.length?Promise.all(r.map(function(t){return t.complete?Promise.resolve():new Promise(function(e){var r=function(){t.removeEventListener("load",r),t.removeEventListener("error",r),e()};t.addEventListener("load",r),t.addEventListener("error",r)})})):Promise.resolve()}},{key:"_normalizeElements",value:function(t){return t?t instanceof Element?[t]:Array.from(t):[]}}],r&&u(t.prototype,r),i&&u(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,i,o,a}();window.EkitMasonry=h}();