framer-motion
Version:
A simple and powerful JavaScript animation library
2 lines (1 loc) • 38.8 kB
JavaScript
import{n as t,p as e,q as n,t as i,u as s,v as r,w as o,x as a,y as l,z as u,A as c,B as h,C as d,D as p,E as m,F as f,G as y,H as v,I as g,J as w,K as b,M as T,L as A,W as x,N as S,O as k,P as C,Q as M,R as E,S as V,T as P,U as D,V as O,X as F,Y as I,r as L,Z as R,_ as K,i as B,o as j,$ as G,a0 as q,a1 as H,a2 as N,a3 as U,a4 as $,a5 as W,a6 as z,a7 as _,a8 as Y,a9 as X,aa as J,ab as Z,ac as Q,ad as tt,ae as et,d as nt,s as it,af as st,ag as rt,ah as ot,k as at,e as lt,f as ut,ai as ct,b as ht,aj as dt,j as pt,ak as mt,g as ft}from"./size-rollup-dom-animation-assets.js";import{Fragment as yt}from"react";const vt=(...t)=>t.reduce((t,e)=>n=>e(t(n))),gt=(t,e,n)=>{const i=e-t;return i?(n-t)/i:1},wt=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function bt(e,n,i,s){if(e===n&&i===s)return t;const r=t=>function(t,e,n,i,s){let r,o,a=0;do{o=e+(n-e)/2,r=wt(o,i,s)-t,r>0?n=o:e=o}while(Math.abs(r)>1e-7&&++a<12);return o}(t,0,1,e,i);return t=>0===t||1===t?t:wt(r(t),n,s)}const Tt=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,At=t=>e=>1-t(1-e),xt=bt(.33,1.53,.69,.99),St=At(xt),kt=Tt(St),Ct=t=>t>=1?1:(t*=2)<1?.5*St(t):.5*(2-Math.pow(2,-10*(t-1))),Mt=t=>1-Math.sin(Math.acos(t)),Et=At(Mt),Vt=Tt(Mt),Pt=bt(.42,0,1,1),Dt=bt(0,0,.58,1),Ot=bt(.42,0,.58,1),Ft={linear:t,easeIn:Pt,easeInOut:Ot,easeOut:Dt,circIn:Mt,circInOut:Vt,circOut:Et,backIn:St,backInOut:kt,backOut:xt,anticipate:Ct},It=t=>{if(e(t)){n(4===t.length,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,i,s,r]=t;return bt(e,i,s,r)}return"string"==typeof t?(n(void 0!==Ft[t],`Invalid easing type '${t}'`,"invalid-easing-type"),Ft[t]):t};function Lt(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function Rt(t,e){return n=>n>0?e:t}const Kt=(t,e,n)=>{const i=t*t,s=n*(e*e-i)+i;return s<0?0:Math.sqrt(s)},Bt=[o,s,r];function jt(t){const e=(n=t,Bt.find(t=>t.test(n)));var n;if(!e)return a(!1,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!1;let i=e.parse(t);return e===r&&(i=function({hue:t,saturation:e,lightness:n,alpha:i}){t/=360,n/=100;let s=0,r=0,o=0;if(e/=100){const i=n<.5?n*(1+e):n+e-n*e,a=2*n-i;s=Lt(a,i,t+1/3),r=Lt(a,i,t),o=Lt(a,i,t-1/3)}else s=r=o=n;return{red:Math.round(255*s),green:Math.round(255*r),blue:Math.round(255*o),alpha:i}}(i)),i}const Gt=(t,e)=>{const n=jt(t),r=jt(e);if(!n||!r)return Rt(t,e);const o={...n};return t=>(o.red=Kt(n.red,r.red,t),o.green=Kt(n.green,r.green,t),o.blue=Kt(n.blue,r.blue,t),o.alpha=i(n.alpha,r.alpha,t),s.transform(o))},qt=new Set(["none","hidden"]);function Ht(t,e){return n=>i(t,e,n)}function Nt(t){return"number"==typeof t?Ht:"string"==typeof t?l(t)?Rt:u.test(t)?Gt:Wt:Array.isArray(t)?Ut:"object"==typeof t?u.test(t)?Gt:$t:Rt}function Ut(t,e){const n=[...t],i=n.length,s=t.map((t,n)=>Nt(t)(t,e[n]));return t=>{for(let e=0;e<i;e++)n[e]=s[e](t);return n}}function $t(t,e){const n={...t,...e},i={};for(const s in n)void 0!==t[s]&&void 0!==e[s]&&(i[s]=Nt(t[s])(t[s],e[s]));return t=>{for(const e in i)n[e]=i[e](t);return n}}const Wt=(t,e)=>{const n=c.createTransformer(e),i=h(t),s=h(e);return i.indexes.var.length===s.indexes.var.length&&i.indexes.color.length===s.indexes.color.length&&i.indexes.number.length>=s.indexes.number.length?qt.has(t)&&!s.values.length||qt.has(e)&&!i.values.length?function(t,e){return qt.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}(t,e):vt(Ut(function(t,e){const n=[],i={color:0,var:0,number:0};for(let s=0;s<e.values.length;s++){const r=e.types[s],o=t.indexes[r][i[r]],a=t.values[o]??0;n[s]=a,i[r]++}return n}(i,s),s.values),n):(a(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Rt(t,e))},zt=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function _t(t,e,n){if("number"==typeof t&&"number"==typeof e&&"number"==typeof n)return i(t,e,n);if("string"==typeof t&&"string"==typeof e){const n=function(t,e){const n=zt.exec(t);if(!n)return;const s=zt.exec(e);if(!s||n[2]!==s[2])return;const r=n[2],o=parseFloat(n[1]),a=parseFloat(s[1]);return t=>d(i(o,a,t))+r}(t,e);if(n)return n}return Nt(t)(t,e)}const Yt=t=>{const e=({timestamp:e})=>t(e);return{start:(t=!0)=>y.update(e,t),stop:()=>f(e),now:()=>p.isProcessing?p.timestamp:m.now()}},Xt=2e4;function Jt(t,e=50,n=2e4,i){let s=0,r=t.next(s);for(;!r.done&&s<n;)s+=e,r=t.next(s);return s>=n?1/0:s}const Zt=100,Qt=10,te=1,ee=0,ne=800,ie=.3,se=.3,re={granular:.01,default:2},oe={granular:.005,default:.5},ae=.01,le=10,ue=.05,ce=1;function he(t,e){return t*Math.sqrt(1-e*e)}const de=.001;const pe=["duration","bounce"],me=["stiffness","damping","mass"];function fe(t,e){return e.some(e=>void 0!==t[e])}function ye(t){let e={velocity:ee,stiffness:Zt,damping:Qt,mass:te,isResolvedFromDuration:!1,...t};if(!fe(t,me)&&fe(t,pe))if(e.velocity=0,t.visualDuration){const n=t.visualDuration,i=2*Math.PI/(1.2*n),s=i*i,r=2*g(.05,1,1-(t.bounce||0))*Math.sqrt(s);e={...e,mass:te,stiffness:s,damping:r}}else{const n=function({duration:t=ne,bounce:e=ie,velocity:n=ee,mass:i=te}){let s,r;a(t<=b(le),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=g(ue,ce,o),t=g(ae,le,v(t)),o<1?(s=e=>{const i=e*o,s=i*t,r=i-n,a=he(e,o),l=Math.exp(-s);return de-r/a*l},r=e=>{const i=e*o*t,r=i*n+n,a=o*o*e*e*t,l=Math.exp(-i),u=he(e*e,o);return(-s(e)+de>0?-1:1)*((r-a)*l)/u}):(s=e=>Math.exp(-e*t)*((e-n)*t+1)-.001,r=e=>Math.exp(-e*t)*(t*t*(n-e)));const l=function(t,e,n){let i=n;for(let n=1;n<12;n++)i-=t(i)/e(i);return i}(s,r,5/t);if(t=b(t),isNaN(l))return{stiffness:Zt,damping:Qt,duration:t};{const e=l*l*i;return{stiffness:e,damping:2*o*Math.sqrt(i*e),duration:t}}}({...t,velocity:0});e={...e,...n,mass:te},e.isResolvedFromDuration=!0}return e}function ve(t=se,e=ie){const n="object"!=typeof t?{visualDuration:t,keyframes:[0,1],bounce:e}:t,i=n.keyframes[0],s=n.keyframes[n.keyframes.length-1],r={done:!1,value:i},{stiffness:o,damping:a,mass:l,duration:u,velocity:c,isResolvedFromDuration:h}=ye({...n,velocity:-v(n.velocity||0)}),d=a/(2*Math.sqrt(o*l)),p=v(Math.sqrt(o/l)),m=d*p,f={target:s,delta:s-i,velocity:c||0,restSpeed:0,restDelta:0},y=()=>{const t=Math.abs(f.delta)<5;f.restSpeed=n.restSpeed||(t?re.granular:re.default),f.restDelta=n.restDelta||(t?oe.granular:oe.default)};let g,T,A;if(y(),d<1){const t=he(p,d),e={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};A=()=>{e.A=(f.velocity+m*f.delta)/t,e.sinC=m*e.A+f.delta*t,e.cosC=m*f.delta-e.A*t};const n=n=>{n!==e.t&&(e.t=n,e.env=Math.exp(-m*n),e.sin=Math.sin(t*n),e.cos=Math.cos(t*n))};g=t=>(n(t),f.target-e.env*(e.A*e.sin+f.delta*e.cos)),T=t=>(n(t),e.env*(e.sinC*e.sin+e.cosC*e.cos))}else if(1===d){g=t=>f.target-Math.exp(-p*t)*(f.delta+(f.velocity+p*f.delta)*t);const t={C:0};A=()=>{t.C=f.velocity+p*f.delta},T=e=>Math.exp(-p*e)*(p*t.C*e-f.velocity)}else{const t=p*Math.sqrt(d*d-1);g=e=>{const n=Math.exp(-m*e),i=Math.min(t*e,300);return f.target-n*((f.velocity+m*f.delta)*Math.sinh(i)+t*f.delta*Math.cosh(i))/t};const e={P:0,sinh:0,cosh:0};A=()=>{e.P=(f.velocity+m*f.delta)/t,e.sinh=m*e.P-f.delta*t,e.cosh=m*f.delta-e.P*t},T=n=>{const i=Math.exp(-m*n),s=Math.min(t*n,300);return i*(e.sinh*Math.sinh(s)+e.cosh*Math.cosh(s))}}A();const x=!fe(n,me)&&fe(n,pe),S=h&&u||null,k={calculatedDuration:S,retarget:(t,e)=>{f.target=t[t.length-1],f.delta=f.target-t[0],f.velocity=x?0:-v(e),n.restSpeed&&n.restDelta||y(),k.calculatedDuration=S,r.done=!1,A()},velocity:t=>b(T(t)),next:t=>{const e=g(t);if(h)r.done=t>=u;else{const n=b(T(t));r.done=Math.abs(n)<=f.restSpeed&&Math.abs(f.target-e)<=f.restDelta}return r.value=r.done?f.target:e,r},toString:()=>{const t=Math.min(Jt(k),Xt),e=w(e=>k.next(t*e).value,t,30);return t+"ms "+e},toTransition:()=>{}};return k}function ge({keyframes:t,velocity:e=0,power:n=.8,timeConstant:i=325,bounceDamping:s=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:u=.5,restSpeed:c}){const h=t[0],d={done:!1,value:h},p=t=>void 0===a?l:void 0===l||Math.abs(a-t)<Math.abs(l-t)?a:l;let m=n*e;const f=h+m,y=void 0===o?f:o(f);y!==f&&(m=y-h);const v=t=>-m*Math.exp(-t/i),g=t=>{const e=v(t);d.done=Math.abs(e)<=u,d.value=d.done?y:y+e};let w,b;const T=t=>{var e;((e=d.value)<a||e>l)&&(w=t,b=ve({keyframes:[d.value,p(d.value)],velocity:-v(t)/i*1e3,damping:s,stiffness:r,restDelta:u,restSpeed:c}))};return T(0),{calculatedDuration:null,next:t=>{let e=!1;return b||void 0!==w||(e=!0,g(t),T(t)),void 0!==w&&t>=w?b.next(t-w):(!e&&g(t),d)}}}function we(e,i,{clamp:s=!0,ease:r,mixer:o}={}){const a=e.length;if(n(a===i.length,"Both input and output ranges must be the same length","range-length"),1===a)return()=>i[0];if(2===a&&i[0]===i[1])return()=>i[1];const l=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),i=[...i].reverse());const u=function(e,n,i){const s=[],r=i||T.mix||_t,o=e.length-1;for(let i=0;i<o;i++){let o=r(e[i],e[i+1]);if(n){const e=Array.isArray(n)?n[i]||t:n;o=vt(e,o)}s.push(o)}return s}(i,r,o),c=u.length,h=t=>{if(l&&t<e[0])return i[0];let n=0;if(c>1)for(;n<e.length-2&&!(t<e[n+1]);n++);const s=gt(e[n],e[n+1],t);return u[n](s)};return s?t=>h(g(e[0],e[a-1],t)):h}function be(t){const e=[0];return function(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const r=gt(0,e,s);t.push(i(n,1,r))}}(e,t.length-1),e}function Te({duration:t=300,keyframes:e,times:n,ease:i="easeInOut"}){const s=(t=>Array.isArray(t)&&"number"!=typeof t[0])(i)?i.map(It):It(i),r={done:!1,value:e[0]};if(2===e.length&&!Array.isArray(s)&&(!n||2!==n.length||0===n[0]&&1===n[1])){const[n,i]=e,o=n===i?void 0:(T.mix||_t)(n,i);return{calculatedDuration:t,next:e=>(r.value=o?o(s(t>0?g(0,1,e/t):1)):i,r.done=e>=t,r)}}const o=function(t,e){return t.map(t=>t*e)}(n&&n.length===e.length?n:be(e),t),a=we(o,e,{ease:Array.isArray(s)?s:(l=e,u=s,l.map(()=>u||Ot).splice(0,l.length-1))});var l,u;return{calculatedDuration:t,next:e=>(r.value=a(e),r.done=e>=t,r)}}ve.applyToOptions=t=>{const e=function(t,e=100,n){const i=n({...t,keyframes:[0,e]}),s=Math.min(Jt(i),Xt);return{type:"keyframes",ease:t=>i.next(s*t).value/e,duration:v(s)}}(t,100,ve);return t.ease=e.ease,t.duration=b(e.duration),t.type="keyframes",t};function Ae(t,e,n=0){return e<=0?n:t.velocity?t.velocity(e):function(t,e,n){const i=Math.max(e-5,0);return A(n-t(i),e-i)}(e=>t.next(e).value,e,t.next(e).value)}const xe={decay:ge,inertia:ge,tween:Te,keyframes:Te,spring:ve};function Se(t){"string"==typeof t.type&&(t.type=xe[t.type])}const ke=t=>t/100;class Ce extends x{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!==m.now()&&this.tick(m.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),!1===t.autoplay&&this.pause(),S(this,this.options)}initAnimation(){const{options:t}=this;Se(t);const{type:e=Te,repeat:n=0,repeatDelay:i=0,repeatType:s,velocity:r=0}=t;let{keyframes:o}=t;const a=e||Te;a!==Te&&"number"!=typeof o[0]&&(this.mixKeyframes=vt(ke,_t(o[0],o[1])),o=[0,100]);const l=a(o===t.keyframes?t:{...t,keyframes:o});"mirror"===s&&(this.mirroredGenerator=a({...t,keyframes:[...o].reverse(),velocity:-r})),null===l.calculatedDuration&&(l.calculatedDuration=Jt(l));const{calculatedDuration:u}=l;this.calculatedDuration=u,this.resolvedDuration=u+i,this.totalDuration=this.resolvedDuration*(n+1)-i,this.generator=l}updateTime(t){const e=Math.round(t-this.startTime)*this.playbackSpeed;null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=e}tick(t,e=!1){const{generator:n,totalDuration:i,mixKeyframes:s,mirroredGenerator:r,resolvedDuration:o,calculatedDuration:a}=this;if(null===this.startTime)return n.next(0);const{delay:l=0,keyframes:u,repeat:c,repeatType:h,repeatDelay:d,type:p,onUpdate:m,finalKeyframe:f}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),e?this.currentTime=t:this.updateTime(t);const y=this.currentTime-l*(this.playbackSpeed>=0?1:-1),v=this.playbackSpeed>=0?y<0:y>i;this.currentTime=Math.max(y,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=i);let w,b=this.currentTime,T=n;if(c){const t=Math.min(this.currentTime,i)/o;let e=Math.floor(t),n=t%1;!n&&t>=1&&(n=1),1===n&&e--,e=Math.min(e,c+1);Boolean(e%2)&&("reverse"===h?(n=1-n,d&&(n-=d/o)):"mirror"===h&&(T=r)),b=g(0,1,n)*o}v?(this.delayState.value=u[0],w=this.delayState):w=T.next(b),s&&!v&&(w.value=s(w.value));let{done:A}=w;v||null===a||(A=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const x=null===this.holdTime&&("finished"===this.state||"running"===this.state&&A);return x&&p!==ge&&(w.value=k(u,this.options,f,this.speed)),m&&m(w.value),x&&this.finish(),w}then(t,e){return this.finished.then(t,e)}get duration(){return v(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+v(t)}get time(){return v(this.currentTime)}set time(t){t=b(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 Ae(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(m.now()),this.playbackSpeed=t,e&&this.driver&&(this.time=v(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Yt,startTime:e}=this.options;this.driver||(this.driver=t(t=>this.tick(t))),this.options.onPlay?.();const n=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=n):null!==this.holdTime?this.startTime=n-this.holdTime:this.startTime||(this.startTime=e??n),"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(m.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.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}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 Me={anticipate:Ct,backInOut:kt,circInOut:Vt};function Ee(t){"string"==typeof t.ease&&t.ease in Me&&(t.ease=Me[t.ease])}class Ve extends C{constructor(t){Ee(t),Se(t),super(t),void 0!==t.startTime&&!1!==t.autoplay&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:e,onUpdate:n,onComplete:i,element:s,...r}=this.options;if(!e)return;if(void 0!==t)return void e.set(t);const o=new Ce({...r,autoplay:!1}),a=Math.max(10,m.now()-this.startTime),l=g(0,10,a-10),u=o.sample(a).value,{name:c}=this.options;s&&c&&M(s,c,u),e.setWithVelocity(o.sample(Math.max(0,a-l)).value,u,l),o.stop()}}const Pe=(t,e)=>"zIndex"!==e&&(!("number"!=typeof t&&!Array.isArray(t))||!("string"!=typeof t||!c.test(t)&&"0"!==t||t.startsWith("url(")));function De(t){t.duration=0,t.type="keyframes"}const Oe=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;const Fe=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),Ie=P(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Le(t){const{motionValue:e,name:n,repeatDelay:i,repeatType:s,damping:r,type:o,keyframes:a}=t;if(!n||!V.has(n)&&!Fe.has(n))return!1;const l=e?.owner?.current;if(!(l instanceof HTMLElement||l instanceof SVGElement))return!1;const{onUpdate:u,transformTemplate:c}=e.owner.getProps();return Ie()&&(V.has(n)||Fe.has(n)&&function(t){for(let e=0;e<t.length;e++)if("string"==typeof t[e]&&Oe.test(t[e]))return!0;return!1}(a))&&("transform"!==n||!c)&&!u&&!i&&"mirror"!==s&&0!==r&&"inertia"!==o}class Re extends x{constructor(t){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=m.now();const{keyframes:e,name:n,motionValue:i,element:s}=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 o=s?.KeyframeResolver||D;this.keyframeResolver=new o(e,(t,e,n)=>this.onKeyframesResolved(t,e,r,!n),n,i,s),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,e,n,i){this.keyframeResolver=void 0;const{name:s,type:r,velocity:o,delay:l,isHandoff:u,onUpdate:c}=n;this.resolvedAt=m.now();let h=!0;(function(t,e,n,i){const s=t[0];if(null===s)return!1;if("display"===e||"visibility"===e)return!0;const r=t[t.length-1],o=Pe(s,e),l=Pe(r,e);return o&&l?function(t){const e=t[0];if(1===t.length)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}(t)||("spring"===n||E(n))&&i:(o!==l&&a(!1,`You are trying to animate ${e} from "${s}" to "${r}". "${o?r:s}" is not an animatable value.`,"value-not-animatable"),!1)})(t,s,r,o)||(h=!1,!T.instantAnimations&&l||c?.(k(t,n,e)),t[0]=t[t.length-1],De(n),n.repeat=0);const d=i?this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt:void 0,{onComplete:p}=n;n.startTime??(n.startTime=d),n.finalKeyframe=e,n.keyframes=t,n.onComplete=()=>{p?.(),this.notifyFinished()};let f;if(h&&!u&&Le(n)){n.element=n.motionValue?.owner?.current;try{f=new Ve(n)}catch{f=new Ce(n)}}else f=new Ce(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(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),O()),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&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function Ke(t,e,n,i=0,s=1){const r=Array.from(t).sort((t,e)=>t.sortNodePosition(e)).indexOf(e),o=t.size,a=(o-1)*i;return"function"==typeof n?n(r,o):1===s?r*i:a-r*i}function Be(t,e){if(t?.inherit&&e){const{inherit:n,...i}=t;return{...e,...i}}return t}function je(t,e){const n=t?.[e]??t?.default??t;return n!==t?Be(n,t):n}const Ge={type:"spring",stiffness:500,damping:25,restSpeed:10},qe={type:"keyframes",duration:.8},He={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Ne=(t,{keyframes:e})=>e.length>2?qe:F.has(t)?t.startsWith("scale")?{type:"spring",stiffness:550,damping:0===e[1]?2*Math.sqrt(550):30,restSpeed:10}:Ge:He,Ue=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);const $e=(t,e,n,i={},s,r)=>o=>{const a=je(i,t)||{},l=a.delay||i.delay||0;let{elapsed:u=0}=i;u-=b(l);const c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:t=>{e.set(t),a.onUpdate&&a.onUpdate(t)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:r?void 0:s};(function(t){for(const e in t)if(!Ue.has(e))return!0;return!1})(a)||Object.assign(c,Ne(t,c)),c.duration&&(c.duration=b(c.duration)),c.repeatDelay&&(c.repeatDelay=b(c.repeatDelay)),void 0!==c.from&&(c.keyframes[0]=c.from);let h=!1;if((!1===c.type||0===c.duration&&!c.repeatDelay)&&(De(c),0===c.delay&&(h=!0)),(T.instantAnimations||T.skipAnimations||s?.shouldSkipAnimations||a.skipAnimations)&&(h=!0,De(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,h&&!r&&void 0!==e.get()){const t=k(c.keyframes,a);if(void 0!==t)return void y.update(()=>{c.onUpdate(t),c.onComplete()})}return a.isSync?new Ce(c):new Re(c)},We=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ze(t,e,i=1){n(i<=4,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=function(t){const e=We.exec(t);if(!e)return[,];const[,n,i,s]=e;return[`--${n??i}`,s]}(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const t=o.trim();return I(t)?parseFloat(t):t}return l(r)?ze(r,e,i+1):r}function _e(t,e,n){const i=t.getProps();return L(i,e,void 0!==n?n:i.custom,t)}const Ye=new Set(["width","height","top","left","right","bottom",...R]),Xe=t=>Array.isArray(t);function Je(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,K(n))}function Ze(t){return Xe(t)?t[t.length-1]||0:t}function Qe(t,e){const n=t.getValue("willChange");if(i=n,Boolean(B(i)&&i.add))return n.add(e);if(!n&&T.WillChange){const n=new T.WillChange("auto");t.addValue("willChange",n),n.add(e)}var i}function tn(t){return t.props[j]}const en="undefined"!=typeof window;function nn({protectedKeys:t,needsAnimating:e},n){const i=t.hasOwnProperty(n)&&!0!==e[n];return e[n]=!1,i}function sn(t,e,{delay:n=0,transitionOverride:i,type:s}={}){let{transition:r,transitionEnd:o,...a}=e;const l=t.getDefaultTransition();r=r?Be(r,l):l;const u=r?.reduceMotion,c=r?.skipAnimations;i&&(r=i);const h=[],d=s&&t.animationState&&t.animationState.getState()[s],p=r?.path;p&&p.animateVisualElement(t,a,r,n,h);for(const e in a){const i=t.getValue(e,t.latestValues[e]??null),s=a[e];if(void 0===s||d&&nn(d,e))continue;const o={delay:n,...je(r||{},e)};c&&(o.skipAnimations=!0);const l=i.get();if(void 0!==l&&!i.isAnimating()&&!Array.isArray(s)&&s===l&&!o.velocity){y.update(()=>i.set(s));continue}let p=!1;if(en&&window.MotionHandoffAnimation){const n=tn(t);if(n){const t=window.MotionHandoffAnimation(n,e,y);null!==t&&(o.startTime=t,p=!0)}}Qe(t,e);const m=u??t.shouldReduceMotion;i.start($e(e,i,s,m&&Ye.has(e)?{type:!1}:o,t,p));const f=i.animation;f&&h.push(f)}if(o){const e=()=>y.update(()=>{o&&function(t,e){const n=_e(t,e);let{transitionEnd:i={},transition:s={},...r}=n||{};r={...r,...i};for(const e in r)Je(t,e,Ze(r[e]))}(t,o)});h.length?Promise.all(h).then(e):e()}return h}function rn(t,e,n={}){const i=_e(t,e,"exit"===n.type?t.presenceContext?.custom:void 0);let{transition:s=t.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(s=n.transitionOverride);const r=i?()=>Promise.all(sn(t,i,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(i=0)=>{const{delayChildren:r=0,staggerChildren:o,staggerDirection:a}=s;return function(t,e,n=0,i=0,s=0,r=1,o){const a=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),a.push(rn(l,e,{...o,delay:n+("function"==typeof i?0:i)+Ke(t.variantChildren,l,i,s,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}(t,e,i,r,o,a,n)}:()=>Promise.resolve(),{when:a}=s;if(a){const[t,e]="beforeChildren"===a?[r,o]:[o,r];return t().then(()=>e())}return Promise.all([r(),o(n.delay)])}const on=[G,q,H,N,U,$,{test:t=>"auto"===t,parse:t=>t}],an=t=>on.find((t=>e=>e.test(t))(t));function ln(t){return"number"==typeof t?0===t:null===t||("none"===t||"0"===t||W(t))}const un=new Set(["auto","none","0"]);class cn extends D{constructor(t,e,n,i,s){super(t,e,n,i,s,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:e,name:n}=this;if(!e||!e.current)return;super.readKeyframes();for(let n=0;n<t.length;n++){let i=t[n];if("string"==typeof i&&(i=i.trim(),l(i))){const s=ze(i,e.current);void 0!==s&&(t[n]=s),n===t.length-1&&(this.finalKeyframe=i)}}if(this.resolveNoneKeyframes(),!Ye.has(n)||2!==t.length)return;const[i,s]=t;if("number"==typeof i&&"number"==typeof s)return;const r=an(i),o=an(s);if(Y(i)!==Y(s)&&X[n])this.needsMeasurement=!0;else if(r!==o)if(J(r)&&J(o))for(let e=0;e<t.length;e++){const n=t[e];"string"==typeof n&&(t[e]=parseFloat(n))}else X[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:e}=this,n=[];for(let e=0;e<t.length;e++)(null===t[e]||ln(t[e]))&&n.push(e);n.length&&function(t,e,n){let i,s=0;for(;s<t.length&&!i;){const e=t[s];"string"==typeof e&&!un.has(e)&&z(e)&&(i=t[s]),s++}if(i&&n)for(const s of e)t[s]!==i&&(t[s]=_(n,i))}(t,n,e)}measure(){const{element:t,name:e}=this;return X[e](window.getComputedStyle(t.current),()=>t.measureViewportBox())}measureInitialState(){const{element:t,unresolvedKeyframes:e,name:n}=this;if(!t||!t.current)return;"height"===n&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),e[0]=this.measuredOrigin;const i=e[e.length-1];void 0!==i&&this.motionValue?.jump(i,!1)}measureEndState(){const{element:t,unresolvedKeyframes:e}=this;if(!t||!t.current)return;this.motionValue?.jump(this.measuredOrigin,!1);const n=e.length-1,i=e[n];e[n]=this.measure(),null!==i&&void 0===this.finalKeyframe&&(this.finalKeyframe=i),this.removedTransforms?.length&&this.removedTransforms.forEach(([e,n])=>{t.getValue(e).set(n)}),this.resolveNoneKeyframes()}}const hn=!1;function dn(t,e){const n=function(t,e,n){if(null==t)return[];if(t instanceof EventTarget)return[t];if("string"==typeof t){let e=document;const i=n?.[t]??e.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t).filter(t=>null!=t)}(t),i=new AbortController;return[n,{passive:!0,...e,signal:i.signal},()=>i.abort()]}function pn(t){return!("touch"===t.pointerType||hn)}function mn(t,e,n={}){const[i,s,r]=dn(t,n);return i.forEach(t=>{let n,i=!1,r=!1;const o=e=>{n&&(n(e),n=void 0),t.removeEventListener("pointerleave",l)},a=t=>{i=!1,window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a),r&&(r=!1,o(t))},l=t=>{"touch"!==t.pointerType&&(i?r=!0:o(t))};t.addEventListener("pointerenter",i=>{if(!pn(i))return;r=!1;const o=e(t,i);"function"==typeof o&&(n=o,t.addEventListener("pointerleave",l,s))},s),t.addEventListener("pointerdown",()=>{i=!0,window.addEventListener("pointerup",a,s),window.addEventListener("pointercancel",a,s)},s)}),r}const fn=(t,e)=>!!e&&(t===e||fn(t,e.parentElement)),yn=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const vn=new WeakSet;function gn(t){return e=>{"Enter"===e.key&&t(e)}}function wn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}function bn(t){return(t=>"mouse"===t.pointerType?"number"!=typeof t.button||t.button<=0:!1!==t.isPrimary)(t)&&!0}const Tn=new WeakSet;function An(t,e,n={}){const[i,s,r]=dn(t,n),o=t=>{const i=t.currentTarget;if(!bn(t))return;if(Tn.has(t))return;vn.add(i),n.stopPropagation&&Tn.add(t);const r=e(i,t),o={...s,capture:!0},a=(t,e)=>{window.removeEventListener("pointerup",l,o),window.removeEventListener("pointercancel",u,o),vn.has(i)&&vn.delete(i),bn(t)&&"function"==typeof r&&r(t,{success:e})},l=t=>{a(t,i===window||i===document||n.useGlobalTarget||fn(i,t.target))},u=t=>{a(t,!1)};window.addEventListener("pointerup",l,o),window.addEventListener("pointercancel",u,o)};return i.forEach(t=>{var e,i;(n.useGlobalTarget?window:t).addEventListener("pointerdown",o,s),"object"==typeof(i=e=t)&&null!==i&&"offsetHeight"in e&&!("ownerSVGElement"in e)&&(t.addEventListener("focus",t=>((t,e)=>{const n=t.currentTarget;if(!n)return;const i=gn(()=>{if(vn.has(n))return;wn(n,"down");const t=gn(()=>{wn(n,"up")});n.addEventListener("keyup",t,e),n.addEventListener("blur",()=>wn(n,"cancel"),e)});n.addEventListener("keydown",i,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),e)})(t,s)),function(t){return yn.has(t.tagName)||!0===t.isContentEditable}(t)||t.hasAttribute("tabindex")||(t.tabIndex=0))}),r}class xn extends Z{constructor(){super(...arguments),this.KeyframeResolver=cn}sortInstanceNodePosition(t,e){return 2&t.compareDocumentPosition(e)?1:-1}getBaseTargetFromProps(t,e){const n=t.style;return n?n[e]:void 0}removeValueFromRenderState(t,{vars:e,style:n}){delete e[t],delete n[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;B(t)&&(this.childSubscription=t.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}}class Sn{constructor(t){this.isMounted=!1,this.node=t}update(){}}function kn(t,{style:e,vars:n},i,s){const r=t.style;let o;for(o in e)r[o]=e[o];for(o in s?.applyProjectionStyles(r,i),n)r.setProperty(o,n[o])}class Cn extends xn{constructor(){super(...arguments),this.type="html",this.renderInstance=kn}mount(t){n(Boolean(t.style),"motion.create() components must forward their ref to a HTML or SVG element","custom-component-ref"),super.mount(t)}readValueFromInstance(t,e){if(F.has(e))return this.projection?.isProjecting?Q(e):tt(t,e);{const i=(n=t,window.getComputedStyle(n)),s=(et(e)?i.getPropertyValue(e):i[e])||0;return"string"==typeof s?s.trim():s}var n}measureInstanceViewportBox(t,{transformPagePoint:e}){return function(t,e){return function({top:t,left:e,right:n,bottom:i}){return{x:{min:e,max:n},y:{min:t,max:i}}}(function(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),i=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}(t.getBoundingClientRect(),e))}(t,e)}build(t,e,n){nt(t,e,n.transformTemplate)}scrapeMotionValuesFromProps(t,e,n){return it(t,e,n)}}const Mn=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);class En extends xn{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=rt}getBaseTargetFromProps(t,e){return t[e]}readValueFromInstance(t,e){if(F.has(e)){const t=ct(e);return t&&t.default||0}if(ot.includes(e)){const n=getComputedStyle(t)[e];if("string"==typeof n&&n)return n.trim()}return e=Mn.has(e)?e:st(e),t.getAttribute(e)}scrapeMotionValuesFromProps(t,e,n){return at(t,e,n)}build(t,e,n){lt(t,e,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(t,e,n,i){!function(t,e,n,i){kn(t,e,void 0,i);for(const n in e.attrs)t.setAttribute(Mn.has(n)?n:st(n),e.attrs[n])}(t,e,0,i)}mount(t){this.isSVGTag=ut(t.tagName),super.mount(t)}}const Vn=dt.length;function Pn(t){if(!t)return;if(!t.isControllingVariants){const e=t.parent&&Pn(t.parent)||{};return void 0!==t.props.initial&&(e.initial=t.props.initial),e}const e={};for(let n=0;n<Vn;n++){const i=dt[n],s=t.props[i];(ht(s)||!1===s)&&(e[i]=s)}return e}function Dn(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let i=0;i<n;i++)if(e[i]!==t[i])return!1;return!0}const On=[...mt].reverse(),Fn=mt.length;function In(t){return e=>Promise.all(e.map(({animation:e,options:n})=>function(t,e,n={}){let i;if(t.notify("AnimationStart",e),Array.isArray(e)){const s=e.map(e=>rn(t,e,n));i=Promise.all(s)}else if("string"==typeof e)i=rn(t,e,n);else{const s="function"==typeof e?_e(t,e,n.custom):e;i=Promise.all(sn(t,s,n))}return i.then(()=>{t.notify("AnimationComplete",e)})}(t,e,n)))}function Ln(t){let e=In(t),n=Bn(),i=!0,s=!1;const r=e=>(n,i)=>{const s=_e(t,i,"exit"===e?t.presenceContext?.custom:void 0);if(s){const{transition:t,transitionEnd:e,...i}=s;n={...n,...i,...e}}return n};function o(o){const{props:a}=t,l=Pn(t.parent)||{},u=[],c=new Set;let h={},d=1/0;for(let e=0;e<Fn;e++){const p=On[e],m=n[p],f=void 0!==a[p]?a[p]:l[p],y=ht(f),v=p===o?m.isActive:null;!1===v&&(d=e);let g=f===l[p]&&f!==a[p]&&y;if(g&&(i||s)&&t.manuallyAnimateOnMount&&(g=!1),m.protectedKeys={...h},!m.isActive&&null===v||!f&&!m.prevProp||pt(f)||"boolean"==typeof f)continue;if("exit"===p&&m.isActive&&!0!==v){m.prevResolvedValues&&(h={...h,...m.prevResolvedValues});continue}const w=Rn(m.prevProp,f);let b=w||p===o&&m.isActive&&!g&&y||e>d&&y,T=!1;const A=Array.isArray(f)?f:[f];let x=A.reduce(r(p),{});!1===v&&(x={});const{prevResolvedValues:S={}}=m,k={...S,...x},C=e=>{b=!0,c.has(e)&&(T=!0,c.delete(e)),m.needsAnimating[e]=!0;const n=t.getValue(e);n&&(n.liveStyle=!1)};for(const t in k){const e=x[t],n=S[t];if(h.hasOwnProperty(t))continue;let i=!1;i=Xe(e)&&Xe(n)?!Dn(e,n)||w:e!==n,i?null!=e?C(t):c.add(t):void 0!==e&&c.has(t)?C(t):m.protectedKeys[t]=!0}m.prevProp=f,m.prevResolvedValues=x,m.isActive&&(h={...h,...x}),(i||s)&&t.blockInitialAnimation&&(b=!1);const M=g&&w;b&&(!M||T)&&u.push(...A.map(e=>{const n={type:p};if("string"==typeof e&&(i||s)&&!M&&t.manuallyAnimateOnMount&&t.parent){const{parent:i}=t,s=_e(i,e);if(i.enteringChildren&&s){const{delayChildren:e}=s.transition||{};n.delay=Ke(i.enteringChildren,t,e)}}return{animation:e,options:n}}))}if(c.size){const e={};if("boolean"!=typeof a.initial){const n=_e(t,Array.isArray(a.initial)?a.initial[0]:a.initial);n&&n.transition&&(e.transition=n.transition)}c.forEach(n=>{const i=t.getBaseTarget(n),s=t.getValue(n);s&&(s.liveStyle=!0),e[n]=i??null}),u.push({animation:e})}let p=Boolean(u.length);return!i||!1!==a.initial&&a.initial!==a.animate||t.manuallyAnimateOnMount||(p=!1),i=!1,s=!1,p?e(u):Promise.resolve()}return{animateChanges:o,setActive:function(e,i){if(n[e].isActive===i)return Promise.resolve();t.variantChildren?.forEach(t=>t.animationState?.setActive(e,i)),n[e].isActive=i;const s=o(e);for(const t in n)n[t].protectedKeys={};return s},setAnimateFunction:function(n){e=n(t)},getState:()=>n,reset:()=>{n=Bn(),s=!0}}}function Rn(t,e){return"string"==typeof e?e!==t:!!Array.isArray(e)&&!Dn(e,t)}function Kn(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Bn(){return{animate:Kn(!0),whileInView:Kn(),whileHover:Kn(),whileTap:Kn(),whileDrag:Kn(),whileFocus:Kn(),exit:Kn()}}function jn(t,e,n,i={passive:!0}){return t.addEventListener(e,n,i),()=>t.removeEventListener(e,n,i)}let Gn=0;const qn={animation:{Feature:class extends Sn{constructor(t){super(t),t.animationState||(t.animationState=Ln(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();pt(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:e}=this.node.prevProps||{};t!==e&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}},exit:{Feature:class extends Sn{constructor(){super(...arguments),this.id=Gn++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:e}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===n)return;if(t&&!1===n){if(this.isExitComplete){const{initial:t,custom:e}=this.node.getProps();if("string"==typeof t||"object"==typeof t&&null!==t&&!Array.isArray(t)){const n=_e(this.node,t,e);if(n){const{transition:t,transitionEnd:e,...i}=n;for(const t in i)this.node.getValue(t)?.jump(i[t])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);return void(this.isExitComplete=!1)}const i=this.node.animationState.setActive("exit",!t);e&&!t&&i.then(()=>{this.isExitComplete=!0,e(this.id)})}mount(){const{register:t,onExitComplete:e}=this.node.presenceContext||{};e&&e(this.id),t&&(this.unmount=t(this.id))}unmount(){}}}};function Hn(t){return{point:{x:t.pageX,y:t.pageY}}}function Nn(t,e,n){const{props:i}=t;t.animationState&&i.whileHover&&t.animationState.setActive("whileHover","Start"===n);const s=i["onHover"+n];s&&y.postRender(()=>s(e,Hn(e)))}function Un(t,e,n){const{props:i}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&i.whileTap&&t.animationState.setActive("whileTap","Start"===n);const s=i["onTap"+("End"===n?"":n)];s&&y.postRender(()=>s(e,Hn(e)))}const $n=new WeakMap,Wn=new WeakMap,zn=t=>{const e=$n.get(t.target);e&&e(t)},_n=t=>{t.forEach(zn)};function Yn(t,e,n){const i=function({root:t,...e}){const n=t||document;Wn.has(n)||Wn.set(n,{});const i=Wn.get(n),s=JSON.stringify(e);return i[s]||(i[s]=new IntersectionObserver(_n,{root:t,...e})),i[s]}(e);return $n.set(t,n),i.observe(t),()=>{$n.delete(t),i.unobserve(t)}}const Xn={some:0,all:1};const Jn={renderer:(t,e)=>e.isSVG??ft(t)?new En(e):new Cn(e,{allowProjection:t!==yt}),...qn,...{inView:{Feature:class extends Sn{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:t={}}=this.node.getProps(),{root:e,margin:n,amount:i="some",once:s}=t,r={root:e?e.current:void 0,rootMargin:n,threshold:"number"==typeof i?i:Xn[i]};this.stopObserver=Yn(this.node.current,r,t=>{const{isIntersecting:e}=t;if(this.isInView===e)return;if(this.isInView=e,s&&!e&&this.hasEnteredView)return;e&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",e);const{onViewportEnter:n,onViewportLeave:i}=this.node.getProps(),r=e?n:i;r&&r(t)})}mount(){this.startObserver()}update(){if("undefined"==typeof IntersectionObserver)return;const{props:t,prevProps:e}=this.node;["amount","margin","root"].some(function({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}(t,e))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}},tap:{Feature:class extends Sn{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:e,propagate:n}=this.node.props;this.unmount=An(t,(t,e)=>(Un(this.node,e,"Start"),(t,{success:e})=>Un(this.node,t,e?"End":"Cancel")),{useGlobalTarget:e,stopPropagation:!1===n?.tap})}unmount(){}}},focus:{Feature:class extends Sn{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch(e){t=!0}t&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=vt(jn(this.node.current,"focus",()=>this.onFocus()),jn(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}},hover:{Feature:class extends Sn{mount(){const{current:t}=this.node;t&&(this.unmount=mn(t,(t,e)=>(Nn(this.node,e,"Start"),t=>Nn(this.node,t,"End"))))}unmount(){}}}}};export{Jn as domAnimation};