index-18e6fd10.js 5.1 KB

1
  1. import{r as _,bD as N,bE as J,bF as K,bG as Q,w as M,e as x,x as V,aq as U,y as Z}from"./index-61b1bbc0.js";function D(e){return N()?(J(e),!0):!1}function y(e){return typeof e=="function"?e():K(e)}const A=typeof window<"u",g=()=>{};function B(e,r){function t(...o){return new Promise((s,n)=>{Promise.resolve(e(()=>r.apply(this,o),{fn:r,thisArg:this,args:o})).then(s).catch(n)})}return t}function k(e,r={}){let t,o,s=g;const n=i=>{clearTimeout(i),s(),s=g};return i=>{const f=y(e),c=y(r.maxWait);return t&&n(t),f<=0||c!==void 0&&c<=0?(o&&(n(o),o=null),Promise.resolve(i())):new Promise((a,m)=>{s=r.rejectOnCancel?m:a,c&&!o&&(o=setTimeout(()=>{t&&n(t),o=null,a(i())},c)),t=setTimeout(()=>{o&&n(o),o=null,a(i())},f)})}}function ee(e,r=!0,t=!0,o=!1){let s=0,n,l=!0,i=g,f;const c=()=>{n&&(clearTimeout(n),n=void 0,i(),i=g)};return m=>{const p=y(e),v=Date.now()-s,O=()=>f=m();return c(),p<=0?(s=Date.now(),O()):(v>p&&(t||!l)?(s=Date.now(),O()):r&&(f=new Promise((d,h)=>{i=o?h:d,n=setTimeout(()=>{s=Date.now(),l=!0,d(O()),c()},Math.max(0,p-v))})),!t&&!n&&(n=setTimeout(()=>l=!0,p)),l=!1,f)}}function te(e,r=200,t={}){return B(k(r,t),e)}function re(e,r=200,t=!1,o=!0,s=!1){return B(ee(r,t,o,s),e)}function oe(e,r=1e3,t={}){const{immediate:o=!0,immediateCallback:s=!1}=t;let n=null;const l=_(!1);function i(){n&&(clearInterval(n),n=null)}function f(){l.value=!1,i()}function c(){const a=y(r);a<=0||(l.value=!0,s&&e(),i(),n=setInterval(e,a))}if(o&&A&&c(),Q(r)||typeof r=="function"){const a=M(r,()=>{l.value&&A&&c()});D(a)}return D(f),{isActive:l,pause:f,resume:c}}var ne=Object.defineProperty,X=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,z=(e,r,t)=>r in e?ne(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,ae=(e,r)=>{for(var t in r||(r={}))se.call(r,t)&&z(e,t,r[t]);if(X)for(var t of X(r))le.call(r,t)&&z(e,t,r[t]);return e};function ve(e=1e3,r={}){const{controls:t=!1,immediate:o=!0,callback:s}=r,n=_(0),l=()=>n.value+=1,i=()=>{n.value=0},f=oe(s?()=>{l(),s(n.value)}:l,e,{immediate:o});return t?ae({counter:n,reset:i},f):n}function I(e){var r;const t=y(e);return(r=t==null?void 0:t.$el)!=null?r:t}const R=A?window:void 0;function $(...e){let r,t,o,s;if(typeof e[0]=="string"||Array.isArray(e[0])?([t,o,s]=e,r=R):[r,t,o,s]=e,!r)return g;Array.isArray(t)||(t=[t]),Array.isArray(o)||(o=[o]);const n=[],l=()=>{n.forEach(a=>a()),n.length=0},i=(a,m,p,v)=>(a.addEventListener(m,p,v),()=>a.removeEventListener(m,p,v)),f=M(()=>[I(r),y(s)],([a,m])=>{l(),a&&n.push(...t.flatMap(p=>o.map(v=>i(a,p,v,m))))},{immediate:!0,flush:"post"}),c=()=>{f(),l()};return D(c),c}function ue(){const e=_(!1);return U()&&Z(()=>{e.value=!0}),e}function ie(e){const r=ue();return x(()=>(r.value,!!e()))}var Y=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable,pe=(e,r)=>{var t={};for(var o in e)ce.call(e,o)&&r.indexOf(o)<0&&(t[o]=e[o]);if(e!=null&&Y)for(var o of Y(e))r.indexOf(o)<0&&fe.call(e,o)&&(t[o]=e[o]);return t};function de(e,r,t={}){const o=t,{window:s=R}=o,n=pe(o,["window"]);let l;const i=ie(()=>s&&"ResizeObserver"in s),f=()=>{l&&(l.disconnect(),l=void 0)},c=x(()=>Array.isArray(e)?e.map(p=>I(p)):[I(e)]),a=M(c,p=>{if(f(),i.value&&s){l=new ResizeObserver(r);for(const v of p)v&&l.observe(v,n)}},{immediate:!0,flush:"post",deep:!0}),m=()=>{f(),a()};return D(m),{isSupported:i,stop:m}}const q=1;function he(e,r={}){const{throttle:t=0,idle:o=200,onStop:s=g,onScroll:n=g,offset:l={left:0,right:0,top:0,bottom:0},eventListenerOptions:i={capture:!1,passive:!0},behavior:f="auto"}=r,c=_(0),a=_(0),m=x({get(){return c.value},set(u){v(u,void 0)}}),p=x({get(){return a.value},set(u){v(void 0,u)}});function v(u,b){var T,P,w;const E=y(e);E&&((w=E instanceof Document?document.body:E)==null||w.scrollTo({top:(T=y(b))!=null?T:p.value,left:(P=y(u))!=null?P:m.value,behavior:y(f)}))}const O=_(!1),d=V({left:!0,right:!1,top:!0,bottom:!1}),h=V({left:!1,right:!1,top:!1,bottom:!1}),j=u=>{O.value&&(O.value=!1,h.left=!1,h.right=!1,h.top=!1,h.bottom=!1,s(u))},G=te(j,t+o),L=u=>{const b=u===window?u.document.documentElement:u===document?u.documentElement:u,{display:T,flexDirection:P}=getComputedStyle(b),w=b.scrollLeft;h.left=w<c.value,h.right=w>c.value;const E=Math.abs(w)<=0+(l.left||0),C=Math.abs(w)+b.clientWidth>=b.scrollWidth-(l.right||0)-q;T==="flex"&&P==="row-reverse"?(d.left=C,d.right=E):(d.left=E,d.right=C),c.value=w;let S=b.scrollTop;u===document&&!S&&(S=document.body.scrollTop),h.top=S<a.value,h.bottom=S>a.value;const F=Math.abs(S)<=0+(l.top||0),H=Math.abs(S)+b.clientHeight>=b.scrollHeight-(l.bottom||0)-q;T==="flex"&&P==="column-reverse"?(d.top=H,d.bottom=F):(d.top=F,d.bottom=H),a.value=S},W=u=>{const b=u.target===document?u.target.documentElement:u.target;L(b),O.value=!0,G(u),n(u)};return $(e,"scroll",t?re(W,t,!0,!1):W,i),$(e,"scrollend",j,i),{x:m,y:p,isScrolling:O,arrivedState:d,directions:h,measure(){const u=y(e);u&&L(u)}}}function be({window:e=R}={}){if(!e)return{x:_(0),y:_(0)};const r=_(e.scrollX),t=_(e.scrollY);return $(e,"scroll",()=>{r.value=e.scrollX,t.value=e.scrollY},{capture:!1,passive:!0}),{x:r,y:t}}export{be as a,he as b,ve as c,de as d,$ as u};