!function(){function e(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,o){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var i,a,t=[],r=!0,c=!1;try{for(n=n.call(e);!(r=(i=n.next()).done)&&(t.push(i.value),!o||t.length!==o);r=!0);}catch(s){c=!0,a=s}finally{try{r||null==n.return||n.return()}finally{if(c)throw a}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return o(e,n);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return o(e,n)}(e,n)||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 o(e,o){(null==o||o>e.length)&&(o=e.length);for(var n=0,i=new Array(o);nn})),b=s((function(){var e=w.scale,o=w.moveX,n=w.moveY,i=w.moving,a={transitionDuration:w.zooming||i?"0s":".3s"};if(1!==e){var t=o/e,r=n/e;a.transform="scale(".concat(e,", ").concat(e,") translate(").concat(t,"px, ").concat(r,"px)")}return a})),_=s((function(){if(w.imageRatio){var o=e.rootWidth,n=e.rootHeight,i=x.value?n/w.imageRatio:o;return Math.max(0,(w.scale*i-o)/2)}return 0})),z=s((function(){if(w.imageRatio){var o=e.rootWidth,n=e.rootHeight,i=x.value?n:o*w.imageRatio;return Math.max(0,(w.scale*i-n)/2)}return 0})),C=function(o){(o=u(o,+e.minZoom,+e.maxZoom+1))!==w.scale&&(w.scale=o,h("scale",{scale:o,index:e.active}))},I=function(){C(1),w.moveX=0,w.moveY=0},S=function(e){var o=e.touches,r=y.offsetX;y.start(e),n=o.length,i=w.moveX,a=w.moveY,d=Date.now(),w.moving=1===n&&1!==w.scale,w.zooming=2===n&&!r.value,w.zooming&&(t=w.scale,f=D(e.touches))},X=function(e){var o=e.touches;if(y.move(e),(w.moving||w.zooming)&&m(e,!0),w.moving){var n=y.deltaX,r=y.deltaY,c=n.value+i,s=r.value+a;w.moveX=u(c,-_.value,_.value),w.moveY=u(s,-z.value,z.value)}if(w.zooming&&2===o.length){var l=D(o);C(t*l/f)}},Y=function(){if(!(n>1)){var e,o=y.offsetX,i=y.offsetY,a=Date.now()-d;o.value<5&&i.value<5&&a<250&&(p?(clearTimeout(p),p=null,e=w.scale>1?1:2,C(e),w.moveX=0,w.moveY=0):p=setTimeout((function(){h("close"),p=null}),250))}},Z=function(o){var n=!1;(w.moving||w.zooming)&&(n=!0,w.moving&&i===w.moveX&&a===w.moveY&&(n=!1),o.touches.length||(w.zooming&&(w.moveX=u(w.moveX,-_.value,_.value),w.moveY=u(w.moveY,-z.value,z.value),w.zooming=!1),w.moving=!1,i=0,a=0,t=1,w.scale<1&&I(),w.scale>e.maxZoom&&(w.scale=+e.maxZoom))),m(o,n),Y(),y.reset()},H=function(e){var o=e.target,n=o.naturalWidth,i=o.naturalHeight;w.imageRatio=i/n};return l((function(){return e.active}),I),l((function(){return e.show}),(function(e){e||I()})),function(){var o={loading:function(){return v(g,{type:"spinner"},null)}};return v(A,{class:B("swipe-item"),onTouchstart:S,onTouchmove:X,onTouchend:Z,onTouchcancel:Z},{default:function(){return[v(M,{src:e.src,fit:"contain",class:B("image",{vertical:x.value}),style:b.value,onLoad:H},o)]}})}}}),E=e(n("image-preview"),2),q=E[0],L=E[1],$=["show","transition","overlayStyle","closeOnPopstate"],F={show:Boolean,loop:f,images:p(),minZoom:d(1/3),maxZoom:d(3),overlay:f,closeable:Boolean,showIndex:f,className:h,closeIcon:w("clear"),transition:String,beforeClose:Function,overlayClass:h,overlayStyle:Object,swipeDuration:d(300),startPosition:d(0),showIndicators:Boolean,closeOnPopstate:f,closeIconPosition:w("top-right")},G=i({name:q,props:F,emits:["scale","close","closed","change","update:show"],setup:function(e,o){var n=o.emit,i=o.slots,a=y(),t=r({active:0,rootWidth:0,rootHeight:0}),c=function(){if(a.value){var e=Y(a.value.$el);t.rootWidth=e.width,t.rootHeight=e.height,a.value.resize()}},s=function(e){return n("scale",e)},m=function(e){return n("update:show",e)},u=function(){P(e.beforeClose,{args:[t.active],done:function(){return m(!1)}})},g=function(e){e!==t.active&&(t.active=e,n("change",e))},f=function(){if(e.showIndex)return v("div",{class:L("index")},[i.index?i.index({index:t.active}):"".concat(t.active+1," / ").concat(e.images.length)])},p=function(){if(i.cover)return v("div",{class:L("cover")},[i.cover()])},d=function(){if(e.closeable)return v(H,{role:"button",name:e.closeIcon,class:[L("close-icon",e.closeIconPosition),Z],onClick:u},null)},h=function(){return n("closed")},w=function(e,o){var n;return null==(n=a.value)?void 0:n.swipeTo(e,o)};return x({swipeTo:w}),b(c),l([_,z],c),l((function(){return e.startPosition}),(function(e){return g(+e)})),l((function(){return e.show}),(function(o){var i=e.images,a=e.startPosition;o?(g(+a),C((function(){c(),w(+a,{immediate:!0})}))):n("close",{index:t.active,url:i[t.active]})})),function(){return v(X,I({class:[L(),e.className],overlayClass:[L("overlay"),e.overlayClass],onClosed:h,"onUpdate:show":m},S(e,$)),{default:function(){return[d(),v(O,{ref:a,lazyRender:!0,loop:e.loop,class:L("swipe"),duration:e.swipeDuration,initialSwipe:e.startPosition,showIndicators:e.showIndicators,indicatorColor:"white",onChange:g},{default:function(){return[e.images.map((function(o){return v(U,{src:o,show:e.show,active:t.active,maxZoom:e.maxZoom,minZoom:e.minZoom,rootWidth:t.rootWidth,rootHeight:t.rootHeight,onScale:s,onClose:u},null)}))]}}),f(),p()]}})}}}),J={loop:!0,images:[],maxZoom:3,minZoom:1/3,onScale:void 0,onClose:void 0,onChange:void 0,teleport:"body",className:"",showIndex:!0,closeable:!1,closeIcon:"clear",transition:void 0,beforeClose:void 0,overlayStyle:void 0,overlayClass:void 0,startPosition:0,swipeDuration:300,showIndicators:!1,closeOnPopstate:!0,closeIconPosition:"top-right"};function V(){var e=R({setup:function(){var e=k(),o=e.state,n=e.toggle,i=function(){o.images=[]};return function(){return v(G,I(o,{onClosed:i,"onUpdate:show":n}),null)}}});N=e.instance}var K=o("I",(function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(T)return N||V(),e=Array.isArray(e)?{images:e,startPosition:o}:e,N.open(W({},J,e)),N}));K.Component=j(G),K.install=function(e){e.use(K.Component)}}}}))}();