2 lines
102 KiB
JavaScript
2 lines
102 KiB
JavaScript
|
|
(function(E,v,i){"use strict";function Oe(e,t,n){let o;i.isRef(n)?o={evaluating:n}:o=n||{};const{lazy:r=!1,evaluating:l=void 0,shallow:a=!0,onError:u=v.noop}=o,s=i.ref(!r),f=a?i.shallowRef(t):i.ref(t);let c=0;return i.watchEffect(async d=>{if(!s.value)return;c++;const g=c;let m=!1;l&&Promise.resolve().then(()=>{l.value=!0});try{const b=await e(y=>{d(()=>{l&&(l.value=!1),m||y()})});g===c&&(f.value=b)}catch(b){u(b)}finally{l&&g===c&&(l.value=!1),m=!0}}),r?i.computed(()=>(s.value=!0,f.value)):f}function Et(e,t,n,o){let r=i.inject(e);return n&&(r=i.inject(e,n)),o&&(r=i.inject(e,n,o)),typeof t=="function"?i.computed(l=>t(r,l)):i.computed({get:l=>t.get(r,l),set:t.set})}function Tt(e={}){const{inheritAttrs:t=!0}=e,n=i.shallowRef(),o=i.defineComponent({setup(l,{slots:a}){return()=>{n.value=a.default}}}),r=i.defineComponent({inheritAttrs:t,setup(l,{attrs:a,slots:u}){return()=>{var s;if(!n.value&&process.env.NODE_ENV!=="production")throw new Error("[VueUse] Failed to find the definition of reusable template");const f=(s=n.value)==null?void 0:s.call(n,{...kt(a),$slots:u});return t&&f?.length===1?f[0]:f}}});return v.makeDestructurable({define:o,reuse:r},[o,r])}function kt(e){const t={};for(const n in e)t[v.camelize(n)]=e[n];return t}function Ot(e={}){let t=0;const n=i.ref([]);function o(...a){const u=i.shallowReactive({key:t++,args:a,promise:void 0,resolve:()=>{},reject:()=>{},isResolving:!1,options:e});return n.value.push(u),u.promise=new Promise((s,f)=>{u.resolve=c=>(u.isResolving=!0,s(c)),u.reject=f}).finally(()=>{u.promise=void 0;const s=n.value.indexOf(u);s!==-1&&n.value.splice(s,1)}),u.promise}function r(...a){return e.singleton&&n.value.length>0?n.value[0].promise:o(...a)}const l=i.defineComponent((a,{slots:u})=>{const s=()=>n.value.map(f=>{var c;return i.h(i.Fragment,{key:f.key},(c=u.default)==null?void 0:c.call(u,f))});return e.transition?()=>i.h(i.TransitionGroup,e.transition,s):s});return l.start=r,l}function _t(e){return function(...t){return e.apply(this,t.map(n=>v.toValue(n)))}}const I=v.isClient?window:void 0,U=v.isClient?window.document:void 0,B=v.isClient?window.navigator:void 0,Rt=v.isClient?window.location:void 0;function L(e){var t;const n=v.toValue(e);return(t=n?.$el)!=null?t:n}function O(...e){let t,n,o,r;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,o,r]=e,t=I):[t,n,o,r]=e,!t)return v.noop;Array.isArray(n)||(n=[n]),Array.isArray(o)||(o=[o]);const l=[],a=()=>{l.forEach(c=>c()),l.length=0},u=(c,d,g,m)=>(c.addEventListener(d,g,m),()=>c.removeEventListener(d,g,m)),s=i.watch(()=>[L(t),v.toValue(r)],([c,d])=>{if(a(),!c)return;const g=v.isObject(d)?{...d}:d;l.push(...n.flatMap(m=>o.map(b=>u(c,m,b,g))))},{immediate:!0,flush:"post"}),f=()=>{s(),a()};return v.tryOnScopeDispose(f),f}let _e=!1;function Vt(e,t,n={}){const{window:o=I,ignore:r=[],capture:l=!0,detectIframe:a=!1}=n;if(!o)return v.noop;v.isIOS&&!_e&&(_e=!0,Array.from(o.document.body.children).forEach(y=>y.addEventListener("click",v.noop)),o.document.documentElement.addEventListener("click",v.noop));let u=!0;const s=y=>v.toValue(r).some(w=>{if(typeof w=="string")return Array.from(o.document.querySelectorAll(w)).some(p=>p===y.target||y.composedPath().includes(p));{const p=L(w);return p&&(y.target===p||y.composedPath().includes(p))}});function f(y){const w=v.toValue(y);return w&&w.$.subTree.shapeFlag===16}function c(y,w){const p=v.toValue(y),h=p.$.subTree&&p.$.subTree.children;return h==null||!Array.isArray(h)?!1:h.some(S=>S.el===w.target||w.composedPath().includes(S.el))}const d=y=>{const w=L(e);if(y.target!=null&&!(!(w instanceof Element)&&f(e)&&c(e,y))&&!(!w||w===y.target||y.composedPath().includes(w))){if(y.detail===0&&(u=!s(y)),!u){u=!0;return}t(y)}};let g=!1;const m=[O(o,"click",y=>{g||(g=!0,setTimeout(()=>{g=!1},0),d(y))},{passive:!0,capture:l}),O(o,"pointerdown",y=>{const w=L(e);u=!s(y)&&!!(w&&!y.composedPath().includes(w))},{passive:!0}),a&&O(o,"blur",y=>{setTimeout(()=>{var w;const p=L(e);((w=o.document.activeElement)==null?void 0:w.tagName)==="IFRAME"&&!p?.contains(o.document.activeElement)&&t(y)},0)})].filter(Boolean);return()=>m.forEach(y=>y())}f
|