viewer.min.js 32 KB

12345678910
  1. /*!
  2. * Viewer.js v1.6.2
  3. * https://fengyuanchen.github.io/viewerjs
  4. *
  5. * Copyright 2015-present Chen Fengyuan
  6. * Released under the MIT license
  7. *
  8. * Date: 2020-08-30T02:26:56.980Z
  9. */
  10. !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).Viewer=i()}(this,function(){"use strict";function i(t){return(i="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 o(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function e(i,t){var e,n=Object.keys(i);return Object.getOwnPropertySymbols&&(e=Object.getOwnPropertySymbols(i),t&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(i,t).enumerable})),n.push.apply(n,e)),n}function c(o){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?e(Object(s),!0).forEach(function(t){var i,e,n;i=o,n=s[e=t],e in i?Object.defineProperty(i,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):i[e]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(s)):e(Object(s)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(s,t))})}return o}var s={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,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,zoom:null,zoomed:null},t="undefined"!=typeof window&&void 0!==window.document,n=t?window:{},a=!(!t||!n.document.documentElement)&&"ontouchstart"in n.document.documentElement,r=t&&"PointerEvent"in n,v="viewer",u="move",d="switch",m="zoom",g="".concat(v,"-active"),w="".concat(v,"-close"),b="".concat(v,"-fade"),y="".concat(v,"-fixed"),x="".concat(v,"-fullscreen"),h="".concat(v,"-fullscreen-exit"),z="".concat(v,"-hide"),l="".concat(v,"-hide-md-down"),f="".concat(v,"-hide-sm-down"),p="".concat(v,"-hide-xs-down"),k="".concat(v,"-in"),D="".concat(v,"-invisible"),T="".concat(v,"-loading"),I="".concat(v,"-move"),E="".concat(v,"-open"),O="".concat(v,"-show"),S="".concat(v,"-transition"),C="click",L="dblclick",R="dragstart",A="hidden",N="hide",M="keydown",P="load",Y=r?"pointerdown":a?"touchstart":"mousedown",q=r?"pointermove":a?"touchmove":"mousemove",X=r?"pointerup pointercancel":a?"touchend touchcancel":"mouseup",F="ready",W="resize",j="show",H="shown",B="transitionend",V="viewed",U="".concat(v,"Action"),K=/\s\s*/,Z=["zoom-in","zoom-out","one-to-one","reset","prev","play","next","rotate-left","rotate-right","flip-horizontal","flip-vertical"];function $(t){return"string"==typeof t}var _=Number.isNaN||n.isNaN;function G(t){return"number"==typeof t&&!_(t)}function J(t){return void 0===t}function Q(t){return"object"===i(t)&&null!==t}var tt=Object.prototype.hasOwnProperty;function it(t){if(!Q(t))return!1;try{var i=t.constructor,e=i.prototype;return i&&e&&tt.call(e,"isPrototypeOf")}catch(t){return!1}}function et(t){return"function"==typeof t}function nt(i,e){if(i&&et(e))if(Array.isArray(i)||G(i.length))for(var t=i.length,n=0;n<t&&!1!==e.call(i,i[n],n,i);n+=1);else Q(i)&&Object.keys(i).forEach(function(t){e.call(i,i[t],t,i)});return i}var ot=Object.assign||function(e){for(var t=arguments.length,i=new Array(1<t?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return Q(e)&&0<i.length&&i.forEach(function(i){Q(i)&&Object.keys(i).forEach(function(t){e[t]=i[t]})}),e},st=/^(?:width|height|left|top|marginLeft|marginTop)$/;function at(t,i){var e=t.style;nt(i,function(t,i){st.test(i)&&G(t)&&(t+="px"),e[i]=t})}function rt(t,i){return t&&i&&(t.classList?t.classList.contains(i):-1<t.className.indexOf(i))}function ht(t,i){var e;t&&i&&(G(t.length)?nt(t,function(t){ht(t,i)}):t.classList?t.classList.add(i):(e=t.className.trim())?e.indexOf(i)<0&&(t.className="".concat(e," ").concat(i)):t.className=i)}function lt(t,i){t&&i&&(G(t.length)?nt(t,function(t){lt(t,i)}):t.classList?t.classList.remove(i):0<=t.className.indexOf(i)&&(t.className=t.className.replace(i,"")))}function ct(t,i,e){i&&(G(t.length)?nt(t,function(t){ct(t,i,e)}):(e?ht:lt)(t,i))}var ut=/([a-z\d])([A-Z])/g;function dt(t){return t.replace(ut,"$1-$2").toLowerCase()}function mt(t,i){return Q(t[i])?t[i]:t.dataset?t.dataset[i]:t.getAttribute("data-".concat(dt(i)))}function gt(t,i,e){Q(e)?t[i]=e:t.dataset?t.dataset[i]=e:t.setAttribute("data-".concat(dt(i)),e)}var ft,pt,vt,wt,bt=(wt=!1,t&&(ft=!1,pt=function(){},vt=Object.defineProperty({},"once",{get:function(){return wt=!0,ft},set:function(t){ft=t}}),n.addEventListener("test",pt,vt),n.removeEventListener("test",pt,vt)),wt);function yt(e,t,n,i){var o=3<arguments.length&&void 0!==i?i:{},s=n;t.trim().split(K).forEach(function(t){var i;bt||(i=e.listeners)&&i[t]&&i[t][n]&&(s=i[t][n],delete i[t][n],0===Object.keys(i[t]).length&&delete i[t],0===Object.keys(i).length&&delete e.listeners),e.removeEventListener(t,s,o)})}function xt(s,t,a,i){var r=3<arguments.length&&void 0!==i?i:{},h=a;t.trim().split(K).forEach(function(n){var t,o;r.once&&!bt&&(t=s.listeners,h=function(){delete o[n][a],s.removeEventListener(n,h,r);for(var t=arguments.length,i=new Array(t),e=0;e<t;e++)i[e]=arguments[e];a.apply(s,i)},(o=void 0===t?{}:t)[n]||(o[n]={}),o[n][a]&&s.removeEventListener(n,o[n][a],r),o[n][a]=h,s.listeners=o),s.addEventListener(n,h,r)})}function zt(t,i,e){var n;return et(Event)&&et(CustomEvent)?n=new CustomEvent(i,{detail:e,bubbles:!0,cancelable:!0}):(n=document.createEvent("CustomEvent")).initCustomEvent(i,!0,!0,e),t.dispatchEvent(n)}function kt(t){var i=t.rotate,e=t.scaleX,n=t.scaleY,o=t.translateX,s=t.translateY,a=[];G(o)&&0!==o&&a.push("translateX(".concat(o,"px)")),G(s)&&0!==s&&a.push("translateY(".concat(s,"px)")),G(i)&&0!==i&&a.push("rotate(".concat(i,"deg)")),G(e)&&1!==e&&a.push("scaleX(".concat(e,")")),G(n)&&1!==n&&a.push("scaleY(".concat(n,")"));var r=a.length?a.join(" "):"none";return{WebkitTransform:r,msTransform:r,transform:r}}var Dt=n.navigator&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(n.navigator.userAgent);function Tt(e,t,i){var n=document.createElement("img");if(e.naturalWidth&&!Dt)return i(e.naturalWidth,e.naturalHeight),n;var o=document.body||document.documentElement;return n.onload=function(){i(n.width,n.height),Dt||o.removeChild(n)},nt(t.inheritedAttributes,function(t){var i=e.getAttribute(t);null!==i&&n.setAttribute(t,i)}),n.src=e.src,Dt||(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;",o.appendChild(n)),n}function It(t){switch(t){case 2:return p;case 3:return f;case 4:return l;default:return""}}function Et(t,i){var e=t.pageX,n=t.pageY,o={endX:e,endY:n};return i?o:c({timeStamp:Date.now(),startX:e,startY:n},o)}var Ot={render:function(){this.initContainer(),this.initViewer(),this.initList(),this.renderViewer()},initBody:function(){var t=this.element.ownerDocument,i=t.body||t.documentElement;this.body=i,this.scrollbarWidth=window.innerWidth-t.documentElement.clientWidth,this.initialBodyPaddingRight=i.style.paddingRight,this.initialBodyComputedPaddingRight=window.getComputedStyle(i).paddingRight},initContainer:function(){this.containerData={width:window.innerWidth,height:window.innerHeight}},initViewer:function(){var t,i=this.options,e=this.parent;i.inline&&(t={width:Math.max(e.offsetWidth,i.minWidth),height:Math.max(e.offsetHeight,i.minHeight)},this.parentData=t),!this.fulled&&t||(t=this.containerData),this.viewerData=ot({},t)},renderViewer:function(){this.options.inline&&!this.fulled&&at(this.viewer,this.viewerData)},initList:function(){var h=this,t=this.element,l=this.options,c=this.list,u=[];c.innerHTML="",nt(this.images,function(e,t){var i,n,o,s=e.src,a=e.alt||($(i=s)?decodeURIComponent(i.replace(/^.*\//,"").replace(/[?&#].*$/,"")):""),r=h.getImageURL(e);(s||r)&&(n=document.createElement("li"),o=document.createElement("img"),nt(l.inheritedAttributes,function(t){var i=e.getAttribute(t);null!==i&&o.setAttribute(t,i)}),o.src=s||r,o.alt=a,o.setAttribute("data-index",t),o.setAttribute("data-original-url",r||s),o.setAttribute("data-viewer-action","view"),o.setAttribute("role","button"),n.appendChild(o),c.appendChild(n),u.push(n))}),nt(this.items=u,function(i){var t=i.firstElementChild;gt(t,"filled",!0),l.loading&&ht(i,T),xt(t,P,function(t){l.loading&&lt(i,T),h.loadImage(t)},{once:!0})}),l.transition&&xt(t,V,function(){ht(c,S)},{once:!0})},renderList:function(t){var i=t||this.index,e=this.items[i].offsetWidth||30,n=e+1;at(this.list,ot({width:n*this.length},kt({translateX:(this.viewerData.width-e)/2-n*i})))},resetList:function(){var t=this.list;t.innerHTML="",lt(t,S),at(t,kt({translateX:0}))},initImage:function(r){var t,h=this,l=this.options,i=this.image,e=this.viewerData,n=this.footer.offsetHeight,c=e.width,u=Math.max(e.height-n,n),d=this.imageData||{};this.imageInitializing={abort:function(){t.onload=null}},t=Tt(i,l,function(t,i){var e=t/i,n=c,o=u;h.imageInitializing=!1,c<u*e?o=c/e:n=u*e;var s={naturalWidth:t,naturalHeight:i,aspectRatio:e,ratio:(n=Math.min(.9*n,t))/t,width:n,height:o=Math.min(.9*o,i),left:(c-n)/2,top:(u-o)/2},a=ot({},s);l.rotatable&&(s.rotate=d.rotate||0,a.rotate=0),l.scalable&&(s.scaleX=d.scaleX||1,s.scaleY=d.scaleY||1,a.scaleX=1,a.scaleY=1),h.imageData=s,h.initialImageData=a,r&&r()})},renderImage:function(t){var i,e=this,n=this.image,o=this.imageData;at(n,ot({width:o.width,height:o.height,marginLeft:o.left,marginTop:o.top},kt(o))),t&&((this.viewing||this.zooming)&&this.options.transition?(i=function(){e.imageRendering=!1,t()},this.imageRendering={abort:function(){yt(n,B,i)}},xt(n,B,i,{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)}},St={bind:function(){var t=this.options,i=this.viewer,e=this.canvas,n=this.element.ownerDocument;xt(i,C,this.onClick=this.click.bind(this)),xt(i,R,this.onDragStart=this.dragstart.bind(this)),xt(e,Y,this.onPointerDown=this.pointerdown.bind(this)),xt(n,q,this.onPointerMove=this.pointermove.bind(this)),xt(n,X,this.onPointerUp=this.pointerup.bind(this)),xt(n,M,this.onKeyDown=this.keydown.bind(this)),xt(window,W,this.onResize=this.resize.bind(this)),t.zoomable&&t.zoomOnWheel&&xt(i,"wheel",this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),t.toggleOnDblclick&&xt(e,L,this.onDblclick=this.dblclick.bind(this))},unbind:function(){var t=this.options,i=this.viewer,e=this.canvas,n=this.element.ownerDocument;yt(i,C,this.onClick),yt(i,R,this.onDragStart),yt(e,Y,this.onPointerDown),yt(n,q,this.onPointerMove),yt(n,X,this.onPointerUp),yt(n,M,this.onKeyDown),yt(window,W,this.onResize),t.zoomable&&t.zoomOnWheel&&yt(i,"wheel",this.onWheel,{passive:!1,capture:!0}),t.toggleOnDblclick&&yt(e,L,this.onDblclick)}},Ct={click:function(t){var i=t.target,e=this.options,n=this.imageData,o=mt(i,U);switch(a&&t.isTrusted&&i===this.canvas&&clearTimeout(this.clickCanvasTimeout),o){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(mt(i,"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(-n.scaleX||-1);break;case"flip-vertical":this.scaleY(-n.scaleY||-1);break;default:this.played&&this.stop()}},dblclick:function(t){t.preventDefault(),this.viewed&&t.target===this.image&&(a&&t.isTrusted&&clearTimeout(this.doubleClickImageTimeout),this.toggle())},load:function(){var t=this;this.timeout&&(clearTimeout(this.timeout),this.timeout=!1);var i=this.element,e=this.options,n=this.image,o=this.index,s=this.viewerData;lt(n,D),e.loading&&lt(this.canvas,T),n.style.cssText="height:0;"+"margin-left:".concat(s.width/2,"px;")+"margin-top:".concat(s.height/2,"px;")+"max-width:none!important;position:absolute;width:0;",this.initImage(function(){ct(n,I,e.movable),ct(n,S,e.transition),t.renderImage(function(){t.viewed=!0,t.viewing=!1,et(e.viewed)&&xt(i,V,e.viewed,{once:!0}),zt(i,V,{originalImage:t.images[o],index:o,image:n})})})},loadImage:function(t){var s=t.target,i=s.parentNode,a=i.offsetWidth||30,r=i.offsetHeight||50,h=!!mt(s,"filled");Tt(s,this.options,function(t,i){var e=t/i,n=a,o=r;a<r*e?h?n=r*e:o=a/e:h?o=a/e:n=r*e,at(s,ot({width:n,height:o},kt({translateX:(a-n)/2,translateY:(r-o)/2})))})},keydown:function(t){var i=this.options;if(this.fulled&&i.keyboard)switch(t.keyCode||t.which||t.charCode){case 27:this.played?this.stop():i.inline?this.fulled&&this.exit():this.hide();break;case 32:this.played&&this.stop();break;case 37:this.prev(i.loop);break;case 38:t.preventDefault(),this.zoom(i.zoomRatio,!0);break;case 39:this.next(i.loop);break;case 40:t.preventDefault(),this.zoom(-i.zoomRatio,!0);break;case 48:case 49:t.ctrlKey&&(t.preventDefault(),this.toggle())}},dragstart:function(t){"img"===t.target.tagName.toLowerCase()&&t.preventDefault()},pointerdown:function(t){var i,e=this.options,n=this.pointers,o=t.buttons,s=t.button;!this.viewed||this.showing||this.viewing||this.hiding||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(G(o)&&1!==o||G(s)&&0!==s||t.ctrlKey)||(t.preventDefault(),t.changedTouches?nt(t.changedTouches,function(t){n[t.identifier]=Et(t)}):n[t.pointerId||0]=Et(t),i=!!e.movable&&u,e.zoomOnTouch&&e.zoomable&&1<Object.keys(n).length?i=m:e.slideOnTouch&&("touch"===t.pointerType||"touchstart"===t.type)&&this.isSwitchable()&&(i=d),!e.transition||i!==u&&i!==m||lt(this.image,S),this.action=i)},pointermove:function(t){var i=this.pointers,e=this.action;this.viewed&&e&&(t.preventDefault(),t.changedTouches?nt(t.changedTouches,function(t){ot(i[t.identifier]||{},Et(t,!0))}):ot(i[t.pointerId||0]||{},Et(t,!0)),this.change(t))},pointerup:function(t){var i,e=this,n=this.options,o=this.action,s=this.pointers;t.changedTouches?nt(t.changedTouches,function(t){i=s[t.identifier],delete s[t.identifier]}):(i=s[t.pointerId||0],delete s[t.pointerId||0]),o&&(t.preventDefault(),!n.transition||o!==u&&o!==m||ht(this.image,S),this.action=!1,a&&o!==m&&i&&Date.now()-i.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(){zt(e.image,L)},50)):(this.imageClicked=!0,this.doubleClickImageTimeout=setTimeout(function(){e.imageClicked=!1},500)):(this.imageClicked=!1,n.backdrop&&"static"!==n.backdrop&&t.target===this.canvas&&(this.clickCanvasTimeout=setTimeout(function(){zt(e.canvas,C)},50)))))},resize:function(){var i=this;if(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(){i.renderImage()}),this.played)){if(this.options.fullscreen&&this.fulled&&!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement))return void this.stop();nt(this.player.getElementsByTagName("img"),function(t){xt(t,P,i.loadImage.bind(i),{once:!0}),zt(t,P)})}},wheel:function(t){var i,e,n=this;this.viewed&&(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(function(){n.wheeling=!1},50),i=Number(this.options.zoomRatio)||.1,e=1,t.deltaY?e=0<t.deltaY?1:-1:t.wheelDelta?e=-t.wheelDelta/120:t.detail&&(e=0<t.detail?1:-1),this.zoom(-e*i,!0,t)))}},Lt={show:function(t){var i=0<arguments.length&&void 0!==t&&t,e=this.element,n=this.options;if(n.inline||this.showing||this.isShown||this.showing)return this;if(!this.ready)return this.build(),this.ready&&this.show(i),this;if(et(n.show)&&xt(e,j,n.show,{once:!0}),!1===zt(e,j)||!this.ready)return this;this.hiding&&this.transitioning.abort(),this.showing=!0,this.open();var o,s=this.viewer;return lt(s,z),n.transition&&!i?(o=this.shown.bind(this),this.transitioning={abort:function(){yt(s,B,o),lt(s,k)}},ht(s,S),s.initialOffsetWidth=s.offsetWidth,xt(s,B,o,{once:!0}),ht(s,k)):(ht(s,k),this.shown()),this},hide:function(t){var e=this,i=0<arguments.length&&void 0!==t&&t,n=this.element,o=this.options;if(o.inline||this.hiding||!this.isShown&&!this.showing)return this;if(et(o.hide)&&xt(n,N,o.hide,{once:!0}),!1===zt(n,N))return this;this.showing&&this.transitioning.abort(),this.hiding=!0,this.played?this.stop():this.viewing&&this.viewing.abort();function s(){lt(h,k),e.hidden()}var a,r,h=this.viewer,l=this.image;return o.transition&&!i?(a=function t(i){i&&i.target===h&&(yt(h,B,t),e.hidden())},r=function(){rt(h,S)?(xt(h,B,a),lt(h,k)):s()},this.transitioning={abort:function(){e.viewed&&rt(l,S)?yt(l,B,r):rt(h,S)&&yt(h,B,a)}},this.viewed&&rt(l,S)?(xt(l,B,r,{once:!0}),this.zoomTo(0,!1,!1,!0)):r()):s(),this},view:function(t){var n=this,i=0<arguments.length&&void 0!==t?t:this.options.initialViewIndex,i=Number(i)||0;if(this.hiding||this.played||i<0||i>=this.length||this.viewed&&i===this.index)return this;if(!this.isShown)return this.index=i,this.show();this.viewing&&this.viewing.abort();var e=this.element,o=this.options,s=this.title,a=this.canvas,r=this.items[i],h=r.querySelector("img"),l=mt(h,"originalUrl"),c=h.getAttribute("alt"),u=document.createElement("img");if(nt(o.inheritedAttributes,function(t){var i=h.getAttribute(t);null!==i&&u.setAttribute(t,i)}),u.src=l,u.alt=c,et(o.view)&&xt(e,"view",o.view,{once:!0}),!1===zt(e,"view",{originalImage:this.images[i],index:i,image:u})||!this.isShown||this.hiding||this.played)return this;this.image=u,lt(this.items[this.index],g),ht(r,g),this.viewed=!1,this.index=i,this.imageData={},ht(u,D),o.loading&&ht(a,T),a.innerHTML="",a.appendChild(u),this.renderList(),s.innerHTML="";function d(){var t,i=n.imageData,e=Array.isArray(o.title)?o.title[1]:o.title;s.innerHTML=$(t=et(e)?e.call(n,u,i):"".concat(c," (").concat(i.naturalWidth," × ").concat(i.naturalHeight,")"))?t.replace(/&(?!amp;|quot;|#39;|lt;|gt;)/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):t}var m;return xt(e,V,d,{once:!0}),this.viewing={abort:function(){yt(e,V,d),u.complete?n.imageRendering?n.imageRendering.abort():n.imageInitializing&&n.imageInitializing.abort():(u.src="",yt(u,P,m),n.timeout&&clearTimeout(n.timeout))}},u.complete?this.load():(xt(u,P,m=this.load.bind(this),{once:!0}),this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(function(){lt(u,D),n.timeout=!1},1e3)),this},prev:function(t){var i=0<arguments.length&&void 0!==t&&t,e=this.index-1;return e<0&&(e=i?this.length-1:0),this.view(e),this},next:function(t){var i=0<arguments.length&&void 0!==t&&t,e=this.length-1,n=this.index+1;return e<n&&(n=i?0:e),this.view(n),this},move:function(t,i){var e=this.imageData;return this.moveTo(J(t)?t:e.left+Number(t),J(i)?i:e.top+Number(i)),this},moveTo:function(t,i){var e,n=1<arguments.length&&void 0!==i?i:t,o=this.imageData;return t=Number(t),n=Number(n),this.viewed&&!this.played&&this.options.movable&&(e=!1,G(t)&&(o.left=t,e=!0),G(n)&&(o.top=n,e=!0),e&&this.renderImage()),this},zoom:function(t,i,e){var n=1<arguments.length&&void 0!==i&&i,o=2<arguments.length&&void 0!==e?e:null,s=this.imageData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(s.width*t/s.naturalWidth,n,o),this},zoomTo:function(t,i,e,n){var o,s,a,r,h,l,c,u=this,d=1<arguments.length&&void 0!==i&&i,m=2<arguments.length&&void 0!==e?e:null,g=3<arguments.length&&void 0!==n&&n,f=this.element,p=this.options,v=this.pointers,w=this.imageData,b=w.width,y=w.height,x=w.left,z=w.top,k=w.naturalWidth,D=w.naturalHeight;if(G(t=Math.max(0,t))&&this.viewed&&!this.played&&(g||p.zoomable)){g||(o=Math.max(.01,p.minZoomRatio),s=Math.min(100,p.maxZoomRatio),t=Math.min(Math.max(t,o),s)),m&&.055<=p.zoomRatio&&.95<t&&t<1.05&&(t=1);var T,I,E=k*t,O=D*t,S=E-b,C=O-y,L=b/k;if(et(p.zoom)&&xt(f,"zoom",p.zoom,{once:!0}),!1===zt(f,"zoom",{ratio:t,oldRatio:L,originalEvent:m}))return this;this.zooming=!0,m?(l=this.viewer,T={left:(c=l.getBoundingClientRect()).left+(window.pageXOffset-document.documentElement.clientLeft),top:c.top+(window.pageYOffset-document.documentElement.clientTop)},I=v&&Object.keys(v).length?(h=r=a=0,nt(v,function(t){var i=t.startX,e=t.startY;a+=i,r+=e,h+=1}),{pageX:a/=h,pageY:r/=h}):{pageX:m.pageX,pageY:m.pageY},w.left-=(I.pageX-T.left-x)/b*S,w.top-=(I.pageY-T.top-z)/y*C):(w.left-=S/2,w.top-=C/2),w.width=E,w.height=O,w.ratio=t,this.renderImage(function(){u.zooming=!1,et(p.zoomed)&&xt(f,"zoomed",p.zoomed,{once:!0}),zt(f,"zoomed",{ratio:t,oldRatio:L,originalEvent:m})}),d&&this.tooltip()}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t)),this},rotateTo:function(t){var i=this.imageData;return G(t=Number(t))&&this.viewed&&!this.played&&this.options.rotatable&&(i.rotate=t,this.renderImage()),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,i){var e,n=1<arguments.length&&void 0!==i?i:t,o=this.imageData;return t=Number(t),n=Number(n),this.viewed&&!this.played&&this.options.scalable&&(e=!1,G(t)&&(o.scaleX=t,e=!0),G(n)&&(o.scaleY=n,e=!0),e&&this.renderImage()),this},play:function(){var i=this,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];if(!this.isShown||this.played)return this;var e,o=this.options,s=this.player,a=this.loadImage.bind(this),r=[],h=0,l=0;return this.played=!0,this.onLoadWhenPlay=a,t&&this.requestFullscreen(),ht(s,O),nt(this.items,function(t,i){var e=t.querySelector("img"),n=document.createElement("img");n.src=mt(e,"originalUrl"),n.alt=e.getAttribute("alt"),n.referrerPolicy=e.referrerPolicy,h+=1,ht(n,b),ct(n,S,o.transition),rt(t,g)&&(ht(n,k),l=i),r.push(n),xt(n,P,a,{once:!0}),s.appendChild(n)}),G(o.interval)&&0<o.interval&&(e=function t(){i.playing=setTimeout(function(){lt(r[l],k),ht(r[l=(l+=1)<h?l:0],k),t()},o.interval)},1<h&&e()),this},stop:function(){var i=this;if(!this.played)return this;var t=this.player;return this.played=!1,clearTimeout(this.playing),nt(t.getElementsByTagName("img"),function(t){yt(t,P,i.onLoadWhenPlay)}),lt(t,O),t.innerHTML="",this.exitFullscreen(),this},full:function(){var t=this,i=this.options,e=this.viewer,n=this.image,o=this.list;return!this.isShown||this.played||this.fulled||!i.inline||(this.fulled=!0,this.open(),ht(this.button,h),i.transition&&(lt(o,S),this.viewed&&lt(n,S)),ht(e,y),e.setAttribute("style",""),at(e,{zIndex:i.zIndex}),this.initContainer(),this.viewerData=ot({},this.containerData),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){i.transition&&setTimeout(function(){ht(n,S),ht(o,S)},0)})})),this},exit:function(){var t=this,i=this.options,e=this.viewer,n=this.image,o=this.list;return this.isShown&&!this.played&&this.fulled&&i.inline&&(this.fulled=!1,this.close(),lt(this.button,h),i.transition&&(lt(o,S),this.viewed&&lt(n,S)),lt(e,y),at(e,{zIndex:i.zIndexInline}),this.viewerData=ot({},this.parentData),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){i.transition&&setTimeout(function(){ht(n,S),ht(o,S)},0)})})),this},tooltip:function(){var t=this,i=this.options,e=this.tooltipBox,n=this.imageData;return this.viewed&&!this.played&&i.tooltip&&(e.textContent="".concat(Math.round(100*n.ratio),"%"),this.tooltipping?clearTimeout(this.tooltipping):i.transition?(this.fading&&zt(e,B),ht(e,O),ht(e,b),ht(e,S),e.initialOffsetWidth=e.offsetWidth,ht(e,k)):ht(e,O),this.tooltipping=setTimeout(function(){i.transition?(xt(e,B,function(){lt(e,O),lt(e,b),lt(e,S),t.fading=!1},{once:!0}),lt(e,k),t.fading=!0):lt(e,O),t.tooltipping=!1},1e3)),this},toggle:function(){return 1===this.imageData.ratio?this.zoomTo(this.initialImageData.ratio,!0):this.zoomTo(1,!0),this},reset:function(){return this.viewed&&!this.played&&(this.imageData=ot({},this.initialImageData),this.renderImage()),this},update:function(){var i=this,t=this.element,e=this.options,n=this.isImg;if(n&&!t.parentNode)return this.destroy();var o,s,a=[];return nt(n?[t]:t.querySelectorAll("img"),function(t){et(e.filter)?e.filter.call(i,t)&&a.push(t):i.getImageURL(t)&&a.push(t)}),a.length&&(this.images=a,this.length=a.length,this.ready?(o=[],nt(this.items,function(t,i){var e=t.querySelector("img"),n=a[i];n&&e&&n.src===e.src||o.push(i)}),at(this.list,{width:"auto"}),this.initList(),this.isShown&&(this.length?this.viewed&&(0<=(s=o.indexOf(this.index))?(this.viewed=!1,this.view(Math.max(this.index-(s+1),0))):ht(this.items[this.index],g)):(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,i=this.options;return t[v]&&(this.destroyed=!0,this.ready?(this.played&&this.stop(),i.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)):i.inline&&(this.delaying?this.delaying.abort():this.initializing&&this.initializing.abort()),i.inline||yt(t,C,this.onStart),t[v]=void 0),this}},Rt={getImageURL:function(t){var i=this.options.url;return i=$(i)?t.getAttribute(i):et(i)?i.call(this,t):""},open:function(){var t=this.body;ht(t,E),t.style.paddingRight="".concat(this.scrollbarWidth+(parseFloat(this.initialBodyComputedPaddingRight)||0),"px")},close:function(){var t=this.body;lt(t,E),t.style.paddingRight=this.initialBodyPaddingRight},shown:function(){var t=this.element,i=this.options;this.fulled=!0,this.isShown=!0,this.render(),this.bind(),this.showing=!1,et(i.shown)&&xt(t,H,i.shown,{once:!0}),!1!==zt(t,H)&&this.ready&&this.isShown&&!this.hiding&&this.view(this.index)},hidden:function(){var t=this.element,i=this.options;this.fulled=!1,this.viewed=!1,this.isShown=!1,this.close(),this.unbind(),ht(this.viewer,z),this.resetList(),this.resetImage(),this.hiding=!1,this.destroyed||(et(i.hidden)&&xt(t,A,i.hidden,{once:!0}),zt(t,A))},requestFullscreen:function(){var t,i=this.element.ownerDocument;this.fulled&&!(i.fullscreenElement||i.webkitFullscreenElement||i.mozFullScreenElement||i.msFullscreenElement)&&((t=i.documentElement).requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen&&t.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 i,e,h,n=this.options,o=this.pointers,s=o[Object.keys(o)[0]],a=s.endX-s.startX,r=s.endY-s.startY;switch(this.action){case u:this.move(a,r);break;case m:this.zoom((e=c({},i=o),h=[],nt(i,function(r,t){delete e[t],nt(e,function(t){var i=Math.abs(r.startX-t.startX),e=Math.abs(r.startY-t.startY),n=Math.abs(r.endX-t.endX),o=Math.abs(r.endY-t.endY),s=Math.sqrt(i*i+e*e),a=(Math.sqrt(n*n+o*o)-s)/s;h.push(a)})}),h.sort(function(t,i){return Math.abs(t)<Math.abs(i)}),h[0]),!1,t);break;case d:this.action="switched";var l=Math.abs(a);1<l&&l>Math.abs(r)&&(this.pointers={},1<a?this.prev(n.loop):a<-1&&this.next(n.loop))}nt(o,function(t){t.startX=t.endX,t.startY=t.endY})},isSwitchable:function(){var t=this.imageData,i=this.viewerData;return 1<this.length&&0<=t.left&&0<=t.top&&t.width<=i.width&&t.height<=i.height}},At=n.Viewer,Nt=function(){function e(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!function(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}(this,e),!t||1!==t.nodeType)throw new Error("The first argument is required and must be an element.");this.element=t,this.options=ot({},s,it(i)&&i),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.played=!1,this.playing=!1,this.pointers={},this.ready=!1,this.showing=!1,this.timeout=!1,this.tooltipping=!1,this.viewed=!1,this.viewing=!1,this.wheeling=!1,this.zooming=!1,this.init()}var t,i,n;return t=e,n=[{key:"noConflict",value:function(){return window.Viewer=At,e}},{key:"setDefaults",value:function(t){ot(s,it(t)&&t)}}],(i=[{key:"init",value:function(){var t,i,e,n,o=this,s=this.element,a=this.options;s[v]||(s[v]=this,t="img"===s.tagName.toLowerCase(),i=[],nt(t?[s]:s.querySelectorAll("img"),function(t){et(a.filter)?a.filter.call(o,t)&&i.push(t):o.getImageURL(t)&&i.push(t)}),this.isImg=t,this.length=i.length,this.images=i,this.initBody(),J(document.createElement(v).style.transition)&&(a.transition=!1),a.inline?(e=0,n=function(){var t;(e+=1)===o.length&&(o.initializing=!1,o.delaying={abort:function(){clearTimeout(t)}},t=setTimeout(function(){o.delaying=!1,o.build()},0))},this.initializing={abort:function(){nt(i,function(t){t.complete||yt(t,P,n)})}},nt(i,function(t){t.complete?n():xt(t,P,n,{once:!0})})):xt(s,C,this.onStart=function(t){var i=t.target;"img"!==i.tagName.toLowerCase()||et(a.filter)&&!a.filter.call(o,i)||o.view(o.images.indexOf(i))}))}},{key:"build",value:function(){var t,h,i,e,n,o,s,a,r,l,c,u,d,m,g,f,p;this.ready||(t=this.element,h=this.options,i=t.parentNode,(e=document.createElement("div")).innerHTML='<div class="viewer-container" 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"></ul></div></div><div class="viewer-tooltip"></div><div role="button" class="viewer-button" data-viewer-action="mix"></div><div class="viewer-player"></div></div>',o=(n=e.querySelector(".".concat(v,"-container"))).querySelector(".".concat(v,"-title")),s=n.querySelector(".".concat(v,"-toolbar")),a=n.querySelector(".".concat(v,"-navbar")),r=n.querySelector(".".concat(v,"-button")),l=n.querySelector(".".concat(v,"-canvas")),this.parent=i,this.viewer=n,this.title=o,this.toolbar=s,this.navbar=a,this.button=r,this.canvas=l,this.footer=n.querySelector(".".concat(v,"-footer")),this.tooltipBox=n.querySelector(".".concat(v,"-tooltip")),this.player=n.querySelector(".".concat(v,"-player")),this.list=n.querySelector(".".concat(v,"-list")),ht(o,h.title?It(Array.isArray(h.title)?h.title[0]:h.title):z),ht(a,h.navbar?It(h.navbar):z),ct(r,z,!h.button),h.backdrop&&(ht(n,"".concat(v,"-backdrop")),h.inline||"static"===h.backdrop||gt(l,U,"hide")),$(h.className)&&h.className&&h.className.split(K).forEach(function(t){ht(n,t)}),h.toolbar?(c=document.createElement("ul"),u=it(h.toolbar),d=Z.slice(0,3),m=Z.slice(7,9),g=Z.slice(9),u||ht(s,It(h.toolbar)),nt(u?h.toolbar:Z,function(t,i){var e,n,o,s=u&&it(t),a=u?dt(i):t,r=s&&!J(t.show)?t.show:t;!r||!h.zoomable&&-1!==d.indexOf(a)||!h.rotatable&&-1!==m.indexOf(a)||!h.scalable&&-1!==g.indexOf(a)||(e=s&&!J(t.size)?t.size:t,n=s&&!J(t.click)?t.click:t,(o=document.createElement("li")).setAttribute("role","button"),ht(o,"".concat(v,"-").concat(a)),et(n)||gt(o,U,a),G(r)&&ht(o,It(r)),-1!==["small","large"].indexOf(e)?ht(o,"".concat(v,"-").concat(e)):"play"===a&&ht(o,"".concat(v,"-large")),et(n)&&xt(o,C,n),c.appendChild(o))}),s.appendChild(c)):ht(s,z),h.rotatable||(ht(f=s.querySelectorAll('li[class*="rotate"]'),D),nt(f,function(t){s.appendChild(t)})),h.inline?(ht(r,x),at(n,{zIndex:h.zIndexInline}),"static"===window.getComputedStyle(i).position&&at(i,{position:"relative"}),i.insertBefore(n,t.nextSibling)):(ht(r,w),ht(n,y),ht(n,b),ht(n,z),at(n,{zIndex:h.zIndex}),$(p=h.container)&&(p=t.ownerDocument.querySelector(p)),(p=p||this.body).appendChild(n)),h.inline&&(this.render(),this.bind(),this.isShown=!0),this.ready=!0,et(h.ready)&&xt(t,F,h.ready,{once:!0}),!1!==zt(t,F)?this.ready&&h.inline&&this.view(this.index):this.ready=!1)}}])&&o(t.prototype,i),n&&o(t,n),e}();return ot(Nt.prototype,Ot,St,Ct,Lt,Rt),Nt});