Files
Sub-Router/dist/assets/CountUp-CtdzPrSF.js
T
abingyydsandClaude Sonnet 4.6 914ddf0a26 fix: 套餐购买系统修复 - 事务安全、购买记录、前端错误处理
- 新增 PackageOrder 模型,记录每次套餐购买的详细信息
- 将套餐扣费和充值操作改为数据库事务(原子操作),防止部分失败导致数据不一致
- 使用行级锁(FOR UPDATE)确保并发安全
- 添加 ErrInsufficientQuota 哨兵错误,提升错误处理可靠性
- 购买成功后记录操作日志(RecordLog)
- 前端 Packages.jsx 增加失败时的错误提示
- 分站模型管理和设置页面小幅修正

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 16:47:29 +09:00

2 lines
27 KiB
JavaScript

import{r as F,j as te}from"./index-p6W69obe.js";function kt(t){const e=F.useRef(null);return e.current===null&&(e.current=t()),e.current}const ee=typeof window<"u",se=ee?F.useLayoutEffect:F.useEffect;function ne(t,e){t.indexOf(e)===-1&&t.push(e)}function re(t,e){const s=t.indexOf(e);s>-1&&t.splice(s,1)}const U=(t,e,s)=>s>e?e:s<t?t:s;let It=()=>{};const dt={},et=t=>t,ie=(t,e)=>s=>e(t(s)),pt=(...t)=>t.reduce(ie),Et=(t,e,s)=>{const r=e-t;return r===0?1:(s-t)/r};class oe{constructor(){this.subscriptions=[]}add(e){return ne(this.subscriptions,e),()=>re(this.subscriptions,e)}notify(e,s,r){const n=this.subscriptions.length;if(n)if(n===1)this.subscriptions[0](e,s,r);else for(let i=0;i<n;i++){const o=this.subscriptions[i];o&&o(e,s,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const L=t=>t*1e3,N=t=>t/1e3;function Pt(t,e){return e?t*(1e3/e):0}const Nt=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,ae=1e-7,ce=12;function ue(t,e,s,r,n){let i,o,a=0;do o=e+(s-e)/2,i=Nt(o,r,n)-t,i>0?s=o:e=o;while(Math.abs(i)>ae&&++a<ce);return o}function $(t,e,s,r){if(t===e&&s===r)return et;const n=i=>ue(i,0,1,t,s);return i=>i===0||i===1?i:Nt(n(i),e,r)}const Rt=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Ot=t=>e=>1-t(1-e),Ut=$(.33,1.53,.69,.99),mt=Ot(Ut),le=Rt(mt),fe=t=>t>=1?1:(t*=2)<1?.5*mt(t):.5*(2-Math.pow(2,-10*(t-1))),gt=t=>1-Math.sin(Math.acos(t)),he=Ot(gt),de=Rt(gt),pe=$(.42,0,1,1),me=$(0,0,.58,1),Kt=$(.42,0,.58,1),ge=t=>Array.isArray(t)&&typeof t[0]!="number",ye=t=>Array.isArray(t)&&typeof t[0]=="number",be={linear:et,easeIn:pe,easeInOut:Kt,easeOut:me,circIn:gt,circInOut:de,circOut:he,backIn:mt,backInOut:le,backOut:Ut,anticipate:fe},ve=t=>typeof t=="string",Mt=t=>{if(ye(t)){It(t.length===4);const[e,s,r,n]=t;return $(e,s,r,n)}else if(ve(t))return be[t];return t},J=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Te(t,e){let s=new Set,r=new Set,n=!1,i=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function u(c){o.has(c)&&(l.schedule(c),t()),c(a)}const l={schedule:(c,f=!1,d=!1)=>{const x=d&&n?s:r;return f&&o.add(c),x.add(c),c},cancel:c=>{r.delete(c),o.delete(c)},process:c=>{if(a=c,n){i=!0;return}n=!0;const f=s;s=r,r=f,s.forEach(u),s.clear(),n=!1,i&&(i=!1,l.process(c))}};return l}const xe=40;function Me(t,e){let s=!1,r=!0;const n={delta:0,timestamp:0,isProcessing:!1},i=()=>s=!0,o=J.reduce((v,g)=>(v[g]=Te(i),v),{}),{setup:a,read:u,resolveKeyframes:l,preUpdate:c,update:f,preRender:d,render:M,postRender:x}=o,m=()=>{const v=dt.useManualTiming,g=v?n.timestamp:performance.now();s=!1,v||(n.delta=r?1e3/60:Math.max(Math.min(g-n.timestamp,xe),1)),n.timestamp=g,n.isProcessing=!0,a.process(n),u.process(n),l.process(n),c.process(n),f.process(n),d.process(n),M.process(n),x.process(n),n.isProcessing=!1,s&&e&&(r=!1,t(m))},T=()=>{s=!0,r=!0,n.isProcessing||t(m)};return{schedule:J.reduce((v,g)=>{const y=o[g];return v[g]=(S,C=!1,b=!1)=>(s||T(),y.schedule(S,C,b)),v},{}),cancel:v=>{for(let g=0;g<J.length;g++)o[J[g]].cancel(v)},state:n,steps:o}}const{schedule:st,cancel:Gt,state:X,steps:Es}=Me(typeof requestAnimationFrame<"u"?requestAnimationFrame:et,!0);let H;function Ae(){H=void 0}const k={now:()=>(H===void 0&&k.set(X.isProcessing||dt.useManualTiming?X.timestamp:performance.now()),H),set:t=>{H=t,queueMicrotask(Ae)}},Lt=t=>e=>typeof e=="string"&&e.startsWith(t),Ps=Lt("--"),Se=Lt("var(--"),De=t=>Se(t)?Fe.test(t.split("/*")[0].trim()):!1,Fe=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Ns(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const yt={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},qt={...yt,transform:t=>U(0,1,t)},Rs={...yt,default:1},q=t=>Math.round(t*1e5)/1e5,Wt=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function we(t){return t==null}const Ve=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,bt=(t,e)=>s=>!!(typeof s=="string"&&Ve.test(s)&&s.startsWith(t)||e&&!we(s)&&Object.prototype.hasOwnProperty.call(s,e)),Bt=(t,e,s)=>r=>{if(typeof r!="string")return r;const[n,i,o,a]=r.match(Wt);return{[t]:parseFloat(n),[e]:parseFloat(i),[s]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Ce=t=>U(0,255,t),rt={...yt,transform:t=>Math.round(Ce(t))},O={test:bt("rgb","red"),parse:Bt("red","green","blue"),transform:({red:t,green:e,blue:s,alpha:r=1})=>"rgba("+rt.transform(t)+", "+rt.transform(e)+", "+rt.transform(s)+", "+q(qt.transform(r))+")"};function ke(t){let e="",s="",r="",n="";return t.length>5?(e=t.substring(1,3),s=t.substring(3,5),r=t.substring(5,7),n=t.substring(7,9)):(e=t.substring(1,2),s=t.substring(2,3),r=t.substring(3,4),n=t.substring(4,5),e+=e,s+=s,r+=r,n+=n),{red:parseInt(e,16),green:parseInt(s,16),blue:parseInt(r,16),alpha:n?parseInt(n,16)/255:1}}const ut={test:bt("#"),parse:ke,transform:O.transform},z=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Os=z("deg"),W=z("%"),Us=z("px"),Ks=z("vh"),Gs=z("vw"),Ls={...W,parse:t=>W.parse(t)/100,transform:t=>W.transform(t*100)},G={test:bt("hsl","hue"),parse:Bt("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:s,alpha:r=1})=>"hsla("+Math.round(t)+", "+W.transform(q(e))+", "+W.transform(q(s))+", "+q(qt.transform(r))+")"},I={test:t=>O.test(t)||ut.test(t)||G.test(t),parse:t=>O.test(t)?O.parse(t):G.test(t)?G.parse(t):ut.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?O.transform(t):G.transform(t),getAnimatableNone:t=>{const e=I.parse(t);return e.alpha=0,I.transform(e)}},Ie=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Ee(t){var e,s;return isNaN(t)&&typeof t=="string"&&(((e=t.match(Wt))==null?void 0:e.length)||0)+(((s=t.match(Ie))==null?void 0:s.length)||0)>0}const _t="number",jt="color",Pe="var",Ne="var(",At="${}",Re=/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 j(t){const e=t.toString(),s=[],r={color:[],number:[],var:[]},n=[];let i=0;const a=e.replace(Re,u=>(I.test(u)?(r.color.push(i),n.push(jt),s.push(I.parse(u))):u.startsWith(Ne)?(r.var.push(i),n.push(Pe),s.push(u)):(r.number.push(i),n.push(_t),s.push(parseFloat(u))),++i,At)).split(At);return{values:s,split:a,indexes:r,types:n}}function Oe(t){return j(t).values}function $t({split:t,types:e}){const s=t.length;return r=>{let n="";for(let i=0;i<s;i++)if(n+=t[i],r[i]!==void 0){const o=e[i];o===_t?n+=q(r[i]):o===jt?n+=I.transform(r[i]):n+=r[i]}return n}}function Ue(t){return $t(j(t))}const Ke=t=>typeof t=="number"?0:I.test(t)?I.getAnimatableNone(t):t,Ge=(t,e)=>typeof t=="number"?e!=null&&e.trim().endsWith("/")?t:0:Ke(t);function Le(t){const e=j(t);return $t(e)(e.values.map((r,n)=>Ge(r,e.split[n])))}const qe={test:Ee,parse:Oe,createTransformer:Ue,getAnimatableNone:Le};function it(t,e,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+(e-t)*6*s:s<1/2?e:s<2/3?t+(e-t)*(2/3-s)*6:t}function We({hue:t,saturation:e,lightness:s,alpha:r}){t/=360,e/=100,s/=100;let n=0,i=0,o=0;if(!e)n=i=o=s;else{const a=s<.5?s*(1+e):s+e-s*e,u=2*s-a;n=it(u,a,t+1/3),i=it(u,a,t),o=it(u,a,t-1/3)}return{red:Math.round(n*255),green:Math.round(i*255),blue:Math.round(o*255),alpha:r}}function Q(t,e){return s=>s>0?e:t}const nt=(t,e,s)=>t+(e-t)*s,ot=(t,e,s)=>{const r=t*t,n=s*(e*e-r)+r;return n<0?0:Math.sqrt(n)},Be=[ut,O,G],_e=t=>Be.find(e=>e.test(t));function St(t){const e=_e(t);if(!e)return!1;let s=e.parse(t);return e===G&&(s=We(s)),s}const Dt=(t,e)=>{const s=St(t),r=St(e);if(!s||!r)return Q(t,e);const n={...s};return i=>(n.red=ot(s.red,r.red,i),n.green=ot(s.green,r.green,i),n.blue=ot(s.blue,r.blue,i),n.alpha=nt(s.alpha,r.alpha,i),O.transform(n))},lt=new Set(["none","hidden"]);function je(t,e){return lt.has(t)?s=>s<=0?t:e:s=>s>=1?e:t}function $e(t,e){return s=>nt(t,e,s)}function vt(t){return typeof t=="number"?$e:typeof t=="string"?De(t)?Q:I.test(t)?Dt:Je:Array.isArray(t)?zt:typeof t=="object"?I.test(t)?Dt:ze:Q}function zt(t,e){const s=[...t],r=s.length,n=t.map((i,o)=>vt(i)(i,e[o]));return i=>{for(let o=0;o<r;o++)s[o]=n[o](i);return s}}function ze(t,e){const s={...t,...e},r={};for(const n in s)t[n]!==void 0&&e[n]!==void 0&&(r[n]=vt(t[n])(t[n],e[n]));return n=>{for(const i in r)s[i]=r[i](n);return s}}function Ze(t,e){const s=[],r={color:0,var:0,number:0};for(let n=0;n<e.values.length;n++){const i=e.types[n],o=t.indexes[i][r[i]],a=t.values[o]??0;s[n]=a,r[i]++}return s}const Je=(t,e)=>{const s=qe.createTransformer(e),r=j(t),n=j(e);return r.indexes.var.length===n.indexes.var.length&&r.indexes.color.length===n.indexes.color.length&&r.indexes.number.length>=n.indexes.number.length?lt.has(t)&&!n.values.length||lt.has(e)&&!r.values.length?je(t,e):pt(zt(Ze(r,n),n.values),s):Q(t,e)};function Zt(t,e,s){return typeof t=="number"&&typeof e=="number"&&typeof s=="number"?nt(t,e,s):vt(t)(t,e)}const He=t=>{const e=({timestamp:s})=>t(s);return{start:(s=!0)=>st.update(e,s),stop:()=>Gt(e),now:()=>X.isProcessing?X.timestamp:k.now()}},Xe=(t,e,s=10)=>{let r="";const n=Math.max(Math.round(e/s),2);for(let i=0;i<n;i++)r+=Math.round(t(i/(n-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},Y=2e4;function Tt(t){let e=0;const s=50;let r=t.next(e);for(;!r.done&&e<Y;)e+=s,r=t.next(e);return e>=Y?1/0:e}function Qe(t,e=100,s){const r=s({...t,keyframes:[0,e]}),n=Math.min(Tt(r),Y);return{type:"keyframes",ease:i=>r.next(n*i).value/e,duration:N(n)}}const A={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function ft(t,e){return t*Math.sqrt(1-e*e)}const Ye=12;function ts(t,e,s){let r=s;for(let n=1;n<Ye;n++)r=r-t(r)/e(r);return r}const at=.001;function es({duration:t=A.duration,bounce:e=A.bounce,velocity:s=A.velocity,mass:r=A.mass}){let n,i,o=1-e;o=U(A.minDamping,A.maxDamping,o),t=U(A.minDuration,A.maxDuration,N(t)),o<1?(n=l=>{const c=l*o,f=c*t,d=c-s,M=ft(l,o),x=Math.exp(-f);return at-d/M*x},i=l=>{const f=l*o*t,d=f*s+s,M=Math.pow(o,2)*Math.pow(l,2)*t,x=Math.exp(-f),m=ft(Math.pow(l,2),o);return(-n(l)+at>0?-1:1)*((d-M)*x)/m}):(n=l=>{const c=Math.exp(-l*t),f=(l-s)*t+1;return-at+c*f},i=l=>{const c=Math.exp(-l*t),f=(s-l)*(t*t);return c*f});const a=5/t,u=ts(n,i,a);if(t=L(t),isNaN(u))return{stiffness:A.stiffness,damping:A.damping,duration:t};{const l=Math.pow(u,2)*r;return{stiffness:l,damping:o*2*Math.sqrt(r*l),duration:t}}}const ss=["duration","bounce"],ns=["stiffness","damping","mass"];function Ft(t,e){return e.some(s=>t[s]!==void 0)}function rs(t){let e={velocity:A.velocity,stiffness:A.stiffness,damping:A.damping,mass:A.mass,isResolvedFromDuration:!1,...t};if(!Ft(t,ns)&&Ft(t,ss))if(e.velocity=0,t.visualDuration){const s=t.visualDuration,r=2*Math.PI/(s*1.2),n=r*r,i=2*U(.05,1,1-(t.bounce||0))*Math.sqrt(n);e={...e,mass:A.mass,stiffness:n,damping:i}}else{const s=es({...t,velocity:0});e={...e,...s,mass:A.mass},e.isResolvedFromDuration=!0}return e}function tt(t=A.visualDuration,e=A.bounce){const s=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:n}=s;const i=s.keyframes[0],o=s.keyframes[s.keyframes.length-1],a={done:!1,value:i},{stiffness:u,damping:l,mass:c,duration:f,velocity:d,isResolvedFromDuration:M}=rs({...s,velocity:-N(s.velocity||0)}),x=d||0,m=l/(2*Math.sqrt(u*c)),T=o-i,p=N(Math.sqrt(u/c)),w=Math.abs(T)<5;r||(r=w?A.restSpeed.granular:A.restSpeed.default),n||(n=w?A.restDelta.granular:A.restDelta.default);let v,g,y,S,C,b;if(m<1)y=ft(p,m),S=(x+m*p*T)/y,v=h=>{const D=Math.exp(-m*p*h);return o-D*(S*Math.sin(y*h)+T*Math.cos(y*h))},C=m*p*S+T*y,b=m*p*T-S*y,g=h=>Math.exp(-m*p*h)*(C*Math.sin(y*h)+b*Math.cos(y*h));else if(m===1){v=D=>o-Math.exp(-p*D)*(T+(x+p*T)*D);const h=x+p*T;g=D=>Math.exp(-p*D)*(p*h*D-x)}else{const h=p*Math.sqrt(m*m-1);v=P=>{const K=Math.exp(-m*p*P),R=Math.min(h*P,300);return o-K*((x+m*p*T)*Math.sinh(R)+h*T*Math.cosh(R))/h};const D=(x+m*p*T)/h,E=m*p*D-T*h,Z=m*p*T-D*h;g=P=>{const K=Math.exp(-m*p*P),R=Math.min(h*P,300);return K*(E*Math.sinh(R)+Z*Math.cosh(R))}}const V={calculatedDuration:M&&f||null,velocity:h=>L(g(h)),next:h=>{if(!M&&m<1){const E=Math.exp(-m*p*h),Z=Math.sin(y*h),P=Math.cos(y*h),K=o-E*(S*Z+T*P),R=L(E*(C*Z+b*P));return a.done=Math.abs(R)<=r&&Math.abs(o-K)<=n,a.value=a.done?o:K,a}const D=v(h);if(M)a.done=h>=f;else{const E=L(g(h));a.done=Math.abs(E)<=r&&Math.abs(o-D)<=n}return a.value=a.done?o:D,a},toString:()=>{const h=Math.min(Tt(V),Y),D=Xe(E=>V.next(h*E).value,h,30);return h+"ms "+D},toTransition:()=>{}};return V}tt.applyToOptions=t=>{const e=Qe(t,100,tt);return t.ease=e.ease,t.duration=L(e.duration),t.type="keyframes",t};const is=5;function Jt(t,e,s){const r=Math.max(e-is,0);return Pt(s-t(r),e-r)}function ht({keyframes:t,velocity:e=0,power:s=.8,timeConstant:r=325,bounceDamping:n=10,bounceStiffness:i=500,modifyTarget:o,min:a,max:u,restDelta:l=.5,restSpeed:c}){const f=t[0],d={done:!1,value:f},M=b=>a!==void 0&&b<a||u!==void 0&&b>u,x=b=>a===void 0?u:u===void 0||Math.abs(a-b)<Math.abs(u-b)?a:u;let m=s*e;const T=f+m,p=o===void 0?T:o(T);p!==T&&(m=p-f);const w=b=>-m*Math.exp(-b/r),v=b=>p+w(b),g=b=>{const V=w(b),h=v(b);d.done=Math.abs(V)<=l,d.value=d.done?p:h};let y,S;const C=b=>{M(d.value)&&(y=b,S=tt({keyframes:[d.value,x(d.value)],velocity:Jt(v,b,d.value),damping:n,stiffness:i,restDelta:l,restSpeed:c}))};return C(0),{calculatedDuration:null,next:b=>{let V=!1;return!S&&y===void 0&&(V=!0,g(b),C(b)),y!==void 0&&b>=y?S.next(b-y):(!V&&g(b),d)}}}function os(t,e,s){const r=[],n=s||dt.mix||Zt,i=t.length-1;for(let o=0;o<i;o++){let a=n(t[o],t[o+1]);if(e){const u=Array.isArray(e)?e[o]||et:e;a=pt(u,a)}r.push(a)}return r}function Ht(t,e,{clamp:s=!0,ease:r,mixer:n}={}){const i=t.length;if(It(i===e.length),i===1)return()=>e[0];if(i===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[i-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=os(e,r,n),u=a.length,l=c=>{if(o&&c<t[0])return e[0];let f=0;if(u>1)for(;f<t.length-2&&!(c<t[f+1]);f++);const d=Et(t[f],t[f+1],c);return a[f](d)};return s?c=>l(U(t[0],t[i-1],c)):l}function as(t,e){const s=t[t.length-1];for(let r=1;r<=e;r++){const n=Et(0,e,r);t.push(nt(s,1,n))}}function cs(t){const e=[0];return as(e,t.length-1),e}function us(t,e){return t.map(s=>s*e)}function ls(t,e){return t.map(()=>e||Kt).splice(0,t.length-1)}function B({duration:t=300,keyframes:e,times:s,ease:r="easeInOut"}){const n=ge(r)?r.map(Mt):Mt(r),i={done:!1,value:e[0]},o=us(s&&s.length===e.length?s:cs(e),t),a=Ht(o,e,{ease:Array.isArray(n)?n:ls(e,n)});return{calculatedDuration:t,next:u=>(i.value=a(u),i.done=u>=t,i)}}const fs=t=>t!==null;function hs(t,{repeat:e,repeatType:s="loop"},r,n=1){const i=t.filter(fs),a=n<0||e&&s!=="loop"&&e%2===1?0:i.length-1;return!a||r===void 0?i[a]:r}const ds={decay:ht,inertia:ht,tween:B,keyframes:B,spring:tt};function ps(t){typeof t.type=="string"&&(t.type=ds[t.type])}class ms{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,s){return this.finished.then(e,s)}}const gs=t=>t/100;class ys extends ms{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var r,n;const{motionValue:s}=this.options;s&&s.updatedAt!==k.now()&&this.tick(k.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(n=(r=this.options).onStop)==null||n.call(r))},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;ps(e);const{type:s=B,repeat:r=0,repeatDelay:n=0,repeatType:i,velocity:o=0}=e;let{keyframes:a}=e;const u=s||B;u!==B&&typeof a[0]!="number"&&(this.mixKeyframes=pt(gs,Zt(a[0],a[1])),a=[0,100]);const l=u({...e,keyframes:a});i==="mirror"&&(this.mirroredGenerator=u({...e,keyframes:[...a].reverse(),velocity:-o})),l.calculatedDuration===null&&(l.calculatedDuration=Tt(l));const{calculatedDuration:c}=l;this.calculatedDuration=c,this.resolvedDuration=c+n,this.totalDuration=this.resolvedDuration*(r+1)-n,this.generator=l}updateTime(e){const s=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=s}tick(e,s=!1){const{generator:r,totalDuration:n,mixKeyframes:i,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:u}=this;if(this.startTime===null)return r.next(0);const{delay:l=0,keyframes:c,repeat:f,repeatType:d,repeatDelay:M,type:x,onUpdate:m,finalKeyframe:T}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-n/this.speed,this.startTime)),s?this.currentTime=e:this.updateTime(e);const p=this.currentTime-l*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?p<0:p>n;this.currentTime=Math.max(p,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=n);let v=this.currentTime,g=r;if(f){const b=Math.min(this.currentTime,n)/a;let V=Math.floor(b),h=b%1;!h&&b>=1&&(h=1),h===1&&V--,V=Math.min(V,f+1),!!(V%2)&&(d==="reverse"?(h=1-h,M&&(h-=M/a)):d==="mirror"&&(g=o)),v=U(0,1,h)*a}let y;w?(this.delayState.value=c[0],y=this.delayState):y=g.next(v),i&&!w&&(y.value=i(y.value));let{done:S}=y;!w&&u!==null&&(S=this.playbackSpeed>=0?this.currentTime>=n:this.currentTime<=0);const C=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&S);return C&&x!==ht&&(y.value=hs(c,this.options,T,this.speed)),m&&m(y.value),C&&this.finish(),y}then(e,s){return this.finished.then(e,s)}get duration(){return N(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+N(e)}get time(){return N(this.currentTime)}set time(e){e=L(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=e,this.tick(e))}getGeneratorVelocity(){const e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);const s=this.generator.next(e).value;return Jt(r=>this.generator.next(r).value,e,s)}get speed(){return this.playbackSpeed}set speed(e){const s=this.playbackSpeed!==e;s&&this.driver&&this.updateTime(k.now()),this.playbackSpeed=e,s&&this.driver&&(this.time=N(this.currentTime))}play(){var n,i;if(this.isStopped)return;const{driver:e=He,startTime:s}=this.options;this.driver||(this.driver=e(o=>this.tick(o))),(i=(n=this.options).onPlay)==null||i.call(n);const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=s??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(k.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,s;this.notifyFinished(),this.teardown(),this.state="finished",(s=(e=this.options).onComplete)==null||s.call(e)}cancel(){var e,s;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(s=(e=this.options).onCancel)==null||s.call(e)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){var s;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(s=this.driver)==null||s.stop(),e.observe(this)}}const wt=30,bs=t=>!isNaN(parseFloat(t)),_={current:void 0};class vs{constructor(e,s={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{var i;const n=k.now();if(this.updatedAt!==n&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&((i=this.events.change)==null||i.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=s.owner}setCurrent(e){this.current=e,this.updatedAt=k.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=bs(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,s){this.events[e]||(this.events[e]=new oe);const r=this.events[e].add(s);return e==="change"?()=>{r(),st.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,s){this.passiveEffect=e,this.stopPassiveEffect=s}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,s,r){this.set(s),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,s=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,s&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;(e=this.events.change)==null||e.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return _.current&&_.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=k.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>wt)return 0;const s=Math.min(this.updatedAt-this.prevUpdatedAt,wt);return Pt(parseFloat(this.current)-parseFloat(this.prevFrameValue),s)}start(e){return this.stop(),new Promise(s=>{this.hasAnimated=!0,this.animation=e(s),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(){var e,s;(e=this.dependents)==null||e.clear(),(s=this.events.destroy)==null||s.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ts(t,e){return new vs(t,e)}const Xt=t=>!!(t&&t.getVelocity);function xs(t,e,s){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){const n=document.querySelectorAll(t);return n?Array.from(n):[]}return Array.from(t).filter(r=>r!=null)}function Ms(...t){const e=!Array.isArray(t[0]),s=e?0:-1,r=t[0+s],n=t[1+s],i=t[2+s],o=t[3+s],a=Ht(n,i,o);return e?a(r):a}function As(t,e,s={}){const r=t.get();let n=null,i=r,o;const a=typeof r=="string"?r.replace(/[\d.-]/g,""):void 0,u=()=>{n&&(n.stop(),n=null),t.animation=void 0},l=()=>{const f=Vt(t.get()),d=Vt(i);if(f===d){u();return}const M=n?n.getGeneratorVelocity():t.getVelocity();u(),n=new ys({keyframes:[f,d],velocity:M,type:"spring",restDelta:.001,restSpeed:.01,...s,onUpdate:o})},c=()=>{var f;l(),t.animation=n??void 0,(f=t.events.animationStart)==null||f.notify(),n==null||n.then(()=>{var d;t.animation=void 0,(d=t.events.animationComplete)==null||d.notify()})};if(t.attach((f,d)=>{i=f,o=M=>d(ct(M,a)),st.postRender(c)},u),Xt(e)){let f=s.skipInitialAnimation===!0;const d=e.on("change",x=>{f?(f=!1,t.jump(ct(x,a),!1)):t.set(ct(x,a))}),M=t.on("destroy",d);return()=>{d(),M()}}return u}function ct(t,e){return e?t+e:t}function Vt(t){return typeof t=="number"?t:parseFloat(t)}const Qt=F.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function xt(t){const e=kt(()=>Ts(t)),{isStatic:s}=F.useContext(Qt);if(s){const[,r]=F.useState(t);F.useEffect(()=>e.on("change",r),[])}return e}function Yt(t,e){const s=xt(e()),r=()=>s.set(e());return r(),se(()=>{const n=()=>st.preRender(r,!1,!0),i=t.map(o=>o.on("change",n));return()=>{i.forEach(o=>o()),Gt(r)}}),s}function Ss(t){_.current=[],t();const e=Yt(_.current,t);return _.current=void 0,e}function Ds(t,e,s,r){if(typeof t=="function")return Ss(t);const i=typeof e=="function"?e:Ms(e,s,r),o=Array.isArray(t)?Ct(t,i):Ct([t],([u])=>i(u)),a=Array.isArray(t)?void 0:t.accelerate;return a&&!a.isTransformed&&typeof e!="function"&&Array.isArray(s)&&(r==null?void 0:r.clamp)!==!1&&(o.accelerate={...a,times:e,keyframes:s,isTransformed:!0}),o}function Ct(t,e){const s=kt(()=>[]);return Yt(t,()=>{s.length=0;const r=t.length;for(let n=0;n<r;n++)s[n]=t[n].get();return e(s)})}function Fs(t,e={}){const{isStatic:s}=F.useContext(Qt),r=()=>Xt(t)?t.get():t;if(s)return Ds(r);const n=xt(r());return F.useInsertionEffect(()=>As(n,t,e),[n,JSON.stringify(e)]),n}function ws(t,e={}){return Fs(t,{type:"spring",...e})}const Vs={some:0,all:1};function Cs(t,e,{root:s,margin:r,amount:n="some"}={}){const i=xs(t),o=new WeakMap,a=l=>{l.forEach(c=>{const f=o.get(c.target);if(c.isIntersecting!==!!f)if(c.isIntersecting){const d=e(c.target,c);typeof d=="function"?o.set(c.target,d):u.unobserve(c.target)}else typeof f=="function"&&(f(c),o.delete(c.target))})},u=new IntersectionObserver(a,{root:s,rootMargin:r,threshold:typeof n=="number"?n:Vs[n]});return i.forEach(l=>u.observe(l)),()=>u.disconnect()}function ks(t,{root:e,margin:s,amount:r,once:n=!1,initial:i=!1}={}){const[o,a]=F.useState(i);return F.useEffect(()=>{if(!t.current||n&&o)return;const u=()=>(a(!0),n?void 0:()=>a(!1)),l={root:e&&e.current||void 0,margin:s,amount:r};return Cs(t.current,u,l)},[e,t,s,n,r]),o}function qs({to:t,from:e=0,direction:s="up",delay:r=0,duration:n=2,className:i="",startWhen:o=!0,separator:a="",onStart:u,onEnd:l}){const c=F.useRef(null),f=xt(s==="down"?t:e),d=20+40*(1/n),M=100*(1/n),x=ws(f,{damping:d,stiffness:M}),m=ks(c,{once:!0,margin:"0px"}),T=v=>{const g=v.toString();if(g.includes(".")){const y=g.split(".")[1];if(parseInt(y)!==0)return y.length}return 0},p=Math.max(T(e),T(t)),w=F.useCallback(v=>{const g=p>0,y={useGrouping:!!a,minimumFractionDigits:g?p:0,maximumFractionDigits:g?p:0},S=Intl.NumberFormat("en-US",y).format(v);return a?S.replace(/,/g,a):S},[p,a]);return F.useEffect(()=>{c.current&&(c.current.textContent=w(s==="down"?t:e))},[e,t,s,w]),F.useEffect(()=>{if(m&&o){typeof u=="function"&&u();const v=setTimeout(()=>{f.set(s==="down"?e:t)},r*1e3),g=setTimeout(()=>{typeof l=="function"&&l()},r*1e3+n*1e3);return()=>{clearTimeout(v),clearTimeout(g)}}},[m,o,f,s,e,t,r,u,l,n]),F.useEffect(()=>{const v=x.on("change",g=>{c.current&&(c.current.textContent=w(g))});return()=>v()},[x,w]),te.jsx("span",{className:i,ref:c})}export{W as A,Os as B,qs as C,Gs as D,Ks as E,Wt as F,Ls as G,qt as H,Rs as I,ys as J,I as K,j as L,Qt as M,Ns as N,Me as O,xs as P,nt as Q,Ps as R,oe as S,Et as T,he as U,ne as V,ms as W,re as X,X as Y,Es as Z,pt as _,Ds as a,kt as b,Gt as c,se as d,It as e,st as f,Xe as g,hs as h,ye as i,et as j,de as k,le as l,N as m,yt as n,fe as o,Us as p,U as q,ps as r,L as s,k as t,xt as u,qe as v,dt as w,De as x,Ts as y,Xt as z};