framer-motion
Version:
A simple and powerful JavaScript animation library
3 lines • 68.4 kB
JavaScript
function t(t,e){const s=t.indexOf(e);s>-1&&t.splice(s,1)}const e=(t,e,s)=>s>e?e:s<t?t:s,s={},n=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t),i=t=>"object"==typeof t&&null!==t,r=t=>/^0[^.\s]+$/u.test(t);const a=t=>t,o=(...t)=>t.reduce((t,e)=>s=>e(t(s))),h=(t,e,s)=>{const n=e-t;return n?(s-t)/n:1};class l{constructor(){this.subscriptions=[]}add(t){var e,s;return e=this.subscriptions,s=t,-1===e.indexOf(s)&&e.push(s),()=>this.remove(t)}remove(e){t(this.subscriptions,e)}notify(t,e,s){const n=this.subscriptions.length;if(n)if(1===n)this.subscriptions[0](t,e,s);else for(let i=0;i<n;i++){const n=this.subscriptions[i];n&&n(t,e,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const u=t=>1e3*t,c=t=>t/1e3,p=(t,e)=>e?t*(1e3/e):0,d=(t,e,s)=>t*(3*(1-t)*((1-t)*e+t*s)+t*t);function m(t,e,s,n){return t===e&&s===n?a:i=>{let r=0,a=1,o=i;for(let e=0;;e++){o>=r&&o<=a||(o=(r+a)/2);const n=d(o,t,s)-i;if(n*n<1e-28||40===e)break;n>0?a=o:r=o,o-=1e-7*n/(d(o+1e-7,t,s)-i-n)}return d(o,e,n)}}const f=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,g=t=>e=>1-t(1-e),y=m(.33,1.53,.69,.99),v=g(y),b=f(v),T=t=>t>=1?1:(t*=2)<1?.5*v(t):.5*(2-Math.pow(2,-10*(t-1))),A=t=>1-Math.sin(Math.acos(t)),k=g(A),w=f(A),M=m(.42,0,1,1),S=m(0,0,.58,1),x=m(.42,0,.58,1),D=t=>Array.isArray(t)&&"number"!=typeof t[0];function R(t,e){return D(t)?t[((t,e,s)=>{const n=e-t;return((s-t)%n+n)%n+t})(0,t.length,e)]:t}const F=t=>Array.isArray(t)&&"number"==typeof t[0],C={linear:a,easeIn:M,easeInOut:x,easeOut:S,circIn:A,circInOut:w,circOut:k,backIn:v,backInOut:b,backOut:y,anticipate:T},E=t=>{if(F(t)){const[e,s,n,i]=t;return m(e,s,n,i)}return"string"==typeof t?C[t]:t},P={delta:0,timestamp:0,isProcessing:!1};let V;function O(){V=void 0}const I={now:()=>(void 0===V&&I.set(P.isProcessing||s.useManualTiming?P.timestamp:performance.now()),V),set:t=>{V=t,queueMicrotask(O)}},K=t=>Math.round(1e5*t)/1e5,W=(t=>e=>"string"==typeof e&&e.startsWith(t))("var(--"),N=t=>!!W(t)&&j.test(t.split("/*")[0].trim()),j=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function B(t){return"string"==typeof t&&t.split("/*")[0].includes("var(--")}const Y={test:t=>"number"==typeof t,parse:parseFloat,transform:t=>t},U={...Y,transform:t=>e(0,1,t)},$={...Y,default:1},_=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const q=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,X=(t,e)=>s=>Boolean("string"==typeof s&&q.test(s)&&s.startsWith(t)||e&&!function(t){return null==t}(s)&&Object.prototype.hasOwnProperty.call(s,e)),z=(t,e,s)=>n=>{if("string"!=typeof n)return n;const[i,r,a,o]=n.match(_);return{[t]:parseFloat(i),[e]:parseFloat(r),[s]:parseFloat(a),alpha:void 0!==o?parseFloat(o):1}},L={...Y,transform:t=>Math.round((t=>e(0,255,t))(t))},Z={test:X("rgb","red"),parse:z("red","green","blue"),transform:({red:t,green:e,blue:s,alpha:n=1})=>"rgba("+L.transform(t)+", "+L.transform(e)+", "+L.transform(s)+", "+K(U.transform(n))+")"},J=(t,e,s)=>{const n=t.substring(1+e*s,1+(e+1)*s);return s>1?n:n+n};const G={test:X("#"),parse:function(t){const e=t.length>5?2:1,s=J(t,3,e);return{red:parseInt(J(t,0,e),16),green:parseInt(J(t,1,e),16),blue:parseInt(J(t,2,e),16),alpha:s?parseInt(s,16)/255:1}},transform:Z.transform},H=t=>({test:e=>"string"==typeof e&&e.endsWith(t)&&1===e.split(" ").length,parse:parseFloat,transform:e=>`${e}${t}`}),Q=H("deg"),tt=H("%"),et=H("px"),st=H("vh"),nt=H("vw"),it=(()=>({...tt,parse:t=>tt.parse(t)/100,transform:t=>tt.transform(100*t)}))(),rt={test:X("hsl","hue"),parse:z("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:s,alpha:n=1})=>"hsla("+Math.round(t)+", "+tt.transform(K(e))+", "+tt.transform(K(s))+", "+K(U.transform(n))+")"},at={test:t=>Z.test(t)||G.test(t)||rt.test(t),parse:t=>Z.test(t)?Z.parse(t):rt.test(t)?rt.parse(t):G.parse(t),transform:t=>"string"==typeof t?t:t.hasOwnProperty("red")?Z.transform(t):rt.transform(t),getAnimatableNone:t=>{const e=at.parse(t);return e.alpha=0,at.transform(e)}},ot=new RegExp(_.source),ht=new RegExp(/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu.source,"i");const lt="number",ut="color",ct=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)(?![a-z]*\()/giu;function pt(t){const e=t.toString();return ot.test(e)||ht.test(e)}function dt(t){const e=t.toString(),s=[],n={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(ct,t=>(at.test(t)?(n.color.push(r),i.push(ut),s.push(at.parse(t))):t.startsWith("var(")?(n.var.push(r),i.push("var"),s.push(t)):(n.number.push(r),i.push(lt),s.push(parseFloat(t))),++r,"${}")).split("${}");return{values:s,split:a,indexes:n,types:i}}function mt({split:t,types:e}){const s=t.length;return n=>{let i="";for(let r=0;r<s;r++)if(i+=t[r],void 0!==n[r]){const t=e[r];i+=t===lt?K(n[r]):t===ut?at.transform(n[r]):n[r]}return i}}const ft=(t,e)=>{return"number"==typeof t?e?.trim().endsWith("/")?t:0:"number"==typeof(s=t)?0:at.test(s)?at.getAnimatableNone(s):s;var s};const gt={test:function(t){return isNaN(t)&&"string"==typeof t&&(ot.test(t)||ht.test(t))},parse:function(t){return dt(t).values},createTransformer:function(t){return mt(dt(t))},getAnimatableNone:function(t){const e=dt(t);return mt(e)(e.values.map((t,s)=>ft(t,e.split[s])))}};function yt(t,e,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t}function vt(t,e){return s=>s>0?e:t}const bt=(t,e,s)=>t+(e-t)*s,Tt=(t,e,s)=>{const n=t*t,i=s*(e*e-n)+n;return i<0?0:Math.sqrt(i)},At=[G,Z,rt];function kt(t){const e=(s=t,At.find(t=>t.test(s)));var s;if(!e)return!1;let n=e.parse(t);return e===rt&&(n=function({hue:t,saturation:e,lightness:s,alpha:n}){t/=360,s/=100;let i=0,r=0,a=0;if(e/=100){const n=s<.5?s*(1+e):s+e-s*e,o=2*s-n;i=yt(o,n,t+1/3),r=yt(o,n,t),a=yt(o,n,t-1/3)}else i=r=a=s;return{red:Math.round(255*i),green:Math.round(255*r),blue:Math.round(255*a),alpha:n}}(n)),n}const wt=(t,e)=>{const s=kt(t),n=kt(e);if(!s||!n)return vt(t,e);const i={...s};return t=>(i.red=Tt(s.red,n.red,t),i.green=Tt(s.green,n.green,t),i.blue=Tt(s.blue,n.blue,t),i.alpha=bt(s.alpha,n.alpha,t),Z.transform(i))},Mt=new Set(["none","hidden"]);function St(t,e){return s=>bt(t,e,s)}function xt(t){return"number"==typeof t?St:"string"==typeof t?N(t)?vt:at.test(t)?wt:Ft:Array.isArray(t)?Dt:"object"==typeof t?at.test(t)?wt:Rt:vt}function Dt(t,e){const s=[...t],n=s.length,i=t.map((t,s)=>xt(t)(t,e[s]));return t=>{for(let e=0;e<n;e++)s[e]=i[e](t);return s}}function Rt(t,e){const s={...t,...e},n={};for(const i in s)void 0!==t[i]&&void 0!==e[i]&&(n[i]=xt(t[i])(t[i],e[i]));return t=>{for(const e in n)s[e]=n[e](t);return s}}const Ft=(t,e)=>{const s=dt(t),n=dt(e);return s.indexes.var.length===n.indexes.var.length&&s.indexes.color.length===n.indexes.color.length&&s.indexes.number.length>=n.indexes.number.length?Mt.has(t)&&!n.values.length||Mt.has(e)&&!s.values.length?function(t,e){return Mt.has(t)?s=>s<=0?t:e:s=>s>=1?e:t}(t,e):o(Dt(function(t,e){const s=[],n={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const r=e.types[i],a=t.indexes[r][n[r]],o=t.values[a]??0;s[i]=o,n[r]++}return s}(s,n),n.values),mt(n)):vt(t,e)},Ct=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function Et(t,e,s){if("number"==typeof t&&"number"==typeof e&&"number"==typeof s)return bt(t,e,s);if("string"==typeof t&&"string"==typeof e){const s=function(t,e){const s=Ct.exec(t);if(!s)return;const n=Ct.exec(e);if(!n||s[2]!==n[2])return;const i=s[2],r=parseFloat(s[1]),a=parseFloat(n[1]);return t=>K(bt(r,a,t))+i}(t,e);if(s)return s}return xt(t)(t,e)}const Pt=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Vt(t,e,n={delta:0,timestamp:0,isProcessing:!1}){let i=!1,r=!0;const a=()=>i=!0,o=Pt.reduce((t,e)=>(t[e]=function(t){let e,s=new Set,n=new Set,i=!1,r=!1;const a=new Set;let o={delta:0,timestamp:0,isProcessing:!1};function h(s){a.has(s)&&(n.add(s),t()),(e=s)(o)}const l={schedule:(t,r=!1,o=!1)=>{const h=o&&i,l=h?s:n;return r&&a.add(t),h&&t!==e&&l.delete(t),l.add(t),t},cancel:t=>{n.delete(t),a.delete(t)},process:t=>{if(o=t,i)return void(r=!0);i=!0;const a=s;s=n,n=a,s.forEach(h),s.clear(),e=void 0,i=!1,r&&(r=!1,l.process(t))}};return l}(a),t),{}),{setup:h,read:l,resolveKeyframes:u,preUpdate:c,update:p,preRender:d,render:m,postRender:f}=o,g=()=>{const a=s.useManualTiming,o=a?n.timestamp:performance.now();i=!1,a||(n.delta=r?1e3/60:Math.max(Math.min(o-n.timestamp,40),1)),n.timestamp=o,n.isProcessing=!0,h.process(n),l.process(n),u.process(n),c.process(n),p.process(n),d.process(n),m.process(n),f.process(n),n.isProcessing=!1,i&&e&&(r=!1,t(g))};return{schedule:Pt.reduce((e,s)=>{const a=o[s];return e[s]=(e,s=!1,o=!1)=>(i||(i=!0,r=!0,n.isProcessing||t(g)),a.schedule(e,s,o)),e},{}),cancel:t=>{for(let e=0;e<Pt.length;e++)o[Pt[e]].cancel(t)},state:n,steps:o}}const{schedule:Ot,cancel:It}=Vt("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:a,!0,P),Kt=t=>{const e=({timestamp:e})=>t(e);return{start:(t=!0)=>Ot.update(e,t),stop:()=>It(e),now:()=>P.isProcessing?P.timestamp:I.now()}},Wt=(t,e,s=10)=>{let n="";const i=Math.max(Math.round(e/s),2);for(let e=0;e<i;e++)n+=Math.round(1e4*t(e/(i-1)))/1e4+", ";return`linear(${n.substring(0,n.length-2)})`},Nt=2e4;function jt(t,e=50,s=2e4,n){let i=0,r=t.next(i);for(;!r.done&&i<s;)i+=e,r=t.next(i);return i>=s?1/0:i}function Bt(t,e=100,s){const{keyframes:n,velocity:i}=t,r=n&&n[n.length-1]-n[0],a=s({...t,velocity:i&&r?i*e/r:i,keyframes:[0,e]}),o=Math.min(jt(a),Nt);return{type:"keyframes",ease:t=>a.next(o*t).value/e,duration:c(o)}}const Yt=t=>t<0?1/Math.max(1+t,.05):Math.max(1-t,.05);function Ut(t,e){if(!(t>1))return 1;const s=Math.sqrt(t*t-1),n=t-s,i=t+s,r=2*s*Math.exp(-e)*(1+e);return qt(t=>i*Math.exp(-n*t)-n*Math.exp(-i*t)-r,t=>Math.exp(-i*t)-Math.exp(-n*t),e)/e}function $t(t,e){return t*Math.sqrt(1-e*e)}const _t=12;function qt(t,e,s){let n=s;for(let s=1;s<_t;s++)n-=t(n)/e(n);return n}const Xt=.001;const zt=(t,e)=>(e?t>=0:t>0)&&t<1/0;function Lt(t,e){if(zt(t,e))return t}function Zt(t){const s=Lt(t.stiffness),n=Lt(t.damping,!0),i=Lt(t.mass),r={...t,stiffness:s??100,damping:n??10,mass:i??1,isResolvedFromDuration:!1,isTimeDefined:void 0===(s??n??i)&&(void 0!==t.duration||void 0!==t.bounce)};if(r.isTimeDefined){if(t.visualDuration){const e=Yt(t.bounce||0),s=2*Math.PI/(1.2*t.visualDuration)*Ut(e,2*Math.PI/1.2);r.stiffness=s*s,r.damping=2*e*Math.sqrt(r.stiffness)}else Object.assign(r,function({duration:t=800,bounce:s=.3}){let n,i;const r=Yt(s);t=e(.01,10,c(t)),r<1?(n=e=>{const s=e*r,n=s*t,i=$t(e,r),a=Math.exp(-n);return Xt-s/i*a},i=e=>{const s=e*r*t,i=r*r*e*e*t,a=Math.exp(-s),o=$t(e*e,r);return(-n(e)+Xt>0?-1:1)*-i*a/o}):(n=e=>Math.exp(-e*t)*(e*t+1)-.001,i=e=>Math.exp(-e*t)*(t*t*-e));const a=qt(n,i,5/t),o=a*Ut(r,a*t),h=o*o;return{stiffness:h,damping:2*r*Math.sqrt(h),duration:u(t)}}(r)),r.isResolvedFromDuration=!0;zt(r.stiffness)&&zt(r.damping,!0)||(r.stiffness=100,r.damping=10)}return r}function Jt(t=.3,e=.3){const s="object"!=typeof t?{visualDuration:t,keyframes:[0,1],bounce:e}:t,n=s.keyframes[0],i=s.keyframes[s.keyframes.length-1],r={done:!1,value:n},{stiffness:a,damping:o,mass:h,duration:l,isResolvedFromDuration:p,isTimeDefined:d}=Zt({...s}),m=t=>d?0:-c(t),f=o/(2*Math.sqrt(a*h)),g=c(Math.sqrt(a/h)),y=f*g,v={target:i,delta:i-n,velocity:m(s.velocity||0)||0,restSpeed:0,restDelta:0},b=()=>{const t=Math.abs(v.delta)<5;v.restSpeed=s.restSpeed||(t?.01:2),v.restDelta=s.restDelta||(t?.005:.5)};let T,A,k;if(b(),f<1){const t=$t(g,f),e={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};k=()=>{e.A=(v.velocity+y*v.delta)/t,e.sinC=y*e.A+v.delta*t,e.cosC=y*v.delta-e.A*t};const s=s=>{s!==e.t&&(e.t=s,e.env=Math.exp(-y*s),e.sin=Math.sin(t*s),e.cos=Math.cos(t*s))};T=t=>(s(t),v.target-e.env*(e.A*e.sin+v.delta*e.cos)),A=t=>(s(t),e.env*(e.sinC*e.sin+e.cosC*e.cos))}else if(1===f){T=t=>v.target-Math.exp(-g*t)*(v.delta+(v.velocity+g*v.delta)*t);const t={C:0};k=()=>{t.C=v.velocity+g*v.delta},A=e=>Math.exp(-g*e)*(g*t.C*e-v.velocity)}else{const t=g*Math.sqrt(f*f-1),e=y-t,s=y+t,n=t<1||d?1/0:300/t,i=(t,e)=>Math.exp(e>n?(y-t)*n-y*e:-t*e),r={S:0,F:0};k=()=>{const e=(v.velocity+y*v.delta)/t;r.S=(v.delta+e)/2,r.F=(v.delta-e)/2},T=t=>v.target-r.S*i(e,t)-r.F*i(s,t),A=t=>e*r.S*i(e,t)+s*r.F*i(s,t)}k();const w=p&&l||null,M={calculatedDuration:w,retarget:(t,e)=>{v.target=t[t.length-1],v.delta=v.target-t[0],v.velocity=m(e),s.restSpeed&&s.restDelta||b(),M.calculatedDuration=w,r.done=!1,k()},velocity:t=>u(A(t)),next:t=>{const e=T(t);if(p)r.done=t>=l;else{const s=u(A(t));r.done=Math.abs(s)<=v.restSpeed&&Math.abs(v.target-e)<=v.restDelta}return r.value=r.done?v.target:e,r},toString:()=>{const t=Math.min(jt(M),Nt),e=Wt(e=>M.next(t*e).value,t,30);return t+"ms "+e},toTransition:()=>{}};return M}const Gt=Object.assign(Jt,{applyToOptions:t=>{const e=Bt(t,100,Jt);return t.ease=e.ease,t.duration=u(e.duration),t.type="keyframes",t}});function Ht({keyframes:t,velocity:e=0,power:s=.8,timeConstant:n=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:a,min:o,max:h,restDelta:l=.5,restSpeed:u}){const c=t[0],p={done:!1,value:c},d=t=>void 0===o?h:void 0===h||Math.abs(o-t)<Math.abs(h-t)?o:h;let m=s*e;const f=c+m,g=a?a(f):f;g!==f&&(m=g-c);const y=t=>-m*Math.exp(-t/n),v=t=>{const e=y(t);p.done=Math.abs(e)<=l,p.value=p.done?g:t?g+e:c};let b,T;const A=t=>{var e;((e=p.value)<o||e>h)&&(b=t,T=Gt({keyframes:[p.value,d(p.value)],velocity:-y(t)/n*1e3,damping:i,stiffness:r,restDelta:l,restSpeed:u}))};return A(0),{calculatedDuration:null,next:t=>{let e=!1;return T||void 0!==b||(e=!0,v(t),A(t)),void 0!==b&&t>=b?T.next(t-b):(!e&&v(t),p)}}}function Qt(t,n,{clamp:i=!0,ease:r,mixer:l}={}){const u=t.length;if(1===u)return()=>n[0];if(2===u&&n[0]===n[1])return()=>n[1];const c=t[0]===t[1];t[0]>t[u-1]&&(t=[...t].reverse(),n=[...n].reverse());const p=function(t,e,n){const i=[],r=n||s.mix||Et,h=t.length-1;for(let s=0;s<h;s++){let n=r(t[s],t[s+1]);if(e){const t=Array.isArray(e)?e[s]||a:e;n=o(t,n)}i.push(n)}return i}(n,r,l),d=p.length,m=e=>{if(c&&e<t[0])return n[0];let s=0;if(d>1)for(;s<t.length-2&&!(e<t[s+1]);s++);const i=h(t[s],t[s+1],e);return p[s](i)};return i?s=>m(e(t[0],t[u-1],s)):m}function te(t,e){const s=t[t.length-1];for(let n=1;n<=e;n++){const i=h(0,e,n);t.push(bt(s,1,i))}}function ee(t){const e=[0];return te(e,t.length-1),e}function se({duration:t=300,keyframes:n,times:i,ease:r="easeInOut"}){const a=D(r)?r.map(E):E(r)||x,o={done:!1,value:n[0]};if(2===n.length&&!Array.isArray(a)&&(!i||2!==i.length||0===i[0]&&1===i[1])){const[i,r]=n,h=i===r?void 0:(s.mix||Et)(i,r);return{calculatedDuration:t,next:s=>(o.value=h?h(a(t>0?e(0,1,s/t):1)):r,o.done=s>=t,o)}}const h=function(t,e){return t.map(t=>t*e)}(i&&i.length===n.length?i:ee(n),t),l=Qt(h,n,{ease:Array.isArray(a)?a:(u=n,c=a,u.map(()=>c||x).splice(0,u.length-1))});var u,c;return{calculatedDuration:t,next:e=>(o.value=l(e),o.done=e>=t,o)}}function ne(t,e,s=0){return e<=0?s:t.velocity?t.velocity(e):function(t,e,s){const n=Math.max(e-5,0);return p(s-t(n),e-n)}(e=>t.next(e).value,e,t.next(e).value)}const ie=t=>null!==t;function re(t,{repeat:e,repeatType:s="loop"},n,i=1){const r=t.filter(ie),a=i<0||e&&"loop"!==s&&e%2==1?0:r.length-1;return a&&void 0!==n?n:r[a]}const ae={decay:Ht,inertia:Ht,tween:se,keyframes:se,spring:Gt};function oe(t){"string"==typeof t.type&&(t.type=ae[t.type])}const he=(t,e)=>e-t>40&&!s.useManualTiming?e:t;function le(t,e){return{kind:t,animation:e,timestamp:I.now(),frameTimestamp:P.timestamp,frameIsProcessing:P.isProcessing}}function ue(t,e,s){const n=globalThis.__MOTION_INSPECT__;if(n)try{n({...le("animation-start",t),options:s?{...e,...s}:e})}catch{}}class ce{constructor(){this.isResolved=!1}get finished(){return this._finished||(this._finished=this.isResolved?Promise.resolve():new Promise(t=>{this._resolve=t})),this._finished}updateFinished(){this._finished=this._resolve=void 0,this.isResolved=!1}notifyFinished(){this.isResolved=!0,this._resolve?.()}then(t,e){return this.finished.then(t,e)}}const pe=t=>t/100,de=t=>Math.round(1e4*t)/1e4;class me extends ce{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{const{motionValue:t}=this.options;t&&t.updatedAt!==I.now()&&this.tick(I.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),!1===t.autoplay&&this.pause(),ue(this,this.options)}initAnimation(){const{options:t}=this;oe(t);const{type:e=se,repeat:s=0,repeatDelay:n=0,repeatType:i,velocity:r=0}=t;let{keyframes:a}=t;const h=e||se;h!==se&&"number"!=typeof a[0]&&(this.mixKeyframes=o(pe,Et(a[0],a[1])),a=[0,100]);const l=h(a===t.keyframes?t:{...t,keyframes:a});"mirror"===i&&(this.mirroredGenerator=h({...t,keyframes:[...a].reverse(),velocity:-r})),null===l.calculatedDuration&&(l.calculatedDuration=jt(l));const{calculatedDuration:u}=l;this.calculatedDuration=u,this.resolvedDuration=u+n,this.totalDuration=this.resolvedDuration*(s+1)-n,this.generator=l}updateTime(t){this.currentTime=this.holdTime??Math.round(t-this.startTime)*this.playbackSpeed}tick(t,e=!1){const{generator:s,totalDuration:n,calculatedDuration:i}=this;if(null===this.startTime)return s.next(0);const{delay:r=0,keyframes:a,type:o,onUpdate:h,finalKeyframe:l}=this.options;this.startTime===this.pendingStartTime&&(this.startTime=he(this.startTime,t)),this.pendingStartTime=void 0,this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-n/this.speed,this.startTime)),e?this.currentTime=t:this.updateTime(t);const u=this.currentTime-r*(this.playbackSpeed>=0?1:-1),c=this.playbackSpeed>=0?u<0:u>n;this.currentTime=Math.max(u,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=n);const p=this.generate(this.currentTime,c);let{done:d}=p;c||(d=this.playbackSpeed>=0?i<1/0?this.currentTime>=n:d:this.currentTime<=0);const m=null===this.holdTime&&("finished"===this.state||"running"===this.state&&d);return m&&o!==Ht&&(p.value=re(a,this.options,l,this.speed)),h&&h(p.value),m&&this.finish(),p}at(t){return this.holdTime??de((t-this.startTime)*this.playbackSpeed)}sampleAt(t,e){const{options:s,totalDuration:n}=this,i=this.at(t)-(s.delay||0);return i>=n&&s.type!==Ht?re(s.keyframes,s,e?void 0:s.finalKeyframe):this.generate(Math.max(i,0),i<0).value}generate(t,s){const{generator:n,totalDuration:i,mixKeyframes:r,mirroredGenerator:a,resolvedDuration:o}=this,{keyframes:h,repeat:l,repeatType:u,repeatDelay:c}=this.options;let p,d=t,m=n;if(l){const s=Math.min(t,i)/o;let n=Math.floor(s),r=s%1;!r&&s>=1&&(r=1),1===r&&n--,n=Math.min(n,l+1);Boolean(n%2)&&("reverse"===u?(r=1-r,c&&(r-=c/o)):"mirror"===u&&(m=a)),d=e(0,1,r)*o}return s?(this.delayState.value=h[0],p=this.delayState):p=m.next(d),r&&!s&&(p.value=r(p.value)),p}get duration(){return c(this.calculatedDuration)}get iterationDuration(){return this.duration+c(this.options.delay??0)}get time(){return c(this.currentTime)}set time(t){t=u(t),this.currentTime=t,null===this.startTime||null!==this.holdTime||0===this.playbackSpeed?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){return ne(this.generator,this.currentTime,this.options.velocity)}get speed(){return this.playbackSpeed}set speed(t){const e=this.playbackSpeed!==t;e&&this.driver&&this.updateTime(I.now()),this.playbackSpeed=t,e&&this.driver&&(this.time=c(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Kt,startTime:e}=this.options;this.driver||(this.driver=t(t=>this.tick(t))),this.options.onPlay?.();const s=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=s):null!==this.holdTime?this.startTime=s-this.holdTime/(this.playbackSpeed||1):this.startTime||(this.startTime=e??(this.pendingStartTime=s)),"finished"===this.state&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(I.now()),this.holdTime=this.currentTime}complete(){"running"!==this.state&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.driver?.stop(),this.driver=void 0,this.startTime=this.holdTime=null}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}const fe=new Set(["brightness","contrast","saturate","opacity"]);function ge(t){const[e,s]=t.slice(0,-1).split("(");if("drop-shadow"===e)return t;const[n]=s.match(_)||[];if(!n)return t;const i=s.replace(n,"");let r=fe.has(e)?1:0;return n!==s&&(r*=100),e+"("+r+i+")"}const ye=/\b([a-z-]*)\(.*?\)/gu,ve={...gt,getAnimatableNone:t=>{const e=t.match(ye);return e?e.map(ge).join(" "):t}},be={...gt,getAnimatableNone:t=>{const e=gt.parse(t);return gt.createTransformer(t)(e.map(t=>"number"==typeof t?0:"object"==typeof t?{...t,alpha:1}:t))}},Te={...Y,transform:Math.round},Ae={rotate:Q,pathRotation:Q,rotateX:Q,rotateY:Q,rotateZ:Q,scale:$,scaleX:$,scaleY:$,scaleZ:$,skew:Q,skewX:Q,skewY:Q,distance:et,translateX:et,translateY:et,translateZ:et,x:et,y:et,z:et,perspective:et,transformPerspective:et,opacity:U,originX:it,originY:it,originZ:et},ke={borderWidth:et,borderTopWidth:et,borderRightWidth:et,borderBottomWidth:et,borderLeftWidth:et,borderRadius:et,borderTopLeftRadius:et,borderTopRightRadius:et,borderBottomRightRadius:et,borderBottomLeftRadius:et,width:et,maxWidth:et,height:et,maxHeight:et,top:et,right:et,bottom:et,left:et,inset:et,insetBlock:et,insetBlockStart:et,insetBlockEnd:et,insetInline:et,insetInlineStart:et,insetInlineEnd:et,padding:et,paddingTop:et,paddingRight:et,paddingBottom:et,paddingLeft:et,paddingBlock:et,paddingBlockStart:et,paddingBlockEnd:et,paddingInline:et,paddingInlineStart:et,paddingInlineEnd:et,margin:et,marginTop:et,marginRight:et,marginBottom:et,marginLeft:et,marginBlock:et,marginBlockStart:et,marginBlockEnd:et,marginInline:et,marginInlineStart:et,marginInlineEnd:et,fontSize:et,backgroundPositionX:et,backgroundPositionY:et,...Ae,zIndex:Te,fillOpacity:U,strokeOpacity:U,numOctaves:Te},we={...ke,color:at,backgroundColor:at,outlineColor:at,fill:at,stroke:at,borderColor:at,borderTopColor:at,borderRightColor:at,borderBottomColor:at,borderLeftColor:at,filter:ve,WebkitFilter:ve,mask:be,WebkitMask:be},Me=new Set([ve,be]);function Se(t,e){let s=(t=>we[t])(t);return Me.has(s)||(s=gt),s.getAnimatableNone?s.getAnimatableNone(e):void 0}const xe=t=>180*t/Math.PI,De=t=>{const e=xe(Math.atan2(t[1],t[0]));return Fe(e)},Re={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scaleZ:()=>1,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:De,rotateZ:De,skewX:t=>xe(Math.atan(t[1])),skewY:t=>xe(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Fe=t=>((t%=360)<0&&(t+=360),t),Ce=t=>Math.hypot(t[0],t[1]),Ee=t=>Math.hypot(t[4],t[5]),Pe={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ce,scaleY:Ee,scaleZ:t=>Math.hypot(t[8],t[9],t[10]),scale:t=>(Ce(t)+Ee(t))/2,rotateX:t=>Fe(xe(Math.atan2(t[6],t[5]))),rotateY:t=>Fe(xe(Math.atan2(-t[2],t[0]))),rotateZ:De,rotate:De,skewX:t=>xe(Math.atan(t[4])),skewY:t=>xe(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Ve(t){return t.includes("scale")?1:0}function Oe(t,e){if(!t||"none"===t)return Ve(e);const s=t.match(/^matrix(3d)?\(([-\d.e\s,]+)\)$/u);if(!s)return Ve(e);const n=(s[1]?Pe:Re)[e],i=s[2].split(",").map(t=>parseFloat(t));return"function"==typeof n?n(i):i[n]}const Ie=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","scaleZ","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ke=(()=>new Set([...Ie,"pathRotation"]))(),We=t=>t===Y||t===et,Ne=new Set(["x","y","z"]),je=Ie.filter(t=>!Ne.has(t));const Be=new Set(["bottom","right"]);function Ye(t,e,s,n,i,r){const a=parseFloat(t);if(!isNaN(a))return a;const{min:o,max:h}=e()[s],l=h-o;return"border-box"===r?l:l-parseFloat(n)-parseFloat(i)}const Ue=({transform:t})=>Oe(t,"x"),$e=({transform:t})=>Oe(t,"y"),_e={width:({width:t,paddingLeft:e="0",paddingRight:s="0",boxSizing:n},i)=>Ye(t,i,"x",e,s,n),height:({height:t,paddingTop:e="0",paddingBottom:s="0",boxSizing:n},i)=>Ye(t,i,"y",e,s,n),top:({top:t})=>parseFloat(t),left:({left:t})=>parseFloat(t),bottom:({top:t},e)=>{const{y:s}=e();return parseFloat(t)+(s.max-s.min)},right:({left:t},e)=>{const{x:s}=e();return parseFloat(t)+(s.max-s.min)},x:Ue,y:$e,translateX:Ue,translateY:$e},qe=new Set;let Xe=!1,ze=!1,Le=!1;function Ze(){if(ze){const t=[],e=new Set,s=new Set;qe.forEach(n=>{n.needsMeasurement&&(t.push(n),e.add(n.element),Be.has(n.name)&&s.add(n.element))});const n=new Map;s.forEach(t=>{const e=function(t){const e=[];return je.forEach(s=>{const n=t.getValue(s);if(void 0!==n){const t=n.get(),i=s.startsWith("scale")?1:0;if(t===i)return;e.push([s,t]),n.set(i)}}),e}(t);e.length&&(n.set(t,e),t.render())}),t.forEach(t=>t.measureInitialState()),e.forEach(t=>{t.render();const e=n.get(t);e&&e.forEach(([e,s])=>{t.getValue(e)?.set(s)})}),t.forEach(t=>t.measureEndState()),t.forEach(t=>{void 0!==t.suspendedScrollY&&window.scrollTo(0,t.suspendedScrollY)})}ze=!1,Xe=!1,qe.forEach(t=>t.complete(Le)),qe.clear()}function Je(){qe.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ze=!0)})}class Ge{constructor(t,e,s,n,i,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=e,this.name=s,this.motionValue=n,this.element=i,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(qe.add(this),Xe||(Xe=!0,Ot.read(Je),Ot.resolveKeyframes(Ze))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:e,element:s,motionValue:i}=this;if(null===t[0]){const a=i?.get(),o=t[t.length-1];if(void 0!==a)t[0]=a;else if(s&&e){const i=function(t,e,s){if("string"==typeof t){if(n(t)||r(t))return parseFloat(t);if(!gt.test(t)&>.test(s))return Se(e,s)}return t??void 0}(s.readValue(e,o),e,o);void 0!==i&&(t[0]=i)}void 0===t[0]&&(t[0]=o),i&&void 0===a&&i.set(t[0])}!function(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),qe.delete(this)}cancel(){"scheduled"===this.state&&(qe.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}const He=t=>t.startsWith("--");function Qe(t,e,s){He(e)?t.style.setProperty(e,s):t.style[e]=s}const ts={};function es(t,e){const s=function(t){let e;return()=>(void 0===e&&(e=t()),e)}(t);return()=>ts[e]??s()}const ss=es(()=>void 0!==window.ScrollTimeline,"scrollTimeline"),ns=es(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0},"linearEasing"),is=([t,e,s,n])=>`cubic-bezier(${t}, ${e}, ${s}, ${n})`,rs={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:is([0,.65,.55,1]),circOut:is([.55,0,1,.45]),backIn:is([.31,.01,.66,-.59]),backOut:is([.33,1.53,.69,.99])};function as(t,e){return t?"function"==typeof t?ns()?Wt(t,e):"ease-out":F(t)?is(t):Array.isArray(t)?t.map(t=>as(t,e)||rs.easeOut):rs[t]:void 0}function os(t,e,s,{delay:n=0,duration:i=300,repeat:r=0,repeatType:a="loop",ease:o="easeOut",times:h}={},l=void 0){const u={[e]:s};h&&(u.offset=h);const c=as(o,i);Array.isArray(c)&&(u.easing=c);const p={delay:n,duration:i,easing:Array.isArray(c)?"linear":c,fill:"both",iterations:r+1,direction:"reverse"===a?"alternate":"normal"};return l&&(p.pseudoElement=l),t.animate(u,p)}function hs(t){return"function"==typeof t&&"applyToOptions"in t}class ls extends ce{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:e,name:s,keyframes:n,pseudoElement:i,allowFlatten:r=!1,finalKeyframe:a,onComplete:o}=t;this.isPseudoElement=Boolean(i),this.allowFlatten=r,this.options=t;const h=function({type:t,...e}){return hs(t)&&ns()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}(t);this.animation=os(e,s,n,h,i),!1===h.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const t=re(n,this.options,a,this.speed);this.updateMotionValue?.(t),Qe(e,s,t),this.animation.cancel()}o?.(),this.notifyFinished()},ue(this,t,h)}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch(t){}}stop(){this.isStopped||(this.isStopped=!0,"idle"!==this.state&&null===this.finishedTime&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||(this.animation.onfinish=null,this.cancel())))}commitStyles(){const t=this.options?.element;!this.isPseudoElement&&t?.isConnected&&this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return c(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+c(t)}get time(){return c(Number(this.animation.currentTime)||0)}set time(t){const e=null!==this.finishedTime;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=u(t),e&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return null!==this.finishedTime?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,onAttach:e,observe:s}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&ss()?(this.animation.timeline=t,e?.(this.animation),a):s(this)}}const us={anticipate:T,backInOut:b,circInOut:w};function cs(t){"string"==typeof t.ease&&t.ease in us&&(t.ease=us[t.ease])}class ps extends ls{constructor(t){cs(t),oe(t),super(t),void 0!==t.startTime&&!1!==t.autoplay&&(this.startTime=t.startTime),this.options=t}elapsed(){return"running"===this.state?(I.now()-this.startTime)*this.speed:1e3*this.time}sample(t){if(!this.sampler){const{motionValue:t,onUpdate:e,onComplete:s,onPlay:n,onStop:i,element:r,...a}=this.options;this.sampler=new me({...a,autoplay:!1}),this.sampler.stop()}return this.sampler.sample(Math.max(0,t)).value}liveValue(){const{state:t}=this;if("running"===t||"paused"===t)return this.sample(this.elapsed())}updateMotionValue(t){const{motionValue:s,element:n,name:i}=this.options;if(!s)return;if(void 0!==t)return void s.set(t);const{speed:r}=this,a=this.elapsed(),o="running"===this.state&&r?e(0,10,a):0,h=this.sample(a);n&&i&&Qe(n,i,h),s.setWithVelocity(this.sample(a-o*Math.sign(r)),h,o/Math.abs(r||1))}}const ds=(t,e)=>"zIndex"!==e&&(!("number"!=typeof t&&!Array.isArray(t))||!("string"!=typeof t||!gt.test(t)&&"0"!==t||t.startsWith("url(")));function ms(t){t.duration=0,t.type="keyframes"}const fs=new Set(["opacity","clipPath","filter","transform"]),gs=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;const ys=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),vs=()=>!s.useManualTiming&&Object.hasOwnProperty.call(Element.prototype,"animate");function bs(t){const{motionValue:e,name:s,repeatDelay:n,repeatType:i,damping:r,type:a,keyframes:o}=t;if(!s||!fs.has(s)&&!ys.has(s))return!1;const h=e?.owner?.current;if(!(h instanceof HTMLElement||h instanceof SVGElement))return!1;const{onUpdate:l,transformTemplate:u}=e.owner.getProps();return vs()&&(fs.has(s)||ys.has(s)&&function(t){for(let e=0;e<t.length;e++)if("string"==typeof t[e]&&gs.test(t[e]))return!0;return!1}(o))&&("transform"!==s||!u)&&!l&&!n&&"mirror"!==i&&0!==r&&"inertia"!==a}const Ts=(t,e)=>e&&"number"==typeof t?e.transform(t):t,As={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"};Ie.length;const ks={},ws=(t,e,s=Ts(e,Ae[t]))=>(ks[t]||(ks[t]=(As[t]||t)+"("))+s+")",Ms=(t,e)=>("number"==typeof e?e:parseFloat(e))===(t.startsWith("scale")?1:0),Ss=new WeakMap,xs=.001,Ds=(t,e)=>t-e,Rs=(t,e,s)=>{const n=[];for(let i=0;i<=s;i++)n.push(bt(t,e,i/s));return n},Fs=t=>t.motionValue.owner,Cs=t=>Ss.get(t),Es=(t,e)=>t.latestValues?t.latestValues[e]:t.getValue(e)?.get();class Ps extends me{constructor(t){const e=Fs(t).current,{driver:s=Kt}=t;let n;const i=function(t){const e=Fs(t),{onUpdate:s,transformTemplate:n}=e.getProps();return!(t.isHandoff||s||t.hasOnUpdate||n||"inertia"===t.type||"none"!==(Es(e,"transform")||"none")||Es(e,"pathRotation")||e.projection?.isProjecting())}(t);t.driver=t=>{const i=s(t);return{js:i,now:i.now,start:(t=!0)=>{const s=Cs(e);!s||s.isJS?i.start(t):s.schedule(!1,!t)},stop:()=>{i.stop();const t=Cs(e);t&&!t.isFinishing&&t.release(n)}}},super(t),n=this,this.canAccelerate=i;const{stop:r}=this;this.stop=()=>{this.isAccelerated()&&this.sync(),r()}}get group(){return Cs(Fs(this.options).current)}get js(){return this.driver?.js}get name(){return this.options.name}timing(){const{startTime:t,speed:e,totalDuration:s}=this,{delay:n=0,repeatType:i}=this.options;return null!==this.holdTime?[1/0,0]:s===1/0?[t+n/e,this.resolvedDuration*("loop"===i?1:2)/e||1]:[t+(n+s)/e,0]}isAccelerated(){const{group:t,state:e}=this;return t?.tracks.has(this)&&!t.isJS&&this.canAccelerate&&("running"===e||"paused"===e)}liveValue(){return this.isAccelerated()?this.sampleAt(I.now()):void 0}tween(){const{keyframes:t,type:e,ease:s,times:n,repeat:i,delay:r=0}=this.options,a=F(s)?is(s):(t=>/^(linear|ease(In|Out|InOut))$/.test(t))(s)&&rs[s];if(a&&!i&&!n&&2===t.length&&e===se&&null===this.holdTime){const t=this.startTime+r/this.speed;return[t,t+this.resolvedDuration/this.speed,a]}}boundaries(t,e){const{startTime:s,speed:n,resolvedDuration:i,options:r}=this,{delay:a=0,repeat:o=0,repeatDelay:h=0,repeatType:l,times:u,keyframes:c,type:p}=r,d=(p||se)===se?u||ee(c):[0,1],m=s+a/n,f=[];if(null!==this.holdTime||!(i>0))return f;for(let s=Math.max(0,Math.floor((t-m)*n/i));s<=o;s++){const r=m+s*i/n;if(r>e)break;for(const a of d){const o=r+(s%2&&l&&"loop"!==l?1-a:a)*(i-h)/n;o>t&&o<e&&f.push(o)}}return f}numberAt(t){return parseFloat(this.sampleAt(t,!0))}sync(){const t=I.now();this.options.motionValue.setWithVelocity(this.sampleAt(t-10,!0),this.sampleAt(t,!0),10)}play(){this.isStopped||((this.group||function(t){const e=t.current,s=new Set,n=new Map;let i={},r=[],a=new Map,o=[],l=!1,u=!1,c=!1,p=!1,d=-1/0;const m=t=>{for(const e of s)if(e.name===t)return!0},f=(e,s)=>{const a={};for(const o of void 0===e?Ie:r){const r=n.get(o),h=void 0===e?Es(t,o):r?r.sampleAt(s>e&&!r.timing()[1]?s:e):i[o];void 0!==h&&(a[o]=h)}return a},g=(t,e)=>{let s="";for(const n in t){const i=t[n];e&&Ms(n,i)||(s+=ws(n,i)+" ")}return(e?s.trim():s)||"none"},y=(t,e)=>g(f(t,e)),v=(t=f())=>{e.style.transform=g(t,!0)},b=(t=!0)=>{t&&v(),o.forEach(({animation:t})=>t.cancel()),o=[]},T=(t,s)=>new Animation(new KeyframeEffect(e,t,s)),A=(t,e,s=1/0)=>{const n={animation:t,offset:e,end:s};t.startTime=I.now()+e,s<1/0&&(t.onfinish=()=>{n.isDone=!0,o.some(t=>t.end===1/0)&&(t.cancel(),o=o.filter(t=>t!==n)),E.schedule(!1)}),t.oncancel=()=>o.includes(n)&&E.demote(),o.push(n)},k=(t,e,s)=>{const n=(e,s)=>Math.abs(t(s)-t(e)),i=n(e,s);for(;s-e>.01;){const t=(e+s)/2;n(e,t)>n(t,s)?s=t:e=t}return n(e,s)>i/2?[e,s]:[]},w=(t,e,s,n)=>{const i=Math.min(200,Math.max(2,Math.ceil((s-e)/10)));if(4*n.length>i)return;const r=Rs(e,s,i).concat(n).sort(Ds),a=t=>h(e,s,t);let o,l;for(const e of t){const t=r.map(t=>e.numberAt(t)),[s]=t,n=t.map(t=>t-s),i=n[n.length-1],a=n.some(t=>Math.abs(t)*xs>Math.abs(i))?0:i,h=n.map(t=>a?t/a:t);if(a)if(o){if(h.some((t,e)=>!(Math.abs(t-o[e])<=xs)))return}else o=h,l=t=>(e.numberAt(t)-s)/a;else if(h.some(t=>!(Math.abs(t)<=xs)))return}if(!o||o.every((t,e)=>Math.abs(t-a(r[e]))<=xs))return"linear";const u=[],c=(t,e=l(t))=>u.push(de(e)+" "+de(100*a(t))+"%");return o.forEach((t,e)=>{e&&Math.abs(t-o[e-1])>.2&&k(l,r[e-1],r[e]).forEach(t=>c(t)),c(r[e],t)}),"linear("+u+")"},M=(t,e,s,n)=>{const i=[e],r=(e,s)=>t.every(t=>!(Math.abs(t.numberAt((e+s)/2)-(t.numberAt(e)+t.numberAt(s))/2)>(t.name.startsWith("scale")?.001:.1))),a=(e,s,n)=>{if(s-e<1||r(e,s))i.push(s);else if(n<4)a(e,(e+s)/2,n+1),a((e+s)/2,s,n+1);else{for(const n of t)i.push(...k(t=>n.numberAt(t),e,s));i.push(s)}},o=Rs(e,s,Math.ceil((s-e)/100));for(const t of n)o.push(t,Math.min(t+.01,s));let h=e;for(const t of o.sort(Ds))t>h&&a(h,t,0),h=t;return i.sort(Ds)},S=t=>{let e;for(const s of t){const t=s.tween();if(!t||e?.some((e,s)=>s<2?Math.abs(t[s]-e)>1:t[s]!==e))return;e=t}return e},x=(t,e,s,n={fill:"both"},i,r)=>{const a=t.flatMap(t=>t.boundaries(e,s)),o=r||w(t,e,s,a),l=o?[e,s]:M(t,e,s,a),u=l.map(t=>y(t,i));let c={transform:u};return o||(c.offset=l.map(t=>h(e,s,t))),u.every(t=>t===u[0])&&(v(f(e,i)),c=null),T(c,{...n,duration:s-e,easing:o||"linear"})},D=e=>{let h=e,l=0,u=0;const c=[],p=[],d=new Set;n.clear(),a=new Map;for(const t of s){n.set(t.name,t);const[s,i]=t.timing(),r=s===1/0;if(a.set(t,[t.at(e),t.speed,r]),r)t.sync();else{if(t.speed<0)return;if(i){if(l){const t=(s-u)/i;if(Math.abs(i-l)>1||Math.abs(t-Math.round(t))*l>1)return}else l=i,u=s;p.push(t)}else d.add(s);c.push(t),h=Math.max(h,s)}}i={},r=Ie.filter(e=>{if(n.has(e))return!0;const s=i[e]=Es(t,e);return void 0!==s&&parseFloat(s)!==(e.startsWith("scale")?1:0)}),b(!1);const m=!l&&S(c);try{if(m&&m[1]>e){const[t,s,n]=m;A(x(c,t,s,void 0,void 0,n),t-e,s-t)}else h>e&&(A(x(c,e,h),0,h-e),d.forEach(t=>t<h-1&&A(T(null,{duration:t-e}),0,t-e)));if(l){const t=u+Math.floor((h-u)/l)*l;A(x(p,t,t+l,{iterations:1/0,iterationStart:(h-t)/l,fill:"forwards"},h),h-e)}}catch{return}return o.length||b(),!0},R=t=>{let e,n=0;for(const i of s){const s=a.get(i);if(!s)return!1;const[r,o,h]=s,l=i.at(t),u=i.timing()[0]===1/0;if(h){if(u&&l===r)continue;return!1}const c=(l-r)/o,p=u?0:i.speed/o;if(void 0===e)e=c,n=p;else if(Math.abs(c-e)>1||p!==n)return!1}if(void 0===e)return!0;if(!o.length)return!1;for(const{offset:t,end:s,isDone:n}of o){const i=e-t;if(s<1/0&&(n?i<s-1:i<0||i>=s))return!1}for(const{animation:s,offset:i,isDone:r}of o){if(r)continue;const a=e-i;n&&s.updatePlaybackRate&&"running"===s.playState&&Math.abs(Number(s.currentTime)-a)<20?s.playbackRate!==n&&s.updatePlaybackRate(n):n?(s.playbackRate=n,s.startTime=t-a/n):(s.startTime=null,s.currentTime=a)}return!0},F=()=>!s.size&&(c=!0,Cs(e)===E&&Ss.delete(e),E.isJS||b(),!0),C=()=>{const e=I.now();if(E.isJS||(E.isFinishing=!0,s.forEach(s=>{const[n,r]=s.timing();"running"===s.state&&s.speed>0&&!r&&n<=e+1&&(s.complete(),i[s.name]=Es(t,s.name),a.has(s)||(l=!0))}),E.isFinishing=!1),u=!1,c)return;if(s.forEach(({state:t},e)=>{"idle"!==t&&"finished"!==t||s.delete(e)}),F())return;for(const t of s)if(!t.canAccelerate)return E.demote(!0);E.isJS&&(E.isJS=!1,l=!0,s.forEach(t=>t.js?.stop()));const n=l,r=p;if(l=p=!1,n||!R(e)){if(r){if(e-d<100)return E.demote();d=e}if(!D(e))return E.demote()}},E={tracks:s,isJS:!1,isFinishing:!1,schedule(t,e){c||(l||(l=t),p||(p=!!e),u||(u=!0,P.isProcessing?Ot.render(C,!1,!0):queueMicrotask(C)))},release(t){const{state:e}=t;"idle"!==e&&"finished"!==e||s.delete(t),F()||E.schedule(!0)},check(){if(!E.isJS)for(const e in i)if(Es(t,e)!==i[e]&&!m(e))return E.schedule(!0,!0)},demote(t){E.isJS||c||(s.forEach(e=>{e.isAccelerated()&&e.sync(),t||(e.canAccelerate=!1)}),E.isJS=!0,a=new Map,b(),s.forEach(t=>"running"===t.state&&t.js?.start()))}};return Ss.set(e,E),E}(Fs(this.options))).tracks.add(this),super.play())}pause(){super.pause(),this.isAccelerated()&&(this.sync(),this.group.schedule(!1))}complete(){super.complete();const{group:t}=this;t&&!t.isJS&&this.canAccelerate&&this.tick(I.now())}get time(){return this.isAccelerated()?c(e(0,this.totalDuration,this.at(I.now())-(this.options.delay||0))):super.time}set time(t){super.time=t,this.isAccelerated()&&this.sync()}attachTimeline(t){return this.canAccelerate=!1,this.group?.demote(!0),super.attachTimeline(t)}}class Vs extends ce{constructor(t){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=I.now();const{keyframes:e,name:s,motionValue:n,element:i}=t,r=t;r.autoplay??(r.autoplay=!0),r.delay??(r.delay=0),r.type??(r.type="keyframes"),r.repeat??(r.repeat=0),r.repeatDelay??(r.repeatDelay=0),r.repeatType??(r.repeatType="loop");const a=i?.KeyframeResolver||Ge;this.keyframeResolver=new a(e,(t,e,s)=>this.onKeyframesResolved(t,e,r,!s),s,n,i),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,e,n,i){this.keyframeResolver=void 0;const{name:r,type:a,velocity:o,delay:h,isHandoff:l,onUpdate:u}=n;this.resolvedAt=I.now();const c=function(t,e,s,n){const i=t[0];if(null===i)return!1;if("display"===e||"visibility"===e)return!0;const r=t[t.length-1],a=ds(i,e),o=ds(r,e);return!(!a||!o)&&(function(t){const e=t[0];if(1===t.length)return!0;for(let s=0;s<t.length;s++)if(t[s]!==e)return!0}(t)||("spring"===s||hs(s))&&n)}(t,r,a,o);c||(!s.instantAnimations&&h||u?.(re(t,n,e)),t[0]=t[t.length-1],ms(n),n.repeat=0);const{onComplete:p}=n;n.finalKeyframe=e,n.keyframes=t,n.onComplete=()=>{p?.(),this.notifyFinished()};const d=c&&!l&&bs(n),m=!d&&(({name:t,motionValue:e})=>t&&Ie.includes(t)&&e?.owner?.current instanceof HTMLElement&&vs()&&ns())(n);let f;if(i&&(d||m||this.resolvedAt!==this.createdAt)&&(n.startTime??(n.startTime=he(this.createdAt,this.resolvedAt))),d){n.element=n.motionValue?.owner?.current;try{f=new ps(n)}catch{f=new me(n)}}else f=m?new Ps(n):new me(n);this.pendingTimeline&&(this.stopTimeline=f.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=f}get finished(){return this._animation?this._animation.finished:super.finished}then(t,e){return this.finished.finally(t).then(()=>{})}liveValue(){return this._animation?.liveValue?.()}get animation(){return this._animation||(this.keyframeResolver?.resume(),Le=!0,Je(),Ze(),Le=!1),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation?.cancel(),this.keyframeResolver?.cancel()}}class Os{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>t.finished))}getAll(t){return this.animations[0][t]}setAll(t,e){for(let s=0;s<this.animations.length;s++)this.animations[s][t]=e}attachTimeline(t){const e=this.animations.map(e=>e.attachTimeline(t));return()=>{e.forEach((t,e)=>{t&&t(),this.animations[e].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return Is(this.animations,"duration")}get iterationDuration(){return Is(this.animations,"iterationDuration")}runAll(t){this.animations.forEach(e=>e[t]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function Is(t,e){let s=0;for(let n=0;n<t.length;n++){const i=t[n][e];null!==i&&i>s&&(s=i)}return s}class Ks extends Os{then(t,e){return this.finished.finally(t).then(()=>{})}}class Ws{constructor(t,e={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=t=>{const e=I.now();if(this.updatedAt!==e&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(t),this.current!==this.prev&&(this.dirty(),this.dependents))for(const t of this.dependents)t.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=e.owner}setCurrent(t){var e;this.current=t,this.updatedAt=I.now(),null===this.canTrackVelocity&&void 0!==t&&(this.canTrackVelocity=(e=this.current,!isNaN(parseFloat(e))))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,e){var s;return"change"===t?this.onChangeSubscribe(e):((s=this.events)[t]||(s[t]=new l)).add(e)}onChangeSubscribe(t){const{events:e}=this;return e.change||this.changeSubscriber?(e.change||(e.change=new l,e.change.add(this.changeSubscriber),this.changeSubscriber=void 0),e.change.add(t)):this.changeSubscriber=t,()=>{this.changeSubscriber===t?this.changeSubscriber=void 0:e.change?.remove(t),this.stopIfUnobserved()}}stopIfUnobserved(){Ot.read(()=>{this.changeSubscriber||this.events.change?.getSize()||this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(const t in this.events)this.events[t].clear()}attach(t,e){this.passiveEffect=t,this.stopPassiveEffect=e}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,e,s){this.set(e),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,e=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,e&&this.stop(),this.stopPassiveEffect?.()}dirty(){const{current:t,changeSubscriber:e}=this;e?e(t):this.events.change?.notify(t)}addDependent(t){(this.dependents||(this.dependents=new Set)).add(t)}removeDependent(t){this.dependents?.delete(t)}get(){const t=this.animation?.liveValue?.();return void 0===t?this.current:t}getCurrent(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=I.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const e=Math.min(this.updatedAt-this.prevUpdatedAt,30);return p(parseFloat(this.current)-parseFloat(this.prevFrameValue),e)}start(t){return this.stop(),new Promise(e=>{this.hasAnimated=!0;let s,n=!1;s=t(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===s&&(this.animation=void 0),e()}),n||(this.animation=s),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel?.notify()),this.animation=void 0}isAnimating(){return!!this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect?.()}}function Ns(t,e){return new Ws(t,e)}const js={type:"spring",stiffness:500,damping:25,restSpeed:10},Bs={type:"keyframes",duration:.8},Ys={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Us=(t,{keyframes:e})=>e.length>2?Bs:Ke.has(t)?t.startsWith("scale")?{type:"spring",stiffness:550,damping:0===e[1]?2*Math.sqrt(550):30,restSpeed:10}:js:Ys,$s=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed","out"]);const _s=(t,e,n,i={},r,a)=>a=>{const o=function(t,e){const s=t?.[e]??t?.default??t;return s!==t?function(t,e){if(t?.inherit&&e){const{inherit:s,...n}=t;return{...e,...n}}return t}(s,t):s}(i,t)||{},h=o.delay||i.delay||0;let{elapsed:l=0}=i;l-=u(h);const c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...o,delay:-l,onUpdate:t=>{e.set(t),o.onUpdate&&o.onUpdate(t)},onComplete:()=>{a(),o.onComplete&&o.onComplete()},name:t,motionValue:e,element:r,hasOnUpdate:!!o.onUpdate};(function(t){for(const e in t)if(!$s.has(e))return!0;return!1})(o)||Object.assign(c,Us(t,c)),c.duration&&(c.duration=u(c.duration)),c.repeatDelay&&(c.repeatDelay=u(c.repeatDelay)),void 0!==c.from&&(c.keyframes[0]=c.from);let p=!1;if((!1===c.type||0===c.duration&&!c.repeatDelay)&&(ms(c),0===c.delay&&(p=!0)),(s.instantAnimations||s.skipAnimations||r?.shouldSkipAnimations||o.skipAnimations)&&(p=!0,ms(c),c.delay=0),c.allowFlatten=!o.type&&!o.ease,p&&void 0!==e.get()){const t=re(c.keyframes,o);if(void 0!==t)return void Ot.update(()=>{c.onUpdate(t),c.onComplete()})}return o.isSync?new me(c):new Vs(c)},qs=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Xs(t,e,s=1){const[i,r]=function(t){const e=qs.exec(t);if(!e)return[,];const[,s,n,i]=e;return[`--${s??n}`,i]}(t);if(!i)return;const a=window.getComputedStyle(e).getPropertyValue(i);if(a){const t=a.trim();return n(t)?parseFloat(t):t}return N(r)?Xs(r,e,s+1):r}const zs=new Set(["width","height","top","left","right","bottom",...Ie]),Ls=t=>Boolean(t&&t.getVelocity),Zs=[Y,et,tt,Q,nt,st,{test:t=>"auto"===t,parse:t=>t}],Js=t=>Zs.find((t=>e=>e.test(t))(t));function Gs(t){return"number"==typeof t?0===t:null===t||("none"===t||"0"===t||r(t))}const Hs=new Set(["auto","none","0"]);class Qs extends Ge{constructor(){super(...arguments),this.isAsync=!0}scheduleResolve(){if(this.canReadNow()&&(this.readKeyframes(),!this.needsMeasurement))return this.complete();super.scheduleResolve()}canReadNow(){const{unresolvedKeyframes:t,element:e,motionValue:s}=this,n=t[0]??s?.get();if(!e?.current||void 0===n)return!1;for(let e=0;e<t.length;e++)if(B(e?t[e]:n))return!1;return!0}readKeyframes(){const{unresolvedKeyframes:t,element:e,name:s}=this;if(!e?.current)return;super.readKeyframes();for(let s=0;s<t.length;s++){let n=t[s];if("string"==typeof n&&(n=n.trim(),N(n))){const i=Xs(n,e.current);void 0!==i&&(t[s]=i),s===t.length-1&&(this.finalKeyframe=n)}}if(this.resolveNoneKeyframes(),!zs.has(s)||2!==t.length)return;const[n,i]=t;if("number"==typeof n&&"number"==typeof i)return;const r=Js(n),a=Js(i);if(B(n)!==B(i)&&_e[s])this.needsMeasurement=!0;else if(r!==a)if(We(r)&&We(a))for(let e=0;e<t.length;e++){const s=t[e];"string"==typeof s&&(t[e]=parseFloat(s))}else _e[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:e}=this,s=[];for(let e=0;e<t.length;e++)(null===t[e]||Gs(t[e]))&&s.push(e);s.length&&function(t,e,s){let n,i=0;for(;i<t.length&&!n;){const e=t[i];"string"==typeof e&&!Hs.has(e)&&pt(e)&&(n=t[i]),i++}if(n&&s)for(const i of e)t[i]!==n&&(t[i]=Se(s,n))}(t,s,e)}measure(){const{element:t,name:e}=this;return _e[e](window.getComputedStyle(t.current),()=>t.measureViewportBox())}measureInitialState(){const{element:t,unresolvedKeyframes:e,name:s}=this;if(!t?.current)return;"height"===s&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),e[0]=this.measuredOrigin;const n=e[e.length-1];void 0!==n&&this.motionValue?.jump(n,!1)}measureEndState(){const{element:t,unresolvedKeyframes:e}=this;if(!t?.current)return;this.motionValue?.jump(this.measuredOrigin,!1);const s=e.length-1,n=e[s];e[s]=this.measure(),null!==n&&void 0===this.finalKeyframe&&(this.finalKeyframe=n),this.resolveNoneKeyframes()}}const tn=[];function en(e){t(tn,e)}function sn(t){return tn.find(e=>e.test(t))}function nn(t,e,s={},n){const i=[],{velocity:r,path:a}=s,o=s.reduceMotion??n?.shouldReduceMotion;a?.animateValues&&n&&(e={...e},a.animateValues(t,e,s,0,i));for(const a in e){if("transition"===a||"transitionEnd"===a)continue;const h=e[a];if(void 0===h)continue;const l=t(a),u=l.get();void 0===u||l.isAnimating()||Array.isArray(h)||h!==u||r?(l.start(_s(a,l,h,o&&zs.has(a)?{type:!1}:s,n)),l.animation&&i.push(l.animation)):Ot.update(()=>l.set(h))}const{transitionEnd:h}=e;if(h){const e=()=>Ot.update(()=>{for(const e in h)t(e).set(h[e])});i.length?Promise.all(i).then(e):e()}return i}function rn(t,e,s,n,i){return nn(n=>{let r=t.get(e,n);if(!r){let a;if(!i){const i=s[n];a=function(t){const e=Array.isArray(t)?t[0]:void 0;return null===e?void 0:e}(i)??t.read(e,n,i)}r=Ns(a,{owner:i}),t(e,{[n]:r})}return r},s,n,i)}function an(t){return i(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}function on(t){return i(t)&&"ownerSVGElement"in t}const hn={};class ln{constructor(t=Ot.render){this.step=t,this.values=new Map,this.pending=[],this.numPending=0,this.flush=()=>{const{pending:t,numPending:e}=this;this.numPending=0;for(let s=0;s<e;s++)t[s]()}}set(t,e,s,n){if(this.values.get(t)?.onRemove(),n)for(const t of this.values.values())t.value===n&&(s=t.render);const i=()=>s&&this.schedule(s);void 0!==e.get()&&i();const r=e.on("change",i),a=()=>{r(),s&&!n&&this.cancel(s),this.values.get(t)?.onRemove===a&&this.values.delete(t)};return this.values.set(t,{value:e,render:n?void 0:s,onRemove:a}),a}get(t){return this.values.get(t)?.value}release(){const t=new Map;return this.values.forEach((e,s)=>{t.set(s,e.value),e.onRemove()}),this.transformKeys=this.transformValues=void 0,t}schedule(t){const{pending:e,numPending:s}=this;for(let n=0;n<s;n++)if(e[n]===t)return;s||this.step(this.flush),e[this.numPending++]=t}cancel(t){const{pending:e}=this;for(let s=0;s<this.numPending;s++)if(e[s]===t)return void(e[s]=e[--this.numPending])}}function un(t,{step:e,...s}={}){const n=new WeakMap;return Object.assign((s,i)=>{const r=n.get(s)??new ln(e);n.set(s,r);const a=[];for(const e in i){const n=i[e],o=t(s,r,e,n);a.push(o)}return()=>{for(const t of a)t()}},s,{get:(t,e)=>n.get(t)?.get(e),flush:t=>n.get(t)?.flush(),state:t=>n.get(t)})}const cn=new Set(["originX","originY","originZ"]),pn=(t,e)=>Ts(t.get(e)?.get(),ke[e]),dn=(t,e,s,n)=>{let i,r;if(Ke.has(s)){if("pathRotation"!==s){const t=e.transformKeys??(e.transformKeys=[]);(e.transformValues??(e.transformValues={}))[s]=n,t.includes(s)||(t.push(s),t.sort((t,e)=>Ie.indexOf(t)-Ie.indexOf(e)))}e.get("transform")||(an(t)||e.get("transformBox")||dn(t,e,"transformBox",new Ws("fill-box")),e.set("transform",new Ws("none"),()=>{Ss.get(t)?.check(),t.style.transform=function(t){let e="";const{transformKeys:s=[],transformValues:n={}}=t;for(let t=0;t<s.length;t++){const i=s[t],r=n[i].getCurrent();void 0!==r&&(Ms(i,r)||(e+=(e&&" ")+ws(i,r)))}const i=t.get("pathRotation")?.get();return i&&(e+=(e&&" ")+ws("rotate",i)),e||"none"}(e)})),r=e.get("transform")}else cn.has(s)?(e.get("transformOrigin")||e.set("transformOrigin",new Ws(""),()=>{const s=pn(e,"originX")??"50%",n=pn(e,"originY")??"50%",i=pn(e,"originZ")??0;t.style.transformOrigin=`${s} ${n} ${i}`}),r=e.get("transformOrigin")):i=He(s)?()=>{t.style.setProperty(s,n.getCurrent())}:()=>{t.style[s]=Ts(n.getCurrent(),ke[s])};return e.set(s,n,i,r)},mn=(t,e)=>{if(Ke.has(e))return((t,e)=>{const{transform:s="none"}=getComputedStyle(t);return Oe(s,e)})(t,e);const s=getComputedStyle(t),n=He(e)?s.getPropertyValue(e):s[e];return"string"==typeof n&&n.trim()||0},fn=un(dn,{test:t=>an(t)||on(t),read:mn});function gn(t){return t.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const yn=["transform","opacity","clipPath","filter","offsetDistance","offsetPath","offsetRotate","offsetAnchor"];const vn=(t,e,s,n,i=s)=>{const r=function(t,e){if(!(e in t))return!1;const s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),e)||Object.getOwnPropertyDescriptor(t,e);return s&&"function"==typeof s.set}(t,i);r||!i.startsWith("data")&&!i.startsWith("aria")||(i=gn(i));const a=ke[s]||ke[i],o=r?()=>{t[i]=Ts(n.get(),ke[s])}:()=>{const e=Ts(n.get(),a);null==e?t.removeAttribute(i):t.setAttribute(i,String(e))};return e.set(s,n,o)};const bn=un((t,e,s,n)=>{if(s.startsWith("path")&&!Ke.has(s))return function(t,e,s,n){return Ot.render(()=>t.setAttribute("pathLength","1")),"pathOffset"===s?e.set(s,n,()=>{const e=n.get();t.setAttribute("stroke-dashoffset",""+-e)}):(e.get("stroke-dasharray")||e.set("stroke-dasharray",new Ws("1 1"),()=>{const s=e.get("pathLength")?.get()??1,n=e.get("pathSpacing")?.get();t.setAttribute("stroke-dasharray",`${s} ${n??1-Number(s)}`)}),e.set(s,n,void 0,e.get("stroke-dasharray")))}(t,e,s,n);if(s.startsWith("attr"))return vn(t,e,s,n,Tn(s));return(Ke.has(s)||cn.has(s)||He(s)||s in t.style?dn:vn)(t,e,s,n)},{test:on,read:(t,e)=>Ke.has(e)?ke[e]?.default||0:He(e)||yn.includes(e)?mn(t,e)||t.getAttribute(gn(e))||0:(e=Tn(e),t.getAttribute(gn(e))??t.getAttribute(e)??void 0)});function Tn(t){return t.replace(/^attr([A-Z])/,(t,e)=>e.toLowerCase())}const An={};class kn{constructor(t,e){this.effect=t,this.current=e,this.KeyframeResolver=Qs}getValue(t){return this.effect.get(this.current,t)}readValue(t,e){return this.effect.read(this.current,t,e)}render(){this.effect.flush(this.current)}measureViewportBox(){return function({top:t,left:e,right:s,bottom:n}){return{x:{min:e,max:s},y:{min:t,max:n}}}(this.current.getBoundingClientRect())}getProps(){return An}}function wn(t,e,s,n){if(hn.current?.track(t),n)return nn(t=>n.getValue(t,null),e,s,n);const i=(t=>on(t)?bn:fn)(t);return rn(i,t,e,s,new kn(i,t))}const Mn=un((t,e,s,n)=>e.set(s,n,()=>{t[s]=n.get()}),{test:t=>i(t),read:(t,e)=>{const s=t[e];return"string"==typeof s||"number"==typeof s?s:void 0}});function Sn(t,e,s){const n=Ls(t)?t:Ns(t);return n.start(_s("",n,e,s)),n.animation}const xn=new WeakMap;function Dn(t){return"object"==typeof t&&!Array.isArray(t)}function Rn(t,e,s,n){return null==t?[]:"string"==typeof t&&Dn(e)?function(t,e,s){if(null==t)return[];if(t instanceof EventTarget)return[t];if("string"==typeof t){const n=e?e.current:hn.current?.root||document,i=s?.[t]??n.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t).filter(t=>null!=t)}(t,s,n):t instanceof NodeList?Array.from(t):Array.isArray(t)?t.filter(t=>null!=t):[t]}function Fn(t,e,s){return t*(e+1)+s*e}function Cn(t,e){if(e.has(t))return e.get(t);const[,s,n]=t.match(/^(.+?)([+-][\d.]+)$/)||[];return e.has(s)?Math.max(0,e.get(s)+parseFloat(n)):void 0}function En(e,s,n,i,r,a){!function(e,s,n){for(let i=0;i<e.length;i++){const r=e[i];r.at>s&&r.at<n&&(t(e,r),i--)}}(e,r,a);for(let t=0;t<s.length;t++)e.push({value:s[t],at:bt(r,a,i[t]),easing:R(n,t)})}function Pn(t,e,s=0){const n=e+1+e*s;for(let e=0;e<t.length;e++)t[e]=t[e]/n}function Vn(t,e){return t.at===e.at?null===t.value?1:null===e.value?-1:0:t.at-e.at}function On(t,{defaultTransition:e={},...s}={},n,i,r){const a=e.duration||.3,o=new Map,l=new Map,c={},p=new Map;let d=0,m=0,f=0;const y=(t,s)=>{let r=s;const o=t=>{return"number"==typeof t?s+t:(e=m,i=d,r=p,"number"==typeof(n=t)?n:n.startsWith("-")||n.startsWith("+")?Math.max(0,e+parseFloat(n)):"<"===n?i:n.startsWith("<")?Math.max(0,i+parseFloat(n.slice(1))):Cn(n,r)??e);var e,n,i,r};for(let s=0;s<t.length;s++){const h=t[s];if("string"==typeof h){p.set(h,m);continue}if(!Array.isArray(h)){const t=void 0===h.at?m:o(h.at);"sequence"in h?(d=m=t,m=y(h.sequence,t),d=t,r=Math.max(r,m)):p.set(h.name,t);continue}let[v,b,T={}]=h;void 0!==T.at&&(m=o(T.at));let A=0;const k=(t,s,n,r=0,o=0)=>{const h=Wn(t),{delay:l=0,times:c=ee(h),type:p=e.type||"keyframes",repeat:d,repeatType:y,repeatDelay:v=0,...b}=s;let{ease:T=e.ease||"easeOut",duration:k}=s;const w="function"==typeof l?l(r,o):l,M=h.length,S=hs(p)?p:i?.[p||"keyframes"];if(M<=2&&S){let t=100;if(2===M&&Bn(h)){const e=h[1]-h[0];t=Math.abs(e)}const s={...e,...b};void 0!==k&&(s.duration=u(k));const n=Bt(s,t,S);T=n.ease,k=n.duration}k??(k=a);const x=m+w;1===c.length&&0===c[0]&&(c[1]=1);const D=c.length-h.length;if(D>0&&te(c,D),1===h.length&&h.unshift(null),d&&d<20){const t=k>0?v/k:0;k=Fn(k,d,v);const e=[...h],s=[...c];T=Array.isArray(T)?[...T]:[T];const n=[...T],i="reverse"===y||"mirror"===y;let r=e,a=n;i&&(r=[...e].reverse(),"reverse"===y&&(a=[...n].reverse().map(t=>"function"==typeof t?g(t):t)));for(let o=0;o<d;o++){const l=i&&o%2==0,u=l?r:e,p=l?a:n,d=(o+1)*(1+t);t>0&&(h.push(h[h.length-1]),c.push(d),T.push("linear")),h.push(...u);for(let t=0;t<u.length;t++)c.push(s[t]+d),T.push(0===t?"linear":R(p,t-1))}Pn(c,d,t)}const F=x+k;En(n,h,T,c,x,F),A=Math.max(w+k,A),f=Math.max(F,f)};if(Ls(v)){k(b,T,Kn("default",In(v,l)))}else{const t=Rn(v,b,n,c),e=t.length;for(let s=0;s<e;s++){const n=In(t[s],l);for(const t in b)k(b[t],Nn(T,t),Kn(t,n),s,e)}}d=m,m+=A,r=Math.max(r,m)}return r};return y(t,0),r&&(r.duration=f,r.labels=p),l.forEach((t,n)=>{for(const i in t){const r=t[i];r.sort(Vn);const a=[],l=[],u=[];for(let t=0;t<r.length;t++){const{at:e,value:s,easing:n}=r[t];a.push(s),l.push(h(0,f,e)),u.push(n||"easeOut")}0!==l[0]&&(l.unshift(0),a.unshift(a[0]),u.unshift("easeInOut")),1!==l[l.length-1]&&(l.push(1),a.push(null)),o.has(n)||o.set(n,{keyframes:{},transition:{}});const c=o.get(n);c.keyframes[i]=a;const{type:p,...d}=e;c.transition[i]={...d,duration:f,ease:u,times:l,...s}}}),o}function In(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function Kn(t,e){return e[t]||(e[t]=[]),e[t]}function Wn(t){return Array.isArray(t)?t:[t]}function Nn(t,e){return t&&t[e]?{...t,...t[e]}:{...t}}const jn=t=>"number"==typeof t,Bn=t=>t.every(jn);function Yn(t,e,s,n){const i=[];if(function(t,e){return Ls(t)||"number"==typeof t||"string"==typeof t&&!Dn(e)}(t,e))i.push(Sn(t,Dn(e)&&e.default||e,s&&s.default||s));else{if(null==t)return i;const r=Rn(t,e,n),a=r.length;for(let t=0;t<a;t++){const n=r[t],o={...s};"delay"in o&&"function"==typeof o.delay&&(o.delay=o.delay(t,a)),n instanceof Element?i.push(...wn(n,e,o,xn.get(n))):i.push(...rn(sn(n)??Mn,n,e,o))}}return i}let Un=0;const $n=(t,e)=>void 0===e?t:{name:t,at:e};function _n(t){t.pause(),t.time=0,t.stop()}class qn{constructor(e=[],s={},n){this.options=s,this.entries=[],this.repeatIndex=0,this.prevTime=0,this.markers=[],this.labels=new Map,this.totalDuration=0,this.isDirty=!1,this.isDone=!1,this.isRebuilding=!1,this.playbackSpeed=1,this.isWrapped=!1,this.stop=()=>{this.flush(),this.group?.stop()},this.isPaused=!1===s.autoplay,this.newFinished(),e.forEach(t=>this.add(t)),n?(this.isDirty=!1,this.isWrapped=!0,this.group=new Ks(n),this.watch()):(this.invalidate(),this.flush());const{scope:i}=s;i&&(i.animations.push(this),this.finished.then(()=>t(i.animations,this)))}add(t,e){return t instanceof qn&&t.adopt(this),this.push({item:t,at:e})}call(t,e){return this.push({item:t,at:e,marker:{name:"_m"+Un++,time:0,callback:t}})}addPause(t,e){return this.push({item:e||{},at:t,marker:{name:"_m"+Un++,time:0,callback:e,pause:!0}})}move(t,e){return this.entries.forEach(s=>{s.item===t&&(s.at=e)}),this.invalidate()}remove(t){return t instanceof qn&&(t.parent=void 0),this.entries=this.entries.filter(e=>e.item!==t),this.invalidate()}clear(){return this.entries=[],this.invalidate()}getLabelTime(t){return this.flush(),this.labels.get(t)}seek(t){return this.time=this.resolve(t),this}playTo(t){const e=this.resolve(t),s=Math.abs(this.speed);return this.speed=e<this.time?-s:s,this.stopAt=e,this.clock||this.invalidate(),this.play(),this}reverse(){return this.speed=-this.speed,this.play(),this}get progress(){return this.duration?this.time/this.duration:0}set progress(t){this.time=t*this.duration}get time(){return this.active()?.time??0}set time(t){this.flush(),this.prevTime=t,this.group&&(this.group.time=t),this.repeatIndex=this.currentRepeat()}get speed(){return this.playbackSpeed}set speed(t){this.playbackSpeed=t,this.group&&(this.group.speed=t)}get duration(){return this.flush(),this.isWrapped?this.group.duration:this.totalDuration}get iterationDuration(){return this.flush(),this.isWrapped?this.group.iterationDuration:this.totalDuration}get state(){return this.active()?.state??"idle"}get startTime(){return this.active()?.startTime??null}play(){this.flush(),this.isPaused=!1,this.group?.play(),this.isDone&&(this.newFinished(),this.watch())}pause(){this.flush(),this.isPaused=!0,this.group?.pause()}cancel(){this.flush(),this.group?.cancel()}complete(){this.flush(),this.group?.complete()}attachTimeline(t){return this.flush(),this.scrollTimeline=t,this.detachScroll=this.group?.attachTimeline(t),()=>{this.scrollTimeline=void 0,this.detachScroll?.()}}then(t,e){return this.finished.then(t,e)}active(){return this.flush(),this.group?.animations.length?this.group:void 0}push(t){return this.entries.push(t),this.invalidate()}invalidate(){return this.parent?this.parent.invalidate():this.isDirty||(this.isDirty=!0,queueMicrotask(()=>this.flush())),this}flush(){this.isDirty&&!this.parent&&this.build()}adopt(t){this.group&&(_n(this.group),this.group=void 0),this.isDirty=!1,this.parent=t}build(){this.isDirty=!1,this.isWrapped=!1;const t=this.group;let e=0;t&&(this.isRebuilding=!0,this.scrollTimeline?(this.detachScroll?.(),t.cancel()):(e=t.animations.length?t.time:0,_n(t)),this.isRebuilding=!1);const{defaultTransition:s,onComplete:n,onUpdate:i,onRepeat:r,onReverseComplete:a,autoplay:o,scope:h,...l}=this.options,u={};void 0!==h?.reduceMotion&&(u.reduceMotion=h.reduceMotion),void 0!==h?.skipAnimations&&(u.skipAnimations=h.skipAnimations),Object.assign(u,l);const c=new Map,p={},d=function(t,e,s,n){const i=[];return On(t.map(t=>{if(Array.isArray(t)&&"function"==typeof t[0]){const e=t[0],s=Ns(0);return s.on("change",e),1===t.length?[s,[0,1]]:2===t.length?[s,[0,1],t[1]]:[s,t[1],t[2]]}return t}),e,s,{spring:Gt},n).forEach(({keyframes:t,transition:e},s)=>{i.push(...Yn(s,t,e))}),i}(this.toSequence(c),{defaultTransition:s,...u},h,p),m=p.labels;let f=u.duration??p.duration;const g=p.duration?f/p.duration:1;if(m.forEach((t,e)=>m.set(e,t*g)),this.markers=[],c.forEach((t,e)=>{t.time=m.get(e),m.delete(e),f=Math.max(f,t.time),this.markers.push(t)}),this.markers.sort((t,e)=>t.time-e.time),this.labels=m,this.totalDuration=f,this.clock=this.clockAnimation=void 0,this.markers.length||void 0!==this.stopAt||i||r){const t=this.clock=Ns(0);t.on("change",e=>t===this.clock&&this.onClock(e)),d.unshift(this.clockAnimation=Sn(t,[0,f],{...u,duration:f,ease:"linear"}))}const y=this.group=new Ks(d);e=Math.min(e,f),this.isDone&&e<f&&this.newFinished(),this.scrollTimeline?this.detachScroll=y.attachTimeline(this.scrollTimeline):(y.speed=this.playbackSpeed,this.isPaused&&y.pause(),e&&(y.time=e)),this.repeatIndex=this.currentRepeat(),this.prevTime=e||-1,this.watch()}toSequence(t){return this.entries.map(({item:e,at:s,marker:n})=>n?(t.set(n.name,n),$n(n.name,s)):e instanceof qn?{sequence:e.toSequence(t),at:s}:"string"==typeof e?$n(e,s):void 0===s?e:Array.isArray(e)?function(t,e){const s=[...t],n="function"==typeof s[0]?Math.max(1,s.length-1):2;return s[n]={...s[n],at:e},s}(e,s):{...e,at:s})}resolve(t){return this.flush(),"number"==typeof t?t:Cn(t,this.labels)??this.time}currentRepeat(){const{repeat:t=0,repeatDelay:e=0,delay:s=0}=this.options,n=this.totalDuration+e,i=(this.clockAnimation?.time??0)-s;return n&&i>0?Math.min(t,Math.floor(i/n)):0}onClock(t){let e=this.prevTime;if(this.prevTime=t,this.isRebuilding)return;const{onUpdate:s,onRepeat:n,repeatType:i="loop"}=this.options;s?.(t);const r=this.currentRepeat();if(r!==this.repeatIndex&&(this.repeatIndex=r,n?.(),"loop"===i)){const t=this.speed>0;if(this.cross(e,t?this.totalDuration:0))return;e=t?-1:1/0}this.cross(e,t)}cross(t,e){if(t===e)return;const s=e>t,n=n=>s?n>t&&n<=e:n<t&&n>=e,i=s?this.markers:[...this.markers].reverse();for(const t of i)if(n(t.time)&&(t.callback?.(s?1:-1),t.pause))return this.pauseAt(t.time);return void 0!==this.stopAt&&n(this.stopAt)?(this.pauseAt(this.stopAt),this.stopAt=void 0,!0):void 0}pauseAt(t){return this.pause(),this.time=t,!0}watch(){const t=this.group;t.finished.then(()=>{if(t!==this.group||this.isDone)return;this.isDone=!0;const{onComplete:e,onReverseComplete:s}=this.options,n=this.speed<0&&s||e;n?.(),this.resolveFinished()})}newFinished(){this.isDone=!1,this.finished=new Promise(t=>{this.resolveFinished=t})}}function Xn(t={}){const{scope:e,reduceMotion:s,skipAnimations:n}=t;return function(t,i,r){const a=hn.current,o=a?.transition,h={};let l;if(void 0!==s&&(h.reduceMotion=s),void 0!==n&&(h.skipAnimations=n),u=t,Array.isArray(u)&&u.some(Array.isArray)){const s={...h,...i,scope:e};o&&(s.defaultTransition={...o,...s.defaultTransition}),l=new qn(t,s)}else{const{onComplete:s,...n}=r||{},a={...h,...o,...n},{onUpdate:u}=n,c="number"==typeof t||"string"==typeof t&&("string"==typeof i||Array.isArray(i))?[u||(()=>{}),Array.isArray(i)?i:[t,i],{...a,onUpdate:void 0}]:[t,i,a];l=new qn([c],{...h,onComplete:s,scope:e},Yn(t,i,a,e))}var u;return a&&l.finished.then(a.add(()=>l.stop())),l}}const zn=Object.assign(Xn(),{addEffect:function(t){en(t),tn.unshift(t)},removeEffect:en});export{zn as animate,Xn as createScopedAnimate};
//# sourceMappingURL=size-rollup-animate.js.map