JavaScript UI component library, includes the latest Fancybox
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

2 lines
45 KiB

// @fancyapps/ui/Carousel v4.0.0-alpha.2
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";function e(t){return(e="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 i(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 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&&a(t,e)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function h(t,e){return!e||"object"!=typeof 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=r(t);if(e){var s=r(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return h(this,i)}}function d(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=t&&("undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"]);if(null==i)return;var n,s,o=[],r=!0,a=!1;try{for(i=i.call(t);!(r=(n=i.next()).done)&&(o.push(n.value),!e||o.length!==e);r=!0);}catch(t){a=!0,s=t}finally{try{r||null==i.return||i.return()}finally{if(a)throw s}}return o}(t,e)||p(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t){return function(t){if(Array.isArray(t))return f(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||p(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 p(t,e){if(t){if("string"==typeof t)return f(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)?f(t,e):void 0}}function f(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,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=p(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0,s=function(){};return{s:s,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,r=!0,a=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return r=t.done,t},e:function(t){a=!0,o=t},f:function(){try{r||null==i.return||i.return()}finally{if(a)throw o}}}}var g=function(t){return"object"===e(t)&&null!==t&&t.constructor===Object&&"[object Object]"===Object.prototype.toString.call(t)},m=function t(){for(var i=!1,n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];"boolean"==typeof s[0]&&(i=s.shift());var r=s[0];if(!r||"object"!==e(r))throw new Error("extendee must be an object");for(var a=s.slice(1),l=a.length,h=0;h<l;h++){var c=a[h];for(var d in c)if(c.hasOwnProperty(d)){var u=c[d];if(i&&(Array.isArray(u)||g(u))){var p=Array.isArray(u)?[]:{};r[d]=t(!0,r.hasOwnProperty(d)?r[d]:p,u)}else r[d]=u}}return r},y=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;return t=parseFloat(t)||0,Math.round((t+Number.EPSILON)*e)/e},w="undefined"!=typeof window&&window.ResizeObserver||function(){function t(e){i(this,t),this.observables=[],this.boundCheck=this.check.bind(this),this.boundCheck(),this.callback=e}return s(t,[{key:"observe",value:function(t){if(!this.observables.some((function(e){return e.el===t}))){var e={el:t,size:{height:t.clientHeight,width:t.clientWidth}};this.observables.push(e)}}},{key:"unobserve",value:function(t){this.observables=this.observables.filter((function(e){return e.el!==t}))}},{key:"disconnect",value:function(){this.observables=[]}},{key:"check",value:function(){var t=this.observables.filter((function(t){var e=t.el.clientHeight,i=t.el.clientWidth;if(t.size.height!==e||t.size.width!==i)return t.size.height=e,t.size.width=i,!0})).map((function(t){return t.el}));t.length>0&&this.callback(t),window.requestAnimationFrame(this.boundCheck)}}]),t}(),b=function t(e){return!(!e||e.classList.contains("carousel__track")||e===document.body)&&(function(t){var e=window.getComputedStyle(t)["overflow-y"],i=window.getComputedStyle(t)["overflow-x"],n=("scroll"===e||"auto"===e)&&Math.abs(t.scrollHeight-t.clientHeight)>1,s=("scroll"===i||"auto"===i)&&Math.abs(t.scrollWidth-t.clientWidth)>1;return n||s}(e)?e:t(e.parentNode))},x=function(t){var e=0;return t&&(e=t instanceof SVGElement?Math.min(t.getClientRects()[0].height,t.height.baseVal.value):Math.max(t.offsetHeight,t.scrollHeight)),e},P=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,t),this.options=m(!0,{},e),this.plugins=[],this.events={};for(var n=0,s=["on","once"];n<s.length;n++)for(var o=s[n],r=0,a=Object.entries(this.options[o]||{});r<a.length;r++){var l=a[r];this[o].apply(this,u(l))}}return s(t,[{key:"option",value:function(t,e){t=String(t);var i,n,s=(i=t,n=this.options,i.split(".").reduce((function(t,e){return t[e]}),n));return"function"==typeof s&&(s=s.call(this,t)),void 0===s?e:s}},{key:"localize",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return String(t).replace(/\{\{(\w+).?(\w+)?\}\}/g,(function(t,n,s){var o=!1;if(!(o=s?e.option("".concat(n[0]+n.toLowerCase().substring(1),".l10n.").concat(s)):e.option("l10n.".concat(n))))return n;for(var r=0;r<i.length;r++)o=o.split(i[r][0]).join(i[r][1]);return o}))}},{key:"on",value:function(t,e){var i=this;if(g(t)){for(var n=0,s=Object.entries(t);n<s.length;n++){var o=s[n];this.on.apply(this,u(o))}return this}return String(t).split(" ").forEach((function(t){var n=i.events[t]=i.events[t]||[];-1==n.indexOf(e)&&n.push(e)})),this}},{key:"once",value:function(t,e){var i=this;if(g(t)){for(var n=0,s=Object.entries(t);n<s.length;n++){var o=s[n];this.once.apply(this,u(o))}return this}return String(t).split(" ").forEach((function(t){var n=function n(){i.off(t,n);for(var s=arguments.length,o=new Array(s),r=0;r<s;r++)o[r]=arguments[r];e.call.apply(e,[i,i].concat(o))};n._=e,i.on(t,n)})),this}},{key:"off",value:function(t,e){var i=this;if(!g(t))return t.split(" ").forEach((function(t){var n=i.events[t];if(!n||!n.length)return i;for(var s=-1,o=0,r=n.length;o<r;o++){var a=n[o];if(a&&(a===e||a._===e)){s=o;break}}-1!=s&&n.splice(s,1)})),this;for(var n=0,s=Object.entries(t);n<s.length;n++){var o=s[n];this.off.apply(this,u(o))}}},{key:"trigger",value:function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];var s,o=v(u(this.events[t]||[]).slice());try{for(o.s();!(s=o.n()).done;){var r=s.value;if(r&&!1===r.call.apply(r,[this,this].concat(i)))return!1}}catch(t){o.e(t)}finally{o.f()}var a,l=v(u(this.events["*"]||[]).slice());try{for(l.s();!(a=l.n()).done;){var h=a.value;if(h&&!1===h.call.apply(h,[this,t,this].concat(i)))return!1}}catch(t){l.e(t)}finally{l.f()}return!0}},{key:"attachPlugins",value:function(t){for(var e={},i=0,n=Object.entries(t||{});i<n.length;i++){var s=d(n[i],2),o=s[0],r=s[1];!1!==this.options[o]&&(this.options[o]=m({},r.defaults||{},this.options[o]),e[o]=new r(this))}for(var a=0,l=Object.entries(e);a<l.length;a++){var h=d(l[a],2);h[0],h[1].attach(this)}return this.plugins=Object.assign({},this.plugins,e),this}},{key:"detachPlugins",value:function(){for(var t in this.plugins){var e=void 0;(e=this.plugins[t])&&"function"==typeof e.detach&&e.detach(this)}return this.plugins={},this}}]),t}(),k={panOnlyZoomed:!1,lockAxis:!1,friction:.72,decelFriction:.92,zoomFriction:.72,bounceForce:.1,baseScale:1,minScale:1,maxScale:2,step:.5,zoomInCentered:!0,pinchToZoom:!0,textSelection:!0,click:"toggleZoom",clickDelay:250,doubleClick:!1,wheel:"zoom",wheelFactor:30,wheelLimit:3,touch:!0,draggableClass:"is-draggable",draggingClass:"is-dragging"},$=function(t){o(n,t);var e=c(n);function n(t){var s,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this,n),o=m(!0,{},k,o),s=e.call(this,o),!(t instanceof HTMLElement))throw new Error("Viewport not found");s.state="init",s.$viewport=t;for(var r=0,a=["onPointerDown","onPointerMove","onPointerUp","onWheel","onClick"];r<a.length;r++){var h=a[r];s[h]=s[h].bind(l(s))}if(s.$content=s.option("content"),s.$content||(s.$content=s.$viewport.querySelector(".panzoom__content")),!s.$content)throw new Error("Content not found");if(!1===s.option("textSelection")&&s.$viewport.classList.add("not-selectable"),s.resetValues(),s.attachPlugins(n.Plugins),s.trigger("init"),s.handleContent(),s.attachEvents(),s.trigger("ready"),"init"===s.state){var c=s.option("baseScale");1===c?(s.state="ready",s.handleCursor()):s.panTo({scale:c,friction:0})}return s}return s(n,[{key:"handleContent",value:function(){var t=this;if(this.$content instanceof HTMLImageElement){var e=function(){var e=t.$content.naturalWidth;t.maxScale=t.option("maxScale"),t.options.maxScale=function(){var t=this.contentDim.width;return e>0&&t>0?e/t*this.maxScale:this.maxScale},t.updateMetrics(),t.trigger(e>0?"load":"error")};!0!==this.$content.complete?(this.$content.onload=function(){return e()},this.$content.onerror=function(){return e()}):e()}else this.updateMetrics()}},{key:"resetValues",value:function(){this.viewportDim={top:0,left:0,width:0,height:0},this.contentDim={width:0,height:0},this.friction=this.option("friction"),this.current={x:0,y:0,scale:1},this.velocity={x:0,y:0,scale:0},this.pan={x:0,y:0,scale:1},this.drag={startTime:null,firstPosition:null,startPosition:null,startPoint:null,startDistance:null,endPosition:null,endPoint:null,distance:0,distanceX:0,distanceY:0,elapsedTime:0},this.lockAxis=null,this.pendingAnimateUpdate=null,this.pendingResizeUpdate=null,this.pointers=[]}},{key:"updateMetrics",value:function(){var t,e,i=this.$viewport.getBoundingClientRect(),n=i.top,s=i.left,o=i.width,r=i.height,a=window.getComputedStyle(this.$viewport);o-=parseFloat(a.paddingLeft)+parseFloat(a.paddingRight),r-=parseFloat(a.paddingTop)+parseFloat(a.paddingBottom),this.viewportDim={top:n,left:s,width:o,height:r},this.contentDim={width:this.option("width",(t=this.$content,e=0,t&&(e=t instanceof SVGElement?Math.min(t.getClientRects()[0].width,t.width.baseVal.value):Math.max(t.offsetWidth,t.scrollWidth)),e)),height:this.option("hidth",x(this.$content))},this.trigger("updateMetrics"),this.updateBounds()}},{key:"updateBounds",value:function(t){var e={from:0,to:0},i={from:0,to:0};if(t||(t=this.velocity.scale?this.pan.scale:this.current.scale),t<1)return[e,i];var n=this.contentDim,s=this.viewportDim,o=n.width*t,r=n.height*t;return e.to=y(.5*(o-n.width)),n.width>s.width?e.from=y(e.to+s.width-o):e.from=y(-1*e.to),i.to=y(.5*(r-n.height)),n.height>s.height?i.from=y(i.to+s.height-r):i.from=y(-1*i.to),this.boundX=e,this.boundY=i,this.trigger("updateBounds",t),[this.boundX,this.boundY]}},{key:"zoomIn",value:function(t){this.zoomTo(this.current.scale+(t||this.option("step")))}},{key:"zoomOut",value:function(t){this.zoomTo(this.current.scale-(t||this.option("step")))}},{key:"toggleZoom",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.option("maxScale"),i=this.option("baseScale");this.zoomTo(this.current.scale>i+.5*(e-i)?i:e,t)}},{key:"zoomTo",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.x,n=void 0===i?null:i,s=e.y,o=void 0===s?null:s,r=e.friction,a=void 0===r?this.option("zoomFriction"):r;t||(t=this.option("baseScale")),t=Math.max(Math.min(t,this.option("maxScale")),this.option("minScale"));var l=this.contentDim.width,h=this.contentDim.height,c=l*this.current.scale,d=h*this.current.scale,u=l*t,p=h*t;null===n&&(n=.5*c),null===o&&(o=.5*d),!1===this.option("zoomInCentered")&&(n<.5*c&&(n=c),n>c&&(n=0),o<0&&(o=d),o>d&&(o=0));var f=c>0?n/c:0,v=d>0?o/d:0,g=(u-c)*(f-.5),m=(p-d)*(v-.5);Math.abs(g)<1&&(g=0),Math.abs(m)<1&&(m=0),n=this.current.x-g,o=this.current.y-m,this.panTo({x:n,y:o,scale:t,friction:a})}},{key:"panTo",value:function(t){var e=t.x,i=void 0===e?0:e,n=t.y,s=void 0===n?0:n,o=t.scale,r=void 0===o?this.current.scale:o,a=t.friction,l=void 0===a?this.option("friction"):a,h=t.ignoreBounds,c=void 0!==h&&h;if(l||this.stopMoving(),!0!==c){var u=d(this.updateBounds(r),2),p=u[0],f=u[1];p&&(i=Math.max(Math.min(i,p.to),p.from)),f&&(s=Math.max(Math.min(s,f.to),f.from))}return l>0&&(Math.abs(i-this.current.x)>.1||Math.abs(s-this.current.y)>.1||Math.abs(r-this.current.scale)>.1)?(this.state="panning",this.friction=l,this.pan={x:i,y:s,scale:r},this.velocity={x:(1/this.friction-1)*(i-this.current.x),y:(1/this.friction-1)*(s-this.current.y),scale:(1/this.friction-1)*(r-this.current.scale)},this.animate(),this):(this.pendingAnimateUpdate&&(cancelAnimationFrame(this.pendingAnimateUpdate),this.pendingAnimateUpdate=null),this.state="ready",this.stopMoving(),this.current={x:i,y:s,scale:r},this.transform(),this.handleCursor(),this.trigger("afterAnimate",!0),this)}},{key:"animate",value:function(){var t=this;if(!this.pendingAnimateUpdate){if(this.applyBoundForce(),this.applyDragForce(),this.velocity.x*=this.friction,this.velocity.y*=this.friction,this.velocity.scale*=this.friction,this.current.x+=this.velocity.x,this.current.y+=this.velocity.y,this.current.scale+=this.velocity.scale,"dragging"==this.state||"pointerdown"==this.state||Math.abs(this.velocity.x)>.05||Math.abs(this.velocity.y)>.05||Math.abs(this.velocity.scale)>.05)return this.transform(),void(this.pendingAnimateUpdate=requestAnimationFrame((function(){t.pendingAnimateUpdate=null,t.animate()})));this.current.x=y(this.current.x+this.velocity.x/(1/this.friction-1)),this.current.y=y(this.current.y+this.velocity.y/(1/this.friction-1)),Math.abs(this.current.x)<.5&&(this.current.x=0),Math.abs(this.current.y)<.5&&(this.current.y=0),this.current.scale=y(this.current.scale+this.velocity.scale/(1/this.friction-1),1e4),Math.abs(this.current.scale-1)<.01&&(this.current.scale=1),this.state="ready",this.stopMoving(),this.transform(),this.handleCursor(),this.trigger("afterAnimate")}}},{key:"handleCursor",value:function(){var t=this.option("draggableClass");t&&this.option("touch")&&(this.contentDim.width<=this.viewportDim.width&&1==this.option("panOnlyZoomed")&&this.current.scale<=this.option("baseScale")?this.$viewport.classList.remove(t):this.$viewport.classList.add(t))}},{key:"isMoved",value:function(){return 0!==this.current.x||0!==this.current.y||1!==this.current.scale||this.velocity.x>0||this.velocity.y>0||this.velocity.scale>0}},{key:"stopMoving",value:function(){this.velocity={x:0,y:0,scale:0}}},{key:"transform",value:function(){this.trigger("beforeTransform");var t=y(this.current.x,100),e=y(this.current.y,100),i=y(this.current.scale,1e5);Math.abs(t)<=.1&&Math.abs(e)<=.1&&Math.abs(i-1)<=.1?this.$content.style.transform="":this.$content.style.transform="translate3d(".concat(t,"px, ").concat(e,"px, 0px) scale(").concat(i,")"),this.trigger("afterTransform")}},{key:"applyBoundForce",value:function(){if("decel"===this.state){var t,e,i,n,s={x:0,y:0},o=this.option("bounceForce"),r=this.boundX,a=this.boundY;if(r&&(t=this.current.x<r.from,e=this.current.x>r.to),a&&(i=this.current.y<a.from,n=this.current.y>a.to),t||e){var l=(t?r.from:r.to)-this.current.x,h=l*o,c=this.current.x+(this.velocity.x+h)/(1/this.friction-1);t&&c<r.from||e&&c>r.to||(h=l*o-this.velocity.x),s.x=h}if(i||n){var d=(i?a.from:a.to)-this.current.y,u=d*o,p=this.current.y+(this.velocity.y+u)/(1/this.friction-1);i&&p<a.from||n&&p>a.to||(u=d*o-this.velocity.y),s.y=u}this.velocity.x+=s.x,this.velocity.y+=s.y}}},{key:"applyDragForce",value:function(){"dragging"===this.state&&(this.velocity={x:(1/this.friction-1)*(this.drag.endPosition.x-this.current.x),y:(1/this.friction-1)*(this.drag.endPosition.y-this.current.y),scale:(1/this.friction-1)*(this.drag.endPosition.scale-this.current.scale)})}},{key:"attachEvents",value:function(){var t=this,e=this.$viewport;this.resizeObserver=this.resizeObserver||new w((function(e){t.pendingResizeUpdate=t.pendingResizeUpdate||setTimeout((function(){t.pendingResizeUpdate=null;var i=e&&e[0].contentRect;!i&&t.$viewport&&(i=t.$viewport.getBoundingClientRect()),i&&(Math.abs(i.width-t.viewportDim.width)>1||Math.abs(i.height-t.viewportDim.height)>1)&&t.updateMetrics()}),50)})),this.resizeObserver.observe(e),e.addEventListener("click",this.onClick,{passive:!1}),e.addEventListener("wheel",this.onWheel,{passive:!1}),this.option("touch")&&(window.PointerEvent?(e.addEventListener("pointerdown",this.onPointerDown,{passive:!1}),e.addEventListener("pointermove",this.onPointerMove,{passive:!1}),e.addEventListener("pointerup",this.onPointerUp),e.addEventListener("pointercancel",this.onPointerUp)):(e.addEventListener("touchstart",this.onPointerDown,{passive:!1}),e.addEventListener("touchmove",this.onPointerMove,{passive:!1}),e.addEventListener("touchend",this.onPointerUp),e.addEventListener("touchcancel",this.onPointerUp),e.addEventListener("mousedown",this.onPointerDown)))}},{key:"detachEvents",value:function(){this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeObserver=null,this.pendingResizeUpdate&&(clearTimeout(this.pendingResizeUpdate),this.pendingResizeUpdate=null);var t=this.$viewport;window.PointerEvent?(t.removeEventListener("pointerdown",this.onPointerDown,{passive:!1}),t.removeEventListener("pointermove",this.onPointerMove,{passive:!1}),t.removeEventListener("pointerup",this.onPointerUp),t.removeEventListener("pointercancel",this.onPointerUp)):(t.removeEventListener("touchstart",this.onPointerDown,{passive:!1}),t.removeEventListener("touchmove",this.onPointerMove,{passive:!1}),t.removeEventListener("touchend",this.onPointerUp),t.removeEventListener("touchcancel",this.onPointerUp),t.removeEventListener("mousedown",this.onPointerDown)),t.removeEventListener("click",this.onClick,{passive:!1}),t.removeEventListener("wheel",this.onWheel,{passive:!1})}},{key:"copyPointer",value:function(t){return{pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY}}},{key:"findPointerIndex",value:function(t){for(var e=this.pointers.length;e--;)if(this.pointers[e].pointerId===t.pointerId)return e;return-1}},{key:"addPointer",value:function(t){var e=0;if(t.touches&&t.touches.length){var i,n=v(t.touches);try{for(n.s();!(i=n.n()).done;){var s=i.value;s.pointerId=e++,this.addPointer(s)}}catch(t){n.e(t)}finally{n.f()}}else(e=this.findPointerIndex(t))>-1&&this.pointers.splice(e,1),this.pointers.push(t)}},{key:"removePointer",value:function(t){if(t.touches)for(;this.pointers.length;)this.pointers.pop();else{var e=this.findPointerIndex(t);e>-1&&this.pointers.splice(e,1)}}},{key:"getMiddlePoint",value:function(){var t=u(this.pointers),e=(t=t.sort((function(t,e){return e.pointerId-t.pointerId}))).shift(),i=t.shift();return i?{clientX:.5*(e.clientX-i.clientX)+i.clientX,clientY:.5*(e.clientY-i.clientY)+i.clientY}:{clientX:e?e.clientX:0,clientY:e?e.clientY:0}}},{key:"getDistance",value:function(t,e){if(!(t=(t=t||u(this.pointers)).slice())||t.length<2)return 0;var i=(t=t.sort((function(t,e){return e.pointerId-t.pointerId}))).shift(),n=t.shift(),s=Math.abs(n.clientX-i.clientX);if("x"===e)return s;var o=Math.abs(n.clientY-i.clientY);return"y"===e?o:Math.sqrt(Math.pow(s,2)+Math.pow(o,2))}},{key:"resetDragState",value:function(){var t=this.$content.getClientRects()[0],e=t.left,i=t.top,n=this.getMiddlePoint(),s={top:i,left:e,x:this.current.x,y:this.current.y,scale:this.current.scale};m(this.drag,{startPosition:m({},s),startPoint:m({},n),startDistance:this.getDistance(),endPosition:m({},s),endPoint:m({},n),distance:0,distanceX:0,distanceY:0}),"pointerdown"===this.state&&(this.lockAxis=null,this.drag.startTime=new Date,this.drag.firstPosition=Object.assign({},s)),this.stopMoving(),this.friction=this.option("friction")}},{key:"onPointerDown",value:function(t){if(t&&!(t.button&&t.button>0))if(this.option("panOnlyZoomed")&&this.velocity.scale)t.preventDefault();else{if(this.resetDragState(),!this.pointers.length){if(-1!==["BUTTON","TEXTAREA","OPTION","INPUT","SELECT","VIDEO"].indexOf(t.target.nodeName))return;if(this.option("textSelection")&&function(t,e,i){for(var n=t.childNodes,s=document.createRange(),o=0;o<n.length;o++){var r=n[o];if(r.nodeType===Node.TEXT_NODE){s.selectNodeContents(r);var a=s.getBoundingClientRect();if(e>=a.left&&i>=a.top&&e<=a.right&&i<=a.bottom)return r}}return!1}(t.target,t.clientX,t.clientY))return;if(b(t.target))return}var e;if((e=window.getSelection?window.getSelection():document.selection)&&e.rangeCount&&e.getRangeAt(0).getClientRects().length&&(e.removeAllRanges?e.removeAllRanges():e.empty&&e.empty()),this.pointers.length>1||this.pointers.length&&this.lockAxis)t.preventDefault();else if(!1!==this.trigger("touchStart",t))if(t.preventDefault(),this.state="pointerdown",this.addPointer(this.copyPointer(t)),this.resetDragState(),window.PointerEvent)try{t.target.setPointerCapture(t.pointerId)}catch(t){}else document.addEventListener("mousemove",this.onPointerMove,{passive:!1}),document.addEventListener("mouseup",this.onPointerUp,{passive:!1})}}},{key:"onPointerMove",value:function(t){if(!(t.targetTouches&&t.targetTouches.length>1||"pointerdown"!==this.state&&"dragging"!==this.state))if(0!=this.trigger("touchMove",t)){if(this.addPointer(this.copyPointer(t)),!(this.pointers.length>1&&!1===this.option("pinchToZoom")))if(1==this.option("panOnlyZoomed")&&this.current.scale===this.option("baseScale")&&this.pointers.length<2)t.preventDefault();else{var e=this.getMiddlePoint(),i=[e,this.drag.startPoint];this.drag.distance=this.getDistance(i);var n=this.events.click&&this.events.click.length||this.events.doubleClick&&this.events.doubleClick.length||this.option.click||this.option.doubleClick;if(!(this.drag.distance<6&&(n||this.option("lockAxis")&&!this.lockAxis))&&("pointerdown"==this.state&&(this.state="dragging"),"dragging"===this.state)){var s=this.option("lockAxis");if(!this.lockAxis&&s)if("xy"===s){var o=this.getDistance(i,"x"),r=this.getDistance(i,"y"),a=Math.abs(180*Math.atan2(r,o)/Math.PI);this.lockAxis=a>45&&a<135?"y":"x"}else this.lockAxis=s;t.preventDefault(),t.stopPropagation(),this.$viewport.classList.add(this.option("draggingClass")),this.animate();var l=this.current.scale,h=0,c=0;if(this.current.scale===this.option("baseScale")&&"y"===this.lockAxis||(h=e.clientX-this.drag.startPoint.clientX),this.current.scale===this.option("baseScale")&&"x"===this.lockAxis||(c=e.clientY-this.drag.startPoint.clientY),this.drag.endPosition.x=this.drag.startPosition.x+h,this.drag.endPosition.y=this.drag.startPosition.y+c,this.pointers.length>1){this.drag.middlePoint=e,l=this.drag.startPosition.scale*this.getDistance()/this.drag.startDistance,l=Math.max(Math.min(l,2*this.option("maxScale")),.5*this.option("minScale"));var d=this.$content.width,u=this.$content.height,p=d*this.drag.startPosition.scale,f=u*this.drag.startPosition.scale,v=u*l,g=(d*l-p)*((this.drag.startPoint.clientX-this.drag.startPosition.left)/p-.5),m=(v-f)*((this.drag.startPoint.clientY-this.drag.startPosition.top)/f-.5);this.drag.endPosition.x-=g,this.drag.endPosition.y-=m,this.drag.endPosition.scale=l,this.updateBounds(l)}this.applyDragResistance()}}}else t.preventDefault()}},{key:"onPointerUp",value:function(t){if(this.removePointer(t),window.PointerEvent)try{t.target.releasePointerCapture(t.pointerId)}catch(t){}else document.removeEventListener("mousemove",this.onPointerMove,{passive:!1}),document.removeEventListener("mouseup",this.onPointerUp,{passive:!1});if(this.pointers.length>0)return t.preventDefault(),void this.resetDragState();if("pointerdown"===this.state||"dragging"===this.state){this.$viewport.classList.remove(this.option("draggingClass"));var e=this.$content.getClientRects()[0],i=e.top,n=e.left,s=this.drag;if(m(!0,s,{elapsedTime:new Date-s.startTime,distanceX:s.endPosition.x-s.firstPosition.x,distanceY:s.endPosition.y-s.firstPosition.y,endPosition:{top:i,left:n}}),s.distance=Math.sqrt(Math.pow(s.distanceX,2)+Math.pow(s.distanceY,2)),this.state="decel",this.friction=this.option("decelFriction"),this.pan={x:this.current.x+this.velocity.x/(1/this.friction-1),y:this.current.y+this.velocity.y/(1/this.friction-1),scale:this.current.scale+this.velocity.scale/(1/this.friction-1)},!1!==this.trigger("touchEnd",t)&&"decel"===this.state){var o=this.option("minScale");if(this.current.scale<o)this.zoomTo(o,{friction:.64});else{var r=this.option("maxScale");if(this.current.scale-r>.01){var a={friction:.64};s.middlePoint&&(a.x=s.middlePoint.clientX-n,a.y=s.middlePoint.clientY-i),this.zoomTo(r,a)}}}}}},{key:"applyDragResistance",value:function(){var t,e,i,n,s=this.boundX,o=this.boundY;if(s&&(t=this.drag.endPosition.x<s.from,e=this.drag.endPosition.x>s.to),o&&(i=this.drag.endPosition.y<o.from,n=this.drag.endPosition.y>o.to),t||e){var r=t?s.from:s.to,a=this.drag.endPosition.x-r;this.drag.endPosition.x=r+.3*a}if(i||n){var l=i?o.from:o.to,h=this.drag.endPosition.y-l;this.drag.endPosition.y=l+.3*h}}},{key:"onWheel",value:function(t){!1!==this.trigger("wheel",t)&&"zoom"==this.option("wheel",t)&&this.zoomWithWheel(t)}},{key:"zoomWithWheel",value:function(t){void 0===this.changedDelta&&(this.changedDelta=0);var e=this.current.scale,i=Math.max(-1,Math.min(1,-t.deltaY||-t.deltaX||t.wheelDelta||-t.detail));if(i<0&&e<=this.option("minScale")||i>0&&e>=this.option("maxScale")){if(this.changedDelta+=Math.abs(i),this.changedDelta>this.option("wheelLimit"))return}else this.changedDelta=0;e=e*(100+i*this.option("wheelFactor"))/100,t.preventDefault();var n=this.$content.getClientRects()[0],s=n.top,o=n.left,r=t.clientX-o,a=t.clientY-s;this.zoomTo(e,{x:r,y:a})}},{key:"onClick",value:function(t){var e=this;if(!t.defaultPrevented){if(window.getSelection().toString().length)return t.stopPropagation(),void t.stopImmediatePropagation();if(this.drag.startPosition&&this.drag.endPosition&&(Math.abs(this.drag.endPosition.top-this.drag.startPosition.top)>1||Math.abs(this.drag.endPosition.left-this.drag.startPosition.left)>1))return t.stopPropagation(),void t.stopImmediatePropagation();if(this.drag.distance>(this.lockAxis?6:1))return t.preventDefault(),t.stopPropagation(),void t.stopImmediatePropagation();var i=null,n=null;void 0!==t.clientX&&void 0!==t.clientY&&(i=t.clientX-this.$content.getClientRects()[0].left,n=t.clientY-this.$content.getClientRects()[0].top);var s=this.options.doubleClick;if(!s&&this.events.doubleClick&&this.events.doubleClick.length&&(s=!0),s){if(!this.clickTimer)return this.lastClickEvent=t,void(this.clickTimer=setTimeout((function(){e.clickTimer=null,!1!==e.trigger("click",t)&&"toggleZoom"===e.option("click")&&e.toggleZoom({x:i,y:n})}),this.option("clickDelay")));this.getDistance([t,this.lastClickEvent])>=6||(clearTimeout(this.clickTimer),this.clickTimer=null,!1!==this.trigger("doubleClick",t)&&"toggleZoom"===this.option("doubleClick")&&this.toggleZoom({x:i,y:n}))}else{if(!1===this.trigger("click",t))return;"toggleZoom"===this.option("click")&&this.toggleZoom({x:i,y:n})}}}},{key:"destroy",value:function(){"destroy"!==this.state&&(this.state="destroy",this.$viewport.classList.remove("not-selectable"),this.$content instanceof HTMLImageElement&&!this.$content.complete&&(this.$content.onload=null,this.$content.onerror=null),this.pendingAnimateUpdate&&(cancelAnimationFrame(this.pendingAnimateUpdate),this.pendingAnimateUpdate=null),this.clickTimer&&(clearTimeout(this.clickTimer),this.clickTimer=null),this.detachEvents(),this.pointers=[],this.resetValues(),this.$viewport=null,this.$content=null,this.options={},this.events={})}}]),n}(P);$.version="4.0.0-alpha.2",$.Plugins={};var S=function(t,e){var i=0;return function(){var n=(new Date).getTime();if(!(n-i<e))return i=n,t.apply(void 0,arguments)}},D=function(){function t(e){i(this,t),this.$container=null,this.$prev=null,this.$next=null,this.carousel=e,this.onRefresh=this.onRefresh.bind(this)}return s(t,[{key:"option",value:function(t){return this.carousel.option("Navigation.".concat(t))}},{key:"createButton",value:function(t){var e,i=this,n=document.createElement("button");n.setAttribute("title",this.carousel.localize("{{".concat(t.toUpperCase(),"}}")));var s=this.option("classNames.button")+" "+this.option("classNames.".concat(t));return(e=n.classList).add.apply(e,u(s.split(" "))),n.setAttribute("tabindex","0"),n.innerHTML=this.carousel.localize(this.option("".concat(t,"Tpl"))),n.addEventListener("click",(function(e){e.preventDefault(),e.stopPropagation(),i.carousel["slide".concat("next"===t?"Next":"Prev")]()})),n}},{key:"build",value:function(){this.$container||(this.$container=document.createElement("div"),this.$container.classList.add(this.option("classNames.main")),this.carousel.$element.appendChild(this.$container)),this.$next||(this.$next=this.createButton("next"),this.$container.appendChild(this.$next)),this.$prev||(this.$prev=this.createButton("prev"),this.$container.appendChild(this.$prev))}},{key:"onRefresh",value:function(){var t=this.carousel.pages.length;t<=1||t>1&&this.carousel.elemDimWidth<this.carousel.wrapDimWidth&&!Number.isInteger(this.carousel.option("slidesPerPage"))?this.cleanup():(this.build(),this.$prev.removeAttribute("disabled"),this.$next.removeAttribute("disabled"),this.carousel.option("infiniteX",this.carousel.option("infinite"))||(this.carousel.page<=0&&this.$prev.setAttribute("disabled",""),this.carousel.page>=t-1&&this.$next.setAttribute("disabled","")))}},{key:"cleanup",value:function(){this.$prev&&this.$prev.remove(),this.$prev=null,this.$next&&this.$next.remove(),this.$next=null,this.$container&&this.$container.remove(),this.$container=null}},{key:"attach",value:function(){this.carousel.on("refresh change",this.onRefresh)}},{key:"detach",value:function(){this.carousel.off("refresh change",this.onRefresh),this.cleanup()}}]),t}();D.defaults={prevTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M15 3l-9 9 9 9"/></svg>',nextTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M9 3l9 9-9 9"/></svg>',classNames:{main:"carousel__nav",button:"carousel__button",next:"is-next",prev:"is-prev"}};var E=function(){function t(e){i(this,t),this.carousel=e,this.$list=null,this.events={change:this.onChange.bind(this),refresh:this.onRefresh.bind(this)}}return s(t,[{key:"buildList",value:function(){var t=this;if(!(this.carousel.pages.length<2)){var e=document.createElement("ol");return e.classList.add("carousel__dots"),e.addEventListener("click",(function(e){if("page"in e.target.dataset){e.preventDefault(),e.stopPropagation();var i=parseInt(e.target.dataset.page,10),n=t.carousel;i!==n.page&&(n.pages.length<3&&n.option("infinite")?n[0==i?"slidePrev":"slideNext"]():n.slideTo(i))}})),this.$list=e,this.carousel.$element.appendChild(e),this.carousel.$element.classList.add("has-dots"),e}}},{key:"removeList",value:function(){this.$list&&(this.$list.parentNode.removeChild(this.$list),this.$list=null)}},{key:"rebuildDots",value:function(){var t=this,e=this.$list,i=!!e,n=this.carousel.pages.length;if(n<2)i&&this.removeList();else{i||(e=this.buildList());var s=this.$list.children.length;if(s>n)for(var o=n;o<s;o++)this.$list.removeChild(this.$list.lastChild);else{for(var r=function(e){var i=document.createElement("li");i.classList.add("carousel__dot"),i.dataset.page=e,i.setAttribute("role","button"),i.setAttribute("tabindex","0"),i.setAttribute("title",t.carousel.localize("{{GOTO}}",[["%d",e+1]])),i.addEventListener("keydown",(function(t){var e,n=t.code;"Enter"===n||"NumpadEnter"===n?e=i:"ArrowRight"===n?e=i.nextSibling:"ArrowLeft"===n&&(e=i.previousSibling),e&&e.click()})),t.$list.appendChild(i)},a=s;a<n;a++)r(a);this.setActiveDot()}}}},{key:"setActiveDot",value:function(){if(this.$list){this.$list.childNodes.forEach((function(t){t.classList.remove("is-selected")}));var t=this.$list.childNodes[this.carousel.page];t&&t.classList.add("is-selected")}}},{key:"onChange",value:function(){this.setActiveDot()}},{key:"onRefresh",value:function(){this.rebuildDots()}},{key:"attach",value:function(){this.carousel.on(this.events)}},{key:"detach",value:function(){this.removeList(),this.carousel.off(this.events),this.carousel=null}}]),t}(),M=function(){function t(e){i(this,t),this.nav=e,this.selectedIndex=null,this.onNavReady=this.onNavReady.bind(this),this.onNavClick=this.onNavClick.bind(this),this.onNavCreateSlide=this.onNavCreateSlide.bind(this),this.onTargetChange=this.onTargetChange.bind(this)}return s(t,[{key:"onNavReady",value:function(){this.onTargetChange(!0),this.nav.on("createSlide",this.onNavCreateSlide),this.sync.on("change",this.onTargetChange),this.nav.Panzoom.on("click",this.onNavClick)}},{key:"onNavCreateSlide",value:function(t,e){e.index===this.selectedIndex&&this.markSelectedSlide(e.index)}},{key:"onNavClick",value:function(t,e){var i=e.target.closest(".carousel__slide");if(i){e.preventDefault();var n=parseInt(i.dataset.index,10),s=this.sync.getPageforSlide(n);this.sync.page!==s&&this.sync.slideTo(s,{friction:this.nav.option("Sync.friction")}),this.markSelectedSlide(n)}}},{key:"markSelectedSlide",value:function(t){this.selectedIndex=t,u(this.nav.slides).filter((function(t){return t.$el&&t.$el.classList.remove("is-nav-selected")}));var e=this.nav.slides[t];e&&e.$el&&e.$el.classList.add("is-nav-selected")}},{key:"onTargetChange",value:function(t){var e=this.sync.pages[this.sync.page].indexes[0],i=this.nav.getPageforSlide(e);null!==i&&(this.nav.slideTo(i,!0===t?{friction:0}:{}),this.markSelectedSlide(e))}},{key:"attach",value:function(){var t=this.nav.options.Sync;t&&(g(t)&&"object"===e(t.with)&&(this.sync=t.with),this.sync&&this.nav.on("ready",this.onNavReady))}},{key:"detach",value:function(){this.sync&&(this.nav.off("ready",this.onNavReady),this.nav.off("createSlide",this.onNavCreate),this.sync.off("change",this.onTargetChange)),this.nav.Panzoom.off("click",this.onNavClick),this.sync=null,this.selectedIndex=null}}]),t}();M.defaults={friction:.92};var C={Navigation:D,Dots:E,Sync:M},T={slides:[],preload:0,slidesPerPage:"auto",initialPage:0,friction:.92,center:!0,infinite:!0,fill:!0,dragFree:!1,classNames:{viewport:"carousel__viewport",track:"carousel__track",slide:"carousel__slide",slideSelected:"is-selected"},l10n:{NEXT:"Next slide",PREV:"Previous slide",GOTO:"Go to slide %d"}},A=function(t){o(n,t);var e=c(n);function n(t){var s,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return i(this,n),o=m(!0,{},T,o),(s=e.call(this,o)).state="init",s.$element=t,t.Carousel=l(s),s.page=s.pageIndex=null,s.prevPage=s.prevPageIndex=null,s.slideNext=S(s.slideNext.bind(l(s)),250),s.slidePrev=S(s.slidePrev.bind(l(s)),250),s.attachPlugins(n.Plugins),s.trigger("init"),s.initLayout(),s.initSlides(),s.initPanzoom(),s.state="ready",s.trigger("ready"),s}return s(n,[{key:"initLayout",value:function(){if(!(this.$element instanceof HTMLElement))throw new Error("No root element provided");var t,e,i=this.option("classNames");(this.$viewport=this.option("viewport")||this.$element.querySelector("."+i.viewport),this.$viewport)||(this.$viewport=document.createElement("div"),this.$viewport.classList.add(i.viewport),(t=this.$viewport).append.apply(t,u(this.$element.childNodes)),this.$element.appendChild(this.$viewport));(this.$track=this.option("track")||this.$element.querySelector("."+i.track),this.$track)||(this.$track=document.createElement("div"),this.$track.classList.add(i.track),(e=this.$track).append.apply(e,u(this.$viewport.childNodes)),this.$viewport.appendChild(this.$track))}},{key:"initSlides",value:function(){var t=this;this.slides=[],this.$viewport.querySelectorAll("."+this.option("classNames.slide")).forEach((function(e){var i={$el:e,isDom:!0};t.slides.push(i),t.trigger("createSlide",i,t.slides.length)})),Array.isArray(this.options.slides)&&(this.slides=m(!0,u(this.slides),this.options.slides))}},{key:"updatePage",value:function(){var t=this.page;null===t&&(t=this.page=this.option("initialPage")),this.updateMetrics();var e=this.pages;e[t]||(t=e.length?e[e.length-1].index:0),this.slideTo(t,{friction:0})}},{key:"updateBounds",value:function(){var t=this.Panzoom,e=this.option("infinite"),i=this.option("infiniteX",e),n=this.option("infiniteY",e);i&&(t.boundX=null),n&&(t.boundY=null),i||n||(t.boundX={from:-1*this.pages[this.pages.length-1].left,to:-1*this.pages[0].left})}},{key:"initPanzoom",value:function(){var t=this,e=m(!0,{},{content:this.$track,click:!1,doubleClick:!1,wheel:!1,pinchToZoom:!1,lockAxis:"x",textSelection:function(){return t.option("textSelection",!1)},panOnlyZoomed:function(){return t.option("panOnlyZoomed",t.elemDimWidth<t.wrapDimWidth)},on:{"*":function(e){for(var i=arguments.length,n=new Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];return t.trigger.apply(t,["Panzoom.".concat(e)].concat(n))},init:function(e){return t.Panzoom=e},updateMetrics:function(){t.updatePage()},updateBounds:function(){t.updateBounds()},beforeTransform:this.onBeforeTransform.bind(this),afterAnimate:this.onAfterAnimate.bind(this),touchEnd:this.onTouchEnd.bind(this)}},this.option("Panzoom"));new $(this.$viewport,e)}},{key:"onBeforeTransform",value:function(){this.option("infiniteX",this.option("infinite"))&&this.manageInfiniteTrack(),this.manageSlideVisiblity()}},{key:"onAfterAnimate",value:function(t,e){e||this.trigger("settle")}},{key:"onTouchEnd",value:function(t){var e=this.option("dragFree");if(!e&&this.pages.length>1&&t.drag.elapsedTime<350&&Math.abs(t.drag.distanceY)<1&&Math.abs(t.drag.distanceX)>5)this[t.drag.distanceX<0?"slideNext":"slidePrev"]();else if(e){var i=d(this.getPageFromPosition(-1*this.Panzoom.pan.x),2)[1];this.setPage(i)}else this.slideToClosest()}},{key:"manageInfiniteTrack",value:function(){if(!(!this.option("infiniteX",this.option("infinite"))||this.pages.length<2||this.elemDimWidth<this.wrapDimWidth)){var t=this.Panzoom,e=!1;return t.current.x<-1*(t.contentDim.width-t.viewportDim.width)&&(t.current.x+=t.contentDim.width,t.drag.firstPosition&&(t.drag.firstPosition.x+=t.contentDim.width),this.pageIndex=this.pageIndex-this.pages.length,e=!0),t.current.x>t.viewportDim.width&&(t.current.x-=t.contentDim.width,t.drag.firstPosition&&(t.drag.firstPosition.x-=t.contentDim.width),this.pageIndex=this.pageIndex+this.pages.length,e=!0),e&&"dragging"===t.state&&t.resetDragState(),e}}},{key:"manageSlideVisiblity",value:function(){var t=this,e=this.elemDimWidth,i=this.wrapDimWidth,n=-1*this.Panzoom.current.x;Math.abs(n)<.1&&(n=0);var s=this.option("preload"),o=this.option("infiniteX",this.option("infinite")),r=parseFloat(window.getComputedStyle(this.$viewport,null).getPropertyValue("padding-left")),a=parseFloat(window.getComputedStyle(this.$viewport,null).getPropertyValue("padding-right"));this.slides.forEach((function(l){var h,c,d=0;h=n-r,c=n+i+a,h-=s*(i+r+a),c+=s*(i+r+a);var u=l.left+l.width>h&&l.left<c;h=n+e-r,c=n+e+i+a,h-=s*(i+r+a);var p=o&&l.left+l.width>h&&l.left<c;h=n-e-r,c=n-e+i+a,h-=s*(i+r+a);var f=o&&l.left+l.width>h&&l.left<c;p||u||f?(t.createSlideEl(l),u&&(d=0),p&&(d=-1),f&&(d=1),l.left+l.width>n&&l.left<=n+i+a&&(d=0)):t.removeSlideEl(l),l.hasDiff=d}));var l=0,h=0;this.slides.forEach((function(t,i){var n=0;t.$el?(i!==l||t.hasDiff?n=h+t.hasDiff*e:h=0,t.$el.style.left=Math.abs(n)>.1?"".concat(h+t.hasDiff*e,"px"):"",l++):h+=t.width})),this.Panzoom.viewportDim.height=this.Panzoom.$content.clientHeight,this.markSelectedSlides()}},{key:"markSelectedSlides",value:function(){var t=this,e=this.option("classNames.slideSelected"),i="aria-hidden";this.slides.forEach((function(n,s){var o=n.$el;if(o){var r=t.pages[t.page];r&&r.indexes&&r.indexes.indexOf(s)>-1?(e&&!o.classList.contains(e)&&(o.classList.add(e),t.trigger("selectSlide",n)),o.removeAttribute(i)):(e&&o.classList.contains(e)&&(o.classList.remove(e),t.trigger("unselectSlide",n)),o.setAttribute(i,!0))}}))}},{key:"createSlideEl",value:function(t){if(t){if(!t.$el){var e,i=document.createElement("div");if(i.dataset.index=t.index,i.classList.add(this.option("classNames.slide")),t.customClass)(e=i.classList).add.apply(e,u(t.customClass.split(" ")));t.html&&(i.innerHTML=t.html);var n=[];this.slides.forEach((function(t,e){t.$el&&n.push(e)}));var s=t.index,o=null;if(n.length){var r=n.reduce((function(t,e){return Math.abs(e-s)<Math.abs(t-s)?e:t}));o=this.slides[r]}return this.$track.insertBefore(i,o&&o.$el?o.index<t.index?o.$el.nextSibling:o.$el:null),t.$el=i,this.trigger("createSlide",t,s),t}var a;parseInt(t.$el.dataset.index,10)!==t.index&&(t.$el.dataset.index=t.index,t.$el.querySelectorAll("[data-lazy-src]").forEach((function(t){var e=t.dataset.lazySrc;t instanceof HTMLImageElement?t.src=e:t.style.backgroundImage="url('".concat(e,"')")})),(a=t.$el.dataset.lazySrc)&&(t.$el.style.backgroundImage="url('".concat(a,"')")),t.state="ready")}}},{key:"getSlideMetrics",value:function(t){if(!t){var e,i=this.slides[0];if((t=document.createElement("div")).dataset.isTestEl=1,t.style.visibility="hidden",t.classList.add(this.option("classNames.slide")),i.customClass)(e=t.classList).add.apply(e,u(i.customClass.split(" ")));this.$track.prepend(t)}var n=y(t.getBoundingClientRect().width),s=t.currentStyle||window.getComputedStyle(t);return n=n+(parseFloat(s.marginLeft)||0)+(parseFloat(s.marginRight)||0),window.visualViewport&&(n*=window.visualViewport.scale),t.dataset.isTestEl&&t.remove(),n}},{key:"updateMetrics",value:function(){var t,e=this,i=0,n=[];this.slides.forEach((function(s,o){var r=s.$el,a=s.isDom||!t?e.getSlideMetrics(r):t;s.index=o,s.width=a,s.left=i,t=a,i+=a,n.push(o)})),this.elemDimWidth=y(i),this.Panzoom.contentDim.width=this.elemDimWidth,this.wrapDimWidth=y(this.$viewport.getBoundingClientRect().width);var s=window.getComputedStyle(this.$viewport),o=parseFloat(s.paddingLeft)+parseFloat(s.paddingRight);this.wrapDimWidth=this.wrapDimWidth-o,window.visualViewport&&(this.wrapDimWidth*=window.visualViewport.scale),this.Panzoom.viewportDim.width=this.wrapDimWidth;var r=[],a=this.option("slidesPerPage");if(Number.isInteger(a)&&this.elemDimWidth>this.wrapDimWidth)for(var l=0;l<this.slides.length;l+=a)r.push({indexes:n.slice(l,l+a),slides:this.slides.slice(l,l+a)});else for(var h=0,c=0,d=0;d<this.slides.length;d+=1){var p=this.slides[d];(!r.length||c+p.width>this.wrapDimWidth)&&(r.push({indexes:[],slides:[]}),h=r.length-1,c=0),c+=p.width,r[h].indexes.push(d),r[h].slides.push(p)}var f=this.option("center"),v=this.option("fill");r.forEach((function(t,i){t.index=i,t.width=t.slides.reduce((function(t,e){return t+e.width}),0),t.left=t.slides[0].left,f&&(t.left+=.5*(e.wrapDimWidth-t.width)*-1),v&&!e.option("infiniteX",e.option("infinite"))&&e.elemDimWidth>e.wrapDimWidth&&(t.left=Math.max(t.left,0),t.left=Math.min(t.left,e.elemDimWidth-e.wrapDimWidth))}));var g,m=[];r.forEach((function(t){g&&t.left===g.left?(g.width+=t.width,g.slides=[].concat(u(g.slides),u(t.slides)),g.indexes=[].concat(u(g.indexes),u(t.indexes))):(t.index=m.length,g=t,m.push(t))})),this.pages=m,this.manageSlideVisiblity(),this.trigger("refresh")}},{key:"setPage",value:function(t,e){var i=0,n=parseInt(t,10)||0,s=this.page,o=this.pageIndex,r=this.pages.length;if(t=(n%r+r)%r,this.option("infiniteX",this.option("infinite"))&&this.elemDimWidth>this.wrapDimWidth){var a=Math.floor(n/r)||0,l=this.elemDimWidth;if(i=this.pages[t].left+a*l,!0===e&&r>2){var h=-1*this.Panzoom.current.x,c=i-l,d=i+l,u=Math.abs(h-i),p=Math.abs(h-c),f=Math.abs(h-d);f<u&&f<=p?(i=d,n+=r):p<u&&p<f&&(i=c,n-=r)}}else t=n=Math.max(0,Math.min(n,r-1)),i=this.pages[t].left;return this.page=t,this.pageIndex=n,null!==s&&t!==s&&(this.prevPage=s,this.prevPageIndex=o,this.trigger("change",t,s)),i}},{key:"slideTo",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.friction,n=void 0===i?this.option("friction"):i;this.Panzoom.panTo({x:-1*this.setPage(t,!0),y:0,friction:n})}},{key:"slideToClosest",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.getPageFromPosition(-1*this.Panzoom.pan.x),i=d(e,2),n=i[1];this.slideTo(n,t)}},{key:"slideNext",value:function(){this.slideTo(this.pageIndex+1)}},{key:"slidePrev",value:function(){this.slideTo(this.pageIndex-1)}},{key:"getPageforSlide",value:function(t){var e=this.pages.find((function(e){return e.indexes.indexOf(t)>-1}));return e?e.index:null}},{key:"getPageFromPosition",value:function(t){var e=this.pages.length;this.option("center")&&(t+=.5*this.wrapDimWidth);var i=Math.floor(t/this.elemDimWidth);t-=i*this.elemDimWidth;var n=this.slides.find((function(e){return e.left<t&&e.left+e.width>t}));if(n){var s=this.getPageforSlide(n.index);return[s,s+i*e]}return[0,0]}},{key:"removeSlideEl",value:function(t){t.$el&&!t.isDom&&(this.trigger("deleteSlide",t),t.$el.remove(),t.$el=null)}},{key:"destroy",value:function(){var t=this;this.state="destroy",this.slides.forEach((function(e){t.removeSlideEl(e)})),this.Panzoom.destroy(),this.options={},this.events={}}}]),n}(P);A.version="4.0.0-alpha.2",A.Plugins=C,t.Carousel=A,t.Panzoom=$}));