%PDF- %PDF-
Direktori : /proc/1857783/root/var/www/cwg/wp-content/plugins/wp-grid-builder/frontend/assets/js/ |
Current File : //proc/1857783/root/var/www/cwg/wp-content/plugins/wp-grid-builder/frontend/assets/js/layout.js |
/*! * WP Grid Builder Plugin * * @package WP Grid Builder * @author Loïc Blascos * @link https://www.wpgridbuilder.com * @copyright 2019-2021 Loïc Blascos * */ !function(){var t={281:function(){function t(){var t=elementorFrontend,e=t.elements&&t.elements.$document,i=t.utils&&t.utils.lightbox,n=wpgb_settings&&wpgb_settings.lightbox.plugin;if(e&&i&&n){var s=!1,r=i.showModal;r&&(e.on("click",".wpgb-handle-lb",(function(){return s=!0})),i.showModal=function(){!s&&r.apply(void 0,arguments),s=!1})}}window.elementorFrontend&&elementorFrontend.utils&&elementorFrontend.utils.lightbox&&t(),window.jQuery&&jQuery(window).on("elementor/frontend/init",(function(){return elementorFrontend.on("components:init",t)}))},150:function(){"undefined"!=typeof jQuery&&jQuery(document.body).on("wc_cart_button_updated",(function(t,e){var i=e.next();if(e.is('[class*="wpgb-block-"]')&&i.is('[class*="added_to_cart wc-forward"]')){var n=jQuery.grep(e[0].className.split(" "),(function(t){return 0===t.indexOf("wpgb-")})).join(" ");i[0].className=n+" "+i[0].className}}))}},e={};function i(n){var s=e[n];if(void 0!==s)return s.exports;var r=e[n]={exports:{}};return t[n](r,r.exports,i),r.exports}i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,{a:e}),e},i.d=function(t,e){for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},function(){"use strict";var t=function(t){if("complete"===document.readyState||"interactive"===document.readyState)return t();document.addEventListener("DOMContentLoaded",t)};function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function s(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}function r(t,e){return(r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t,e){return!e||"object"!==h(e)&&"function"!=typeof e?l(t):e}function c(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=a(t);if(e){var s=a(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return u(this,i)}}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function v(t){return function(t){if(Array.isArray(t))return d(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 d(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?d(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.")}()}var p,f,g,y,m,w=function(){function t(){e(this,t),this.listeners=new Map}return s(t,[{key:"canListen",value:function(t,e){return!("function"!=typeof e||!t)||(!("object"!==h(e)||!e[t])||(console.error('Invalid listener for event name: "'.concat(t,'"')),!1))}},{key:"exists",value:function(t,e){if(this.listeners.has(t))return this.listeners.get(t).find((function(t){return t.listener===e}))}},{key:"on",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.canListen(t,e)?(this.listeners.has(t)||this.listeners.set(t,[]),this.exists(t,e)||this.listeners.get(t).push({listener:e,once:i}),this):this}},{key:"once",value:function(t,e){return this.on(t,e,!0)}},{key:"off",value:function(t,e){var i=this.listeners.get(t)||[],n=i.findIndex((function(t){return t.listener===e}));return n>-1&&i.splice(n,1),i.length<1&&this.listeners.delete(t),this}},{key:"offAll",value:function(){return this.listeners.clear(),this}},{key:"emit",value:function(t){for(var e=this,i=arguments.length,n=new Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];var r=this.listeners.get(t)||[];return v(r).forEach((function(i){var s,r;(i.once&&e.off(t,i.listener),"object"===h(i.listener))?(s=i.listener[t]).apply.apply(s,[i.listener].concat(n)):(r=i.listener).apply.apply(r,[e].concat(n))})),this}}]),t}(),b=function(t){o(n,t);var i=c(n);function n(){var t;return e(this,n),(t=i.call(this)).vendors={},t.instances={},t}return s(n,[{key:"get",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=this.instances,i=[];if(!Object.keys(e).length)return[];for(var n in e)(e[n].id||"").toString()===t.toString()&&i.push(e[n]);return i}},{key:"instance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return Object.keys(this.instances).length&&this.instances[t]?this.instances[t]:{}}}]),n}(w),k=Math.sign&&Array.from&&Array.prototype.fill&&Array.prototype.find&&Array.prototype.findIndex&&Array.prototype.includes&&Element.prototype.matches&&Element.prototype.closest&&NodeList.prototype.forEach&&window.Map&&window.URLSearchParams;function x(){!function(){var t=I();if(!t)return;t.getGalleries()}(),y&&window.easy_fancybox_handler&&window.easy_fancybox_auto&&(jQuery(easy_fancybox_handler),jQuery(easy_fancybox_auto)),m&&"undefined"!=typeof FOOBOX&&"function"==typeof FOOBOX.init&&FOOBOX.init()}function S(){f=window.wpgb_settings&&window.wpgb_settings.lightbox&&window.wpgb_settings.lightbox.plugin?wpgb_settings.lightbox.plugin:"",g=["modulobox","modulobox_lite"].includes(f),y="easy_fancybox"===f,m="foobox"===f,g&&"ModuloBox"in window&&(ModuloBox.prototype.openFromQuery=function(){})}function I(){if(g&&"ModuloBox"in window)return p||((p=new ModuloBox).init(),p)}window.WP_Grid_Builder||(window.WP_Grid_Builder=k?new b:{get:function(){return[]},instance:function(){return[]},instances:function(){return[]},instantiate:function(){return[]},on:function(){return null},off:function(){return null},once:function(){return null},offAll:function(){return null},emit:function(){return null},vendors:{},unsupported:!0}),WP_Grid_Builder.unsupported||(S(),t((function(){S();var t=I();t&&(t.options.history=!1),!y&&window.easy_fancybox_handler&&window.easy_fancybox_auto&&jQuery("a.wpgb-handle-lb").off("click")})));i(281);var E=i(150);i.n(E)();function A(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function L(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function P(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?L(Object(i),!0).forEach((function(e){A(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):L(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}Math.max,Math.min;function _(t,e,i){var n,s,r,o,a,l=!1,u=!1,c=!0;if("function"!=typeof t)throw new TypeError(FUNC_ERROR_TEXT);function d(e){var i=n,o=s;return n=s=void 0,e,r=t.apply(o,i)}function v(t){return t,o=setTimeout(f,e),l?d(t):r}function p(t){var i=t-a;return void 0===a||i>=e||i<0||u}function f(){var t=Date.now();if(p(t))return g(t);o=setTimeout(f,function(t){return e-(t-a)}(t))}function g(t){return o=void 0,c&&n?d(t):(n=s=void 0,r)}function y(){var t=Date.now(),i=p(t);if(n=arguments,s=this,a=t,i){if(void 0===o)return v(a);u}return void 0===o&&(o=setTimeout(f,e)),r}return e=Number(e)||0,"object"===h(i)&&(l=!!i.leading,c="trailing"in i?!!i.trailing:c),y.cancel=function(){void 0!==o&&clearTimeout(o),0,n=a=s=o=void 0},y}var M=function(t){o(n,t);var i=c(n);function n(t,s){var r;return e(this,n),(r=i.call(this)).element=t,r.options=s,r.wrapper=t.querySelector(".wpgb-wrapper"),r.viewport=t.querySelector(".wpgb-viewport"),r}return s(n,[{key:"init",value:function(){var t=this.getItems();if(!this.items.length)return!1;this.layout(),this.bindEvents(),this.emit("init",[t])}},{key:"destroy",value:function(){this.bindEvents(!1),this.wrapper.removeAttribute("style"),this.viewport.removeAttribute("style"),this.items.forEach((function(t){return t.node.removeAttribute("style")})),this.items=[]}},{key:"layout",value:function(){this.getMeasurement(),this.setLayoutWidth(),this.resetLayout(),this.layoutItems(this.items)}},{key:"renderLayout",value:function(){var t=this;this.items.forEach((function(e){t.css(e.node,{left:e.x+"px",top:e.y+"px"})}))}},{key:"setLayoutHeight",value:function(){"horizontal"===this.options.layout?this.viewport.style.height=this.maxY-this.gutter+500+"px":this.viewport.style.height=this.maxY-this.gutter+"px"}},{key:"setLayoutWidth",value:function(){if(this.body=this.getStyle(document.body),this.options.fullWidth){var t=this.getStyle(this.wrapper);this.css(this.wrapper,{left:this.body.left-t.left+t.marginLeft+"px",width:this.body.width-t.marginLeft-t.marginRight+"px"}),this.grid=this.getSize(this.viewport)}}},{key:"getMeasurement",value:function(){this.wrapper.removeAttribute("style"),this.grid=this.getSize(this.viewport),this.getItemSizes()}},{key:"getViewportWidth",value:function(){return(document.documentElement||document.body).clientWidth}},{key:"getSize",value:function(t){var e=t.getBoundingClientRect();return{width:e.width,height:e.height,top:e.top,left:e.left,right:e.right,bottom:e.bottom}}},{key:"getStyle",value:function(t){var e=t.getBoundingClientRect(),i=e.left,n=e.top,s=e.right,r=e.bottom,o=getComputedStyle(t),a=["Top","Right","Bottom","Left"],h={left:i,top:n,right:s,bottom:r};return["margin","padding"].forEach((function(t){a.forEach((function(e){var i=parseFloat(o[t+e]);h[t+e]=i||0}))})),h.width=Math.max(0,t.clientWidth-(h.marginLeft+h.marginRight)),h.height=Math.max(0,t.clientHeight-(h.paddingLeft+h.paddingRight)),h}},{key:"css",value:function(t,e){var i=this.options.rightToLeft;for(var n in e)t.style[i&&"left"===n?"right":n]=e[n]}}]),n}(function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"layoutItems",value:function(t){var e=this,i=t.length;this.emit("beforeLayout",[t]),t.forEach((function(t,n){e.lastItem=i-1===n,e.getItemPosition(t)})),delete this.lastItem,this.setLayoutHeight(),this.renderLayout(),this.emit("layout",[this.items])}},{key:"getItems",value:function(){var t=this.element.querySelectorAll(this.options.items);if(this.items=[],t)return this.items=this.setItems(t),t}},{key:"addItems",value:function(t){if(t.length){var e=this.setItems(t);this.items=[].concat(v(this.items),v(e)),this.layoutItems(e),this.emit("added",[t])}}},{key:"removeItems",value:function(t){this.items=this.items.filter((function(e){return!(!t||e.node===e)||(e.node.parentElement.removeChild(e.node),!1)})),this.resetLayout(),this.emit("removed",[t])}},{key:"setItems",value:function(t){return v(t).map((function(t,e){var i=t.querySelector("svg[data-ratio]"),n=i?i.viewBox.baseVal:null;return{node:t,rows:parseInt(t.getAttribute("data-row"),10)||1,columns:parseInt(t.getAttribute("data-col"),10)||1,ratio:n?n.width/n.height:1.5625}}))}},{key:"getItemSizes",value:function(){var t=this.getViewportWidth(),e=this.options.cardSizes,i=Object.keys(e).sort((function(t,e){return t-e})).filter((function(e){return e>=t}));for(var n in e[i=Math.min.apply(Math,v(i))])this[n]=e[i][n]}},{key:"getItemCol",value:function(t){return Math.min(t.columns||1,this.columns)}},{key:"getItemRow",value:function(t){return"horizontal"===this.options.layout?Math.min(t.rows||1,this.options.rowsNumber):t.rows||1}}]),n}(function(t){o(n,t);var i=c(n);function n(){var t;e(this,n);for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return A(l(t=i.call.apply(i,[this].concat(r))),"onresize",_((function(){var e=t.getStyle(document.body);t.body.width!==e.width&&t.layout()}),100)),t}return s(n,[{key:"handleEvent",value:function(t){var e="on"+t.type;this[e]&&this[e](t)}},{key:"bindEvents",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];t=t?"addEventListener":"removeEventListener",window[t]("load",this),window[t]("resize",this),window[t]("orientationchange",this)}},{key:"onload",value:function(){this.layout()}},{key:"orientationchange",value:function(){this.onresize()}}]),n}(w))),O=function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"resetLayout",value:function(){this.maxX=0,this.maxY=0,this.placed=[]}},{key:"getItemPosition",value:function(t){var e=(this.grid.width+this.gutter)/this.columns,i=this.getItemCol(t);t.x=this.maxX,t.y=0,t.width=Math.ceil(10*(e*i-this.gutter))/10,this.css(t.node,{width:t.width+"px",height:""});var n=this.getSize(t.node);n.height||(n.height=3*e/4,this.css(t.node,{height:n.height+"px"})),this.placed.push(t),this.maxX+=e*i,this.maxY=Math.max(this.maxY,n.height+this.gutter),this.lastItem&&0!==this.x&&this.equalColumns()}},{key:"equalColumns",value:function(){var t=this;this.options.equalColumns&&this.placed.forEach((function(e){t.css(e.node,{height:t.maxY-t.gutter+"px"})}))}}]),n}(M),D=function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"resetLayout",value:function(){this.maxX=0,this.maxY=0,this.rowY=0,this.rowItems=[],this.rowWidth=0,this.prevProg=0,this.prevItem=null}},{key:"getItemPosition",value:function(t){"horizontal"===this.options.layout?this.layoutHorizontal(t):this.layoutVertical(t)}},{key:"layoutHorizontal",value:function(t){var e=t.ratio*this.height,i=this.rowItems.index;(!i||i>this.options.rowsNumber-1)&&(i=this.rowItems.index=0),t.x=this.rowItems[i]?this.rowItems[i].x:0,t.y=i*(this.height+this.gutter),t.width=e,t.height=this.height,this.rowItems[i]={x:t.x+e+this.gutter},this.maxY=this.options.rowsNumber*(this.height+this.gutter),this.maxX=this.maxX<this.rowItems[i].x?this.rowItems[i].x:this.maxX,this.css(t.node,{height:this.height+"px",width:e+"px"}),this.rowItems.index++}},{key:"layoutVertical",value:function(t){var e=t.ratio*this.height;if(this.rowItems.push(t),this.rowWidth+=e,this.maxX+=e+this.gutter,this.maxY=this.rowY,this.rowWidth>=this.getMaxRowWidth())return this.layoutRow(),void this.resetRow();this.lastItem&&this.layoutRow(!0),this.prevProg=this.getRowProgress()}},{key:"layoutRow",value:function(t){var e=this.getClosestHeigth(),i=!this.options.fillLastRow&&t||this.options.equalRows?this.height:e,n=this.options.equalRows&&!t||this.options.fillLastRow?e/i:1;this.maxX=t?this.getCenterOffset():0;for(var s=0,r=this.rowItems.length;s<r;s++){var o=this.rowItems[s],a=i*o.ratio*n;o.x=this.maxX,o.y=this.rowY,this.maxX+=a+this.gutter,this.css(o.node,{height:i+"px",width:a+"px"})}this.maxY+=i+this.gutter,this.rowY+=t?0:i+this.gutter}},{key:"getCenterOffset",value:function(){return!this.options.centerLastRow||this.options.fillLastRow?0:(1-this.getRowProgress())*this.grid.width*.5}},{key:"getRowProgress",value:function(){return this.rowWidth/this.getMaxRowWidth()}},{key:"getMaxRowWidth",value:function(){var t=(this.rowItems.length-1)*this.gutter;return this.grid.width-t}},{key:"getClosestHeigth",value:function(){var t=this.rowItems.length,e=this.getRowProgress(),i=this.height/e,n=this.height/this.prevProg;return t>1&&Math.abs(n-this.height)<Math.abs(i-this.height)?(this.prevItem=this.rowItems.pop(),n):i}},{key:"resetRow",value:function(){this.rowItems=[],this.rowWidth=0,this.prevProg=0,this.maxX=0,this.pushPrevItem()}},{key:"pushPrevItem",value:function(){if(this.prevItem){var t=this.prevItem;this.prevItem=null,this.getItemPosition(t)}}}]),n}(M),C=function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"resetLayout",value:function(){this.x=0,this.y=0,this.maxY=0,this.maxX=0,this.placed=[],this.colYs=Array(this.columns).fill(0)}},{key:"getItemPosition",value:function(t){var e=this.grid.width+this.gutter,i=e/this.columns,n=i*this.getItemCol(t);0!==this.x&&Math.floor(n+this.x)>e&&(this.equalColumns(),this.x=0,this.y=this.maxY,this.placed=[]),t.x=this.x,t.y=this.y,this.css(t.node,{width:Math.ceil(10*(n-this.gutter))/10+"px",height:""});var s=this.getSize(t.node);s.height||(s.height=3*i/4,this.css(t.node,{height:s.height+"px"})),this.placed.push(t),this.maxY=Math.max(this.maxY,this.y+s.height+this.gutter),this.x+=n,this.lastItem&&0!==this.x&&this.equalColumns()}},{key:"equalColumns",value:function(){var t=this;this.options.equalColumns&&this.placed.forEach((function(e){t.css(e.node,{height:t.maxY-t.y-t.gutter+"px"})}))}}]),n}(M),B=function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"resetLayout",value:function(){this.x=0,this.y=0,this.maxY=0,this.maxX=0,this.colId=0,this.colYs=Array(this.columns).fill(0)}},{key:"getItemPosition",value:function(t){var e=(this.grid.width+this.gutter)/this.columns,i=this.getItemCol(t),n=this[this.options.horizontalOrder?"getHorColPosition":"getTopColPosition"](i),s=i+n.col;this.css(t.node,{width:e*i-this.gutter+"px"});var r=this.getSize(t.node);r.height||(r.height=3*e/4);for(var o=n.y+r.height+this.gutter,a=n.col;a<s;a++)this.colYs[a]=o;t.x=e*n.col,t.y=n.y,this.maxY=Math.max(this.maxY,n.y+r.height+this.gutter)}},{key:"getTopColPosition",value:function(t){var e=this.getTopColGroup(t),i=Math.min.apply(Math,e);return{col:e.indexOf(i),y:i}}},{key:"getTopColGroup",value:function(t){if(t<2)return this.colYs;for(var e=[],i=this.columns+1-t,n=0;n<i;n++)e[n]=this.getColGroupY(n,t);return e}},{key:"getColGroupY",value:function(t,e){if(e<2)return this.colYs[t];var i=this.colYs.slice(t,t+e);return Math.max.apply(Math,i)}},{key:"getHorColPosition",value:function(t){var e=this.colId%this.columns;return t>1&&e+t>this.columns&&(e=0),this.colId=e+t,{col:e,y:this.getColGroupY(e,t)}}}]),n}(M),R=function(){function t(i){e(this,t);var n={x:0,y:0,width:0,height:0};for(var s in n)this[s]=n[s];for(var r in i)this[r]=i[r]}return s(t,[{key:"contains",value:function(t){var e=t.width||0,i=t.height||0;return this.x<=t.x&&this.y<=t.y&&this.x+this.width>=t.x+e&&this.y+this.height>=t.y+i}},{key:"overlaps",value:function(t){var e=this.x+this.width,i=this.y+this.height,n=t.x+t.width,s=t.y+t.height;return this.x<n&&e>t.x&&this.y<s&&i>t.y}},{key:"getMaximalFreeRects",value:function(e){if(!this.overlaps(e))return!1;var i,n=[],s=this.x+this.width,r=this.y+this.height,o=e.x+e.width,a=e.y+e.height;return this.y<e.y&&(i=new t({x:this.x,y:this.y,width:this.width,height:e.y-this.y}),n.push(i)),s>o&&(i=new t({x:o,y:this.y,width:s-o,height:this.height}),n.push(i)),r>a&&(i=new t({x:this.x,y:a,width:this.width,height:r-a}),n.push(i)),this.x<e.x&&(i=new t({x:this.x,y:this.y,width:e.x-this.x,height:this.height}),n.push(i)),n}},{key:"canFit",value:function(t){return this.width>=t.width&&this.height>=t.height}}]),t}(),F=function(){function t(){e(this,t)}return s(t,[{key:"reset",value:function(){var t={downwardLeftToRight:function(t,e){return t.y-e.y||t.x-e.x},rightwardTopToBottom:function(t,e){return t.x-e.x||t.y-e.y}};this.spaces=[],this.spaces.push(new R({x:0,y:0,width:this.width,height:this.height})),this.sorter=t[this.direct]||t.downwardLeftToRight}},{key:"pack",value:function(t){for(var e=0;e<this.spaces.length;e++){var i=this.spaces[e];if(i.canFit(t)){this.placeInSpace(t,i);break}}}},{key:"columnPack",value:function(t){for(var e=0;e<this.spaces.length;e++){var i=this.spaces[e];if(i.x<=t.x&&i.x+i.width>=t.x+t.width&&i.height>=t.height-.01){t.y=i.y,this.placed(t);break}}}},{key:"rowPack",value:function(t){for(var e=0;e<this.spaces.length;e++){var i=this.spaces[e];if(i.y<=t.y&&i.y+i.height>=t.y+t.height&&i.width>=t.width-.01){t.x=i.x,this.placed(t);break}}}},{key:"placeInSpace",value:function(t,e){t.x=e.x,t.y=e.y,this.placed(t)}},{key:"placed",value:function(t){for(var e=[],i=0;i<this.spaces.length;i++){var n=this.spaces[i],s=n.getMaximalFreeRects(t);s?e.push.apply(e,s):e.push(n)}this.spaces=e,this.mergeSortSpaces()}},{key:"mergeSortSpaces",value:function(){this.mergeRects(this.spaces),this.spaces.sort(this.sorter)}},{key:"addSpace",value:function(t){this.spaces.push(t),this.mergeSortSpaces()}},{key:"mergeRects",value:function(t){var e=0,i=t[e];t:for(;i;){for(var n=0,s=t[e+n];s;){if(s==i)n++;else{if(s.contains(i)){t.splice(e,1),i=t[e];continue t}i.contains(s)?t.splice(e+n,1):n++}s=t[e+n]}i=t[++e]}return t}}]),t}(),z=function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"resetLayout",value:function(){if(this.maxY=0,this.maxX=0,this.packer||(this.packer=new F),"horizontal"===this.options.layout){var t=(this.grid.width+this.gutter)/this.columns,e=Math.floor(t/this.ratio)*this.options.rowsNumber;this.packer.width=1/0,this.packer.height=e+this.gutter,this.packer.direct="rightwardTopToBottom"}else this.packer.height=1/0,this.packer.width=this.grid.width+this.gutter,this.packer.direct="downwardLeftToRight";this.packer.reset()}},{key:"getItemPosition",value:function(t){this.setRectSize(t),this.packer.pack(t),this.floatRect(t),this.setMaxXY(t)}},{key:"setRectSize",value:function(t){var e=this.getItemCol(t),i=this.getItemRow(t),n=(this.grid.width+this.gutter)/this.columns,s=Math.floor(n)*e,r=Math.floor(n/this.ratio)*i;t.width=Math.min(s,this.packer.width),t.height=Math.min(r,this.packer.height),this.css(t.node,{width:Math.ceil(10*(n*e-this.gutter))/10+"px",height:r-this.gutter+"px"})}},{key:"floatRect",value:function(t){var e=(this.grid.width+this.gutter)/this.columns;t.x=Math.round(t.x/e)*e}},{key:"setMaxXY",value:function(t){this.maxX=Math.max(t.x+t.width,this.maxX),this.maxY=Math.max(t.y+t.height,this.maxY),t.width-=this.gutter,t.height-=this.gutter}}]),n}(M),T=function(){function t(i,n){e(this,t),this.id=i,this.base=500,this.instance=n}return s(t,[{key:"init",value:function(){this.style=document.createElement("style"),document.head.appendChild(this.style),this.sheet=this.style.sheet}},{key:"destroy",value:function(){this.style.parentElement.removeChild(this.style)}},{key:"handleEvent",value:function(t){var e="on"+t.type;this[e]&&this[e](t)}},{key:"setFontSize",value:function(){var t=Math.ceil(this.width)/this.base*16;this.addRules(".wpgb-grid-".concat(this.id,'[data-instance="').concat(this.instance,'"] .wpgb-card[data-fluid]'),{"font-size":"".concat(t,"px")})}},{key:"addRules",value:function(t,e){var i=this.rulesExist(t,e);i?this.addRule(i,e):(e=this.buildRules(e))&&this.insertRules(t+"{"+e+"}")}},{key:"rulesExist",value:function(t,e){for(var i=0,n=(e=this.sheet.cssRules).length;i<n;i++)if(e[i].selectorText===t)return e[i].style}},{key:"addRule",value:function(t,e){if(e)for(var i in e)e.hasOwnProperty(i)&&(t.hasOwnProperty(i)&&t[i]===e[i]||t.setProperty(i,e[i]))}},{key:"buildRules",value:function(t){var e="";if(!t)return e;for(var i in t)t.hasOwnProperty(i)&&""!==t[i]&&(e+=i+":"+t[i]+";");return e}},{key:"insertRules",value:function(t){try{var e=this.sheet.cssRules.length;this.sheet.insertRule(t,e)}catch(t){return""}}}]),t}(),q=function(){function t(i){e(this,t),this.element=i,this.interval=5e3}return s(t,[{key:"init",value:function(){this.rand=-1,this.clear(),this.query(),this.loop()}},{key:"destroy",value:function(){this.clear()}},{key:"clear",value:function(){clearInterval(this.timer)}},{key:"query",value:function(){this.galleries=this.element.querySelectorAll(".wpgb-card-media-gallery[data-slideshow]")}},{key:"loop",value:function(){var t=this;this.galleries.length&&(this.timer=setInterval((function(){t.randomize()}),this.interval))}},{key:"randomize",value:function(){var t=this.galleries.length,e=Math.floor(Math.random()*t);e===this.rand&&(e=(t+(e+1)%t)%t),this.rand=e,this.update()}},{key:"update",value:function(){var t=this.galleries[this.rand];if(t){var e=v(t.children);(e=e.filter((function(t){return!t.hasAttribute("data-active")||(t.removeAttribute("data-active"),!1)})))[Math.floor(Math.random()*e.length)].setAttribute("data-active","")}}}]),t}();function W(t,e){var i=0;return function(){var n=(new Date).getTime();if(!(n-i<e))return i=n,t.apply(void 0,arguments)}}var X=function(){function t(i,n,s){e(this,t),this.callback=s,this.element=n,this.source=i,this.image=new Image,this.load()}return s(t,[{key:"load",value:function(){var t=this,e="decode"in this.image;e||this.bindEvents(),this.image.src=this.source,this.isComplete()?this.onload(!0):e&&this.image.decode().then((function(){return t.onload(!0)})).catch((function(){return t.onload(!1)}))}},{key:"onload",value:function(t){this.callback(this.element,this.source,t),this.destroy()}},{key:"isComplete",value:function(){return this.image.complete&&this.image.naturalWidth}},{key:"destroy",value:function(){this.bindEvents(!1),this.callback=null,this.element=null,this.source=null,this.image=null}},{key:"bindEvents",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];t=t?"addEventListener":"removeEventListener",this.image[t]("load",this),this.image[t]("error",this)}},{key:"handleEvent",value:function(t){this.onload("load"===t.type)}}]),t}(),j={selector:"[data-wpgb-src]",source:"data-wpgb-src",thumb:"data-wpgb-thumb",spinner:"wpgb-lazy-spinner",treshold:300},N=function(t){o(n,t);var i=c(n);function n(t){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e(this,n),A(l(s=i.call(this)),"handleEvent",W((function(t){s.check()}),60)),s.options=P(P({},j),r),s}return s(n,[{key:"query",value:function(t){this.items=v(t.querySelectorAll(this.options.selector))}},{key:"addItems",value:function(t){this.unObserve(),this.query(t),this.observe()}},{key:"canObserve",value:function(){return"IntersectionObserver"in window&&"isIntersecting"in window.IntersectionObserverEntry.prototype}},{key:"observe",value:function(){var t=this;if(this.items.length){if(this.canObserve())return this.observer(),void this.items.forEach((function(e){return t.intersection.observe(e)}));this.bindEvents(),requestAnimationFrame((function(){return setTimeout((function(){return t.check()}))}))}}},{key:"unObserve",value:function(){if(this.intersection)return this.intersection.disconnect(),void delete this.intersection;this.bindEvents(!1)}},{key:"observer",value:function(){var t=this;this.intersection=new IntersectionObserver((function(e,i){e.forEach((function(e,n){if(e.isIntersecting){var s=t.items.indexOf(e.target);t.items.splice(s,1),i.unobserve(e.target),t.loadImage(e.target)}}))}),{rootMargin:this.options.treshold+"px"})}},{key:"bindEvents",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];t=t?"addEventListener":"removeEventListener",window[t]("load",this),window[t]("resize",this),document[t]("scroll",this),window[t]("orientationchange",this)}},{key:"check",value:function(){var t=this;this.items=this.items.filter((function(e,i){return!t.inView(e)||(t.loadImage(e),!1)})),this.isComplete()}},{key:"inView",value:function(t){var e=t.getBoundingClientRect(),i=e.top,n=e.bottom,s=window.innerHeight;return i>=this.options.treshold&&i<=s||n>=0&&n<=s}},{key:"loadImage",value:function(t){var e=this.imageLoaded.bind(this),i=t.getAttribute(this.options.source),n=t.getAttribute(this.options.thumb);i&&(n&&(t.style.backgroundImage="url("+n+")"),t.removeAttribute(this.options.source),t.removeAttribute(this.options.thumb),this.emit("load",[i]),new X(i,t,e))}},{key:"imageLoaded",value:function(t,e,i){if("IMG"===t.nodeName)t.src=e;else{if(t.parentNode){var n=document.createElement(t.tagName);n.className=t.className,n.style.backgroundImage="url("+e+")",n.classList.remove("wpgb-lazy-load",this.options.thumb,this.options.spinner),""===n.className&&n.removeAttribute("class"),t.parentNode.insertBefore(n,t.nextElementSibling)}setTimeout((function(){t.parentNode&&t.parentNode.removeChild(t)}),600)}t.classList.remove(this.options.spinner),this.emit("loaded",[e,i])}},{key:"isComplete",value:function(){this.items.length||this.bindEvents(!1)}}]),n}(w),Y={draggable:1,threshold:3,slideAlign:"center",groupCells:"50%",rightToLeft:0,initialIndex:0,contain:0,freeScroll:0,freeFriction:.075,friction:.285,attraction:.025,autoPlay:0,arrowShape:"M18,12 L10,20 L18,28 M10,20 L30,20",sliderSelector:".wpgb-viewport",pageDotsSelector:".wpgb-page-dots",prevButtonSelector:".wpgb-prev-button",nextButtonSelector:".wpgb-next-button",carouselClass:"wpgb-carousel",draggingClass:"wpgb-is-dragging",pageDotAriaLabel:"Page dot %d"},G=!1;try{var V=Object.defineProperty({},"passive",{get:function(){return G=!0}});window.addEventListener("test",null,V),window.removeEventListener("test",null,V)}catch(t){}var Q,U,H=function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"attachPointers",value:function(t){this.pointer={},this.pointedElement=t,this.passiveListener=G,this._getEvents(),this._unifyEvents(),this._bindEvents()}},{key:"_getEvents",value:function(){this.events={down:"mousedown",move:"mousemove",up:"mouseup"},window.PointerEvent?this.events={down:"pointerdown",move:"pointermove",up:"pointerup",cancel:"pointercancel"}:"ontouchstart"in window&&(this.events={down:"touchstart",move:"touchmove",up:"touchend",cancel:"touchcancel"})}},{key:"_unifyEvents",value:function(){for(var t in this.events)this["on".concat(this.events[t])]=this._handleEvent}},{key:"_bindEvents",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["down"],i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];i=i?"add":"remove",e.forEach((function(e){("down"===e?t.pointedElement:window)["".concat(i,"EventListener")](t.events[e],t,!!t.passiveListener&&{passive:!1})}))}},{key:"handleEvent",value:function(t){var e="on"+t.type;this[e]&&this[e](t)}},{key:"_handleEvent",value:function(t){if(this.isPointer(t)&&this.hasPointer(t))for(var e in this.events)if(this.events[e]===t.type)return this["_pointer".concat(e)](t)}},{key:"isPointer",value:function(t){return!t.button||t.button<1}},{key:"hasPointer",value:function(t){for(var e=t.changedTouches||[t],i=0;i<e.length;i++){var n=e[i].pointerId||e[i].identifier,s=this.pointer.pointerId||this.pointer.identifier;if(n===s||void 0===s)return this.pointer=e[i],!0}return!1}},{key:"_pointerdown",value:function(t){this._bindEvents(["move","up","cancel"]),this._callBack("pointerDown",t)}},{key:"_pointermove",value:function(t){this._callBack("pointerMove",t)}},{key:"_pointerup",value:function(t){this._callBack("pointerUp",t),this._pointerDone(t)}},{key:"_pointercancel",value:function(t){this._callBack("pointerCancel",t),this._pointerDone(t)}},{key:"_pointerDone",value:function(t){this._callBack("pointerDone",t),this._pointerReset()}},{key:"_pointerReset",value:function(){this._bindEvents(["move","up","cancel"],!1),this.pointer={}}},{key:"_callBack",value:function(t,e,i){this[t]?this[t](e,this.pointer,i):this.emit(t,[e,this.pointer,i])}}]),n}(w),J={nodes:["TEXTAREA","SELECT","OPTION","INPUT"],types:["checkbox","radio","button","submit","image","file"]},$=function(t){o(n,t);var i=c(n);function n(){var t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return e(this,n),(t=i.call(this)).options=P(P({},Y),s),t.layout=r,t.element=r.element.querySelector(t.options.sliderSelector),t.slider=t.element.firstElementChild,t.pageDots=r.element.querySelector(t.options.pageDotsSelector),t.prevButton=r.element.querySelector(t.options.prevButtonSelector),t.nextButton=r.element.querySelector(t.options.nextButtonSelector),t}return s(n,[{key:"init",value:function(){this.element.tabIndex=0,this.element.classList.add(this.options.carouselClass),this.updateSlides(),this.setDots();var t=this.options.initialIndex||0,e=this.slides.length-1,i=Math.max(0,Math.min(t,e));this.cells&&this.cells.length&&this.cells.forEach((function(t){return t.node.setAttribute("aria-hidden",!0)})),this.select(i,!0),this.options.draggable&&this.initDragger(),this.bindEvents(),this.autoPlay()}},{key:"destroy",value:function(){var t=this;this.bindEvents(!1),this._bindEvents(["down","move","up","cancel"],!1),this.isAnimating=!1,cancelAnimationFrame(this.frame),this.cells&&(this.cells.forEach((function(t){t.node.removeAttribute("aria-hidden")})),this.cells=[],this.slides=[]),this.dots&&(this.dots.forEach((function(e){t.pageDots.removeChild(e)})),this.dots=[],this.pageDots.removeAttribute("role")),this.prevButton&&(this.prevButton.disabled=!0,this.prevButton.hidden=!0),this.nextButton&&(this.nextButton.disabled=!0,this.nextButton.hidden=!0),this.slider.removeAttribute("style"),this.element.removeAttribute("style"),this.element.removeAttribute("tabIndex"),this.element.classList.remove(this.options.carouselClass)}},{key:"previous",value:function(){this.select(this.selectedIndex-1)}},{key:"next",value:function(){this.select(this.selectedIndex+1)}},{key:"select",value:function(t,e){var i=this.selectedIndex;this.cells.length&&this.slides[t]&&(this.isFreeScrolling=!1,this.selectedIndex=t,this.selectedSlide=this.slides[t],this.updateUI(),e?this.settleSlider():this.startAnimation(),this.emit("select",[t]),t!==i&&this.emit("change",[t]))}},{key:"autoPlay",value:function(){var t=this;this.options.autoPlay&&(this.player=setInterval((function(){if(!t.hovered){var e=t.selectedIndex+1,i=t.slides.length,n=(i+e%i)%i;t.select(n)}}),this.options.autoPlay))}},{key:"setDots",value:function(){if(this.cells.length&&this.pageDots){this.dots||(this.dots=[]);var t=this.slides.length-this.dots.length;t>0?this.addDots(t):t<0&&this.removeDots(t),this.dots=v(this.pageDots.children)}}},{key:"addDots",value:function(t){for(var e=document.createDocumentFragment(),i=this.dots.length,n=i;n<i+t;n++){var s=document.createElement("li"),r=this.options.pageDotAriaLabel.replace("%d",n+1);s.className="wpgb-dot",s.setAttribute("role","tab"),s.setAttribute("tabindex",-1),s.setAttribute("aria-selected",!1),s.setAttribute("aria-label",r),e.appendChild(s)}this.pageDots.appendChild(e),this.pageDots.setAttribute("role","tablist")}},{key:"removeDots",value:function(t){for(var e=this.dots.length-1,i=e;i>e+t;i--)this.pageDots.removeChild(this.dots[i])}},{key:"updateUI",value:function(){this.cells.length&&(this.updateDots(),this.updateCells(),this.updateButtons())}},{key:"updateButtons",value:function(){this.prevButton&&(this.prevButton.disabled=!1,this.prevButton.hidden=!1,this.selectedSlide===this.getFirstSlide()&&(this.prevButton.disabled=!0)),this.nextButton&&(this.nextButton.disabled=!1,this.nextButton.hidden=!1,(this.selectedSlide===this.getLastSlide()||this.slides.length<2)&&(this.nextButton.disabled=!0))}},{key:"updateCells",value:function(){var t=this.cell,e=this.cells;this.selectedIndex;e.length&&(t&&t.forEach((function(t){t.setAttribute("aria-hidden",!0)})),(t=this.selectedSlide.cells)&&(t.forEach((function(t){t.setAttribute("aria-hidden",!1)})),this.cell=t))}},{key:"updateDots",value:function(){var t=this.dot,e=this.dots,i=this.selectedIndex;t&&(t.setAttribute("aria-selected",!1),t.setAttribute("tabindex",-1)),e&&e.length&&((t=e[i]).setAttribute("aria-selected",!0),t.setAttribute("tabindex",0),this.dot=t)}},{key:"reposition",value:function(){this.select(this.selectedIndex,!0)}},{key:"resize",value:function(t){var e=this.viewportWidth;this.updateSlides(),t&&e===this.viewportWidth||(this.setDots(),this.updateUI())}}]),n}(function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"updateSlides",value:function(){this.viewportWidth=this.layout.grid.width,this.cells=v(this.layout.items),this.getcells(),this.setSlides(),this.setSlider(),this.filterSlides(),this.selectSlide()}},{key:"getcells",value:function(){var t=this.options.slideAlign;"left"===t?this.cells=this.cells.sort((function(t,e){return t.x-e.x})):"center"===t?this.cells=this.cells.sort((function(t,e){return t.x+t.width/2-(e.x+e.width/2)})):"right"===t&&(this.cells=this.cells.sort((function(t,e){return t.x+t.width-(e.x+e.width)})))}},{key:"setSlides",value:function(){var t,e=this;this.slides=[],this.cells.forEach((function(i,n){var s=i.x,r=i.width,o=i.node;e.slideCanFit(t,i)||e.slides.push(t={cells:[],width:0,x:s}),s<t.x&&(t.x=s),t.width=s+r-t.x,t.cells.push(o)}),this)}},{key:"setSlider",value:function(){var t=this.getFirstSlide(),e=this.getLastSlide();this.sliderWidth=e.x+e.width-t.x,this.slideableWidth=Math.max(0,this.sliderWidth-this.viewportWidth)}},{key:"slideCanFit",value:function(t,e){if(!t)return!1;var i=Math.floor(e.x+e.width-t.x);return i>Math.round(this.viewportWidth)?void 0:this.groupSlides(t.cells.length,i)}},{key:"groupSlides",value:function(t,e){var i=this.viewportWidth,n=this.options.groupCells;if(!n)return!1;if("number"==typeof n)return t<parseInt(n,10);var s=n.match(/^(\d+)%$/),r=s?parseInt(s[1],10)/100:1;return e<=Math.round(i*Math.min(1,r))}},{key:"filterSlides",value:function(){var t=this,e=[];this.slides=this.slides.filter((function(i){var n;t.offsetSlide(i),t.containSlide(i);var s=Math.round(i.x);if(!e[s])return e[s]=i;(n=e[s].cells).push.apply(n,v(i.cells)),e[s].width+=i.width})),this.slidesWidth=this.getLastSlide().x-this.getFirstSlide().x}},{key:"offsetSlide",value:function(t){var e=this.viewportWidth,i=this.options.slideAlign;"center"===i&&(t.x+=(t.width-e)/2),"right"===i&&(t.x+=t.width-e)}},{key:"containSlide",value:function(t){var e=this.slideableWidth,i=this.sliderWidth;this.options.contain&&(t.x<i&&(t.x-=this.getFirstSlide().x,t.x=Math.max(0,t.x)),t.x>e&&(t.x=e))}},{key:"selectSlide",value:function(t){this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,this.slides.length-1)),this.selectedSlide=this.slides[this.selectedIndex],this.isAnimating&&(this.emit("select",[this.selectedIndex]),this.selectedIndex!==t&&this.emit("change",[this.selectedIndex]))}},{key:"getFirstSlide",value:function(){return this.slides[0]}},{key:"getLastSlide",value:function(){return v(this.slides).pop()}}]),n}(function(t){o(n,t);var i=c(n);function n(){var t;e(this,n);for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return A(l(t=i.call.apply(i,[this].concat(r))),"onresize",_((function(e){t.dragging||(t.resize(e),t.reposition())}),100)),t}return s(n,[{key:"bindEvents",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];t=t?"addEventListener":"removeEventListener",this.slider[t]("click",this),this.prevButton&&this.prevButton[t]("click",this),this.nextButton&&this.nextButton[t]("click",this),this.pageDots&&this.pageDots[t]("click",this),this.options.autoPlay&&(this.layout.element[t]("mouseenter",this),this.layout.element[t]("mouseleave",this)),window[t]("load",this),window[t]("keydown",this),window[t]("resize",this),window[t]("orientationchange",this)}},{key:"onclick",value:function(t){switch(t.currentTarget){case this.prevButton:t.stopPropagation(),this.previous();break;case this.nextButton:t.stopPropagation(),this.next();break;case this.pageDots:var e=Array.isArray(this.dots)?this.dots.indexOf(t.target):null;this.select(e);break;default:var i=t.target.closest("a, input, select, textarea");if(this.focus(),this.isAnimating)t.preventDefault(),t.stopPropagation();else if(i)return void this.element.blur()}}},{key:"focus",value:function(){document.activeElement!==this.element&&this.element.focus({preventScroll:!0})}},{key:"onmouseenter",value:function(){clearInterval(this.player)}},{key:"onmouseleave",value:function(){this.autoPlay()}},{key:"onkeydown",value:function(t){var e=t.keyCode,i=this.options.rightToLeft,n=document.activeElement;if(n===this.element||t.target.parentElement===this.pageDots){var s=this.dots&&this.dots.includes(n);37===e?(this[i?"next":"previous"](),s&&this.dots[this.selectedIndex].focus()):39===e&&(this[i?"previous":"next"](),s&&this.dots[this.selectedIndex].focus())}}},{key:"onload",value:function(t){this.resize(),this.reposition()}},{key:"onorientationchange",value:function(t){this.resize(),this.reposition()}}]),n}(function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"startAnimation",value:function(){this.isAnimating||(this.restingFrames=0,this.isAnimating=!0,this.animate())}},{key:"animate",value:function(){var t=this;this.prevX=this.x,this.applyDragForce(),this.applyAttraction(),this.applyPhysics(),this.moveSlider(),this.settle(),this.isAnimating&&(this.frame=requestAnimationFrame((function(){return t.animate()})))}},{key:"moveSlider",value:function(){var t=this.x,e=this.slider.style;t=this.options.rightToLeft?-t:t,this.isAnimating?e.transform="translate3d(".concat(t,"px,0,0)"):(t=Math.round(t),e.transform="translateX(".concat(t,"px)")),this.progress()}},{key:"settleSlider",value:function(){this.x=-this.selectedSlide.x,this.velocity=0,this.moveSlider()}},{key:"progress",value:function(){if(this.x!==this.prevX){var t=-this.x-this.getFirstSlide().x,e=t/this.slidesWidth;this.emit("scroll",[e,t])}}},{key:"settle",value:function(){this.isPointerDown||Math.round(100*this.x)!==Math.round(100*this.prevX)||this.restingFrames++,this.restingFrames>2&&(this.isAnimating=!1,this.isFreeScrolling?this.moveSlider():this.settleSlider(),delete this.isFreeScrolling,this.emit("settle",[this.selectedIndex]))}}]),n}(function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"getFrictionFactor",value:function(){return 1-this.options[this.isFreeScrolling?"freeFriction":"friction"]}},{key:"getRestingPosition",value:function(){return this.x+this.velocity/(1-this.getFrictionFactor())}},{key:"applyPhysics",value:function(){this.x+=this.velocity,this.velocity*=this.getFrictionFactor()}},{key:"applyForce",value:function(t){this.velocity+=t}},{key:"applyDragForce",value:function(){if(this.isPointerDown){var t=this.dragX-this.x-this.velocity;this.applyForce(t)}}},{key:"applyAttraction",value:function(){if(!this.isPointerDown&&!this.isFreeScrolling){var t=(-1*this.selectedSlide.x-this.x)*this.options.attraction;this.applyForce(t)}}}]),n}(function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"initDragger",value:function(){this.drag(this.element.parentElement,{x:this.options.threshold,y:!1},!0)}},{key:"dragDown",value:function(){this.element.classList.add(this.options.draggingClass),this.isPointerDown=!0,this.dragX=this.x}},{key:"dragStart",value:function(t,e){this.startDragX=this.x,this.startAnimation(),this.emit("dragStart",[t])}},{key:"dragMove",value:function(t,e,i){var n=Math.max(-this.getFirstSlide().x,this.startDragX),s=Math.min(-this.getLastSlide().x,this.startDragX);this.prevDragX=this.dragX,this.dragTime=Date.now();var r=this.options.rightToLeft?-1:1,o=this.startDragX+i.x*r;o=(o=o>n?(o+n)/2:o)<s?(o+s)/2:o,this.dragX=o,this.emit("dragMove",[t,i])}},{key:"dragUp",value:function(t,e){var i=this.selectedIndex;if(this.options.freeScroll&&(this.isFreeScrolling=!0),this.isAnimating&&this.getClosestIndex(),this.options.freeScroll){var n=this.getRestingPosition(),s=-n>this.getFirstSlide().x,r=-n<this.getLastSlide().x;this.isFreeScrolling=s&&r}else this.selectedIndex===i&&this.dragBoost();this.selectSlide(i),this.updateUI(),this.element.classList.remove(this.options.draggingClass),this.isPointerDown=!1,this.dragging&&this.emit("dragEnd",[t])}},{key:"getClosestIndex",value:function(){var t=this.slides,e=this.selectedIndex,i=this.selectedSlide.x,n=this.getRestingPosition(),s=Math.sign(-n-i);if(s){for(var r=1/0,o=Math.abs(-n-i),a=e;o<=r&&(r=o,t[a+=s]);)o=Math.abs(-n-t[a].x);this.selectedIndex=a-s}}},{key:"dragBoost",value:function(){var t=this.dragX,e=this.prevDragX,i=this.dragTime,n=-t-this.selectedSlide.x,s=e-t;!i||Date.now()-i>100||(n>0&&s>0?this.selectedIndex+=1:n<0&&s<0&&(this.selectedIndex-=1))}},{key:"dragEnd",value:function(){}},{key:"dragDone",value:function(){}},{key:"dragCancel",value:function(){}}]),n}(function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"drag",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{x:3,y:3},i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.threshold=e,this.attachPointers(t),t.addEventListener("click",this),i&&window.addEventListener("touchmove",this.preventScrolling.bind(this),!!this.passiveListener&&{passive:!1})}},{key:"canDragTarget",value:function(t){var e=t.target,i=e.nodeName,n=e.type;return!(J.nodes.includes(i)||J.types.includes(n))}},{key:"canDragStart",value:function(t,e){var i=this.threshold,n=i.x,s=i.y,r=180*Math.atan2(Math.abs(e),Math.abs(t))/Math.PI,o=Math.sqrt(Math.pow(t,2)+Math.pow(e,2));return!1!==n&&o>n&&r<=45||!1!==s&&o>s&&r>=45}},{key:"canPreventDefault",value:function(t){var e=t.type,i=t.pointerType;return"touchstart"!==e&&"touch"!==i}},{key:"getPointerVector",value:function(t){return{x:t.pageX-this.pointerStart.x,y:t.pageY-this.pointerStart.y}}},{key:"pointerDown",value:function(t,e){this.preventClick=!1,this.canDragTarget(t)?(this.pointerStart={x:e.pageX,y:e.pageY},this.canPreventDefault(t)&&t.preventDefault(),this._callBack("dragDown",t)):this._pointerReset()}},{key:"pointerMove",value:function(t,e){var i=this.getPointerVector(e),n=i.x,s=i.y;this.dragging?(t.preventDefault(),this._callBack("dragMove",t,{x:n,y:s})):this.canDragStart(n,s)&&(this.pointerStart.x+=n,this.pointerStart.y+=s,this.preventClick=!0,this.dragging=!0,this._callBack("dragStart",t,this.getPointerVector(e)))}},{key:"pointerUp",value:function(t,e){this.dragging&&this._callBack("dragEnd",t,this.getPointerVector(e))}},{key:"pointerCancel",value:function(t,e){this.dragging&&this._callBack("dragCancel",t,this.getPointerVector(e))}},{key:"pointerDone",value:function(t,e){this._callBack("dragUp",t,this.getPointerVector(e)),this.dragging&&(this.dragging=!1,this._callBack("dragDone",t,this.getPointerVector(e)))}},{key:"onclick",value:function(t){this.preventClick&&t.preventDefault()}},{key:"preventScrolling",value:function(t){this.dragging&&t.preventDefault()}}]),n}(H))))))),Z={class:"wpgb-card-hidden",treshold:0,delay:300},K=function(t){o(n,t);var i=c(n);function n(){var t,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e(this,n),A(l(t=i.call(this)),"handleEvent",W((function(){t.check()}),60)),t.options=P(P({},Z),s),t.items=[],t.queue=[],t}return s(n,[{key:"addItems",value:function(t){var e=this;t.length&&(this.unObserve(),this.items=[].concat(v(this.items),v(t)),this.items=this.items.filter((function(t){return!e.queue.includes(t)&&t.classList.contains(e.options.class)})),this.observe())}},{key:"canObserve",value:function(){return"IntersectionObserver"in window&&"isIntersecting"in window.IntersectionObserverEntry.prototype}},{key:"observe",value:function(){var t=this;if(this.items.length){if(this.canObserve())return this.observer(),void this.items.forEach((function(e){return t.intersection.observe(e)}));this.bindEvents(),requestAnimationFrame((function(){return setTimeout((function(){return t.check()}))}))}}},{key:"unObserve",value:function(){if(this.intersection)return this.intersection.disconnect(),void delete this.intersection;this.bindEvents(!1)}},{key:"observer",value:function(){var t=this;this.intersection=new IntersectionObserver((function(e,i){e.forEach((function(e,n){if(e.isIntersecting){var s=t.items.indexOf(e.target);t.items.splice(s,1),i.unobserve(e.target),t.addToQueue(e.target)}}))}),{rootMargin:this.options.treshold+"px"})}},{key:"bindEvents",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];t=t?"addEventListener":"removeEventListener",window[t]("load",this),window[t]("resize",this),document[t]("scroll",this),window[t]("orientationchange",this)}},{key:"check",value:function(){var t=this;this.items=this.items.filter((function(e,i){return!t.inView(e)||(t.addToQueue(e),!1)})),this.isComplete()}},{key:"inView",value:function(t){var e=t.getBoundingClientRect(),i=e.top,n=e.bottom,s=window.innerHeight;return i>=this.options.treshold&&i<=s||n>=0&&n<=s}},{key:"addToQueue",value:function(t){var e=this;this.queue.push(t),this.isProcessing||(this.options.delay>0?this.processQueue():requestAnimationFrame((function(){return e.reveal()})))}},{key:"processQueue",value:function(){var t=this;if(!this.queue.length)return Date.now()-this.time<this.options.delay?void requestAnimationFrame((function(){return t.processQueue()})):(delete this.isProcessing,void delete this.time);this.isProcessing=!0,requestAnimationFrame((function(){return t.loop()}))}},{key:"loop",value:function(){var t=Date.now();t-this.time<this.options.delay||(this.time=t,this.reveal()),this.processQueue()}},{key:"reveal",value:function(){if(this.queue.length){var t=this.queue.shift();t.classList.remove(this.options.class),this.emit("revealed",[t])}}},{key:"isComplete",value:function(t){this.items.length||this.bindEvents(!1)}}]),n}(w),tt={},et={},it={grid:".wp-grid-builder",items:".wpgb-card",layout:"masonry"},nt=0,st=function(t){o(n,t);var i=c(n);function n(t){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e(this,n),s=i.call(this),t?t.instance?u(s,et[t.instance]):(s.element=t,s.options=P(P({},it),r),s.htmlInit(),s.id=s.options.id,s.setInstance(),s.setEvents(),s.initGrid(),s.initCarousel(),s.initLazyLoad(),s.initReveal(),s.initDependencies(),s.bindEvents(),s):u(s)}return s(n,[{key:"setInstance",value:function(){this.instance=++nt,this.element.instance=this.instance,et[this.instance]=this}},{key:"htmlInit",value:function(){var t=this.element.getAttribute("data-options");t&&(t=JSON.parse(t),this.options=P(P({},this.options),t),this.element.removeAttribute("data-options"))}},{key:"initGrid",value:function(){var t=this.element,e=this.options;e.isShadow||e.isTemplate||("masonry"===e.type?"horizontal"===e.layout?this.grid=new O(t,e):e.fitRows||e.equalColumns?this.grid=new C(t,e):this.grid=new B(t,e):"metro"===e.type?this.grid=new z(t,e):this.grid=new D(t,e))}},{key:"initCarousel",value:function(){"horizontal"===this.options.layout&&(this.carousel=new $(this.options,this.grid))}},{key:"initLazyLoad",value:function(){this.options.lazyLoad&&(this.lazyLoad=new N(this.element))}},{key:"initReveal",value:function(){this.options.reveal&&(this.reveal=new K({delay:this.options.transitionDelay}))}},{key:"initDependencies",value:function(){var t=this.element,e=this.options,i=(window.wpgb_settings?wpgb_settings:{}).lightbox,n='[data-instance="'.concat(this.instance,'"] .wpgb-lightbox');WP_Grid_Builder.Facets&&(this.facets=WP_Grid_Builder.Facets(t,e)),e.isShadow||e.isTemplate||(WP_Grid_Builder.Lightbox&&(this.lightbox=WP_Grid_Builder.Lightbox(P(P({},i),{},{selector:n}))),this.slideShow=new q(t),this.styleSheet=new T(e.id,this.instance))}},{key:"toggleLayout",value:function(t,e){this.bindEvents(!1),this.grid&&this.grid.destroy(),this.carousel&&this.carousel.destroy(),this.options.type=t,this.options.layout=e,this.initGrid(),this.initCarousel(),this.bindEvents(),this.emit("beforeToggleLayout"),this.element.querySelector(".wpgb-viewport > div").className="wpgb-".concat(t),this.grid&&this.grid.init(),"horizontal"===e&&this.carousel.init()}},{key:"init",value:function(){this.element&&(this.element.classList.add("wpgb-enabled"),this.element.setAttribute("data-instance",this.instance),window.WP_Grid_Builder.emit("init",[this]),this.styleSheet&&this.styleSheet.init(),this.facets&&this.facets.init(),this.grid&&this.grid.init(),this.carousel&&this.carousel.init(),this.lightbox&&this.lightbox.init(),this.slideShow&&this.slideShow.init())}},{key:"destroy",value:function(){var t=Object.getOwnPropertyNames(this);if(this.element){this.grid&&this.grid.items.map((function(t){return t.node.classList.remove("wpgb-card-hidden")})),this.styleSheet&&this.styleSheet.destroy(),this.grid&&this.grid.destroy(),this.facets&&this.facets.destroy(),this.lightbox&&this.lightbox.destroy(),this.slideShow&&this.slideShow.destroy(),this.carousel&&this.carousel.destroy(),this.lazyLoad&&this.lazyLoad.unObserve(),this.reveal&&this.reveal.unObserve(),this.element.classList.remove("wpgb-enabled"),this.element.setAttribute("data-options",JSON.stringify(this.options)),this.bindEvents(!1),delete WP_Grid_Builder.instances[this.instance],delete this.element.instance,delete tt[this.instance],delete et[this.instance];for(var e=0;e<t.length;e++)delete this[t[e]]}}}]),n}(function(t){o(n,t);var i=c(n);function n(){return e(this,n),i.apply(this,arguments)}return s(n,[{key:"setEvents",value:function(){var t=this;tt[this.instance]={initGrid:function(e){return t._initGrid(e)},beforeLayout:function(e){return t._beforeLayout(e)},itemsAdded:function(e){return t._itemsAdded(e)},itemsRemoved:function(e){return t._itemsRemoved(e)},itemsAppended:function(e,i){return t._itemsAppended(e,i)},onProgress:function(e,i){return t._onProgress(e,i)}}}},{key:"bindEvents",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=tt[this.instance];t=t?"on":"off",this.grid&&(this.grid[t]("init",e.initGrid),this.grid[t]("beforeLayout",e.beforeLayout),this.grid[t]("added",e.itemsAdded),this.grid[t]("removed",e.itemsRemoved),this.facets&&this.facets[t]("appended",e.itemsAppended)),this.carousel&&this.carousel[t]("scroll",e.onProgress)}},{key:"_initGrid",value:function(t){var e=this;this.reveal&&this.reveal.addItems(t),this.lazyLoad&&(this.lazyLoad.addItems(this.element),this.reveal&&!this.reveal.canObserve()&&this.reveal.on("revealed",(function(){return setTimeout((function(){return e.lazyLoad.check()}),150)})))}},{key:"_itemsAppended",value:function(t,e){"append"!==e&&this.grid.removeItems(),this.grid.addItems(t),x()}},{key:"_itemsRemoved",value:function(t){this.lazyLoad&&(this.lazyLoad.items=[]),this.reveal&&(this.reveal.items=[],this.reveal.queue=[]),"horizontal"===this.options.layout&&this.carousel&&this.carousel.select(0,!0)}},{key:"_itemsAdded",value:function(t){this.slideShow.init(),this.lazyLoad&&this.lazyLoad.addItems(this.element),this.reveal&&this.reveal.addItems(t),"horizontal"===this.options.layout&&this.carousel&&(this.carousel.resize(),this.carousel.on("scroll",tt[this.instance].onProgress))}},{key:"_beforeLayout",value:function(t){var e=this.grid,i=e.gutter,n=e.columns,s=e.grid;this.styleSheet.width=(s.width+i)/n-i,this.styleSheet.setFontSize()}},{key:"_onProgress",value:function(t,e){this.facets&&t>.8&&this.facets.loader&&this.facets.loader.onScroll&&(this.carousel.off("scroll",tt[this.instance].onProgress),this.facets.loader.click())}}]),n}(w)),rt={youtube:{regex:/(?:www\.)?youtu\.?be(?:\.com)?\/?.*?(?:watch|embed)?(?:.*v=|v\/|watch%3Fv%3D|\/)/i,play:{event:"command",func:"playVideo"},pause:{event:"command",func:"pauseVideo"}},vimeo:{regex:/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/)?(\d+)/i,play:{event:"command",method:"play"},pause:{event:"command",method:"pause"}},wistia:{regex:/(?:www\.)?(?:wistia\.(?:com|net)|wi\.st)\/(?:(?:m|medias|projects)|embed\/(?:iframe|playlists))\/([a-zA-Z0-9_\-]+)/i,play:{event:"cmd",method:"play"},pause:{event:"cmd",method:"pause"}}},ot=["TEXTAREA","SELECT","OPTION","INPUT","AUDIO","VIDEO","A"],at=["checkbox","radio","button","submit","image","file"],ht=function(t){o(n,t);var i=c(n);function n(){var t;return e(this,n),(t=i.call(this)).attachPointers(document),document.addEventListener("click",l(t),!0),document.addEventListener("play",l(t),!0),t}return s(n,[{key:"pointerDown",value:function(t,e){this.move=!1,this.pointerStart={x:e.pageX,y:e.pageY}}},{key:"pointerMove",value:function(t,e){var i=e.pageX-this.pointerStart.x,n=e.pageY-this.pointerStart.y;!this.move&&(Math.abs(i)>1||Math.abs(n)>1)&&(this.move=!0)}},{key:"pointerEnd",value:function(){}},{key:"pointerCancel",value:function(){}},{key:"pointerDone",value:function(){}},{key:"onplay",value:function(t){var e=t.target;e&&e.closest(".wpgb-card")&&this.pauseAll(e)}},{key:"onclick",value:function(t){if(t.button||!t.target||this.move)this.move=!1;else if(t.target.closest(".wpgb-handle-lb"))this.pauseAll();else if(this.isClickable(t))if(t.target.closest(".wpgb-card-media-button")){var e=t.target.closest(".wpgb-card");if(!e)return;this.onLightboxClick(t,e),this.onPlayButtonClick(t,e)}else t.target.closest("[data-action]")&&this.onActionLink(t)}},{key:"isClickable",value:function(t){var e=t.target.type,i=ot,n=at,s=t.target.closest(i.join(","));return!(s&&!s.classList.contains("wpgb-card-media-button")||n.includes(e))}},{key:"onActionLink",value:function(t){var e=t.target.closest("[data-action]").querySelector(".wpgb-card-layer-link");e&&e.click()}},{key:"onLightboxClick",value:function(t,e){var i=e.querySelector("[data-active] .wpgb-handle-lb");i||(i=e.querySelector(".wpgb-handle-lb")),i&&(t.preventDefault(),t.stopPropagation(),i.click())}},{key:"onPlayButtonClick",value:function(t,e){var i=e.querySelector(".wpgb-card-media-player > *:not(div), .wpgb-card-media-player .wpgb-card-media-iframe");i&&(t.preventDefault(),t.stopPropagation(),this.pauseAll(i),this.player=i,this.play())}},{key:"play",value:function(){"AUDIO"===this.player.nodeName||"VIDEO"===this.player.nodeName?(this.revealPoster(),this.player.controlsList="nodownload",this.player.play()):this.playIframe(),this.reveal()}},{key:"revealPoster",value:function(){var t=this.player.previousElementSibling;t&&t.getAttribute("data-wpgb-poster")&&(t.style.backgroundImage="url("+t.getAttribute("data-wpgb-poster")+")",t.removeAttribute("data-wpgb-poster"))}},{key:"playIframe",value:function(){var t=this.getIframeProvider();t?this.player.contentWindow.postMessage(JSON.stringify(t.play),"*"):this.createIframe()}},{key:"pause",value:function(){"AUDIO"===this.player.nodeName||"VIDEO"===this.player.nodeName?this.player.pause():this.pauseIframe(),this.hide()}},{key:"pauseIframe",value:function(){var t=this.getIframeProvider();t?this.player.contentWindow.postMessage(JSON.stringify(t.pause),"*"):this.removeIframe()}},{key:"pauseAll",value:function(t){for(var e=document.querySelectorAll(".wpgb-card audio, .wpgb-card video, .wpgb-card iframe"),i=0,n=e.length;i<n;i++){var s=e[i];s!==t&&(s===this.player?this.pause():"IFRAME"!==s.nodeName&&s.pause())}}},{key:"createIframe",value:function(){var t=document.createElement("iframe");t.className=this.player.className,t.src=this.player.getAttribute("data-src"),t.setAttribute("frameborder",0),t.setAttribute("allow","autoplay"),t.setAttribute("allowfullscreen",""),this.player.parentElement.replaceChild(t,this.player),this.player=t}},{key:"removeIframe",value:function(){var t=document.createElement("div");t.className=this.player.className,t.setAttribute("data-src",this.player.src),this.player.removeAttribute("src"),this.player.parentElement.replaceChild(t,this.player),this.player=t}},{key:"getIframeProvider",value:function(){if(this.player.src)for(var t in rt){if(rt.hasOwnProperty(t))if(this.player.src.match(rt[t].regex))return rt[t]}}},{key:"reveal",value:function(){this.player.closest(".wpgb-card").classList.add("wpgb-card-playing")}},{key:"hide",value:function(){this.player.closest(".wpgb-card").classList.remove("wpgb-card-playing")}}]),n}(H),lt=0;function ut(){var t,e,i=document.querySelectorAll(".wp-grid-builder:not(.wpgb-template)");i&&i.forEach((function(t){WP_Grid_Builder.instances[++lt]=new st(t)})),new ht,t="wpgb.loaded","function"==typeof Event?e=new CustomEvent(t):(e=document.createEvent("CustomEvent")).initEvent(t,!0,!0),window.dispatchEvent(e)}WP_Grid_Builder.unsupported?(Q=document.querySelectorAll(".wpgb-card"),U=document.querySelectorAll(".wp-grid-builder"),Q&&Q.forEach((function(t){var e=t.querySelector(".wpgb-card-hidden .wpgb-card-wrapper"),i=t.querySelectorAll("[data-wpgb-src]");e&&(e.style.visibility="visible",e.style.transform="none",e.style.opacity=1),i.forEach((function(t){t.style.backgroundImage="url("+t.getAttribute("data-wpgb-src")+")",t.className=""}))})),U&&U.forEach((function(t){return t.removeAttribute("data-options")}))):(window.WP_Grid_Builder.instantiate=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.instances[++lt]=new st(t,e)},t((function(){var t=wpgb_settings.hasFacets,e=wpgb_settings.hasLightbox,i=!t||t&&WP_Grid_Builder.Facets,n=!e||e&&WP_Grid_Builder.Lightbox;i&&n?ut():!i&&n?window.addEventListener("wpgb.facets.loaded",ut):i&&!n?window.addEventListener("wpgb.lightbox.loaded",ut):(window.addEventListener("wpgb.facets.loaded",(function(){return window.addEventListener("wpgb.lightbox.loaded",ut)})),window.addEventListener("wpgb.lightbox.loaded",(function(){return window.addEventListener("wpgb.facets.loaded",ut)})))})))}()}();