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