1 |
- var R=new Set,f=new WeakMap,T=new WeakMap,w=new WeakMap,B=new WeakMap,U=new WeakMap,M=new WeakMap,S=new WeakMap,O=new WeakSet,g,k=0,$=0,p="__aa_tgt",W="__aa_del",N="__aa_new",G=t=>{let e=tt(t);e&&e.forEach(n=>et(n))},V=t=>{t.forEach(e=>{e.target===g&&K(),f.has(e.target)&&y(e.target)})};function J(t){let e=B.get(t);e?.disconnect();let n=f.get(t),o=0,i=5;n||(n=x(t),f.set(t,n));let{offsetWidth:r,offsetHeight:s}=g,d=[n.top-i,r-(n.left+i+n.width),s-(n.top+i+n.height),n.left-i].map(c=>`${-1*Math.floor(c)}px`).join(" "),l=new IntersectionObserver(()=>{++o>1&&y(t)},{root:g,threshold:1,rootMargin:d});l.observe(t),B.set(t,l)}function y(t){clearTimeout(S.get(t));let e=P(t),n=C(e)?500:e.duration;S.set(t,setTimeout(async()=>{let o=w.get(t);try{await o?.finished,f.set(t,x(t)),J(t)}catch{}},n))}function K(){clearTimeout(S.get(g)),S.set(g,setTimeout(()=>{R.forEach(t=>I(t,e=>D(()=>y(e))))},100))}function Z(t){setTimeout(()=>{U.set(t,setInterval(()=>D(y.bind(null,t)),2e3))},Math.round(2e3*Math.random()))}function D(t){typeof requestIdleCallback=="function"?requestIdleCallback(()=>t()):requestAnimationFrame(()=>t())}var _,E;typeof window<"u"&&(g=document.documentElement,_=new MutationObserver(G),E=new ResizeObserver(V),window.addEventListener("scroll",()=>{$=window.scrollY,k=window.scrollX}),E.observe(g));function tt(t){return t.reduce((o,i)=>[...o,...Array.from(i.addedNodes),...Array.from(i.removedNodes)],[]).every(o=>o.nodeName==="#comment")?!1:t.reduce((o,i)=>{if(o===!1)return!1;if(i.target instanceof Element){if(L(i.target),!o.has(i.target)){o.add(i.target);for(let r=0;r<i.target.children.length;r++){let s=i.target.children.item(r);if(s){if(W in s)return!1;L(i.target,s),o.add(s)}}}if(i.removedNodes.length)for(let r=0;r<i.removedNodes.length;r++){let s=i.removedNodes[r];if(W in s)return!1;s instanceof Element&&(o.add(s),L(i.target,s),T.set(s,[i.previousSibling,i.nextSibling]))}}return o},new Set)}function L(t,e){!e&&!(p in t)?Object.defineProperty(t,p,{value:t}):e&&!(p in e)&&Object.defineProperty(e,p,{value:t})}function et(t){var e;let n=t.isConnected,o=f.has(t);n&&T.has(t)&&T.delete(t),w.has(t)&&((e=w.get(t))===null||e===void 0||e.cancel()),N in t?Y(t):o&&n?ot(t):o&&!n?it(t):Y(t)}function h(t){return Number(t.replace(/[^0-9.\-]/g,""))}function nt(t){let e=t.parentElement;for(;e;){if(e.scrollLeft||e.scrollTop)return{x:e.scrollLeft,y:e.scrollTop};e=e.parentElement}return{x:0,y:0}}function x(t){let e=t.getBoundingClientRect(),{x:n,y:o}=nt(t);return{top:e.top+o,left:e.left+n,width:e.width,height:e.height}}function H(t,e,n){let o=e.width,i=e.height,r=n.width,s=n.height,a=getComputedStyle(t);if(a.getPropertyValue("box-sizing")==="content-box"){let l=h(a.paddingTop)+h(a.paddingBottom)+h(a.borderTopWidth)+h(a.borderBottomWidth),c=h(a.paddingLeft)+h(a.paddingRight)+h(a.borderRightWidth)+h(a.borderLeftWidth);o-=c,r-=c,i-=l,s-=l}return[o,r,i,s].map(Math.round)}function P(t){return p in t&&M.has(t[p])?M.get(t[p]):{duration:250,easing:"ease-in-out"}}function F(t){if(p in t)return t[p]}function j(t){let e=F(t);return e?O.has(e):!1}function I(t,...e){e.forEach(n=>n(t,M.has(t)));for(let n=0;n<t.children.length;n++){let o=t.children.item(n);o&&e.forEach(i=>i(o,M.has(o)))}}function X(t){return Array.isArray(t)?t:[t]}function C(t){return typeof t=="function"}function ot(t){let e=f.get(t),n=x(t);if(!j(t))return f.set(t,n);let o;if(!e)return;let i=P(t);if(typeof i!="function"){let r=e.left-n.left,s=e.top-n.top,[a,d,l,c]=H(t,e,n),m={transform:`translate(${r}px, ${s}px)`},u={transform:"translate(0, 0)"};a!==d&&(m.width=`${a}px`,u.width=`${d}px`),l!==c&&(m.height=`${l}px`,u.height=`${c}px`),o=t.animate([m,u],{duration:i.duration,easing:i.easing})}else{let[r]=X(i(t,"remain",e,n));o=new Animation(r),o.play()}w.set(t,o),f.set(t,n),o.addEventListener("finish",y.bind(null,t))}function Y(t){N in t&&delete t[N];let e=x(t);f.set(t,e);let n=P(t);if(!j(t))return;let o;if(typeof n!="function")o=t.animate([{transform:"scale(.98)",opacity:0},{transform:"scale(0.98)",opacity:0,offset:.5},{transform:"scale(1)",opacity:1}],{duration:n.duration*1.5,easing:"ease-in"});else{let[i]=X(n(t,"add",e));o=new Animation(i),o.play()}w.set(t,o),o.addEventListener("finish",y.bind(null,t))}function z(t,e){var n;t.remove(),f.delete(t),T.delete(t),w.delete(t),(n=B.get(t))===null||n===void 0||n.disconnect(),setTimeout(()=>{if(W in t&&delete t[W],Object.defineProperty(t,N,{value:!0,configurable:!0}),e&&t instanceof HTMLElement)for(let o in e)t.style[o]=""},0)}function it(t){var e;if(!T.has(t)||!f.has(t))return;let[n,o]=T.get(t);Object.defineProperty(t,W,{value:!0,configurable:!0});let i=window.scrollX,r=window.scrollY;if(o&&o.parentNode&&o.parentNode instanceof Element?o.parentNode.insertBefore(t,o):n&&n.parentNode?n.parentNode.appendChild(t):(e=F(t))===null||e===void 0||e.appendChild(t),!j(t))return z(t);let[s,a,d,l]=st(t),c=P(t),m=f.get(t);(i!==k||r!==$)&&rt(t,i,r,c);let u,v={position:"absolute",top:`${s}px`,left:`${a}px`,width:`${d}px`,height:`${l}px`,margin:"0",pointerEvents:"none",transformOrigin:"center",zIndex:"100"};if(!C(c))Object.assign(t.style,v),u=t.animate([{transform:"scale(1)",opacity:1},{transform:"scale(.98)",opacity:0}],{duration:c.duration,easing:"ease-out"});else{let[A,b]=X(c(t,"remove",m));b?.styleReset!==!1&&(v=b?.styleReset||v,Object.assign(t.style,v)),u=new Animation(A),u.play()}w.set(t,u),u.addEventListener("finish",z.bind(null,t,v))}function rt(t,e,n,o){let i=k-e,r=$-n,s=document.documentElement.style.scrollBehavior;if(getComputedStyle(g).scrollBehavior==="smooth"&&(document.documentElement.style.scrollBehavior="auto"),window.scrollTo(window.scrollX+i,window.scrollY+r),!t.parentElement)return;let d=t.parentElement,l=d.clientHeight,c=d.clientWidth,m=performance.now();function u(){requestAnimationFrame(()=>{if(!C(o)){let v=l-d.clientHeight,A=c-d.clientWidth;m+o.duration>performance.now()?(window.scrollTo({left:window.scrollX-A,top:window.scrollY-v}),l=d.clientHeight,c=d.clientWidth,u()):document.documentElement.style.scrollBehavior=s}})}u()}function st(t){let e=f.get(t),[n,,o]=H(t,e,x(t)),i=t.parentElement;for(;i&&(getComputedStyle(i).position==="static"||i instanceof HTMLBodyElement);)i=i.parentElement;i||(i=document.body);let r=getComputedStyle(i),s=f.get(i)||x(i),a=Math.round(e.top-s.top)-h(r.borderTopWidth),d=Math.round(e.left-s.left)-h(r.borderLeftWidth);return[a,d,n,o]}function q(t,e={}){return _&&E&&(window.matchMedia("(prefers-reduced-motion: reduce)").matches&&!C(e)&&!e.disrespectUserMotionPreference||(O.add(t),getComputedStyle(t).position==="static"&&Object.assign(t.style,{position:"relative"}),I(t,y,Z,i=>E?.observe(i)),C(e)?M.set(t,e):M.set(t,{duration:250,easing:"ease-in-out",...e}),_.observe(t,{childList:!0}),R.add(t))),Object.freeze({parent:t,enable:()=>{O.add(t)},disable:()=>{O.delete(t)},isEnabled:()=>O.has(t)})}function Q(t){t.directive("autoanimate",(e,{expression:n},{evaluate:o})=>{q(e,n&&o(n)||{})})}var lt=Q;export{lt as default};
|