2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
import{V as $}from"./viewerjs-c43574b2.js";import"./vue-20eed888.js";import{ah as q,as as R,w as T,n as M,d as gt,r as mt,f as ht,Y as jt,o as wt,c as Ot,J as _t}from"./@vue-e95c845e.js";var $t=typeof global=="object"&&global&&global.Object===Object&&global;const tt=$t;var At=typeof self=="object"&&self&&self.Object===Object&&self,xt=tt||At||Function("return this")();const E=xt;var Tt=E.Symbol;const S=Tt;var rt=Object.prototype,Mt=rt.hasOwnProperty,St=rt.toString,O=S?S.toStringTag:void 0;function Vt(t){var r=Mt.call(t,O),e=t[O];try{t[O]=void 0;var n=!0}catch{}var o=St.call(t);return n&&(r?t[O]=e:delete t[O]),o}var Et=Object.prototype,Pt=Et.toString;function Dt(t){return Pt.call(t)}var Ut="[object Null]",Ft="[object Undefined]",N=S?S.toStringTag:void 0;function P(t){return t==null?t===void 0?Ft:Ut:N&&N in Object(t)?Vt(t):Dt(t)}function D(t){return t!=null&&typeof t=="object"}var It="[object Symbol]";function Ct(t){return typeof t=="symbol"||D(t)&&P(t)==It}var kt=Array.isArray;const Bt=kt;var Wt=/\s/;function Lt(t){for(var r=t.length;r--&&Wt.test(t.charAt(r)););return r}var qt=/^\s+/;function Rt(t){return t&&t.slice(0,Lt(t)+1).replace(qt,"")}function g(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}var z=0/0,Nt=/^[-+]0x[0-9a-f]+$/i,zt=/^0b[01]+$/i,Ht=/^0o[0-7]+$/i,Jt=parseInt;function H(t){if(typeof t=="number")return t;if(Ct(t))return z;if(g(t)){var r=typeof t.valueOf=="function"?t.valueOf():t;t=g(r)?r+"":r}if(typeof t!="string")return t===0?t:+t;t=Rt(t);var e=zt.test(t);return e||Ht.test(t)?Jt(t.slice(2),e?2:8):Nt.test(t)?z:+t}function et(t){return t}var Yt="[object AsyncFunction]",Gt="[object Function]",Kt="[object GeneratorFunction]",Qt="[object Proxy]";function nt(t){if(!g(t))return!1;var r=P(t);return r==Gt||r==Kt||r==Yt||r==Qt}var Xt=E["__core-js_shared__"];const I=Xt;var J=function(){var t=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Zt(t){return!!J&&J in t}var tr=Function.prototype,rr=tr.toString;function er(t){if(t!=null){try{return rr.call(t)}catch{}try{return t+""}catch{}}return""}var nr=/[\\^$.*+?()[\]{}|]/g,or=/^\[object .+?Constructor\]$/,ir=Function.prototype,ur=Object.prototype,cr=ir.toString,ar=ur.hasOwnProperty,fr=RegExp("^"+cr.call(ar).replace(nr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function sr(t){if(!g(t)||Zt(t))return!1;var r=nt(t)?fr:or;return r.test(er(t))}function lr(t,r){return t==null?void 0:t[r]}function vr(t,r){var e=lr(t,r);return sr(e)?e:void 0}function dr(t,r,e){switch(e.length){case 0:return t.call(r);case 1:return t.call(r,e[0]);case 2:return t.call(r,e[0],e[1]);case 3:return t.call(r,e[0],e[1],e[2])}return t.apply(r,e)}var pr=800,br=16,yr=Date.now;function gr(t){var r=0,e=0;return function(){var n=yr(),o=br-(n-e);if(e=n,o>0){if(++r>=pr)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}function mr(t){return function(){return t}}var hr=function(){try{var t=vr(Object,"defineProperty");return t({},"",{}),t}catch{}}();const V=hr;var jr=V?function(t,r){return V(t,"toString",{configurable:!0,enumerable:!1,value:mr(r),writable:!0})}:et;const wr=jr;var Or=gr(wr);const _r=Or;var $r=9007199254740991,Ar=/^(?:0|[1-9]\d*)$/;function ot(t,r){var e=typeof t;return r=r??$r,!!r&&(e=="number"||e!="symbol"&&Ar.test(t))&&t>-1&&t%1==0&&t<r}function it(t,r,e){r=="__proto__"&&V?V(t,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[r]=e}function B(t,r){return t===r||t!==t&&r!==r}var xr=Object.prototype,Tr=xr.hasOwnProperty;function ut(t,r,e){var n=t[r];(!(Tr.call(t,r)&&B(n,e))||e===void 0&&!(r in t))&&it(t,r,e)}function Mr(t,r,e,n){var o=!e;e||(e={});for(var a=-1,f=r.length;++a<f;){var u=r[a],v=n?n(e[u],t[u],u,e,t):void 0;v===void 0&&(v=t[u]),o?it(e,u,v):ut(e,u,v)}return e}var Y=Math.max;function Sr(t,r,e){return r=Y(r===void 0?t.length-1:r,0),function(){for(var n=arguments,o=-1,a=Y(n.length-r,0),f=Array(a);++o<a;)f[o]=n[r+o];o=-1;for(var u=Array(r+1);++o<r;)u[o]=n[o];return u[r]=e(f),dr(t,this,u)}}function ct(t,r){return _r(Sr(t,r,et),t+"")}var Vr=9007199254740991;function at(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Vr}function U(t){return t!=null&&at(t.length)&&!nt(t)}function ft(t,r,e){if(!g(e))return!1;var n=typeof r;return(n=="number"?U(e)&&ot(r,e.length):n=="string"&&r in e)?B(e[r],t):!1}function Er(t){return ct(function(r,e){var n=-1,o=e.length,a=o>1?e[o-1]:void 0,f=o>2?e[2]:void 0;for(a=t.length>3&&typeof a=="function"?(o--,a):void 0,f&&ft(e[0],e[1],f)&&(a=o<3?void 0:a,o=1),r=Object(r);++n<o;){var u=e[n];u&&t(r,u,n,a)}return r})}var Pr=Object.prototype;function W(t){var r=t&&t.constructor,e=typeof r=="function"&&r.prototype||Pr;return t===e}function Dr(t,r){for(var e=-1,n=Array(t);++e<t;)n[e]=r(e);return n}var Ur="[object Arguments]";function G(t){return D(t)&&P(t)==Ur}var st=Object.prototype,Fr=st.hasOwnProperty,Ir=st.propertyIsEnumerable,Cr=G(function(){return arguments}())?G:function(t){return D(t)&&Fr.call(t,"callee")&&!Ir.call(t,"callee")};const kr=Cr;function Br(){return!1}var lt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,K=lt&&typeof module=="object"&&module&&!module.nodeType&&module,Wr=K&&K.exports===lt,Q=Wr?E.Buffer:void 0,Lr=Q?Q.isBuffer:void 0,qr=Lr||Br;const Rr=qr;var Nr="[object Arguments]",zr="[object Array]",Hr="[object Boolean]",Jr="[object Date]",Yr="[object Error]",Gr="[object Function]",Kr="[object Map]",Qr="[object Number]",Xr="[object Object]",Zr="[object RegExp]",te="[object Set]",re="[object String]",ee="[object WeakMap]",ne="[object ArrayBuffer]",oe="[object DataView]",ie="[object Float32Array]",ue="[object Float64Array]",ce="[object Int8Array]",ae="[object Int16Array]",fe="[object Int32Array]",se="[object Uint8Array]",le="[object Uint8ClampedArray]",ve="[object Uint16Array]",de="[object Uint32Array]",s={};s[ie]=s[ue]=s[ce]=s[ae]=s[fe]=s[se]=s[le]=s[ve]=s[de]=!0;s[Nr]=s[zr]=s[ne]=s[Hr]=s[oe]=s[Jr]=s[Yr]=s[Gr]=s[Kr]=s[Qr]=s[Xr]=s[Zr]=s[te]=s[re]=s[ee]=!1;function pe(t){return D(t)&&at(t.length)&&!!s[P(t)]}function be(t){return function(r){return t(r)}}var vt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_=vt&&typeof module=="object"&&module&&!module.nodeType&&module,ye=_&&_.exports===vt,C=ye&&tt.process,ge=function(){try{var t=_&&_.require&&_.require("util").types;return t||C&&C.binding&&C.binding("util")}catch{}}();const X=ge;var Z=X&&X.isTypedArray,me=Z?be(Z):pe;const he=me;var je=Object.prototype,we=je.hasOwnProperty;function dt(t,r){var e=Bt(t),n=!e&&kr(t),o=!e&&!n&&Rr(t),a=!e&&!n&&!o&&he(t),f=e||n||o||a,u=f?Dr(t.length,String):[],v=u.length;for(var c in t)(r||we.call(t,c))&&!(f&&(c=="length"||o&&(c=="offset"||c=="parent")||a&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||ot(c,v)))&&u.push(c);return u}function Oe(t,r){return function(e){return t(r(e))}}var _e=Oe(Object.keys,Object);const $e=_e;var Ae=Object.prototype,xe=Ae.hasOwnProperty;function Te(t){if(!W(t))return $e(t);var r=[];for(var e in Object(t))xe.call(t,e)&&e!="constructor"&&r.push(e);return r}function Me(t){return U(t)?dt(t):Te(t)}var Se=Object.prototype,Ve=Se.hasOwnProperty,Ee=Er(function(t,r){if(W(r)||U(r)){Mr(r,Me(r),t);return}for(var e in r)Ve.call(r,e)&&ut(t,e,r[e])});const Pe=Ee;function De(t){var r=[];if(t!=null)for(var e in Object(t))r.push(e);return r}var Ue=Object.prototype,Fe=Ue.hasOwnProperty;function Ie(t){if(!g(t))return De(t);var r=W(t),e=[];for(var n in t)n=="constructor"&&(r||!Fe.call(t,n))||e.push(n);return e}function Ce(t){return U(t)?dt(t,!0):Ie(t)}var ke=function(){return E.Date.now()};const k=ke;var Be="Expected a function",We=Math.max,Le=Math.min;function qe(t,r,e){var n,o,a,f,u,v,c=0,i=!1,l=!1,p=!0;if(typeof t!="function")throw new TypeError(Be);r=H(r)||0,g(e)&&(i=!!e.leading,l="maxWait"in e,a=l?We(H(e.maxWait)||0,r):a,p="trailing"in e?!!e.trailing:p);function b(d){var y=n,w=o;return n=o=void 0,c=d,f=t.apply(w,y),f}function m(d){return c=d,u=setTimeout(h,r),i?b(d):f}function j(d){var y=d-v,w=d-c,L=r-y;return l?Le(L,a-w):L}function A(d){var y=d-v,w=d-c;return v===void 0||y>=r||y<0||l&&w>=a}function h(){var d=k();if(A(d))return x(d);u=setTimeout(h,j(d))}function x(d){return u=void 0,p&&n?b(d):(n=o=void 0,f)}function bt(){u!==void 0&&clearTimeout(u),c=0,n=v=o=u=void 0}function yt(){return u===void 0?f:x(k())}function F(){var d=k(),y=A(d);if(n=arguments,o=this,v=d,y){if(u===void 0)return m(v);if(l)return clearTimeout(u),u=setTimeout(h,r),b(v)}return u===void 0&&(u=setTimeout(h,r)),f}return F.cancel=bt,F.flush=yt,F}var pt=Object.prototype,Re=pt.hasOwnProperty,Ne=ct(function(t,r){t=Object(t);var e=-1,n=r.length,o=n>2?r[2]:void 0;for(o&&ft(r[0],r[1],o)&&(n=1);++e<n;)for(var a=r[e],f=Ce(a),u=-1,v=f.length;++u<v;){var c=f[u],i=t[c];(i===void 0||B(i,pt[c])&&!Re.call(t,c))&&(t[c]=a[c])}return t});const ze=Ne,He=({images:t=[],options:r})=>{r=Pe(r,{inline:!1});const e=document.createElement("div"),n=q("div",{style:{display:"none"},class:["__viewer-token"]},t.map(u=>q("img",typeof u=="string"?{src:u}:u)));R(n,e);const o=e.firstElementChild;document.body.appendChild(o);const a=new $(o,r),f=a.destroy.bind(a);return a.destroy=function(){return f(),R(null,e),a},a.show(),o.addEventListener("hidden",function(){this.viewer===a&&a.destroy()}),a},Je=({name:t="viewer",debug:r=!1}={})=>{async function e(i,l,p=!1,b=!1){await M(),!(b&&!n(i))&&(p||!i[`$${t}`]?(f(i),i[`$${t}`]=new $(i,l),c("Viewer created")):(i[`$${t}`].update(),c("Viewer updated")))}function n(i){const l=i.innerHTML.match(/<img([\w\W]+?)[\\/]?>/g),p=l?l.join(""):void 0;return i.__viewerImageDiffCache===p?(c("Element change detected, but image(s) has not changed"),!1):(c("Image change detected"),i.__viewerImageDiffCache=p,!0)}function o(i,l,p,b){u(i);const m=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;if(!m){c("Observer not supported");return}const j=new m(h=>{h.forEach(x=>{c(`Viewer mutation:${x.type}`),p(i,l,b,!0)})}),A={attributes:!0,childList:!0,characterData:!0,subtree:!0};j.observe(i,A),i.__viewerMutationObserver=j,c("Observer created")}function a(i,l,p,b){i.__viewerUnwatch=T(()=>l.value,(m,j)=>{c("Change detected by watcher: ",l.value),b(i,m,!0,!1)},{deep:!0}),c("Watcher created, expression: ",l.value)}function f(i){!i[`$${t}`]||(i[`$${t}`].destroy(),delete i[`$${t}`],c("Viewer destroyed"))}function u(i){!i.__viewerMutationObserver||(i.__viewerMutationObserver.disconnect(),delete i.__viewerMutationObserver,c("observer destroyed"))}function v(i){!i.__viewerUnwatch||(i.__viewerUnwatch(),delete i.__viewerUnwatch,c("Watcher destroyed"))}function c(...i){r&&console.log(...i)}return{mounted(i,l,p){c("Viewer bind");const b=qe(e,50);b(i,l.value),a(i,l,p,b),l.modifiers.static||o(i,l.value,b,l.modifiers.rebuild)},unmounted(i){c("Viewer unbind"),u(i),v(i),f(i)}}},Ye=gt({name:"Viewer",props:{images:{type:Array,default:()=>[]},rebuild:{type:Boolean,default:!1},trigger:{type:Object,default:null},options:{type:Object,default:()=>null}},emits:["inited"],setup(t,{emit:r}){let e;const n=mt();function o(){e=new $(n.value,t.options),r("inited",e)}function a(){e&&e.destroy()}function f(){a(),o()}function u(){e?(e.update(),r("inited",e)):o()}function v(){t.rebuild?f():u()}const c={deep:!0};return T(()=>t.images,()=>{M(()=>{v()})},c),T(()=>t.trigger,()=>{M(()=>{v()})},c),T(()=>t.options,()=>{M(()=>{f()})},c),ht(()=>o()),jt(()=>a()),{root:n,createViewer:o,rebuildViewer:f,updateViewer:u,destroyViewer:a}}}),Ge=(t,r)=>{const e=t.__vccOpts||t;for(const[n,o]of r)e[n]=o;return e},Ke={ref:"root"};function Qe(t,r,e,n,o,a){return wt(),Ot("div",Ke,[_t(t.$slots,"default",{images:t.images,options:t.options})],512)}const Xe=Ge(Ye,[["render",Qe]]),en={install(t,{name:r="viewer",debug:e=!1,defaultOptions:n}={}){n&&$.setDefaults(n),t.config.globalProperties[`$${r}Api`]=He,t.component(r,ze(Xe,{name:r})),t.directive(r,Je({name:r,debug:e}))},setDefaults(t){$.setDefaults(t)}};export{He as q,en as r};
|