UNPKG

framer-motion

Version:

A simple and powerful JavaScript animation library

1 lines • 100 kB
import{q as t,t as e,u as i,v as n,w as s,x as o,y as r,z as a,A as l,B as h,C as u,D as c,b as d,m as p,o as m,r as f,E as y,n as g,i as v,h as x,p as T,k as P,F as w,d as S,s as A,P as b,L as E,S as V,G as M,a as D,H as C,j as k,I as R,J as L,l as j,e as B,f as F,g as I}from"./size-rollup-dom-max-assets.js";import{jsx as O}from"react/jsx-runtime";import{useContext as U,useId as N,useEffect as K,useCallback as W,Component as $,Fragment as z}from"react";function Y(t,e){-1===t.indexOf(e)&&t.push(e)}function X(t,e){const i=t.indexOf(e);i>-1&&t.splice(i,1)}const H={},G=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function q(t){return"object"==typeof t&&null!==t}const _=t=>/^0[^.\s]+$/u.test(t);function Z(t){let e;return()=>(void 0===e&&(e=t()),e)}const J=t=>t,Q=(t,e)=>i=>e(t(i)),tt=(...t)=>t.reduce(Q),et=(t,e,i)=>{const n=e-t;return 0===n?1:(i-t)/n};class it{constructor(){this.subscriptions=[]}add(t){return Y(this.subscriptions,t),()=>X(this.subscriptions,t)}notify(t,e,i){const n=this.subscriptions.length;if(n)if(1===n)this.subscriptions[0](t,e,i);else for(let s=0;s<n;s++){const n=this.subscriptions[s];n&&n(t,e,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const nt=t=>1e3*t,st=t=>t/1e3;function ot(t,e){return e?t*(1e3/e):0}const rt=(t,e,i)=>(((1-3*i+3*e)*t+(3*i-6*e))*t+3*e)*t;function at(t,e,i,n){if(t===e&&i===n)return J;const s=e=>function(t,e,i,n,s){let o,r,a=0;do{r=e+(i-e)/2,o=rt(r,n,s)-t,o>0?i=r:e=r}while(Math.abs(o)>1e-7&&++a<12);return r}(e,0,1,t,i);return t=>0===t||1===t?t:rt(s(t),e,n)}const lt=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,ht=t=>e=>1-t(1-e),ut=at(.33,1.53,.69,.99),ct=ht(ut),dt=lt(ct),pt=t=>(t*=2)<1?.5*ct(t):.5*(2-Math.pow(2,-10*(t-1))),mt=t=>1-Math.sin(Math.acos(t)),ft=ht(mt),yt=lt(mt),gt=at(.42,0,1,1),vt=at(0,0,.58,1),xt=at(.42,0,.58,1),Tt=t=>Array.isArray(t)&&"number"==typeof t[0],Pt={linear:J,easeIn:gt,easeInOut:xt,easeOut:vt,circIn:mt,circInOut:yt,circOut:ft,backIn:ct,backInOut:dt,backOut:ut,anticipate:pt},wt=t=>{if(Tt(t)){t.length;const[e,i,n,s]=t;return at(e,i,n,s)}return"string"==typeof t?Pt[t]:t},St=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],At={value:null,addProjectionMetrics:null};function bt(t,e){let i=!1,n=!0;const s={delta:0,timestamp:0,isProcessing:!1},o=()=>i=!0,r=St.reduce((t,i)=>(t[i]=function(t,e){let i=new Set,n=new Set,s=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1},l=0;function h(e){r.has(e)&&(u.schedule(e),t()),l++,e(a)}const u={schedule:(t,e=!1,o=!1)=>{const a=o&&s?i:n;return e&&r.add(t),a.has(t)||a.add(t),t},cancel:t=>{n.delete(t),r.delete(t)},process:t=>{a=t,s?o=!0:(s=!0,[i,n]=[n,i],i.forEach(h),e&&At.value&&At.value.frameloop[e].push(l),l=0,i.clear(),s=!1,o&&(o=!1,u.process(t)))}};return u}(o,e?i:void 0),t),{}),{setup:a,read:l,resolveKeyframes:h,preUpdate:u,update:c,preRender:d,render:p,postRender:m}=r,f=()=>{const o=H.useManualTiming?s.timestamp:performance.now();i=!1,H.useManualTiming||(s.delta=n?1e3/60:Math.max(Math.min(o-s.timestamp,40),1)),s.timestamp=o,s.isProcessing=!0,a.process(s),l.process(s),h.process(s),u.process(s),c.process(s),d.process(s),p.process(s),m.process(s),s.isProcessing=!1,i&&e&&(n=!1,t(f))};return{schedule:St.reduce((e,o)=>{const a=r[o];return e[o]=(e,o=!1,r=!1)=>(i||(i=!0,n=!0,s.isProcessing||t(f)),a.schedule(e,o,r)),e},{}),cancel:t=>{for(let e=0;e<St.length;e++)r[St[e]].cancel(t)},state:s,steps:r}}const{schedule:Et,cancel:Vt,state:Mt,steps:Dt}=bt("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:J,!0);let Ct;function kt(){Ct=void 0}const Rt={now:()=>(void 0===Ct&&Rt.set(Mt.isProcessing||H.useManualTiming?Mt.timestamp:performance.now()),Ct),set:t=>{Ct=t,queueMicrotask(kt)}},Lt=t=>Math.round(1e5*t)/1e5,jt=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const Bt=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ft=(t,e)=>i=>Boolean("string"==typeof i&&Bt.test(i)&&i.startsWith(t)||e&&!function(t){return null==t}(i)&&Object.prototype.hasOwnProperty.call(i,e)),It=(t,e,i)=>n=>{if("string"!=typeof n)return n;const[s,o,r,a]=n.match(jt);return{[t]:parseFloat(s),[e]:parseFloat(o),[i]:parseFloat(r),alpha:void 0!==a?parseFloat(a):1}},Ot={...t,transform:t=>Math.round((t=>i(0,255,t))(t))},Ut={test:Ft("rgb","red"),parse:It("red","green","blue"),transform:({red:t,green:i,blue:n,alpha:s=1})=>"rgba("+Ot.transform(t)+", "+Ot.transform(i)+", "+Ot.transform(n)+", "+Lt(e.transform(s))+")"};const Nt={test:Ft("#"),parse:function(t){let e="",i="",n="",s="";return t.length>5?(e=t.substring(1,3),i=t.substring(3,5),n=t.substring(5,7),s=t.substring(7,9)):(e=t.substring(1,2),i=t.substring(2,3),n=t.substring(3,4),s=t.substring(4,5),e+=e,i+=i,n+=n,s+=s),{red:parseInt(e,16),green:parseInt(i,16),blue:parseInt(n,16),alpha:s?parseInt(s,16)/255:1}},transform:Ut.transform},Kt={test:Ft("hsl","hue"),parse:It("hue","saturation","lightness"),transform:({hue:t,saturation:i,lightness:s,alpha:o=1})=>"hsla("+Math.round(t)+", "+n.transform(Lt(i))+", "+n.transform(Lt(s))+", "+Lt(e.transform(o))+")"},Wt={test:t=>Ut.test(t)||Nt.test(t)||Kt.test(t),parse:t=>Ut.test(t)?Ut.parse(t):Kt.test(t)?Kt.parse(t):Nt.parse(t),transform:t=>"string"==typeof t?t:t.hasOwnProperty("red")?Ut.transform(t):Kt.transform(t),getAnimatableNone:t=>{const e=Wt.parse(t);return e.alpha=0,Wt.transform(e)}},$t=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;const zt="number",Yt="color",Xt=/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 Ht(t){const e=t.toString(),i=[],n={color:[],number:[],var:[]},s=[];let o=0;const r=e.replace(Xt,t=>(Wt.test(t)?(n.color.push(o),s.push(Yt),i.push(Wt.parse(t))):t.startsWith("var(")?(n.var.push(o),s.push("var"),i.push(t)):(n.number.push(o),s.push(zt),i.push(parseFloat(t))),++o,"${}")).split("${}");return{values:i,split:r,indexes:n,types:s}}function Gt(t){return Ht(t).values}function qt(t){const{split:e,types:i}=Ht(t),n=e.length;return t=>{let s="";for(let o=0;o<n;o++)if(s+=e[o],void 0!==t[o]){const e=i[o];s+=e===zt?Lt(t[o]):e===Yt?Wt.transform(t[o]):t[o]}return s}}const _t=t=>"number"==typeof t?0:Wt.test(t)?Wt.getAnimatableNone(t):t;const Zt={test:function(t){return isNaN(t)&&"string"==typeof t&&(t.match(jt)?.length||0)+(t.match($t)?.length||0)>0},parse:Gt,createTransformer:qt,getAnimatableNone:function(t){const e=Gt(t);return qt(t)(e.map(_t))}};function Jt(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}function Qt(t,e){return i=>i>0?e:t}const te=(t,e,i)=>t+(e-t)*i,ee=(t,e,i)=>{const n=t*t,s=i*(e*e-n)+n;return s<0?0:Math.sqrt(s)},ie=[Nt,Ut,Kt];function ne(t){const e=(i=t,ie.find(t=>t.test(i)));var i;if(!Boolean(e))return!1;let n=e.parse(t);return e===Kt&&(n=function({hue:t,saturation:e,lightness:i,alpha:n}){t/=360,i/=100;let s=0,o=0,r=0;if(e/=100){const n=i<.5?i*(1+e):i+e-i*e,a=2*i-n;s=Jt(a,n,t+1/3),o=Jt(a,n,t),r=Jt(a,n,t-1/3)}else s=o=r=i;return{red:Math.round(255*s),green:Math.round(255*o),blue:Math.round(255*r),alpha:n}}(n)),n}const se=(t,e)=>{const i=ne(t),n=ne(e);if(!i||!n)return Qt(t,e);const s={...i};return t=>(s.red=ee(i.red,n.red,t),s.green=ee(i.green,n.green,t),s.blue=ee(i.blue,n.blue,t),s.alpha=te(i.alpha,n.alpha,t),Ut.transform(s))},oe=new Set(["none","hidden"]);function re(t,e){return i=>te(t,e,i)}function ae(t){return"number"==typeof t?re:"string"==typeof t?s(t)?Qt:Wt.test(t)?se:ue:Array.isArray(t)?le:"object"==typeof t?Wt.test(t)?se:he:Qt}function le(t,e){const i=[...t],n=i.length,s=t.map((t,i)=>ae(t)(t,e[i]));return t=>{for(let e=0;e<n;e++)i[e]=s[e](t);return i}}function he(t,e){const i={...t,...e},n={};for(const s in i)void 0!==t[s]&&void 0!==e[s]&&(n[s]=ae(t[s])(t[s],e[s]));return t=>{for(const e in n)i[e]=n[e](t);return i}}const ue=(t,e)=>{const i=Zt.createTransformer(e),n=Ht(t),s=Ht(e);return n.indexes.var.length===s.indexes.var.length&&n.indexes.color.length===s.indexes.color.length&&n.indexes.number.length>=s.indexes.number.length?oe.has(t)&&!s.values.length||oe.has(e)&&!n.values.length?function(t,e){return oe.has(t)?i=>i<=0?t:e:i=>i>=1?e:t}(t,e):tt(le(function(t,e){const i=[],n={color:0,var:0,number:0};for(let s=0;s<e.values.length;s++){const o=e.types[s],r=t.indexes[o][n[o]],a=t.values[r]??0;i[s]=a,n[o]++}return i}(n,s),s.values),i):Qt(t,e)};function ce(t,e,i){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i)return te(t,e,i);return ae(t)(t,e)}const de=t=>{const e=({timestamp:e})=>t(e);return{start:(t=!0)=>Et.update(e,t),stop:()=>Vt(e),now:()=>Mt.isProcessing?Mt.timestamp:Rt.now()}},pe=(t,e,i=10)=>{let n="";const s=Math.max(Math.round(e/i),2);for(let e=0;e<s;e++)n+=Math.round(1e4*t(e/(s-1)))/1e4+", ";return`linear(${n.substring(0,n.length-2)})`},me=2e4;function fe(t){let e=0;let i=t.next(e);for(;!i.done&&e<me;)e+=50,i=t.next(e);return e>=me?1/0:e}function ye(t,e,i){const n=Math.max(e-5,0);return ot(i-t(n),e-n)}const ge=100,ve=10,xe=1,Te=0,Pe=800,we=.3,Se=.3,Ae={granular:.01,default:2},be={granular:.005,default:.5},Ee=.01,Ve=10,Me=.05,De=1,Ce=.001;function ke({duration:t=Pe,bounce:e=we,velocity:n=Te,mass:s=xe}){let o,r,a=1-e;a=i(Me,De,a),t=i(Ee,Ve,st(t)),a<1?(o=e=>{const i=e*a,s=i*t,o=i-n,r=Le(e,a),l=Math.exp(-s);return Ce-o/r*l},r=e=>{const i=e*a*t,s=i*n+n,r=Math.pow(a,2)*Math.pow(e,2)*t,l=Math.exp(-i),h=Le(Math.pow(e,2),a);return(-o(e)+Ce>0?-1:1)*((s-r)*l)/h}):(o=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,i){let n=i;for(let i=1;i<Re;i++)n-=t(n)/e(n);return n}(o,r,5/t);if(t=nt(t),isNaN(l))return{stiffness:ge,damping:ve,duration:t};{const e=Math.pow(l,2)*s;return{stiffness:e,damping:2*a*Math.sqrt(s*e),duration:t}}}const Re=12;function Le(t,e){return t*Math.sqrt(1-e*e)}const je=["duration","bounce"],Be=["stiffness","damping","mass"];function Fe(t,e){return e.some(e=>void 0!==t[e])}function Ie(t=Se,e=we){const n="object"!=typeof t?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:o}=n;const r=n.keyframes[0],a=n.keyframes[n.keyframes.length-1],l={done:!1,value:r},{stiffness:h,damping:u,mass:c,duration:d,velocity:p,isResolvedFromDuration:m}=function(t){let e={velocity:Te,stiffness:ge,damping:ve,mass:xe,isResolvedFromDuration:!1,...t};if(!Fe(t,Be)&&Fe(t,je))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(1.2*n),o=s*s,r=2*i(.05,1,1-(t.bounce||0))*Math.sqrt(o);e={...e,mass:xe,stiffness:o,damping:r}}else{const i=ke(t);e={...e,...i,mass:xe},e.isResolvedFromDuration=!0}return e}({...n,velocity:-st(n.velocity||0)}),f=p||0,y=u/(2*Math.sqrt(h*c)),g=a-r,v=st(Math.sqrt(h/c)),x=Math.abs(g)<5;let T;if(s||(s=x?Ae.granular:Ae.default),o||(o=x?be.granular:be.default),y<1){const t=Le(v,y);T=e=>{const i=Math.exp(-y*v*e);return a-i*((f+y*v*g)/t*Math.sin(t*e)+g*Math.cos(t*e))}}else if(1===y)T=t=>a-Math.exp(-v*t)*(g+(f+v*g)*t);else{const t=v*Math.sqrt(y*y-1);T=e=>{const i=Math.exp(-y*v*e),n=Math.min(t*e,300);return a-i*((f+y*v*g)*Math.sinh(n)+t*g*Math.cosh(n))/t}}const P={calculatedDuration:m&&d||null,next:t=>{const e=T(t);if(m)l.done=t>=d;else{let i=0===t?f:0;y<1&&(i=0===t?nt(f):ye(T,t,e));const n=Math.abs(i)<=s,r=Math.abs(a-e)<=o;l.done=n&&r}return l.value=l.done?a:e,l},toString:()=>{const t=Math.min(fe(P),me),e=pe(e=>P.next(t*e).value,t,30);return t+"ms "+e},toTransition:()=>{}};return P}function Oe({keyframes:t,velocity:e=0,power:i=.8,timeConstant:n=325,bounceDamping:s=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:l,restDelta:h=.5,restSpeed:u}){const c=t[0],d={done:!1,value:c},p=t=>void 0===a?l:void 0===l||Math.abs(a-t)<Math.abs(l-t)?a:l;let m=i*e;const f=c+m,y=void 0===r?f:r(f);y!==f&&(m=y-c);const g=t=>-m*Math.exp(-t/n),v=t=>y+g(t),x=t=>{const e=g(t),i=v(t);d.done=Math.abs(e)<=h,d.value=d.done?y:i};let T,P;const w=t=>{var e;(e=d.value,void 0!==a&&e<a||void 0!==l&&e>l)&&(T=t,P=Ie({keyframes:[d.value,p(d.value)],velocity:ye(v,t,d.value),damping:s,stiffness:o,restDelta:h,restSpeed:u}))};return w(0),{calculatedDuration:null,next:t=>{let e=!1;return P||void 0!==T||(e=!0,x(t),w(t)),void 0!==T&&t>=T?P.next(t-T):(!e&&x(t),d)}}}function Ue(t,e,{clamp:n=!0,ease:s,mixer:o}={}){const r=t.length;if(e.length,1===r)return()=>e[0];if(2===r&&e[0]===e[1])return()=>e[1];const a=t[0]===t[1];t[0]>t[r-1]&&(t=[...t].reverse(),e=[...e].reverse());const l=function(t,e,i){const n=[],s=i||H.mix||ce,o=t.length-1;for(let i=0;i<o;i++){let o=s(t[i],t[i+1]);if(e){const t=Array.isArray(e)?e[i]||J:e;o=tt(t,o)}n.push(o)}return n}(e,s,o),h=l.length,u=i=>{if(a&&i<t[0])return e[0];let n=0;if(h>1)for(;n<t.length-2&&!(i<t[n+1]);n++);const s=et(t[n],t[n+1],i);return l[n](s)};return n?e=>u(i(t[0],t[r-1],e)):u}function Ne(t){const e=[0];return function(t,e){const i=t[t.length-1];for(let n=1;n<=e;n++){const s=et(0,e,n);t.push(te(i,1,s))}}(e,t.length-1),e}function Ke({duration:t=300,keyframes:e,times:i,ease:n="easeInOut"}){const s=(t=>Array.isArray(t)&&"number"!=typeof t[0])(n)?n.map(wt):wt(n),o={done:!1,value:e[0]},r=function(t,e){return t.map(t=>t*e)}(i&&i.length===e.length?i:Ne(e),t),a=Ue(r,e,{ease:Array.isArray(s)?s:(l=e,h=s,l.map(()=>h||xt).splice(0,l.length-1))});var l,h;return{calculatedDuration:t,next:e=>(o.value=a(e),o.done=e>=t,o)}}Ie.applyToOptions=t=>{const e=function(t,e=100,i){const n=i({...t,keyframes:[0,e]}),s=Math.min(fe(n),me);return{type:"keyframes",ease:t=>n.next(s*t).value/e,duration:st(s)}}(t,100,Ie);return t.ease=e.ease,t.duration=nt(e.duration),t.type="keyframes",t};const We=t=>null!==t;function $e(t,{repeat:e,repeatType:i="loop"},n,s=1){const o=t.filter(We),r=s<0||e&&"loop"!==i&&e%2==1?0:o.length-1;return r&&void 0!==n?n:o[r]}const ze={decay:Oe,inertia:Oe,tween:Ke,keyframes:Ke,spring:Ie};function Ye(t){"string"==typeof t.type&&(t.type=ze[t.type])}class Xe{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,e){return this.finished.then(t,e)}}const He=t=>t/100;class Ge extends Xe{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:t}=this.options;t&&t.updatedAt!==Rt.now()&&this.tick(Rt.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),!1===t.autoplay&&this.pause()}initAnimation(){const{options:t}=this;Ye(t);const{type:e=Ke,repeat:i=0,repeatDelay:n=0,repeatType:s,velocity:o=0}=t;let{keyframes:r}=t;const a=e||Ke;a!==Ke&&"number"!=typeof r[0]&&(this.mixKeyframes=tt(He,ce(r[0],r[1])),r=[0,100]);const l=a({...t,keyframes:r});"mirror"===s&&(this.mirroredGenerator=a({...t,keyframes:[...r].reverse(),velocity:-o})),null===l.calculatedDuration&&(l.calculatedDuration=fe(l));const{calculatedDuration:h}=l;this.calculatedDuration=h,this.resolvedDuration=h+n,this.totalDuration=this.resolvedDuration*(i+1)-n,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:s,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:l}=this;if(null===this.startTime)return n.next(0);const{delay:h=0,keyframes:u,repeat:c,repeatType:d,repeatDelay:p,type:m,onUpdate:f,finalKeyframe:y}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-s/this.speed,this.startTime)),e?this.currentTime=t:this.updateTime(t);const g=this.currentTime-h*(this.playbackSpeed>=0?1:-1),v=this.playbackSpeed>=0?g<0:g>s;this.currentTime=Math.max(g,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=s);let x=this.currentTime,T=n;if(c){const t=Math.min(this.currentTime,s)/a;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"===d?(n=1-n,p&&(n-=p/a)):"mirror"===d&&(T=r)),x=i(0,1,n)*a}const P=v?{done:!1,value:u[0]}:T.next(x);o&&(P.value=o(P.value));let{done:w}=P;v||null===l||(w=this.playbackSpeed>=0?this.currentTime>=s:this.currentTime<=0);const S=null===this.holdTime&&("finished"===this.state||"running"===this.state&&w);return S&&m!==Oe&&(P.value=$e(u,this.options,y,this.speed)),f&&f(P.value),S&&this.finish(),P}then(t,e){return this.finished.then(t,e)}get duration(){return st(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+st(t)}get time(){return st(this.currentTime)}set time(t){t=nt(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?.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(Rt.now());const e=this.playbackSpeed!==t;this.playbackSpeed=t,e&&(this.time=st(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=de,startTime:e}=this.options;this.driver||(this.driver=t(t=>this.tick(t))),this.options.onPlay?.();const i=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=i):null!==this.holdTime?this.startTime=i-this.holdTime:this.startTime||(this.startTime=e??i),"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(Rt.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 qe=t=>180*t/Math.PI,_e=t=>{const e=qe(Math.atan2(t[1],t[0]));return Je(e)},Ze={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:_e,rotateZ:_e,skewX:t=>qe(Math.atan(t[1])),skewY:t=>qe(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Je=t=>((t%=360)<0&&(t+=360),t),Qe=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),ti=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),ei={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Qe,scaleY:ti,scale:t=>(Qe(t)+ti(t))/2,rotateX:t=>Je(qe(Math.atan2(t[6],t[5]))),rotateY:t=>Je(qe(Math.atan2(-t[2],t[0]))),rotateZ:_e,rotate:_e,skewX:t=>qe(Math.atan(t[4])),skewY:t=>qe(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function ii(t){return t.includes("scale")?1:0}function ni(t,e){if(!t||"none"===t)return ii(e);const i=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,s;if(i)n=ei,s=i;else{const e=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=Ze,s=e}if(!s)return ii(e);const o=n[e],r=s[1].split(",").map(si);return"function"==typeof o?o(r):r[o]}function si(t){return parseFloat(t.trim())}const oi=e=>e===t||e===o,ri=new Set(["x","y","z"]),ai=r.filter(t=>!ri.has(t));const li={width:({x:t},{paddingLeft:e="0",paddingRight:i="0"})=>t.max-t.min-parseFloat(e)-parseFloat(i),height:({y:t},{paddingTop:e="0",paddingBottom:i="0"})=>t.max-t.min-parseFloat(e)-parseFloat(i),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})=>ni(e,"x"),y:(t,{transform:e})=>ni(e,"y")};li.translateX=li.x,li.translateY=li.y;const hi=new Set;let ui=!1,ci=!1,di=!1;function pi(){if(ci){const t=Array.from(hi).filter(t=>t.needsMeasurement),e=new Set(t.map(t=>t.element)),i=new Map;e.forEach(t=>{const e=function(t){const e=[];return ai.forEach(i=>{const n=t.getValue(i);void 0!==n&&(e.push([i,n.get()]),n.set(i.startsWith("scale")?1:0))}),e}(t);e.length&&(i.set(t,e),t.render())}),t.forEach(t=>t.measureInitialState()),e.forEach(t=>{t.render();const e=i.get(t);e&&e.forEach(([e,i])=>{t.getValue(e)?.set(i)})}),t.forEach(t=>t.measureEndState()),t.forEach(t=>{void 0!==t.suspendedScrollY&&window.scrollTo(0,t.suspendedScrollY)})}ci=!1,ui=!1,hi.forEach(t=>t.complete(di)),hi.clear()}function mi(){hi.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ci=!0)})}class fi{constructor(t,e,i,n,s,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=e,this.name=i,this.motionValue=n,this.element=s,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(hi.add(this),ui||(ui=!0,Et.read(mi),Et.resolveKeyframes(pi))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:e,element:i,motionValue:n}=this;if(null===t[0]){const s=n?.get(),o=t[t.length-1];if(void 0!==s)t[0]=s;else if(i&&e){const n=i.readValue(e,o);null!=n&&(t[0]=n)}void 0===t[0]&&(t[0]=o),n&&void 0===s&&n.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),hi.delete(this)}cancel(){"scheduled"===this.state&&(hi.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}const yi=Z(()=>void 0!==window.ScrollTimeline),gi={};function vi(t,e){const i=Z(t);return()=>gi[e]??i()}const xi=vi(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0},"linearEasing"),Ti=([t,e,i,n])=>`cubic-bezier(${t}, ${e}, ${i}, ${n})`,Pi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Ti([0,.65,.55,1]),circOut:Ti([.55,0,1,.45]),backIn:Ti([.31,.01,.66,-.59]),backOut:Ti([.33,1.53,.69,.99])};function wi(t,e){return t?"function"==typeof t?xi()?pe(t,e):"ease-out":Tt(t)?Ti(t):Array.isArray(t)?t.map(t=>wi(t,e)||Pi.easeOut):Pi[t]:void 0}function Si(t,e,i,{delay:n=0,duration:s=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:l}={},h=void 0){const u={[e]:i};l&&(u.offset=l);const c=wi(a,s);Array.isArray(c)&&(u.easing=c);const d={delay:n,duration:s,easing:Array.isArray(c)?"linear":c,fill:"both",iterations:o+1,direction:"reverse"===r?"alternate":"normal"};h&&(d.pseudoElement=h);return t.animate(u,d)}function Ai(t){return"function"==typeof t&&"applyToOptions"in t}class bi extends Xe{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:e,name:i,keyframes:n,pseudoElement:s,allowFlatten:o=!1,finalKeyframe:r,onComplete:a}=t;this.isPseudoElement=Boolean(s),this.allowFlatten=o,this.options=t,t.type;const l=function({type:t,...e}){return Ai(t)&&xi()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}(t);this.animation=Si(e,i,n,l,s),!1===l.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){const t=$e(n,this.options,r,this.speed);this.updateMotionValue?this.updateMotionValue(t):function(t,e,i){(t=>t.startsWith("--"))(e)?t.style.setProperty(e,i):t.style[e]=i}(e,i,t),this.animation.cancel()}a?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch(t){}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;"idle"!==t&&"finished"!==t&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return st(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+st(t)}get time(){return st(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=nt(t)}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 Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:e}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&yi()?(this.animation.timeline=t,J):e(this)}}const Ei={anticipate:pt,backInOut:dt,circInOut:yt};function Vi(t){"string"==typeof t.ease&&t.ease in Ei&&(t.ease=Ei[t.ease])}class Mi extends bi{constructor(t){Vi(t),Ye(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:e,onUpdate:i,onComplete:n,element:s,...o}=this.options;if(!e)return;if(void 0!==t)return void e.set(t);const r=new Ge({...o,autoplay:!1}),a=nt(this.finishedTime??this.time);e.setWithVelocity(r.sample(a-10).value,r.sample(a).value,10),r.stop()}}const Di=(t,e)=>"zIndex"!==e&&(!("number"!=typeof t&&!Array.isArray(t))||!("string"!=typeof t||!Zt.test(t)&&"0"!==t||t.startsWith("url(")));function Ci(t){t.duration=0,t.type="keyframes"}const ki=new Set(["opacity","clipPath","filter","transform"]),Ri=Z(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));class Li extends Xe{constructor({autoplay:t=!0,delay:e=0,type:i="keyframes",repeat:n=0,repeatDelay:s=0,repeatType:o="loop",keyframes:r,name:a,motionValue:l,element:h,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Rt.now();const c={autoplay:t,delay:e,type:i,repeat:n,repeatDelay:s,repeatType:o,name:a,motionValue:l,element:h,...u},d=h?.KeyframeResolver||fi;this.keyframeResolver=new d(r,(t,e,i)=>this.onKeyframesResolved(t,e,c,!i),a,l,h),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,e,i,n){this.keyframeResolver=void 0;const{name:s,type:o,velocity:r,delay:a,isHandoff:l,onUpdate:h}=i;this.resolvedAt=Rt.now(),function(t,e,i,n){const s=t[0];if(null===s)return!1;if("display"===e||"visibility"===e)return!0;const o=t[t.length-1],r=Di(s,e),a=Di(o,e);return!(!r||!a)&&(function(t){const e=t[0];if(1===t.length)return!0;for(let i=0;i<t.length;i++)if(t[i]!==e)return!0}(t)||("spring"===i||Ai(i))&&n)}(t,s,o,r)||(!H.instantAnimations&&a||h?.($e(t,i,e)),t[0]=t[t.length-1],Ci(i),i.repeat=0);const u={startTime:n?this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt:void 0,finalKeyframe:e,...i,keyframes:t},c=!l&&function(t){const{motionValue:e,name:i,repeatDelay:n,repeatType:s,damping:o,type:r}=t,a=e?.owner?.current;if(!(a instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:h}=e.owner.getProps();return Ri()&&i&&ki.has(i)&&("transform"!==i||!h)&&!l&&!n&&"mirror"!==s&&0!==o&&"inertia"!==r}(u)?new Mi({...u,element:u.motionValue.owner.current}):new Ge(u);c.finished.then(()=>this.notifyFinished()).catch(J),this.pendingTimeline&&(this.stopTimeline=c.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=c}get finished(){return this._animation?this.animation.finished:this._finished}then(t,e){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),di=!0,mi(),pi(),di=!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&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const ji=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Bi(t,e,i=1){const[n,o]=function(t){const e=ji.exec(t);if(!e)return[,];const[,i,n,s]=e;return[`--${i??n}`,s]}(t);if(!n)return;const r=window.getComputedStyle(e).getPropertyValue(n);if(r){const t=r.trim();return G(t)?parseFloat(t):t}return s(o)?Bi(o,e,i+1):o}function Fi(t,e){return t?.[e]??t?.default??t}const Ii=new Set(["width","height","top","left","right","bottom",...r]),Oi=t=>e=>e.test(t),Ui=[t,o,n,a,l,h,{test:t=>"auto"===t,parse:t=>t}],Ni=t=>Ui.find(Oi(t));function Ki(t){return"number"==typeof t?0===t:null===t||("none"===t||"0"===t||_(t))}const Wi=new Set(["brightness","contrast","saturate","opacity"]);function $i(t){const[e,i]=t.slice(0,-1).split("(");if("drop-shadow"===e)return t;const[n]=i.match(jt)||[];if(!n)return t;const s=i.replace(n,"");let o=Wi.has(e)?1:0;return n!==i&&(o*=100),e+"("+o+s+")"}const zi=/\b([a-z-]*)\(.*?\)/gu,Yi={...Zt,getAnimatableNone:t=>{const e=t.match(zi);return e?e.map($i).join(" "):t}},Xi={...u,color:Wt,backgroundColor:Wt,outlineColor:Wt,fill:Wt,stroke:Wt,borderColor:Wt,borderTopColor:Wt,borderRightColor:Wt,borderBottomColor:Wt,borderLeftColor:Wt,filter:Yi,WebkitFilter:Yi},Hi=t=>Xi[t];function Gi(t,e){let i=Hi(t);return i!==Yi&&(i=Zt),i.getAnimatableNone?i.getAnimatableNone(e):void 0}const qi=new Set(["auto","none","0"]);class _i extends fi{constructor(t,e,i,n,s){super(t,e,i,n,s,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:e,name:i}=this;if(!e||!e.current)return;super.readKeyframes();for(let i=0;i<t.length;i++){let n=t[i];if("string"==typeof n&&(n=n.trim(),s(n))){const s=Bi(n,e.current);void 0!==s&&(t[i]=s),i===t.length-1&&(this.finalKeyframe=n)}}if(this.resolveNoneKeyframes(),!Ii.has(i)||2!==t.length)return;const[n,o]=t,r=Ni(n),a=Ni(o);if(r!==a)if(oi(r)&&oi(a))for(let e=0;e<t.length;e++){const i=t[e];"string"==typeof i&&(t[e]=parseFloat(i))}else li[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:e}=this,i=[];for(let e=0;e<t.length;e++)(null===t[e]||Ki(t[e]))&&i.push(e);i.length&&function(t,e,i){let n,s=0;for(;s<t.length&&!n;){const e=t[s];"string"==typeof e&&!qi.has(e)&&Ht(e).values.length&&(n=t[s]),s++}if(n&&i)for(const s of e)t[s]=Gi(i,n)}(t,i,e)}measureInitialState(){const{element:t,unresolvedKeyframes:e,name:i}=this;if(!t||!t.current)return;"height"===i&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=li[i](t.measureViewportBox(),window.getComputedStyle(t.current)),e[0]=this.measuredOrigin;const n=e[e.length-1];void 0!==n&&t.getValue(i,n).jump(n,!1)}measureEndState(){const{element:t,name:e,unresolvedKeyframes:i}=this;if(!t||!t.current)return;const n=t.getValue(e);n&&n.jump(this.measuredOrigin,!1);const s=i.length-1,o=i[s];i[s]=li[e](t.measureViewportBox(),window.getComputedStyle(t.current)),null!==o&&void 0===this.finalKeyframe&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([e,i])=>{t.getValue(e).set(i)}),this.resolveNoneKeyframes()}}class Zi{constructor(t,e={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=t=>{const e=Rt.now();if(this.updatedAt!==e&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(t),this.current!==this.prev&&(this.events.change?.notify(this.current),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=Rt.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 it);const i=this.events[t].add(e);return"change"===t?()=>{i(),Et.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){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,i){this.set(e),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-i}jump(t,e=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,e&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Rt.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const e=Math.min(this.updatedAt-this.prevUpdatedAt,30);return ot(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.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ji(t,e){return new Zi(t,e)}const{schedule:Qi,cancel:tn}=bt(queueMicrotask,!1),en={x:!1,y:!1};function nn(){return en.x||en.y}function sn(t,e){const i=function(t){if(t instanceof EventTarget)return[t];if("string"==typeof t){const e=document.querySelectorAll(t);return e?Array.from(e):[]}return Array.from(t)}(t),n=new AbortController;return[i,{passive:!0,...e,signal:n.signal},()=>n.abort()]}function on(t){return!("touch"===t.pointerType||nn())}const rn=(t,e)=>!!e&&(t===e||rn(t,e.parentElement)),an=t=>"mouse"===t.pointerType?"number"!=typeof t.button||t.button<=0:!1!==t.isPrimary,ln=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const hn=new WeakSet;function un(t){return e=>{"Enter"===e.key&&t(e)}}function cn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}function dn(t){return an(t)&&!nn()}function pn(t,e,i={}){const[n,s,o]=sn(t,i),r=t=>{const n=t.currentTarget;if(!dn(t))return;hn.add(n);const o=e(n,t),r=(t,e)=>{window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",l),hn.has(n)&&hn.delete(n),dn(t)&&"function"==typeof o&&o(t,{success:e})},a=t=>{r(t,n===window||n===document||i.useGlobalTarget||rn(n,t.target))},l=t=>{r(t,!1)};window.addEventListener("pointerup",a,s),window.addEventListener("pointercancel",l,s)};return n.forEach(t=>{var e;(i.useGlobalTarget?window:t).addEventListener("pointerdown",r,s),q(e=t)&&"offsetHeight"in e&&(t.addEventListener("focus",t=>((t,e)=>{const i=t.currentTarget;if(!i)return;const n=un(()=>{if(hn.has(i))return;cn(i,"down");const t=un(()=>{cn(i,"up")});i.addEventListener("keyup",t,e),i.addEventListener("blur",()=>cn(i,"cancel"),e)});i.addEventListener("keydown",n,e),i.addEventListener("blur",()=>i.removeEventListener("keydown",n),e)})(t,s)),function(t){return ln.has(t.tagName)||-1!==t.tabIndex}(t)||t.hasAttribute("tabindex")||(t.tabIndex=0))}),o}function mn(t){return q(t)&&"ownerSVGElement"in t}const fn=[...Ui,Wt,Zt];class yn{constructor(t){this.isMounted=!1,this.node=t}update(){}}const gn=t=>null!==t;const vn={type:"spring",stiffness:500,damping:25,restSpeed:10},xn={type:"keyframes",duration:.8},Tn={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Pn=(t,{keyframes:e})=>e.length>2?xn:c.has(t)?t.startsWith("scale")?{type:"spring",stiffness:550,damping:0===e[1]?2*Math.sqrt(550):30,restSpeed:10}:vn:Tn;const wn=(t,e,i,n={},s,o)=>r=>{const a=Fi(n,t)||{},l=a.delay||n.delay||0;let{elapsed:h=0}=n;h-=nt(l);const u={keyframes:Array.isArray(i)?i:[null,i],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-h,onUpdate:t=>{e.set(t),a.onUpdate&&a.onUpdate(t)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:s};(function({when:t,delay:e,delayChildren:i,staggerChildren:n,staggerDirection:s,repeat:o,repeatType:r,repeatDelay:a,from:l,elapsed:h,...u}){return!!Object.keys(u).length})(a)||Object.assign(u,Pn(t,u)),u.duration&&(u.duration=nt(u.duration)),u.repeatDelay&&(u.repeatDelay=nt(u.repeatDelay)),void 0!==u.from&&(u.keyframes[0]=u.from);let c=!1;if((!1===u.type||0===u.duration&&!u.repeatDelay)&&(Ci(u),0===u.delay&&(c=!0)),(H.instantAnimations||H.skipAnimations)&&(c=!0,Ci(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,c&&!o&&void 0!==e.get()){const t=function(t,{repeat:e,repeatType:i="loop"},n){const s=t.filter(gn),o=e&&"loop"!==i&&e%2==1?0:s.length-1;return o&&void 0!==n?n:s[o]}(u.keyframes,a);if(void 0!==t)return void Et.update(()=>{u.onUpdate(t),u.onComplete()})}return a.isSync?new Ge(u):new Li(u)};function Sn(t,e,i,n={passive:!0}){return t.addEventListener(e,i,n),()=>t.removeEventListener(e,i)}function An(t){return{point:{x:t.pageX,y:t.pageY}}}function bn(t,e,i,n){return Sn(t,e,(t=>e=>an(e)&&t(e,An(e)))(i),n)}function En({top:t,left:e,right:i,bottom:n}){return{x:{min:e,max:i},y:{min:t,max:n}}}function Vn(t){return t.max-t.min}function Mn(t,e,i,n=.5){t.origin=n,t.originPoint=te(e.min,e.max,t.origin),t.scale=Vn(i)/Vn(e),t.translate=te(i.min,i.max,t.origin)-t.originPoint,(t.scale>=.9999&&t.scale<=1.0001||isNaN(t.scale))&&(t.scale=1),(t.translate>=-.01&&t.translate<=.01||isNaN(t.translate))&&(t.translate=0)}function Dn(t,e,i,n){Mn(t.x,e.x,i.x,n?n.originX:void 0),Mn(t.y,e.y,i.y,n?n.originY:void 0)}function Cn(t,e,i){t.min=i.min+e.min,t.max=t.min+Vn(e)}function kn(t,e,i){t.min=e.min-i.min,t.max=t.min+Vn(e)}function Rn(t,e,i){kn(t.x,e.x,i.x),kn(t.y,e.y,i.y)}const Ln=()=>({x:{min:0,max:0},y:{min:0,max:0}});function jn(t){return[t("x"),t("y")]}function Bn(t){return void 0===t||1===t}function Fn({scale:t,scaleX:e,scaleY:i}){return!Bn(t)||!Bn(e)||!Bn(i)}function In(t){return Fn(t)||On(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function On(t){return Un(t.x)||Un(t.y)}function Un(t){return t&&"0%"!==t}function Nn(t,e,i){return i+e*(t-i)}function Kn(t,e,i,n,s){return void 0!==s&&(t=Nn(t,s,n)),Nn(t,i,n)+e}function Wn(t,e=0,i=1,n,s){t.min=Kn(t.min,e,i,n,s),t.max=Kn(t.max,e,i,n,s)}function $n(t,{x:e,y:i}){Wn(t.x,e.translate,e.scale,e.originPoint),Wn(t.y,i.translate,i.scale,i.originPoint)}const zn=.999999999999,Yn=1.0000000000001;function Xn(t,e){t.min=t.min+e,t.max=t.max+e}function Hn(t,e,i,n,s=.5){Wn(t,e,i,te(t.min,t.max,s),n)}function Gn(t,e){Hn(t.x,e.x,e.scaleX,e.scale,e.originX),Hn(t.y,e.y,e.scaleY,e.scale,e.originY)}function qn(t,e){return En(function(t,e){if(!e)return t;const i=e({x:t.left,y:t.top}),n=e({x:t.right,y:t.bottom});return{top:i.y,left:i.x,bottom:n.y,right:n.x}}(t.getBoundingClientRect(),e))}const _n=({current:t})=>t?t.ownerDocument.defaultView:null;function Zn(t,e){const i=t.getValue("willChange");if(n=i,Boolean(d(n)&&n.add))return i.add(e);if(!i&&H.WillChange){const i=new H.WillChange("auto");t.addValue("willChange",i),i.add(e)}var n}const Jn=(t,e)=>Math.abs(t-e);class Qn{constructor(t,e,{transformPagePoint:i,contextWindow:n=window,dragSnapToOrigin:s=!1,distanceThreshold:o=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!this.lastMoveEvent||!this.lastMoveEventInfo)return;const t=is(this.lastMoveEventInfo,this.history),e=null!==this.startEvent,i=function(t,e){const i=Jn(t.x,e.x),n=Jn(t.y,e.y);return Math.sqrt(i**2+n**2)}(t.offset,{x:0,y:0})>=this.distanceThreshold;if(!e&&!i)return;const{point:n}=t,{timestamp:s}=Mt;this.history.push({...n,timestamp:s});const{onStart:o,onMove:r}=this.handlers;e||(o&&o(this.lastMoveEvent,t),this.startEvent=this.lastMoveEvent),r&&r(this.lastMoveEvent,t)},this.handlePointerMove=(t,e)=>{this.lastMoveEvent=t,this.lastMoveEventInfo=ts(e,this.transformPagePoint),Et.update(this.updatePoint,!0)},this.handlePointerUp=(t,e)=>{this.end();const{onEnd:i,onSessionEnd:n,resumeAnimation:s}=this.handlers;if(this.dragSnapToOrigin&&s&&s(),!this.lastMoveEvent||!this.lastMoveEventInfo)return;const o=is("pointercancel"===t.type?this.lastMoveEventInfo:ts(e,this.transformPagePoint),this.history);this.startEvent&&i&&i(t,o),n&&n(t,o)},!an(t))return;this.dragSnapToOrigin=s,this.handlers=e,this.transformPagePoint=i,this.distanceThreshold=o,this.contextWindow=n||window;const r=ts(An(t),this.transformPagePoint),{point:a}=r,{timestamp:l}=Mt;this.history=[{...a,timestamp:l}];const{onSessionStart:h}=e;h&&h(t,is(r,this.history)),this.removeListeners=tt(bn(this.contextWindow,"pointermove",this.handlePointerMove),bn(this.contextWindow,"pointerup",this.handlePointerUp),bn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Vt(this.updatePoint)}}function ts(t,e){return e?{point:e(t.point)}:t}function es(t,e){return{x:t.x-e.x,y:t.y-e.y}}function is({point:t},e){return{point:t,delta:es(t,ss(e)),offset:es(t,ns(e)),velocity:os(e,.1)}}function ns(t){return t[0]}function ss(t){return t[t.length-1]}function os(t,e){if(t.length<2)return{x:0,y:0};let i=t.length-1,n=null;const s=ss(t);for(;i>=0&&(n=t[i],!(s.timestamp-n.timestamp>nt(e)));)i--;if(!n)return{x:0,y:0};const o=st(s.timestamp-n.timestamp);if(0===o)return{x:0,y:0};const r={x:(s.x-n.x)/o,y:(s.y-n.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function rs(t,e,i){return{min:void 0!==e?t.min+e:void 0,max:void 0!==i?t.max+i-(t.max-t.min):void 0}}function as(t,e){let i=e.min-t.min,n=e.max-t.max;return e.max-e.min<t.max-t.min&&([i,n]=[n,i]),{min:i,max:n}}const ls=.35;function hs(t,e,i){return{min:us(t,e),max:us(t,i)}}function us(t,e){return"number"==typeof t?t:t[e]||0}const cs=new WeakMap;class ds{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic={x:{min:0,max:0},y:{min:0,max:0}},this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:e=!1,distanceThreshold:i}={}){const{presenceContext:s}=this.visualElement;if(s&&!1===s.isPresent)return;const{dragSnapToOrigin:o}=this.getProps();this.panSession=new Qn(t,{onSessionStart:t=>{const{dragSnapToOrigin:i}=this.getProps();i?this.pauseAnimation():this.stopAnimation(),e&&this.snapToCursor(An(t).point)},onStart:(t,e)=>{const{drag:i,dragPropagation:s,onDragStart:o}=this.getProps();if(i&&!s&&(this.openDragLock&&this.openDragLock(),this.openDragLock="x"===(r=i)||"y"===r?en[r]?null:(en[r]=!0,()=>{en[r]=!1}):en.x||en.y?null:(en.x=en.y=!0,()=>{en.x=en.y=!1}),!this.openDragLock))return;var r;this.latestPointerEvent=t,this.latestPanInfo=e,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),jn(t=>{let e=this.getAxisMotionValue(t).get()||0;if(n.test(e)){const{projection:i}=this.visualElement;if(i&&i.layout){const n=i.layout.layoutBox[t];if(n){e=Vn(n)*(parseFloat(e)/100)}}}this.originPoint[t]=e}),o&&Et.postRender(()=>o(t,e)),Zn(this.visualElement,"transform");const{animationState:a}=this.visualElement;a&&a.setActive("whileDrag",!0)},onMove:(t,e)=>{this.latestPointerEvent=t,this.latestPanInfo=e;const{dragPropagation:i,dragDirectionLock:n,onDirectionLock:s,onDrag:o}=this.getProps();if(!i&&!this.openDragLock)return;const{offset:r}=e;if(n&&null===this.currentDirection)return this.currentDirection=function(t,e=10){let i=null;Math.abs(t.y)>e?i="y":Math.abs(t.x)>e&&(i="x");return i}(r),void(null!==this.currentDirection&&s&&s(this.currentDirection));this.updateAxis("x",e.point,r),this.updateAxis("y",e.point,r),this.visualElement.render(),o&&o(t,e)},onSessionEnd:(t,e)=>{this.latestPointerEvent=t,this.latestPanInfo=e,this.stop(t,e),this.latestPointerEvent=null,this.latestPanInfo=null},resumeAnimation:()=>jn(t=>"paused"===this.getAnimationState(t)&&this.getAxisMotionValue(t).animation?.play())},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:o,distanceThreshold:i,contextWindow:_n(this.visualElement)})}stop(t,e){const i=t||this.latestPointerEvent,n=e||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!n||!i)return;const{velocity:o}=n;this.startAnimation(o);const{onDragEnd:r}=this.getProps();r&&Et.postRender(()=>r(i,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:e}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),e&&e.setActive("whileDrag",!1)}updateAxis(t,e,i){const{drag:n}=this.getProps();if(!i||!ps(t,n,this.currentDirection))return;const s=this.getAxisMotionValue(t);let o=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(o=function(t,{min:e,max:i},n){return void 0!==e&&t<e?t=n?te(e,t,n.min):Math.max(t,e):void 0!==i&&t>i&&(t=n?te(i,t,n.max):Math.min(t,i)),t}(o,this.constraints[t],this.elastic[t])),s.set(o)}resolveConstraints(){const{dragConstraints:t,dragElastic:e}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,n=this.constraints;t&&p(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):this.constraints=!(!t||!i)&&function(t,{top:e,left:i,bottom:n,right:s}){return{x:rs(t.x,i,s),y:rs(t.y,e,n)}}(i.layoutBox,t),this.elastic=function(t=ls){return!1===t?t=0:!0===t&&(t=ls),{x:hs(t,"left","right"),y:hs(t,"top","bottom")}}(e),n!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&jn(t=>{!1!==this.constraints&&this.getAxisMotionValue(t)&&(this.constraints[t]=function(t,e){const i={};return void 0!==e.min&&(i.min=e.min-t.min),void 0!==e.max&&(i.max=e.max-t.min),i}(i.layoutBox[t],this.constraints[t]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:e}=this.getProps();if(!t||!p(t))return!1;const i=t.current,{projection:n}=this.visualElement;if(!n||!n.layout)return!1;const s=function(t,e,i){const n=qn(t,i),{scroll:s}=e;return s&&(Xn(n.x,s.offset.x),Xn(n.y,s.offset.y)),n}(i,n.root,this.visualElement.getTransformPagePoint());let o=function(t,e){return{x:as(t.x,e.x),y:as(t.y,e.y)}}(n.layout.layoutBox,s);if(e){const t=e(function({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}(o));this.hasMutatedConstraints=!!t,t&&(o=En(t))}return o}startAnimation(t){const{drag:e,dragMomentum:i,dragElastic:n,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:r}=this.getProps(),a=this.constraints||{},l=jn(r=>{if(!ps(r,e,this.currentDirection))return;let l=a&&a[r]||{};o&&(l={min:0,max:0});const h=n?200:1e6,u=n?40:1e7,c={type:"inertia",velocity:i?t[r]:0,bounceStiffness:h,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...s,...l};return this.startAxisValueAnimation(r,c)});return Promise.all(l).then(r)}startAxisValueAnimation(t,e){const i=this.getAxisMotionValue(t);return Zn(this.visualElement,t),i.start(wn(t,i,0,e,this.visualElement,!1))}stopAnimation(){jn(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){jn(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const e=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),n=i[e];return n||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){jn(e=>{const{drag:i}=this.getProps();if(!ps(e,i,this.currentDirection))return;const{projection:n}=this.visualElement,s=this.getAxisMotionValue(e);if(n&&n.layout){const{min:i,max:o}=n.layout.layoutBox[e];s.set(t[e]-te(i,o,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:e}=this.getProps(),{projection:n}=this.visualElement;if(!p(e)||!n||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};jn(t=>{const e=this.getAxisMotionValue(t);if(e&&!1!==this.constraints){const n=e.get();s[t]=function(t,e){let n=.5;const s=Vn(t),o=Vn(e);return o>s?n=et(e.min,e.max-s,t.min):s>o&&(n=et(t.min,t.max-o,e.min)),i(0,1,n)}({min:n,max:n},this.constraints[t])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),jn(e=>{if(!ps(e,t,null))return;const i=this.getAxisMotionValue(e),{min:n,max:o}=this.constraints[e];i.set(te(n,o,s[e]))})}addListeners(){if(!this.visualElement.current)return;cs.set(this.visualElement,this);const t=bn(this.visualElement.current,"pointerdown",t=>{const{drag:e,dragListener:i=!0}=this.getProps();e&&i&&this.start(t)}),e=()=>{const{dragConstraints:t}=this.getProps();p(t)&&t.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,n=i.addEventListener("measure",e);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Et.read(e);const s=Sn(window,"resize",()=>this.scalePositionWithinConstraints()),o=i.addEventListener("didUpdate",({delta:t,hasLayoutChanged:e})=>{this.isDragging&&e&&(jn(e=>{const i=this.getAxisMotionValue(e);i&&(this.originPoint[e]+=t[e].translate,i.set(i.get()+t[e].translate))}),this.visualElement.render())});return()=>{s(),t(),n(),o&&o()}}getProps(){const t=this.visualElement.getProps(),{drag:e=!1,dragDirectionLock:i=!1,dragPropagation:n=!1,dragConstraints:s=!1,dragElastic:o=ls,dragMomentum:r=!0}=t;return{...t,drag:e,dragDirectionLock:i,dragPropagation:n,dragConstraints:s,dragElastic:o,dragMomentum:r}}}function ps(t,