framer-motion
Version:
A simple and powerful JavaScript animation library
1 lines • 68.6 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Motion={})}(this,(function(t){"use strict";function e(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}let n=()=>{};const s={skipAnimations:!1,useManualTiming:!1};function r(t){let e;return()=>(void 0===e&&(e=t()),e)}const i=t=>t,o=(t,e,n)=>{const s=e-t;return 0===s?1:(n-t)/s};class a{constructor(){this.subscriptions=[]}add(t){var n,s;return n=this.subscriptions,s=t,-1===n.indexOf(s)&&n.push(s),()=>e(this.subscriptions,t)}notify(t,e,n){const s=this.subscriptions.length;if(s)if(1===s)this.subscriptions[0](t,e,n);else for(let r=0;r<s;r++){const s=this.subscriptions[r];s&&s(t,e,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const l=t=>1e3*t,u=t=>t/1e3;function c(t,e){return e?t*(1e3/e):0}const h=r((()=>void 0!==window.ScrollTimeline));class d{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 n=0;n<this.animations.length;n++)this.animations[n][t]=e}attachTimeline(t,e){const n=this.animations.map((n=>h()&&n.attachTimeline?n.attachTimeline(t):"function"==typeof e?e(n):void 0));return()=>{n.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 startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let e=0;e<this.animations.length;e++)t=Math.max(t,this.animations[e].duration);return t}runAll(t){this.animations.forEach((e=>e[t]()))}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class p extends d{then(t,e){return this.finished.finally(t).then((()=>{}))}}const f=t=>t.startsWith("--"),m=(t,e,n)=>{f(e)?t.style.setProperty(e,n):t.style[e]=n},g=(t,e)=>f(e)?t.style.getPropertyValue(e):t.style[e],y=t=>null!==t;const v=r((()=>{try{document.createElement("div").animate({opacity:[1]})}catch(t){return!1}return!0})),w=new Set(["borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","radius","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","width","maxWidth","height","maxHeight","top","right","bottom","left","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","margin","marginTop","marginRight","marginBottom","marginLeft","backgroundPositionX","backgroundPositionY"]);const b={value:null,addProjectionMetrics:null},T=t=>Array.isArray(t)&&"number"==typeof t[0],x={};function S(t,e){const n=r(t);return()=>x[e]??n()}const M=S((()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0}),"linearEasing"),A=(t,e,n=10)=>{let s="";const r=Math.max(Math.round(e/n),2);for(let e=0;e<r;e++)s+=t(e/(r-1))+", ";return`linear(${s.substring(0,s.length-2)})`},V=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,k={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:V([0,.65,.55,1]),circOut:V([.55,0,1,.45]),backIn:V([.31,.01,.66,-.59]),backOut:V([.33,1.53,.69,.99])};function P(t,e){return t?"function"==typeof t&&M()?A(t,e):T(t)?V(t):Array.isArray(t)?t.map((t=>P(t,e)||k.easeOut)):k[t]:void 0}function E(t,e,n,{delay:s=0,duration:r=300,repeat:i=0,repeatType:o="loop",ease:a="easeInOut",times:l}={},u=void 0){const c={[e]:n};l&&(c.offset=l);const h=P(a,r);Array.isArray(h)&&(c.easing=h);return t.animate(c,{delay:s,duration:r,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:i+1,direction:"reverse"===o?"alternate":"normal",pseudoElement:u})}function C(t){return"function"==typeof t&&"applyToOptions"in t}const F=new WeakMap;class O{constructor(t){if("animation"in t)return void(this.animation=t.animation);const{element:e,name:n,keyframes:s,pseudoElement:r,allowFlatten:i=!1}=t;let{transition:o}=t;this.isPseudoElement=Boolean(r),this.allowFlatten=i;const a=function(t){const e=F.get(t)||new Map;return F.set(t,e),e}(e),l=((t,e)=>`${t}:${e}`)(n,r||""),u=a.get(l);u&&u.stop();const c=function(t,e,n,s){Array.isArray(n)||(n=[n]);for(let r=0;r<n.length;r++)null===n[r]&&(n[r]=0!==r||s?n[r-1]:g(t,e)),"number"==typeof n[r]&&w.has(e)&&(n[r]=n[r]+"px");return!s&&!v()&&n.length<2&&n.unshift(g(t,e)),n}(e,n,s,r);o.type,o=function({type:t,...e}){return C(t)?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}(o),this.animation=E(e,n,c,o,r),!1===o.autoplay&&this.animation.pause(),this.removeAnimation=()=>a.delete(l),this.animation.onfinish=()=>{r||(m(e,n,function(t,{repeat:e,repeatType:n="loop"},s){const r=t.filter(y),i=e&&"loop"!==n&&e%2==1?0:r.length-1;return i&&void 0!==s?s:r[i]}(c,o)),this.cancel())},a.set(l,this)}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.finish()}cancel(){try{this.animation.cancel()}catch(t){}this.removeAnimation()}stop(){const{state:t}=this;"idle"!==t&&"finished"!==t&&(this.commitStyles(),this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming().duration||0;return u(Number(t))}get time(){return u(Number(this.animation.currentTime)||0)}set time(t){this.animation.currentTime=l(t)}get speed(){return this.animation.playbackRate}set speed(t){this.animation.playbackRate=t}get state(){return this.animation.playState}get startTime(){return Number(this.animation.startTime)}get finished(){return this.animation.finished}flatten(){this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"})}attachTimeline(t){return this.animation.timeline=t,this.animation.onfinish=null,i}then(t,e){return this.finished.then(t).catch(e)}}function R(t,e){return t?.[e]??t?.default??t}const B=2e4;function L(t){let e=0;let n=t.next(e);for(;!n.done&&e<B;)e+=50,n=t.next(e);return e>=B?1/0:e}function I(t,e=100,n){const s=n({...t,keyframes:[0,e]}),r=Math.min(L(s),B);return{type:"keyframes",ease:t=>s.next(r*t).value/e,duration:u(r)}}function W(t){return Boolean("function"==typeof t&&M()||!t||"string"==typeof t&&(t in k||M())||T(t)||Array.isArray(t)&&t.every(W))}function D(t,e){t.timeline=e,t.onfinish=null}const N=["read","resolveKeyframes","update","preRender","render","postRender"];function K(t,e){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},i=()=>n=!0,o=N.reduce(((t,n)=>(t[n]=function(t,e){let n=new Set,s=new Set,r=!1,i=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1},l=0;function u(e){o.has(e)&&(c.schedule(e),t()),l++,e(a)}const c={schedule:(t,e=!1,i=!1)=>{const a=i&&r?n:s;return e&&o.add(t),a.has(t)||a.add(t),t},cancel:t=>{s.delete(t),o.delete(t)},process:t=>{a=t,r?i=!0:(r=!0,[n,s]=[s,n],n.forEach(u),e&&b.value&&b.value.frameloop[e].push(l),l=0,n.clear(),r=!1,i&&(i=!1,c.process(t)))}};return c}(i,e?n:void 0),t)),{}),{read:a,resolveKeyframes:l,update:u,preRender:c,render:h,postRender:d}=o,p=()=>{const i=performance.now();n=!1,r.delta=s?1e3/60:Math.max(Math.min(i-r.timestamp,40),1),r.timestamp=i,r.isProcessing=!0,a.process(r),l.process(r),u.process(r),c.process(r),h.process(r),d.process(r),r.isProcessing=!1,n&&e&&(s=!1,t(p))};return{schedule:N.reduce(((e,i)=>{const a=o[i];return e[i]=(e,i=!1,o=!1)=>(n||(n=!0,s=!0,r.isProcessing||t(p)),a.schedule(e,i,o)),e}),{}),cancel:t=>{for(let e=0;e<N.length;e++)o[N[e]].cancel(t)},state:r,steps:o}}const{schedule:$,cancel:j,state:z,steps:Y}=K("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:i,!0);let U;function X(){U=void 0}const H={now:()=>(void 0===U&&H.set(z.isProcessing||s.useManualTiming?z.timestamp:performance.now()),U),set:t=>{U=t,queueMicrotask(X)}},q=!1;function G(){return q}function Z(t,e,n){if(t instanceof EventTarget)return[t];if("string"==typeof t){let s=document;e&&(s=e.current);const r=n?.[t]??s.querySelectorAll(t);return r?Array.from(r):[]}return Array.from(t)}function _(t,e){const n=Z(t),s=new AbortController;return[n,{passive:!0,...e,signal:s.signal},()=>s.abort()]}function J(t){return!("touch"===t.pointerType||G())}const Q=(t,e)=>!!e&&(t===e||Q(t,e.parentElement)),tt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const et=new WeakSet;function nt(t){return e=>{"Enter"===e.key&&t(e)}}function st(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}function rt(t){return(t=>"mouse"===t.pointerType?"number"!=typeof t.button||t.button<=0:!1!==t.isPrimary)(t)&&!G()}class it{constructor(t,e={}){this.version="12.7.3",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(t,e=!0)=>{const n=H.now();this.updatedAt!==n&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(t),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),e&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=e.owner}setCurrent(t){var e;this.current=t,this.updatedAt=H.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){this.events[t]||(this.events[t]=new a);const n=this.events[t].add(e);return"change"===t?()=>{n(),$.read((()=>{this.events.change.getSize()||this.stop()}))}:n}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,e){this.passiveEffect=t,this.stopPassiveEffect=e}set(t,e=!0){e&&this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t,e)}setWithVelocity(t,e,n){this.set(e),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-n}jump(t,e=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,e&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=H.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const e=Math.min(this.updatedAt-this.prevUpdatedAt,30);return c(parseFloat(this.current)-parseFloat(this.prevFrameValue),e)}start(t){return this.stop(),new Promise((e=>{this.hasAnimated=!0,this.animation=t(e),this.events.animationStart&&this.events.animationStart.notify()})).then((()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()}))}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function ot(t,e){return new it(t,e)}const at=$,lt=N.reduce(((t,e)=>(t[e]=t=>j(t),t)),{}),ut=(t,e,n)=>n>e?e:n<t?t:n;function ct(t,e,n){const s=Math.max(e-5,0);return c(n-t(s),e-s)}const ht=100,dt=10,pt=1,ft=0,mt=800,gt=.3,yt=.3,vt={granular:.01,default:2},wt={granular:.005,default:.5},bt=.01,Tt=10,xt=.05,St=1,Mt=.001;function At({duration:t=mt,bounce:e=gt,velocity:n=ft,mass:s=pt}){let r,i,o=1-e;o=ut(xt,St,o),t=ut(bt,Tt,u(t)),o<1?(r=e=>{const s=e*o,r=s*t,i=s-n,a=kt(e,o),l=Math.exp(-r);return Mt-i/a*l},i=e=>{const s=e*o*t,i=s*n+n,a=Math.pow(o,2)*Math.pow(e,2)*t,l=Math.exp(-s),u=kt(Math.pow(e,2),o);return(-r(e)+Mt>0?-1:1)*((i-a)*l)/u}):(r=e=>Math.exp(-e*t)*((e-n)*t+1)-.001,i=e=>Math.exp(-e*t)*(t*t*(n-e)));const a=function(t,e,n){let s=n;for(let n=1;n<Vt;n++)s-=t(s)/e(s);return s}(r,i,5/t);if(t=l(t),isNaN(a))return{stiffness:ht,damping:dt,duration:t};{const e=Math.pow(a,2)*s;return{stiffness:e,damping:2*o*Math.sqrt(s*e),duration:t}}}const Vt=12;function kt(t,e){return t*Math.sqrt(1-e*e)}const Pt=["duration","bounce"],Et=["stiffness","damping","mass"];function Ct(t,e){return e.some((e=>void 0!==t[e]))}function Ft(t=yt,e=gt){const n="object"!=typeof t?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:r}=n;const i=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:i},{stiffness:c,damping:h,mass:d,duration:p,velocity:f,isResolvedFromDuration:m}=function(t){let e={velocity:ft,stiffness:ht,damping:dt,mass:pt,isResolvedFromDuration:!1,...t};if(!Ct(t,Et)&&Ct(t,Pt))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(1.2*n),r=s*s,i=2*ut(.05,1,1-(t.bounce||0))*Math.sqrt(r);e={...e,mass:pt,stiffness:r,damping:i}}else{const n=At(t);e={...e,...n,mass:pt},e.isResolvedFromDuration=!0}return e}({...n,velocity:-u(n.velocity||0)}),g=f||0,y=h/(2*Math.sqrt(c*d)),v=o-i,w=u(Math.sqrt(c/d)),b=Math.abs(v)<5;let T;if(s||(s=b?vt.granular:vt.default),r||(r=b?wt.granular:wt.default),y<1){const t=kt(w,y);T=e=>{const n=Math.exp(-y*w*e);return o-n*((g+y*w*v)/t*Math.sin(t*e)+v*Math.cos(t*e))}}else if(1===y)T=t=>o-Math.exp(-w*t)*(v+(g+w*v)*t);else{const t=w*Math.sqrt(y*y-1);T=e=>{const n=Math.exp(-y*w*e),s=Math.min(t*e,300);return o-n*((g+y*w*v)*Math.sinh(s)+t*v*Math.cosh(s))/t}}const x={calculatedDuration:m&&p||null,next:t=>{const e=T(t);if(m)a.done=t>=p;else{let n=0;y<1&&(n=0===t?l(g):ct(T,t,e));const i=Math.abs(n)<=s,u=Math.abs(o-e)<=r;a.done=i&&u}return a.value=a.done?o:e,a},toString:()=>{const t=Math.min(L(x),B),e=A((e=>x.next(t*e).value),t,30);return t+"ms "+e},toTransition:()=>{}};return x}Ft.applyToOptions=t=>{const e=I(t,100,Ft);return t.ease=M()?e.ease:"easeOut",t.duration=l(e.duration),t.type="keyframes",t};const Ot=(t,e,n)=>{const s=e-t;return((n-t)%s+s)%s+t},Rt=t=>Array.isArray(t)&&"number"!=typeof t[0];function Bt(t,e){return Rt(t)?t[Ot(0,t.length,e)]:t}const Lt=(t,e,n)=>t+(e-t)*n;function It(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const r=o(0,e,s);t.push(Lt(n,1,r))}}function Wt(t){const e=[0];return It(e,t.length-1),e}const Dt=t=>Boolean(t&&t.getVelocity);function Nt(t){return"object"==typeof t&&!Array.isArray(t)}function Kt(t,e,n,s){return"string"==typeof t&&Nt(e)?Z(t,n,s):t instanceof NodeList?Array.from(t):Array.isArray(t)?t:[t]}function $t(t,e,n){return t*(e+1)}function jt(t,e,n,s){return"number"==typeof e?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:s.get(e)??t}function zt(t,n,s,r,i,o){!function(t,n,s){for(let r=0;r<t.length;r++){const i=t[r];i.at>n&&i.at<s&&(e(t,i),r--)}}(t,i,o);for(let e=0;e<n.length;e++)t.push({value:n[e],at:Lt(i,o,r[e]),easing:Bt(s,e)})}function Yt(t,e){for(let n=0;n<t.length;n++)t[n]=t[n]/(e+1)}function Ut(t,e){return t.at===e.at?null===t.value?1:null===e.value?-1:0:t.at-e.at}function Xt(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function Ht(t,e){return e[t]||(e[t]=[]),e[t]}function qt(t){return Array.isArray(t)?t:[t]}function Gt(t,e){return t&&t[e]?{...t,...t[e]}:{...t}}const Zt=t=>"number"==typeof t,_t=t=>t.every(Zt),Jt=new WeakMap,Qt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],te=new Set(Qt),ee=new Set(["width","height","top","left","right","bottom",...Qt]),ne=t=>(t=>Array.isArray(t))(t)?t[t.length-1]||0:t;function se(t){const e=[{},{}];return t?.values.forEach(((t,n)=>{e[0][n]=t.get(),e[1][n]=t.getVelocity()})),e}function re(t,e,n,s){if("function"==typeof e){const[r,i]=se(s);e=e(void 0!==n?n:t.custom,r,i)}if("string"==typeof e&&(e=t.variants&&t.variants[e]),"function"==typeof e){const[r,i]=se(s);e=e(void 0!==n?n:t.custom,r,i)}return e}function ie(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,ot(n))}function oe(t,e){const n=function(t,e,n){const s=t.getProps();return re(s,e,void 0!==n?n:s.custom,t)}(t,e);let{transitionEnd:s={},transition:r={},...i}=n||{};i={...i,...s};for(const e in i){ie(t,e,ne(i[e]))}}function ae(t,e){const n=t.getValue("willChange");if(r=n,Boolean(Dt(r)&&r.add))return n.add(e);if(!n&&s.WillChange){const n=new s.WillChange("auto");t.addValue("willChange",n),n.add(e)}var r}const le=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),ue="data-"+le("framerAppearId");function ce(t){return t.props[ue]}const he=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function de(t,e,n,s){if(t===e&&n===s)return i;const r=e=>function(t,e,n,s,r){let i,o,a=0;do{o=e+(n-e)/2,i=he(o,s,r)-t,i>0?n=o:e=o}while(Math.abs(i)>1e-7&&++a<12);return o}(e,0,1,t,n);return t=>0===t||1===t?t:he(r(t),e,s)}const pe=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,fe=t=>e=>1-t(1-e),me=de(.33,1.53,.69,.99),ge=fe(me),ye=pe(ge),ve=t=>(t*=2)<1?.5*ge(t):.5*(2-Math.pow(2,-10*(t-1))),we=t=>1-Math.sin(Math.acos(t)),be=fe(we),Te=pe(we),xe=t=>/^0[^.\s]+$/u.test(t);const Se={test:t=>"number"==typeof t,parse:parseFloat,transform:t=>t},Me={...Se,transform:t=>ut(0,1,t)},Ae={...Se,default:1},Ve=t=>Math.round(1e5*t)/1e5,ke=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const Pe=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ee=(t,e)=>n=>Boolean("string"==typeof n&&Pe.test(n)&&n.startsWith(t)||e&&!function(t){return null==t}(n)&&Object.prototype.hasOwnProperty.call(n,e)),Ce=(t,e,n)=>s=>{if("string"!=typeof s)return s;const[r,i,o,a]=s.match(ke);return{[t]:parseFloat(r),[e]:parseFloat(i),[n]:parseFloat(o),alpha:void 0!==a?parseFloat(a):1}},Fe={...Se,transform:t=>Math.round((t=>ut(0,255,t))(t))},Oe={test:Ee("rgb","red"),parse:Ce("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+Fe.transform(t)+", "+Fe.transform(e)+", "+Fe.transform(n)+", "+Ve(Me.transform(s))+")"};const Re={test:Ee("#"),parse:function(t){let e="",n="",s="",r="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),r=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),r=t.substring(4,5),e+=e,n+=n,s+=s,r+=r),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:r?parseInt(r,16)/255:1}},transform:Oe.transform},Be=t=>({test:e=>"string"==typeof e&&e.endsWith(t)&&1===e.split(" ").length,parse:parseFloat,transform:e=>`${e}${t}`}),Le=Be("deg"),Ie=Be("%"),We=Be("px"),De=Be("vh"),Ne=Be("vw"),Ke={...Ie,parse:t=>Ie.parse(t)/100,transform:t=>Ie.transform(100*t)},$e={test:Ee("hsl","hue"),parse:Ce("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+Ie.transform(Ve(e))+", "+Ie.transform(Ve(n))+", "+Ve(Me.transform(s))+")"},je={test:t=>Oe.test(t)||Re.test(t)||$e.test(t),parse:t=>Oe.test(t)?Oe.parse(t):$e.test(t)?$e.parse(t):Re.parse(t),transform:t=>"string"==typeof t?t:t.hasOwnProperty("red")?Oe.transform(t):$e.transform(t)},ze=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;const Ye="number",Ue="color",Xe=/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+)/giu;function He(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},r=[];let i=0;const o=e.replace(Xe,(t=>(je.test(t)?(s.color.push(i),r.push(Ue),n.push(je.parse(t))):t.startsWith("var(")?(s.var.push(i),r.push("var"),n.push(t)):(s.number.push(i),r.push(Ye),n.push(parseFloat(t))),++i,"${}"))).split("${}");return{values:n,split:o,indexes:s,types:r}}function qe(t){return He(t).values}function Ge(t){const{split:e,types:n}=He(t),s=e.length;return t=>{let r="";for(let i=0;i<s;i++)if(r+=e[i],void 0!==t[i]){const e=n[i];r+=e===Ye?Ve(t[i]):e===Ue?je.transform(t[i]):t[i]}return r}}const Ze=t=>"number"==typeof t?0:t;const _e={test:function(t){return isNaN(t)&&"string"==typeof t&&(t.match(ke)?.length||0)+(t.match(ze)?.length||0)>0},parse:qe,createTransformer:Ge,getAnimatableNone:function(t){const e=qe(t);return Ge(t)(e.map(Ze))}},Je=new Set(["brightness","contrast","saturate","opacity"]);function Qe(t){const[e,n]=t.slice(0,-1).split("(");if("drop-shadow"===e)return t;const[s]=n.match(ke)||[];if(!s)return t;const r=n.replace(s,"");let i=Je.has(e)?1:0;return s!==n&&(i*=100),e+"("+i+r+")"}const tn=/\b([a-z-]*)\(.*?\)/gu,en={..._e,getAnimatableNone:t=>{const e=t.match(tn);return e?e.map(Qe).join(" "):t}},nn={borderWidth:We,borderTopWidth:We,borderRightWidth:We,borderBottomWidth:We,borderLeftWidth:We,borderRadius:We,radius:We,borderTopLeftRadius:We,borderTopRightRadius:We,borderBottomRightRadius:We,borderBottomLeftRadius:We,width:We,maxWidth:We,height:We,maxHeight:We,top:We,right:We,bottom:We,left:We,padding:We,paddingTop:We,paddingRight:We,paddingBottom:We,paddingLeft:We,margin:We,marginTop:We,marginRight:We,marginBottom:We,marginLeft:We,backgroundPositionX:We,backgroundPositionY:We},sn={rotate:Le,rotateX:Le,rotateY:Le,rotateZ:Le,scale:Ae,scaleX:Ae,scaleY:Ae,scaleZ:Ae,skew:Le,skewX:Le,skewY:Le,distance:We,translateX:We,translateY:We,translateZ:We,x:We,y:We,z:We,perspective:We,transformPerspective:We,opacity:Me,originX:Ke,originY:Ke,originZ:We},rn={...Se,transform:Math.round},on={...nn,...sn,zIndex:rn,size:We,fillOpacity:Me,strokeOpacity:Me,numOctaves:rn},an={...on,color:je,backgroundColor:je,outlineColor:je,fill:je,stroke:je,borderColor:je,borderTopColor:je,borderRightColor:je,borderBottomColor:je,borderLeftColor:je,filter:en,WebkitFilter:en},ln=t=>an[t];function un(t,e){let n=ln(t);return n!==en&&(n=_e),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const cn=new Set(["auto","none","0"]);const hn=t=>180*t/Math.PI,dn=t=>{const e=hn(Math.atan2(t[1],t[0]));return fn(e)},pn={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:dn,rotateZ:dn,skewX:t=>hn(Math.atan(t[1])),skewY:t=>hn(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},fn=t=>((t%=360)<0&&(t+=360),t),mn=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),gn=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),yn={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:mn,scaleY:gn,scale:t=>(mn(t)+gn(t))/2,rotateX:t=>fn(hn(Math.atan2(t[6],t[5]))),rotateY:t=>fn(hn(Math.atan2(-t[2],t[0]))),rotateZ:dn,rotate:dn,skewX:t=>hn(Math.atan(t[4])),skewY:t=>hn(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function vn(t){return t.includes("scale")?1:0}function wn(t,e){if(!t||"none"===t)return vn(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=yn,r=n;else{const e=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=pn,r=e}if(!r)return vn(e);const i=s[e],o=r[1].split(",").map(bn);return"function"==typeof i?i(o):o[i]}function bn(t){return parseFloat(t.trim())}const Tn=t=>t===Se||t===We,xn=new Set(["x","y","z"]),Sn=Qt.filter((t=>!xn.has(t)));const Mn={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>wn(e,"x"),y:(t,{transform:e})=>wn(e,"y")};Mn.translateX=Mn.x,Mn.translateY=Mn.y;const An=new Set;let Vn=!1,kn=!1;function Pn(){if(kn){const t=Array.from(An).filter((t=>t.needsMeasurement)),e=new Set(t.map((t=>t.element))),n=new Map;e.forEach((t=>{const e=function(t){const e=[];return Sn.forEach((n=>{const s=t.getValue(n);void 0!==s&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))})),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,n])=>{t.getValue(e)?.set(n)}))})),t.forEach((t=>t.measureEndState())),t.forEach((t=>{void 0!==t.suspendedScrollY&&window.scrollTo(0,t.suspendedScrollY)}))}kn=!1,Vn=!1,An.forEach((t=>t.complete())),An.clear()}function En(){An.forEach((t=>{t.readKeyframes(),t.needsMeasurement&&(kn=!0)}))}class Cn{constructor(t,e,n,s,r,i=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=e,this.name=n,this.motionValue=s,this.element=r,this.isAsync=i}scheduleResolve(){this.isScheduled=!0,this.isAsync?(An.add(this),Vn||(Vn=!0,$.read(En),$.resolveKeyframes(Pn))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:e,element:n,motionValue:s}=this;for(let r=0;r<t.length;r++)if(null===t[r])if(0===r){const r=s?.get(),i=t[t.length-1];if(void 0!==r)t[0]=r;else if(n&&e){const s=n.readValue(e,i);null!=s&&(t[0]=s)}void 0===t[0]&&(t[0]=i),s&&void 0===r&&s.set(t[0])}else t[r]=t[r-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),An.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,An.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const Fn=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t),On=t=>e=>"string"==typeof e&&e.startsWith(t),Rn=On("--"),Bn=On("var(--"),Ln=t=>!!Bn(t)&&In.test(t.split("/*")[0].trim()),In=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Wn=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Dn(t,e,n=1){const[s,r]=function(t){const e=Wn.exec(t);if(!e)return[,];const[,n,s,r]=e;return[`--${n??s}`,r]}(t);if(!s)return;const i=window.getComputedStyle(e).getPropertyValue(s);if(i){const t=i.trim();return Fn(t)?parseFloat(t):t}return Ln(r)?Dn(r,e,n+1):r}const Nn=t=>e=>e.test(t),Kn=[Se,We,Ie,Le,Ne,De,{test:t=>"auto"===t,parse:t=>t}],$n=t=>Kn.find(Nn(t));class jn extends Cn{constructor(t,e,n,s,r){super(t,e,n,s,r,!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 s=t[n];if("string"==typeof s&&(s=s.trim(),Ln(s))){const r=Dn(s,e.current);void 0!==r&&(t[n]=r),n===t.length-1&&(this.finalKeyframe=s)}}if(this.resolveNoneKeyframes(),!ee.has(n)||2!==t.length)return;const[s,r]=t,i=$n(s),o=$n(r);if(i!==o)if(Tn(i)&&Tn(o))for(let e=0;e<t.length;e++){const n=t[e];"string"==typeof n&&(t[e]=parseFloat(n))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:e}=this,n=[];for(let e=0;e<t.length;e++)("number"==typeof(s=t[e])?0===s:null===s||"none"===s||"0"===s||xe(s))&&n.push(e);var s;n.length&&function(t,e,n){let s,r=0;for(;r<t.length&&!s;){const e=t[r];"string"==typeof e&&!cn.has(e)&&He(e).values.length&&(s=t[r]),r++}if(s&&n)for(const r of e)t[r]=un(n,s)}(t,n,e)}measureInitialState(){const{element:t,unresolvedKeyframes:e,name:n}=this;if(!t||!t.current)return;"height"===n&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Mn[n](t.measureViewportBox(),window.getComputedStyle(t.current)),e[0]=this.measuredOrigin;const s=e[e.length-1];void 0!==s&&t.getValue(n,s).jump(s,!1)}measureEndState(){const{element:t,name:e,unresolvedKeyframes:n}=this;if(!t||!t.current)return;const s=t.getValue(e);s&&s.jump(this.measuredOrigin,!1);const r=n.length-1,i=n[r];n[r]=Mn[e](t.measureViewportBox(),window.getComputedStyle(t.current)),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 zn=(t,e)=>"zIndex"!==e&&(!("number"!=typeof t&&!Array.isArray(t))||!("string"!=typeof t||!_e.test(t)&&"0"!==t||t.startsWith("url(")));function Yn(t,e,n,s){const r=t[0];if(null===r)return!1;if("display"===e||"visibility"===e)return!0;const i=t[t.length-1],o=zn(r,e),a=zn(i,e);return!(!o||!a)&&(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||C(n))&&s)}const Un=t=>null!==t;function Xn(t,{repeat:e,repeatType:n="loop"},s){const r=t.filter(Un),i=e&&"loop"!==n&&e%2==1?0:r.length-1;return i&&void 0!==s?s:r[i]}class Hn{constructor({autoplay:t=!0,delay:e=0,type:n="keyframes",repeat:s=0,repeatDelay:r=0,repeatType:i="loop",...o}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=H.now(),this.options={autoplay:t,delay:e,type:n,repeat:s,repeatDelay:r,repeatType:i,...o},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt}get resolved(){return this._resolved||this.hasAttemptedResolve||(En(),Pn()),this._resolved}onKeyframesResolved(t,e){this.resolvedAt=H.now(),this.hasAttemptedResolve=!0;const{name:n,type:s,velocity:r,delay:i,onComplete:o,onUpdate:a,isGenerator:l}=this.options;if(!l&&!Yn(t,n,s,r)){if(!i)return a&&a(Xn(t,this.options,e)),o&&o(),void this.resolveFinishedPromise();this.options.duration=0}const u=this.initPlayback(t,e);!1!==u&&(this._resolved={keyframes:t,finalKeyframe:e,...u},this.onPostResolved())}onPostResolved(){}then(t,e){return this.currentFinishedPromise.then(t,e)}flatten(){this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear")}updateFinishedPromise(){this.currentFinishedPromise=new Promise((t=>{this.resolveFinishedPromise=t}))}}function qn(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 Gn(t,e){return n=>n>0?e:t}const Zn=(t,e,n)=>{const s=t*t,r=n*(e*e-s)+s;return r<0?0:Math.sqrt(r)},_n=[Re,Oe,$e];function Jn(t){const e=(n=t,_n.find((t=>t.test(n))));var n;if(!Boolean(e))return!1;let s=e.parse(t);return e===$e&&(s=function({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,n/=100;let r=0,i=0,o=0;if(e/=100){const s=n<.5?n*(1+e):n+e-n*e,a=2*n-s;r=qn(a,s,t+1/3),i=qn(a,s,t),o=qn(a,s,t-1/3)}else r=i=o=n;return{red:Math.round(255*r),green:Math.round(255*i),blue:Math.round(255*o),alpha:s}}(s)),s}const Qn=(t,e)=>{const n=Jn(t),s=Jn(e);if(!n||!s)return Gn(t,e);const r={...n};return t=>(r.red=Zn(n.red,s.red,t),r.green=Zn(n.green,s.green,t),r.blue=Zn(n.blue,s.blue,t),r.alpha=Lt(n.alpha,s.alpha,t),Oe.transform(r))},ts=(t,e)=>n=>e(t(n)),es=(...t)=>t.reduce(ts),ns=new Set(["none","hidden"]);function ss(t,e){return n=>Lt(t,e,n)}function rs(t){return"number"==typeof t?ss:"string"==typeof t?Ln(t)?Gn:je.test(t)?Qn:as:Array.isArray(t)?is:"object"==typeof t?je.test(t)?Qn:os:Gn}function is(t,e){const n=[...t],s=n.length,r=t.map(((t,n)=>rs(t)(t,e[n])));return t=>{for(let e=0;e<s;e++)n[e]=r[e](t);return n}}function os(t,e){const n={...t,...e},s={};for(const r in n)void 0!==t[r]&&void 0!==e[r]&&(s[r]=rs(t[r])(t[r],e[r]));return t=>{for(const e in s)n[e]=s[e](t);return n}}const as=(t,e)=>{const n=_e.createTransformer(e),s=He(t),r=He(e);return s.indexes.var.length===r.indexes.var.length&&s.indexes.color.length===r.indexes.color.length&&s.indexes.number.length>=r.indexes.number.length?ns.has(t)&&!r.values.length||ns.has(e)&&!s.values.length?function(t,e){return ns.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}(t,e):es(is(function(t,e){const n=[],s={color:0,var:0,number:0};for(let r=0;r<e.values.length;r++){const i=e.types[r],o=t.indexes[i][s[i]],a=t.values[o]??0;n[r]=a,s[i]++}return n}(s,r),r.values),n):Gn(t,e)};function ls(t,e,n){if("number"==typeof t&&"number"==typeof e&&"number"==typeof n)return Lt(t,e,n);return rs(t)(t,e)}function us({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:r=10,bounceStiffness:i=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 f=n*e;const m=h+f,g=void 0===o?m:o(m);g!==m&&(f=g-h);const y=t=>-f*Math.exp(-t/s),v=t=>g+y(t),w=t=>{const e=y(t),n=v(t);d.done=Math.abs(e)<=u,d.value=d.done?g:n};let b,T;const x=t=>{var e;(e=d.value,void 0!==a&&e<a||void 0!==l&&e>l)&&(b=t,T=Ft({keyframes:[d.value,p(d.value)],velocity:ct(v,t,d.value),damping:r,stiffness:i,restDelta:u,restSpeed:c}))};return x(0),{calculatedDuration:null,next:t=>{let e=!1;return T||void 0!==b||(e=!0,w(t),x(t)),void 0!==b&&t>=b?T.next(t-b):(!e&&w(t),d)}}}const cs=de(.42,0,1,1),hs=de(0,0,.58,1),ds=de(.42,0,.58,1),ps={linear:i,easeIn:cs,easeInOut:ds,easeOut:hs,circIn:we,circInOut:Te,circOut:be,backIn:ge,backInOut:ye,backOut:me,anticipate:ve},fs=t=>{if(T(t)){t.length;const[e,n,s,r]=t;return de(e,n,s,r)}return"string"==typeof t?ps[t]:t};function ms(t,e,{clamp:n=!0,ease:s,mixer:r}={}){const a=t.length;if(e.length,1===a)return()=>e[0];if(2===a&&e[0]===e[1])return()=>e[1];const l=t[0]===t[1];t[0]>t[a-1]&&(t=[...t].reverse(),e=[...e].reverse());const u=function(t,e,n){const s=[],r=n||ls,o=t.length-1;for(let n=0;n<o;n++){let o=r(t[n],t[n+1]);if(e){const t=Array.isArray(e)?e[n]||i:e;o=es(t,o)}s.push(o)}return s}(e,s,r),c=u.length,h=n=>{if(l&&n<t[0])return e[0];let s=0;if(c>1)for(;s<t.length-2&&!(n<t[s+1]);s++);const r=o(t[s],t[s+1],n);return u[s](r)};return n?e=>h(ut(t[0],t[a-1],e)):h}function gs({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const r=Rt(s)?s.map(fs):fs(s),i={done:!1,value:e[0]},o=function(t,e){return t.map((t=>t*e))}(n&&n.length===e.length?n:Wt(e),t),a=ms(o,e,{ease:Array.isArray(r)?r:(l=e,u=r,l.map((()=>u||ds)).splice(0,l.length-1))});var l,u;return{calculatedDuration:t,next:e=>(i.value=a(e),i.done=e>=t,i)}}const ys=t=>{const e=({timestamp:e})=>t(e);return{start:()=>$.update(e,!0),stop:()=>j(e),now:()=>z.isProcessing?z.timestamp:H.now()}},vs={decay:us,inertia:us,tween:gs,keyframes:gs,spring:Ft},ws=t=>t/100;class bs extends Hn{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,"idle"===this.state)return;this.teardown();const{onStop:t}=this.options;t&&t()};const{name:e,motionValue:n,element:s,keyframes:r}=this.options,i=s?.KeyframeResolver||Cn;this.resolver=new i(r,((t,e)=>this.onKeyframesResolved(t,e)),e,n,s),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:e="keyframes",repeat:n=0,repeatDelay:s=0,repeatType:r,velocity:i=0}=this.options,o=C(e)?e:vs[e]||gs;let a,l;o!==gs&&"number"!=typeof t[0]&&(a=es(ws,ls(t[0],t[1])),t=[0,100]);const u=o({...this.options,keyframes:t});"mirror"===r&&(l=o({...this.options,keyframes:[...t].reverse(),velocity:-i})),null===u.calculatedDuration&&(u.calculatedDuration=L(u));const{calculatedDuration:c}=u,h=c+s;return{generator:u,mirroredGenerator:l,mapPercentToKeyframes:a,calculatedDuration:c,resolvedDuration:h,totalDuration:h*(n+1)-s}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),"paused"!==this.pendingPlayState&&t?this.state=this.pendingPlayState:this.pause()}tick(t,e=!1){const{resolved:n}=this;if(!n){const{keyframes:t}=this.options;return{done:!0,value:t[t.length-1]}}const{finalKeyframe:s,generator:r,mirroredGenerator:i,mapPercentToKeyframes:o,keyframes:a,calculatedDuration:l,totalDuration:u,resolvedDuration:c}=n;if(null===this.startTime)return r.next(0);const{delay:h,repeat:d,repeatType:p,repeatDelay:f,onUpdate:m}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-u/this.speed,this.startTime)),e?this.currentTime=t:null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const g=this.currentTime-h*(this.speed>=0?1:-1),y=this.speed>=0?g<0:g>u;this.currentTime=Math.max(g,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=u);let v=this.currentTime,w=r;if(d){const t=Math.min(this.currentTime,u)/c;let e=Math.floor(t),n=t%1;!n&&t>=1&&(n=1),1===n&&e--,e=Math.min(e,d+1);Boolean(e%2)&&("reverse"===p?(n=1-n,f&&(n-=f/c)):"mirror"===p&&(w=i)),v=ut(0,1,n)*c}const b=y?{done:!1,value:a[0]}:w.next(v);o&&(b.value=o(b.value));let{done:T}=b;y||null===l||(T=this.speed>=0?this.currentTime>=u:this.currentTime<=0);const x=null===this.holdTime&&("finished"===this.state||"running"===this.state&&T);return x&&void 0!==s&&(b.value=Xn(a,this.options,s)),m&&m(b.value),x&&this.finish(),b}get duration(){const{resolved:t}=this;return t?u(t.calculatedDuration):0}get time(){return u(this.currentTime)}set time(t){t=l(t),this.currentTime=t,null!==this.holdTime||0===this.speed?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const e=this.playbackSpeed!==t;this.playbackSpeed=t,e&&(this.time=u(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved)return void(this.pendingPlayState="running");if(this.isStopped)return;const{driver:t=ys,onPlay:e,startTime:n}=this.options;this.driver||(this.driver=t((t=>this.tick(t)))),e&&e();const s=this.driver.now();null!==this.holdTime?this.startTime=s-this.holdTime:this.startTime?"finished"===this.state&&(this.startTime=s):this.startTime=n??this.calcStartTime(),"finished"===this.state&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){this._resolved?(this.state="paused",this.holdTime=this.currentTime??0):this.pendingPlayState="paused"}complete(){"running"!==this.state&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){null!==this.cancelTime&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}get finished(){return this.currentFinishedPromise}}const Ts=new Set(["opacity","clipPath","filter","transform"]),xs=r((()=>Object.hasOwnProperty.call(Element.prototype,"animate")));const Ss={anticipate:ve,backInOut:ye,circInOut:Te};class Ms extends Hn{constructor(t){super(t);const{name:e,motionValue:n,element:s,keyframes:r}=this.options;this.resolver=new jn(r,((t,e)=>this.onKeyframesResolved(t,e)),e,n,s),this.resolver.scheduleResolve()}initPlayback(t,e){let{duration:n=300,times:s,ease:r,type:i,motionValue:o,name:a,startTime:l}=this.options;if(!o.owner||!o.owner.current)return!1;var u;if("string"==typeof r&&M()&&r in Ss&&(r=Ss[r]),C((u=this.options).type)||"spring"===u.type||!W(u.ease)){const{onComplete:e,onUpdate:o,motionValue:a,element:l,...u}=this.options,c=function(t,e){const n=new bs({...e,keyframes:t,repeat:0,delay:0,isGenerator:!0});let s={done:!1,value:t[0]};const r=[];let i=0;for(;!s.done&&i<2e4;)s=n.sample(i),r.push(s.value),i+=10;return{times:void 0,keyframes:r,duration:i-10,ease:"linear"}}(t,u);1===(t=c.keyframes).length&&(t[1]=t[0]),n=c.duration,s=c.times,r=c.ease,i="keyframes"}const c=E(o.owner.current,a,t,{...this.options,duration:n,times:s,ease:r});return c.startTime=l??this.calcStartTime(),this.pendingTimeline?(D(c,this.pendingTimeline),this.pendingTimeline=void 0):c.onfinish=()=>{const{onComplete:n}=this.options;o.set(Xn(t,this.options,e)),n&&n(),this.cancel(),this.resolveFinishedPromise()},{animation:c,duration:n,times:s,type:i,ease:r,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:e}=t;return u(e)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:e}=t;return u(e.currentTime||0)}set time(t){const{resolved:e}=this;if(!e)return;const{animation:n}=e;n.currentTime=l(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:e}=t;return e.playbackRate}get finished(){return this.resolved.animation.finished}set speed(t){const{resolved:e}=this;if(!e)return;const{animation:n}=e;n.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:e}=t;return e.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:e}=t;return e.startTime}attachTimeline(t){if(this._resolved){const{resolved:e}=this;if(!e)return i;const{animation:n}=e;D(n,t)}else this.pendingTimeline=t;return i}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:e}=t;"finished"===e.playState&&this.updateFinishedPromise(),e.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:e}=t;e.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,"idle"===this.state)return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:e,keyframes:n,duration:s,type:r,ease:i,times:o}=t;if("idle"===e.playState||"finished"===e.playState)return;if(this.time){const{motionValue:t,onUpdate:e,onComplete:a,element:u,...c}=this.options,h=new bs({...c,keyframes:n,duration:s,type:r,ease:i,times:o,isGenerator:!0}),d=l(this.time);t.setWithVelocity(h.sample(d-10).value,h.sample(d).value,10)}const{onStop:a}=this.options;a&&a(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:r,damping:i,type:o}=t;if(!(e&&e.owner&&e.owner.current instanceof HTMLElement))return!1;const{onUpdate:a,transformTemplate:l}=e.owner.getProps();return xs()&&n&&Ts.has(n)&&("transform"!==n||!l)&&!a&&!s&&"mirror"!==r&&0!==i&&"inertia"!==o}}const As={type:"spring",stiffness:500,damping:25,restSpeed:10},Vs={type:"keyframes",duration:.8},ks={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Ps=(t,{keyframes:e})=>e.length>2?Vs:te.has(t)?t.startsWith("scale")?{type:"spring",stiffness:550,damping:0===e[1]?2*Math.sqrt(550):30,restSpeed:10}:As:ks;const Es=(t,e,n,s={},r,i)=>o=>{const a=R(s,t)||{},u=a.delay||s.delay||0;let{elapsed:c=0}=s;c-=l(u);let h={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-c,onUpdate:t=>{e.set(t),a.onUpdate&&a.onUpdate(t)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:i?void 0:r};(function({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:r,repeat:i,repeatType:o,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length})(a)||(h={...h,...Ps(t,h)}),h.duration&&(h.duration=l(h.duration)),h.repeatDelay&&(h.repeatDelay=l(h.repeatDelay)),void 0!==h.from&&(h.keyframes[0]=h.from);let d=!1;if((!1===h.type||0===h.duration&&!h.repeatDelay)&&(h.duration=0,0===h.delay&&(d=!0)),h.allowFlatten=!a.type&&!a.ease,d&&!i&&void 0!==e.get()){const t=Xn(h.keyframes,a);if(void 0!==t)return $.update((()=>{h.onUpdate(t),h.onComplete()})),new p([])}return!i&&Ms.supports(h)?new Ms(h):new bs(h)};function Cs({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&!0!==e[n];return e[n]=!1,s}function Fs(t,e,{delay:n=0,transitionOverride:s,type:r}={}){let{transition:i=t.getDefaultTransition(),transitionEnd:o,...a}=e;s&&(i=s);const l=[],u=r&&t.animationState&&t.animationState.getState()[r];for(const e in a){const s=t.getValue(e,t.latestValues[e]??null),r=a[e];if(void 0===r||u&&Cs(u,e))continue;const o={delay:n,...R(i||{},e)};let c=!1;if(window.MotionHandoffAnimation){const n=ce(t);if(n){const t=window.MotionHandoffAnimation(n,e,$);null!==t&&(o.startTime=t,c=!0)}}ae(t,e),s.start(Es(e,s,r,t.shouldReduceMotion&&ee.has(e)?{type:!1}:o,t,c));const h=s.animation;h&&l.push(h)}return o&&Promise.all(l).then((()=>{$.update((()=>{o&&oe(t,o)}))})),l}const Os=()=>({x:{min:0,max:0},y:{min:0,max:0}}),Rs={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Bs={};for(const t in Rs)Bs[t]={isEnabled:e=>Rs[t].some((t=>!!e[t]))};const Ls="undefined"!=typeof window,Is={current:null},Ws={current:!1};const Ds=[...Kn,je,_e];const Ns=["initial","animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"];function Ks(t){return null!==(e=t.animate)&&"object"==typeof e&&"function"==typeof e.start||Ns.some((e=>function(t){return"string"==typeof t||Array.isArray(t)}(t[e])));var e}const $s=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class js{scrapeMotionValuesFromProps(t,e,n){return{}}constructor({parent:t,props:e,presenceContext:n,reducedMotionConfig:s,blockInitialAnimation:r,visualState:i},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Cn,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const t=H.now();this.renderScheduledAt<t&&(this.renderScheduledAt=t,$.render(this.render,!1,!0))};const{latestValues:a,renderState:l,onUpdate:u}=i;this.onUpdate=u,this.latestValues=a,this.baseTarget={...a},this.initialValues=e.initial?{...a}:{},this.renderState=l,this.parent=t,this.props=e,this.presenceContext=n,this.depth=t?t.depth+1:0,this.reducedMotionConfig=s,this.options=o,this.blockInitialAnimation=Boolean(r),this.isControllingVariants=Ks(e),this.isVariantNode=function(t){return Boolean(Ks(t)||t.variants)}(e),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=Boolean(t&&t.current);const{willChange:c,...h}=this.scrapeMotionValuesFromProps(e,{},this);for(const t in h){const e=h[t];void 0!==a[t]&&Dt(e)&&e.set(a[t],!1)}}mount(t){this.current=t,Jt.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach(((t,e)=>this.bindToMotionValue(e,t))),Ws.current||function(){if(Ws.current=!0,Ls)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Is.current=t.matches;t.addListener(e),e()}else Is.current=!1}(),this.shouldReduceMotion="never"!==this.reducedMotionConfig&&("always"===this.reducedMotionConfig||Is.current),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),j(this.notifyUpdate),j(this.render),this.valueSubscriptions.forEach((t=>t())),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const e=this.features[t];e&&(e.unmount(),e.isMounted=!1)}this.current=null}bindToMotionValue(t,e){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const n=te.has(t);n&&this.onBindTransform&&this.onBindTransform();const s=e.on("change",(e=>{this.latestValues[t]=e,this.props.onUpdate&&$.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0)})),r=e.on("renderRequest",this.scheduleRender);let i;window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,t,e)),this.valueSubscriptions.set(t,(()=>{s(),r(),i&&i(),e.owner&&e.stop()}))}sortNodePosition(t){return this.current&&this.sortInstanceNodePosition&&this.type===t.type?this.sortInstanceNodePosition(this.current,t.current):0}updateFeatures(){let t="animation";for(t in Bs){const e=Bs[t];if(!e)continue;const{isEnabled:n,Feature:s}=e;if(!this.features[t]&&s&&n(this.props)&&(this.features[t]=new s(this)),this.features[t]){const e=this.features[t];e.isMounted?e.update():(e.mount(),e.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):{x:{min:0,max:0},y:{min:0,max:0}}}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,e){this.latestValues[t]=e}update(t,e){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=e;for(let e=0;e<$s.length;e++){const n=$s[e];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);const s=t["on"+n];s&&(this.propEventSubscriptions[n]=this.on(n,s))}this.prevMotionValues=function(t,e,n){for(const s in e){const r=e[s],i=n[s];if(Dt(r))t.addValue(s,r);else if(Dt(i))t.addValue(s,ot(r,{owner:t}));else if(i!==r)if(t.hasValue(s)){const e=t.getValue(s);!0===e.liveStyle?e.jump(r):e.hasAnimated||e.set(r)}else{const e=t.getStaticValue(s);t.addValue(s,ot(void 0!==e?e:r,{owner:t}))}}for(const s in n)void 0===e[s]&&t.removeValue(s);return e}(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const e=this.getClosestVariantNode();if(e)return e.variantChildren&&e.variantChildren.add(t),()=>e.variantChildren.delete(t)}addValue(t,e){const n=this.values.get(t);e!==n&&(n&&this.removeValue(t),this.bindToMotionValue(t,e),this.values.set(t,e),this.latestValues[t]=e.get())}removeValue(t){this.values.delete(t);const e=this.valueSubscriptions.get(t);e&&(e(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,e){if(this.props.values&&this.props.values[t])return this.props.values[t];let n=this.values.get(t);return void 0===n&&void 0!==e&&(n=ot(null===e?void 0:e,{owner:this}),this.addValue(t,n)),n}readValue(t,e){let n=void 0