@arcteninc/core 0.0.73 → 0.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var $a=Object.create;var gi=Object.defineProperty;var za=Object.getOwnPropertyDescriptor;var Ua=Object.getOwnPropertyNames;var _a=Object.getPrototypeOf,Wa=Object.prototype.hasOwnProperty;var Ka=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ua(e))!Wa.call(t,i)&&i!==n&&gi(t,i,{get:()=>e[i],enumerable:!(s=za(e,i))||s.enumerable});return t};var Ha=(t,e,n)=>(n=t!=null?$a(_a(t)):{},Ka(e||!t||!t.__esModule?gi(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),Q=require("lucide-react"),Nr=require("@ai-sdk/react"),bn=require("ai"),Ir=require("@radix-ui/react-slot"),Lr=require("class-variance-authority"),Ga=require("clsx"),Xa=require("tailwind-merge"),qa=require("@radix-ui/react-tooltip"),yi=require("@radix-ui/react-use-controllable-state"),Ya=require("@radix-ui/react-collapsible"),Ja=require("./server.cjs");function As(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Pt=As(m),Ce=As(qa),Ps=As(Ya);function it(...t){return Xa.twMerge(Ga.clsx(t))}const ie=Lr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),wn=Pt.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},o)=>{const r=s?Ir.Slot:"button";return h.jsx(r,{ref:o,"data-slot":"button",className:it(ie({variant:e,size:n,className:t})),...i})});wn.displayName="Button";const Za=Lr.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function Fn({className:t,variant:e,asChild:n=!1,...s}){const i=n?Ir.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:it(Za({variant:e}),t),...s})}const Qa=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,o]=Pt.useState(!0);Pt.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const c=a.scrollHeight;c>n?a.style.height=`${n}px`:a.style.height=`${c+6}px`}},[t.current,e])},Or=Pt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...o},r)=>{const a=Pt.useRef(null),[c,u]=Pt.useState("");return Qa({textAreaRef:a,triggerAutoSize:c,maxHeight:t,minHeight:e}),m.useImperativeHandle(r,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),Pt.useEffect(()=>{u(i)},[o?.defaultValue,i]),h.jsx("textarea",{...o,value:i,ref:a,className:it("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:l=>{u(l.target.value),s?.(l)}})});Or.displayName="AutosizeTextarea";function tc({delayDuration:t=0,...e}){return h.jsx(Ce.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function te({...t}){return h.jsx(tc,{children:h.jsx(Ce.Root,{"data-slot":"tooltip",...t})})}function ee({...t}){return h.jsx(Ce.Trigger,{"data-slot":"tooltip-trigger",...t})}function ne({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(Ce.Portal,{children:h.jsxs(Ce.Content,{"data-slot":"tooltip-content",sideOffset:e,className:it("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...s,children:[n,h.jsx(Ce.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function xi({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:it("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",t),...e})}const Cs=m.createContext({});function Ms(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const js=typeof window<"u",Fr=js?m.useLayoutEffect:m.useEffect,Mn=m.createContext(null);function Es(t,e){t.indexOf(e)===-1&&t.push(e)}function ks(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Lt=(t,e,n)=>n>e?e:n<t?t:n;function es(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let ke=()=>{},Ot=()=>{};process.env.NODE_ENV!=="production"&&(ke=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(es(e,n))},Ot=(t,e,n)=>{if(!t)throw new Error(es(e,n))});const Ft={},Br=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function $r(t){return typeof t=="object"&&t!==null}const zr=t=>/^0[^.\s]+$/u.test(t);function Ds(t){let e;return()=>(e===void 0&&(e=t()),e)}const wt=t=>t,ec=(t,e)=>n=>e(t(n)),Qe=(...t)=>t.reduce(ec),Ge=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Vs{constructor(){this.subscriptions=[]}add(e){return Es(this.subscriptions,e),()=>ks(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Ct=t=>t*1e3,bt=t=>t/1e3;function Ur(t,e){return e?t*(1e3/e):0}const vi=new Set;function Rs(t,e,n){t||vi.has(e)||(console.warn(es(e,n)),vi.add(e))}const _r=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,nc=1e-7,sc=12;function ic(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=_r(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>nc&&++a<sc);return r}function tn(t,e,n,s){if(t===e&&n===s)return wt;const i=o=>ic(o,0,1,t,n);return o=>o===0||o===1?o:_r(i(o),e,s)}const Wr=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Kr=t=>e=>1-t(1-e),Hr=tn(.33,1.53,.69,.99),Ns=Kr(Hr),Gr=Wr(Ns),Xr=t=>(t*=2)<1?.5*Ns(t):.5*(2-Math.pow(2,-10*(t-1))),Is=t=>1-Math.sin(Math.acos(t)),qr=Kr(Is),Yr=Wr(Is),rc=tn(.42,0,1,1),oc=tn(0,0,.58,1),Jr=tn(.42,0,.58,1),ac=t=>Array.isArray(t)&&typeof t[0]!="number",Zr=t=>Array.isArray(t)&&typeof t[0]=="number",bi={linear:wt,easeIn:rc,easeInOut:Jr,easeOut:oc,circIn:Is,circInOut:Yr,circOut:qr,backIn:Ns,backInOut:Gr,backOut:Hr,anticipate:Xr},cc=t=>typeof t=="string",wi=t=>{if(Zr(t)){Ot(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return tn(e,n,s,i)}else if(cc(t))return Ot(bi[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),bi[t];return t},un=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function lc(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(l){r.has(l)&&(u.schedule(l),t()),l(a)}const u={schedule:(l,d=!1,f=!1)=>{const x=f&&i?n:s;return d&&r.add(l),x.has(l)||x.add(l),l},cancel:l=>{s.delete(l),r.delete(l)},process:l=>{if(a=l,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(c),n.clear(),i=!1,o&&(o=!1,u.process(l))}};return u}const uc=40;function Qr(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=un.reduce((S,D)=>(S[D]=lc(o),S),{}),{setup:a,read:c,resolveKeyframes:u,preUpdate:l,update:d,preRender:f,render:g,postRender:x}=r,v=()=>{const S=Ft.useManualTiming?i.timestamp:performance.now();n=!1,Ft.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(S-i.timestamp,uc),1)),i.timestamp=S,i.isProcessing=!0,a.process(i),c.process(i),u.process(i),l.process(i),d.process(i),f.process(i),g.process(i),x.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},A=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:un.reduce((S,D)=>{const j=r[D];return S[D]=(E,O=!1,R=!1)=>(n||A(),j.schedule(E,O,R)),S},{}),cancel:S=>{for(let D=0;D<un.length;D++)r[un[D]].cancel(S)},state:i,steps:r}}const{schedule:G,cancel:_t,state:st,steps:Bn}=Qr(typeof requestAnimationFrame<"u"?requestAnimationFrame:wt,!0);let pn;function dc(){pn=void 0}const mt={now:()=>(pn===void 0&&mt.set(st.isProcessing||Ft.useManualTiming?st.timestamp:performance.now()),pn),set:t=>{pn=t,queueMicrotask(dc)}},to=t=>e=>typeof e=="string"&&e.startsWith(t),Ls=to("--"),hc=to("var(--"),Os=t=>hc(t)?fc.test(t.split("/*")[0].trim()):!1,fc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,De={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Xe={...De,transform:t=>Lt(0,1,t)},dn={...De,default:1},ze=t=>Math.round(t*1e5)/1e5,Fs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function mc(t){return t==null}const pc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Bs=(t,e)=>n=>!!(typeof n=="string"&&pc.test(n)&&n.startsWith(t)||e&&!mc(n)&&Object.prototype.hasOwnProperty.call(n,e)),eo=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(Fs);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},gc=t=>Lt(0,255,t),$n={...De,transform:t=>Math.round(gc(t))},oe={test:Bs("rgb","red"),parse:eo("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+$n.transform(t)+", "+$n.transform(e)+", "+$n.transform(n)+", "+ze(Xe.transform(s))+")"};function yc(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const ns={test:Bs("#"),parse:yc,transform:oe.transform},en=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Ut=en("deg"),Dt=en("%"),L=en("px"),xc=en("vh"),vc=en("vw"),Ti={...Dt,parse:t=>Dt.parse(t)/100,transform:t=>Dt.transform(t*100)},be={test:Bs("hsl","hue"),parse:eo("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+Dt.transform(ze(e))+", "+Dt.transform(ze(n))+", "+ze(Xe.transform(s))+")"},Z={test:t=>oe.test(t)||ns.test(t)||be.test(t),parse:t=>oe.test(t)?oe.parse(t):be.test(t)?be.parse(t):ns.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?oe.transform(t):be.transform(t),getAnimatableNone:t=>{const e=Z.parse(t);return e.alpha=0,Z.transform(e)}},bc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function wc(t){return isNaN(t)&&typeof t=="string"&&(t.match(Fs)?.length||0)+(t.match(bc)?.length||0)>0}const no="number",so="color",Tc="var",Sc="var(",Si="${}",Ac=/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 qe(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const a=e.replace(Ac,c=>(Z.test(c)?(s.color.push(o),i.push(so),n.push(Z.parse(c))):c.startsWith(Sc)?(s.var.push(o),i.push(Tc),n.push(c)):(s.number.push(o),i.push(no),n.push(parseFloat(c))),++o,Si)).split(Si);return{values:n,split:a,indexes:s,types:i}}function io(t){return qe(t).values}function ro(t){const{split:e,types:n}=qe(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===no?o+=ze(i[r]):a===so?o+=Z.transform(i[r]):o+=i[r]}return o}}const Pc=t=>typeof t=="number"?0:Z.test(t)?Z.getAnimatableNone(t):t;function Cc(t){const e=io(t);return ro(t)(e.map(Pc))}const Wt={test:wc,parse:io,createTransformer:ro,getAnimatableNone:Cc};function zn(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function Mc({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=zn(c,a,t+1/3),o=zn(c,a,t),r=zn(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function Tn(t,e){return n=>n>0?e:t}const q=(t,e,n)=>t+(e-t)*n,Un=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},jc=[ns,oe,be],Ec=t=>jc.find(e=>e.test(t));function Ai(t){const e=Ec(t);if(ke(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===be&&(n=Mc(n)),n}const Pi=(t,e)=>{const n=Ai(t),s=Ai(e);if(!n||!s)return Tn(t,e);const i={...n};return o=>(i.red=Un(n.red,s.red,o),i.green=Un(n.green,s.green,o),i.blue=Un(n.blue,s.blue,o),i.alpha=q(n.alpha,s.alpha,o),oe.transform(i))},ss=new Set(["none","hidden"]);function kc(t,e){return ss.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Dc(t,e){return n=>q(t,e,n)}function $s(t){return typeof t=="number"?Dc:typeof t=="string"?Os(t)?Tn:Z.test(t)?Pi:Nc:Array.isArray(t)?oo:typeof t=="object"?Z.test(t)?Pi:Vc:Tn}function oo(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>$s(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function Vc(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=$s(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function Rc(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],r=t.indexes[o][s[o]],a=t.values[r]??0;n[i]=a,s[o]++}return n}const Nc=(t,e)=>{const n=Wt.createTransformer(e),s=qe(t),i=qe(e);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?ss.has(t)&&!i.values.length||ss.has(e)&&!s.values.length?kc(t,e):Qe(oo(Rc(s,i),i.values),n):(ke(!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"),Tn(t,e))};function ao(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?q(t,e,n):$s(t)(t,e)}const Ic=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>G.update(e,n),stop:()=>_t(e),now:()=>st.isProcessing?st.timestamp:mt.now()}},co=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Sn=2e4;function zs(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Sn;)e+=n,s=t.next(e);return e>=Sn?1/0:e}function Lc(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(zs(s),Sn);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:bt(i)}}const Oc=5;function lo(t,e,n){const s=Math.max(e-Oc,0);return Ur(n-t(s),e-s)}const X={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},_n=.001;function Fc({duration:t=X.duration,bounce:e=X.bounce,velocity:n=X.velocity,mass:s=X.mass}){let i,o;ke(t<=Ct(X.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=Lt(X.minDamping,X.maxDamping,r),t=Lt(X.minDuration,X.maxDuration,bt(t)),r<1?(i=u=>{const l=u*r,d=l*t,f=l-n,g=is(u,r),x=Math.exp(-d);return _n-f/g*x},o=u=>{const d=u*r*t,f=d*n+n,g=Math.pow(r,2)*Math.pow(u,2)*t,x=Math.exp(-d),v=is(Math.pow(u,2),r);return(-i(u)+_n>0?-1:1)*((f-g)*x)/v}):(i=u=>{const l=Math.exp(-u*t),d=(u-n)*t+1;return-_n+l*d},o=u=>{const l=Math.exp(-u*t),d=(n-u)*(t*t);return l*d});const a=5/t,c=$c(i,o,a);if(t=Ct(t),isNaN(c))return{stiffness:X.stiffness,damping:X.damping,duration:t};{const u=Math.pow(c,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const Bc=12;function $c(t,e,n){let s=n;for(let i=1;i<Bc;i++)s=s-t(s)/e(s);return s}function is(t,e){return t*Math.sqrt(1-e*e)}const zc=["duration","bounce"],Uc=["stiffness","damping","mass"];function Ci(t,e){return e.some(n=>t[n]!==void 0)}function _c(t){let e={velocity:X.velocity,stiffness:X.stiffness,damping:X.damping,mass:X.mass,isResolvedFromDuration:!1,...t};if(!Ci(t,Uc)&&Ci(t,zc))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*Lt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:X.mass,stiffness:i,damping:o}}else{const n=Fc(t);e={...e,...n,mass:X.mass},e.isResolvedFromDuration=!0}return e}function An(t=X.visualDuration,e=X.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:c,damping:u,mass:l,duration:d,velocity:f,isResolvedFromDuration:g}=_c({...n,velocity:-bt(n.velocity||0)}),x=f||0,v=u/(2*Math.sqrt(c*l)),A=r-o,y=bt(Math.sqrt(c/l)),w=Math.abs(A)<5;s||(s=w?X.restSpeed.granular:X.restSpeed.default),i||(i=w?X.restDelta.granular:X.restDelta.default);let S;if(v<1){const j=is(y,v);S=E=>{const O=Math.exp(-v*y*E);return r-O*((x+v*y*A)/j*Math.sin(j*E)+A*Math.cos(j*E))}}else if(v===1)S=j=>r-Math.exp(-y*j)*(A+(x+y*A)*j);else{const j=y*Math.sqrt(v*v-1);S=E=>{const O=Math.exp(-v*y*E),R=Math.min(j*E,300);return r-O*((x+v*y*A)*Math.sinh(R)+j*A*Math.cosh(R))/j}}const D={calculatedDuration:g&&d||null,next:j=>{const E=S(j);if(g)a.done=j>=d;else{let O=j===0?x:0;v<1&&(O=j===0?Ct(x):lo(S,j,E));const R=Math.abs(O)<=s,B=Math.abs(r-E)<=i;a.done=R&&B}return a.value=a.done?r:E,a},toString:()=>{const j=Math.min(zs(D),Sn),E=co(O=>D.next(j*O).value,j,30);return j+"ms "+E},toTransition:()=>{}};return D}An.applyToOptions=t=>{const e=Lc(t,100,An);return t.ease=e.ease,t.duration=Ct(e.duration),t.type="keyframes",t};function rs({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:c,restDelta:u=.5,restSpeed:l}){const d=t[0],f={done:!1,value:d},g=R=>a!==void 0&&R<a||c!==void 0&&R>c,x=R=>a===void 0?c:c===void 0||Math.abs(a-R)<Math.abs(c-R)?a:c;let v=n*e;const A=d+v,y=r===void 0?A:r(A);y!==A&&(v=y-d);const w=R=>-v*Math.exp(-R/s),S=R=>y+w(R),D=R=>{const B=w(R),Y=S(R);f.done=Math.abs(B)<=u,f.value=f.done?y:Y};let j,E;const O=R=>{g(f.value)&&(j=R,E=An({keyframes:[f.value,x(f.value)],velocity:lo(S,R,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:l}))};return O(0),{calculatedDuration:null,next:R=>{let B=!1;return!E&&j===void 0&&(B=!0,D(R),O(R)),j!==void 0&&R>=j?E.next(R-j):(!B&&D(R),f)}}}function Wc(t,e,n){const s=[],i=n||Ft.mix||ao,o=t.length-1;for(let r=0;r<o;r++){let a=i(t[r],t[r+1]);if(e){const c=Array.isArray(e)?e[r]||wt:e;a=Qe(c,a)}s.push(a)}return s}function Kc(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(Ot(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Wc(e,s,i),c=a.length,u=l=>{if(r&&l<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(l<t[d+1]);d++);const f=Ge(t[d],t[d+1],l);return a[d](f)};return n?l=>u(Lt(t[0],t[o-1],l)):u}function Hc(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ge(0,e,s);t.push(q(n,1,i))}}function Gc(t){const e=[0];return Hc(e,t.length-1),e}function Xc(t,e){return t.map(n=>n*e)}function qc(t,e){return t.map(()=>e||Jr).splice(0,t.length-1)}function we({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=ac(s)?s.map(wi):wi(s),o={done:!1,value:e[0]},r=Xc(n&&n.length===e.length?n:Gc(e),t),a=Kc(r,e,{ease:Array.isArray(i)?i:qc(e,i)});return{calculatedDuration:t,next:c=>(o.value=a(c),o.done=c>=t,o)}}const Yc=t=>t!==null;function Us(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(Yc),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Jc={decay:rs,inertia:rs,tween:we,keyframes:we,spring:An};function uo(t){typeof t.type=="string"&&(t.type=Jc[t.type])}class _s{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const Zc=t=>t/100;class Ws extends _s{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==mt.now()&&this.tick(mt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;uo(e);const{type:n=we,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const c=n||we;process.env.NODE_ENV!=="production"&&c!==we&&Ot(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==we&&typeof a[0]!="number"&&(this.mixKeyframes=Qe(Zc,ao(a[0],a[1])),a=[0,100]);const u=c({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=zs(u));const{calculatedDuration:l}=u;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:l,repeat:d,repeatType:f,repeatDelay:g,type:x,onUpdate:v,finalKeyframe:A}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const y=this.currentTime-u*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?y<0:y>i;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let S=this.currentTime,D=s;if(d){const R=Math.min(this.currentTime,i)/a;let B=Math.floor(R),Y=R%1;!Y&&R>=1&&(Y=1),Y===1&&B--,B=Math.min(B,d+1),!!(B%2)&&(f==="reverse"?(Y=1-Y,g&&(Y-=g/a)):f==="mirror"&&(D=r)),S=Lt(0,1,Y)*a}const j=w?{done:!1,value:l[0]}:D.next(S);o&&(j.value=o(j.value));let{done:E}=j;!w&&c!==null&&(E=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const O=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return O&&x!==rs&&(j.value=Us(l,this.options,A,this.speed)),v&&v(j.value),O&&this.finish(),j}then(e,n){return this.finished.then(e,n)}get duration(){return bt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(this.currentTime)}set time(e){e=Ct(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?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(mt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=bt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Ic,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),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(mt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&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(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function Qc(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const ae=t=>t*180/Math.PI,os=t=>{const e=ae(Math.atan2(t[1],t[0]));return as(e)},tl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:os,rotateZ:os,skewX:t=>ae(Math.atan(t[1])),skewY:t=>ae(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},as=t=>(t=t%360,t<0&&(t+=360),t),Mi=os,ji=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Ei=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),el={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ji,scaleY:Ei,scale:t=>(ji(t)+Ei(t))/2,rotateX:t=>as(ae(Math.atan2(t[6],t[5]))),rotateY:t=>as(ae(Math.atan2(-t[2],t[0]))),rotateZ:Mi,rotate:Mi,skewX:t=>ae(Math.atan(t[4])),skewY:t=>ae(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function cs(t){return t.includes("scale")?1:0}function ls(t,e){if(!t||t==="none")return cs(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=el,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=tl,i=a}if(!i)return cs(e);const o=s[e],r=i[1].split(",").map(sl);return typeof o=="function"?o(r):r[o]}const nl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return ls(n,e)};function sl(t){return parseFloat(t.trim())}const Ve=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Re=new Set(Ve),ki=t=>t===De||t===L,il=new Set(["x","y","z"]),rl=Ve.filter(t=>!il.has(t));function ol(t){const e=[];return rl.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const ce={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>ls(e,"x"),y:(t,{transform:e})=>ls(e,"y")};ce.translateX=ce.x;ce.translateY=ce.y;const le=new Set;let us=!1,ds=!1,hs=!1;function ho(){if(ds){const t=Array.from(le).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=ol(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}ds=!1,us=!1,le.forEach(t=>t.complete(hs)),le.clear()}function fo(){le.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ds=!0)})}function al(){hs=!0,fo(),ho(),hs=!1}class Ks{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(le.add(this),us||(us=!0,G.read(fo),G.resolveKeyframes(ho))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const o=i?.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(s&&n){const a=s.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),i&&o===void 0&&i.set(e[0])}Qc(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),le.delete(this)}cancel(){this.state==="scheduled"&&(le.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const cl=t=>t.startsWith("--");function ll(t,e,n){cl(e)?t.style.setProperty(e,n):t.style[e]=n}const ul=Ds(()=>window.ScrollTimeline!==void 0),dl={};function hl(t,e){const n=Ds(t);return()=>dl[e]??n()}const mo=hl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),$e=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,Di={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:$e([0,.65,.55,1]),circOut:$e([.55,0,1,.45]),backIn:$e([.31,.01,.66,-.59]),backOut:$e([.33,1.53,.69,.99])};function po(t,e){if(t)return typeof t=="function"?mo()?co(t,e):"ease-out":Zr(t)?$e(t):Array.isArray(t)?t.map(n=>po(n,e)||Di.easeOut):Di[t]}function fl(t,e,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:c}={},u=void 0){const l={[e]:n};c&&(l.offset=c);const d=po(a,i);Array.isArray(d)&&(l.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(l,f)}function go(t){return typeof t=="function"&&"applyToOptions"in t}function ml({type:t,...e}){return go(t)&&mo()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class pl extends _s{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,Ot(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=ml(e);this.animation=fl(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const l=Us(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(l):ll(n,s,l),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return bt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Ct(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&ul()?(this.animation.timeline=e,wt):n(this)}}const yo={anticipate:Xr,backInOut:Gr,circInOut:Yr};function gl(t){return t in yo}function yl(t){typeof t.ease=="string"&&gl(t.ease)&&(t.ease=yo[t.ease])}const Vi=10;class xl extends pl{constructor(e){yl(e),uo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Ws({...r,autoplay:!1}),c=Ct(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-Vi).value,a.sample(c).value,Vi),a.stop()}}const Ri=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Wt.test(t)||t==="0")&&!t.startsWith("url("));function vl(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function bl(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=Ri(i,e),a=Ri(o,e);return ke(r===a,`You are trying to animate ${e} from "${i}" to "${o}". "${r?o:i}" is not an animatable value.`,"value-not-animatable"),!r||!a?!1:vl(t)||(n==="spring"||go(n))&&s}function fs(t){t.duration=0,t.type="keyframes"}const wl=new Set(["opacity","clipPath","filter","transform"]),Tl=Ds(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Sl(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return Tl()&&n&&wl.has(n)&&(n!=="transform"||!u)&&!c&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const Al=40;class Pl extends _s{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:c,motionValue:u,element:l,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=mt.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:c,motionValue:u,element:l,...d},g=l?.KeyframeResolver||Ks;this.keyframeResolver=new g(a,(x,v,A)=>this.onKeyframesResolved(x,v,f,!A),c,u,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:c,isHandoff:u,onUpdate:l}=s;this.resolvedAt=mt.now(),bl(e,o,r,a)||((Ft.instantAnimations||!c)&&l?.(Us(e,s,n)),e[0]=e[e.length-1],fs(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>Al?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&Sl(f)?new xl({...f,element:f.motionValue.owner.current}):new Ws(f);g.finished.then(()=>this.notifyFinished()).catch(wt),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),al()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const Cl=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Ml(t){const e=Cl.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const jl=4;function xo(t,e,n=1){Ot(n<=jl,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=Ml(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return Br(r)?parseFloat(r):r}return Os(i)?xo(i,e,n+1):i}function Hs(t,e){return t?.[e]??t?.default??t}const vo=new Set(["width","height","top","left","right","bottom",...Ve]),El={test:t=>t==="auto",parse:t=>t},bo=t=>e=>e.test(t),wo=[De,L,Dt,Ut,vc,xc,El],Ni=t=>wo.find(bo(t));function kl(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||zr(t):!0}const Dl=new Set(["brightness","contrast","saturate","opacity"]);function Vl(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(Fs)||[];if(!s)return t;const i=n.replace(s,"");let o=Dl.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const Rl=/\b([a-z-]*)\(.*?\)/gu,ms={...Wt,getAnimatableNone:t=>{const e=t.match(Rl);return e?e.map(Vl).join(" "):t}},Ii={...De,transform:Math.round},Nl={rotate:Ut,rotateX:Ut,rotateY:Ut,rotateZ:Ut,scale:dn,scaleX:dn,scaleY:dn,scaleZ:dn,skew:Ut,skewX:Ut,skewY:Ut,distance:L,translateX:L,translateY:L,translateZ:L,x:L,y:L,z:L,perspective:L,transformPerspective:L,opacity:Xe,originX:Ti,originY:Ti,originZ:L},Gs={borderWidth:L,borderTopWidth:L,borderRightWidth:L,borderBottomWidth:L,borderLeftWidth:L,borderRadius:L,radius:L,borderTopLeftRadius:L,borderTopRightRadius:L,borderBottomRightRadius:L,borderBottomLeftRadius:L,width:L,maxWidth:L,height:L,maxHeight:L,top:L,right:L,bottom:L,left:L,padding:L,paddingTop:L,paddingRight:L,paddingBottom:L,paddingLeft:L,margin:L,marginTop:L,marginRight:L,marginBottom:L,marginLeft:L,backgroundPositionX:L,backgroundPositionY:L,...Nl,zIndex:Ii,fillOpacity:Xe,strokeOpacity:Xe,numOctaves:Ii},Il={...Gs,color:Z,backgroundColor:Z,outlineColor:Z,fill:Z,stroke:Z,borderColor:Z,borderTopColor:Z,borderRightColor:Z,borderBottomColor:Z,borderLeftColor:Z,filter:ms,WebkitFilter:ms},To=t=>Il[t];function So(t,e){let n=To(t);return n!==ms&&(n=Wt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Ll=new Set(["auto","none","0"]);function Ol(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!Ll.has(o)&&qe(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=So(n,i)}class Fl extends Ks{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let u=e[c];if(typeof u=="string"&&(u=u.trim(),Os(u))){const l=xo(u,n.current);l!==void 0&&(e[c]=l),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!vo.has(s)||e.length!==2)return;const[i,o]=e,r=Ni(i),a=Ni(o);if(r!==a)if(ki(r)&&ki(a))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else ce[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||kl(e[i]))&&s.push(i);s.length&&Ol(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ce[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=ce[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}function Bl(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const Ao=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Po(t){return $r(t)&&"offsetHeight"in t}const Li=30,$l=t=>!isNaN(parseFloat(t));class zl{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=mt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=mt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=$l(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Rs(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Vs);const s=this.events[e].add(n);return e==="change"?()=>{s(),G.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.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 this.current}getPrevious(){return this.prev}getVelocity(){const e=mt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Li)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Li);return Ur(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),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 je(t,e){return new zl(t,e)}const{schedule:Xs}=Qr(queueMicrotask,!1),At={x:!1,y:!1};function Co(){return At.x||At.y}function Ul(t){return t==="x"||t==="y"?At[t]?null:(At[t]=!0,()=>{At[t]=!1}):At.x||At.y?null:(At.x=At.y=!0,()=>{At.x=At.y=!1})}function Mo(t,e){const n=Bl(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Oi(t){return!(t.pointerType==="touch"||Co())}function _l(t,e,n={}){const[s,i,o]=Mo(t,n),r=a=>{if(!Oi(a))return;const{target:c}=a,u=e(c,a);if(typeof u!="function"||!c)return;const l=d=>{Oi(d)&&(u(d),c.removeEventListener("pointerleave",l))};c.addEventListener("pointerleave",l,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const jo=(t,e)=>e?t===e?!0:jo(t,e.parentElement):!1,qs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Wl=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Kl(t){return Wl.has(t.tagName)||t.tabIndex!==-1}const gn=new WeakSet;function Fi(t){return e=>{e.key==="Enter"&&t(e)}}function Wn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Hl=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=Fi(()=>{if(gn.has(n))return;Wn(n,"down");const i=Fi(()=>{Wn(n,"up")}),o=()=>Wn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function Bi(t){return qs(t)&&!Co()}function Gl(t,e,n={}){const[s,i,o]=Mo(t,n),r=a=>{const c=a.currentTarget;if(!Bi(a))return;gn.add(c);const u=e(c,a),l=(g,x)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),gn.has(c)&&gn.delete(c),Bi(g)&&typeof u=="function"&&u(g,{success:x})},d=g=>{l(g,c===window||c===document||n.useGlobalTarget||jo(c,g.target))},f=g=>{l(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),Po(a)&&(a.addEventListener("focus",u=>Hl(u,i)),!Kl(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Eo(t){return $r(t)&&"ownerSVGElement"in t}function Xl(t){return Eo(t)&&t.tagName==="svg"}const ct=t=>!!(t&&t.getVelocity),ql=[...wo,Z,Wt],Yl=t=>ql.find(bo(t)),Ys=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function $i(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Jl(...t){return e=>{let n=!1;const s=t.map(i=>{const o=$i(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():$i(t[i],null)}}}}function Zl(...t){return Pt.useCallback(Jl(...t),t)}class Ql extends Pt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=Po(s)&&s.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=i-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function tu({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),o=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Ys),c=Zl(o,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:l,top:d,left:f,right:g}=r.current;if(e||!o.current||!u||!l)return;const x=n==="left"?`left: ${f}`:`right: ${g}`;o.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const A=s??document.head;return A.appendChild(v),v.sheet&&v.sheet.insertRule(`
1
+ "use strict";var za=Object.create;var yi=Object.defineProperty;var Ua=Object.getOwnPropertyDescriptor;var _a=Object.getOwnPropertyNames;var Wa=Object.getPrototypeOf,Ka=Object.prototype.hasOwnProperty;var Ha=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _a(e))!Ka.call(t,i)&&i!==n&&yi(t,i,{get:()=>e[i],enumerable:!(s=Ua(e,i))||s.enumerable});return t};var Ga=(t,e,n)=>(n=t!=null?za(Wa(t)):{},Ha(e||!t||!t.__esModule?yi(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),Z=require("lucide-react"),Ir=require("@ai-sdk/react"),An=require("ai"),Lr=require("@radix-ui/react-slot"),Or=require("class-variance-authority"),Xa=require("clsx"),qa=require("tailwind-merge"),Ya=require("@radix-ui/react-tooltip"),xi=require("@radix-ui/react-use-controllable-state"),Ja=require("@radix-ui/react-collapsible"),Za=require("./server.cjs");function Ms(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Pt=Ms(m),Ce=Ms(Ya),js=Ms(Ja);function st(...t){return qa.twMerge(Xa.clsx(t))}const re=Or.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),Pn=Pt.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},o)=>{const r=s?Lr.Slot:"button";return h.jsx(r,{ref:o,"data-slot":"button",className:st(re({variant:e,size:n,className:t})),...i})});Pn.displayName="Button";const Qa=Or.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function zn({className:t,variant:e,asChild:n=!1,...s}){const i=n?Lr.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:st(Qa({variant:e}),t),...s})}const tc=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,o]=Pt.useState(!0);Pt.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const c=a.scrollHeight;c>n?a.style.height=`${n}px`:a.style.height=`${c+6}px`}},[t.current,e])},Fr=Pt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...o},r)=>{const a=Pt.useRef(null),[c,u]=Pt.useState("");return tc({textAreaRef:a,triggerAutoSize:c,maxHeight:t,minHeight:e}),m.useImperativeHandle(r,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),Pt.useEffect(()=>{u(i)},[o?.defaultValue,i]),h.jsx("textarea",{...o,value:i,ref:a,className:st("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:l=>{u(l.target.value),s?.(l)}})});Fr.displayName="AutosizeTextarea";function ec({delayDuration:t=0,...e}){return h.jsx(Ce.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function ee({...t}){return h.jsx(ec,{children:h.jsx(Ce.Root,{"data-slot":"tooltip",...t})})}function ne({...t}){return h.jsx(Ce.Trigger,{"data-slot":"tooltip-trigger",...t})}function se({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(Ce.Portal,{children:h.jsxs(Ce.Content,{"data-slot":"tooltip-content",sideOffset:e,className:st("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...s,children:[n,h.jsx(Ce.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function vi({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:st("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",t),...e})}const Es=m.createContext({});function ks(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const Ds=typeof window<"u",Br=Ds?m.useLayoutEffect:m.useEffect,Dn=m.createContext(null);function Vs(t,e){t.indexOf(e)===-1&&t.push(e)}function Rs(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Lt=(t,e,n)=>n>e?e:n<t?t:n;function is(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let ke=()=>{},Ot=()=>{};process.env.NODE_ENV!=="production"&&(ke=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(is(e,n))},Ot=(t,e,n)=>{if(!t)throw new Error(is(e,n))});const Ft={},$r=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function zr(t){return typeof t=="object"&&t!==null}const Ur=t=>/^0[^.\s]+$/u.test(t);function Ns(t){let e;return()=>(e===void 0&&(e=t()),e)}const wt=t=>t,nc=(t,e)=>n=>e(t(n)),nn=(...t)=>t.reduce(nc),Ye=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Is{constructor(){this.subscriptions=[]}add(e){return Vs(this.subscriptions,e),()=>Rs(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Ct=t=>t*1e3,bt=t=>t/1e3;function _r(t,e){return e?t*(1e3/e):0}const bi=new Set;function Ls(t,e,n){t||bi.has(e)||(console.warn(is(e,n)),bi.add(e))}const Wr=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,sc=1e-7,ic=12;function rc(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=Wr(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>sc&&++a<ic);return r}function sn(t,e,n,s){if(t===e&&n===s)return wt;const i=o=>rc(o,0,1,t,n);return o=>o===0||o===1?o:Wr(i(o),e,s)}const Kr=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Hr=t=>e=>1-t(1-e),Gr=sn(.33,1.53,.69,.99),Os=Hr(Gr),Xr=Kr(Os),qr=t=>(t*=2)<1?.5*Os(t):.5*(2-Math.pow(2,-10*(t-1))),Fs=t=>1-Math.sin(Math.acos(t)),Yr=Hr(Fs),Jr=Kr(Fs),oc=sn(.42,0,1,1),ac=sn(0,0,.58,1),Zr=sn(.42,0,.58,1),cc=t=>Array.isArray(t)&&typeof t[0]!="number",Qr=t=>Array.isArray(t)&&typeof t[0]=="number",wi={linear:wt,easeIn:oc,easeInOut:Zr,easeOut:ac,circIn:Fs,circInOut:Jr,circOut:Yr,backIn:Os,backInOut:Xr,backOut:Gr,anticipate:qr},lc=t=>typeof t=="string",Ti=t=>{if(Qr(t)){Ot(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return sn(e,n,s,i)}else if(lc(t))return Ot(wi[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),wi[t];return t},mn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function uc(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(l){r.has(l)&&(u.schedule(l),t()),l(a)}const u={schedule:(l,d=!1,f=!1)=>{const x=f&&i?n:s;return d&&r.add(l),x.has(l)||x.add(l),l},cancel:l=>{s.delete(l),r.delete(l)},process:l=>{if(a=l,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(c),n.clear(),i=!1,o&&(o=!1,u.process(l))}};return u}const dc=40;function to(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=mn.reduce((T,D)=>(T[D]=uc(o),T),{}),{setup:a,read:c,resolveKeyframes:u,preUpdate:l,update:d,preRender:f,render:g,postRender:x}=r,v=()=>{const T=Ft.useManualTiming?i.timestamp:performance.now();n=!1,Ft.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(T-i.timestamp,dc),1)),i.timestamp=T,i.isProcessing=!0,a.process(i),c.process(i),u.process(i),l.process(i),d.process(i),f.process(i),g.process(i),x.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},A=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:mn.reduce((T,D)=>{const j=r[D];return T[D]=(E,O=!1,R=!1)=>(n||A(),j.schedule(E,O,R)),T},{}),cancel:T=>{for(let D=0;D<mn.length;D++)r[mn[D]].cancel(T)},state:i,steps:r}}const{schedule:H,cancel:Wt,state:nt,steps:Un}=to(typeof requestAnimationFrame<"u"?requestAnimationFrame:wt,!0);let vn;function hc(){vn=void 0}const mt={now:()=>(vn===void 0&&mt.set(nt.isProcessing||Ft.useManualTiming?nt.timestamp:performance.now()),vn),set:t=>{vn=t,queueMicrotask(hc)}},eo=t=>e=>typeof e=="string"&&e.startsWith(t),Bs=eo("--"),fc=eo("var(--"),$s=t=>fc(t)?mc.test(t.split("/*")[0].trim()):!1,mc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,De={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Je={...De,transform:t=>Lt(0,1,t)},pn={...De,default:1},We=t=>Math.round(t*1e5)/1e5,zs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function pc(t){return t==null}const gc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Us=(t,e)=>n=>!!(typeof n=="string"&&gc.test(n)&&n.startsWith(t)||e&&!pc(n)&&Object.prototype.hasOwnProperty.call(n,e)),no=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(zs);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},yc=t=>Lt(0,255,t),_n={...De,transform:t=>Math.round(yc(t))},ae={test:Us("rgb","red"),parse:no("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+_n.transform(t)+", "+_n.transform(e)+", "+_n.transform(n)+", "+We(Je.transform(s))+")"};function xc(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const rs={test:Us("#"),parse:xc,transform:ae.transform},rn=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),_t=rn("deg"),Dt=rn("%"),L=rn("px"),vc=rn("vh"),bc=rn("vw"),Si={...Dt,parse:t=>Dt.parse(t)/100,transform:t=>Dt.transform(t*100)},be={test:Us("hsl","hue"),parse:no("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+Dt.transform(We(e))+", "+Dt.transform(We(n))+", "+We(Je.transform(s))+")"},J={test:t=>ae.test(t)||rs.test(t)||be.test(t),parse:t=>ae.test(t)?ae.parse(t):be.test(t)?be.parse(t):rs.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ae.transform(t):be.transform(t),getAnimatableNone:t=>{const e=J.parse(t);return e.alpha=0,J.transform(e)}},wc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Tc(t){return isNaN(t)&&typeof t=="string"&&(t.match(zs)?.length||0)+(t.match(wc)?.length||0)>0}const so="number",io="color",Sc="var",Ac="var(",Ai="${}",Pc=/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 Ze(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const a=e.replace(Pc,c=>(J.test(c)?(s.color.push(o),i.push(io),n.push(J.parse(c))):c.startsWith(Ac)?(s.var.push(o),i.push(Sc),n.push(c)):(s.number.push(o),i.push(so),n.push(parseFloat(c))),++o,Ai)).split(Ai);return{values:n,split:a,indexes:s,types:i}}function ro(t){return Ze(t).values}function oo(t){const{split:e,types:n}=Ze(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===so?o+=We(i[r]):a===io?o+=J.transform(i[r]):o+=i[r]}return o}}const Cc=t=>typeof t=="number"?0:J.test(t)?J.getAnimatableNone(t):t;function Mc(t){const e=ro(t);return oo(t)(e.map(Cc))}const Kt={test:Tc,parse:ro,createTransformer:oo,getAnimatableNone:Mc};function Wn(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function jc({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=Wn(c,a,t+1/3),o=Wn(c,a,t),r=Wn(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function Cn(t,e){return n=>n>0?e:t}const X=(t,e,n)=>t+(e-t)*n,Kn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},Ec=[rs,ae,be],kc=t=>Ec.find(e=>e.test(t));function Pi(t){const e=kc(t);if(ke(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===be&&(n=jc(n)),n}const Ci=(t,e)=>{const n=Pi(t),s=Pi(e);if(!n||!s)return Cn(t,e);const i={...n};return o=>(i.red=Kn(n.red,s.red,o),i.green=Kn(n.green,s.green,o),i.blue=Kn(n.blue,s.blue,o),i.alpha=X(n.alpha,s.alpha,o),ae.transform(i))},os=new Set(["none","hidden"]);function Dc(t,e){return os.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Vc(t,e){return n=>X(t,e,n)}function _s(t){return typeof t=="number"?Vc:typeof t=="string"?$s(t)?Cn:J.test(t)?Ci:Ic:Array.isArray(t)?ao:typeof t=="object"?J.test(t)?Ci:Rc:Cn}function ao(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>_s(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function Rc(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=_s(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function Nc(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],r=t.indexes[o][s[o]],a=t.values[r]??0;n[i]=a,s[o]++}return n}const Ic=(t,e)=>{const n=Kt.createTransformer(e),s=Ze(t),i=Ze(e);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?os.has(t)&&!i.values.length||os.has(e)&&!s.values.length?Dc(t,e):nn(ao(Nc(s,i),i.values),n):(ke(!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"),Cn(t,e))};function co(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?X(t,e,n):_s(t)(t,e)}const Lc=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>H.update(e,n),stop:()=>Wt(e),now:()=>nt.isProcessing?nt.timestamp:mt.now()}},lo=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Mn=2e4;function Ws(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Mn;)e+=n,s=t.next(e);return e>=Mn?1/0:e}function Oc(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(Ws(s),Mn);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:bt(i)}}const Fc=5;function uo(t,e,n){const s=Math.max(e-Fc,0);return _r(n-t(s),e-s)}const G={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},Hn=.001;function Bc({duration:t=G.duration,bounce:e=G.bounce,velocity:n=G.velocity,mass:s=G.mass}){let i,o;ke(t<=Ct(G.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=Lt(G.minDamping,G.maxDamping,r),t=Lt(G.minDuration,G.maxDuration,bt(t)),r<1?(i=u=>{const l=u*r,d=l*t,f=l-n,g=as(u,r),x=Math.exp(-d);return Hn-f/g*x},o=u=>{const d=u*r*t,f=d*n+n,g=Math.pow(r,2)*Math.pow(u,2)*t,x=Math.exp(-d),v=as(Math.pow(u,2),r);return(-i(u)+Hn>0?-1:1)*((f-g)*x)/v}):(i=u=>{const l=Math.exp(-u*t),d=(u-n)*t+1;return-Hn+l*d},o=u=>{const l=Math.exp(-u*t),d=(n-u)*(t*t);return l*d});const a=5/t,c=zc(i,o,a);if(t=Ct(t),isNaN(c))return{stiffness:G.stiffness,damping:G.damping,duration:t};{const u=Math.pow(c,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const $c=12;function zc(t,e,n){let s=n;for(let i=1;i<$c;i++)s=s-t(s)/e(s);return s}function as(t,e){return t*Math.sqrt(1-e*e)}const Uc=["duration","bounce"],_c=["stiffness","damping","mass"];function Mi(t,e){return e.some(n=>t[n]!==void 0)}function Wc(t){let e={velocity:G.velocity,stiffness:G.stiffness,damping:G.damping,mass:G.mass,isResolvedFromDuration:!1,...t};if(!Mi(t,_c)&&Mi(t,Uc))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*Lt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:G.mass,stiffness:i,damping:o}}else{const n=Bc(t);e={...e,...n,mass:G.mass},e.isResolvedFromDuration=!0}return e}function jn(t=G.visualDuration,e=G.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:c,damping:u,mass:l,duration:d,velocity:f,isResolvedFromDuration:g}=Wc({...n,velocity:-bt(n.velocity||0)}),x=f||0,v=u/(2*Math.sqrt(c*l)),A=r-o,y=bt(Math.sqrt(c/l)),w=Math.abs(A)<5;s||(s=w?G.restSpeed.granular:G.restSpeed.default),i||(i=w?G.restDelta.granular:G.restDelta.default);let T;if(v<1){const j=as(y,v);T=E=>{const O=Math.exp(-v*y*E);return r-O*((x+v*y*A)/j*Math.sin(j*E)+A*Math.cos(j*E))}}else if(v===1)T=j=>r-Math.exp(-y*j)*(A+(x+y*A)*j);else{const j=y*Math.sqrt(v*v-1);T=E=>{const O=Math.exp(-v*y*E),R=Math.min(j*E,300);return r-O*((x+v*y*A)*Math.sinh(R)+j*A*Math.cosh(R))/j}}const D={calculatedDuration:g&&d||null,next:j=>{const E=T(j);if(g)a.done=j>=d;else{let O=j===0?x:0;v<1&&(O=j===0?Ct(x):uo(T,j,E));const R=Math.abs(O)<=s,$=Math.abs(r-E)<=i;a.done=R&&$}return a.value=a.done?r:E,a},toString:()=>{const j=Math.min(Ws(D),Mn),E=lo(O=>D.next(j*O).value,j,30);return j+"ms "+E},toTransition:()=>{}};return D}jn.applyToOptions=t=>{const e=Oc(t,100,jn);return t.ease=e.ease,t.duration=Ct(e.duration),t.type="keyframes",t};function cs({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:c,restDelta:u=.5,restSpeed:l}){const d=t[0],f={done:!1,value:d},g=R=>a!==void 0&&R<a||c!==void 0&&R>c,x=R=>a===void 0?c:c===void 0||Math.abs(a-R)<Math.abs(c-R)?a:c;let v=n*e;const A=d+v,y=r===void 0?A:r(A);y!==A&&(v=y-d);const w=R=>-v*Math.exp(-R/s),T=R=>y+w(R),D=R=>{const $=w(R),q=T(R);f.done=Math.abs($)<=u,f.value=f.done?y:q};let j,E;const O=R=>{g(f.value)&&(j=R,E=jn({keyframes:[f.value,x(f.value)],velocity:uo(T,R,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:l}))};return O(0),{calculatedDuration:null,next:R=>{let $=!1;return!E&&j===void 0&&($=!0,D(R),O(R)),j!==void 0&&R>=j?E.next(R-j):(!$&&D(R),f)}}}function Kc(t,e,n){const s=[],i=n||Ft.mix||co,o=t.length-1;for(let r=0;r<o;r++){let a=i(t[r],t[r+1]);if(e){const c=Array.isArray(e)?e[r]||wt:e;a=nn(c,a)}s.push(a)}return s}function Hc(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(Ot(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Kc(e,s,i),c=a.length,u=l=>{if(r&&l<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(l<t[d+1]);d++);const f=Ye(t[d],t[d+1],l);return a[d](f)};return n?l=>u(Lt(t[0],t[o-1],l)):u}function Gc(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ye(0,e,s);t.push(X(n,1,i))}}function Xc(t){const e=[0];return Gc(e,t.length-1),e}function qc(t,e){return t.map(n=>n*e)}function Yc(t,e){return t.map(()=>e||Zr).splice(0,t.length-1)}function we({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=cc(s)?s.map(Ti):Ti(s),o={done:!1,value:e[0]},r=qc(n&&n.length===e.length?n:Xc(e),t),a=Hc(r,e,{ease:Array.isArray(i)?i:Yc(e,i)});return{calculatedDuration:t,next:c=>(o.value=a(c),o.done=c>=t,o)}}const Jc=t=>t!==null;function Ks(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(Jc),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Zc={decay:cs,inertia:cs,tween:we,keyframes:we,spring:jn};function ho(t){typeof t.type=="string"&&(t.type=Zc[t.type])}class Hs{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const Qc=t=>t/100;class Gs extends Hs{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==mt.now()&&this.tick(mt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;ho(e);const{type:n=we,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const c=n||we;process.env.NODE_ENV!=="production"&&c!==we&&Ot(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==we&&typeof a[0]!="number"&&(this.mixKeyframes=nn(Qc,co(a[0],a[1])),a=[0,100]);const u=c({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=Ws(u));const{calculatedDuration:l}=u;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:l,repeat:d,repeatType:f,repeatDelay:g,type:x,onUpdate:v,finalKeyframe:A}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const y=this.currentTime-u*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?y<0:y>i;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let T=this.currentTime,D=s;if(d){const R=Math.min(this.currentTime,i)/a;let $=Math.floor(R),q=R%1;!q&&R>=1&&(q=1),q===1&&$--,$=Math.min($,d+1),!!($%2)&&(f==="reverse"?(q=1-q,g&&(q-=g/a)):f==="mirror"&&(D=r)),T=Lt(0,1,q)*a}const j=w?{done:!1,value:l[0]}:D.next(T);o&&(j.value=o(j.value));let{done:E}=j;!w&&c!==null&&(E=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const O=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return O&&x!==cs&&(j.value=Ks(l,this.options,A,this.speed)),v&&v(j.value),O&&this.finish(),j}then(e,n){return this.finished.then(e,n)}get duration(){return bt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(this.currentTime)}set time(e){e=Ct(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?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(mt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=bt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Lc,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),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(mt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&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(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function tl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const ce=t=>t*180/Math.PI,ls=t=>{const e=ce(Math.atan2(t[1],t[0]));return us(e)},el={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:ls,rotateZ:ls,skewX:t=>ce(Math.atan(t[1])),skewY:t=>ce(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},us=t=>(t=t%360,t<0&&(t+=360),t),ji=ls,Ei=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),ki=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),nl={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ei,scaleY:ki,scale:t=>(Ei(t)+ki(t))/2,rotateX:t=>us(ce(Math.atan2(t[6],t[5]))),rotateY:t=>us(ce(Math.atan2(-t[2],t[0]))),rotateZ:ji,rotate:ji,skewX:t=>ce(Math.atan(t[4])),skewY:t=>ce(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function ds(t){return t.includes("scale")?1:0}function hs(t,e){if(!t||t==="none")return ds(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=nl,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=el,i=a}if(!i)return ds(e);const o=s[e],r=i[1].split(",").map(il);return typeof o=="function"?o(r):r[o]}const sl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return hs(n,e)};function il(t){return parseFloat(t.trim())}const Ve=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Re=new Set(Ve),Di=t=>t===De||t===L,rl=new Set(["x","y","z"]),ol=Ve.filter(t=>!rl.has(t));function al(t){const e=[];return ol.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const le={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>hs(e,"x"),y:(t,{transform:e})=>hs(e,"y")};le.translateX=le.x;le.translateY=le.y;const ue=new Set;let fs=!1,ms=!1,ps=!1;function fo(){if(ms){const t=Array.from(ue).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=al(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}ms=!1,fs=!1,ue.forEach(t=>t.complete(ps)),ue.clear()}function mo(){ue.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ms=!0)})}function cl(){ps=!0,mo(),fo(),ps=!1}class Xs{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(ue.add(this),fs||(fs=!0,H.read(mo),H.resolveKeyframes(fo))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const o=i?.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(s&&n){const a=s.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),i&&o===void 0&&i.set(e[0])}tl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ue.delete(this)}cancel(){this.state==="scheduled"&&(ue.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const ll=t=>t.startsWith("--");function ul(t,e,n){ll(e)?t.style.setProperty(e,n):t.style[e]=n}const dl=Ns(()=>window.ScrollTimeline!==void 0),hl={};function fl(t,e){const n=Ns(t);return()=>hl[e]??n()}const po=fl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),_e=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,Vi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:_e([0,.65,.55,1]),circOut:_e([.55,0,1,.45]),backIn:_e([.31,.01,.66,-.59]),backOut:_e([.33,1.53,.69,.99])};function go(t,e){if(t)return typeof t=="function"?po()?lo(t,e):"ease-out":Qr(t)?_e(t):Array.isArray(t)?t.map(n=>go(n,e)||Vi.easeOut):Vi[t]}function ml(t,e,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:c}={},u=void 0){const l={[e]:n};c&&(l.offset=c);const d=go(a,i);Array.isArray(d)&&(l.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(l,f)}function yo(t){return typeof t=="function"&&"applyToOptions"in t}function pl({type:t,...e}){return yo(t)&&po()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class gl extends Hs{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,Ot(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=pl(e);this.animation=ml(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const l=Ks(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(l):ul(n,s,l),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return bt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Ct(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&dl()?(this.animation.timeline=e,wt):n(this)}}const xo={anticipate:qr,backInOut:Xr,circInOut:Jr};function yl(t){return t in xo}function xl(t){typeof t.ease=="string"&&yl(t.ease)&&(t.ease=xo[t.ease])}const Ri=10;class vl extends gl{constructor(e){xl(e),ho(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Gs({...r,autoplay:!1}),c=Ct(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-Ri).value,a.sample(c).value,Ri),a.stop()}}const Ni=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Kt.test(t)||t==="0")&&!t.startsWith("url("));function bl(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function wl(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=Ni(i,e),a=Ni(o,e);return ke(r===a,`You are trying to animate ${e} from "${i}" to "${o}". "${r?o:i}" is not an animatable value.`,"value-not-animatable"),!r||!a?!1:bl(t)||(n==="spring"||yo(n))&&s}function gs(t){t.duration=0,t.type="keyframes"}const Tl=new Set(["opacity","clipPath","filter","transform"]),Sl=Ns(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Al(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return Sl()&&n&&Tl.has(n)&&(n!=="transform"||!u)&&!c&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const Pl=40;class Cl extends Hs{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:c,motionValue:u,element:l,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=mt.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:c,motionValue:u,element:l,...d},g=l?.KeyframeResolver||Xs;this.keyframeResolver=new g(a,(x,v,A)=>this.onKeyframesResolved(x,v,f,!A),c,u,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:c,isHandoff:u,onUpdate:l}=s;this.resolvedAt=mt.now(),wl(e,o,r,a)||((Ft.instantAnimations||!c)&&l?.(Ks(e,s,n)),e[0]=e[e.length-1],gs(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>Pl?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&Al(f)?new vl({...f,element:f.motionValue.owner.current}):new Gs(f);g.finished.then(()=>this.notifyFinished()).catch(wt),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),cl()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const Ml=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function jl(t){const e=Ml.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const El=4;function vo(t,e,n=1){Ot(n<=El,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=jl(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return $r(r)?parseFloat(r):r}return $s(i)?vo(i,e,n+1):i}function qs(t,e){return t?.[e]??t?.default??t}const bo=new Set(["width","height","top","left","right","bottom",...Ve]),kl={test:t=>t==="auto",parse:t=>t},wo=t=>e=>e.test(t),To=[De,L,Dt,_t,bc,vc,kl],Ii=t=>To.find(wo(t));function Dl(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Ur(t):!0}const Vl=new Set(["brightness","contrast","saturate","opacity"]);function Rl(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(zs)||[];if(!s)return t;const i=n.replace(s,"");let o=Vl.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const Nl=/\b([a-z-]*)\(.*?\)/gu,ys={...Kt,getAnimatableNone:t=>{const e=t.match(Nl);return e?e.map(Rl).join(" "):t}},Li={...De,transform:Math.round},Il={rotate:_t,rotateX:_t,rotateY:_t,rotateZ:_t,scale:pn,scaleX:pn,scaleY:pn,scaleZ:pn,skew:_t,skewX:_t,skewY:_t,distance:L,translateX:L,translateY:L,translateZ:L,x:L,y:L,z:L,perspective:L,transformPerspective:L,opacity:Je,originX:Si,originY:Si,originZ:L},Ys={borderWidth:L,borderTopWidth:L,borderRightWidth:L,borderBottomWidth:L,borderLeftWidth:L,borderRadius:L,radius:L,borderTopLeftRadius:L,borderTopRightRadius:L,borderBottomRightRadius:L,borderBottomLeftRadius:L,width:L,maxWidth:L,height:L,maxHeight:L,top:L,right:L,bottom:L,left:L,padding:L,paddingTop:L,paddingRight:L,paddingBottom:L,paddingLeft:L,margin:L,marginTop:L,marginRight:L,marginBottom:L,marginLeft:L,backgroundPositionX:L,backgroundPositionY:L,...Il,zIndex:Li,fillOpacity:Je,strokeOpacity:Je,numOctaves:Li},Ll={...Ys,color:J,backgroundColor:J,outlineColor:J,fill:J,stroke:J,borderColor:J,borderTopColor:J,borderRightColor:J,borderBottomColor:J,borderLeftColor:J,filter:ys,WebkitFilter:ys},So=t=>Ll[t];function Ao(t,e){let n=So(t);return n!==ys&&(n=Kt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Ol=new Set(["auto","none","0"]);function Fl(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!Ol.has(o)&&Ze(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=Ao(n,i)}class Bl extends Xs{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let u=e[c];if(typeof u=="string"&&(u=u.trim(),$s(u))){const l=vo(u,n.current);l!==void 0&&(e[c]=l),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!bo.has(s)||e.length!==2)return;const[i,o]=e,r=Ii(i),a=Ii(o);if(r!==a)if(Di(r)&&Di(a))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else le[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||Dl(e[i]))&&s.push(i);s.length&&Fl(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=le[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=le[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}function $l(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const Po=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Co(t){return zr(t)&&"offsetHeight"in t}const Oi=30,zl=t=>!isNaN(parseFloat(t));class Ul{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=mt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=mt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=zl(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Ls(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Is);const s=this.events[e].add(n);return e==="change"?()=>{s(),H.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.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 this.current}getPrevious(){return this.prev}getVelocity(){const e=mt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Oi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Oi);return _r(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),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 je(t,e){return new Ul(t,e)}const{schedule:Js}=to(queueMicrotask,!1),At={x:!1,y:!1};function Mo(){return At.x||At.y}function _l(t){return t==="x"||t==="y"?At[t]?null:(At[t]=!0,()=>{At[t]=!1}):At.x||At.y?null:(At.x=At.y=!0,()=>{At.x=At.y=!1})}function jo(t,e){const n=$l(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Fi(t){return!(t.pointerType==="touch"||Mo())}function Wl(t,e,n={}){const[s,i,o]=jo(t,n),r=a=>{if(!Fi(a))return;const{target:c}=a,u=e(c,a);if(typeof u!="function"||!c)return;const l=d=>{Fi(d)&&(u(d),c.removeEventListener("pointerleave",l))};c.addEventListener("pointerleave",l,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const Eo=(t,e)=>e?t===e?!0:Eo(t,e.parentElement):!1,Zs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Kl=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Hl(t){return Kl.has(t.tagName)||t.tabIndex!==-1}const bn=new WeakSet;function Bi(t){return e=>{e.key==="Enter"&&t(e)}}function Gn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Gl=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=Bi(()=>{if(bn.has(n))return;Gn(n,"down");const i=Bi(()=>{Gn(n,"up")}),o=()=>Gn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function $i(t){return Zs(t)&&!Mo()}function Xl(t,e,n={}){const[s,i,o]=jo(t,n),r=a=>{const c=a.currentTarget;if(!$i(a))return;bn.add(c);const u=e(c,a),l=(g,x)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),bn.has(c)&&bn.delete(c),$i(g)&&typeof u=="function"&&u(g,{success:x})},d=g=>{l(g,c===window||c===document||n.useGlobalTarget||Eo(c,g.target))},f=g=>{l(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),Co(a)&&(a.addEventListener("focus",u=>Gl(u,i)),!Hl(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function ko(t){return zr(t)&&"ownerSVGElement"in t}function ql(t){return ko(t)&&t.tagName==="svg"}const at=t=>!!(t&&t.getVelocity),Yl=[...To,J,Kt],Jl=t=>Yl.find(wo(t)),Qs=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function zi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Zl(...t){return e=>{let n=!1;const s=t.map(i=>{const o=zi(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():zi(t[i],null)}}}}function Ql(...t){return Pt.useCallback(Zl(...t),t)}class tu extends Pt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=Co(s)&&s.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=i-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function eu({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),o=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Qs),c=Ql(o,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:l,top:d,left:f,right:g}=r.current;if(e||!o.current||!u||!l)return;const x=n==="left"?`left: ${f}`:`right: ${g}`;o.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const A=s??document.head;return A.appendChild(v),v.sheet&&v.sheet.insertRule(`
2
2
  [data-motion-pop-id="${i}"] {
3
3
  position: absolute !important;
4
4
  width: ${u}px !important;
@@ -6,7 +6,7 @@
6
6
  ${x}px !important;
7
7
  top: ${d}px !important;
8
8
  }
9
- `),()=>{A.contains(v)&&A.removeChild(v)}},[e]),h.jsx(Ql,{isPresent:e,childRef:o,sizeRef:r,children:Pt.cloneElement(t,{ref:c})})}const eu=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:a,root:c})=>{const u=Ms(nu),l=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:l,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const x of u.values())if(!x)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return o&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,x)=>u.set(x,!1))},[n]),Pt.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),r==="popLayout"&&(t=h.jsx(tu,{isPresent:n,anchorX:a,root:c,children:t})),h.jsx(Mn.Provider,{value:f,children:t})};function nu(){return new Map}function ko(t=!0){const e=m.useContext(Mn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=m.useId();m.useEffect(()=>{if(t)return i(o)},[t]);const r=m.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const hn=t=>t.key||"";function zi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const su=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:c})=>{const[u,l]=ko(r),d=m.useMemo(()=>zi(t),[t]),f=r&&!u?[]:d.map(hn),g=m.useRef(!0),x=m.useRef(d),v=Ms(()=>new Map),[A,y]=m.useState(d),[w,S]=m.useState(d);Fr(()=>{g.current=!1,x.current=d;for(let E=0;E<w.length;E++){const O=hn(w[E]);f.includes(O)?v.delete(O):v.get(O)!==!0&&v.set(O,!1)}},[w,f.length,f.join("-")]);const D=[];if(d!==A){let E=[...d];for(let O=0;O<w.length;O++){const R=w[O],B=hn(R);f.includes(B)||(E.splice(O,0,R),D.push(R))}return o==="wait"&&D.length&&(E=D),S(zi(E)),y(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&w.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:j}=m.useContext(Cs);return h.jsx(h.Fragment,{children:w.map(E=>{const O=hn(E),R=r&&!u?!1:d===w||f.includes(O),B=()=>{if(v.has(O))v.set(O,!0);else return;let Y=!0;v.forEach(tt=>{tt||(Y=!1)}),Y&&(j?.(),S(x.current),r&&l?.(),s&&s())};return h.jsx(eu,{isPresent:R,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:o,root:c,onExitComplete:R?void 0:B,anchorX:a,children:E},O)})})},Js=m.createContext({strict:!1}),Ui={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Ee={};for(const t in Ui)Ee[t]={isEnabled:e=>Ui[t].some(n=>!!e[n])};function ps(t){for(const e in t)Ee[e]={...Ee[e],...t[e]}}function iu({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!Kn(e)),i=m.useRef(void 0);if(!Kn(e)){const{renderer:o,...r}=e;i.current=o,ps(r)}return m.useEffect(()=>{Kn(e)&&e().then(({renderer:o,...r})=>{ps(r),i.current=o,s(!0)})},[]),h.jsx(Js.Provider,{value:{renderer:i.current,strict:n},children:t})}function Kn(t){return typeof t=="function"}const ru=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Pn(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||ru.has(t)}let Do=t=>!Pn(t);function ou(t){typeof t=="function"&&(Do=e=>e.startsWith("on")?!Pn(e):t(e))}try{ou(require("@emotion/is-prop-valid").default)}catch{}function au(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(Do(i)||n===!0&&Pn(i)||!e&&!Pn(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const jn=m.createContext({});function En(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Ye(t){return typeof t=="string"||Array.isArray(t)}const Zs=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Qs=["initial",...Zs];function kn(t){return En(t.animate)||Qs.some(e=>Ye(t[e]))}function Vo(t){return!!(kn(t)||t.variants)}function cu(t,e){if(kn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Ye(n)?n:void 0,animate:Ye(s)?s:void 0}}return t.inherit!==!1?e:{}}function lu(t){const{initial:e,animate:n}=cu(t,m.useContext(jn));return m.useMemo(()=>({initial:e,animate:n}),[_i(e),_i(n)])}function _i(t){return Array.isArray(t)?t.join(" "):t}const Je={};function uu(t){for(const e in t)Je[e]=t[e],Ls(e)&&(Je[e].isCSSVariable=!0)}function Ro(t,{layout:e,layoutId:n}){return Re.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Je[t]||t==="opacity")}const du={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},hu=Ve.length;function fu(t,e,n){let s="",i=!0;for(let o=0;o<hu;o++){const r=Ve[o],a=t[r];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(r.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const u=Ao(a,Gs[r]);if(!c){i=!1;const l=du[r]||r;s+=`${l}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function ti(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const c in e){const u=e[c];if(Re.has(c)){r=!0;continue}else if(Ls(c)){i[c]=u;continue}else{const l=Ao(u,Gs[c]);c.startsWith("origin")?(a=!0,o[c]=l):s[c]=l}}if(e.transform||(r||n?s.transform=fu(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:c="50%",originY:u="50%",originZ:l=0}=o;s.transformOrigin=`${c} ${u} ${l}`}}const ei=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function No(t,e,n){for(const s in e)!ct(e[s])&&!Ro(s,n)&&(t[s]=e[s])}function mu({transformTemplate:t},e){return m.useMemo(()=>{const n=ei();return ti(n,e,t),Object.assign({},n.vars,n.style)},[e])}function pu(t,e){const n=t.style||{},s={};return No(s,n,t),Object.assign(s,mu(t,e)),s}function gu(t,e){const n={},s=pu(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const yu={offset:"stroke-dashoffset",array:"stroke-dasharray"},xu={offset:"strokeDashoffset",array:"strokeDasharray"};function vu(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?yu:xu;t[o.offset]=L.transform(-s);const r=L.transform(e),a=L.transform(n);t[o.array]=`${r} ${a}`}function Io(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},c,u,l){if(ti(t,a,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=l?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&vu(d,i,o,r,!1)}const Lo=()=>({...ei(),attrs:{}}),Oo=t=>typeof t=="string"&&t.toLowerCase()==="svg";function bu(t,e,n,s){const i=m.useMemo(()=>{const o=Lo();return Io(o,e,Oo(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};No(o,t.style,t),i.style={...o,...i.style}}return i}const wu=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function ni(t){return typeof t!="string"||t.includes("-")?!1:!!(wu.indexOf(t)>-1||/[A-Z]/u.test(t))}function Tu(t,e,n,{latestValues:s},i,o=!1){const a=(ni(t)?bu:gu)(e,s,i,t),c=au(e,typeof t=="string",o),u=t!==m.Fragment?{...c,...a,ref:n}:{},{children:l}=e,d=m.useMemo(()=>ct(l)?l.get():l,[l]);return m.createElement(t,{...u,children:d})}function Wi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function si(t,e,n,s){if(typeof e=="function"){const[i,o]=Wi(s);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=Wi(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function yn(t){return ct(t)?t.get():t}function Su({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:Au(n,s,i,t),renderState:e()}}function Au(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=yn(o[f]);let{initial:r,animate:a}=t;const c=kn(t),u=Vo(t);e&&u&&!c&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let l=n?n.initial===!1:!1;l=l||r===!1;const d=l?a:r;if(d&&typeof d!="boolean"&&!En(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const x=si(t,f[g]);if(x){const{transitionEnd:v,transition:A,...y}=x;for(const w in y){let S=y[w];if(Array.isArray(S)){const D=l?S.length-1:0;S=S[D]}S!==null&&(i[w]=S)}for(const w in v)i[w]=v[w]}}}return i}const Fo=t=>(e,n)=>{const s=m.useContext(jn),i=m.useContext(Mn),o=()=>Su(t,e,s,i);return n?o():Ms(o)};function ii(t,e,n){const{style:s}=t,i={};for(const o in s)(ct(s[o])||e.style&&ct(e.style[o])||Ro(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const Pu=Fo({scrapeMotionValuesFromProps:ii,createRenderState:ei});function Bo(t,e,n){const s=ii(t,e,n);for(const i in t)if(ct(t[i])||ct(e[i])){const o=Ve.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const Cu=Fo({scrapeMotionValuesFromProps:Bo,createRenderState:Lo}),Mu=Symbol.for("motionComponentSymbol");function Te(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function ju(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):Te(n)&&(n.current=s))},[e])}const ri=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Eu="framerAppearId",$o="data-"+ri(Eu),zo=m.createContext({});function ku(t,e,n,s,i){const{visualElement:o}=m.useContext(jn),r=m.useContext(Js),a=m.useContext(Mn),c=m.useContext(Ys).reducedMotion,u=m.useRef(null);s=s||r.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const l=u.current,d=m.useContext(zo);l&&!l.projection&&i&&(l.type==="html"||l.type==="svg")&&Du(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{l&&f.current&&l.update(n,a)});const g=n[$o],x=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return Fr(()=>{l&&(f.current=!0,window.MotionIsMounted=!0,l.updateFeatures(),l.scheduleRenderMicrotask(),x.current&&l.animationState&&l.animationState.animateChanges())}),m.useEffect(()=>{l&&(!x.current&&l.animationState&&l.animationState.animateChanges(),x.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),x.current=!1),l.enteringChildren=void 0)}),l}function Du(t,e,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:l}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Uo(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&Te(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:c,layoutRoot:u})}function Uo(t){if(t)return t.options.allowProjection!==!1?t.projection:Uo(t.parent)}function xn(t,{forwardMotionProps:e=!1}={},n,s){n&&ps(n);const i=ni(t)?Cu:Pu;function o(a,c){let u;const l={...m.useContext(Ys),...a,layoutId:Vu(a)},{isStatic:d}=l,f=lu(a),g=i(a,d);if(!d&&js){Ru(l,n);const x=Nu(l);u=x.MeasureLayout,f.visualElement=ku(t,g,l,s,x.ProjectionNode)}return h.jsxs(jn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...l}):null,Tu(t,a,ju(g,f.visualElement,c),g,d,e)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const r=m.forwardRef(o);return r[Mu]=t,r}function Vu({layoutId:t}){const e=m.useContext(Cs).id;return e&&t!==void 0?e+"-"+t:t}function Ru(t,e){const n=m.useContext(Js).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?ke(!1,s,"lazy-strict-mode"):Ot(!1,s,"lazy-strict-mode")}}function Nu(t){const{drag:e,layout:n}=Ee;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Iu(t,e){if(typeof Proxy>"u")return xn;const n=new Map,s=(o,r)=>xn(o,r,t,e),i=(o,r)=>(process.env.NODE_ENV!=="production"&&Rs(!1,"motion() is deprecated. Use motion.create() instead."),s(o,r));return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,xn(r,void 0,t,e)),n.get(r))})}function _o({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function Lu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function Ou(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Hn(t){return t===void 0||t===1}function gs({scale:t,scaleX:e,scaleY:n}){return!Hn(t)||!Hn(e)||!Hn(n)}function re(t){return gs(t)||Wo(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Wo(t){return Ki(t.x)||Ki(t.y)}function Ki(t){return t&&t!=="0%"}function Cn(t,e,n){const s=t-n,i=e*s;return n+i}function Hi(t,e,n,s,i){return i!==void 0&&(t=Cn(t,i,s)),Cn(t,n,s)+e}function ys(t,e=0,n=1,s,i){t.min=Hi(t.min,e,n,s,i),t.max=Hi(t.max,e,n,s,i)}function Ko(t,{x:e,y:n}){ys(t.x,e.translate,e.scale,e.originPoint),ys(t.y,n.translate,n.scale,n.originPoint)}const Gi=.999999999999,Xi=1.0000000000001;function Fu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,r;for(let a=0;a<i;a++){o=n[a],r=o.projectionDelta;const{visualElement:c}=o.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&Ae(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,Ko(t,r)),s&&re(o.latestValues)&&Ae(t,o.latestValues))}e.x<Xi&&e.x>Gi&&(e.x=1),e.y<Xi&&e.y>Gi&&(e.y=1)}function Se(t,e){t.min=t.min+e,t.max=t.max+e}function qi(t,e,n,s,i=.5){const o=q(t.min,t.max,i);ys(t,e,n,o,s)}function Ae(t,e){qi(t.x,e.x,e.scaleX,e.scale,e.originX),qi(t.y,e.y,e.scaleY,e.scale,e.originY)}function Ho(t,e){return _o(Ou(t.getBoundingClientRect(),e))}function Bu(t,e,n){const s=Ho(t,n),{scroll:i}=e;return i&&(Se(s.x,i.offset.x),Se(s.y,i.offset.y)),s}const Yi=()=>({translate:0,scale:1,origin:0,originPoint:0}),Pe=()=>({x:Yi(),y:Yi()}),Ji=()=>({min:0,max:0}),J=()=>({x:Ji(),y:Ji()}),xs={current:null},Go={current:!1};function $u(){if(Go.current=!0,!!js)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>xs.current=t.matches;t.addEventListener("change",e),e()}else xs.current=!1}const zu=new WeakMap;function Uu(t,e,n){for(const s in e){const i=e[s],o=n[s];if(ct(i))t.addValue(s,i);else if(ct(o))t.addValue(s,je(i,{owner:t}));else if(o!==i)if(t.hasValue(s)){const r=t.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=t.getStaticValue(s);t.addValue(s,je(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Zi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class _u{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Ks,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=mt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,G.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=r;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=kn(n),this.isVariantNode=Vo(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:l,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];c[f]!==void 0&&ct(g)&&g.set(c[f])}}mount(e){this.current=e,zu.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Go.current||$u(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:xs.current,process.env.NODE_ENV!=="production"&&Rs(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),_t(this.notifyUpdate),_t(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=Re.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&G.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Ee){const n=Ee[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):J()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Zi.length;s++){const i=Zi[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=e[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=Uu(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=je(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(Br(s)||zr(s))?s=parseFloat(s):!Yl(s)&&Wt.test(n)&&(s=So(e,n)),this.setBaseTarget(e,ct(s)?s.get():s)),ct(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=si(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!ct(i)?i:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Vs),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){Xs.render(this.render)}}class Xo extends _u{constructor(){super(...arguments),this.KeyframeResolver=Fl}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;ct(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function qo(t,{style:e,vars:n},s,i){const o=t.style;let r;for(r in e)o[r]=e[r];i?.applyProjectionStyles(o,s);for(r in n)o.setProperty(r,n[r])}function Wu(t){return window.getComputedStyle(t)}class Ku extends Xo{constructor(){super(...arguments),this.type="html",this.renderInstance=qo}readValueFromInstance(e,n){if(Re.has(n))return this.projection?.isProjecting?cs(n):nl(e,n);{const s=Wu(e),i=(Ls(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Ho(e,n)}build(e,n,s){ti(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return ii(e,n,s)}}const Yo=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"]);function Hu(t,e,n,s){qo(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Yo.has(i)?i:ri(i),e.attrs[i])}class Gu extends Xo{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=J}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Re.has(n)){const s=To(n);return s&&s.default||0}return n=Yo.has(n)?n:ri(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return Bo(e,n,s)}build(e,n,s){Io(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Hu(e,n,s,i)}mount(e){this.isSVGTag=Oo(e.tagName),super.mount(e)}}const Jo=(t,e)=>ni(t)?new Gu(e):new Ku(e,{allowProjection:t!==m.Fragment});function Me(t,e,n){const s=t.getProps();return si(s,e,n!==void 0?n:s.custom,t)}const vs=t=>Array.isArray(t);function Xu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,je(n))}function qu(t){return vs(t)?t[t.length-1]||0:t}function Yu(t,e){const n=Me(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=qu(o[r]);Xu(t,r,a)}}function Ju(t){return!!(ct(t)&&t.add)}function bs(t,e){const n=t.getValue("willChange");if(Ju(n))return n.add(e);if(!n&&Ft.WillChange){const s=new Ft.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Zo(t){return t.props[$o]}const Zu=t=>t!==null;function Qu(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Zu),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const td={type:"spring",stiffness:500,damping:25,restSpeed:10},ed=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),nd={type:"keyframes",duration:.8},sd={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},id=(t,{keyframes:e})=>e.length>2?nd:Re.has(t)?t.startsWith("scale")?ed(e[1]):td:sd;function rd({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:c,elapsed:u,...l}){return!!Object.keys(l).length}const oi=(t,e,n,s={},i,o)=>r=>{const a=Hs(s,t)||{},c=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-Ct(c);const l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:i};rd(a)||Object.assign(l,id(t,l)),l.duration&&(l.duration=Ct(l.duration)),l.repeatDelay&&(l.repeatDelay=Ct(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let d=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(fs(l),l.delay===0&&(d=!0)),(Ft.instantAnimations||Ft.skipAnimations)&&(d=!0,fs(l),l.delay=0),l.allowFlatten=!a.type&&!a.ease,d&&!o&&e.get()!==void 0){const f=Qu(l.keyframes,a);if(f!==void 0){G.update(()=>{l.onUpdate(f),l.onComplete()});return}}return a.isSync?new Ws(l):new Pl(l)};function od({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Qo(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;s&&(o=s);const c=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const l in a){const d=t.getValue(l,t.latestValues[l]??null),f=a[l];if(f===void 0||u&&od(u,l))continue;const g={delay:n,...Hs(o||{},l)},x=d.get();if(x!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===x&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const y=Zo(t);if(y){const w=window.MotionHandoffAnimation(y,l,G);w!==null&&(g.startTime=w,v=!0)}}bs(t,l),d.start(oi(l,d,f,t.shouldReduceMotion&&vo.has(l)?{type:!1}:g,t,v));const A=d.animation;A&&c.push(A)}return r&&Promise.all(c).then(()=>{G.update(()=>{r&&Yu(t,r)})}),c}function ta(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,l)=>u.sortNodePosition(l)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function ws(t,e,n={}){const s=Me(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(Qo(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:l,staggerDirection:d}=i;return ad(t,e,c,u,l,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[o,r]:[r,o];return c().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function ad(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(ws(c,e,{...r,delay:n+(typeof s=="function"?0:s)+ta(t.variantChildren,c,s,i,o)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function cd(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>ws(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=ws(t,e,n);else{const i=typeof e=="function"?Me(t,e,n.custom):e;s=Promise.all(Qo(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function ea(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const ld=Qs.length;function na(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?na(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<ld;n++){const s=Qs[n],i=t.props[s];(Ye(i)||i===!1)&&(e[s]=i)}return e}const ud=[...Zs].reverse(),dd=Zs.length;function hd(t){return e=>Promise.all(e.map(({animation:n,options:s})=>cd(t,n,s)))}function fd(t){let e=hd(t),n=Qi(),s=!0;const i=c=>(u,l)=>{const d=Me(t,l,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...x}=d;u={...u,...x,...g}}return u};function o(c){e=c(t)}function r(c){const{props:u}=t,l=na(t.parent)||{},d=[],f=new Set;let g={},x=1/0;for(let A=0;A<dd;A++){const y=ud[A],w=n[y],S=u[y]!==void 0?u[y]:l[y],D=Ye(S),j=y===c?w.isActive:null;j===!1&&(x=A);let E=S===l[y]&&S!==u[y]&&D;if(E&&s&&t.manuallyAnimateOnMount&&(E=!1),w.protectedKeys={...g},!w.isActive&&j===null||!S&&!w.prevProp||En(S)||typeof S=="boolean")continue;const O=md(w.prevProp,S);let R=O||y===c&&w.isActive&&!E&&D||A>x&&D,B=!1;const Y=Array.isArray(S)?S:[S];let tt=Y.reduce(i(y),{});j===!1&&(tt={});const{prevResolvedValues:z={}}=w,ue={...z,...tt},Tt=F=>{R=!0,f.has(F)&&(B=!0,f.delete(F)),w.needsAnimating[F]=!0;const lt=t.getValue(F);lt&&(lt.liveStyle=!1)};for(const F in ue){const lt=tt[F],ut=z[F];if(g.hasOwnProperty(F))continue;let dt=!1;vs(lt)&&vs(ut)?dt=!ea(lt,ut):dt=lt!==ut,dt?lt!=null?Tt(F):f.add(F):lt!==void 0&&f.has(F)?Tt(F):w.protectedKeys[F]=!0}w.prevProp=S,w.prevResolvedValues=tt,w.isActive&&(g={...g,...tt}),s&&t.blockInitialAnimation&&(R=!1);const rt=E&&O;R&&(!rt||B)&&d.push(...Y.map(F=>{const lt={type:y};if(typeof F=="string"&&s&&!rt&&t.manuallyAnimateOnMount&&t.parent){const{parent:ut}=t,dt=Me(ut,F);if(ut.enteringChildren&&dt){const{delayChildren:ht}=dt.transition||{};lt.delay=ta(ut.enteringChildren,t,ht)}}return{animation:F,options:lt}}))}if(f.size){const A={};if(typeof u.initial!="boolean"){const y=Me(t,Array.isArray(u.initial)?u.initial[0]:u.initial);y&&y.transition&&(A.transition=y.transition)}f.forEach(y=>{const w=t.getBaseTarget(y),S=t.getValue(y);S&&(S.liveStyle=!0),A[y]=w??null}),d.push({animation:A})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(c,u){if(n[c].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(c,u)),n[c].isActive=u;const l=r(c);for(const d in n)n[d].protectedKeys={};return l}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Qi()}}}function md(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!ea(e,t):!1}function se(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Qi(){return{animate:se(!0),whileInView:se(),whileHover:se(),whileTap:se(),whileDrag:se(),whileFocus:se(),exit:se()}}class Kt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class pd extends Kt{constructor(e){super(e),e.animationState||(e.animationState=fd(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();En(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let gd=0;class yd extends Kt{constructor(){super(...arguments),this.id=gd++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const sa={animation:{Feature:pd},exit:{Feature:yd}};function Ze(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function nn(t){return{point:{x:t.pageX,y:t.pageY}}}const xd=t=>e=>qs(e)&&t(e,nn(e));function Ue(t,e,n,s){return Ze(t,e,xd(n),s)}const ia=1e-4,vd=1-ia,bd=1+ia,ra=.01,wd=0-ra,Td=0+ra;function ft(t){return t.max-t.min}function Sd(t,e,n){return Math.abs(t-e)<=n}function tr(t,e,n,s=.5){t.origin=s,t.originPoint=q(e.min,e.max,t.origin),t.scale=ft(n)/ft(e),t.translate=q(n.min,n.max,t.origin)-t.originPoint,(t.scale>=vd&&t.scale<=bd||isNaN(t.scale))&&(t.scale=1),(t.translate>=wd&&t.translate<=Td||isNaN(t.translate))&&(t.translate=0)}function _e(t,e,n,s){tr(t.x,e.x,n.x,s?s.originX:void 0),tr(t.y,e.y,n.y,s?s.originY:void 0)}function er(t,e,n){t.min=n.min+e.min,t.max=t.min+ft(e)}function Ad(t,e,n){er(t.x,e.x,n.x),er(t.y,e.y,n.y)}function nr(t,e,n){t.min=e.min-n.min,t.max=t.min+ft(e)}function We(t,e,n){nr(t.x,e.x,n.x),nr(t.y,e.y,n.y)}function vt(t){return[t("x"),t("y")]}const oa=({current:t})=>t?t.ownerDocument.defaultView:null,sr=(t,e)=>Math.abs(t-e);function Pd(t,e){const n=sr(t.x,e.x),s=sr(t.y,e.y);return Math.sqrt(n**2+s**2)}class aa{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=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 f=Xn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,x=Pd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!x)return;const{point:v}=f,{timestamp:A}=st;this.history.push({...v,timestamp:A});const{onStart:y,onMove:w}=this.handlers;g||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Gn(g,this.transformPagePoint),G.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:x,onSessionEnd:v,resumeAnimation:A}=this.handlers;if(this.dragSnapToOrigin&&A&&A(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=Xn(f.type==="pointercancel"?this.lastMoveEventInfo:Gn(g,this.transformPagePoint),this.history);this.startEvent&&x&&x(f,y),v&&v(f,y)},!qs(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const a=nn(e),c=Gn(a,this.transformPagePoint),{point:u}=c,{timestamp:l}=st;this.history=[{...u,timestamp:l}];const{onSessionStart:d}=n;d&&d(e,Xn(c,this.history)),this.removeListeners=Qe(Ue(this.contextWindow,"pointermove",this.handlePointerMove),Ue(this.contextWindow,"pointerup",this.handlePointerUp),Ue(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),_t(this.updatePoint)}}function Gn(t,e){return e?{point:e(t.point)}:t}function ir(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Xn({point:t},e){return{point:t,delta:ir(t,ca(e)),offset:ir(t,Cd(e)),velocity:Md(e,.1)}}function Cd(t){return t[0]}function ca(t){return t[t.length-1]}function Md(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=ca(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>Ct(e)));)n--;if(!s)return{x:0,y:0};const o=bt(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const r={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function jd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?q(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?q(n,t,s.max):Math.min(t,n)),t}function rr(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function Ed(t,{top:e,left:n,bottom:s,right:i}){return{x:rr(t.x,n,i),y:rr(t.y,e,s)}}function or(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function kd(t,e){return{x:or(t.x,e.x),y:or(t.y,e.y)}}function Dd(t,e){let n=.5;const s=ft(t),i=ft(e);return i>s?n=Ge(e.min,e.max-s,t.min):s>i&&(n=Ge(t.min,t.max-i,e.min)),Lt(0,1,n)}function Vd(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Ts=.35;function Rd(t=Ts){return t===!1?t=0:t===!0&&(t=Ts),{x:ar(t,"left","right"),y:ar(t,"top","bottom")}}function ar(t,e,n){return{min:cr(t,e),max:cr(t,n)}}function cr(t,e){return typeof t=="number"?t:t[e]||0}const Nd=new WeakMap;class Id{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=J(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(nn(d).point)},r=(d,f)=>{const{drag:g,dragPropagation:x,onDragStart:v}=this.getProps();if(g&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ul(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),vt(y=>{let w=this.getAxisMotionValue(y).get()||0;if(Dt.test(w)){const{projection:S}=this.visualElement;if(S&&S.layout){const D=S.layout.layoutBox[y];D&&(w=ft(D)*(parseFloat(w)/100))}}this.originPoint[y]=w}),v&&G.postRender(()=>v(d,f)),bs(this.visualElement,"transform");const{animationState:A}=this.visualElement;A&&A.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:x,onDirectionLock:v,onDrag:A}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:y}=f;if(x&&this.currentDirection===null){this.currentDirection=Ld(y),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),A&&A(d,f)},c=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>vt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:l}=this.getProps();this.panSession=new aa(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:s,contextWindow:oa(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:r}=i;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&G.postRender(()=>a(s,i))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(e,n,s){const{drag:i}=this.getProps();if(!s||!fn(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=jd(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&Te(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=Ed(s.layoutBox,e):this.constraints=!1,this.elastic=Rd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&vt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Vd(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Te(e))return!1;const s=e.current;Ot(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=Bu(s,i.root,this.visualElement.getTransformPagePoint());let r=kd(i.layout.layoutBox,o);if(n){const a=n(Lu(r));this.hasMutatedConstraints=!!a,a&&(r=_o(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=vt(l=>{if(!fn(l,n,this.currentDirection))return;let d=c&&c[l]||{};r&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,x={type:"inertia",velocity:s?e[l]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(l,x)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return bs(this.visualElement,e),s.start(oi(e,s,0,n,this.visualElement,!1))}stopAnimation(){vt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){vt(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){vt(n=>{const{drag:s}=this.getProps();if(!fn(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n];o.set(e[n]-q(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Te(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};vt(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const c=a.get();i[r]=Dd({min:c,max:c},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),vt(r=>{if(!fn(r,e,null))return;const a=this.getAxisMotionValue(r),{min:c,max:u}=this.constraints[r];a.set(q(c,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;Nd.set(this.visualElement,this);const e=this.visualElement.current,n=Ue(e,"pointerdown",c=>{const{drag:u,dragListener:l=!0}=this.getProps();u&&l&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();Te(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),G.read(s);const r=Ze(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(vt(l=>{const d=this.getAxisMotionValue(l);d&&(this.originPoint[l]+=c[l].translate,d.set(d.get()+c[l].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=Ts,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function fn(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Ld(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class Od extends Kt{constructor(e){super(e),this.removeGroupControls=wt,this.removeListeners=wt,this.controls=new Id(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||wt}unmount(){this.removeGroupControls(),this.removeListeners()}}const lr=t=>(e,n)=>{t&&G.postRender(()=>t(e,n))};class Fd extends Kt{constructor(){super(...arguments),this.removePointerDownListener=wt}onPointerDown(e){this.session=new aa(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:oa(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:lr(e),onStart:lr(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&G.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=Ue(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const vn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function ur(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Be={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(L.test(t))t=parseFloat(t);else return t;const n=ur(t,e.target.x),s=ur(t,e.target.y);return`${n}% ${s}%`}},Bd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Wt.parse(t);if(i.length>5)return s;const o=Wt.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=c;const u=q(a,c,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}};let qn=!1;class $d extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;uu(zd),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),qn&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),vn.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,qn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||G.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Xs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;qn=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function la(t){const[e,n]=ko(),s=m.useContext(Cs);return h.jsx($d,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(zo),isPresent:e,safeToRemove:n})}const zd={borderRadius:{...Be,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Be,borderTopRightRadius:Be,borderBottomLeftRadius:Be,borderBottomRightRadius:Be,boxShadow:Bd};function Ud(t,e,n){const s=ct(t)?t:je(t);return s.start(oi("",s,e,n)),s.animation}const _d=(t,e)=>t.depth-e.depth;class Wd{constructor(){this.children=[],this.isDirty=!1}add(e){Es(this.children,e),this.isDirty=!0}remove(e){ks(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(_d),this.isDirty=!1,this.children.forEach(e)}}function Kd(t,e){const n=mt.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(_t(s),t(o-e))};return G.setup(s,!0),()=>_t(s)}const ua=["TopLeft","TopRight","BottomLeft","BottomRight"],Hd=ua.length,dr=t=>typeof t=="string"?parseFloat(t):t,hr=t=>typeof t=="number"||L.test(t);function Gd(t,e,n,s,i,o){i?(t.opacity=q(0,n.opacity??1,Xd(s)),t.opacityExit=q(e.opacity??1,0,qd(s))):o&&(t.opacity=q(e.opacity??1,n.opacity??1,s));for(let r=0;r<Hd;r++){const a=`border${ua[r]}Radius`;let c=fr(e,a),u=fr(n,a);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||hr(c)===hr(u)?(t[a]=Math.max(q(dr(c),dr(u),s),0),(Dt.test(u)||Dt.test(c))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=q(e.rotate||0,n.rotate||0,s))}function fr(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Xd=da(0,.5,qr),qd=da(.5,.95,wt);function da(t,e,n){return s=>s<t?0:s>e?1:n(Ge(t,e,s))}function mr(t,e){t.min=e.min,t.max=e.max}function xt(t,e){mr(t.x,e.x),mr(t.y,e.y)}function pr(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function gr(t,e,n,s,i){return t-=e,t=Cn(t,1/n,s),i!==void 0&&(t=Cn(t,1/i,s)),t}function Yd(t,e=0,n=1,s=.5,i,o=t,r=t){if(Dt.test(e)&&(e=parseFloat(e),e=q(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=q(o.min,o.max,s);t===o&&(a-=e),t.min=gr(t.min,e,n,a,i),t.max=gr(t.max,e,n,a,i)}function yr(t,e,[n,s,i],o,r){Yd(t,e[n],e[s],e[i],e.scale,o,r)}const Jd=["x","scaleX","originX"],Zd=["y","scaleY","originY"];function xr(t,e,n,s){yr(t.x,e,Jd,n?n.x:void 0,s?s.x:void 0),yr(t.y,e,Zd,n?n.y:void 0,s?s.y:void 0)}function vr(t){return t.translate===0&&t.scale===1}function ha(t){return vr(t.x)&&vr(t.y)}function br(t,e){return t.min===e.min&&t.max===e.max}function Qd(t,e){return br(t.x,e.x)&&br(t.y,e.y)}function wr(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function fa(t,e){return wr(t.x,e.x)&&wr(t.y,e.y)}function Tr(t){return ft(t.x)/ft(t.y)}function Sr(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class th{constructor(){this.members=[]}add(e){Es(this.members,e),e.scheduleRender()}remove(e){if(ks(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function eh(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:l,rotateX:d,rotateY:f,skewX:g,skewY:x}=n;u&&(s=`perspective(${u}px) ${s}`),l&&(s+=`rotate(${l}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),x&&(s+=`skewY(${x}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(s+=`scale(${a}, ${c})`),s||"none"}const Yn=["","X","Y","Z"],nh=1e3;let sh=0;function Jn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function ma(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Zo(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",G,!(i||o))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&ma(s)}function pa({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=sh++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(oh),this.nodes.forEach(uh),this.nodes.forEach(dh),this.nodes.forEach(ah)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Wd)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new Vs),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const c=this.eventHandlers.get(r);c&&c.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=Eo(r)&&!Xl(r),this.instance=r;const{layoutId:a,layout:c,visualElement:u}=this.options;if(u&&!u.current&&u.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let l,d=0;const f=()=>this.root.updateBlockedByResize=!1;G.read(()=>{d=window.innerWidth}),t(r,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,l&&l(),l=Kd(f,250),vn.hasAnimatedSinceResize&&(vn.hasAnimatedSinceResize=!1,this.nodes.forEach(Cr)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||c)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||u.getDefaultTransition()||gh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:A}=u.getProps(),y=!this.targetLayout||!fa(this.targetLayout,g),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...Hs(x,"layout"),onPlay:v,onComplete:A};(u.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(l,w)}else d||Cr(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),_t(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(hh),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&ma(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const d=this.path[l];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Ar);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Pr);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(lh),this.nodes.forEach(ih),this.nodes.forEach(rh)):this.nodes.forEach(Pr),this.clearAllSnapshots();const a=mt.now();st.delta=Lt(0,1e3/60,a-st.timestamp),st.timestamp=a,st.isProcessing=!0,Bn.update.process(st),Bn.preRender.process(st),Bn.render.process(st),st.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Xs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(ch),this.sharedNodes.forEach(fh)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,G.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){G.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ft(this.snapshot.measuredBox.x)&&!ft(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutCorrected=J(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&this.instance){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!ha(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,l=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||re(this.latestValues)||l)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return r&&(c=this.removeTransform(c)),yh(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return J();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(xh))){const{scroll:u}=this.root;u&&(Se(a.x,u.offset.x),Se(a.y,u.offset.y))}return a}removeElementScroll(r){const a=J();if(xt(a,r),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:l,options:d}=u;u!==this.root&&l&&d.layoutScroll&&(l.wasRoot&&xt(a,r),Se(a.x,l.offset.x),Se(a.y,l.offset.y))}return a}applyTransform(r,a=!1){const c=J();xt(c,r);for(let u=0;u<this.path.length;u++){const l=this.path[u];!a&&l.options.layoutScroll&&l.scroll&&l!==l.root&&Ae(c,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),re(l.latestValues)&&Ae(c,l.latestValues)}return re(this.latestValues)&&Ae(c,this.latestValues),c}removeTransform(r){const a=J();xt(a,r);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!re(u.latestValues))continue;gs(u.latestValues)&&u.updateSnapshot();const l=J(),d=u.measurePageBox();xt(l,d),xr(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,l)}return re(this.latestValues)&&xr(a,this.latestValues),a}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==st.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(r||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:l,layoutId:d}=this.options;if(!(!this.layout||!(l||d))){if(this.resolvedRelativeTargetAt=st.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=J(),this.relativeTargetOrigin=J(),We(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=J(),this.targetWithTransforms=J()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Ad(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):xt(this.target,this.layout.layoutBox),Ko(this.target,this.targetDelta)):xt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=J(),this.relativeTargetOrigin=J(),We(this.relativeTargetOrigin,this.target,f.target),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||gs(this.parent.latestValues)||Wo(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const r=this.getLead(),a=!!this.resumingFrom||this!==r;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===st.timestamp&&(c=!1),c)return;const{layout:u,layoutId:l}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||l))return;xt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;Fu(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=J());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(pr(this.prevProjectionDelta.x,this.projectionDelta.x),pr(this.prevProjectionDelta.y,this.projectionDelta.y)),_e(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Sr(this.projectionDelta.x,this.prevProjectionDelta.x)||!Sr(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){if(this.options.visualElement?.scheduleRender(),r){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Pe(),this.projectionDelta=Pe(),this.projectionDeltaWithTransform=Pe()}setAnimationOrigin(r,a=!1){const c=this.snapshot,u=c?c.latestValues:{},l={...this.latestValues},d=Pe();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=J(),g=c?c.source:void 0,x=this.layout?this.layout.source:void 0,v=g!==x,A=this.getStack(),y=!A||A.members.length<=1,w=!!(v&&!y&&this.options.crossfade===!0&&!this.path.some(ph));this.animationProgress=0;let S;this.mixTargetDelta=D=>{const j=D/1e3;Mr(d.x,r.x,j),Mr(d.y,r.y,j),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(We(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),mh(this.relativeTarget,this.relativeTargetOrigin,f,j),S&&Qd(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=J()),xt(S,this.relativeTarget)),v&&(this.animationValues=l,Gd(l,u,this.latestValues,j,w,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=j},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(_t(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=G.update(()=>{vn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=je(0)),this.currentAnimation=Ud(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),r.onUpdate&&r.onUpdate(a)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(nh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:c,layout:u,latestValues:l}=r;if(!(!a||!c||!u)){if(this!==r&&this.layout&&u&&ga(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||J();const d=ft(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+d;const f=ft(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+f}xt(a,c),Ae(a,l),_e(this.projectionDeltaWithTransform,this.layoutCorrected,a,l)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new th),this.sharedNodes.get(r).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const u={};c.z&&Jn("z",r,u,this.animationValues);for(let l=0;l<Yn.length;l++)Jn(`rotate${Yn[l]}`,r,u,this.animationValues),Jn(`skew${Yn[l]}`,r,u,this.animationValues);r.render();for(const l in u)r.setStaticValue(l,u[l]),this.animationValues&&(this.animationValues[l]=u[l]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=yn(a?.pointerEvents)||"",r.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=yn(a?.pointerEvents)||""),this.hasProjected&&!re(this.latestValues)&&(r.transform=c?c({},""):"none",this.hasProjected=!1);return}r.visibility="";const l=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=eh(this.projectionDeltaWithTransform,this.treeScale,l);c&&(d=c(l,d)),r.transform=d;const{x:f,y:g}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?r.opacity=u===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:r.opacity=u===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const x in Je){if(l[x]===void 0)continue;const{correct:v,applyTo:A,isCSSVariable:y}=Je[x],w=d==="none"?l[x]:v(l[x],u);if(A){const S=A.length;for(let D=0;D<S;D++)r[A[D]]=w}else y?this.options.visualElement.renderState.vars[x]=w:r[x]=w}this.options.layoutId&&(r.pointerEvents=u===this?yn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(Ar),this.root.sharedNodes.clear()}}}function ih(t){t.updateLayout()}function rh(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(d);d.min=n[l].min,d.max=d.min+f}):ga(i,e.layoutBox,n)&&vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(n[l]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[l].max=t.relativeTarget[l].min+f)});const r=Pe();_e(r,n,e.layoutBox);const a=Pe();o?_e(a,t.applyTransform(s,!0),e.measuredBox):_e(a,n,e.layoutBox);const c=!ha(r);let u=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:d,layout:f}=l;if(d&&f){const g=J();We(g,e.layoutBox,d.layoutBox);const x=J();We(x,n,f.layoutBox),fa(g,x)||(u=!0),l.options.layoutRoot&&(t.relativeTarget=x,t.relativeTargetOrigin=g,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function oh(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function ah(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function ch(t){t.clearSnapshot()}function Ar(t){t.clearMeasurements()}function Pr(t){t.isLayoutDirty=!1}function lh(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Cr(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function uh(t){t.resolveTargetDelta()}function dh(t){t.calcProjection()}function hh(t){t.resetSkewAndRotation()}function fh(t){t.removeLeadSnapshot()}function Mr(t,e,n){t.translate=q(e.translate,0,n),t.scale=q(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function jr(t,e,n,s){t.min=q(e.min,n.min,s),t.max=q(e.max,n.max,s)}function mh(t,e,n,s){jr(t.x,e.x,n.x,s),jr(t.y,e.y,n.y,s)}function ph(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const gh={duration:.45,ease:[.4,0,.1,1]},Er=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),kr=Er("applewebkit/")&&!Er("chrome/")?Math.round:wt;function Dr(t){t.min=kr(t.min),t.max=kr(t.max)}function yh(t){Dr(t.x),Dr(t.y)}function ga(t,e,n){return t==="position"||t==="preserve-aspect"&&!Sd(Tr(e),Tr(n),.2)}function xh(t){return t!==t.root&&t.scroll?.wasRoot}const vh=pa({attachResizeListener:(t,e)=>Ze(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Zn={current:void 0},ya=pa({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Zn.current){const t=new vh({});t.mount(window),t.setOptions({layoutScroll:!0}),Zn.current=t}return Zn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),bh={pan:{Feature:Fd},drag:{Feature:Od,ProjectionNode:ya,MeasureLayout:la}};function Vr(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&G.postRender(()=>o(e,nn(e)))}class wh extends Kt{mount(){const{current:e}=this.node;e&&(this.unmount=_l(e,(n,s)=>(Vr(this.node,s,"Start"),i=>Vr(this.node,i,"End"))))}unmount(){}}class Th extends Kt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!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=Qe(Ze(this.node.current,"focus",()=>this.onFocus()),Ze(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Rr(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&G.postRender(()=>o(e,nn(e)))}class Sh extends Kt{mount(){const{current:e}=this.node;e&&(this.unmount=Gl(e,(n,s)=>(Rr(this.node,s,"Start"),(i,{success:o})=>Rr(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Ss=new WeakMap,Qn=new WeakMap,Ah=t=>{const e=Ss.get(t.target);e&&e(t)},Ph=t=>{t.forEach(Ah)};function Ch({root:t,...e}){const n=t||document;Qn.has(n)||Qn.set(n,{});const s=Qn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(Ph,{root:t,...e})),s[i]}function Mh(t,e,n){const s=Ch(e);return Ss.set(t,n),s.observe(t),()=>{Ss.delete(t),s.unobserve(t)}}const jh={some:0,all:1};class Eh extends Kt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:jh[i]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:l,onViewportLeave:d}=this.node.getProps(),f=u?l:d;f&&f(c)};return Mh(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(kh(e,n))&&this.startObserver()}unmount(){}}function kh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const xa={inView:{Feature:Eh},tap:{Feature:Sh},focus:{Feature:Th},hover:{Feature:wh}},Dh={layout:{ProjectionNode:ya,MeasureLayout:la}},Vh={...sa,...xa,...bh,...Dh},Rh=Iu(Vh,Jo),Nh={renderer:Jo,...sa,...xa};function va(t,e){return xn(t,e)}const mn=va("div"),Ih=va("p"),kt=Symbol.for("@arcteninc/core:originalName");function Lh(t,e){return t[kt]=e,t}function Oh(t,e,n,s){if(typeof t!="function")return null;const i=t[kt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const o=t.name;let r;if(o&&(r=e[o],r&&!n.has(r.name)))return t[kt]=r.name,{fn:t,meta:r};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(r=e[a],r))return t[kt]=r.name,{fn:t,meta:r}}else if(r=Object.values(e).find(c=>!n.has(c.name)),r)return t[kt]=r.name,{fn:t,meta:r};return null}function ba(t,e){let n,s;if(!e)throw new Error(`❌ toolMetadata is required!
9
+ `),()=>{A.contains(v)&&A.removeChild(v)}},[e]),h.jsx(tu,{isPresent:e,childRef:o,sizeRef:r,children:Pt.cloneElement(t,{ref:c})})}const nu=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:a,root:c})=>{const u=ks(su),l=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:l,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const x of u.values())if(!x)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return o&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,x)=>u.set(x,!1))},[n]),Pt.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),r==="popLayout"&&(t=h.jsx(eu,{isPresent:n,anchorX:a,root:c,children:t})),h.jsx(Dn.Provider,{value:f,children:t})};function su(){return new Map}function Do(t=!0){const e=m.useContext(Dn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=m.useId();m.useEffect(()=>{if(t)return i(o)},[t]);const r=m.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const gn=t=>t.key||"";function Ui(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const iu=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:c})=>{const[u,l]=Do(r),d=m.useMemo(()=>Ui(t),[t]),f=r&&!u?[]:d.map(gn),g=m.useRef(!0),x=m.useRef(d),v=ks(()=>new Map),[A,y]=m.useState(d),[w,T]=m.useState(d);Br(()=>{g.current=!1,x.current=d;for(let E=0;E<w.length;E++){const O=gn(w[E]);f.includes(O)?v.delete(O):v.get(O)!==!0&&v.set(O,!1)}},[w,f.length,f.join("-")]);const D=[];if(d!==A){let E=[...d];for(let O=0;O<w.length;O++){const R=w[O],$=gn(R);f.includes($)||(E.splice(O,0,R),D.push(R))}return o==="wait"&&D.length&&(E=D),T(Ui(E)),y(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&w.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:j}=m.useContext(Es);return h.jsx(h.Fragment,{children:w.map(E=>{const O=gn(E),R=r&&!u?!1:d===w||f.includes(O),$=()=>{if(v.has(O))v.set(O,!0);else return;let q=!0;v.forEach(Q=>{Q||(q=!1)}),q&&(j?.(),T(x.current),r&&l?.(),s&&s())};return h.jsx(nu,{isPresent:R,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:o,root:c,onExitComplete:R?void 0:$,anchorX:a,children:E},O)})})},ti=m.createContext({strict:!1}),_i={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Ee={};for(const t in _i)Ee[t]={isEnabled:e=>_i[t].some(n=>!!e[n])};function xs(t){for(const e in t)Ee[e]={...Ee[e],...t[e]}}function ru({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!Xn(e)),i=m.useRef(void 0);if(!Xn(e)){const{renderer:o,...r}=e;i.current=o,xs(r)}return m.useEffect(()=>{Xn(e)&&e().then(({renderer:o,...r})=>{xs(r),i.current=o,s(!0)})},[]),h.jsx(ti.Provider,{value:{renderer:i.current,strict:n},children:t})}function Xn(t){return typeof t=="function"}const ou=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function En(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||ou.has(t)}let Vo=t=>!En(t);function au(t){typeof t=="function"&&(Vo=e=>e.startsWith("on")?!En(e):t(e))}try{au(require("@emotion/is-prop-valid").default)}catch{}function cu(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(Vo(i)||n===!0&&En(i)||!e&&!En(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const Vn=m.createContext({});function Rn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Qe(t){return typeof t=="string"||Array.isArray(t)}const ei=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],ni=["initial",...ei];function Nn(t){return Rn(t.animate)||ni.some(e=>Qe(t[e]))}function Ro(t){return!!(Nn(t)||t.variants)}function lu(t,e){if(Nn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Qe(n)?n:void 0,animate:Qe(s)?s:void 0}}return t.inherit!==!1?e:{}}function uu(t){const{initial:e,animate:n}=lu(t,m.useContext(Vn));return m.useMemo(()=>({initial:e,animate:n}),[Wi(e),Wi(n)])}function Wi(t){return Array.isArray(t)?t.join(" "):t}const tn={};function du(t){for(const e in t)tn[e]=t[e],Bs(e)&&(tn[e].isCSSVariable=!0)}function No(t,{layout:e,layoutId:n}){return Re.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!tn[t]||t==="opacity")}const hu={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},fu=Ve.length;function mu(t,e,n){let s="",i=!0;for(let o=0;o<fu;o++){const r=Ve[o],a=t[r];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(r.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const u=Po(a,Ys[r]);if(!c){i=!1;const l=hu[r]||r;s+=`${l}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function si(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const c in e){const u=e[c];if(Re.has(c)){r=!0;continue}else if(Bs(c)){i[c]=u;continue}else{const l=Po(u,Ys[c]);c.startsWith("origin")?(a=!0,o[c]=l):s[c]=l}}if(e.transform||(r||n?s.transform=mu(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:c="50%",originY:u="50%",originZ:l=0}=o;s.transformOrigin=`${c} ${u} ${l}`}}const ii=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Io(t,e,n){for(const s in e)!at(e[s])&&!No(s,n)&&(t[s]=e[s])}function pu({transformTemplate:t},e){return m.useMemo(()=>{const n=ii();return si(n,e,t),Object.assign({},n.vars,n.style)},[e])}function gu(t,e){const n=t.style||{},s={};return Io(s,n,t),Object.assign(s,pu(t,e)),s}function yu(t,e){const n={},s=gu(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const xu={offset:"stroke-dashoffset",array:"stroke-dasharray"},vu={offset:"strokeDashoffset",array:"strokeDasharray"};function bu(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?xu:vu;t[o.offset]=L.transform(-s);const r=L.transform(e),a=L.transform(n);t[o.array]=`${r} ${a}`}function Lo(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},c,u,l){if(si(t,a,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=l?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&bu(d,i,o,r,!1)}const Oo=()=>({...ii(),attrs:{}}),Fo=t=>typeof t=="string"&&t.toLowerCase()==="svg";function wu(t,e,n,s){const i=m.useMemo(()=>{const o=Oo();return Lo(o,e,Fo(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};Io(o,t.style,t),i.style={...o,...i.style}}return i}const Tu=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function ri(t){return typeof t!="string"||t.includes("-")?!1:!!(Tu.indexOf(t)>-1||/[A-Z]/u.test(t))}function Su(t,e,n,{latestValues:s},i,o=!1){const a=(ri(t)?wu:yu)(e,s,i,t),c=cu(e,typeof t=="string",o),u=t!==m.Fragment?{...c,...a,ref:n}:{},{children:l}=e,d=m.useMemo(()=>at(l)?l.get():l,[l]);return m.createElement(t,{...u,children:d})}function Ki(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function oi(t,e,n,s){if(typeof e=="function"){const[i,o]=Ki(s);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=Ki(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function wn(t){return at(t)?t.get():t}function Au({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:Pu(n,s,i,t),renderState:e()}}function Pu(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=wn(o[f]);let{initial:r,animate:a}=t;const c=Nn(t),u=Ro(t);e&&u&&!c&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let l=n?n.initial===!1:!1;l=l||r===!1;const d=l?a:r;if(d&&typeof d!="boolean"&&!Rn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const x=oi(t,f[g]);if(x){const{transitionEnd:v,transition:A,...y}=x;for(const w in y){let T=y[w];if(Array.isArray(T)){const D=l?T.length-1:0;T=T[D]}T!==null&&(i[w]=T)}for(const w in v)i[w]=v[w]}}}return i}const Bo=t=>(e,n)=>{const s=m.useContext(Vn),i=m.useContext(Dn),o=()=>Au(t,e,s,i);return n?o():ks(o)};function ai(t,e,n){const{style:s}=t,i={};for(const o in s)(at(s[o])||e.style&&at(e.style[o])||No(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const Cu=Bo({scrapeMotionValuesFromProps:ai,createRenderState:ii});function $o(t,e,n){const s=ai(t,e,n);for(const i in t)if(at(t[i])||at(e[i])){const o=Ve.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const Mu=Bo({scrapeMotionValuesFromProps:$o,createRenderState:Oo}),ju=Symbol.for("motionComponentSymbol");function Te(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Eu(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):Te(n)&&(n.current=s))},[e])}const ci=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),ku="framerAppearId",zo="data-"+ci(ku),Uo=m.createContext({});function Du(t,e,n,s,i){const{visualElement:o}=m.useContext(Vn),r=m.useContext(ti),a=m.useContext(Dn),c=m.useContext(Qs).reducedMotion,u=m.useRef(null);s=s||r.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const l=u.current,d=m.useContext(Uo);l&&!l.projection&&i&&(l.type==="html"||l.type==="svg")&&Vu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{l&&f.current&&l.update(n,a)});const g=n[zo],x=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return Br(()=>{l&&(f.current=!0,window.MotionIsMounted=!0,l.updateFeatures(),l.scheduleRenderMicrotask(),x.current&&l.animationState&&l.animationState.animateChanges())}),m.useEffect(()=>{l&&(!x.current&&l.animationState&&l.animationState.animateChanges(),x.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),x.current=!1),l.enteringChildren=void 0)}),l}function Vu(t,e,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:l}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:_o(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&Te(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:c,layoutRoot:u})}function _o(t){if(t)return t.options.allowProjection!==!1?t.projection:_o(t.parent)}function Tn(t,{forwardMotionProps:e=!1}={},n,s){n&&xs(n);const i=ri(t)?Mu:Cu;function o(a,c){let u;const l={...m.useContext(Qs),...a,layoutId:Ru(a)},{isStatic:d}=l,f=uu(a),g=i(a,d);if(!d&&Ds){Nu(l,n);const x=Iu(l);u=x.MeasureLayout,f.visualElement=Du(t,g,l,s,x.ProjectionNode)}return h.jsxs(Vn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...l}):null,Su(t,a,Eu(g,f.visualElement,c),g,d,e)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const r=m.forwardRef(o);return r[ju]=t,r}function Ru({layoutId:t}){const e=m.useContext(Es).id;return e&&t!==void 0?e+"-"+t:t}function Nu(t,e){const n=m.useContext(ti).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?ke(!1,s,"lazy-strict-mode"):Ot(!1,s,"lazy-strict-mode")}}function Iu(t){const{drag:e,layout:n}=Ee;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Lu(t,e){if(typeof Proxy>"u")return Tn;const n=new Map,s=(o,r)=>Tn(o,r,t,e),i=(o,r)=>(process.env.NODE_ENV!=="production"&&Ls(!1,"motion() is deprecated. Use motion.create() instead."),s(o,r));return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,Tn(r,void 0,t,e)),n.get(r))})}function Wo({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function Ou({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function Fu(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function qn(t){return t===void 0||t===1}function vs({scale:t,scaleX:e,scaleY:n}){return!qn(t)||!qn(e)||!qn(n)}function oe(t){return vs(t)||Ko(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Ko(t){return Hi(t.x)||Hi(t.y)}function Hi(t){return t&&t!=="0%"}function kn(t,e,n){const s=t-n,i=e*s;return n+i}function Gi(t,e,n,s,i){return i!==void 0&&(t=kn(t,i,s)),kn(t,n,s)+e}function bs(t,e=0,n=1,s,i){t.min=Gi(t.min,e,n,s,i),t.max=Gi(t.max,e,n,s,i)}function Ho(t,{x:e,y:n}){bs(t.x,e.translate,e.scale,e.originPoint),bs(t.y,n.translate,n.scale,n.originPoint)}const Xi=.999999999999,qi=1.0000000000001;function Bu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,r;for(let a=0;a<i;a++){o=n[a],r=o.projectionDelta;const{visualElement:c}=o.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&Ae(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,Ho(t,r)),s&&oe(o.latestValues)&&Ae(t,o.latestValues))}e.x<qi&&e.x>Xi&&(e.x=1),e.y<qi&&e.y>Xi&&(e.y=1)}function Se(t,e){t.min=t.min+e,t.max=t.max+e}function Yi(t,e,n,s,i=.5){const o=X(t.min,t.max,i);bs(t,e,n,o,s)}function Ae(t,e){Yi(t.x,e.x,e.scaleX,e.scale,e.originX),Yi(t.y,e.y,e.scaleY,e.scale,e.originY)}function Go(t,e){return Wo(Fu(t.getBoundingClientRect(),e))}function $u(t,e,n){const s=Go(t,n),{scroll:i}=e;return i&&(Se(s.x,i.offset.x),Se(s.y,i.offset.y)),s}const Ji=()=>({translate:0,scale:1,origin:0,originPoint:0}),Pe=()=>({x:Ji(),y:Ji()}),Zi=()=>({min:0,max:0}),Y=()=>({x:Zi(),y:Zi()}),ws={current:null},Xo={current:!1};function zu(){if(Xo.current=!0,!!Ds)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>ws.current=t.matches;t.addEventListener("change",e),e()}else ws.current=!1}const Uu=new WeakMap;function _u(t,e,n){for(const s in e){const i=e[s],o=n[s];if(at(i))t.addValue(s,i);else if(at(o))t.addValue(s,je(i,{owner:t}));else if(o!==i)if(t.hasValue(s)){const r=t.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=t.getStaticValue(s);t.addValue(s,je(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Qi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Wu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Xs,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=mt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,H.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=r;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=Nn(n),this.isVariantNode=Ro(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:l,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];c[f]!==void 0&&at(g)&&g.set(c[f])}}mount(e){this.current=e,Uu.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Xo.current||zu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:ws.current,process.env.NODE_ENV!=="production"&&Ls(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Wt(this.notifyUpdate),Wt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=Re.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&H.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Ee){const n=Ee[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Y()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Qi.length;s++){const i=Qi[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=e[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=_u(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=je(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&($r(s)||Ur(s))?s=parseFloat(s):!Jl(s)&&Kt.test(n)&&(s=Ao(e,n)),this.setBaseTarget(e,at(s)?s.get():s)),at(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=oi(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!at(i)?i:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Is),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){Js.render(this.render)}}class qo extends Wu{constructor(){super(...arguments),this.KeyframeResolver=Bl}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;at(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Yo(t,{style:e,vars:n},s,i){const o=t.style;let r;for(r in e)o[r]=e[r];i?.applyProjectionStyles(o,s);for(r in n)o.setProperty(r,n[r])}function Ku(t){return window.getComputedStyle(t)}class Hu extends qo{constructor(){super(...arguments),this.type="html",this.renderInstance=Yo}readValueFromInstance(e,n){if(Re.has(n))return this.projection?.isProjecting?ds(n):sl(e,n);{const s=Ku(e),i=(Bs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Go(e,n)}build(e,n,s){si(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return ai(e,n,s)}}const Jo=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"]);function Gu(t,e,n,s){Yo(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Jo.has(i)?i:ci(i),e.attrs[i])}class Xu extends qo{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Y}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Re.has(n)){const s=So(n);return s&&s.default||0}return n=Jo.has(n)?n:ci(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return $o(e,n,s)}build(e,n,s){Lo(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Gu(e,n,s,i)}mount(e){this.isSVGTag=Fo(e.tagName),super.mount(e)}}const Zo=(t,e)=>ri(t)?new Xu(e):new Hu(e,{allowProjection:t!==m.Fragment});function Me(t,e,n){const s=t.getProps();return oi(s,e,n!==void 0?n:s.custom,t)}const Ts=t=>Array.isArray(t);function qu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,je(n))}function Yu(t){return Ts(t)?t[t.length-1]||0:t}function Ju(t,e){const n=Me(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=Yu(o[r]);qu(t,r,a)}}function Zu(t){return!!(at(t)&&t.add)}function Ss(t,e){const n=t.getValue("willChange");if(Zu(n))return n.add(e);if(!n&&Ft.WillChange){const s=new Ft.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Qo(t){return t.props[zo]}const Qu=t=>t!==null;function td(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Qu),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const ed={type:"spring",stiffness:500,damping:25,restSpeed:10},nd=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),sd={type:"keyframes",duration:.8},id={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},rd=(t,{keyframes:e})=>e.length>2?sd:Re.has(t)?t.startsWith("scale")?nd(e[1]):ed:id;function od({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:c,elapsed:u,...l}){return!!Object.keys(l).length}const li=(t,e,n,s={},i,o)=>r=>{const a=qs(s,t)||{},c=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-Ct(c);const l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:i};od(a)||Object.assign(l,rd(t,l)),l.duration&&(l.duration=Ct(l.duration)),l.repeatDelay&&(l.repeatDelay=Ct(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let d=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(gs(l),l.delay===0&&(d=!0)),(Ft.instantAnimations||Ft.skipAnimations)&&(d=!0,gs(l),l.delay=0),l.allowFlatten=!a.type&&!a.ease,d&&!o&&e.get()!==void 0){const f=td(l.keyframes,a);if(f!==void 0){H.update(()=>{l.onUpdate(f),l.onComplete()});return}}return a.isSync?new Gs(l):new Cl(l)};function ad({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function ta(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;s&&(o=s);const c=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const l in a){const d=t.getValue(l,t.latestValues[l]??null),f=a[l];if(f===void 0||u&&ad(u,l))continue;const g={delay:n,...qs(o||{},l)},x=d.get();if(x!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===x&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const y=Qo(t);if(y){const w=window.MotionHandoffAnimation(y,l,H);w!==null&&(g.startTime=w,v=!0)}}Ss(t,l),d.start(li(l,d,f,t.shouldReduceMotion&&bo.has(l)?{type:!1}:g,t,v));const A=d.animation;A&&c.push(A)}return r&&Promise.all(c).then(()=>{H.update(()=>{r&&Ju(t,r)})}),c}function ea(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,l)=>u.sortNodePosition(l)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function As(t,e,n={}){const s=Me(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(ta(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:l,staggerDirection:d}=i;return cd(t,e,c,u,l,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[o,r]:[r,o];return c().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function cd(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(As(c,e,{...r,delay:n+(typeof s=="function"?0:s)+ea(t.variantChildren,c,s,i,o)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function ld(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>As(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=As(t,e,n);else{const i=typeof e=="function"?Me(t,e,n.custom):e;s=Promise.all(ta(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function na(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const ud=ni.length;function sa(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?sa(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<ud;n++){const s=ni[n],i=t.props[s];(Qe(i)||i===!1)&&(e[s]=i)}return e}const dd=[...ei].reverse(),hd=ei.length;function fd(t){return e=>Promise.all(e.map(({animation:n,options:s})=>ld(t,n,s)))}function md(t){let e=fd(t),n=tr(),s=!0;const i=c=>(u,l)=>{const d=Me(t,l,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...x}=d;u={...u,...x,...g}}return u};function o(c){e=c(t)}function r(c){const{props:u}=t,l=sa(t.parent)||{},d=[],f=new Set;let g={},x=1/0;for(let A=0;A<hd;A++){const y=dd[A],w=n[y],T=u[y]!==void 0?u[y]:l[y],D=Qe(T),j=y===c?w.isActive:null;j===!1&&(x=A);let E=T===l[y]&&T!==u[y]&&D;if(E&&s&&t.manuallyAnimateOnMount&&(E=!1),w.protectedKeys={...g},!w.isActive&&j===null||!T&&!w.prevProp||Rn(T)||typeof T=="boolean")continue;const O=pd(w.prevProp,T);let R=O||y===c&&w.isActive&&!E&&D||A>x&&D,$=!1;const q=Array.isArray(T)?T:[T];let Q=q.reduce(i(y),{});j===!1&&(Q={});const{prevResolvedValues:z={}}=w,de={...z,...Q},Tt=F=>{R=!0,f.has(F)&&($=!0,f.delete(F)),w.needsAnimating[F]=!0;const ct=t.getValue(F);ct&&(ct.liveStyle=!1)};for(const F in de){const ct=Q[F],lt=z[F];if(g.hasOwnProperty(F))continue;let ut=!1;Ts(ct)&&Ts(lt)?ut=!na(ct,lt):ut=ct!==lt,ut?ct!=null?Tt(F):f.add(F):ct!==void 0&&f.has(F)?Tt(F):w.protectedKeys[F]=!0}w.prevProp=T,w.prevResolvedValues=Q,w.isActive&&(g={...g,...Q}),s&&t.blockInitialAnimation&&(R=!1);const it=E&&O;R&&(!it||$)&&d.push(...q.map(F=>{const ct={type:y};if(typeof F=="string"&&s&&!it&&t.manuallyAnimateOnMount&&t.parent){const{parent:lt}=t,ut=Me(lt,F);if(lt.enteringChildren&&ut){const{delayChildren:dt}=ut.transition||{};ct.delay=ea(lt.enteringChildren,t,dt)}}return{animation:F,options:ct}}))}if(f.size){const A={};if(typeof u.initial!="boolean"){const y=Me(t,Array.isArray(u.initial)?u.initial[0]:u.initial);y&&y.transition&&(A.transition=y.transition)}f.forEach(y=>{const w=t.getBaseTarget(y),T=t.getValue(y);T&&(T.liveStyle=!0),A[y]=w??null}),d.push({animation:A})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(c,u){if(n[c].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(c,u)),n[c].isActive=u;const l=r(c);for(const d in n)n[d].protectedKeys={};return l}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=tr()}}}function pd(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!na(e,t):!1}function ie(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function tr(){return{animate:ie(!0),whileInView:ie(),whileHover:ie(),whileTap:ie(),whileDrag:ie(),whileFocus:ie(),exit:ie()}}class Ht{constructor(e){this.isMounted=!1,this.node=e}update(){}}class gd extends Ht{constructor(e){super(e),e.animationState||(e.animationState=md(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Rn(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let yd=0;class xd extends Ht{constructor(){super(...arguments),this.id=yd++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const ia={animation:{Feature:gd},exit:{Feature:xd}};function en(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function on(t){return{point:{x:t.pageX,y:t.pageY}}}const vd=t=>e=>Zs(e)&&t(e,on(e));function Ke(t,e,n,s){return en(t,e,vd(n),s)}const ra=1e-4,bd=1-ra,wd=1+ra,oa=.01,Td=0-oa,Sd=0+oa;function ft(t){return t.max-t.min}function Ad(t,e,n){return Math.abs(t-e)<=n}function er(t,e,n,s=.5){t.origin=s,t.originPoint=X(e.min,e.max,t.origin),t.scale=ft(n)/ft(e),t.translate=X(n.min,n.max,t.origin)-t.originPoint,(t.scale>=bd&&t.scale<=wd||isNaN(t.scale))&&(t.scale=1),(t.translate>=Td&&t.translate<=Sd||isNaN(t.translate))&&(t.translate=0)}function He(t,e,n,s){er(t.x,e.x,n.x,s?s.originX:void 0),er(t.y,e.y,n.y,s?s.originY:void 0)}function nr(t,e,n){t.min=n.min+e.min,t.max=t.min+ft(e)}function Pd(t,e,n){nr(t.x,e.x,n.x),nr(t.y,e.y,n.y)}function sr(t,e,n){t.min=e.min-n.min,t.max=t.min+ft(e)}function Ge(t,e,n){sr(t.x,e.x,n.x),sr(t.y,e.y,n.y)}function vt(t){return[t("x"),t("y")]}const aa=({current:t})=>t?t.ownerDocument.defaultView:null,ir=(t,e)=>Math.abs(t-e);function Cd(t,e){const n=ir(t.x,e.x),s=ir(t.y,e.y);return Math.sqrt(n**2+s**2)}class ca{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=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 f=Jn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,x=Cd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!x)return;const{point:v}=f,{timestamp:A}=nt;this.history.push({...v,timestamp:A});const{onStart:y,onMove:w}=this.handlers;g||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Yn(g,this.transformPagePoint),H.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:x,onSessionEnd:v,resumeAnimation:A}=this.handlers;if(this.dragSnapToOrigin&&A&&A(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=Jn(f.type==="pointercancel"?this.lastMoveEventInfo:Yn(g,this.transformPagePoint),this.history);this.startEvent&&x&&x(f,y),v&&v(f,y)},!Zs(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const a=on(e),c=Yn(a,this.transformPagePoint),{point:u}=c,{timestamp:l}=nt;this.history=[{...u,timestamp:l}];const{onSessionStart:d}=n;d&&d(e,Jn(c,this.history)),this.removeListeners=nn(Ke(this.contextWindow,"pointermove",this.handlePointerMove),Ke(this.contextWindow,"pointerup",this.handlePointerUp),Ke(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Wt(this.updatePoint)}}function Yn(t,e){return e?{point:e(t.point)}:t}function rr(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Jn({point:t},e){return{point:t,delta:rr(t,la(e)),offset:rr(t,Md(e)),velocity:jd(e,.1)}}function Md(t){return t[0]}function la(t){return t[t.length-1]}function jd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=la(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>Ct(e)));)n--;if(!s)return{x:0,y:0};const o=bt(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const r={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function Ed(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?X(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?X(n,t,s.max):Math.min(t,n)),t}function or(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function kd(t,{top:e,left:n,bottom:s,right:i}){return{x:or(t.x,n,i),y:or(t.y,e,s)}}function ar(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function Dd(t,e){return{x:ar(t.x,e.x),y:ar(t.y,e.y)}}function Vd(t,e){let n=.5;const s=ft(t),i=ft(e);return i>s?n=Ye(e.min,e.max-s,t.min):s>i&&(n=Ye(t.min,t.max-i,e.min)),Lt(0,1,n)}function Rd(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Ps=.35;function Nd(t=Ps){return t===!1?t=0:t===!0&&(t=Ps),{x:cr(t,"left","right"),y:cr(t,"top","bottom")}}function cr(t,e,n){return{min:lr(t,e),max:lr(t,n)}}function lr(t,e){return typeof t=="number"?t:t[e]||0}const Id=new WeakMap;class Ld{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Y(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(on(d).point)},r=(d,f)=>{const{drag:g,dragPropagation:x,onDragStart:v}=this.getProps();if(g&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=_l(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),vt(y=>{let w=this.getAxisMotionValue(y).get()||0;if(Dt.test(w)){const{projection:T}=this.visualElement;if(T&&T.layout){const D=T.layout.layoutBox[y];D&&(w=ft(D)*(parseFloat(w)/100))}}this.originPoint[y]=w}),v&&H.postRender(()=>v(d,f)),Ss(this.visualElement,"transform");const{animationState:A}=this.visualElement;A&&A.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:x,onDirectionLock:v,onDrag:A}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:y}=f;if(x&&this.currentDirection===null){this.currentDirection=Od(y),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),A&&A(d,f)},c=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>vt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:l}=this.getProps();this.panSession=new ca(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:s,contextWindow:aa(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:r}=i;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&H.postRender(()=>a(s,i))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(e,n,s){const{drag:i}=this.getProps();if(!s||!yn(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=Ed(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&Te(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=kd(s.layoutBox,e):this.constraints=!1,this.elastic=Nd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&vt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Rd(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Te(e))return!1;const s=e.current;Ot(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=$u(s,i.root,this.visualElement.getTransformPagePoint());let r=Dd(i.layout.layoutBox,o);if(n){const a=n(Ou(r));this.hasMutatedConstraints=!!a,a&&(r=Wo(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=vt(l=>{if(!yn(l,n,this.currentDirection))return;let d=c&&c[l]||{};r&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,x={type:"inertia",velocity:s?e[l]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(l,x)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Ss(this.visualElement,e),s.start(li(e,s,0,n,this.visualElement,!1))}stopAnimation(){vt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){vt(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){vt(n=>{const{drag:s}=this.getProps();if(!yn(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n];o.set(e[n]-X(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Te(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};vt(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const c=a.get();i[r]=Vd({min:c,max:c},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),vt(r=>{if(!yn(r,e,null))return;const a=this.getAxisMotionValue(r),{min:c,max:u}=this.constraints[r];a.set(X(c,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;Id.set(this.visualElement,this);const e=this.visualElement.current,n=Ke(e,"pointerdown",c=>{const{drag:u,dragListener:l=!0}=this.getProps();u&&l&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();Te(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),H.read(s);const r=en(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(vt(l=>{const d=this.getAxisMotionValue(l);d&&(this.originPoint[l]+=c[l].translate,d.set(d.get()+c[l].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=Ps,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function yn(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Od(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class Fd extends Ht{constructor(e){super(e),this.removeGroupControls=wt,this.removeListeners=wt,this.controls=new Ld(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||wt}unmount(){this.removeGroupControls(),this.removeListeners()}}const ur=t=>(e,n)=>{t&&H.postRender(()=>t(e,n))};class Bd extends Ht{constructor(){super(...arguments),this.removePointerDownListener=wt}onPointerDown(e){this.session=new ca(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:aa(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:ur(e),onStart:ur(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&H.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=Ke(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Sn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function dr(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Ue={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(L.test(t))t=parseFloat(t);else return t;const n=dr(t,e.target.x),s=dr(t,e.target.y);return`${n}% ${s}%`}},$d={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Kt.parse(t);if(i.length>5)return s;const o=Kt.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=c;const u=X(a,c,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}};let Zn=!1;class zd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;du(Ud),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),Zn&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),Sn.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,Zn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||H.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Js.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;Zn=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function ua(t){const[e,n]=Do(),s=m.useContext(Es);return h.jsx(zd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(Uo),isPresent:e,safeToRemove:n})}const Ud={borderRadius:{...Ue,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ue,borderTopRightRadius:Ue,borderBottomLeftRadius:Ue,borderBottomRightRadius:Ue,boxShadow:$d};function _d(t,e,n){const s=at(t)?t:je(t);return s.start(li("",s,e,n)),s.animation}const Wd=(t,e)=>t.depth-e.depth;class Kd{constructor(){this.children=[],this.isDirty=!1}add(e){Vs(this.children,e),this.isDirty=!0}remove(e){Rs(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Wd),this.isDirty=!1,this.children.forEach(e)}}function Hd(t,e){const n=mt.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(Wt(s),t(o-e))};return H.setup(s,!0),()=>Wt(s)}const da=["TopLeft","TopRight","BottomLeft","BottomRight"],Gd=da.length,hr=t=>typeof t=="string"?parseFloat(t):t,fr=t=>typeof t=="number"||L.test(t);function Xd(t,e,n,s,i,o){i?(t.opacity=X(0,n.opacity??1,qd(s)),t.opacityExit=X(e.opacity??1,0,Yd(s))):o&&(t.opacity=X(e.opacity??1,n.opacity??1,s));for(let r=0;r<Gd;r++){const a=`border${da[r]}Radius`;let c=mr(e,a),u=mr(n,a);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||fr(c)===fr(u)?(t[a]=Math.max(X(hr(c),hr(u),s),0),(Dt.test(u)||Dt.test(c))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=X(e.rotate||0,n.rotate||0,s))}function mr(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const qd=ha(0,.5,Yr),Yd=ha(.5,.95,wt);function ha(t,e,n){return s=>s<t?0:s>e?1:n(Ye(t,e,s))}function pr(t,e){t.min=e.min,t.max=e.max}function xt(t,e){pr(t.x,e.x),pr(t.y,e.y)}function gr(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function yr(t,e,n,s,i){return t-=e,t=kn(t,1/n,s),i!==void 0&&(t=kn(t,1/i,s)),t}function Jd(t,e=0,n=1,s=.5,i,o=t,r=t){if(Dt.test(e)&&(e=parseFloat(e),e=X(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=X(o.min,o.max,s);t===o&&(a-=e),t.min=yr(t.min,e,n,a,i),t.max=yr(t.max,e,n,a,i)}function xr(t,e,[n,s,i],o,r){Jd(t,e[n],e[s],e[i],e.scale,o,r)}const Zd=["x","scaleX","originX"],Qd=["y","scaleY","originY"];function vr(t,e,n,s){xr(t.x,e,Zd,n?n.x:void 0,s?s.x:void 0),xr(t.y,e,Qd,n?n.y:void 0,s?s.y:void 0)}function br(t){return t.translate===0&&t.scale===1}function fa(t){return br(t.x)&&br(t.y)}function wr(t,e){return t.min===e.min&&t.max===e.max}function th(t,e){return wr(t.x,e.x)&&wr(t.y,e.y)}function Tr(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function ma(t,e){return Tr(t.x,e.x)&&Tr(t.y,e.y)}function Sr(t){return ft(t.x)/ft(t.y)}function Ar(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class eh{constructor(){this.members=[]}add(e){Vs(this.members,e),e.scheduleRender()}remove(e){if(Rs(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function nh(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:l,rotateX:d,rotateY:f,skewX:g,skewY:x}=n;u&&(s=`perspective(${u}px) ${s}`),l&&(s+=`rotate(${l}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),x&&(s+=`skewY(${x}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(s+=`scale(${a}, ${c})`),s||"none"}const Qn=["","X","Y","Z"],sh=1e3;let ih=0;function ts(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function pa(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Qo(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",H,!(i||o))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&pa(s)}function ga({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=ih++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(ah),this.nodes.forEach(dh),this.nodes.forEach(hh),this.nodes.forEach(ch)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Kd)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new Is),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const c=this.eventHandlers.get(r);c&&c.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=ko(r)&&!ql(r),this.instance=r;const{layoutId:a,layout:c,visualElement:u}=this.options;if(u&&!u.current&&u.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let l,d=0;const f=()=>this.root.updateBlockedByResize=!1;H.read(()=>{d=window.innerWidth}),t(r,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,l&&l(),l=Hd(f,250),Sn.hasAnimatedSinceResize&&(Sn.hasAnimatedSinceResize=!1,this.nodes.forEach(Mr)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||c)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||u.getDefaultTransition()||yh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:A}=u.getProps(),y=!this.targetLayout||!ma(this.targetLayout,g),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const T={...qs(x,"layout"),onPlay:v,onComplete:A};(u.shouldReduceMotion||this.options.layoutRoot)&&(T.delay=0,T.type=!1),this.startAnimation(T),this.setAnimationOrigin(l,w)}else d||Mr(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Wt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(fh),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&pa(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const d=this.path[l];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Pr);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Cr);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(uh),this.nodes.forEach(rh),this.nodes.forEach(oh)):this.nodes.forEach(Cr),this.clearAllSnapshots();const a=mt.now();nt.delta=Lt(0,1e3/60,a-nt.timestamp),nt.timestamp=a,nt.isProcessing=!0,Un.update.process(nt),Un.preRender.process(nt),Un.render.process(nt),nt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Js.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(lh),this.sharedNodes.forEach(mh)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,H.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){H.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ft(this.snapshot.measuredBox.x)&&!ft(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Y(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&this.instance){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!fa(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,l=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||oe(this.latestValues)||l)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return r&&(c=this.removeTransform(c)),xh(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return Y();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(vh))){const{scroll:u}=this.root;u&&(Se(a.x,u.offset.x),Se(a.y,u.offset.y))}return a}removeElementScroll(r){const a=Y();if(xt(a,r),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:l,options:d}=u;u!==this.root&&l&&d.layoutScroll&&(l.wasRoot&&xt(a,r),Se(a.x,l.offset.x),Se(a.y,l.offset.y))}return a}applyTransform(r,a=!1){const c=Y();xt(c,r);for(let u=0;u<this.path.length;u++){const l=this.path[u];!a&&l.options.layoutScroll&&l.scroll&&l!==l.root&&Ae(c,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),oe(l.latestValues)&&Ae(c,l.latestValues)}return oe(this.latestValues)&&Ae(c,this.latestValues),c}removeTransform(r){const a=Y();xt(a,r);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!oe(u.latestValues))continue;vs(u.latestValues)&&u.updateSnapshot();const l=Y(),d=u.measurePageBox();xt(l,d),vr(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,l)}return oe(this.latestValues)&&vr(a,this.latestValues),a}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==nt.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(r||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:l,layoutId:d}=this.options;if(!(!this.layout||!(l||d))){if(this.resolvedRelativeTargetAt=nt.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Y(),this.relativeTargetOrigin=Y(),Ge(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Y(),this.targetWithTransforms=Y()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Pd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):xt(this.target,this.layout.layoutBox),Ho(this.target,this.targetDelta)):xt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Y(),this.relativeTargetOrigin=Y(),Ge(this.relativeTargetOrigin,this.target,f.target),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||vs(this.parent.latestValues)||Ko(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const r=this.getLead(),a=!!this.resumingFrom||this!==r;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===nt.timestamp&&(c=!1),c)return;const{layout:u,layoutId:l}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||l))return;xt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;Bu(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=Y());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(gr(this.prevProjectionDelta.x,this.projectionDelta.x),gr(this.prevProjectionDelta.y,this.projectionDelta.y)),He(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Ar(this.projectionDelta.x,this.prevProjectionDelta.x)||!Ar(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){if(this.options.visualElement?.scheduleRender(),r){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Pe(),this.projectionDelta=Pe(),this.projectionDeltaWithTransform=Pe()}setAnimationOrigin(r,a=!1){const c=this.snapshot,u=c?c.latestValues:{},l={...this.latestValues},d=Pe();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=Y(),g=c?c.source:void 0,x=this.layout?this.layout.source:void 0,v=g!==x,A=this.getStack(),y=!A||A.members.length<=1,w=!!(v&&!y&&this.options.crossfade===!0&&!this.path.some(gh));this.animationProgress=0;let T;this.mixTargetDelta=D=>{const j=D/1e3;jr(d.x,r.x,j),jr(d.y,r.y,j),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Ge(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),ph(this.relativeTarget,this.relativeTargetOrigin,f,j),T&&th(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=Y()),xt(T,this.relativeTarget)),v&&(this.animationValues=l,Xd(l,u,this.latestValues,j,w,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=j},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Wt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=H.update(()=>{Sn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=je(0)),this.currentAnimation=_d(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),r.onUpdate&&r.onUpdate(a)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(sh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:c,layout:u,latestValues:l}=r;if(!(!a||!c||!u)){if(this!==r&&this.layout&&u&&ya(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||Y();const d=ft(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+d;const f=ft(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+f}xt(a,c),Ae(a,l),He(this.projectionDeltaWithTransform,this.layoutCorrected,a,l)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new eh),this.sharedNodes.get(r).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const u={};c.z&&ts("z",r,u,this.animationValues);for(let l=0;l<Qn.length;l++)ts(`rotate${Qn[l]}`,r,u,this.animationValues),ts(`skew${Qn[l]}`,r,u,this.animationValues);r.render();for(const l in u)r.setStaticValue(l,u[l]),this.animationValues&&(this.animationValues[l]=u[l]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=wn(a?.pointerEvents)||"",r.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=wn(a?.pointerEvents)||""),this.hasProjected&&!oe(this.latestValues)&&(r.transform=c?c({},""):"none",this.hasProjected=!1);return}r.visibility="";const l=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=nh(this.projectionDeltaWithTransform,this.treeScale,l);c&&(d=c(l,d)),r.transform=d;const{x:f,y:g}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?r.opacity=u===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:r.opacity=u===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const x in tn){if(l[x]===void 0)continue;const{correct:v,applyTo:A,isCSSVariable:y}=tn[x],w=d==="none"?l[x]:v(l[x],u);if(A){const T=A.length;for(let D=0;D<T;D++)r[A[D]]=w}else y?this.options.visualElement.renderState.vars[x]=w:r[x]=w}this.options.layoutId&&(r.pointerEvents=u===this?wn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(Pr),this.root.sharedNodes.clear()}}}function rh(t){t.updateLayout()}function oh(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(d);d.min=n[l].min,d.max=d.min+f}):ya(i,e.layoutBox,n)&&vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(n[l]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[l].max=t.relativeTarget[l].min+f)});const r=Pe();He(r,n,e.layoutBox);const a=Pe();o?He(a,t.applyTransform(s,!0),e.measuredBox):He(a,n,e.layoutBox);const c=!fa(r);let u=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:d,layout:f}=l;if(d&&f){const g=Y();Ge(g,e.layoutBox,d.layoutBox);const x=Y();Ge(x,n,f.layoutBox),ma(g,x)||(u=!0),l.options.layoutRoot&&(t.relativeTarget=x,t.relativeTargetOrigin=g,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function ah(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function ch(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function lh(t){t.clearSnapshot()}function Pr(t){t.clearMeasurements()}function Cr(t){t.isLayoutDirty=!1}function uh(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Mr(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function dh(t){t.resolveTargetDelta()}function hh(t){t.calcProjection()}function fh(t){t.resetSkewAndRotation()}function mh(t){t.removeLeadSnapshot()}function jr(t,e,n){t.translate=X(e.translate,0,n),t.scale=X(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Er(t,e,n,s){t.min=X(e.min,n.min,s),t.max=X(e.max,n.max,s)}function ph(t,e,n,s){Er(t.x,e.x,n.x,s),Er(t.y,e.y,n.y,s)}function gh(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const yh={duration:.45,ease:[.4,0,.1,1]},kr=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Dr=kr("applewebkit/")&&!kr("chrome/")?Math.round:wt;function Vr(t){t.min=Dr(t.min),t.max=Dr(t.max)}function xh(t){Vr(t.x),Vr(t.y)}function ya(t,e,n){return t==="position"||t==="preserve-aspect"&&!Ad(Sr(e),Sr(n),.2)}function vh(t){return t!==t.root&&t.scroll?.wasRoot}const bh=ga({attachResizeListener:(t,e)=>en(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),es={current:void 0},xa=ga({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!es.current){const t=new bh({});t.mount(window),t.setOptions({layoutScroll:!0}),es.current=t}return es.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),wh={pan:{Feature:Bd},drag:{Feature:Fd,ProjectionNode:xa,MeasureLayout:ua}};function Rr(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&H.postRender(()=>o(e,on(e)))}class Th extends Ht{mount(){const{current:e}=this.node;e&&(this.unmount=Wl(e,(n,s)=>(Rr(this.node,s,"Start"),i=>Rr(this.node,i,"End"))))}unmount(){}}class Sh extends Ht{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!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=nn(en(this.node.current,"focus",()=>this.onFocus()),en(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Nr(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&H.postRender(()=>o(e,on(e)))}class Ah extends Ht{mount(){const{current:e}=this.node;e&&(this.unmount=Xl(e,(n,s)=>(Nr(this.node,s,"Start"),(i,{success:o})=>Nr(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Cs=new WeakMap,ns=new WeakMap,Ph=t=>{const e=Cs.get(t.target);e&&e(t)},Ch=t=>{t.forEach(Ph)};function Mh({root:t,...e}){const n=t||document;ns.has(n)||ns.set(n,{});const s=ns.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(Ch,{root:t,...e})),s[i]}function jh(t,e,n){const s=Mh(e);return Cs.set(t,n),s.observe(t),()=>{Cs.delete(t),s.unobserve(t)}}const Eh={some:0,all:1};class kh extends Ht{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Eh[i]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:l,onViewportLeave:d}=this.node.getProps(),f=u?l:d;f&&f(c)};return jh(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(Dh(e,n))&&this.startObserver()}unmount(){}}function Dh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const va={inView:{Feature:kh},tap:{Feature:Ah},focus:{Feature:Sh},hover:{Feature:Th}},Vh={layout:{ProjectionNode:xa,MeasureLayout:ua}},Rh={...ia,...va,...wh,...Vh},Nh=Lu(Rh,Zo),Ih={renderer:Zo,...ia,...va};function ba(t,e){return Tn(t,e)}const xn=ba("div"),Lh=ba("p"),kt=Symbol.for("@arcteninc/core:originalName");function Oh(t,e){return t[kt]=e,t}function Fh(t,e,n,s){if(typeof t!="function")return null;const i=t[kt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const o=t.name;let r;if(o&&(r=e[o],r&&!n.has(r.name)))return t[kt]=r.name,{fn:t,meta:r};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(r=e[a],r))return t[kt]=r.name,{fn:t,meta:r}}else if(r=Object.values(e).find(c=>!n.has(c.name)),r)return t[kt]=r.name,{fn:t,meta:r};return null}function wa(t,e){let n,s;if(!e)throw new Error(`❌ toolMetadata is required!
10
10
 
11
11
  Please:
12
12
  1. Run "arcten-extract-types ." before build (add to package.json scripts)
@@ -15,10 +15,10 @@ Please:
15
15
  3. Pass it to useAgent/ArctenAgent:
16
16
  useAgent({ tools: [...], toolMetadata: toolMetadata })
17
17
  (Pass the full object for better minification support, or toolMetadata.functions for backward compatibility)
18
- `);if("functions"in e&&typeof e.functions=="object"){const o=e;n=o.functions,s=o.toolOrder}else n=e,s=void 0;const i=new Set;return t.map(o=>{const r=Oh(o,n,i,s);if(!r){const a=o.name,u=o[kt]||a||"unnamed";return typeof process<"u"&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production")&&typeof console<"u"&&console.warn&&console.warn(`⚠️ [@arcteninc/core] No metadata found for tool "${u}". This tool will be excluded.
19
- To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return i.add(r.meta.name),{name:r.meta.name,description:r.meta.description,jsonSchema:r.meta.parameters}}).filter(o=>o!==null)}function Fh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const o=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),o&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([r,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[r,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},r))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(wn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(Q.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(wn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(Q.X,{className:"h-3 w-3"})})]})]})})}function Bh({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,o]=m.useState(!1);if(t==="fetchDocContent")return null;const r=["k","maxResults","_organizationId"];t==="searchDocs"&&r.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!r.includes(u))),c=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>c&&o(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${c?"cursor-pointer hover:bg-opacity-80":""}`,children:[c&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(Q.ChevronDown,{className:"h-3 w-3"}):h.jsx(Q.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(Q.X,{className:"h-3 w-3"}):s?h.jsx(Q.Zap,{className:"h-3 w-3"}):h.jsx(Q.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&c&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},u))})})]})}function $h({...t}){return h.jsx(Ps.Root,{"data-slot":"collapsible",...t})}function zh({...t}){return h.jsx(Ps.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Uh({...t}){return h.jsx(Ps.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const _h=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ai=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(_h,{className:it("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ai.displayName="Response";const Wh=Object.freeze(Object.defineProperty({__proto__:null,Response:ai},Symbol.toStringTag,{value:"Module"})),Kh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const o=Rh.create(e),r=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(o,{animate:{backgroundPosition:"0% center"},className:it("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${r}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},Hh=m.memo(Kh),wa=m.createContext(null),Gh=()=>{const t=m.useContext(wa);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Xh=1e3,qh=1e3,Ta=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:o,children:r,...a})=>{const[c,u]=yi.useControllableState({prop:n,defaultProp:s,onChange:i}),[l,d]=yi.useControllableState({prop:o,defaultProp:0}),[f,g]=m.useState(!1),[x,v]=m.useState(null);m.useEffect(()=>{e?x===null&&v(Date.now()):x!==null&&(d(Math.ceil((Date.now()-x)/qh)),v(null))},[e,x,d]),m.useEffect(()=>{if(s&&!e&&c&&!f){const y=setTimeout(()=>{u(!1),g(!0)},Xh);return()=>clearTimeout(y)}},[e,c,s,u,f]);const A=y=>{u(y)};return h.jsx(wa.Provider,{value:{isStreaming:e,isOpen:c,setIsOpen:u,duration:l},children:h.jsx($h,{className:it("not-prose mb-4",t),onOpenChange:A,open:c,...a,children:r})})}),Yh=(t,e)=>t||e===0?h.jsx(Hh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Sa=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:o}=Gh();return h.jsx(zh,{className:it("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...n,children:e??h.jsxs(h.Fragment,{children:[h.jsx(Q.BrainIcon,{className:"size-4"}),Yh(s,o),h.jsx(Q.ChevronDownIcon,{className:it("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Aa=m.memo(({className:t,children:e,...n})=>h.jsx(Uh,{className:it("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...n,children:h.jsx(ai,{className:"grid gap-2",children:e})}));Ta.displayName="Reasoning";Sa.displayName="ReasoningTrigger";Aa.displayName="ReasoningContent";function Jh(t){const e=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,n=t.match(e),s=new Map;if(n&&n[1]){const u=n[1],l=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let d;for(;(d=l.exec(u))!==null;)if(d[1]&&d[2]){const f=parseInt(d[1],10),g=d[2].replace(/[.,;:!?]+$/,"");s.set(f,g)}}const i=[];let o=0;const r=/```[\s\S]*?```|`[^`]+`/g;let a;for(;(a=r.exec(t))!==null;)a.index>o&&i.push({type:"text",content:t.slice(o,a.index),start:o,end:a.index}),i.push({type:"code",content:a[0],start:a.index,end:a.index+a[0].length}),o=a.index+a[0].length;return o<t.length&&i.push({type:"text",content:t.slice(o),start:o,end:t.length}),i.map(u=>{if(u.type==="code")return u.content;let l=u.content;l=l.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(v,A,y)=>{const w=parseInt(A,10);return`<sup><a href="${y.replace(/"/g,"&quot;")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${w}]</a></sup>`});const d=/\[([^\]]+)\]\([^\)]+\)/g,f=[];let g;for(;(g=d.exec(l))!==null;)f.push({start:g.index,end:g.index+g[0].length});return l.replace(/\[(\d+)\]/g,(v,A,y)=>{if(f.some(j=>y>=j.start&&y<j.end))return v;const S=parseInt(A,10),D=s.get(S);return D?`<sup><a href="${D.replace(/"/g,"&quot;")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${S}]</a></sup>`:v})}).join("")}function Ke(t){if(typeof t=="string")try{const e=JSON.parse(t);return Ke(e)}catch{return t}if(Array.isArray(t))return t.map(Ke);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=Ke(s);return e}return t}function ts(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return Ke(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?Ke(t):{}}function Zh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:o=void 0,defaultWidth:r=384,minWidth:a=300,maxWidth:c=800,initiallyExpanded:u=!1,tools:l=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:x="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:A,state:y,onStateChange:w,allowStateEdits:S=!0}){const[D,j]=m.useState(null),E=m.useRef(null),[O,R]=m.useState(null),[B,Y]=m.useState(null),tt=m.useRef(null),z=y!==void 0,[ue,Tt]=m.useState({}),rt=m.useRef({});z&&y?rt.current=y:z||(rt.current=ue);const[Bt,F]=m.useState(!1),[lt,ut]=m.useState(null),dt=m.useRef(!1),[ht,Vt]=m.useState(u),[yt,de]=m.useState(r),[Ht,Gt]=m.useState(600),[Mt,Rt]=m.useState(!1),[_,he]=m.useState(!1),[pt,Xt]=m.useState(!1),[gt,fe]=m.useState({x:100,y:100}),[St,Ne]=m.useState(!1),[qt,me]=m.useState({x:0,y:0}),[Dn,pe]=m.useState(!1),Yt=m.useRef(null),ge=m.useRef(null),[ye,Ie]=m.useState(""),[Le,Vn]=m.useState(null),[Rn,Nn]=m.useState("Thinking..."),[xe,P]=m.useState(new Set),[C,V]=m.useState(""),[I,U]=m.useState([]),[W,ot]=m.useState(!1),[Nt,Jt]=m.useState([]),[jt,Oe]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[ve,sn]=m.useState(!1),[ef,rn]=m.useState(!1),[nf,on]=m.useState([]),ci=m.useCallback(async(p,b=3)=>{if(!jt||!E.current)return;const M=async()=>{const k=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,N=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:jt,updates:p},format:"json"})});if(!N.ok){if(N.status===404){console.warn("[ArctenAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const $=await N.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${N.status} ${$}`)}};for(let T=0;T<b;T++)try{await M(),ut(null);return}catch(k){if(T===b-1){const $=k instanceof Error?k:new Error(String(k));throw ut($),console.error("Failed to sync state to Convex after retries:",k),$}await new Promise($=>setTimeout($,Math.pow(2,T)*100))}},[jt,v,E]),li=m.useMemo(()=>function(){return rt.current},[]),ui=m.useMemo(()=>async function(b){const M={...rt.current,...b};rt.current=M,z||Tt(M),w&&w(M);try{await ci(b)}catch(T){throw T}},[ci,w,z]);m.useEffect(()=>{z&&y&&(rt.current=y)},[z,y]);const Zt=m.useMemo(()=>{const p=[...l,...d,li];return(!z||S)&&p.push(ui),p},[l,d,li,ui,z,S]),In=m.useMemo(()=>ba(Zt,f),[Zt,f]),It=m.useMemo(()=>{const p=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}];return(!z||S)&&p.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}),[...In,...p]},[In,z,S]),di=m.useMemo(()=>new Set(It.map(p=>p.name)),[It]),an=m.useMemo(()=>It.filter(p=>p.name==="getState"?!0:p.name==="setState"?!z||S:di.has(p.name)),[It,di,z,S]),Ln=m.useMemo(()=>{const p=new Map,b=new Map(In.map(M=>[M.name,M]));return Zt.forEach(M=>{const T=M[kt];if(T){const N=b.get(T);if(N){p.set(N.name,M);return}}const k=It.find(N=>N.name===M.name);k&&p.set(k.name,M)}),p},[Zt,It]),Fe=m.useMemo(()=>{const p=new Set;p.add("getState"),p.add("setState");const b=new Map(It.map(M=>[M.name,M]));return d.forEach(M=>{const T=M[kt];if(T&&b.has(T))p.add(T);else{const k=It.find(N=>N.name===M.name);k&&p.add(k.name)}}),p},[d,It]),hi=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&Vt(JSON.parse(p));const b=localStorage.getItem("arcten-sidebar-width");b&&de(parseInt(b));const M=localStorage.getItem("arcten-sidebar-height");M&&Gt(parseInt(M));const T=localStorage.getItem("arcten-sidebar-detached");T&&he(JSON.parse(T));const k=localStorage.getItem("arcten-sidebar-position");if(k){const $=JSON.parse(k),K=50,et=Math.max(K-r,Math.min($.x,window.innerWidth-K)),H=Math.max(0,Math.min($.y,window.innerHeight-K));fe({x:et,y:H})}const N=localStorage.getItem("arcten-sidebar-minimized");N&&Xt(JSON.parse(N)),pe(!0)}},[]);const $t=m.useMemo(()=>A,[A?.id]);m.useEffect(()=>((async()=>{try{const b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!b.ok)throw new Error("Failed to fetch token");const M=await b.json();j(M.clientToken),E.current=M.clientToken,Y(M.expiresAt),R(null)}catch(b){R(b instanceof Error?b.message:"Failed to fetch token")}})(),()=>{tt.current&&clearTimeout(tt.current)}),[x,$t]),m.useEffect(()=>{if(!B)return;tt.current&&clearTimeout(tt.current);const p=Math.floor(Date.now()/1e3),b=B-p,T=Math.max(0,b-5);return tt.current=setTimeout(async()=>{try{const k=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!k.ok)throw new Error("Failed to refresh token");const N=await k.json();j(N.clientToken),E.current=N.clientToken,Y(N.expiresAt),R(null)}catch(k){console.error("Token refresh failed:",k),R(k instanceof Error?k.message:"Failed to refresh token")}},T*1e3),()=>{tt.current&&clearTimeout(tt.current)}},[B,x,$t]),m.useEffect(()=>{(async()=>{if(Zt.length!==0)try{const b=Zt.map(T=>({name:T.name,code:T.toString()})),M=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:b})});if(M.ok){const T=await M.json();U(T.tools)}}catch(b){console.error("Failed to fetch tool descriptions:",b)}})()},[Zt]),m.useEffect(()=>{Promise.resolve().then(()=>Wh).then(p=>{Vn(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{V(window.location.pathname)};p(),window.addEventListener("popstate",p);const b=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(b)}},[]);const On=m.useCallback(async()=>{if(!(!$t?.id||!D)){rn(!0);try{const b=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${D}`}})).json();Jt(b.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{rn(!1)}}},[$t?.id,D,v]);m.useEffect(()=>{$t?.id&&D&&On()},[$t?.id,D,On]);function Pa(p){const b=Math.floor((Date.now()-p)/1e3);return b<60?"now":b<3600?`${Math.floor(b/60)}m`:b<86400?`${Math.floor(b/3600)}h`:`${Math.floor(b/86400)}d`}function Ca(){const p=crypto.randomUUID();Oe(p),ln([]),on([]),sn(!1);const b=z?y||{}:{};rt.current=b,z||Tt(b),w&&w(b),dt.current=!1}async function Ma(p){if(D)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${D}`}}),Jt(Nt.filter(b=>b._id!==p)),p===jt&&Ca()}catch(b){console.error("Failed to delete conversation:",b)}}async function ja(p){Oe(p.chatId),sn(!1),rn(!0);try{const b=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${E.current}`}});if(!b.ok)throw new Error(`Failed to fetch messages: ${b.statusText}`);const T=(await b.json()).messages||[];ln(T),on(T)}catch(b){console.error("Failed to load conversation messages:",b);const M=p.messages||[];ln(M),on(M)}finally{rn(!1)}}const Ea=async(p,b={})=>{const M=b.headers?new Headers(b.headers):new Headers;return M.delete("user-agent"),M.delete("User-Agent"),fetch(p,{...b,headers:M})},{messages:zt,sendMessage:ka,status:Et,error:fi,stop:cn,addToolResult:Qt,setMessages:ln}=Nr.useChat({id:jt||void 0,transport:new bn.DefaultChatTransport({api:`${v}/chat`,fetch:Ea,headers:()=>{const p={};return E.current&&(p.Authorization=`Bearer ${E.current}`),p},body:()=>({tools:an.map(b=>({name:b.name,description:b.description,inputSchema:b.jsonSchema})),systemPrompt:g,currentRoute:C,state:rt.current})}),sendAutomaticallyWhen:bn.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{const p=zt[zt.length-1];if(!p||p.role!=="assistant")return;const b=p.parts?.filter(M=>M.type?.startsWith("tool-")&&M.state==="input-available"&&typeof M.toolCallId=="string"&&M.input!==void 0)||[];for(const M of b){const T=M,k=T.type?.replace("tool-","")||"",N=T.toolCallId;Fe.has(k)&&!xe.has(N)&&(P($=>new Set($).add(N)),(async()=>{try{const $=Ln.get(k);if(!$){console.warn(`[ArctenAgent] Tool ${k} not found in toolsMap`),Qt({toolCallId:N,tool:k,output:`Error: Tool ${k} not found`}),P(nt=>{const at=new Set(nt);return at.delete(N),at});return}const K=ts(T.input),et=an.find(nt=>nt.name===k);let H;if(et&&et.jsonSchema?.properties){const at=Object.keys(et.jsonSchema.properties).map(Ba=>K[Ba]);console.log(`[ArctenAgent] Executing safe tool ${k} with args:`,at),H=await $(...at)}else if(k==="getState")H=$();else if(k==="setState"){const nt=K.updates||K;H=await $(nt)}else H=await $(...Object.values(K));console.log(`[ArctenAgent] Tool ${k} completed, result:`,H),Qt({toolCallId:N,tool:k,output:H}),P(nt=>{const at=new Set(nt);return at.delete(N),at})}catch($){console.error(`[ArctenAgent] Error executing safe tool ${k}:`,$),Qt({toolCallId:N,tool:k,output:`Error: ${$ instanceof Error?$.message:String($)}`}),P(K=>{const et=new Set(K);return et.delete(N),et})}})())}},[zt,Fe,Ln,an,xe,Qt]),m.useEffect(()=>{if(!jt||!E.current)return;(async()=>{F(!0),ut(null);try{const M=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,T=await fetch(M,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:jt},format:"json"})});if(!T.ok){if(T.status===404||T.status>=500){console.warn(`[ArctenAgent] Convex API endpoint not available (${T.status}), using empty state`);const H=z?y||{}:{};rt.current=H,z||Tt(H),w&&w(H),dt.current=!0,F(!1);return}const et=await T.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${T.status} ${et}`)}const N=(await T.json())?.value||{},$=!dt.current;let K;$?(K={...z?y||{}:{},...N},dt.current=!0):K=N,rt.current=K,z||Tt(K),w&&w(K)}catch(b){b instanceof TypeError&&b.message.includes("fetch")?console.warn("[ArctenAgent] Network error fetching state (likely Convex endpoint not available), using fallback state:",b):console.error("[ArctenAgent] Failed to fetch state:",b);const T=b instanceof Error?b:new Error(String(b));if(ut(T),!dt.current){const k=z?y||{}:{};rt.current=k,z||Tt(k),w&&w(k),dt.current=!0}}finally{F(!1)}})()},[jt,v,z,y,w]),m.useEffect(()=>{ht&&ge.current&&ge.current.focus()},[ht,zt]);function Da(){Vt(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Va(){Vt(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[ht]),m.useEffect(()=>{Yt.current&&Yt.current.scrollIntoView({behavior:"smooth"})},[zt]),m.useEffect(()=>{function p(b){b.key==="Escape"&&(Et==="streaming"||Et==="submitted")&&(b.preventDefault(),cn())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[Et,cn]);function Ra(){const p=crypto.randomUUID();Oe(p),ln([]),on([]),sn(!1)}function mi(p){if(p.preventDefault(),!ye.trim())return;(Et==="streaming"||Et==="submitted")&&cn();const b=hi[Math.floor(Math.random()*hi.length)]||"Thinking...";Nn(b),ka({text:ye}),Ie("")}function Na(p){const b=p.target.value;Ie(b)}m.useEffect(()=>{if(!Mt)return;function p(M){if(_){const T=M.clientX-gt.x,k=M.clientY-gt.y;T>=a&&T<=c&&de(T),k>=400&&k<=1e3&&Gt(k)}else{const T=window.innerWidth-M.clientX;T>=a&&T<=c&&de(T)}}function b(){Rt(!1),localStorage.setItem("arcten-sidebar-width",yt.toString()),localStorage.setItem("arcten-sidebar-height",Ht.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[Mt,yt,Ht,_,gt,a,c]);function Ia(p){p.preventDefault(),Rt(!0)}function La(){he(!0),Xt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Oa(){he(!1),Xt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function pi(){Xt(!pt),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!pt))}function Fa(p){_&&(Ne(!0),me({x:p.clientX-gt.x,y:p.clientY-gt.y}))}return m.useEffect(()=>{if(!_)return;function p(){fe(b=>{const T=window.innerWidth-50,k=window.innerHeight-50,N=50-yt,$=0,K=Math.max(N,Math.min(b.x,T)),et=Math.max($,Math.min(b.y,k));if(K!==b.x||et!==b.y){const H={x:K,y:et};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(H)),H}return b})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[_,yt]),m.useEffect(()=>{if(!St)return;function p(M){const T=M.clientX-qt.x,k=M.clientY-qt.y,N=50,$=window.innerWidth-N,K=window.innerHeight-N,et=N-yt,H=0,nt=Math.max(et,Math.min(T,$)),at=Math.max(H,Math.min(k,K));fe({x:nt,y:at})}function b(){Ne(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(gt))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[St,qt,gt,yt]),Dn?O?h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",O]})}):D?h.jsx(iu,{features:Nh,children:h.jsx(mn,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:_?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:_?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
18
+ `);if("functions"in e&&typeof e.functions=="object"){const o=e;n=o.functions,s=o.toolOrder}else n=e,s=void 0;const i=new Set;return t.map(o=>{const r=Fh(o,n,i,s);if(!r){const a=o.name,u=o[kt]||a||"unnamed";return typeof process<"u"&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production")&&typeof console<"u"&&console.warn&&console.warn(`⚠️ [@arcteninc/core] No metadata found for tool "${u}". This tool will be excluded.
19
+ To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return i.add(r.meta.name),{name:r.meta.name,description:r.meta.description,jsonSchema:r.meta.parameters}}).filter(o=>o!==null)}function Bh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const o=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),o&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([r,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[r,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},r))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(Pn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(Z.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(Pn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(Z.X,{className:"h-3 w-3"})})]})]})})}function $h({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,o]=m.useState(!1);if(t==="fetchDocContent")return null;const r=["k","maxResults","_organizationId"];t==="searchDocs"&&r.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!r.includes(u))),c=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>c&&o(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${c?"cursor-pointer hover:bg-opacity-80":""}`,children:[c&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(Z.ChevronDown,{className:"h-3 w-3"}):h.jsx(Z.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(Z.X,{className:"h-3 w-3"}):s?h.jsx(Z.Zap,{className:"h-3 w-3"}):h.jsx(Z.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&c&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},u))})})]})}function zh({...t}){return h.jsx(js.Root,{"data-slot":"collapsible",...t})}function Uh({...t}){return h.jsx(js.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function _h({...t}){return h.jsx(js.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Wh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ui=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Wh,{className:st("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ui.displayName="Response";const Kh=Object.freeze(Object.defineProperty({__proto__:null,Response:ui},Symbol.toStringTag,{value:"Module"})),Hh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const o=Nh.create(e),r=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(o,{animate:{backgroundPosition:"0% center"},className:st("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${r}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},Gh=m.memo(Hh),Ta=m.createContext(null),Xh=()=>{const t=m.useContext(Ta);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},qh=1e3,Yh=1e3,Sa=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:o,children:r,...a})=>{const[c,u]=xi.useControllableState({prop:n,defaultProp:s,onChange:i}),[l,d]=xi.useControllableState({prop:o,defaultProp:0}),[f,g]=m.useState(!1),[x,v]=m.useState(null);m.useEffect(()=>{e?x===null&&v(Date.now()):x!==null&&(d(Math.ceil((Date.now()-x)/Yh)),v(null))},[e,x,d]),m.useEffect(()=>{if(s&&!e&&c&&!f){const y=setTimeout(()=>{u(!1),g(!0)},qh);return()=>clearTimeout(y)}},[e,c,s,u,f]);const A=y=>{u(y)};return h.jsx(Ta.Provider,{value:{isStreaming:e,isOpen:c,setIsOpen:u,duration:l},children:h.jsx(zh,{className:st("not-prose mb-4",t),onOpenChange:A,open:c,...a,children:r})})}),Jh=(t,e)=>t||e===0?h.jsx(Gh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Aa=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:o}=Xh();return h.jsx(Uh,{className:st("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...n,children:e??h.jsxs(h.Fragment,{children:[h.jsx(Z.BrainIcon,{className:"size-4"}),Jh(s,o),h.jsx(Z.ChevronDownIcon,{className:st("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Pa=m.memo(({className:t,children:e,...n})=>h.jsx(_h,{className:st("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...n,children:h.jsx(ui,{className:"grid gap-2",children:e})}));Sa.displayName="Reasoning";Aa.displayName="ReasoningTrigger";Pa.displayName="ReasoningContent";function Zh(t){const e=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,n=t.match(e),s=new Map;if(n&&n[1]){const u=n[1],l=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let d;for(;(d=l.exec(u))!==null;)if(d[1]&&d[2]){const f=parseInt(d[1],10),g=d[2].replace(/[.,;:!?]+$/,"");s.set(f,g)}}const i=[];let o=0;const r=/```[\s\S]*?```|`[^`]+`/g;let a;for(;(a=r.exec(t))!==null;)a.index>o&&i.push({type:"text",content:t.slice(o,a.index),start:o,end:a.index}),i.push({type:"code",content:a[0],start:a.index,end:a.index+a[0].length}),o=a.index+a[0].length;return o<t.length&&i.push({type:"text",content:t.slice(o),start:o,end:t.length}),i.map(u=>{if(u.type==="code")return u.content;let l=u.content;l=l.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(v,A,y)=>{const w=parseInt(A,10);return`<sup><a href="${y.replace(/"/g,"&quot;")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${w}]</a></sup>`});const d=/\[([^\]]+)\]\([^\)]+\)/g,f=[];let g;for(;(g=d.exec(l))!==null;)f.push({start:g.index,end:g.index+g[0].length});return l.replace(/\[(\d+)\]/g,(v,A,y)=>{if(f.some(j=>y>=j.start&&y<j.end))return v;const T=parseInt(A,10),D=s.get(T);return D?`<sup><a href="${D.replace(/"/g,"&quot;")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${T}]</a></sup>`:v})}).join("")}function Xe(t){if(typeof t=="string")try{const e=JSON.parse(t);return Xe(e)}catch{return t}if(Array.isArray(t))return t.map(Xe);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=Xe(s);return e}return t}function ss(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return Xe(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?Xe(t):{}}function Qh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:o=void 0,defaultWidth:r=384,minWidth:a=300,maxWidth:c=800,initiallyExpanded:u=!1,tools:l=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:x="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:A,state:y,onStateChange:w,allowStateEdits:T=!0}){const[D,j]=m.useState(null),E=m.useRef(null),[O,R]=m.useState(null),[$,q]=m.useState(null),Q=m.useRef(null),z=y!==void 0,[de,Tt]=m.useState({}),it=m.useRef({});z&&y?it.current=y:z||(it.current=de);const[Bt,F]=m.useState(!1),[ct,lt]=m.useState(null),ut=m.useRef(!1),[dt,Vt]=m.useState(u),[yt,he]=m.useState(r),[Gt,Xt]=m.useState(600),[Mt,Rt]=m.useState(!1),[_,fe]=m.useState(!1),[pt,qt]=m.useState(!1),[gt,me]=m.useState({x:100,y:100}),[St,Ne]=m.useState(!1),[Yt,pe]=m.useState({x:0,y:0}),[In,ge]=m.useState(!1),Jt=m.useRef(null),ye=m.useRef(null),[xe,Ie]=m.useState(""),[Le,Ln]=m.useState(null),[On,Fn]=m.useState("Thinking..."),[Oe,P]=m.useState(new Set),[C,V]=m.useState(""),[I,U]=m.useState([]),[W,rt]=m.useState(!1),[Nt,Zt]=m.useState([]),[jt,Fe]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[ve,an]=m.useState(!1),[nf,cn]=m.useState(!1),[sf,ln]=m.useState([]),di=m.useCallback(async(p,b=3)=>{if(!jt||!E.current)return;const M=async()=>{const k=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,N=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:jt,updates:p},format:"json"})});if(!N.ok){if(N.status===404){console.warn("[ArctenAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const tt=await N.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${N.status} ${tt}`)}};for(let S=0;S<b;S++)try{await M(),lt(null);return}catch(k){if(S===b-1){const tt=k instanceof Error?k:new Error(String(k));throw lt(tt),console.error("Failed to sync state to Convex after retries:",k),tt}await new Promise(tt=>setTimeout(tt,Math.pow(2,S)*100))}},[jt,v,E]),Be=m.useMemo(()=>function(){return it.current},[]),$e=m.useMemo(()=>async function(b){const M={...it.current,...b};it.current=M,z||Tt(M),w&&w(M);try{await di(b)}catch(S){throw S}},[di,w,z]);m.useEffect(()=>{z&&y&&(it.current=y)},[z,y]);const Qt=m.useMemo(()=>{const p=[...l,...d,Be];return(!z||T)&&p.push($e),p},[l,d,Be,$e,z,T]),Bn=m.useMemo(()=>wa(Qt,f),[Qt,f]),It=m.useMemo(()=>{const p=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}];return(!z||T)&&p.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}),[...Bn,...p]},[Bn,z,T]),hi=m.useMemo(()=>new Set(It.map(p=>p.name)),[It]),un=m.useMemo(()=>It.filter(p=>p.name==="getState"?!0:p.name==="setState"?!z||T:hi.has(p.name)),[It,hi,z,T]),dn=m.useMemo(()=>{const p=new Map,b=new Map(Bn.map(M=>[M.name,M]));return p.set("getState",Be),(!z||T)&&p.set("setState",$e),Qt.forEach(M=>{if(M===Be||M===$e)return;const S=M[kt];if(S){const N=b.get(S);if(N){p.set(N.name,M);return}}const k=It.find(N=>N.name===M.name);k&&p.set(k.name,M)}),p},[Qt,It,Be,$e,z,T]),ze=m.useMemo(()=>{const p=new Set;p.add("getState"),p.add("setState");const b=new Map(It.map(M=>[M.name,M]));return d.forEach(M=>{const S=M[kt];if(S&&b.has(S))p.add(S);else{const k=It.find(N=>N.name===M.name);k&&p.add(k.name)}}),p},[d,It]),fi=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&Vt(JSON.parse(p));const b=localStorage.getItem("arcten-sidebar-width");b&&he(parseInt(b));const M=localStorage.getItem("arcten-sidebar-height");M&&Xt(parseInt(M));const S=localStorage.getItem("arcten-sidebar-detached");S&&fe(JSON.parse(S));const k=localStorage.getItem("arcten-sidebar-position");if(k){const tt=JSON.parse(k),B=50,et=Math.max(B-r,Math.min(tt.x,window.innerWidth-B)),K=Math.max(0,Math.min(tt.y,window.innerHeight-B));me({x:et,y:K})}const N=localStorage.getItem("arcten-sidebar-minimized");N&&qt(JSON.parse(N)),ge(!0)}},[]);const $t=m.useMemo(()=>A,[A?.id]);m.useEffect(()=>((async()=>{try{const b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!b.ok)throw new Error("Failed to fetch token");const M=await b.json();j(M.clientToken),E.current=M.clientToken,q(M.expiresAt),R(null)}catch(b){R(b instanceof Error?b.message:"Failed to fetch token")}})(),()=>{Q.current&&clearTimeout(Q.current)}),[x,$t]),m.useEffect(()=>{if(!$)return;Q.current&&clearTimeout(Q.current);const p=Math.floor(Date.now()/1e3),b=$-p,S=Math.max(0,b-5);return Q.current=setTimeout(async()=>{try{const k=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!k.ok)throw new Error("Failed to refresh token");const N=await k.json();j(N.clientToken),E.current=N.clientToken,q(N.expiresAt),R(null)}catch(k){console.error("Token refresh failed:",k),R(k instanceof Error?k.message:"Failed to refresh token")}},S*1e3),()=>{Q.current&&clearTimeout(Q.current)}},[$,x,$t]),m.useEffect(()=>{(async()=>{if(Qt.length!==0)try{const b=Qt.map(S=>({name:S.name,code:S.toString()})),M=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:b})});if(M.ok){const S=await M.json();U(S.tools)}}catch(b){console.error("Failed to fetch tool descriptions:",b)}})()},[Qt]),m.useEffect(()=>{Promise.resolve().then(()=>Kh).then(p=>{Ln(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{V(window.location.pathname)};p(),window.addEventListener("popstate",p);const b=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(b)}},[]);const $n=m.useCallback(async()=>{if(!(!$t?.id||!D)){cn(!0);try{const b=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${D}`}})).json();Zt(b.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{cn(!1)}}},[$t?.id,D,v]);m.useEffect(()=>{$t?.id&&D&&$n()},[$t?.id,D,$n]);function Ca(p){const b=Math.floor((Date.now()-p)/1e3);return b<60?"now":b<3600?`${Math.floor(b/60)}m`:b<86400?`${Math.floor(b/3600)}h`:`${Math.floor(b/86400)}d`}function Ma(){const p=crypto.randomUUID();Fe(p),fn([]),ln([]),an(!1);const b=z?y||{}:{};it.current=b,z||Tt(b),w&&w(b),ut.current=!1}async function ja(p){if(D)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${D}`}}),Zt(Nt.filter(b=>b._id!==p)),p===jt&&Ma()}catch(b){console.error("Failed to delete conversation:",b)}}async function Ea(p){Fe(p.chatId),an(!1),cn(!0);try{const b=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${E.current}`}});if(!b.ok)throw new Error(`Failed to fetch messages: ${b.statusText}`);const S=(await b.json()).messages||[];fn(S),ln(S)}catch(b){console.error("Failed to load conversation messages:",b);const M=p.messages||[];fn(M),ln(M)}finally{cn(!1)}}const ka=async(p,b={})=>{const M=b.headers?new Headers(b.headers):new Headers;return M.delete("user-agent"),M.delete("User-Agent"),fetch(p,{...b,headers:M})},{messages:zt,sendMessage:Da,status:Et,error:mi,stop:hn,addToolResult:te,setMessages:fn}=Ir.useChat({id:jt||void 0,transport:new An.DefaultChatTransport({api:`${v}/chat`,fetch:ka,headers:()=>{const p={};return E.current&&(p.Authorization=`Bearer ${E.current}`),p},body:()=>({tools:un.map(b=>({name:b.name,description:b.description,inputSchema:b.jsonSchema})),systemPrompt:g,currentRoute:C,state:it.current})}),sendAutomaticallyWhen:An.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{const p=zt[zt.length-1];if(!p||p.role!=="assistant")return;const b=p.parts?.filter(M=>M.type?.startsWith("tool-")&&M.state==="input-available"&&typeof M.toolCallId=="string"&&M.input!==void 0)||[];for(const M of b){const S=M,k=S.type?.replace("tool-","")||"",N=S.toolCallId;if(ze.has(k)){if(Oe.has(N))continue;P(B=>B.has(N)?B:new Set(B).add(N)),(async()=>{try{const B=dn.get(k);if(!B){console.warn(`[ArctenAgent] Tool ${k} not found in toolsMap. Available tools:`,Array.from(dn.keys())),te({toolCallId:N,tool:k,output:`Error: Tool ${k} not found`}),P(ot=>{const Ut=new Set(ot);return Ut.delete(N),Ut});return}const et=ss(S.input),K=un.find(ot=>ot.name===k);let ht;if(K&&K.jsonSchema?.properties){const Ut=Object.keys(K.jsonSchema.properties).map($a=>et[$a]);console.log(`[ArctenAgent] Executing safe tool ${k} with args:`,Ut),ht=await B(...Ut)}else if(k==="getState")ht=B();else if(k==="setState"){const ot=et.updates||et;ht=await B(ot)}else ht=await B(...Object.values(et));console.log(`[ArctenAgent] Tool ${k} completed, result:`,ht),te({toolCallId:N,tool:k,output:ht}),P(ot=>{const Ut=new Set(ot);return Ut.delete(N),Ut})}catch(B){console.error(`[ArctenAgent] Error executing safe tool ${k}:`,B),te({toolCallId:N,tool:k,output:`Error: ${B instanceof Error?B.message:String(B)}`}),P(et=>{const K=new Set(et);return K.delete(N),K})}})()}}},[zt,ze,dn,un,te]),m.useEffect(()=>{if(!jt||!E.current)return;(async()=>{F(!0),lt(null);try{const M=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,S=await fetch(M,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:jt},format:"json"})});if(!S.ok){if(S.status===404||S.status>=500){console.warn(`[ArctenAgent] Convex API endpoint not available (${S.status}), using empty state`);const K=z?y||{}:{};it.current=K,z||Tt(K),w&&w(K),ut.current=!0,F(!1);return}const et=await S.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${S.status} ${et}`)}const N=(await S.json())?.value||{},tt=!ut.current;let B;tt?(B={...z?y||{}:{},...N},ut.current=!0):B=N,it.current=B,z||Tt(B),w&&w(B)}catch(b){b instanceof TypeError&&b.message.includes("fetch")?console.warn("[ArctenAgent] Network error fetching state (likely Convex endpoint not available), using fallback state:",b):console.error("[ArctenAgent] Failed to fetch state:",b);const S=b instanceof Error?b:new Error(String(b));if(lt(S),!ut.current){const k=z?y||{}:{};it.current=k,z||Tt(k),w&&w(k),ut.current=!0}}finally{F(!1)}})()},[jt,v,z,y,w]),m.useEffect(()=>{dt&&ye.current&&ye.current.focus()},[dt,zt]);function Va(){Vt(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Ra(){Vt(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[dt]),m.useEffect(()=>{Jt.current&&Jt.current.scrollIntoView({behavior:"smooth"})},[zt]),m.useEffect(()=>{function p(b){b.key==="Escape"&&(Et==="streaming"||Et==="submitted")&&(b.preventDefault(),hn())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[Et,hn]);function Na(){const p=crypto.randomUUID();Fe(p),fn([]),ln([]),an(!1)}function pi(p){if(p.preventDefault(),!xe.trim())return;(Et==="streaming"||Et==="submitted")&&hn();const b=fi[Math.floor(Math.random()*fi.length)]||"Thinking...";Fn(b),Da({text:xe}),Ie("")}function Ia(p){const b=p.target.value;Ie(b)}m.useEffect(()=>{if(!Mt)return;function p(M){if(_){const S=M.clientX-gt.x,k=M.clientY-gt.y;S>=a&&S<=c&&he(S),k>=400&&k<=1e3&&Xt(k)}else{const S=window.innerWidth-M.clientX;S>=a&&S<=c&&he(S)}}function b(){Rt(!1),localStorage.setItem("arcten-sidebar-width",yt.toString()),localStorage.setItem("arcten-sidebar-height",Gt.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[Mt,yt,Gt,_,gt,a,c]);function La(p){p.preventDefault(),Rt(!0)}function Oa(){fe(!0),qt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Fa(){fe(!1),qt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function gi(){qt(!pt),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!pt))}function Ba(p){_&&(Ne(!0),pe({x:p.clientX-gt.x,y:p.clientY-gt.y}))}return m.useEffect(()=>{if(!_)return;function p(){me(b=>{const S=window.innerWidth-50,k=window.innerHeight-50,N=50-yt,tt=0,B=Math.max(N,Math.min(b.x,S)),et=Math.max(tt,Math.min(b.y,k));if(B!==b.x||et!==b.y){const K={x:B,y:et};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(K)),K}return b})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[_,yt]),m.useEffect(()=>{if(!St)return;function p(M){const S=M.clientX-Yt.x,k=M.clientY-Yt.y,N=50,tt=window.innerWidth-N,B=window.innerHeight-N,et=N-yt,K=0,ht=Math.max(et,Math.min(S,tt)),ot=Math.max(K,Math.min(k,B));me({x:ht,y:ot})}function b(){Ne(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(gt))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[St,Yt,gt,yt]),In?O?h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",O]})}):D?h.jsx(ru,{features:Ih,children:h.jsx(xn,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:_?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:_?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
20
20
  ${_?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
21
- ${ht?"bg-stone-50 dark:bg-stone-900":"bg-stone-100 dark:bg-stone-800 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors duration-200"}
21
+ ${dt?"bg-stone-50 dark:bg-stone-900":"bg-stone-100 dark:bg-stone-800 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors duration-200"}
22
22
  ${_?"border border-border":"border-l border-border"}
23
- ${ht?"":"w-[30px]"}
24
- `,style:ht?_?{width:`${yt}px`,height:pt?"auto":`${Ht}px`,left:`${gt.x}px`,top:`${gt.y}px`}:{width:`${yt}px`}:void 0,onClick:ht?void 0:Da,children:ht?h.jsxs(h.Fragment,{children:[!_&&h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:Ia,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),_&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),Rt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),Ne(!0),me({x:p.clientX-gt.x,y:p.clientY-gt.y})},children:h.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),Rt(!0)}})]}),h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${_?"cursor-move":""}`,onMouseDown:_?Fa:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${_&&pt?"cursor-pointer":""}`,onClick:_&&pt?p=>{p.stopPropagation(),pi()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx("button",{type:"button",className:it(ie({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Ra,"aria-label":"New chat",children:h.jsx(Q.Plus,{className:"h-4 w-4"})})}),h.jsx(ne,{children:"Start a new conversation"})]}),h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx("button",{type:"button",className:it(ie({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:_?Oa:La,"aria-label":_?"Dock sidebar":"Float sidebar",children:_?h.jsx(Q.Dock,{className:"h-4 w-4"}):h.jsx(Q.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(ne,{children:_?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx("button",{type:"button",className:it(ie({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:_?pi:Va,"aria-label":_?pt?"Maximize":"Minimize":"Close sidebar",children:_?pt?h.jsx(Q.Maximize2,{className:"h-4 w-4"}):h.jsx(Q.Minimize2,{className:"h-4 w-4"}):h.jsx(Q.X,{className:"h-4 w-4"})})}),h.jsx(ne,{children:_?pt?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!pt&&h.jsxs(h.Fragment,{children:[A&&Nt.length>0&&h.jsxs("div",{className:`border-b border-border ${ve?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(wn,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{ve||On(),sn(!ve)},children:ve?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${ve?"flex-1 overflow-y-auto":""}`,children:Nt.slice(0,ve?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:it(ie({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>ja(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:Pa(p.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:b=>{b.stopPropagation(),Ma(p._id)},"aria-label":"Delete conversation",children:h.jsx(Q.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:zt.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&h.jsx("div",{className:"mb-6",children:o}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),I.length>0&&h.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:h.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(W?I:I.slice(0,10)).map(p=>h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Ie(p.sampleUsage),ge.current?.focus()},children:p.friendlyName})}),h.jsx(ne,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),I.length>10&&!W&&h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsxs(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ot(!0),children:["+",I.length-10," more"]})}),h.jsx(ne,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),h.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:I.slice(10).map(p=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[p.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:p.description})]},p.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),W&&I.length>10&&h.jsx(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ot(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[zt.map(p=>{const M=p.parts.filter(T=>T.type==="text").map(T=>T.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(Ih,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:M}):h.jsx("div",{className:"space-y-2",children:p.parts.map((T,k)=>{if(T.type?.startsWith("tool-")){const N=T.type?.replace("tool-","")||"",$=an.find(H=>H.name===N),K=T.state==="input-available",et=T.state==="output-available";if(K&&Fe.has(N),K){if(Fe.has(N))return null;const H=ts(T.input);return h.jsx(mn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(Fh,{toolName:N,description:$?.description||"",args:H,onApprove:async()=>{if(xe.has(T.toolCallId))return;P(at=>new Set(at).add(T.toolCallId));const nt=Ln.get(N);if(nt)try{const at=await nt(...Object.values(H));Qt({toolCallId:T.toolCallId,tool:N,output:at})}catch(at){Qt({toolCallId:T.toolCallId,tool:N,output:`Error: ${at}`})}},onDeny:async()=>{xe.has(T.toolCallId)||(P(nt=>new Set(nt).add(T.toolCallId)),Qt({toolCallId:T.toolCallId,tool:N,output:"User denied tool execution"}))}})},`${T.toolCallId}-${k}`)}else if(et){const H=T.output==="User denied tool execution",nt=ts(T.input);return h.jsx(Bh,{toolName:N,args:nt,isDenied:H,isSafe:Fe.has(N)},`${T.toolCallId}-${k}`)}return null}if(T.type==="text"&&T.text&&Le){const N=Jh(T.text);return h.jsx(Le,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:N},`${p.id}-${k}`)}return T.type==="reasoning"&&T.text?h.jsxs(Ta,{className:"w-full",isStreaming:Et==="streaming"&&k===p.parts.length-1&&p.id===zt.at(-1)?.id,children:[h.jsx(Sa,{}),h.jsx(Aa,{children:T.text})]},`${p.id}-${k}`):null})})})},p.id)}),h.jsx("div",{ref:Yt})]})}),fi&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",fi.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(su,{mode:"wait",children:(Et==="streaming"||Et==="submitted")&&h.jsxs(mn,{initial:{opacity:0,filter:"blur(4px)",y:5},animate:{opacity:1,filter:"blur(0px)",y:0},exit:{opacity:0,filter:"blur(4px)",y:5},transition:{duration:.2,ease:"easeOut"},className:"absolute left-1/2 -translate-x-1/2 -top-6 flex items-center gap-1.5 bg-stone-100 dark:bg-stone-800 px-3 py-1.5 rounded-full shadow-lg border border-border z-50",children:[h.jsx(mn,{className:"w-2 h-2 bg-stone-400 dark:bg-stone-600",animate:{rotate:[0,0,90,90],borderRadius:["50%","30%","30%","50%"],scale:[.75,1,1,.75]},transition:{duration:2,repeat:1/0,ease:"easeInOut",times:[0,.4,.6,1]}}),h.jsx("p",{className:"text-xs text-muted-foreground",children:Rn})]})}),h.jsxs("form",{onSubmit:mi,className:"relative",children:[h.jsx(Or,{ref:ge,value:ye,onChange:Na,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),mi(p))}}),Et==="streaming"||Et==="submitted"?h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx("button",{type:"button",className:it(ie({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:cn,children:h.jsx(Q.Square,{className:"h-4 w-4"})})}),h.jsxs(ne,{children:[h.jsx(xi,{children:"Escape"})," to stop"]})]}):h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx("button",{type:"submit",className:it(ie({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!ye.trim(),children:h.jsx(Q.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(ne,{children:[h.jsx(xi,{children:"Enter"})," to send"]})]})]})]})]}),h.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[h.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(Q.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),h.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function He(t){if(typeof t=="string")try{const e=JSON.parse(t);return He(e)}catch{return t}if(Array.isArray(t))return t.map(He);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=He(s);return e}return t}function Qh(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return He(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?He(t):{}}function tf({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:o=[],safeTools:r=[],toolMetadata:a,systemPrompt:c="",initialMessages:u=[],conversationId:l,initialState:d={},onToolCall:f,onFinish:g,ragFilters:x}={}){const[v,A]=m.useState(n||null),y=m.useRef(n||null),[w,S]=m.useState(null),[D,j]=m.useState(null),E=m.useRef(null),[O,R]=m.useState([]),[B,Y]=m.useState(l||(typeof window<"u"?crypto.randomUUID():null)),[tt,z]=m.useState(!1),[ue,Tt]=m.useState(new Set),[rt,Bt]=m.useState(d),F=m.useRef(d),[lt,ut]=m.useState(!1),[dt,ht]=m.useState(null),Vt=m.useRef(!1),yt=m.useCallback(async(P,C=3)=>{if(!B||!y.current)return;const V=async()=>{const I=await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:B,updates:P},format:"json"})});if(!I.ok){const U=await I.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${I.status} ${U}`)}};for(let I=0;I<C;I++)try{await V(),ht(null);return}catch(U){if(I===C-1){const ot=U instanceof Error?U:new Error(String(U));throw ht(ot),console.error("Failed to sync state to Convex after retries:",U),ot}await new Promise(ot=>setTimeout(ot,Math.pow(2,I)*100))}},[B,t,y]),de=m.useMemo(()=>function(){return F.current},[]),Ht=m.useMemo(()=>async function(C){const V={...F.current,...C};F.current=V,Bt(V);try{await yt(C)}catch(I){throw I}},[yt]),Gt=m.useMemo(()=>[...o,...r,de,Ht],[o,r,de,Ht]),Mt=m.useMemo(()=>ba(Gt,a),[Gt,a]),Rt=m.useMemo(()=>{const P=new Map,C=new Map(Mt.map(V=>[V.name,V]));return Gt.forEach(V=>{const I=V[kt];if(I){const W=C.get(I);if(W){P.set(W.name,V);return}}const U=Mt.find(W=>W.name===V.name);U&&P.set(U.name,V)}),P},[Gt,Mt]),_=m.useMemo(()=>new Set(Mt.map(P=>P.name)),[Mt]),he=m.useMemo(()=>{const P=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}},{name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}];return[...Mt,...P]},[Mt]),pt=m.useMemo(()=>he.filter(P=>P.name==="getState"||P.name==="setState"?!0:_.has(P.name)),[he,_]),Xt=m.useMemo(()=>{const P=new Set;return P.add("getState"),P.add("setState"),r.forEach(C=>{for(const[V,I]of Rt.entries())if(I===C){P.add(V);break}}),P},[r,Rt]);m.useEffect(()=>s||n?void 0:((async()=>{try{const C=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!C.ok)throw new Error("Failed to fetch token");const V=await C.json();A(V.clientToken),y.current=V.clientToken,j(V.expiresAt),S(null)}catch(C){console.error("[useAgent] Token fetch failed:",C),S(C instanceof Error?C.message:"Failed to fetch token")}})(),()=>{E.current&&clearTimeout(E.current)}),[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(!D||s||n)return;E.current&&clearTimeout(E.current);const P=Math.floor(Date.now()/1e3),C=D-P,I=Math.max(0,C-5);return E.current=setTimeout(async()=>{try{const U=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!U.ok)throw new Error("Failed to refresh token");const W=await U.json();A(W.clientToken),y.current=W.clientToken,j(W.expiresAt),S(null)}catch(U){console.error("[useAgent] Token refresh failed:",U),S(U instanceof Error?U.message:"Failed to refresh token")}},I*1e3),()=>{E.current&&clearTimeout(E.current)}},[D,e,JSON.stringify(i),s,n]);const gt=async(P,C={})=>{const V=C.headers?new Headers(C.headers):new Headers;V.delete("user-agent"),V.delete("User-Agent"),console.log("[useAgent] Making request to:",P),console.log("[useAgent] Method:",C.method||"GET"),console.log("[useAgent] Has Authorization header:",V.has("Authorization")),console.log("[useAgent] Client token available:",!!y.current);try{const I=await fetch(P,{...C,headers:V});if(!I.ok){console.error("[useAgent] Request failed:",I.status,I.statusText);const U=await I.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",U)}return I}catch(I){throw console.error("[useAgent] Fetch error:",I),I}},fe=`${t}/chat`;console.log("[useAgent] Chat API URL:",fe);const{messages:St,sendMessage:Ne,status:qt,error:me,stop:Dn,addToolResult:pe,setMessages:Yt}=Nr.useChat({id:B||void 0,messages:u,transport:new bn.DefaultChatTransport({api:fe,fetch:gt,headers:()=>{const P={};return y.current?(P.Authorization=`Bearer ${y.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),P},body:()=>{const P=pt.map(V=>({name:V.name,description:V.description,inputSchema:V.jsonSchema})),C=P.filter(V=>V.name==="getState"||V.name==="setState").map(V=>V.name);return C.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",C),{tools:P,systemPrompt:c,state:F.current,...x&&{ragFilters:x}}}}),sendAutomaticallyWhen:bn.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{St.forEach(P=>{P.role==="assistant"&&P.parts.forEach(C=>{if(!C.type?.startsWith("tool-")||C.state!=="input-available")return;const V=C.type.replace("tool-",""),I=C.toolCallId;if(ue.has(I))return;Tt(W=>new Set(W).add(I));const U=Qh(C.input);if(Xt.has(V)){const W=Rt.get(V);W?(async()=>{try{const ot=pt.find(Jt=>Jt.name===V);let Nt;if(ot&&ot.jsonSchema?.properties){const jt=Object.keys(ot.jsonSchema.properties).map(Oe=>U[Oe]);Nt=await W(...jt)}else if(V==="getState")Nt=W();else if(V==="setState"){const Jt=U.updates||U;Nt=await W(Jt)}else Nt=await W(...Object.values(U));pe({toolCallId:I,tool:V,output:Nt})}catch(ot){console.error(`[useAgent] Error executing tool ${V}:`,ot),pe({toolCallId:I,tool:V,output:`Error: ${ot}`})}})():console.warn(`[useAgent] Tool ${V} not found in toolsMap`)}else f&&f({toolCall:{toolCallId:I,toolName:V,args:U}})})})},[St,Xt,Rt,f,pe,ue,Ht,pt]),m.useEffect(()=>{if(qt==="ready"&&St.length>0&&g){const P=St[St.length-1];P&&P.role==="assistant"&&g({message:P,messages:St,isAbort:!1,isDisconnect:!1,isError:!!me})}},[qt,St,me,g]);async function ge(){if(!(!i?.id||!v)){z(!0);try{const C=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${v}`}})).json();R(C.conversations||[])}catch(P){console.error("Failed to fetch conversations:",P)}finally{z(!1)}}}m.useEffect(()=>{i?.id&&v&&ge()},[JSON.stringify(i),v,t]),m.useEffect(()=>{if(!B||!y.current)return;(async()=>{ut(!0),ht(null);try{const C=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:B},format:"json"})});if(!C.ok){const ot=await C.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${C.status} ${ot}`)}const I=(await C.json())?.value||{},U=!Vt.current;let W;U?(W={...d,...I},Vt.current=!0):W=I,F.current=W,Bt(W)}catch(C){console.error("Failed to fetch state:",C);const V=C instanceof Error?C:new Error(String(C));ht(V),Vt.current||(F.current=d,Bt(d),Vt.current=!0)}finally{ut(!1)}})()},[B,t]);async function ye(P){Y(P),z(!0);try{const C=await fetch(`${t}/conversations/${P}/messages`,{headers:{Authorization:`Bearer ${y.current}`}});if(!C.ok)throw new Error(`Failed to fetch messages: ${C.statusText}`);const I=(await C.json()).messages||[];Yt(I)}catch(C){console.error("Failed to load conversation messages:",C)}finally{z(!1)}}async function Ie(P){if(v)try{await fetch(`${t}/conversations/${P}`,{method:"DELETE",headers:{Authorization:`Bearer ${v}`}}),R(O.filter(C=>C._id!==P)),P===B&&Le()}catch(C){console.error("Failed to delete conversation:",C)}}function Le(){const P=crypto.randomUUID();Y(P),Yt([]),Tt(new Set),F.current=d,Bt(d),Vt.current=!1}function Vn(P){pe(P)}async function Rn(P){const C={...F.current,...P};F.current=C,Bt(C);try{await yt(P)}catch(V){throw V}}async function Nn(){if(!i?.id||!y.current)throw new Error("User authentication required to share state");const P=`shared_${crypto.randomUUID()}`;try{return await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:create",args:{stateId:P,state:F.current,projectId:"default",createdBy:i.id},format:"json"})}),P}catch(C){throw console.error("Failed to share state:",C),C}}async function xe(P){if(!y.current)throw new Error("Authentication required to import state");try{const C=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:P},format:"json"})});if(!C.ok)throw new Error("Failed to fetch shared state");const I=(await C.json())?.value||{};F.current=I,Bt(I)}catch(C){throw console.error("Failed to import state:",C),C}}return{id:B,messages:St,status:qt,error:me,sendMessage:Ne,stop:Dn,addToolOutput:Vn,setMessages:Yt,conversations:O,loadConversation:ye,deleteConversation:Ie,startNewConversation:Le,isLoadingConversations:tt,clientToken:v,tokenError:w,state:rt,setState:Rn,shareState:Nn,importState:xe,isStateLoading:lt,stateError:dt}}exports.verifyToken=Ja.verifyToken;exports.ARCTEN_ORIGINAL_NAME=kt;exports.ArctenAgent=Zh;exports.preserveToolName=Lh;exports.useAgent=tf;
23
+ ${dt?"":"w-[30px]"}
24
+ `,style:dt?_?{width:`${yt}px`,height:pt?"auto":`${Gt}px`,left:`${gt.x}px`,top:`${gt.y}px`}:{width:`${yt}px`}:void 0,onClick:dt?void 0:Va,children:dt?h.jsxs(h.Fragment,{children:[!_&&h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:La,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),_&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),Rt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),Ne(!0),pe({x:p.clientX-gt.x,y:p.clientY-gt.y})},children:h.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),Rt(!0)}})]}),h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${_?"cursor-move":""}`,onMouseDown:_?Ba:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${_&&pt?"cursor-pointer":""}`,onClick:_&&pt?p=>{p.stopPropagation(),gi()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:st(re({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Na,"aria-label":"New chat",children:h.jsx(Z.Plus,{className:"h-4 w-4"})})}),h.jsx(se,{children:"Start a new conversation"})]}),h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:st(re({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:_?Fa:Oa,"aria-label":_?"Dock sidebar":"Float sidebar",children:_?h.jsx(Z.Dock,{className:"h-4 w-4"}):h.jsx(Z.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(se,{children:_?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:st(re({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:_?gi:Ra,"aria-label":_?pt?"Maximize":"Minimize":"Close sidebar",children:_?pt?h.jsx(Z.Maximize2,{className:"h-4 w-4"}):h.jsx(Z.Minimize2,{className:"h-4 w-4"}):h.jsx(Z.X,{className:"h-4 w-4"})})}),h.jsx(se,{children:_?pt?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!pt&&h.jsxs(h.Fragment,{children:[A&&Nt.length>0&&h.jsxs("div",{className:`border-b border-border ${ve?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(Pn,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{ve||$n(),an(!ve)},children:ve?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${ve?"flex-1 overflow-y-auto":""}`,children:Nt.slice(0,ve?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:st(re({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>Ea(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:Ca(p.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:b=>{b.stopPropagation(),ja(p._id)},"aria-label":"Delete conversation",children:h.jsx(Z.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:zt.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&h.jsx("div",{className:"mb-6",children:o}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),I.length>0&&h.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:h.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(W?I:I.slice(0,10)).map(p=>h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Ie(p.sampleUsage),ye.current?.focus()},children:p.friendlyName})}),h.jsx(se,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),I.length>10&&!W&&h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsxs(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>rt(!0),children:["+",I.length-10," more"]})}),h.jsx(se,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),h.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:I.slice(10).map(p=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[p.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:p.description})]},p.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),W&&I.length>10&&h.jsx(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>rt(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[zt.map(p=>{const M=p.parts.filter(S=>S.type==="text").map(S=>S.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(Lh,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:M}):h.jsx("div",{className:"space-y-2",children:p.parts.map((S,k)=>{if(S.type?.startsWith("tool-")){const N=S.type?.replace("tool-","")||"",tt=un.find(K=>K.name===N),B=S.state==="input-available",et=S.state==="output-available";if(B&&ze.has(N),B){if(ze.has(N))return null;const K=ss(S.input);return h.jsx(xn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(Bh,{toolName:N,description:tt?.description||"",args:K,onApprove:async()=>{if(Oe.has(S.toolCallId))return;P(ot=>new Set(ot).add(S.toolCallId));const ht=dn.get(N);if(ht)try{const ot=await ht(...Object.values(K));te({toolCallId:S.toolCallId,tool:N,output:ot})}catch(ot){te({toolCallId:S.toolCallId,tool:N,output:`Error: ${ot}`})}},onDeny:async()=>{Oe.has(S.toolCallId)||(P(ht=>new Set(ht).add(S.toolCallId)),te({toolCallId:S.toolCallId,tool:N,output:"User denied tool execution"}))}})},`${S.toolCallId}-${k}`)}else if(et){const K=S.output==="User denied tool execution",ht=ss(S.input);return h.jsx($h,{toolName:N,args:ht,isDenied:K,isSafe:ze.has(N)},`${S.toolCallId}-${k}`)}return null}if(S.type==="text"&&S.text&&Le){const N=Zh(S.text);return h.jsx(Le,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:N},`${p.id}-${k}`)}return S.type==="reasoning"&&S.text?h.jsxs(Sa,{className:"w-full",isStreaming:Et==="streaming"&&k===p.parts.length-1&&p.id===zt.at(-1)?.id,children:[h.jsx(Aa,{}),h.jsx(Pa,{children:S.text})]},`${p.id}-${k}`):null})})})},p.id)}),h.jsx("div",{ref:Jt})]})}),mi&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",mi.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(iu,{mode:"wait",children:(Et==="streaming"||Et==="submitted")&&h.jsxs(xn,{initial:{opacity:0,filter:"blur(4px)",y:5},animate:{opacity:1,filter:"blur(0px)",y:0},exit:{opacity:0,filter:"blur(4px)",y:5},transition:{duration:.2,ease:"easeOut"},className:"absolute left-1/2 -translate-x-1/2 -top-6 flex items-center gap-1.5 bg-stone-100 dark:bg-stone-800 px-3 py-1.5 rounded-full shadow-lg border border-border z-50",children:[h.jsx(xn,{className:"w-2 h-2 bg-stone-400 dark:bg-stone-600",animate:{rotate:[0,0,90,90],borderRadius:["50%","30%","30%","50%"],scale:[.75,1,1,.75]},transition:{duration:2,repeat:1/0,ease:"easeInOut",times:[0,.4,.6,1]}}),h.jsx("p",{className:"text-xs text-muted-foreground",children:On})]})}),h.jsxs("form",{onSubmit:pi,className:"relative",children:[h.jsx(Fr,{ref:ye,value:xe,onChange:Ia,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),pi(p))}}),Et==="streaming"||Et==="submitted"?h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:st(re({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:hn,children:h.jsx(Z.Square,{className:"h-4 w-4"})})}),h.jsxs(se,{children:[h.jsx(vi,{children:"Escape"})," to stop"]})]}):h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"submit",className:st(re({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!xe.trim(),children:h.jsx(Z.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(se,{children:[h.jsx(vi,{children:"Enter"})," to send"]})]})]})]})]}),h.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[h.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(Z.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),h.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function qe(t){if(typeof t=="string")try{const e=JSON.parse(t);return qe(e)}catch{return t}if(Array.isArray(t))return t.map(qe);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=qe(s);return e}return t}function tf(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return qe(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?qe(t):{}}function ef({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:o=[],safeTools:r=[],toolMetadata:a,systemPrompt:c="",initialMessages:u=[],conversationId:l,initialState:d={},onToolCall:f,onFinish:g,ragFilters:x}={}){const[v,A]=m.useState(n||null),y=m.useRef(n||null),[w,T]=m.useState(null),[D,j]=m.useState(null),E=m.useRef(null),[O,R]=m.useState([]),[$,q]=m.useState(l||(typeof window<"u"?crypto.randomUUID():null)),[Q,z]=m.useState(!1),[de,Tt]=m.useState(new Set),[it,Bt]=m.useState(d),F=m.useRef(d),[ct,lt]=m.useState(!1),[ut,dt]=m.useState(null),Vt=m.useRef(!1),yt=m.useCallback(async(P,C=3)=>{if(!$||!y.current)return;const V=async()=>{const I=await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:$,updates:P},format:"json"})});if(!I.ok){const U=await I.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${I.status} ${U}`)}};for(let I=0;I<C;I++)try{await V(),dt(null);return}catch(U){if(I===C-1){const rt=U instanceof Error?U:new Error(String(U));throw dt(rt),console.error("Failed to sync state to Convex after retries:",U),rt}await new Promise(rt=>setTimeout(rt,Math.pow(2,I)*100))}},[$,t,y]),he=m.useMemo(()=>function(){return F.current},[]),Gt=m.useMemo(()=>async function(C){const V={...F.current,...C};F.current=V,Bt(V);try{await yt(C)}catch(I){throw I}},[yt]),Xt=m.useMemo(()=>[...o,...r,he,Gt],[o,r,he,Gt]),Mt=m.useMemo(()=>wa(Xt,a),[Xt,a]),Rt=m.useMemo(()=>{const P=new Map,C=new Map(Mt.map(V=>[V.name,V]));return Xt.forEach(V=>{const I=V[kt];if(I){const W=C.get(I);if(W){P.set(W.name,V);return}}const U=Mt.find(W=>W.name===V.name);U&&P.set(U.name,V)}),P},[Xt,Mt]),_=m.useMemo(()=>new Set(Mt.map(P=>P.name)),[Mt]),fe=m.useMemo(()=>{const P=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}},{name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}];return[...Mt,...P]},[Mt]),pt=m.useMemo(()=>fe.filter(P=>P.name==="getState"||P.name==="setState"?!0:_.has(P.name)),[fe,_]),qt=m.useMemo(()=>{const P=new Set;return P.add("getState"),P.add("setState"),r.forEach(C=>{for(const[V,I]of Rt.entries())if(I===C){P.add(V);break}}),P},[r,Rt]);m.useEffect(()=>s||n?void 0:((async()=>{try{const C=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!C.ok)throw new Error("Failed to fetch token");const V=await C.json();A(V.clientToken),y.current=V.clientToken,j(V.expiresAt),T(null)}catch(C){console.error("[useAgent] Token fetch failed:",C),T(C instanceof Error?C.message:"Failed to fetch token")}})(),()=>{E.current&&clearTimeout(E.current)}),[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(!D||s||n)return;E.current&&clearTimeout(E.current);const P=Math.floor(Date.now()/1e3),C=D-P,I=Math.max(0,C-5);return E.current=setTimeout(async()=>{try{const U=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!U.ok)throw new Error("Failed to refresh token");const W=await U.json();A(W.clientToken),y.current=W.clientToken,j(W.expiresAt),T(null)}catch(U){console.error("[useAgent] Token refresh failed:",U),T(U instanceof Error?U.message:"Failed to refresh token")}},I*1e3),()=>{E.current&&clearTimeout(E.current)}},[D,e,JSON.stringify(i),s,n]);const gt=async(P,C={})=>{const V=C.headers?new Headers(C.headers):new Headers;V.delete("user-agent"),V.delete("User-Agent"),console.log("[useAgent] Making request to:",P),console.log("[useAgent] Method:",C.method||"GET"),console.log("[useAgent] Has Authorization header:",V.has("Authorization")),console.log("[useAgent] Client token available:",!!y.current);try{const I=await fetch(P,{...C,headers:V});if(!I.ok){console.error("[useAgent] Request failed:",I.status,I.statusText);const U=await I.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",U)}return I}catch(I){throw console.error("[useAgent] Fetch error:",I),I}},me=`${t}/chat`;console.log("[useAgent] Chat API URL:",me);const{messages:St,sendMessage:Ne,status:Yt,error:pe,stop:In,addToolResult:ge,setMessages:Jt}=Ir.useChat({id:$||void 0,messages:u,transport:new An.DefaultChatTransport({api:me,fetch:gt,headers:()=>{const P={};return y.current?(P.Authorization=`Bearer ${y.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),P},body:()=>{const P=pt.map(V=>({name:V.name,description:V.description,inputSchema:V.jsonSchema})),C=P.filter(V=>V.name==="getState"||V.name==="setState").map(V=>V.name);return C.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",C),{tools:P,systemPrompt:c,state:F.current,...x&&{ragFilters:x}}}}),sendAutomaticallyWhen:An.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{St.forEach(P=>{P.role==="assistant"&&P.parts.forEach(C=>{if(!C.type?.startsWith("tool-")||C.state!=="input-available")return;const V=C.type.replace("tool-",""),I=C.toolCallId;if(de.has(I))return;Tt(W=>new Set(W).add(I));const U=tf(C.input);if(qt.has(V)){const W=Rt.get(V);W?(async()=>{try{const rt=pt.find(Zt=>Zt.name===V);let Nt;if(rt&&rt.jsonSchema?.properties){const jt=Object.keys(rt.jsonSchema.properties).map(Fe=>U[Fe]);Nt=await W(...jt)}else if(V==="getState")Nt=W();else if(V==="setState"){const Zt=U.updates||U;Nt=await W(Zt)}else Nt=await W(...Object.values(U));ge({toolCallId:I,tool:V,output:Nt})}catch(rt){console.error(`[useAgent] Error executing tool ${V}:`,rt),ge({toolCallId:I,tool:V,output:`Error: ${rt}`})}})():console.warn(`[useAgent] Tool ${V} not found in toolsMap`)}else f&&f({toolCall:{toolCallId:I,toolName:V,args:U}})})})},[St,qt,Rt,f,ge,de,Gt,pt]),m.useEffect(()=>{if(Yt==="ready"&&St.length>0&&g){const P=St[St.length-1];P&&P.role==="assistant"&&g({message:P,messages:St,isAbort:!1,isDisconnect:!1,isError:!!pe})}},[Yt,St,pe,g]);async function ye(){if(!(!i?.id||!v)){z(!0);try{const C=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${v}`}})).json();R(C.conversations||[])}catch(P){console.error("Failed to fetch conversations:",P)}finally{z(!1)}}}m.useEffect(()=>{i?.id&&v&&ye()},[JSON.stringify(i),v,t]),m.useEffect(()=>{if(!$||!y.current)return;(async()=>{lt(!0),dt(null);try{const C=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:$},format:"json"})});if(!C.ok){const rt=await C.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${C.status} ${rt}`)}const I=(await C.json())?.value||{},U=!Vt.current;let W;U?(W={...d,...I},Vt.current=!0):W=I,F.current=W,Bt(W)}catch(C){console.error("Failed to fetch state:",C);const V=C instanceof Error?C:new Error(String(C));dt(V),Vt.current||(F.current=d,Bt(d),Vt.current=!0)}finally{lt(!1)}})()},[$,t]);async function xe(P){q(P),z(!0);try{const C=await fetch(`${t}/conversations/${P}/messages`,{headers:{Authorization:`Bearer ${y.current}`}});if(!C.ok)throw new Error(`Failed to fetch messages: ${C.statusText}`);const I=(await C.json()).messages||[];Jt(I)}catch(C){console.error("Failed to load conversation messages:",C)}finally{z(!1)}}async function Ie(P){if(v)try{await fetch(`${t}/conversations/${P}`,{method:"DELETE",headers:{Authorization:`Bearer ${v}`}}),R(O.filter(C=>C._id!==P)),P===$&&Le()}catch(C){console.error("Failed to delete conversation:",C)}}function Le(){const P=crypto.randomUUID();q(P),Jt([]),Tt(new Set),F.current=d,Bt(d),Vt.current=!1}function Ln(P){ge(P)}async function On(P){const C={...F.current,...P};F.current=C,Bt(C);try{await yt(P)}catch(V){throw V}}async function Fn(){if(!i?.id||!y.current)throw new Error("User authentication required to share state");const P=`shared_${crypto.randomUUID()}`;try{return await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:create",args:{stateId:P,state:F.current,projectId:"default",createdBy:i.id},format:"json"})}),P}catch(C){throw console.error("Failed to share state:",C),C}}async function Oe(P){if(!y.current)throw new Error("Authentication required to import state");try{const C=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:P},format:"json"})});if(!C.ok)throw new Error("Failed to fetch shared state");const I=(await C.json())?.value||{};F.current=I,Bt(I)}catch(C){throw console.error("Failed to import state:",C),C}}return{id:$,messages:St,status:Yt,error:pe,sendMessage:Ne,stop:In,addToolOutput:Ln,setMessages:Jt,conversations:O,loadConversation:xe,deleteConversation:Ie,startNewConversation:Le,isLoadingConversations:Q,clientToken:v,tokenError:w,state:it,setState:On,shareState:Fn,importState:Oe,isStateLoading:ct,stateError:ut}}exports.verifyToken=Za.verifyToken;exports.ARCTEN_ORIGINAL_NAME=kt;exports.ArctenAgent=Qh;exports.preserveToolName=Oh;exports.useAgent=ef;