viewer.common.min.js 43 KB

1
  1. "use strict";function ownKeys(e,t){var i,n=Object.keys(e);return Object.getOwnPropertySymbols&&(i=Object.getOwnPropertySymbols(e),t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)),n}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(i),!0).forEach(function(t){_defineProperty(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function _typeof(t){return(_typeof="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 _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(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 _createClass(t,e,i){return e&&_defineProperties(t.prototype,e),i&&_defineProperties(t,i),t}function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var DEFAULTS={backdrop:!0,button:!0,navbar:!0,title:!0,toolbar:!0,className:"",container:"body",filter:null,fullscreen:!0,inheritedAttributes:["crossOrigin","decoding","isMap","loading","referrerPolicy","sizes","srcset","useMap"],initialViewIndex:0,inline:!1,interval:5e3,keyboard:!0,focus:!0,loading:!0,loop:!0,minWidth:200,minHeight:100,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,slideOnTouch:!0,toggleOnDblclick:!0,tooltip:!0,transition:!0,zIndex:2015,zIndexInline:0,zoomRatio:.1,minZoomRatio:.01,maxZoomRatio:100,url:"src",ready:null,show:null,shown:null,hide:null,hidden:null,view:null,viewed:null,move:null,moved:null,rotate:null,rotated:null,scale:null,scaled:null,zoom:null,zoomed:null,play:null,stop:null},TEMPLATE='<div class="viewer-container" tabindex="-1" touch-action="none"><div class="viewer-canvas"></div><div class="viewer-footer"><div class="viewer-title"></div><div class="viewer-toolbar"></div><div class="viewer-navbar"><ul class="viewer-list" role="navigation"></ul></div></div><div class="viewer-tooltip" role="alert" aria-hidden="true"></div><div class="viewer-button" data-viewer-action="mix" role="button"></div><div class="viewer-player"></div></div>',IS_BROWSER="undefined"!=typeof window&&void 0!==window.document,WINDOW=IS_BROWSER?window:{},IS_TOUCH_DEVICE=!(!IS_BROWSER||!WINDOW.document.documentElement)&&"ontouchstart"in WINDOW.document.documentElement,HAS_POINTER_EVENT=!!IS_BROWSER&&"PointerEvent"in WINDOW,NAMESPACE="viewer",ACTION_MOVE="move",ACTION_SWITCH="switch",ACTION_ZOOM="zoom",CLASS_ACTIVE="".concat(NAMESPACE,"-active"),CLASS_CLOSE="".concat(NAMESPACE,"-close"),CLASS_FADE="".concat(NAMESPACE,"-fade"),CLASS_FIXED="".concat(NAMESPACE,"-fixed"),CLASS_FULLSCREEN="".concat(NAMESPACE,"-fullscreen"),CLASS_FULLSCREEN_EXIT="".concat(NAMESPACE,"-fullscreen-exit"),CLASS_HIDE="".concat(NAMESPACE,"-hide"),CLASS_HIDE_MD_DOWN="".concat(NAMESPACE,"-hide-md-down"),CLASS_HIDE_SM_DOWN="".concat(NAMESPACE,"-hide-sm-down"),CLASS_HIDE_XS_DOWN="".concat(NAMESPACE,"-hide-xs-down"),CLASS_IN="".concat(NAMESPACE,"-in"),CLASS_INVISIBLE="".concat(NAMESPACE,"-invisible"),CLASS_LOADING="".concat(NAMESPACE,"-loading"),CLASS_MOVE="".concat(NAMESPACE,"-move"),CLASS_OPEN="".concat(NAMESPACE,"-open"),CLASS_SHOW="".concat(NAMESPACE,"-show"),CLASS_TRANSITION="".concat(NAMESPACE,"-transition"),EVENT_CLICK="click",EVENT_DBLCLICK="dblclick",EVENT_DRAG_START="dragstart",EVENT_FOCUSIN="focusin",EVENT_KEY_DOWN="keydown",EVENT_LOAD="load",EVENT_ERROR="error",EVENT_TOUCH_END=IS_TOUCH_DEVICE?"touchend touchcancel":"mouseup",EVENT_TOUCH_MOVE=IS_TOUCH_DEVICE?"touchmove":"mousemove",EVENT_TOUCH_START=IS_TOUCH_DEVICE?"touchstart":"mousedown",EVENT_POINTER_DOWN=HAS_POINTER_EVENT?"pointerdown":EVENT_TOUCH_START,EVENT_POINTER_MOVE=HAS_POINTER_EVENT?"pointermove":EVENT_TOUCH_MOVE,EVENT_POINTER_UP=HAS_POINTER_EVENT?"pointerup pointercancel":EVENT_TOUCH_END,EVENT_RESIZE="resize",EVENT_TRANSITION_END="transitionend",EVENT_WHEEL="wheel",EVENT_READY="ready",EVENT_SHOW="show",EVENT_SHOWN="shown",EVENT_HIDE="hide",EVENT_HIDDEN="hidden",EVENT_VIEW="view",EVENT_VIEWED="viewed",EVENT_MOVE="move",EVENT_MOVED="moved",EVENT_ROTATE="rotate",EVENT_ROTATED="rotated",EVENT_SCALE="scale",EVENT_SCALED="scaled",EVENT_ZOOM="zoom",EVENT_ZOOMED="zoomed",EVENT_PLAY="play",EVENT_STOP="stop",DATA_ACTION="".concat(NAMESPACE,"Action"),REGEXP_SPACES=/\s\s*/,BUTTONS=["zoom-in","zoom-out","one-to-one","reset","prev","play","next","rotate-left","rotate-right","flip-horizontal","flip-vertical"];function isString(t){return"string"==typeof t}var isNaN=Number.isNaN||WINDOW.isNaN;function isNumber(t){return"number"==typeof t&&!isNaN(t)}function isUndefined(t){return void 0===t}function isObject(t){return"object"===_typeof(t)&&null!==t}var hasOwnProperty=Object.prototype.hasOwnProperty;function isPlainObject(t){if(!isObject(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&hasOwnProperty.call(i,"isPrototypeOf")}catch(t){return!1}}function isFunction(t){return"function"==typeof t}function forEach(e,i){if(e&&isFunction(i))if(Array.isArray(e)||isNumber(e.length))for(var t=e.length,n=0;n<t&&!1!==i.call(e,e[n],n,e);n+=1);else isObject(e)&&Object.keys(e).forEach(function(t){i.call(e,e[t],t,e)});return e}var assign=Object.assign||function(i){for(var t=arguments.length,e=new Array(1<t?t-1:0),n=1;n<t;n++)e[n-1]=arguments[n];return isObject(i)&&0<e.length&&e.forEach(function(e){isObject(e)&&Object.keys(e).forEach(function(t){i[t]=e[t]})}),i},REGEXP_SUFFIX=/^(?:width|height|left|top|marginLeft|marginTop)$/;function setStyle(t,e){var i=t.style;forEach(e,function(t,e){REGEXP_SUFFIX.test(e)&&isNumber(t)&&(t+="px"),i[e]=t})}function escapeHTMLEntities(t){return isString(t)?t.replace(/&(?!amp;|quot;|#39;|lt;|gt;)/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):t}function hasClass(t,e){return!(!t||!e)&&(t.classList?t.classList.contains(e):-1<t.className.indexOf(e))}function addClass(t,e){var i;t&&e&&(isNumber(t.length)?forEach(t,function(t){addClass(t,e)}):t.classList?t.classList.add(e):(i=t.className.trim())?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e)}function removeClass(t,e){t&&e&&(isNumber(t.length)?forEach(t,function(t){removeClass(t,e)}):t.classList?t.classList.remove(e):0<=t.className.indexOf(e)&&(t.className=t.className.replace(e,"")))}function toggleClass(t,e,i){e&&(isNumber(t.length)?forEach(t,function(t){toggleClass(t,e,i)}):(i?addClass:removeClass)(t,e))}var REGEXP_HYPHENATE=/([a-z\d])([A-Z])/g;function hyphenate(t){return t.replace(REGEXP_HYPHENATE,"$1-$2").toLowerCase()}function getData(t,e){return isObject(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(hyphenate(e)))}function setData(t,e,i){isObject(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(hyphenate(e)),i)}var onceSupported=function(){var e,t,i,n=!1;return IS_BROWSER&&(e=!1,t=function(){},i=Object.defineProperty({},"once",{get:function(){return n=!0,e},set:function(t){e=t}}),WINDOW.addEventListener("test",t,i),WINDOW.removeEventListener("test",t,i)),n}();function removeListener(i,t,n){var s=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},a=n;t.trim().split(REGEXP_SPACES).forEach(function(t){var e;onceSupported||(e=i.listeners)&&e[t]&&e[t][n]&&(a=e[t][n],delete e[t][n],0===Object.keys(e[t]).length&&delete e[t],0===Object.keys(e).length&&delete i.listeners),i.removeEventListener(t,a,s)})}function addListener(a,t,o){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},l=o;t.trim().split(REGEXP_SPACES).forEach(function(n){var t,s;r.once&&!onceSupported&&(t=a.listeners,l=function(){delete s[n][o],a.removeEventListener(n,l,r);for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];o.apply(a,e)},(s=void 0===t?{}:t)[n]||(s[n]={}),s[n][o]&&a.removeEventListener(n,s[n][o],r),s[n][o]=l,a.listeners=s),a.addEventListener(n,l,r)})}function dispatchEvent(t,e,i,n){var s;return isFunction(Event)&&isFunction(CustomEvent)?s=new CustomEvent(e,_objectSpread2({bubbles:!0,cancelable:!0,detail:i},n)):(s=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i),t.dispatchEvent(s)}function getOffset(t){t=t.getBoundingClientRect();return{left:t.left+(window.pageXOffset-document.documentElement.clientLeft),top:t.top+(window.pageYOffset-document.documentElement.clientTop)}}function getTransforms(t){var e=t.rotate,i=t.scaleX,n=t.scaleY,s=t.translateX,a=t.translateY,t=[];isNumber(s)&&0!==s&&t.push("translateX(".concat(s,"px)")),isNumber(a)&&0!==a&&t.push("translateY(".concat(a,"px)")),isNumber(e)&&0!==e&&t.push("rotate(".concat(e,"deg)")),isNumber(i)&&1!==i&&t.push("scaleX(".concat(i,")")),isNumber(n)&&1!==n&&t.push("scaleY(".concat(n,")"));t=t.length?t.join(" "):"none";return{WebkitTransform:t,msTransform:t,transform:t}}function getImageNameFromURL(t){return isString(t)?decodeURIComponent(t.replace(/^.*\//,"").replace(/[?&#].*$/,"")):""}var IS_SAFARI=WINDOW.navigator&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(WINDOW.navigator.userAgent);function getImageNaturalSizes(i,t,e){var n=document.createElement("img");if(i.naturalWidth&&!IS_SAFARI)return e(i.naturalWidth,i.naturalHeight),n;var s=document.body||document.documentElement;return n.onload=function(){e(n.width,n.height),IS_SAFARI||s.removeChild(n)},forEach(t.inheritedAttributes,function(t){var e=i.getAttribute(t);null!==e&&n.setAttribute(t,e)}),n.src=i.src,IS_SAFARI||(n.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",s.appendChild(n)),n}function getResponsiveClass(t){switch(t){case 2:return CLASS_HIDE_XS_DOWN;case 3:return CLASS_HIDE_SM_DOWN;case 4:return CLASS_HIDE_MD_DOWN;default:return""}}function getMaxZoomRatio(t){var e=_objectSpread2({},t),a=[];return forEach(t,function(s,t){delete e[t],forEach(e,function(t){var e=Math.abs(s.startX-t.startX),i=Math.abs(s.startY-t.startY),n=Math.abs(s.endX-t.endX),t=Math.abs(s.endY-t.endY),i=Math.sqrt(e*e+i*i),t=Math.sqrt(n*n+t*t);a.push((t-i)/i)})}),a.sort(function(t,e){return Math.abs(t)<Math.abs(e)}),a[0]}function getPointer(t,e){var i=t.pageX,n=t.pageY,t={endX:i,endY:n};return e?t:_objectSpread2({timeStamp:Date.now(),startX:i,startY:n},t)}function getPointersCenter(t){var i=0,n=0,s=0;return forEach(t,function(t){var e=t.startX,t=t.startY;i+=e,n+=t,s+=1}),{pageX:i/=s,pageY:n/=s}}var render={render:function(){this.initContainer(),this.initViewer(),this.initList(),this.renderViewer()},initBody:function(){var t=this.element.ownerDocument,e=t.body||t.documentElement;this.body=e,this.scrollbarWidth=window.innerWidth-t.documentElement.clientWidth,this.initialBodyPaddingRight=e.style.paddingRight,this.initialBodyComputedPaddingRight=window.getComputedStyle(e).paddingRight},initContainer:function(){this.containerData={width:window.innerWidth,height:window.innerHeight}},initViewer:function(){var t,e=this.options,i=this.parent;e.inline&&(t={width:Math.max(i.offsetWidth,e.minWidth),height:Math.max(i.offsetHeight,e.minHeight)},this.parentData=t),!this.fulled&&t||(t=this.containerData),this.viewerData=assign({},t)},renderViewer:function(){this.options.inline&&!this.fulled&&setStyle(this.viewer,this.viewerData)},initList:function(){var r=this,t=this.element,l=this.options,h=this.list,c=[];h.innerHTML="",forEach(this.images,function(i,t){var e,n,s=i.src,a=i.alt||getImageNameFromURL(s),o=r.getImageURL(i);(s||o)&&(e=document.createElement("li"),n=document.createElement("img"),forEach(l.inheritedAttributes,function(t){var e=i.getAttribute(t);null!==e&&n.setAttribute(t,e)}),n.src=s||o,n.alt=a,n.setAttribute("data-original-url",o||s),e.setAttribute("data-index",t),e.setAttribute("data-viewer-action","view"),e.setAttribute("role","button"),l.keyboard&&e.setAttribute("tabindex",0),e.appendChild(n),h.appendChild(e),c.push(e))}),forEach(this.items=c,function(e){var t,i,n=e.firstElementChild;setData(n,"filled",!0),l.loading&&addClass(e,CLASS_LOADING),addListener(n,EVENT_LOAD,t=function(t){removeListener(n,EVENT_ERROR,i),l.loading&&removeClass(e,CLASS_LOADING),r.loadImage(t)},{once:!0}),addListener(n,EVENT_ERROR,i=function(){removeListener(n,EVENT_LOAD,t),l.loading&&removeClass(e,CLASS_LOADING)},{once:!0})}),l.transition&&addListener(t,EVENT_VIEWED,function(){addClass(h,CLASS_TRANSITION)},{once:!0})},renderList:function(){var t,e,i=this.index,n=this.items[i];n&&(e=n.nextElementSibling,t=parseInt(window.getComputedStyle(e||n).marginLeft,10),e=n.offsetWidth,setStyle(this.list,assign({width:(n=e+t)*this.length-t},getTransforms({translateX:(this.viewerData.width-e)/2-n*i}))))},resetList:function(){var t=this.list;t.innerHTML="",removeClass(t,CLASS_TRANSITION),setStyle(t,getTransforms({translateX:0}))},initImage:function(r){var t,l=this,h=this.options,e=this.image,i=this.viewerData,n=this.footer.offsetHeight,c=i.width,d=Math.max(i.height-n,n),u=this.imageData||{};this.imageInitializing={abort:function(){t.onload=null}},t=getImageNaturalSizes(e,h,function(t,e){var i=t/e,n=c,s=d;l.imageInitializing=!1,c<d*i?s=c/i:n=d*i;var n=Math.min(.9*n,t),s=Math.min(.9*s,e),a=(c-n)/2,o=(d-s)/2,t={left:a,top:o,x:a,y:o,width:n,height:s,oldRatio:1,ratio:n/t,aspectRatio:i,naturalWidth:t,naturalHeight:e},e=assign({},t);h.rotatable&&(t.rotate=u.rotate||0,e.rotate=0),h.scalable&&(t.scaleX=u.scaleX||1,t.scaleY=u.scaleY||1,e.scaleX=1,e.scaleY=1),l.imageData=t,l.initialImageData=e,r&&r()})},renderImage:function(t){var e,i=this,n=this.image,s=this.imageData;setStyle(n,assign({width:s.width,height:s.height,marginLeft:s.x,marginTop:s.y},getTransforms(s))),t&&((this.viewing||this.moving||this.rotating||this.scaling||this.zooming)&&this.options.transition&&hasClass(n,CLASS_TRANSITION)?(e=function(){i.imageRendering=!1,t()},this.imageRendering={abort:function(){removeListener(n,EVENT_TRANSITION_END,e)}},addListener(n,EVENT_TRANSITION_END,e,{once:!0})):t())},resetImage:function(){var t;(this.viewing||this.viewed)&&(t=this.image,this.viewing&&this.viewing.abort(),t.parentNode.removeChild(t),this.image=null)}},events={bind:function(){var t=this.options,e=this.viewer,i=this.canvas,n=this.element.ownerDocument;addListener(e,EVENT_CLICK,this.onClick=this.click.bind(this)),addListener(e,EVENT_DRAG_START,this.onDragStart=this.dragstart.bind(this)),addListener(i,EVENT_POINTER_DOWN,this.onPointerDown=this.pointerdown.bind(this)),addListener(n,EVENT_POINTER_MOVE,this.onPointerMove=this.pointermove.bind(this)),addListener(n,EVENT_POINTER_UP,this.onPointerUp=this.pointerup.bind(this)),addListener(n,EVENT_KEY_DOWN,this.onKeyDown=this.keydown.bind(this)),addListener(window,EVENT_RESIZE,this.onResize=this.resize.bind(this)),t.zoomable&&t.zoomOnWheel&&addListener(e,EVENT_WHEEL,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),t.toggleOnDblclick&&addListener(i,EVENT_DBLCLICK,this.onDblclick=this.dblclick.bind(this))},unbind:function(){var t=this.options,e=this.viewer,i=this.canvas,n=this.element.ownerDocument;removeListener(e,EVENT_CLICK,this.onClick),removeListener(e,EVENT_DRAG_START,this.onDragStart),removeListener(i,EVENT_POINTER_DOWN,this.onPointerDown),removeListener(n,EVENT_POINTER_MOVE,this.onPointerMove),removeListener(n,EVENT_POINTER_UP,this.onPointerUp),removeListener(n,EVENT_KEY_DOWN,this.onKeyDown),removeListener(window,EVENT_RESIZE,this.onResize),t.zoomable&&t.zoomOnWheel&&removeListener(e,EVENT_WHEEL,this.onWheel,{passive:!1,capture:!0}),t.toggleOnDblclick&&removeListener(i,EVENT_DBLCLICK,this.onDblclick)}},handlers={click:function(t){var e=this.options,i=this.imageData,n=t.target,s=getData(n,DATA_ACTION);switch(s||"img"!==n.localName||"li"!==n.parentElement.localName||(s=getData(n=n.parentElement,DATA_ACTION)),IS_TOUCH_DEVICE&&t.isTrusted&&n===this.canvas&&clearTimeout(this.clickCanvasTimeout),s){case"mix":this.played?this.stop():e.inline?this.fulled?this.exit():this.full():this.hide();break;case"hide":this.hide();break;case"view":this.view(getData(n,"index"));break;case"zoom-in":this.zoom(.1,!0);break;case"zoom-out":this.zoom(-.1,!0);break;case"one-to-one":this.toggle();break;case"reset":this.reset();break;case"prev":this.prev(e.loop);break;case"play":this.play(e.fullscreen);break;case"next":this.next(e.loop);break;case"rotate-left":this.rotate(-90);break;case"rotate-right":this.rotate(90);break;case"flip-horizontal":this.scaleX(-i.scaleX||-1);break;case"flip-vertical":this.scaleY(-i.scaleY||-1);break;default:this.played&&this.stop()}},dblclick:function(t){t.preventDefault(),this.viewed&&t.target===this.image&&(IS_TOUCH_DEVICE&&t.isTrusted&&clearTimeout(this.doubleClickImageTimeout),this.toggle(t))},load:function(){var t=this;this.timeout&&(clearTimeout(this.timeout),this.timeout=!1);var e=this.element,i=this.options,n=this.image,s=this.index,a=this.viewerData;removeClass(n,CLASS_INVISIBLE),i.loading&&removeClass(this.canvas,CLASS_LOADING),n.style.cssText="height:0;"+"margin-left:".concat(a.width/2,"px;")+"margin-top:".concat(a.height/2,"px;")+"max-width:none!important;position:relative;width:0;",this.initImage(function(){toggleClass(n,CLASS_MOVE,i.movable),toggleClass(n,CLASS_TRANSITION,i.transition),t.renderImage(function(){t.viewed=!0,t.viewing=!1,isFunction(i.viewed)&&addListener(e,EVENT_VIEWED,i.viewed,{once:!0}),dispatchEvent(e,EVENT_VIEWED,{originalImage:t.images[s],index:s,image:n},{cancelable:!1})})})},loadImage:function(t){var n=t.target,t=n.parentNode,s=t.offsetWidth||30,a=t.offsetHeight||50,o=!!getData(n,"filled");getImageNaturalSizes(n,this.options,function(t,e){var i=t/e,t=s,e=a;s<a*i?o?t=a*i:e=s/i:o?e=s/i:t=a*i,setStyle(n,assign({width:t,height:e},getTransforms({translateX:(s-t)/2,translateY:(a-e)/2})))})},keydown:function(t){var e=this.options;if(e.keyboard){var i=t.keyCode||t.which||t.charCode;if(13===i&&this.viewer.contains(t.target)&&this.click(t),this.fulled)switch(i){case 27:this.played?this.stop():e.inline?this.fulled&&this.exit():this.hide();break;case 32:this.played&&this.stop();break;case 37:this.prev(e.loop);break;case 38:t.preventDefault(),this.zoom(e.zoomRatio,!0);break;case 39:this.next(e.loop);break;case 40:t.preventDefault(),this.zoom(-e.zoomRatio,!0);break;case 48:case 49:t.ctrlKey&&(t.preventDefault(),this.toggle())}}},dragstart:function(t){"img"===t.target.localName&&t.preventDefault()},pointerdown:function(t){var e=this.options,i=this.pointers,n=t.buttons,s=t.button;!this.viewed||this.showing||this.viewing||this.hiding||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(isNumber(n)&&1!==n||isNumber(s)&&0!==s||t.ctrlKey)||(t.preventDefault(),t.changedTouches?forEach(t.changedTouches,function(t){i[t.identifier]=getPointer(t)}):i[t.pointerId||0]=getPointer(t),s=!!e.movable&&ACTION_MOVE,e.zoomOnTouch&&e.zoomable&&1<Object.keys(i).length?s=ACTION_ZOOM:e.slideOnTouch&&("touch"===t.pointerType||"touchstart"===t.type)&&this.isSwitchable()&&(s=ACTION_SWITCH),!e.transition||s!==ACTION_MOVE&&s!==ACTION_ZOOM||removeClass(this.image,CLASS_TRANSITION),this.action=s)},pointermove:function(t){var e=this.pointers,i=this.action;this.viewed&&i&&(t.preventDefault(),t.changedTouches?forEach(t.changedTouches,function(t){assign(e[t.identifier]||{},getPointer(t,!0))}):assign(e[t.pointerId||0]||{},getPointer(t,!0)),this.change(t))},pointerup:function(t){var e,i=this,n=this.options,s=this.action,a=this.pointers;t.changedTouches?forEach(t.changedTouches,function(t){e=a[t.identifier],delete a[t.identifier]}):(e=a[t.pointerId||0],delete a[t.pointerId||0]),s&&(t.preventDefault(),!n.transition||s!==ACTION_MOVE&&s!==ACTION_ZOOM||addClass(this.image,CLASS_TRANSITION),this.action=!1,IS_TOUCH_DEVICE&&s!==ACTION_ZOOM&&e&&Date.now()-e.timeStamp<500&&(clearTimeout(this.clickCanvasTimeout),clearTimeout(this.doubleClickImageTimeout),n.toggleOnDblclick&&this.viewed&&t.target===this.image?this.imageClicked?(this.imageClicked=!1,this.doubleClickImageTimeout=setTimeout(function(){dispatchEvent(i.image,EVENT_DBLCLICK)},50)):(this.imageClicked=!0,this.doubleClickImageTimeout=setTimeout(function(){i.imageClicked=!1},500)):(this.imageClicked=!1,n.backdrop&&"static"!==n.backdrop&&t.target===this.canvas&&(this.clickCanvasTimeout=setTimeout(function(){dispatchEvent(i.canvas,EVENT_CLICK)},50)))))},resize:function(){var e=this;this.isShown&&!this.hiding&&(this.fulled&&(this.close(),this.initBody(),this.open()),this.initContainer(),this.initViewer(),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){e.renderImage()}),this.played&&(!this.options.fullscreen||!this.fulled||document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement?forEach(this.player.getElementsByTagName("img"),function(t){addListener(t,EVENT_LOAD,e.loadImage.bind(e),{once:!0}),dispatchEvent(t,EVENT_LOAD)}):this.stop()))},wheel:function(t){var e,i,n=this;this.viewed&&(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(function(){n.wheeling=!1},50),e=Number(this.options.zoomRatio)||.1,i=1,t.deltaY?i=0<t.deltaY?1:-1:t.wheelDelta?i=-t.wheelDelta/120:t.detail&&(i=0<t.detail?1:-1),this.zoom(-i*e,!0,t)))}},methods={show:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=this.element,i=this.options;if(i.inline||this.showing||this.isShown||this.showing)return this;if(!this.ready)return this.build(),this.ready&&this.show(t),this;if(isFunction(i.show)&&addListener(e,EVENT_SHOW,i.show,{once:!0}),!1===dispatchEvent(e,EVENT_SHOW)||!this.ready)return this;this.hiding&&this.transitioning.abort(),this.showing=!0,this.open();var n,s=this.viewer;return removeClass(s,CLASS_HIDE),s.setAttribute("role","dialog"),s.setAttribute("aria-labelledby",this.title.id),s.setAttribute("aria-modal",!0),s.removeAttribute("aria-hidden"),i.transition&&!t?(n=this.shown.bind(this),this.transitioning={abort:function(){removeListener(s,EVENT_TRANSITION_END,n),removeClass(s,CLASS_IN)}},addClass(s,CLASS_TRANSITION),s.initialOffsetWidth=s.offsetWidth,addListener(s,EVENT_TRANSITION_END,n,{once:!0}),addClass(s,CLASS_IN)):(addClass(s,CLASS_IN),this.shown()),this},hide:function(){var i=this,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=this.element,n=this.options;if(n.inline||this.hiding||!this.isShown&&!this.showing)return this;if(isFunction(n.hide)&&addListener(e,EVENT_HIDE,n.hide,{once:!0}),!1===dispatchEvent(e,EVENT_HIDE))return this;this.showing&&this.transitioning.abort(),this.hiding=!0,this.played?this.stop():this.viewing&&this.viewing.abort();var s,a,o=this.viewer,r=this.image,l=function(){removeClass(o,CLASS_IN),i.hidden()};return n.transition&&!t?(s=function t(e){e&&e.target===o&&(removeListener(o,EVENT_TRANSITION_END,t),i.hidden())},a=function(){hasClass(o,CLASS_TRANSITION)?(addListener(o,EVENT_TRANSITION_END,s),removeClass(o,CLASS_IN)):l()},this.transitioning={abort:function(){i.viewed&&hasClass(r,CLASS_TRANSITION)?removeListener(r,EVENT_TRANSITION_END,a):hasClass(o,CLASS_TRANSITION)&&removeListener(o,EVENT_TRANSITION_END,s)}},this.viewed&&hasClass(r,CLASS_TRANSITION)?(addListener(r,EVENT_TRANSITION_END,a,{once:!0}),this.zoomTo(0,!1,null,!0)):a()):l(),this},view:function(){var i=this,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.options.initialViewIndex,t=Number(t)||0;if(this.hiding||this.played||t<0||t>=this.length||this.viewed&&t===this.index)return this;if(!this.isShown)return this.index=t,this.show();this.viewing&&this.viewing.abort();var e=this.element,n=this.options,s=this.title,a=this.canvas,o=this.items[t],r=o.querySelector("img"),l=getData(r,"originalUrl"),h=r.getAttribute("alt"),c=document.createElement("img");if(forEach(n.inheritedAttributes,function(t){var e=r.getAttribute(t);null!==e&&c.setAttribute(t,e)}),c.src=l,c.alt=h,isFunction(n.view)&&addListener(e,EVENT_VIEW,n.view,{once:!0}),!1===dispatchEvent(e,EVENT_VIEW,{originalImage:this.images[t],index:t,image:c})||!this.isShown||this.hiding||this.played)return this;l=this.items[this.index];l&&(removeClass(l,CLASS_ACTIVE),l.removeAttribute("aria-selected")),addClass(o,CLASS_ACTIVE),o.setAttribute("aria-selected",!0),n.focus&&o.focus(),this.image=c,this.viewed=!1,this.index=t,this.imageData={},addClass(c,CLASS_INVISIBLE),n.loading&&addClass(a,CLASS_LOADING),a.innerHTML="",a.appendChild(c),this.renderList(),s.innerHTML="";function d(){var t=i.imageData,e=Array.isArray(n.title)?n.title[1]:n.title;s.innerHTML=escapeHTMLEntities(isFunction(e)?e.call(i,c,t):"".concat(h," (").concat(t.naturalWidth," × ").concat(t.naturalHeight,")"))}var u,E;return addListener(e,EVENT_VIEWED,d,{once:!0}),this.viewing={abort:function(){removeListener(e,EVENT_VIEWED,d),c.complete?i.imageRendering?i.imageRendering.abort():i.imageInitializing&&i.imageInitializing.abort():(c.src="",removeListener(c,EVENT_LOAD,u),i.timeout&&clearTimeout(i.timeout))}},c.complete?this.load():(addListener(c,EVENT_LOAD,u=function(){removeListener(c,EVENT_ERROR,E),i.load()},{once:!0}),addListener(c,EVENT_ERROR,E=function(){removeListener(c,EVENT_LOAD,u),i.timeout&&(clearTimeout(i.timeout),i.timeout=!1),removeClass(c,CLASS_INVISIBLE),n.loading&&removeClass(i.canvas,CLASS_LOADING)},{once:!0}),this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(function(){removeClass(c,CLASS_INVISIBLE),i.timeout=!1},1e3)),this},prev:function(){var t=this.index-1;return t<0&&(t=0<arguments.length&&void 0!==arguments[0]&&arguments[0]?this.length-1:0),this.view(t),this},next:function(){var t=this.length-1,e=this.index+1;return this.view(e=t<e?0<arguments.length&&void 0!==arguments[0]&&arguments[0]?0:t:e),this},move:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData;return this.moveTo(isUndefined(t)?t:i.x+Number(t),isUndefined(e)?e:i.y+Number(e)),this},moveTo:function(t){var e=this,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,s=this.element,a=this.options,o=this.imageData;if(t=Number(t),i=Number(i),this.viewed&&!this.played&&a.movable){var r=o.x,l=o.y,h=!1;if(isNumber(t)?h=!0:t=r,isNumber(i)?h=!0:i=l,h){if(isFunction(a.move)&&addListener(s,EVENT_MOVE,a.move,{once:!0}),!1===dispatchEvent(s,EVENT_MOVE,{x:t,y:i,oldX:r,oldY:l,originalEvent:n}))return this;o.x=t,o.y=i,o.left=t,o.top=i,this.moving=!0,this.renderImage(function(){e.moving=!1,isFunction(a.moved)&&addListener(s,EVENT_MOVED,a.moved,{once:!0}),dispatchEvent(s,EVENT_MOVED,{x:t,y:i,oldX:r,oldY:l,originalEvent:n},{cancelable:!1})})}}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t)),this},rotateTo:function(t){var e=this,i=this.element,n=this.options,s=this.imageData;if(isNumber(t=Number(t))&&this.viewed&&!this.played&&n.rotatable){var a=s.rotate;if(isFunction(n.rotate)&&addListener(i,EVENT_ROTATE,n.rotate,{once:!0}),!1===dispatchEvent(i,EVENT_ROTATE,{degree:t,oldDegree:a}))return this;s.rotate=t,this.rotating=!0,this.renderImage(function(){e.rotating=!1,isFunction(n.rotated)&&addListener(i,EVENT_ROTATED,n.rotated,{once:!0}),dispatchEvent(i,EVENT_ROTATED,{degree:t,oldDegree:a},{cancelable:!1})})}return this},scaleX:function(t){return this.scale(t,this.imageData.scaleY),this},scaleY:function(t){return this.scale(this.imageData.scaleX,t),this},scale:function(t){var e=this,i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,n=this.element,s=this.options,a=this.imageData;if(t=Number(t),i=Number(i),this.viewed&&!this.played&&s.scalable){var o=a.scaleX,r=a.scaleY,l=!1;if(isNumber(t)?l=!0:t=o,isNumber(i)?l=!0:i=r,l){if(isFunction(s.scale)&&addListener(n,EVENT_SCALE,s.scale,{once:!0}),!1===dispatchEvent(n,EVENT_SCALE,{scaleX:t,scaleY:i,oldScaleX:o,oldScaleY:r}))return this;a.scaleX=t,a.scaleY=i,this.scaling=!0,this.renderImage(function(){e.scaling=!1,isFunction(s.scaled)&&addListener(n,EVENT_SCALED,s.scaled,{once:!0}),dispatchEvent(n,EVENT_SCALED,{scaleX:t,scaleY:i,oldScaleX:o,oldScaleY:r},{cancelable:!1})})}}return this},zoom:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=this.imageData;return t=Number(t),this.zoomTo(n.width*(t=t<0?1/(1-t):1+t)/n.naturalWidth,e,i),this},zoomTo:function(t){var e=this,i=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,s=3<arguments.length&&void 0!==arguments[3]&&arguments[3],a=this.element,o=this.options,r=this.pointers,l=this.imageData,h=l.x,c=l.y,d=l.width,u=l.height,E=l.naturalWidth,m=l.naturalHeight;if(isNumber(t=Math.max(0,t))&&this.viewed&&!this.played&&(s||o.zoomable)){s||(g=Math.max(.01,o.minZoomRatio),v=Math.min(100,o.maxZoomRatio),t=Math.min(Math.max(t,g),v));var s=E*(t=n&&.055<=o.zoomRatio&&.95<t&&t<1.05?1:t),g=m*t,v=s-d,E=g-u,S=l.ratio;if(isFunction(o.zoom)&&addListener(a,EVENT_ZOOM,o.zoom,{once:!0}),!1===dispatchEvent(a,EVENT_ZOOM,{ratio:t,oldRatio:S,originalEvent:n}))return this;this.zooming=!0,n?(m=getOffset(this.viewer),r=r&&Object.keys(r).length?getPointersCenter(r):{pageX:n.pageX,pageY:n.pageY},l.x-=v*((r.pageX-m.left-h)/d),l.y-=E*((r.pageY-m.top-c)/u)):(l.x-=v/2,l.y-=E/2),l.left=l.x,l.top=l.y,l.width=s,l.height=g,l.oldRatio=S,l.ratio=t,this.renderImage(function(){e.zooming=!1,isFunction(o.zoomed)&&addListener(a,EVENT_ZOOMED,o.zoomed,{once:!0}),dispatchEvent(a,EVENT_ZOOMED,{ratio:t,oldRatio:S,originalEvent:n},{cancelable:!1})}),i&&this.tooltip()}return this},play:function(){var e=this,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];if(!this.isShown||this.played)return this;var i=this.element,s=this.options;if(isFunction(s.play)&&addListener(i,EVENT_PLAY,s.play,{once:!0}),!1===dispatchEvent(i,EVENT_PLAY))return this;var a=this.player,o=this.loadImage.bind(this),r=[],l=0,h=0;return this.played=!0,this.onLoadWhenPlay=o,t&&this.requestFullscreen(t),addClass(a,CLASS_SHOW),forEach(this.items,function(t,e){var i=t.querySelector("img"),n=document.createElement("img");n.src=getData(i,"originalUrl"),n.alt=i.getAttribute("alt"),n.referrerPolicy=i.referrerPolicy,l+=1,addClass(n,CLASS_FADE),toggleClass(n,CLASS_TRANSITION,s.transition),hasClass(t,CLASS_ACTIVE)&&(addClass(n,CLASS_IN),h=e),r.push(n),addListener(n,EVENT_LOAD,o,{once:!0}),a.appendChild(n)}),isNumber(s.interval)&&0<s.interval&&1<l&&function t(){e.playing=setTimeout(function(){removeClass(r[h],CLASS_IN),addClass(r[h=(h+=1)<l?h:0],CLASS_IN),t()},s.interval)}(),this},stop:function(){var e=this;if(!this.played)return this;var t=this.element,i=this.options;if(isFunction(i.stop)&&addListener(t,EVENT_STOP,i.stop,{once:!0}),!1===dispatchEvent(t,EVENT_STOP))return this;t=this.player;return this.played=!1,clearTimeout(this.playing),forEach(t.getElementsByTagName("img"),function(t){removeListener(t,EVENT_LOAD,e.onLoadWhenPlay)}),removeClass(t,CLASS_SHOW),t.innerHTML="",this.exitFullscreen(),this},full:function(){var t=this,e=this.options,i=this.viewer,n=this.image,s=this.list;return!this.isShown||this.played||this.fulled||!e.inline||(this.fulled=!0,this.open(),addClass(this.button,CLASS_FULLSCREEN_EXIT),e.transition&&(removeClass(s,CLASS_TRANSITION),this.viewed&&removeClass(n,CLASS_TRANSITION)),addClass(i,CLASS_FIXED),i.setAttribute("role","dialog"),i.setAttribute("aria-labelledby",this.title.id),i.setAttribute("aria-modal",!0),i.removeAttribute("style"),setStyle(i,{zIndex:e.zIndex}),e.focus&&this.enforceFocus(),this.initContainer(),this.viewerData=assign({},this.containerData),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){e.transition&&setTimeout(function(){addClass(n,CLASS_TRANSITION),addClass(s,CLASS_TRANSITION)},0)})})),this},exit:function(){var t=this,e=this.options,i=this.viewer,n=this.image,s=this.list;return this.isShown&&!this.played&&this.fulled&&e.inline&&(this.fulled=!1,this.close(),removeClass(this.button,CLASS_FULLSCREEN_EXIT),e.transition&&(removeClass(s,CLASS_TRANSITION),this.viewed&&removeClass(n,CLASS_TRANSITION)),e.focus&&this.clearEnforceFocus(),i.removeAttribute("role"),i.removeAttribute("aria-labelledby"),i.removeAttribute("aria-modal"),removeClass(i,CLASS_FIXED),setStyle(i,{zIndex:e.zIndexInline}),this.viewerData=assign({},this.parentData),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){e.transition&&setTimeout(function(){addClass(n,CLASS_TRANSITION),addClass(s,CLASS_TRANSITION)},0)})})),this},tooltip:function(){var t=this,e=this.options,i=this.tooltipBox,n=this.imageData;return this.viewed&&!this.played&&e.tooltip&&(i.textContent="".concat(Math.round(100*n.ratio),"%"),this.tooltipping?clearTimeout(this.tooltipping):e.transition?(this.fading&&dispatchEvent(i,EVENT_TRANSITION_END),addClass(i,CLASS_SHOW),addClass(i,CLASS_FADE),addClass(i,CLASS_TRANSITION),i.removeAttribute("aria-hidden"),i.initialOffsetWidth=i.offsetWidth,addClass(i,CLASS_IN)):(addClass(i,CLASS_SHOW),i.removeAttribute("aria-hidden")),this.tooltipping=setTimeout(function(){e.transition?(addListener(i,EVENT_TRANSITION_END,function(){removeClass(i,CLASS_SHOW),removeClass(i,CLASS_FADE),removeClass(i,CLASS_TRANSITION),i.setAttribute("aria-hidden",!0),t.fading=!1},{once:!0}),removeClass(i,CLASS_IN),t.fading=!0):(removeClass(i,CLASS_SHOW),i.setAttribute("aria-hidden",!0)),t.tooltipping=!1},1e3)),this},toggle:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return 1===this.imageData.ratio?this.zoomTo(this.imageData.oldRatio,!0,t):this.zoomTo(1,!0,t),this},reset:function(){return this.viewed&&!this.played&&(this.imageData=assign({},this.initialImageData),this.renderImage()),this},update:function(){var e=this,t=this.element,i=this.options,n=this.isImg;if(n&&!t.parentNode)return this.destroy();var s,a=[];return forEach(n?[t]:t.querySelectorAll("img"),function(t){isFunction(i.filter)?i.filter.call(e,t)&&a.push(t):e.getImageURL(t)&&a.push(t)}),a.length&&(this.images=a,this.length=a.length,this.ready?(s=[],forEach(this.items,function(t,e){var i=t.querySelector("img"),t=a[e];t&&i&&t.src===i.src&&t.alt===i.alt||s.push(e)}),setStyle(this.list,{width:"auto"}),this.initList(),this.isShown&&(this.length?this.viewed&&(0<=(t=s.indexOf(this.index))?(this.viewed=!1,this.view(Math.max(Math.min(this.index-t,this.length-1),0))):(addClass(t=this.items[this.index],CLASS_ACTIVE),t.setAttribute("aria-selected",!0))):(this.image=null,this.viewed=!1,this.index=0,this.imageData={},this.canvas.innerHTML="",this.title.innerHTML=""))):this.build()),this},destroy:function(){var t=this.element,e=this.options;return t[NAMESPACE]&&(this.destroyed=!0,this.ready?(this.played&&this.stop(),e.inline?(this.fulled&&this.exit(),this.unbind()):this.isShown?(this.viewing&&(this.imageRendering?this.imageRendering.abort():this.imageInitializing&&this.imageInitializing.abort()),this.hiding&&this.transitioning.abort(),this.hidden()):this.showing&&(this.transitioning.abort(),this.hidden()),this.ready=!1,this.viewer.parentNode.removeChild(this.viewer)):e.inline&&(this.delaying?this.delaying.abort():this.initializing&&this.initializing.abort()),e.inline||removeListener(t,EVENT_CLICK,this.onStart),t[NAMESPACE]=void 0),this}},others={getImageURL:function(t){var e=this.options.url;return e=isString(e)?t.getAttribute(e):isFunction(e)?e.call(this,t):""},enforceFocus:function(){var i=this;this.clearEnforceFocus(),addListener(document,EVENT_FOCUSIN,this.onFocusin=function(t){var e=i.viewer,t=t.target;t===document||t===e||e.contains(t)||null!==t.getAttribute("tabindex")&&"true"===t.getAttribute("aria-modal")||e.focus()})},clearEnforceFocus:function(){this.onFocusin&&(removeListener(document,EVENT_FOCUSIN,this.onFocusin),this.onFocusin=null)},open:function(){var t=this.body;addClass(t,CLASS_OPEN),t.style.paddingRight="".concat(this.scrollbarWidth+(parseFloat(this.initialBodyComputedPaddingRight)||0),"px")},close:function(){var t=this.body;removeClass(t,CLASS_OPEN),t.style.paddingRight=this.initialBodyPaddingRight},shown:function(){var t=this.element,e=this.options,i=this.viewer;this.fulled=!0,this.isShown=!0,this.render(),this.bind(),this.showing=!1,e.focus&&(i.focus(),this.enforceFocus()),isFunction(e.shown)&&addListener(t,EVENT_SHOWN,e.shown,{once:!0}),!1!==dispatchEvent(t,EVENT_SHOWN)&&this.ready&&this.isShown&&!this.hiding&&this.view(this.index)},hidden:function(){var t=this.element,e=this.options,i=this.viewer;e.fucus&&this.clearEnforceFocus(),this.fulled=!1,this.viewed=!1,this.isShown=!1,this.close(),this.unbind(),addClass(i,CLASS_HIDE),i.removeAttribute("role"),i.removeAttribute("aria-labelledby"),i.removeAttribute("aria-modal"),i.setAttribute("aria-hidden",!0),this.resetList(),this.resetImage(),this.hiding=!1,this.destroyed||(isFunction(e.hidden)&&addListener(t,EVENT_HIDDEN,e.hidden,{once:!0}),dispatchEvent(t,EVENT_HIDDEN,null,{cancelable:!1}))},requestFullscreen:function(t){var e=this.element.ownerDocument;this.fulled&&!(e.fullscreenElement||e.webkitFullscreenElement||e.mozFullScreenElement||e.msFullscreenElement)&&((e=e.documentElement).requestFullscreen?isPlainObject(t)?e.requestFullscreen(t):e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen())},exitFullscreen:function(){var t=this.element.ownerDocument;this.fulled&&(t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement)&&(t.exitFullscreen?t.exitFullscreen():t.webkitExitFullscreen?t.webkitExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.msExitFullscreen&&t.msExitFullscreen())},change:function(t){var e=this.options,i=this.pointers,n=i[Object.keys(i)[0]];if(n){var s=n.endX-n.startX,a=n.endY-n.startY;switch(this.action){case ACTION_MOVE:this.move(s,a,t);break;case ACTION_ZOOM:this.zoom(getMaxZoomRatio(i),!1,t);break;case ACTION_SWITCH:this.action="switched";var o=Math.abs(s);1<o&&o>Math.abs(a)&&(this.pointers={},1<s?this.prev(e.loop):s<-1&&this.next(e.loop))}forEach(i,function(t){t.startX=t.endX,t.startY=t.endY})}},isSwitchable:function(){var t=this.imageData,e=this.viewerData;return 1<this.length&&0<=t.x&&0<=t.y&&t.width<=e.width&&t.height<=e.height}},AnotherViewer=WINDOW.Viewer,getUniqueID=function(t){return function(){return t+=1}}(-1),Viewer=function(){function i(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(_classCallCheck(this,i),!t||1!==t.nodeType)throw new Error("The first argument is required and must be an element.");this.element=t,this.options=assign({},DEFAULTS,isPlainObject(e)&&e),this.action=!1,this.fading=!1,this.fulled=!1,this.hiding=!1,this.imageClicked=!1,this.imageData={},this.index=this.options.initialViewIndex,this.isImg=!1,this.isShown=!1,this.length=0,this.moving=!1,this.played=!1,this.playing=!1,this.pointers={},this.ready=!1,this.rotating=!1,this.scaling=!1,this.showing=!1,this.timeout=!1,this.tooltipping=!1,this.viewed=!1,this.viewing=!1,this.wheeling=!1,this.zooming=!1,this.id=getUniqueID(),this.init()}return _createClass(i,[{key:"init",value:function(){var t,e,i,n,s=this,a=this.element,o=this.options;a[NAMESPACE]||(a[NAMESPACE]=this,o.focus&&!o.keyboard&&(o.focus=!1),t="img"===a.localName,e=[],forEach(t?[a]:a.querySelectorAll("img"),function(t){isFunction(o.filter)?o.filter.call(s,t)&&e.push(t):s.getImageURL(t)&&e.push(t)}),this.isImg=t,this.length=e.length,this.images=e,this.initBody(),isUndefined(document.createElement(NAMESPACE).style.transition)&&(o.transition=!1),o.inline?(i=0,n=function(){var t;(i+=1)===s.length&&(s.initializing=!1,s.delaying={abort:function(){clearTimeout(t)}},t=setTimeout(function(){s.delaying=!1,s.build()},0))},this.initializing={abort:function(){forEach(e,function(t){t.complete||removeListener(t,EVENT_LOAD,n)})}},forEach(e,function(t){t.complete?n():addListener(t,EVENT_LOAD,n,{once:!0})})):addListener(a,EVENT_CLICK,this.onStart=function(t){t=t.target;"img"!==t.localName||isFunction(o.filter)&&!o.filter.call(s,t)||s.view(s.images.indexOf(t))}))}},{key:"build",value:function(){var t,a,e,i,n,s,o,r,l,h,c,d,u,E;this.ready||(t=this.element,a=this.options,e=t.parentNode,(u=document.createElement("div")).innerHTML=TEMPLATE,n=(i=u.querySelector(".".concat(NAMESPACE,"-container"))).querySelector(".".concat(NAMESPACE,"-title")),s=i.querySelector(".".concat(NAMESPACE,"-toolbar")),o=i.querySelector(".".concat(NAMESPACE,"-navbar")),E=i.querySelector(".".concat(NAMESPACE,"-button")),u=i.querySelector(".".concat(NAMESPACE,"-canvas")),this.parent=e,this.viewer=i,this.title=n,this.toolbar=s,this.navbar=o,this.button=E,this.canvas=u,this.footer=i.querySelector(".".concat(NAMESPACE,"-footer")),this.tooltipBox=i.querySelector(".".concat(NAMESPACE,"-tooltip")),this.player=i.querySelector(".".concat(NAMESPACE,"-player")),this.list=i.querySelector(".".concat(NAMESPACE,"-list")),i.id="".concat(NAMESPACE).concat(this.id),n.id="".concat(NAMESPACE,"Title").concat(this.id),addClass(n,a.title?getResponsiveClass(Array.isArray(a.title)?a.title[0]:a.title):CLASS_HIDE),addClass(o,a.navbar?getResponsiveClass(a.navbar):CLASS_HIDE),toggleClass(E,CLASS_HIDE,!a.button),a.keyboard&&E.setAttribute("tabindex",0),a.backdrop&&(addClass(i,"".concat(NAMESPACE,"-backdrop")),a.inline||"static"===a.backdrop||setData(u,DATA_ACTION,"hide")),isString(a.className)&&a.className&&a.className.split(REGEXP_SPACES).forEach(function(t){addClass(i,t)}),a.toolbar?(r=document.createElement("ul"),l=isPlainObject(a.toolbar),h=BUTTONS.slice(0,3),c=BUTTONS.slice(7,9),d=BUTTONS.slice(9),l||addClass(s,getResponsiveClass(a.toolbar)),forEach(l?a.toolbar:BUTTONS,function(t,e){var i=l&&isPlainObject(t),n=l?hyphenate(e):t,s=i&&!isUndefined(t.show)?t.show:t;!s||!a.zoomable&&-1!==h.indexOf(n)||!a.rotatable&&-1!==c.indexOf(n)||!a.scalable&&-1!==d.indexOf(n)||(e=i&&!isUndefined(t.size)?t.size:t,i=i&&!isUndefined(t.click)?t.click:t,t=document.createElement("li"),a.keyboard&&t.setAttribute("tabindex",0),t.setAttribute("role","button"),addClass(t,"".concat(NAMESPACE,"-").concat(n)),isFunction(i)||setData(t,DATA_ACTION,n),isNumber(s)&&addClass(t,getResponsiveClass(s)),-1!==["small","large"].indexOf(e)?addClass(t,"".concat(NAMESPACE,"-").concat(e)):"play"===n&&addClass(t,"".concat(NAMESPACE,"-large")),isFunction(i)&&addListener(t,EVENT_CLICK,i),r.appendChild(t))}),s.appendChild(r)):addClass(s,CLASS_HIDE),a.rotatable||(addClass(u=s.querySelectorAll('li[class*="rotate"]'),CLASS_INVISIBLE),forEach(u,function(t){s.appendChild(t)})),a.inline?(addClass(E,CLASS_FULLSCREEN),setStyle(i,{zIndex:a.zIndexInline}),"static"===window.getComputedStyle(e).position&&setStyle(e,{position:"relative"}),e.insertBefore(i,t.nextSibling)):(addClass(E,CLASS_CLOSE),addClass(i,CLASS_FIXED),addClass(i,CLASS_FADE),addClass(i,CLASS_HIDE),setStyle(i,{zIndex:a.zIndex}),(E=(E=isString(E=a.container)?t.ownerDocument.querySelector(E):E)||this.body).appendChild(i)),a.inline&&(this.render(),this.bind(),this.isShown=!0),this.ready=!0,isFunction(a.ready)&&addListener(t,EVENT_READY,a.ready,{once:!0}),!1!==dispatchEvent(t,EVENT_READY)?this.ready&&a.inline&&this.view(this.index):this.ready=!1)}}],[{key:"noConflict",value:function(){return window.Viewer=AnotherViewer,i}},{key:"setDefaults",value:function(t){assign(DEFAULTS,isPlainObject(t)&&t)}}]),i}();assign(Viewer.prototype,render,events,handlers,methods,others),module.exports=Viewer;