@arcteninc/core 0.0.20 → 0.0.21

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 va=Object.create;var Hs=Object.defineProperty;var ba=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var Ta=Object.getPrototypeOf,Sa=Object.prototype.hasOwnProperty;var Ca=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of wa(t))!Sa.call(e,i)&&i!==n&&Hs(e,i,{get:()=>t[i],enumerable:!(s=ba(t,i))||s.enumerable});return e};var Pa=(e,t,n)=>(n=e!=null?va(Ta(e)):{},Ca(t||!e||!e.__esModule?Hs(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),G=require("lucide-react"),ho=require("@ai-sdk/react"),Xt=require("ai"),fo=require("@radix-ui/react-slot"),mo=require("class-variance-authority"),Aa=require("clsx"),Ma=require("tailwind-merge"),ja=require("@radix-ui/react-tooltip"),N=require("zod"),Da=require("acorn"),Xs=require("@radix-ui/react-use-controllable-state"),Ea=require("@radix-ui/react-collapsible"),Va=require("./server.cjs");function Qt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const he=Qt(m),nt=Qt(ja),ka=Qt(Da),Jn=Qt(Ea);function J(...e){return Ma.twMerge(Aa.clsx(e))}const Ge=mo.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",{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"}}),xt=he.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...i},r)=>{const o=s?fo.Slot:"button";return h.jsx(o,{ref:r,"data-slot":"button",className:J(Ge({variant:t,size:n,className:e})),...i})});xt.displayName="Button";const Ra=mo.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 hn({className:e,variant:t,asChild:n=!1,...s}){const i=n?fo.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:J(Ra({variant:t}),e),...s})}const Na=({textAreaRef:e,triggerAutoSize:t,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=he.useState(!0);he.useEffect(()=>{const a=e.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),r(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[e.current,t])},po=he.forwardRef(({maxHeight:e=Number.MAX_SAFE_INTEGER,minHeight:t=52,className:n,onChange:s,value:i,...r},o)=>{const a=he.useRef(null),[l,u]=he.useState("");return Na({textAreaRef:a,triggerAutoSize:l,maxHeight:e,minHeight:t}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:e,minHeight:t})),he.useEffect(()=>{u(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,value:i,ref:a,className:J("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:c=>{u(c.target.value),s?.(c)}})});po.displayName="AutosizeTextarea";function Ia({delayDuration:e=0,...t}){return h.jsx(nt.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Oe({...e}){return h.jsx(Ia,{children:h.jsx(nt.Root,{"data-slot":"tooltip",...e})})}function Fe({...e}){return h.jsx(nt.Trigger,{"data-slot":"tooltip-trigger",...e})}function Be({className:e,sideOffset:t=0,children:n,...s}){return h.jsx(nt.Portal,{children:h.jsxs(nt.Content,{"data-slot":"tooltip-content",sideOffset:t,className:J("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",e),...s,children:[n,h.jsx(nt.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Ys({className:e,...t}){return h.jsx("kbd",{"data-slot":"kbd",className:J("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",e),...t})}const Qn=m.createContext({});function es(e){const t=m.useRef(null);return t.current===null&&(t.current=e()),t.current}const ts=typeof window<"u",go=ts?m.useLayoutEffect:m.useEffect,en=m.createContext(null);function ns(e,t){e.indexOf(t)===-1&&e.push(t)}function ss(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const Te=(e,t,n)=>n>t?t:n<e?e:n;function jn(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let rt=()=>{},Se=()=>{};process.env.NODE_ENV!=="production"&&(rt=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(jn(t,n))},Se=(e,t,n)=>{if(!e)throw new Error(jn(t,n))});const Ce={},yo=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function xo(e){return typeof e=="object"&&e!==null}const vo=e=>/^0[^.\s]+$/u.test(e);function is(e){let t;return()=>(t===void 0&&(t=e()),t)}const ce=e=>e,La=(e,t)=>n=>t(e(n)),Pt=(...e)=>e.reduce(La),vt=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class os{constructor(){this.subscriptions=[]}add(t){return ns(this.subscriptions,t),()=>ss(this.subscriptions,t)}notify(t,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,s);else for(let r=0;r<i;r++){const o=this.subscriptions[r];o&&o(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const fe=e=>e*1e3,le=e=>e/1e3;function bo(e,t){return t?e*(1e3/t):0}const Gs=new Set;function rs(e,t,n){e||Gs.has(t)||(console.warn(jn(t,n)),Gs.add(t))}const wo=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Oa=1e-7,Fa=12;function Ba(e,t,n,s,i){let r,o,a=0;do o=t+(n-t)/2,r=wo(o,s,i)-e,r>0?n=o:t=o;while(Math.abs(r)>Oa&&++a<Fa);return o}function At(e,t,n,s){if(e===t&&n===s)return ce;const i=r=>Ba(r,0,1,e,n);return r=>r===0||r===1?r:wo(i(r),t,s)}const To=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,So=e=>t=>1-e(1-t),Co=At(.33,1.53,.69,.99),as=So(Co),Po=To(as),Ao=e=>(e*=2)<1?.5*as(e):.5*(2-Math.pow(2,-10*(e-1))),ls=e=>1-Math.sin(Math.acos(e)),Mo=So(ls),jo=To(ls),za=At(.42,0,1,1),$a=At(0,0,.58,1),Do=At(.42,0,.58,1),Ua=e=>Array.isArray(e)&&typeof e[0]!="number",Eo=e=>Array.isArray(e)&&typeof e[0]=="number",qs={linear:ce,easeIn:za,easeInOut:Do,easeOut:$a,circIn:ls,circInOut:jo,circOut:Mo,backIn:as,backInOut:Po,backOut:Co,anticipate:Ao},Wa=e=>typeof e=="string",Zs=e=>{if(Eo(e)){Se(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,i]=e;return At(t,n,s,i)}else if(Wa(e))return Se(qs[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),qs[e];return e},Lt=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function _a(e,t){let n=new Set,s=new Set,i=!1,r=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(c){o.has(c)&&(u.schedule(c),e()),c(a)}const u={schedule:(c,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(c),y.has(c)||y.add(c),c},cancel:c=>{s.delete(c),o.delete(c)},process:c=>{if(a=c,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,u.process(c))}};return u}const Ka=40;function Vo(e,t){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Lt.reduce((T,M)=>(T[M]=_a(r),T),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:c,update:d,preRender:f,render:p,postRender:y}=o,x=()=>{const T=Ce.useManualTiming?i.timestamp:performance.now();n=!1,Ce.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(T-i.timestamp,Ka),1)),i.timestamp=T,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),c.process(i),d.process(i),f.process(i),p.process(i),y.process(i),i.isProcessing=!1,n&&t&&(s=!1,e(x))},b=()=>{n=!0,s=!0,i.isProcessing||e(x)};return{schedule:Lt.reduce((T,M)=>{const P=o[M];return T[M]=(V,D=!1,A=!1)=>(n||b(),P.schedule(V,D,A)),T},{}),cancel:T=>{for(let M=0;M<Lt.length;M++)o[Lt[M]].cancel(T)},state:i,steps:o}}const{schedule:z,cancel:De,state:q,steps:fn}=Vo(typeof requestAnimationFrame<"u"?requestAnimationFrame:ce,!0);let $t;function Ha(){$t=void 0}const ie={now:()=>($t===void 0&&ie.set(q.isProcessing||Ce.useManualTiming?q.timestamp:performance.now()),$t),set:e=>{$t=e,queueMicrotask(Ha)}},ko=e=>t=>typeof t=="string"&&t.startsWith(e),cs=ko("--"),Xa=ko("var(--"),us=e=>Xa(e)?Ya.test(e.split("/*")[0].trim()):!1,Ya=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,at={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},bt={...at,transform:e=>Te(0,1,e)},Ot={...at,default:1},mt=e=>Math.round(e*1e5)/1e5,ds=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ga(e){return e==null}const qa=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,hs=(e,t)=>n=>!!(typeof n=="string"&&qa.test(n)&&n.startsWith(e)||t&&!Ga(n)&&Object.prototype.hasOwnProperty.call(n,t)),Ro=(e,t,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(ds);return{[e]:parseFloat(i),[t]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Za=e=>Te(0,255,e),mn={...at,transform:e=>Math.round(Za(e))},Ue={test:hs("rgb","red"),parse:Ro("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+mn.transform(e)+", "+mn.transform(t)+", "+mn.transform(n)+", "+mt(bt.transform(s))+")"};function Ja(e){let t="",n="",s="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,s+=s,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const Dn={test:hs("#"),parse:Ja,transform:Ue.transform},Mt=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),je=Mt("deg"),xe=Mt("%"),j=Mt("px"),Qa=Mt("vh"),el=Mt("vw"),Js={...xe,parse:e=>xe.parse(e)/100,transform:e=>xe.transform(e*100)},qe={test:hs("hsl","hue"),parse:Ro("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+xe.transform(mt(t))+", "+xe.transform(mt(n))+", "+mt(bt.transform(s))+")"},Y={test:e=>Ue.test(e)||Dn.test(e)||qe.test(e),parse:e=>Ue.test(e)?Ue.parse(e):qe.test(e)?qe.parse(e):Dn.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Ue.transform(e):qe.transform(e),getAnimatableNone:e=>{const t=Y.parse(e);return t.alpha=0,Y.transform(t)}},tl=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function nl(e){return isNaN(e)&&typeof e=="string"&&(e.match(ds)?.length||0)+(e.match(tl)?.length||0)>0}const No="number",Io="color",sl="var",il="var(",Qs="${}",ol=/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 wt(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=t.replace(ol,l=>(Y.test(l)?(s.color.push(r),i.push(Io),n.push(Y.parse(l))):l.startsWith(il)?(s.var.push(r),i.push(sl),n.push(l)):(s.number.push(r),i.push(No),n.push(parseFloat(l))),++r,Qs)).split(Qs);return{values:n,split:a,indexes:s,types:i}}function Lo(e){return wt(e).values}function Oo(e){const{split:t,types:n}=wt(e),s=t.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=t[o],i[o]!==void 0){const a=n[o];a===No?r+=mt(i[o]):a===Io?r+=Y.transform(i[o]):r+=i[o]}return r}}const rl=e=>typeof e=="number"?0:Y.test(e)?Y.getAnimatableNone(e):e;function al(e){const t=Lo(e);return Oo(e)(t.map(rl))}const Ee={test:nl,parse:Lo,createTransformer:Oo,getAnimatableNone:al};function pn(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function ll({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let i=0,r=0,o=0;if(!t)i=r=o=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;i=pn(l,a,e+1/3),r=pn(l,a,e),o=pn(l,a,e-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Yt(e,t){return n=>n>0?t:e}const _=(e,t,n)=>e+(t-e)*n,gn=(e,t,n)=>{const s=e*e,i=n*(t*t-s)+s;return i<0?0:Math.sqrt(i)},cl=[Dn,Ue,qe],ul=e=>cl.find(t=>t.test(e));function ei(e){const t=ul(e);if(rt(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!t)return!1;let n=t.parse(e);return t===qe&&(n=ll(n)),n}const ti=(e,t)=>{const n=ei(e),s=ei(t);if(!n||!s)return Yt(e,t);const i={...n};return r=>(i.red=gn(n.red,s.red,r),i.green=gn(n.green,s.green,r),i.blue=gn(n.blue,s.blue,r),i.alpha=_(n.alpha,s.alpha,r),Ue.transform(i))},En=new Set(["none","hidden"]);function dl(e,t){return En.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function hl(e,t){return n=>_(e,t,n)}function fs(e){return typeof e=="number"?hl:typeof e=="string"?us(e)?Yt:Y.test(e)?ti:pl:Array.isArray(e)?Fo:typeof e=="object"?Y.test(e)?ti:fl:Yt}function Fo(e,t){const n=[...e],s=n.length,i=e.map((r,o)=>fs(r)(r,t[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function fl(e,t){const n={...e,...t},s={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(s[i]=fs(e[i])(e[i],t[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function ml(e,t){const n=[],s={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const r=t.types[i],o=e.indexes[r][s[r]],a=e.values[o]??0;n[i]=a,s[r]++}return n}const pl=(e,t)=>{const n=Ee.createTransformer(t),s=wt(e),i=wt(t);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?En.has(e)&&!i.values.length||En.has(t)&&!s.values.length?dl(e,t):Pt(Fo(ml(s,i),i.values),n):(rt(!0,`Complex values '${e}' and '${t}' 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"),Yt(e,t))};function Bo(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?_(e,t,n):fs(e)(e,t)}const gl=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>z.update(t,n),stop:()=>De(t),now:()=>q.isProcessing?q.timestamp:ie.now()}},zo=(e,t,n=10)=>{let s="";const i=Math.max(Math.round(t/n),2);for(let r=0;r<i;r++)s+=Math.round(e(r/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Gt=2e4;function ms(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<Gt;)t+=n,s=e.next(t);return t>=Gt?1/0:t}function yl(e,t=100,n){const s=n({...e,keyframes:[0,t]}),i=Math.min(ms(s),Gt);return{type:"keyframes",ease:r=>s.next(i*r).value/t,duration:le(i)}}const xl=5;function $o(e,t,n){const s=Math.max(t-xl,0);return bo(n-e(s),t-s)}const W={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},yn=.001;function vl({duration:e=W.duration,bounce:t=W.bounce,velocity:n=W.velocity,mass:s=W.mass}){let i,r;rt(e<=fe(W.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-t;o=Te(W.minDamping,W.maxDamping,o),e=Te(W.minDuration,W.maxDuration,le(e)),o<1?(i=u=>{const c=u*o,d=c*e,f=c-n,p=Vn(u,o),y=Math.exp(-d);return yn-f/p*y},r=u=>{const d=u*o*e,f=d*n+n,p=Math.pow(o,2)*Math.pow(u,2)*e,y=Math.exp(-d),x=Vn(Math.pow(u,2),o);return(-i(u)+yn>0?-1:1)*((f-p)*y)/x}):(i=u=>{const c=Math.exp(-u*e),d=(u-n)*e+1;return-yn+c*d},r=u=>{const c=Math.exp(-u*e),d=(n-u)*(e*e);return c*d});const a=5/e,l=wl(i,r,a);if(e=fe(e),isNaN(l))return{stiffness:W.stiffness,damping:W.damping,duration:e};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:o*2*Math.sqrt(s*u),duration:e}}}const bl=12;function wl(e,t,n){let s=n;for(let i=1;i<bl;i++)s=s-e(s)/t(s);return s}function Vn(e,t){return e*Math.sqrt(1-t*t)}const Tl=["duration","bounce"],Sl=["stiffness","damping","mass"];function ni(e,t){return t.some(n=>e[n]!==void 0)}function Cl(e){let t={velocity:W.velocity,stiffness:W.stiffness,damping:W.damping,mass:W.mass,isResolvedFromDuration:!1,...e};if(!ni(e,Sl)&&ni(e,Tl))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*Te(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:W.mass,stiffness:i,damping:r}}else{const n=vl(e);t={...t,...n,mass:W.mass},t.isResolvedFromDuration=!0}return t}function qt(e=W.visualDuration,t=W.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:l,damping:u,mass:c,duration:d,velocity:f,isResolvedFromDuration:p}=Cl({...n,velocity:-le(n.velocity||0)}),y=f||0,x=u/(2*Math.sqrt(l*c)),b=o-r,v=le(Math.sqrt(l/c)),w=Math.abs(b)<5;s||(s=w?W.restSpeed.granular:W.restSpeed.default),i||(i=w?W.restDelta.granular:W.restDelta.default);let T;if(x<1){const P=Vn(v,x);T=V=>{const D=Math.exp(-x*v*V);return o-D*((y+x*v*b)/P*Math.sin(P*V)+b*Math.cos(P*V))}}else if(x===1)T=P=>o-Math.exp(-v*P)*(b+(y+v*b)*P);else{const P=v*Math.sqrt(x*x-1);T=V=>{const D=Math.exp(-x*v*V),A=Math.min(P*V,300);return o-D*((y+x*v*b)*Math.sinh(A)+P*b*Math.cosh(A))/P}}const M={calculatedDuration:p&&d||null,next:P=>{const V=T(P);if(p)a.done=P>=d;else{let D=P===0?y:0;x<1&&(D=P===0?fe(y):$o(T,P,V));const A=Math.abs(D)<=s,B=Math.abs(o-V)<=i;a.done=A&&B}return a.value=a.done?o:V,a},toString:()=>{const P=Math.min(ms(M),Gt),V=zo(D=>M.next(P*D).value,P,30);return P+"ms "+V},toTransition:()=>{}};return M}qt.applyToOptions=e=>{const t=yl(e,100,qt);return e.ease=t.ease,e.duration=fe(t.duration),e.type="keyframes",e};function kn({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:u=.5,restSpeed:c}){const d=e[0],f={done:!1,value:d},p=A=>a!==void 0&&A<a||l!==void 0&&A>l,y=A=>a===void 0?l:l===void 0||Math.abs(a-A)<Math.abs(l-A)?a:l;let x=n*t;const b=d+x,v=o===void 0?b:o(b);v!==b&&(x=v-d);const w=A=>-x*Math.exp(-A/s),T=A=>v+w(A),M=A=>{const B=w(A),I=T(A);f.done=Math.abs(B)<=u,f.value=f.done?v:I};let P,V;const D=A=>{p(f.value)&&(P=A,V=qt({keyframes:[f.value,y(f.value)],velocity:$o(T,A,f.value),damping:i,stiffness:r,restDelta:u,restSpeed:c}))};return D(0),{calculatedDuration:null,next:A=>{let B=!1;return!V&&P===void 0&&(B=!0,M(A),D(A)),P!==void 0&&A>=P?V.next(A-P):(!B&&M(A),f)}}}function Pl(e,t,n){const s=[],i=n||Ce.mix||Bo,r=e.length-1;for(let o=0;o<r;o++){let a=i(e[o],e[o+1]);if(t){const l=Array.isArray(t)?t[o]||ce:t;a=Pt(l,a)}s.push(a)}return s}function Al(e,t,{clamp:n=!0,ease:s,mixer:i}={}){const r=e.length;if(Se(r===t.length,"Both input and output ranges must be the same length","range-length"),r===1)return()=>t[0];if(r===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[r-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=Pl(t,s,i),l=a.length,u=c=>{if(o&&c<e[0])return t[0];let d=0;if(l>1)for(;d<e.length-2&&!(c<e[d+1]);d++);const f=vt(e[d],e[d+1],c);return a[d](f)};return n?c=>u(Te(e[0],e[r-1],c)):u}function Ml(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const i=vt(0,t,s);e.push(_(n,1,i))}}function jl(e){const t=[0];return Ml(t,e.length-1),t}function Dl(e,t){return e.map(n=>n*t)}function El(e,t){return e.map(()=>t||Do).splice(0,e.length-1)}function Ze({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const i=Ua(s)?s.map(Zs):Zs(s),r={done:!1,value:t[0]},o=Dl(n&&n.length===t.length?n:jl(t),e),a=Al(o,t,{ease:Array.isArray(i)?i:El(t,i)});return{calculatedDuration:e,next:l=>(r.value=a(l),r.done=l>=e,r)}}const Vl=e=>e!==null;function ps(e,{repeat:t,repeatType:n="loop"},s,i=1){const r=e.filter(Vl),a=i<0||t&&n!=="loop"&&t%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const kl={decay:kn,inertia:kn,tween:Ze,keyframes:Ze,spring:qt};function Uo(e){typeof e.type=="string"&&(e.type=kl[e.type])}class gs{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Rl=e=>e/100;class ys extends gs{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==ie.now()&&this.tick(ie.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;Uo(t);const{type:n=Ze,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=t;let{keyframes:a}=t;const l=n||Ze;process.env.NODE_ENV!=="production"&&l!==Ze&&Se(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Ze&&typeof a[0]!="number"&&(this.mixKeyframes=Pt(Rl,Bo(a[0],a[1])),a=[0,100]);const u=l({...t,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-o})),u.calculatedDuration===null&&(u.calculatedDuration=ms(u));const{calculatedDuration:c}=u;this.calculatedDuration=c,this.resolvedDuration=c+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:s,totalDuration:i,mixKeyframes:r,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:c,repeat:d,repeatType:f,repeatDelay:p,type:y,onUpdate:x,finalKeyframe:b}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const v=this.currentTime-u*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?v<0:v>i;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let T=this.currentTime,M=s;if(d){const A=Math.min(this.currentTime,i)/a;let B=Math.floor(A),I=A%1;!I&&A>=1&&(I=1),I===1&&B--,B=Math.min(B,d+1),!!(B%2)&&(f==="reverse"?(I=1-I,p&&(I-=p/a)):f==="mirror"&&(M=o)),T=Te(0,1,I)*a}const P=w?{done:!1,value:c[0]}:M.next(T);r&&(P.value=r(P.value));let{done:V}=P;!w&&l!==null&&(V=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const D=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&V);return D&&y!==kn&&(P.value=ps(c,this.options,b,this.speed)),x&&x(P.value),D&&this.finish(),P}then(t,n){return this.finished.then(t,n)}get duration(){return le(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+le(t)}get time(){return le(this.currentTime)}set time(t){t=fe(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(ie.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=le(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=gl,startTime:n}=this.options;this.driver||(this.driver=t(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(ie.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(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}function Nl(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const We=e=>e*180/Math.PI,Rn=e=>{const t=We(Math.atan2(e[1],e[0]));return Nn(t)},Il={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Rn,rotateZ:Rn,skewX:e=>We(Math.atan(e[1])),skewY:e=>We(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Nn=e=>(e=e%360,e<0&&(e+=360),e),si=Rn,ii=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),oi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Ll={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ii,scaleY:oi,scale:e=>(ii(e)+oi(e))/2,rotateX:e=>Nn(We(Math.atan2(e[6],e[5]))),rotateY:e=>Nn(We(Math.atan2(-e[2],e[0]))),rotateZ:si,rotate:si,skewX:e=>We(Math.atan(e[4])),skewY:e=>We(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function In(e){return e.includes("scale")?1:0}function Ln(e,t){if(!e||e==="none")return In(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Ll,i=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Il,i=a}if(!i)return In(t);const r=s[t],o=i[1].split(",").map(Fl);return typeof r=="function"?r(o):o[r]}const Ol=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Ln(n,t)};function Fl(e){return parseFloat(e.trim())}const lt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ct=new Set(lt),ri=e=>e===at||e===j,Bl=new Set(["x","y","z"]),zl=lt.filter(e=>!Bl.has(e));function $l(e){const t=[];return zl.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const _e={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Ln(t,"x"),y:(e,{transform:t})=>Ln(t,"y")};_e.translateX=_e.x;_e.translateY=_e.y;const Ke=new Set;let On=!1,Fn=!1,Bn=!1;function Wo(){if(Fn){const e=Array.from(Ke).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const i=$l(s);i.length&&(n.set(s,i),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([r,o])=>{s.getValue(r)?.set(o)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Fn=!1,On=!1,Ke.forEach(e=>e.complete(Bn)),Ke.clear()}function _o(){Ke.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Fn=!0)})}function Ul(){Bn=!0,_o(),Wo(),Bn=!1}class xs{constructor(t,n,s,i,r,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Ke.add(this),On||(On=!0,z.read(_o),z.resolveKeyframes(Wo))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:i}=this;if(t[0]===null){const r=i?.get(),o=t[t.length-1];if(r!==void 0)t[0]=r;else if(s&&n){const a=s.readValue(n,o);a!=null&&(t[0]=a)}t[0]===void 0&&(t[0]=o),i&&r===void 0&&i.set(t[0])}Nl(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Ke.delete(this)}cancel(){this.state==="scheduled"&&(Ke.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Wl=e=>e.startsWith("--");function _l(e,t,n){Wl(t)?e.style.setProperty(t,n):e.style[t]=n}const Kl=is(()=>window.ScrollTimeline!==void 0),Hl={};function Xl(e,t){const n=is(e);return()=>Hl[t]??n()}const Ko=Xl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),ft=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,ai={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:ft([0,.65,.55,1]),circOut:ft([.55,0,1,.45]),backIn:ft([.31,.01,.66,-.59]),backOut:ft([.33,1.53,.69,.99])};function Ho(e,t){if(e)return typeof e=="function"?Ko()?zo(e,t):"ease-out":Eo(e)?ft(e):Array.isArray(e)?e.map(n=>Ho(n,t)||ai.easeOut):ai[e]}function Yl(e,t,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},u=void 0){const c={[t]:n};l&&(c.offset=l);const d=Ho(a,i);Array.isArray(d)&&(c.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),e.animate(c,f)}function Xo(e){return typeof e=="function"&&"applyToOptions"in e}function Gl({type:e,...t}){return Xo(e)&&Ko()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class ql extends gs{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:s,keyframes:i,pseudoElement:r,allowFlatten:o=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=t,Se(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=Gl(t);this.animation=Yl(n,s,i,u,r),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const c=ps(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(c):_l(n,s,c),this.animation.cancel()}l?.(),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:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return le(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+le(t)}get time(){return le(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=fe(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&Kl()?(this.animation.timeline=t,ce):n(this)}}const Yo={anticipate:Ao,backInOut:Po,circInOut:jo};function Zl(e){return e in Yo}function Jl(e){typeof e.ease=="string"&&Zl(e.ease)&&(e.ease=Yo[e.ease])}const li=10;class Ql extends ql{constructor(t){Jl(t),Uo(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:s,onComplete:i,element:r,...o}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const a=new ys({...o,autoplay:!1}),l=fe(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-li).value,a.sample(l).value,li),a.stop()}}const ci=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Ee.test(e)||e==="0")&&!e.startsWith("url("));function ec(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function tc(e,t,n,s){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const r=e[e.length-1],o=ci(i,t),a=ci(r,t);return rt(o===a,`You are trying to animate ${t} from "${i}" to "${r}". "${o?r:i}" is not an animatable value.`,"value-not-animatable"),!o||!a?!1:ec(e)||(n==="spring"||Xo(n))&&s}function zn(e){e.duration=0,e.type="keyframes"}const nc=new Set(["opacity","clipPath","filter","transform"]),sc=is(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function ic(e){const{motionValue:t,name:n,repeatDelay:s,repeatType:i,damping:r,type:o}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=t.owner.getProps();return sc()&&n&&nc.has(n)&&(n!=="transform"||!u)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const oc=40;class rc extends gs{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:u,element:c,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=ie.now();const f={autoplay:t,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:l,motionValue:u,element:c,...d},p=c?.KeyframeResolver||xs;this.keyframeResolver=new p(a,(y,x,b)=>this.onKeyframesResolved(y,x,f,!b),l,u,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:u,onUpdate:c}=s;this.resolvedAt=ie.now(),tc(t,r,o,a)||((Ce.instantAnimations||!l)&&c?.(ps(t,s,n)),t[0]=t[t.length-1],zn(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>oc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!u&&ic(f)?new Ql({...f,element:f.motionValue.owner.current}):new ys(f);p.finished.then(()=>this.notifyFinished()).catch(ce),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Ul()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const ac=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function lc(e){const t=ac.exec(e);if(!t)return[,];const[,n,s,i]=t;return[`--${n??s}`,i]}const cc=4;function Go(e,t,n=1){Se(n<=cc,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=lc(e);if(!s)return;const r=window.getComputedStyle(t).getPropertyValue(s);if(r){const o=r.trim();return yo(o)?parseFloat(o):o}return us(i)?Go(i,t,n+1):i}function vs(e,t){return e?.[t]??e?.default??e}const qo=new Set(["width","height","top","left","right","bottom",...lt]),uc={test:e=>e==="auto",parse:e=>e},Zo=e=>t=>t.test(e),Jo=[at,j,xe,je,el,Qa,uc],ui=e=>Jo.find(Zo(e));function dc(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||vo(e):!0}const hc=new Set(["brightness","contrast","saturate","opacity"]);function fc(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(ds)||[];if(!s)return e;const i=n.replace(s,"");let r=hc.has(t)?1:0;return s!==n&&(r*=100),t+"("+r+i+")"}const mc=/\b([a-z-]*)\(.*?\)/gu,$n={...Ee,getAnimatableNone:e=>{const t=e.match(mc);return t?t.map(fc).join(" "):e}},di={...at,transform:Math.round},pc={rotate:je,rotateX:je,rotateY:je,rotateZ:je,scale:Ot,scaleX:Ot,scaleY:Ot,scaleZ:Ot,skew:je,skewX:je,skewY:je,distance:j,translateX:j,translateY:j,translateZ:j,x:j,y:j,z:j,perspective:j,transformPerspective:j,opacity:bt,originX:Js,originY:Js,originZ:j},bs={borderWidth:j,borderTopWidth:j,borderRightWidth:j,borderBottomWidth:j,borderLeftWidth:j,borderRadius:j,radius:j,borderTopLeftRadius:j,borderTopRightRadius:j,borderBottomRightRadius:j,borderBottomLeftRadius:j,width:j,maxWidth:j,height:j,maxHeight:j,top:j,right:j,bottom:j,left:j,padding:j,paddingTop:j,paddingRight:j,paddingBottom:j,paddingLeft:j,margin:j,marginTop:j,marginRight:j,marginBottom:j,marginLeft:j,backgroundPositionX:j,backgroundPositionY:j,...pc,zIndex:di,fillOpacity:bt,strokeOpacity:bt,numOctaves:di},gc={...bs,color:Y,backgroundColor:Y,outlineColor:Y,fill:Y,stroke:Y,borderColor:Y,borderTopColor:Y,borderRightColor:Y,borderBottomColor:Y,borderLeftColor:Y,filter:$n,WebkitFilter:$n},Qo=e=>gc[e];function er(e,t){let n=Qo(e);return n!==$n&&(n=Ee),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const yc=new Set(["auto","none","0"]);function xc(e,t,n){let s=0,i;for(;s<e.length&&!i;){const r=e[s];typeof r=="string"&&!yc.has(r)&&wt(r).values.length&&(i=e[s]),s++}if(i&&n)for(const r of t)e[r]=er(n,i)}class vc extends xs{constructor(t,n,s,i,r){super(t,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<t.length;l++){let u=t[l];if(typeof u=="string"&&(u=u.trim(),us(u))){const c=Go(u,n.current);c!==void 0&&(t[l]=c),l===t.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!qo.has(s)||t.length!==2)return;const[i,r]=t,o=ui(i),a=ui(r);if(o!==a)if(ri(o)&&ri(a))for(let l=0;l<t.length;l++){const u=t[l];typeof u=="string"&&(t[l]=parseFloat(u))}else _e[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let i=0;i<t.length;i++)(t[i]===null||dc(t[i]))&&s.push(i);s.length&&xc(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=_e[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(s,i).jump(i,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const i=t.getValue(n);i&&i.jump(this.measuredOrigin,!1);const r=s.length-1,o=s[r];s[r]=_e[n](t.measureViewportBox(),window.getComputedStyle(t.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{t.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function bc(e,t,n){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let s=document;const i=n?.[e]??s.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e)}const tr=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function nr(e){return xo(e)&&"offsetHeight"in e}const hi=30,wc=e=>!isNaN(parseFloat(e));class Tc{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=ie.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 r of this.dependents)r.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=ie.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=wc(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&rs(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new os);const s=this.events[t].add(n);return t==="change"?()=>{s(),z.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=ie.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>hi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,hi);return bo(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(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 it(e,t){return new Tc(e,t)}const{schedule:ws}=Vo(queueMicrotask,!1),de={x:!1,y:!1};function sr(){return de.x||de.y}function Sc(e){return e==="x"||e==="y"?de[e]?null:(de[e]=!0,()=>{de[e]=!1}):de.x||de.y?null:(de.x=de.y=!0,()=>{de.x=de.y=!1})}function ir(e,t){const n=bc(e),s=new AbortController,i={passive:!0,...t,signal:s.signal};return[n,i,()=>s.abort()]}function fi(e){return!(e.pointerType==="touch"||sr())}function Cc(e,t,n={}){const[s,i,r]=ir(e,n),o=a=>{if(!fi(a))return;const{target:l}=a,u=t(l,a);if(typeof u!="function"||!l)return;const c=d=>{fi(d)&&(u(d),l.removeEventListener("pointerleave",c))};l.addEventListener("pointerleave",c,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const or=(e,t)=>t?e===t?!0:or(e,t.parentElement):!1,Ts=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Pc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Ac(e){return Pc.has(e.tagName)||e.tabIndex!==-1}const Ut=new WeakSet;function mi(e){return t=>{t.key==="Enter"&&e(t)}}function xn(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Mc=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=mi(()=>{if(Ut.has(n))return;xn(n,"down");const i=mi(()=>{xn(n,"up")}),r=()=>xn(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",r,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function pi(e){return Ts(e)&&!sr()}function jc(e,t,n={}){const[s,i,r]=ir(e,n),o=a=>{const l=a.currentTarget;if(!pi(a))return;Ut.add(l);const u=t(l,a),c=(p,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),Ut.has(l)&&Ut.delete(l),pi(p)&&typeof u=="function"&&u(p,{success:y})},d=p=>{c(p,l===window||l===document||n.useGlobalTarget||or(l,p.target))},f=p=>{c(p,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),nr(a)&&(a.addEventListener("focus",u=>Mc(u,i)),!Ac(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function rr(e){return xo(e)&&"ownerSVGElement"in e}function Dc(e){return rr(e)&&e.tagName==="svg"}const Q=e=>!!(e&&e.getVelocity),Ec=[...Jo,Y,Ee],Vc=e=>Ec.find(Zo(e)),Ss=m.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function gi(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function kc(...e){return t=>{let n=!1;const s=e.map(i=>{const r=gi(i,t);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<s.length;i++){const r=s[i];typeof r=="function"?r():gi(e[i],null)}}}}function Rc(...e){return he.useCallback(kc(...e),e)}class Nc extends he.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=nr(s)&&s.offsetWidth||0,r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft,r.right=i-r.width-r.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Ic({children:e,isPresent:t,anchorX:n,root:s}){const i=m.useId(),r=m.useRef(null),o=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Ss),l=Rc(r,e?.ref);return m.useInsertionEffect(()=>{const{width:u,height:c,top:d,left:f,right:p}=o.current;if(t||!r.current||!u||!c)return;const y=n==="left"?`left: ${f}`:`right: ${p}`;r.current.dataset.motionPopId=i;const x=document.createElement("style");a&&(x.nonce=a);const b=s??document.head;return b.appendChild(x),x.sheet&&x.sheet.insertRule(`
1
+ "use strict";var va=Object.create;var Hs=Object.defineProperty;var ba=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var Ta=Object.getPrototypeOf,Sa=Object.prototype.hasOwnProperty;var Ca=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of wa(e))!Sa.call(t,i)&&i!==n&&Hs(t,i,{get:()=>e[i],enumerable:!(s=ba(e,i))||s.enumerable});return t};var Pa=(t,e,n)=>(n=t!=null?va(Ta(t)):{},Ca(e||!t||!t.__esModule?Hs(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),G=require("lucide-react"),ho=require("@ai-sdk/react"),He=require("ai"),fo=require("@radix-ui/react-slot"),mo=require("class-variance-authority"),Aa=require("clsx"),Ma=require("tailwind-merge"),ja=require("@radix-ui/react-tooltip"),N=require("zod"),Da=require("acorn"),Xs=require("@radix-ui/react-use-controllable-state"),Ea=require("@radix-ui/react-collapsible"),Va=require("./server.cjs");function Qe(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 ht=Qe(m),ne=Qe(ja),ka=Qe(Da),Jn=Qe(Ea);function Z(...t){return Ma.twMerge(Aa.clsx(t))}const $t=mo.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",{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"}}),Xe=ht.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},r)=>{const o=s?fo.Slot:"button";return h.jsx(o,{ref:r,"data-slot":"button",className:Z($t({variant:e,size:n,className:t})),...i})});Xe.displayName="Button";const Ra=mo.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 hn({className:t,variant:e,asChild:n=!1,...s}){const i=n?fo.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:Z(Ra({variant:e}),t),...s})}const Na=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=ht.useState(!0);ht.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),r(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[t.current,e])},po=ht.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...r},o)=>{const a=ht.useRef(null),[l,u]=ht.useState("");return Na({textAreaRef:a,triggerAutoSize:l,maxHeight:t,minHeight:e}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),ht.useEffect(()=>{u(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,value:i,ref:a,className:Z("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:c=>{u(c.target.value),s?.(c)}})});po.displayName="AutosizeTextarea";function Ia({delayDuration:t=0,...e}){return h.jsx(ne.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Ot({...t}){return h.jsx(Ia,{children:h.jsx(ne.Root,{"data-slot":"tooltip",...t})})}function Ft({...t}){return h.jsx(ne.Trigger,{"data-slot":"tooltip-trigger",...t})}function Bt({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(ne.Portal,{children:h.jsxs(ne.Content,{"data-slot":"tooltip-content",sideOffset:e,className:Z("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(ne.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Ys({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:Z("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 Qn=m.createContext({});function ts(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const es=typeof window<"u",go=es?m.useLayoutEffect:m.useEffect,tn=m.createContext(null);function ns(t,e){t.indexOf(e)===-1&&t.push(e)}function ss(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Tt=(t,e,n)=>n>e?e:n<t?t:n;function jn(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let re=()=>{},St=()=>{};process.env.NODE_ENV!=="production"&&(re=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(jn(e,n))},St=(t,e,n)=>{if(!t)throw new Error(jn(e,n))});const Ct={},yo=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function xo(t){return typeof t=="object"&&t!==null}const vo=t=>/^0[^.\s]+$/u.test(t);function is(t){let e;return()=>(e===void 0&&(e=t()),e)}const ct=t=>t,La=(t,e)=>n=>e(t(n)),Ce=(...t)=>t.reduce(La),xe=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class os{constructor(){this.subscriptions=[]}add(e){return ns(this.subscriptions,e),()=>ss(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 r=0;r<i;r++){const o=this.subscriptions[r];o&&o(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const ft=t=>t*1e3,lt=t=>t/1e3;function bo(t,e){return e?t*(1e3/e):0}const Gs=new Set;function rs(t,e,n){t||Gs.has(e)||(console.warn(jn(e,n)),Gs.add(e))}const wo=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Oa=1e-7,Fa=12;function Ba(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=wo(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>Oa&&++a<Fa);return o}function Pe(t,e,n,s){if(t===e&&n===s)return ct;const i=r=>Ba(r,0,1,t,n);return r=>r===0||r===1?r:wo(i(r),e,s)}const To=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,So=t=>e=>1-t(1-e),Co=Pe(.33,1.53,.69,.99),as=So(Co),Po=To(as),Ao=t=>(t*=2)<1?.5*as(t):.5*(2-Math.pow(2,-10*(t-1))),ls=t=>1-Math.sin(Math.acos(t)),Mo=So(ls),jo=To(ls),za=Pe(.42,0,1,1),$a=Pe(0,0,.58,1),Do=Pe(.42,0,.58,1),Ua=t=>Array.isArray(t)&&typeof t[0]!="number",Eo=t=>Array.isArray(t)&&typeof t[0]=="number",qs={linear:ct,easeIn:za,easeInOut:Do,easeOut:$a,circIn:ls,circInOut:jo,circOut:Mo,backIn:as,backInOut:Po,backOut:Co,anticipate:Ao},Wa=t=>typeof t=="string",Zs=t=>{if(Eo(t)){St(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return Pe(e,n,s,i)}else if(Wa(t))return St(qs[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),qs[t];return t},Ie=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function _a(t,e){let n=new Set,s=new Set,i=!1,r=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(c){o.has(c)&&(u.schedule(c),t()),c(a)}const u={schedule:(c,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(c),y.has(c)||y.add(c),c},cancel:c=>{s.delete(c),o.delete(c)},process:c=>{if(a=c,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,u.process(c))}};return u}const Ka=40;function Vo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Ie.reduce((T,M)=>(T[M]=_a(r),T),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:c,update:d,preRender:f,render:p,postRender:y}=o,x=()=>{const T=Ct.useManualTiming?i.timestamp:performance.now();n=!1,Ct.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(T-i.timestamp,Ka),1)),i.timestamp=T,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),c.process(i),d.process(i),f.process(i),p.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(x))},b=()=>{n=!0,s=!0,i.isProcessing||t(x)};return{schedule:Ie.reduce((T,M)=>{const P=o[M];return T[M]=(V,D=!1,A=!1)=>(n||b(),P.schedule(V,D,A)),T},{}),cancel:T=>{for(let M=0;M<Ie.length;M++)o[Ie[M]].cancel(T)},state:i,steps:o}}const{schedule:z,cancel:Dt,state:q,steps:fn}=Vo(typeof requestAnimationFrame<"u"?requestAnimationFrame:ct,!0);let ze;function Ha(){ze=void 0}const it={now:()=>(ze===void 0&&it.set(q.isProcessing||Ct.useManualTiming?q.timestamp:performance.now()),ze),set:t=>{ze=t,queueMicrotask(Ha)}},ko=t=>e=>typeof e=="string"&&e.startsWith(t),cs=ko("--"),Xa=ko("var(--"),us=t=>Xa(t)?Ya.test(t.split("/*")[0].trim()):!1,Ya=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ae={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},ve={...ae,transform:t=>Tt(0,1,t)},Le={...ae,default:1},me=t=>Math.round(t*1e5)/1e5,ds=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ga(t){return t==null}const qa=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,hs=(t,e)=>n=>!!(typeof n=="string"&&qa.test(n)&&n.startsWith(t)||e&&!Ga(n)&&Object.prototype.hasOwnProperty.call(n,e)),Ro=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(ds);return{[t]:parseFloat(i),[e]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Za=t=>Tt(0,255,t),mn={...ae,transform:t=>Math.round(Za(t))},Wt={test:hs("rgb","red"),parse:Ro("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+mn.transform(t)+", "+mn.transform(e)+", "+mn.transform(n)+", "+me(ve.transform(s))+")"};function Ja(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 Dn={test:hs("#"),parse:Ja,transform:Wt.transform},Ae=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),jt=Ae("deg"),xt=Ae("%"),j=Ae("px"),Qa=Ae("vh"),tl=Ae("vw"),Js={...xt,parse:t=>xt.parse(t)/100,transform:t=>xt.transform(t*100)},qt={test:hs("hsl","hue"),parse:Ro("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+xt.transform(me(e))+", "+xt.transform(me(n))+", "+me(ve.transform(s))+")"},Y={test:t=>Wt.test(t)||Dn.test(t)||qt.test(t),parse:t=>Wt.test(t)?Wt.parse(t):qt.test(t)?qt.parse(t):Dn.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Wt.transform(t):qt.transform(t),getAnimatableNone:t=>{const e=Y.parse(t);return e.alpha=0,Y.transform(e)}},el=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function nl(t){return isNaN(t)&&typeof t=="string"&&(t.match(ds)?.length||0)+(t.match(el)?.length||0)>0}const No="number",Io="color",sl="var",il="var(",Qs="${}",ol=/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 be(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(ol,l=>(Y.test(l)?(s.color.push(r),i.push(Io),n.push(Y.parse(l))):l.startsWith(il)?(s.var.push(r),i.push(sl),n.push(l)):(s.number.push(r),i.push(No),n.push(parseFloat(l))),++r,Qs)).split(Qs);return{values:n,split:a,indexes:s,types:i}}function Lo(t){return be(t).values}function Oo(t){const{split:e,types:n}=be(t),s=e.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=e[o],i[o]!==void 0){const a=n[o];a===No?r+=me(i[o]):a===Io?r+=Y.transform(i[o]):r+=i[o]}return r}}const rl=t=>typeof t=="number"?0:Y.test(t)?Y.getAnimatableNone(t):t;function al(t){const e=Lo(t);return Oo(t)(e.map(rl))}const Et={test:nl,parse:Lo,createTransformer:Oo,getAnimatableNone:al};function pn(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 ll({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,r=0,o=0;if(!e)i=r=o=n;else{const a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;i=pn(l,a,t+1/3),r=pn(l,a,t),o=pn(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Ye(t,e){return n=>n>0?e:t}const _=(t,e,n)=>t+(e-t)*n,gn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},cl=[Dn,Wt,qt],ul=t=>cl.find(e=>e.test(t));function ti(t){const e=ul(t);if(re(!!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===qt&&(n=ll(n)),n}const ei=(t,e)=>{const n=ti(t),s=ti(e);if(!n||!s)return Ye(t,e);const i={...n};return r=>(i.red=gn(n.red,s.red,r),i.green=gn(n.green,s.green,r),i.blue=gn(n.blue,s.blue,r),i.alpha=_(n.alpha,s.alpha,r),Wt.transform(i))},En=new Set(["none","hidden"]);function dl(t,e){return En.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function hl(t,e){return n=>_(t,e,n)}function fs(t){return typeof t=="number"?hl:typeof t=="string"?us(t)?Ye:Y.test(t)?ei:pl:Array.isArray(t)?Fo:typeof t=="object"?Y.test(t)?ei:fl:Ye}function Fo(t,e){const n=[...t],s=n.length,i=t.map((r,o)=>fs(r)(r,e[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function fl(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=fs(t[i])(t[i],e[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function ml(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const r=e.types[i],o=t.indexes[r][s[r]],a=t.values[o]??0;n[i]=a,s[r]++}return n}const pl=(t,e)=>{const n=Et.createTransformer(e),s=be(t),i=be(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?En.has(t)&&!i.values.length||En.has(e)&&!s.values.length?dl(t,e):Ce(Fo(ml(s,i),i.values),n):(re(!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"),Ye(t,e))};function Bo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?_(t,e,n):fs(t)(t,e)}const gl=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>z.update(e,n),stop:()=>Dt(e),now:()=>q.isProcessing?q.timestamp:it.now()}},zo=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let r=0;r<i;r++)s+=Math.round(t(r/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Ge=2e4;function ms(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Ge;)e+=n,s=t.next(e);return e>=Ge?1/0:e}function yl(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(ms(s),Ge);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:lt(i)}}const xl=5;function $o(t,e,n){const s=Math.max(e-xl,0);return bo(n-t(s),e-s)}const W={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},yn=.001;function vl({duration:t=W.duration,bounce:e=W.bounce,velocity:n=W.velocity,mass:s=W.mass}){let i,r;re(t<=ft(W.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=Tt(W.minDamping,W.maxDamping,o),t=Tt(W.minDuration,W.maxDuration,lt(t)),o<1?(i=u=>{const c=u*o,d=c*t,f=c-n,p=Vn(u,o),y=Math.exp(-d);return yn-f/p*y},r=u=>{const d=u*o*t,f=d*n+n,p=Math.pow(o,2)*Math.pow(u,2)*t,y=Math.exp(-d),x=Vn(Math.pow(u,2),o);return(-i(u)+yn>0?-1:1)*((f-p)*y)/x}):(i=u=>{const c=Math.exp(-u*t),d=(u-n)*t+1;return-yn+c*d},r=u=>{const c=Math.exp(-u*t),d=(n-u)*(t*t);return c*d});const a=5/t,l=wl(i,r,a);if(t=ft(t),isNaN(l))return{stiffness:W.stiffness,damping:W.damping,duration:t};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:o*2*Math.sqrt(s*u),duration:t}}}const bl=12;function wl(t,e,n){let s=n;for(let i=1;i<bl;i++)s=s-t(s)/e(s);return s}function Vn(t,e){return t*Math.sqrt(1-e*e)}const Tl=["duration","bounce"],Sl=["stiffness","damping","mass"];function ni(t,e){return e.some(n=>t[n]!==void 0)}function Cl(t){let e={velocity:W.velocity,stiffness:W.stiffness,damping:W.damping,mass:W.mass,isResolvedFromDuration:!1,...t};if(!ni(t,Sl)&&ni(t,Tl))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*Tt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:W.mass,stiffness:i,damping:r}}else{const n=vl(t);e={...e,...n,mass:W.mass},e.isResolvedFromDuration=!0}return e}function qe(t=W.visualDuration,e=W.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:l,damping:u,mass:c,duration:d,velocity:f,isResolvedFromDuration:p}=Cl({...n,velocity:-lt(n.velocity||0)}),y=f||0,x=u/(2*Math.sqrt(l*c)),b=o-r,v=lt(Math.sqrt(l/c)),w=Math.abs(b)<5;s||(s=w?W.restSpeed.granular:W.restSpeed.default),i||(i=w?W.restDelta.granular:W.restDelta.default);let T;if(x<1){const P=Vn(v,x);T=V=>{const D=Math.exp(-x*v*V);return o-D*((y+x*v*b)/P*Math.sin(P*V)+b*Math.cos(P*V))}}else if(x===1)T=P=>o-Math.exp(-v*P)*(b+(y+v*b)*P);else{const P=v*Math.sqrt(x*x-1);T=V=>{const D=Math.exp(-x*v*V),A=Math.min(P*V,300);return o-D*((y+x*v*b)*Math.sinh(A)+P*b*Math.cosh(A))/P}}const M={calculatedDuration:p&&d||null,next:P=>{const V=T(P);if(p)a.done=P>=d;else{let D=P===0?y:0;x<1&&(D=P===0?ft(y):$o(T,P,V));const A=Math.abs(D)<=s,B=Math.abs(o-V)<=i;a.done=A&&B}return a.value=a.done?o:V,a},toString:()=>{const P=Math.min(ms(M),Ge),V=zo(D=>M.next(P*D).value,P,30);return P+"ms "+V},toTransition:()=>{}};return M}qe.applyToOptions=t=>{const e=yl(t,100,qe);return t.ease=e.ease,t.duration=ft(e.duration),t.type="keyframes",t};function kn({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:u=.5,restSpeed:c}){const d=t[0],f={done:!1,value:d},p=A=>a!==void 0&&A<a||l!==void 0&&A>l,y=A=>a===void 0?l:l===void 0||Math.abs(a-A)<Math.abs(l-A)?a:l;let x=n*e;const b=d+x,v=o===void 0?b:o(b);v!==b&&(x=v-d);const w=A=>-x*Math.exp(-A/s),T=A=>v+w(A),M=A=>{const B=w(A),I=T(A);f.done=Math.abs(B)<=u,f.value=f.done?v:I};let P,V;const D=A=>{p(f.value)&&(P=A,V=qe({keyframes:[f.value,y(f.value)],velocity:$o(T,A,f.value),damping:i,stiffness:r,restDelta:u,restSpeed:c}))};return D(0),{calculatedDuration:null,next:A=>{let B=!1;return!V&&P===void 0&&(B=!0,M(A),D(A)),P!==void 0&&A>=P?V.next(A-P):(!B&&M(A),f)}}}function Pl(t,e,n){const s=[],i=n||Ct.mix||Bo,r=t.length-1;for(let o=0;o<r;o++){let a=i(t[o],t[o+1]);if(e){const l=Array.isArray(e)?e[o]||ct:e;a=Ce(l,a)}s.push(a)}return s}function Al(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(St(r===e.length,"Both input and output ranges must be the same length","range-length"),r===1)return()=>e[0];if(r===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[r-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Pl(e,s,i),l=a.length,u=c=>{if(o&&c<t[0])return e[0];let d=0;if(l>1)for(;d<t.length-2&&!(c<t[d+1]);d++);const f=xe(t[d],t[d+1],c);return a[d](f)};return n?c=>u(Tt(t[0],t[r-1],c)):u}function Ml(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=xe(0,e,s);t.push(_(n,1,i))}}function jl(t){const e=[0];return Ml(e,t.length-1),e}function Dl(t,e){return t.map(n=>n*e)}function El(t,e){return t.map(()=>e||Do).splice(0,t.length-1)}function Zt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=Ua(s)?s.map(Zs):Zs(s),r={done:!1,value:e[0]},o=Dl(n&&n.length===e.length?n:jl(e),t),a=Al(o,e,{ease:Array.isArray(i)?i:El(e,i)});return{calculatedDuration:t,next:l=>(r.value=a(l),r.done=l>=t,r)}}const Vl=t=>t!==null;function ps(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(Vl),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const kl={decay:kn,inertia:kn,tween:Zt,keyframes:Zt,spring:qe};function Uo(t){typeof t.type=="string"&&(t.type=kl[t.type])}class gs{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 Rl=t=>t/100;class ys extends gs{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!==it.now()&&this.tick(it.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=Zt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const l=n||Zt;process.env.NODE_ENV!=="production"&&l!==Zt&&St(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Zt&&typeof a[0]!="number"&&(this.mixKeyframes=Ce(Rl,Bo(a[0],a[1])),a=[0,100]);const u=l({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-o})),u.calculatedDuration===null&&(u.calculatedDuration=ms(u));const{calculatedDuration:c}=u;this.calculatedDuration=c,this.resolvedDuration=c+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:r,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:c,repeat:d,repeatType:f,repeatDelay:p,type:y,onUpdate:x,finalKeyframe:b}=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 v=this.currentTime-u*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?v<0:v>i;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let T=this.currentTime,M=s;if(d){const A=Math.min(this.currentTime,i)/a;let B=Math.floor(A),I=A%1;!I&&A>=1&&(I=1),I===1&&B--,B=Math.min(B,d+1),!!(B%2)&&(f==="reverse"?(I=1-I,p&&(I-=p/a)):f==="mirror"&&(M=o)),T=Tt(0,1,I)*a}const P=w?{done:!1,value:c[0]}:M.next(T);r&&(P.value=r(P.value));let{done:V}=P;!w&&l!==null&&(V=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const D=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&V);return D&&y!==kn&&(P.value=ps(c,this.options,b,this.speed)),x&&x(P.value),D&&this.finish(),P}then(e,n){return this.finished.then(e,n)}get duration(){return lt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+lt(e)}get time(){return lt(this.currentTime)}set time(e){e=ft(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(it.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=lt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=gl,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(it.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 Nl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const _t=t=>t*180/Math.PI,Rn=t=>{const e=_t(Math.atan2(t[1],t[0]));return Nn(e)},Il={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Rn,rotateZ:Rn,skewX:t=>_t(Math.atan(t[1])),skewY:t=>_t(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Nn=t=>(t=t%360,t<0&&(t+=360),t),si=Rn,ii=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),oi=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Ll={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ii,scaleY:oi,scale:t=>(ii(t)+oi(t))/2,rotateX:t=>Nn(_t(Math.atan2(t[6],t[5]))),rotateY:t=>Nn(_t(Math.atan2(-t[2],t[0]))),rotateZ:si,rotate:si,skewX:t=>_t(Math.atan(t[4])),skewY:t=>_t(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function In(t){return t.includes("scale")?1:0}function Ln(t,e){if(!t||t==="none")return In(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Ll,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Il,i=a}if(!i)return In(e);const r=s[e],o=i[1].split(",").map(Fl);return typeof r=="function"?r(o):o[r]}const Ol=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return Ln(n,e)};function Fl(t){return parseFloat(t.trim())}const le=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ce=new Set(le),ri=t=>t===ae||t===j,Bl=new Set(["x","y","z"]),zl=le.filter(t=>!Bl.has(t));function $l(t){const e=[];return zl.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const Kt={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})=>Ln(e,"x"),y:(t,{transform:e})=>Ln(e,"y")};Kt.translateX=Kt.x;Kt.translateY=Kt.y;const Ht=new Set;let On=!1,Fn=!1,Bn=!1;function Wo(){if(Fn){const t=Array.from(Ht).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=$l(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(([r,o])=>{s.getValue(r)?.set(o)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Fn=!1,On=!1,Ht.forEach(t=>t.complete(Bn)),Ht.clear()}function _o(){Ht.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Fn=!0)})}function Ul(){Bn=!0,_o(),Wo(),Bn=!1}class xs{constructor(e,n,s,i,r,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Ht.add(this),On||(On=!0,z.read(_o),z.resolveKeyframes(Wo))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const r=i?.get(),o=e[e.length-1];if(r!==void 0)e[0]=r;else if(s&&n){const a=s.readValue(n,o);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=o),i&&r===void 0&&i.set(e[0])}Nl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ht.delete(this)}cancel(){this.state==="scheduled"&&(Ht.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Wl=t=>t.startsWith("--");function _l(t,e,n){Wl(e)?t.style.setProperty(e,n):t.style[e]=n}const Kl=is(()=>window.ScrollTimeline!==void 0),Hl={};function Xl(t,e){const n=is(t);return()=>Hl[e]??n()}const Ko=Xl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),fe=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,ai={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:fe([0,.65,.55,1]),circOut:fe([.55,0,1,.45]),backIn:fe([.31,.01,.66,-.59]),backOut:fe([.33,1.53,.69,.99])};function Ho(t,e){if(t)return typeof t=="function"?Ko()?zo(t,e):"ease-out":Eo(t)?fe(t):Array.isArray(t)?t.map(n=>Ho(n,e)||ai.easeOut):ai[t]}function Yl(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},u=void 0){const c={[e]:n};l&&(c.offset=l);const d=Ho(a,i);Array.isArray(d)&&(c.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(c,f)}function Xo(t){return typeof t=="function"&&"applyToOptions"in t}function Gl({type:t,...e}){return Xo(t)&&Ko()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class ql extends gs{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:r,allowFlatten:o=!1,finalKeyframe:a,onComplete:l}=e;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=e,St(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=Gl(e);this.animation=Yl(n,s,i,u,r),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const c=ps(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(c):_l(n,s,c),this.animation.cancel()}l?.(),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 lt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+lt(e)}get time(){return lt(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=ft(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&&Kl()?(this.animation.timeline=e,ct):n(this)}}const Yo={anticipate:Ao,backInOut:Po,circInOut:jo};function Zl(t){return t in Yo}function Jl(t){typeof t.ease=="string"&&Zl(t.ease)&&(t.ease=Yo[t.ease])}const li=10;class Ql extends ql{constructor(e){Jl(e),Uo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:r,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new ys({...o,autoplay:!1}),l=ft(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-li).value,a.sample(l).value,li),a.stop()}}const ci=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Et.test(t)||t==="0")&&!t.startsWith("url("));function tc(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 ec(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const r=t[t.length-1],o=ci(i,e),a=ci(r,e);return re(o===a,`You are trying to animate ${e} from "${i}" to "${r}". "${o?r:i}" is not an animatable value.`,"value-not-animatable"),!o||!a?!1:tc(t)||(n==="spring"||Xo(n))&&s}function zn(t){t.duration=0,t.type="keyframes"}const nc=new Set(["opacity","clipPath","filter","transform"]),sc=is(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function ic(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:r,type:o}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=e.owner.getProps();return sc()&&n&&nc.has(n)&&(n!=="transform"||!u)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const oc=40;class rc extends gs{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:u,element:c,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=it.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:l,motionValue:u,element:c,...d},p=c?.KeyframeResolver||xs;this.keyframeResolver=new p(a,(y,x,b)=>this.onKeyframesResolved(y,x,f,!b),l,u,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:u,onUpdate:c}=s;this.resolvedAt=it.now(),ec(e,r,o,a)||((Ct.instantAnimations||!l)&&c?.(ps(e,s,n)),e[0]=e[e.length-1],zn(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>oc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},p=!u&&ic(f)?new Ql({...f,element:f.motionValue.owner.current}):new ys(f);p.finished.then(()=>this.notifyFinished()).catch(ct),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}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(),Ul()),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 ac=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function lc(t){const e=ac.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const cc=4;function Go(t,e,n=1){St(n<=cc,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=lc(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const o=r.trim();return yo(o)?parseFloat(o):o}return us(i)?Go(i,e,n+1):i}function vs(t,e){return t?.[e]??t?.default??t}const qo=new Set(["width","height","top","left","right","bottom",...le]),uc={test:t=>t==="auto",parse:t=>t},Zo=t=>e=>e.test(t),Jo=[ae,j,xt,jt,tl,Qa,uc],ui=t=>Jo.find(Zo(t));function dc(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||vo(t):!0}const hc=new Set(["brightness","contrast","saturate","opacity"]);function fc(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(ds)||[];if(!s)return t;const i=n.replace(s,"");let r=hc.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const mc=/\b([a-z-]*)\(.*?\)/gu,$n={...Et,getAnimatableNone:t=>{const e=t.match(mc);return e?e.map(fc).join(" "):t}},di={...ae,transform:Math.round},pc={rotate:jt,rotateX:jt,rotateY:jt,rotateZ:jt,scale:Le,scaleX:Le,scaleY:Le,scaleZ:Le,skew:jt,skewX:jt,skewY:jt,distance:j,translateX:j,translateY:j,translateZ:j,x:j,y:j,z:j,perspective:j,transformPerspective:j,opacity:ve,originX:Js,originY:Js,originZ:j},bs={borderWidth:j,borderTopWidth:j,borderRightWidth:j,borderBottomWidth:j,borderLeftWidth:j,borderRadius:j,radius:j,borderTopLeftRadius:j,borderTopRightRadius:j,borderBottomRightRadius:j,borderBottomLeftRadius:j,width:j,maxWidth:j,height:j,maxHeight:j,top:j,right:j,bottom:j,left:j,padding:j,paddingTop:j,paddingRight:j,paddingBottom:j,paddingLeft:j,margin:j,marginTop:j,marginRight:j,marginBottom:j,marginLeft:j,backgroundPositionX:j,backgroundPositionY:j,...pc,zIndex:di,fillOpacity:ve,strokeOpacity:ve,numOctaves:di},gc={...bs,color:Y,backgroundColor:Y,outlineColor:Y,fill:Y,stroke:Y,borderColor:Y,borderTopColor:Y,borderRightColor:Y,borderBottomColor:Y,borderLeftColor:Y,filter:$n,WebkitFilter:$n},Qo=t=>gc[t];function tr(t,e){let n=Qo(t);return n!==$n&&(n=Et),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const yc=new Set(["auto","none","0"]);function xc(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!yc.has(r)&&be(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=tr(n,i)}class vc extends xs{constructor(e,n,s,i,r){super(e,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<e.length;l++){let u=e[l];if(typeof u=="string"&&(u=u.trim(),us(u))){const c=Go(u,n.current);c!==void 0&&(e[l]=c),l===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!qo.has(s)||e.length!==2)return;const[i,r]=e,o=ui(i),a=ui(r);if(o!==a)if(ri(o)&&ri(a))for(let l=0;l<e.length;l++){const u=e[l];typeof u=="string"&&(e[l]=parseFloat(u))}else Kt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||dc(e[i]))&&s.push(i);s.length&&xc(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=Kt[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 r=s.length-1,o=s[r];s[r]=Kt[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{e.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function bc(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 er=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function nr(t){return xo(t)&&"offsetHeight"in t}const hi=30,wc=t=>!isNaN(parseFloat(t));class Tc{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=it.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 r of this.dependents)r.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=it.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=wc(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 os);const s=this.events[e].add(n);return e==="change"?()=>{s(),z.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=it.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>hi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,hi);return bo(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 ie(t,e){return new Tc(t,e)}const{schedule:ws}=Vo(queueMicrotask,!1),dt={x:!1,y:!1};function sr(){return dt.x||dt.y}function Sc(t){return t==="x"||t==="y"?dt[t]?null:(dt[t]=!0,()=>{dt[t]=!1}):dt.x||dt.y?null:(dt.x=dt.y=!0,()=>{dt.x=dt.y=!1})}function ir(t,e){const n=bc(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function fi(t){return!(t.pointerType==="touch"||sr())}function Cc(t,e,n={}){const[s,i,r]=ir(t,n),o=a=>{if(!fi(a))return;const{target:l}=a,u=e(l,a);if(typeof u!="function"||!l)return;const c=d=>{fi(d)&&(u(d),l.removeEventListener("pointerleave",c))};l.addEventListener("pointerleave",c,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const or=(t,e)=>e?t===e?!0:or(t,e.parentElement):!1,Ts=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Pc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Ac(t){return Pc.has(t.tagName)||t.tabIndex!==-1}const $e=new WeakSet;function mi(t){return e=>{e.key==="Enter"&&t(e)}}function xn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Mc=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=mi(()=>{if($e.has(n))return;xn(n,"down");const i=mi(()=>{xn(n,"up")}),r=()=>xn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",r,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function pi(t){return Ts(t)&&!sr()}function jc(t,e,n={}){const[s,i,r]=ir(t,n),o=a=>{const l=a.currentTarget;if(!pi(a))return;$e.add(l);const u=e(l,a),c=(p,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),$e.has(l)&&$e.delete(l),pi(p)&&typeof u=="function"&&u(p,{success:y})},d=p=>{c(p,l===window||l===document||n.useGlobalTarget||or(l,p.target))},f=p=>{c(p,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),nr(a)&&(a.addEventListener("focus",u=>Mc(u,i)),!Ac(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function rr(t){return xo(t)&&"ownerSVGElement"in t}function Dc(t){return rr(t)&&t.tagName==="svg"}const Q=t=>!!(t&&t.getVelocity),Ec=[...Jo,Y,Et],Vc=t=>Ec.find(Zo(t)),Ss=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function gi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function kc(...t){return e=>{let n=!1;const s=t.map(i=>{const r=gi(i,e);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<s.length;i++){const r=s[i];typeof r=="function"?r():gi(t[i],null)}}}}function Rc(...t){return ht.useCallback(kc(...t),t)}class Nc extends ht.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=nr(s)&&s.offsetWidth||0,r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft,r.right=i-r.width-r.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Ic({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),r=m.useRef(null),o=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Ss),l=Rc(r,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:c,top:d,left:f,right:p}=o.current;if(e||!r.current||!u||!c)return;const y=n==="left"?`left: ${f}`:`right: ${p}`;r.current.dataset.motionPopId=i;const x=document.createElement("style");a&&(x.nonce=a);const b=s??document.head;return b.appendChild(x),x.sheet&&x.sheet.insertRule(`
2
2
  [data-motion-pop-id="${i}"] {
3
3
  position: absolute !important;
4
4
  width: ${u}px !important;
@@ -6,9 +6,9 @@
6
6
  ${y}px !important;
7
7
  top: ${d}px !important;
8
8
  }
9
- `),()=>{b.contains(x)&&b.removeChild(x)}},[t]),h.jsx(Nc,{isPresent:t,childRef:r,sizeRef:o,children:he.cloneElement(e,{ref:l})})}const Lc=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const u=es(Oc),c=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:c,initial:t,isPresent:n,custom:i,onExitComplete:p=>{u.set(p,!0);for(const y of u.values())if(!y)return;s&&s()},register:p=>(u.set(p,!1),()=>u.delete(p))}),[n,u,s]);return r&&d&&(f={...f}),m.useMemo(()=>{u.forEach((p,y)=>u.set(y,!1))},[n]),he.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),o==="popLayout"&&(e=h.jsx(Ic,{isPresent:n,anchorX:a,root:l,children:e})),h.jsx(en.Provider,{value:f,children:e})};function Oc(){return new Map}function ar(e=!0){const t=m.useContext(en);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=t,r=m.useId();m.useEffect(()=>{if(e)return i(r)},[e]);const o=m.useCallback(()=>e&&s&&s(r),[r,s,e]);return!n&&s?[!1,o]:[!0]}const Ft=e=>e.key||"";function yi(e){const t=[];return m.Children.forEach(e,n=>{m.isValidElement(n)&&t.push(n)}),t}const Fc=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[u,c]=ar(o),d=m.useMemo(()=>yi(e),[e]),f=o&&!u?[]:d.map(Ft),p=m.useRef(!0),y=m.useRef(d),x=es(()=>new Map),[b,v]=m.useState(d),[w,T]=m.useState(d);go(()=>{p.current=!1,y.current=d;for(let V=0;V<w.length;V++){const D=Ft(w[V]);f.includes(D)?x.delete(D):x.get(D)!==!0&&x.set(D,!1)}},[w,f.length,f.join("-")]);const M=[];if(d!==b){let V=[...d];for(let D=0;D<w.length;D++){const A=w[D],B=Ft(A);f.includes(B)||(V.splice(D,0,A),M.push(A))}return r==="wait"&&M.length&&(V=M),T(yi(V)),v(d),null}process.env.NODE_ENV!=="production"&&r==="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:P}=m.useContext(Qn);return h.jsx(h.Fragment,{children:w.map(V=>{const D=Ft(V),A=o&&!u?!1:d===w||f.includes(D),B=()=>{if(x.has(D))x.set(D,!0);else return;let I=!0;x.forEach(ee=>{ee||(I=!1)}),I&&(P?.(),T(y.current),o&&c?.(),s&&s())};return h.jsx(Lc,{isPresent:A,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:A?void 0:B,anchorX:a,children:V},D)})})},Cs=m.createContext({strict:!1}),xi={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"]},ot={};for(const e in xi)ot[e]={isEnabled:t=>xi[e].some(n=>!!t[n])};function Un(e){for(const t in e)ot[t]={...ot[t],...e[t]}}function Bc({children:e,features:t,strict:n=!1}){const[,s]=m.useState(!vn(t)),i=m.useRef(void 0);if(!vn(t)){const{renderer:r,...o}=t;i.current=r,Un(o)}return m.useEffect(()=>{vn(t)&&t().then(({renderer:r,...o})=>{Un(o),i.current=r,s(!0)})},[]),h.jsx(Cs.Provider,{value:{renderer:i.current,strict:n},children:e})}function vn(e){return typeof e=="function"}const zc=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 Zt(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||zc.has(e)}let lr=e=>!Zt(e);function $c(e){typeof e=="function"&&(lr=t=>t.startsWith("on")?!Zt(t):e(t))}try{$c(require("@emotion/is-prop-valid").default)}catch{}function Uc(e,t,n){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||(lr(i)||n===!0&&Zt(i)||!t&&!Zt(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const tn=m.createContext({});function nn(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Tt(e){return typeof e=="string"||Array.isArray(e)}const Ps=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],As=["initial",...Ps];function sn(e){return nn(e.animate)||As.some(t=>Tt(e[t]))}function cr(e){return!!(sn(e)||e.variants)}function Wc(e,t){if(sn(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Tt(n)?n:void 0,animate:Tt(s)?s:void 0}}return e.inherit!==!1?t:{}}function _c(e){const{initial:t,animate:n}=Wc(e,m.useContext(tn));return m.useMemo(()=>({initial:t,animate:n}),[vi(t),vi(n)])}function vi(e){return Array.isArray(e)?e.join(" "):e}const St={};function Kc(e){for(const t in e)St[t]=e[t],cs(t)&&(St[t].isCSSVariable=!0)}function ur(e,{layout:t,layoutId:n}){return ct.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!St[e]||e==="opacity")}const Hc={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Xc=lt.length;function Yc(e,t,n){let s="",i=!0;for(let r=0;r<Xc;r++){const o=lt[r],a=e[o];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(o.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=tr(a,bs[o]);if(!l){i=!1;const c=Hc[o]||o;s+=`${c}(${u}) `}n&&(t[o]=u)}}return s=s.trim(),n?s=n(t,i?"":s):i&&(s="none"),s}function Ms(e,t,n){const{style:s,vars:i,transformOrigin:r}=e;let o=!1,a=!1;for(const l in t){const u=t[l];if(ct.has(l)){o=!0;continue}else if(cs(l)){i[l]=u;continue}else{const c=tr(u,bs[l]);l.startsWith("origin")?(a=!0,r[l]=c):s[l]=c}}if(t.transform||(o||n?s.transform=Yc(t,e.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:c=0}=r;s.transformOrigin=`${l} ${u} ${c}`}}const js=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function dr(e,t,n){for(const s in t)!Q(t[s])&&!ur(s,n)&&(e[s]=t[s])}function Gc({transformTemplate:e},t){return m.useMemo(()=>{const n=js();return Ms(n,t,e),Object.assign({},n.vars,n.style)},[t])}function qc(e,t){const n=e.style||{},s={};return dr(s,n,e),Object.assign(s,Gc(e,t)),s}function Zc(e,t){const n={},s=qc(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const Jc={offset:"stroke-dashoffset",array:"stroke-dasharray"},Qc={offset:"strokeDashoffset",array:"strokeDasharray"};function eu(e,t,n=1,s=0,i=!0){e.pathLength=1;const r=i?Jc:Qc;e[r.offset]=j.transform(-s);const o=j.transform(t),a=j.transform(n);e[r.array]=`${o} ${a}`}function hr(e,{attrX:t,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,u,c){if(Ms(e,a,u),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:d,style:f}=e;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=c?.transformBox??"fill-box",delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&eu(d,i,r,o,!1)}const fr=()=>({...js(),attrs:{}}),mr=e=>typeof e=="string"&&e.toLowerCase()==="svg";function tu(e,t,n,s){const i=m.useMemo(()=>{const r=fr();return hr(r,t,mr(s),e.transformTemplate,e.style),{...r.attrs,style:{...r.style}}},[t]);if(e.style){const r={};dr(r,e.style,e),i.style={...r,...i.style}}return i}const nu=["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 Ds(e){return typeof e!="string"||e.includes("-")?!1:!!(nu.indexOf(e)>-1||/[A-Z]/u.test(e))}function su(e,t,n,{latestValues:s},i,r=!1){const a=(Ds(e)?tu:Zc)(t,s,i,e),l=Uc(t,typeof e=="string",r),u=e!==m.Fragment?{...l,...a,ref:n}:{},{children:c}=t,d=m.useMemo(()=>Q(c)?c.get():c,[c]);return m.createElement(e,{...u,children:d})}function bi(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Es(e,t,n,s){if(typeof t=="function"){const[i,r]=bi(s);t=t(n!==void 0?n:e.custom,i,r)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,r]=bi(s);t=t(n!==void 0?n:e.custom,i,r)}return t}function Wt(e){return Q(e)?e.get():e}function iu({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,i){return{latestValues:ou(n,s,i,e),renderState:t()}}function ou(e,t,n,s){const i={},r=s(e,{});for(const f in r)i[f]=Wt(r[f]);let{initial:o,animate:a}=e;const l=sn(e),u=cr(e);t&&u&&!l&&e.inherit!==!1&&(o===void 0&&(o=t.initial),a===void 0&&(a=t.animate));let c=n?n.initial===!1:!1;c=c||o===!1;const d=c?a:o;if(d&&typeof d!="boolean"&&!nn(d)){const f=Array.isArray(d)?d:[d];for(let p=0;p<f.length;p++){const y=Es(e,f[p]);if(y){const{transitionEnd:x,transition:b,...v}=y;for(const w in v){let T=v[w];if(Array.isArray(T)){const M=c?T.length-1:0;T=T[M]}T!==null&&(i[w]=T)}for(const w in x)i[w]=x[w]}}}return i}const pr=e=>(t,n)=>{const s=m.useContext(tn),i=m.useContext(en),r=()=>iu(e,t,s,i);return n?r():es(r)};function Vs(e,t,n){const{style:s}=e,i={};for(const r in s)(Q(s[r])||t.style&&Q(t.style[r])||ur(r,e)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const ru=pr({scrapeMotionValuesFromProps:Vs,createRenderState:js});function gr(e,t,n){const s=Vs(e,t,n);for(const i in e)if(Q(e[i])||Q(t[i])){const r=lt.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=e[i]}return s}const au=pr({scrapeMotionValuesFromProps:gr,createRenderState:fr}),lu=Symbol.for("motionComponentSymbol");function Je(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function cu(e,t,n){return m.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):Je(n)&&(n.current=s))},[t])}const ks=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),uu="framerAppearId",yr="data-"+ks(uu),xr=m.createContext({});function du(e,t,n,s,i){const{visualElement:r}=m.useContext(tn),o=m.useContext(Cs),a=m.useContext(en),l=m.useContext(Ss).reducedMotion,u=m.useRef(null);s=s||o.renderer,!u.current&&s&&(u.current=s(e,{visualState:t,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const c=u.current,d=m.useContext(xr);c&&!c.projection&&i&&(c.type==="html"||c.type==="svg")&&hu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{c&&f.current&&c.update(n,a)});const p=n[yr],y=m.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return go(()=>{c&&(f.current=!0,window.MotionIsMounted=!0,c.updateFeatures(),c.scheduleRenderMicrotask(),y.current&&c.animationState&&c.animationState.animateChanges())}),m.useEffect(()=>{c&&(!y.current&&c.animationState&&c.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(p)}),y.current=!1),c.enteringChildren=void 0)}),c}function hu(e,t,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:vr(e.parent)),e.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&Je(a),visualElement:e,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u})}function vr(e){if(e)return e.options.allowProjection!==!1?e.projection:vr(e.parent)}function _t(e,{forwardMotionProps:t=!1}={},n,s){n&&Un(n);const i=Ds(e)?au:ru;function r(a,l){let u;const c={...m.useContext(Ss),...a,layoutId:fu(a)},{isStatic:d}=c,f=_c(a),p=i(a,d);if(!d&&ts){mu(c,n);const y=pu(c);u=y.MeasureLayout,f.visualElement=du(e,p,c,s,y.ProjectionNode)}return h.jsxs(tn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...c}):null,su(e,a,cu(p,f.visualElement,l),p,d,t)]})}r.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const o=m.forwardRef(r);return o[lu]=e,o}function fu({layoutId:e}){const t=m.useContext(Qn).id;return t&&e!==void 0?t+"-"+e:e}function mu(e,t){const n=m.useContext(Cs).strict;if(process.env.NODE_ENV!=="production"&&t&&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.";e.ignoreStrict?rt(!1,s,"lazy-strict-mode"):Se(!1,s,"lazy-strict-mode")}}function pu(e){const{drag:t,layout:n}=ot;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function gu(e,t){if(typeof Proxy>"u")return _t;const n=new Map,s=(r,o)=>_t(r,o,e,t),i=(r,o)=>(process.env.NODE_ENV!=="production"&&rs(!1,"motion() is deprecated. Use motion.create() instead."),s(r,o));return new Proxy(i,{get:(r,o)=>o==="create"?s:(n.has(o)||n.set(o,_t(o,void 0,e,t)),n.get(o))})}function br({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function yu({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function xu(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function bn(e){return e===void 0||e===1}function Wn({scale:e,scaleX:t,scaleY:n}){return!bn(e)||!bn(t)||!bn(n)}function $e(e){return Wn(e)||wr(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function wr(e){return wi(e.x)||wi(e.y)}function wi(e){return e&&e!=="0%"}function Jt(e,t,n){const s=e-n,i=t*s;return n+i}function Ti(e,t,n,s,i){return i!==void 0&&(e=Jt(e,i,s)),Jt(e,n,s)+t}function _n(e,t=0,n=1,s,i){e.min=Ti(e.min,t,n,s,i),e.max=Ti(e.max,t,n,s,i)}function Tr(e,{x:t,y:n}){_n(e.x,t.translate,t.scale,t.originPoint),_n(e.y,n.translate,n.scale,n.originPoint)}const Si=.999999999999,Ci=1.0000000000001;function vu(e,t,n,s=!1){const i=n.length;if(!i)return;t.x=t.y=1;let r,o;for(let a=0;a<i;a++){r=n[a],o=r.projectionDelta;const{visualElement:l}=r.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&et(e,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Tr(e,o)),s&&$e(r.latestValues)&&et(e,r.latestValues))}t.x<Ci&&t.x>Si&&(t.x=1),t.y<Ci&&t.y>Si&&(t.y=1)}function Qe(e,t){e.min=e.min+t,e.max=e.max+t}function Pi(e,t,n,s,i=.5){const r=_(e.min,e.max,i);_n(e,t,n,r,s)}function et(e,t){Pi(e.x,t.x,t.scaleX,t.scale,t.originX),Pi(e.y,t.y,t.scaleY,t.scale,t.originY)}function Sr(e,t){return br(xu(e.getBoundingClientRect(),t))}function bu(e,t,n){const s=Sr(e,n),{scroll:i}=t;return i&&(Qe(s.x,i.offset.x),Qe(s.y,i.offset.y)),s}const Ai=()=>({translate:0,scale:1,origin:0,originPoint:0}),tt=()=>({x:Ai(),y:Ai()}),Mi=()=>({min:0,max:0}),X=()=>({x:Mi(),y:Mi()}),Kn={current:null},Cr={current:!1};function wu(){if(Cr.current=!0,!!ts)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Kn.current=e.matches;e.addEventListener("change",t),t()}else Kn.current=!1}const Tu=new WeakMap;function Su(e,t,n){for(const s in t){const i=t[s],r=n[s];if(Q(i))e.addValue(s,i);else if(Q(r))e.addValue(s,it(i,{owner:e}));else if(r!==i)if(e.hasValue(s)){const o=e.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=e.getStaticValue(s);e.addValue(s,it(o!==void 0?o:i,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const ji=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Cu{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:r,visualState:o},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=ie.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,z.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!r,this.isControllingVariants=sn(n),this.isVariantNode=cr(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const p=d[f];l[f]!==void 0&&Q(p)&&p.set(l[f])}}mount(t){this.current=t,Tu.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Cr.current||wu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Kn.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(),De(this.notifyUpdate),De(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=ct.has(t);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[t]=o,this.props.onUpdate&&z.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),r&&r(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in ot){const n=ot[t];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[t]&&i&&s(this.props)&&(this.features[t]=new i(this)),this.features[t]){const r=this.features[t];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):X()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<ji.length;s++){const i=ji[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=t[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=Su(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=it(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(yo(s)||vo(s))?s=parseFloat(s):!Vc(s)&&Ee.test(n)&&(s=er(t,n)),this.setBaseTarget(t,Q(s)?s.get():s)),Q(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const r=Es(this.props,n,this.presenceContext?.custom);r&&(s=r[t])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!Q(i)?i:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new os),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){ws.render(this.render)}}class Pr extends Cu{constructor(){super(...arguments),this.KeyframeResolver=vc}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Q(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Ar(e,{style:t,vars:n},s,i){const r=e.style;let o;for(o in t)r[o]=t[o];i?.applyProjectionStyles(r,s);for(o in n)r.setProperty(o,n[o])}function Pu(e){return window.getComputedStyle(e)}class Au extends Pr{constructor(){super(...arguments),this.type="html",this.renderInstance=Ar}readValueFromInstance(t,n){if(ct.has(n))return this.projection?.isProjecting?In(n):Ol(t,n);{const s=Pu(t),i=(cs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Sr(t,n)}build(t,n,s){Ms(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return Vs(t,n,s)}}const Mr=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 Mu(e,t,n,s){Ar(e,t,void 0,s);for(const i in t.attrs)e.setAttribute(Mr.has(i)?i:ks(i),t.attrs[i])}class ju extends Pr{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=X}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(ct.has(n)){const s=Qo(n);return s&&s.default||0}return n=Mr.has(n)?n:ks(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return gr(t,n,s)}build(t,n,s){hr(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,i){Mu(t,n,s,i)}mount(t){this.isSVGTag=mr(t.tagName),super.mount(t)}}const jr=(e,t)=>Ds(e)?new ju(t):new Au(t,{allowProjection:e!==m.Fragment});function st(e,t,n){const s=e.getProps();return Es(s,t,n!==void 0?n:s.custom,e)}const Hn=e=>Array.isArray(e);function Du(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,it(n))}function Eu(e){return Hn(e)?e[e.length-1]||0:e}function Vu(e,t){const n=st(e,t);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=Eu(r[o]);Du(e,o,a)}}function ku(e){return!!(Q(e)&&e.add)}function Xn(e,t){const n=e.getValue("willChange");if(ku(n))return n.add(t);if(!n&&Ce.WillChange){const s=new Ce.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function Dr(e){return e.props[yr]}const Ru=e=>e!==null;function Nu(e,{repeat:t,repeatType:n="loop"},s){const i=e.filter(Ru),r=t&&n!=="loop"&&t%2===1?0:i.length-1;return i[r]}const Iu={type:"spring",stiffness:500,damping:25,restSpeed:10},Lu=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Ou={type:"keyframes",duration:.8},Fu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Bu=(e,{keyframes:t})=>t.length>2?Ou:ct.has(e)?e.startsWith("scale")?Lu(t[1]):Iu:Fu;function zu({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const Rs=(e,t,n,s={},i,r)=>o=>{const a=vs(s,e)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-fe(l);const c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-u,onUpdate:f=>{t.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:r?void 0:i};zu(a)||Object.assign(c,Bu(e,c)),c.duration&&(c.duration=fe(c.duration)),c.repeatDelay&&(c.repeatDelay=fe(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(zn(c),c.delay===0&&(d=!0)),(Ce.instantAnimations||Ce.skipAnimations)&&(d=!0,zn(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,d&&!r&&t.get()!==void 0){const f=Nu(c.keyframes,a);if(f!==void 0){z.update(()=>{c.onUpdate(f),c.onComplete()});return}}return a.isSync?new ys(c):new rc(c)};function $u({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function Er(e,t,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=e.getDefaultTransition(),transitionEnd:o,...a}=t;s&&(r=s);const l=[],u=i&&e.animationState&&e.animationState.getState()[i];for(const c in a){const d=e.getValue(c,e.latestValues[c]??null),f=a[c];if(f===void 0||u&&$u(u,c))continue;const p={delay:n,...vs(r||{},c)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!p.velocity)continue;let x=!1;if(window.MotionHandoffAnimation){const v=Dr(e);if(v){const w=window.MotionHandoffAnimation(v,c,z);w!==null&&(p.startTime=w,x=!0)}}Xn(e,c),d.start(Rs(c,d,f,e.shouldReduceMotion&&qo.has(c)?{type:!1}:p,e,x));const b=d.animation;b&&l.push(b)}return o&&Promise.all(l).then(()=>{z.update(()=>{o&&Vu(e,o)})}),l}function Vr(e,t,n,s=0,i=1){const r=Array.from(e).sort((u,c)=>u.sortNodePosition(c)).indexOf(t),o=e.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Yn(e,t,n={}){const s=st(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const r=s?()=>Promise.all(Er(e,s,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=i;return Uu(e,t,l,u,c,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,u]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>u())}else return Promise.all([r(),o(n.delay)])}function Uu(e,t,n=0,s=0,i=0,r=1,o){const a=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),a.push(Yn(l,t,{...o,delay:n+(typeof s=="function"?0:s)+Vr(e.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function Wu(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const i=t.map(r=>Yn(e,r,n));s=Promise.all(i)}else if(typeof t=="string")s=Yn(e,t,n);else{const i=typeof t=="function"?st(e,t,n.custom):t;s=Promise.all(Er(e,i,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function kr(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}const _u=As.length;function Rr(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Rr(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<_u;n++){const s=As[n],i=e.props[s];(Tt(i)||i===!1)&&(t[s]=i)}return t}const Ku=[...Ps].reverse(),Hu=Ps.length;function Xu(e){return t=>Promise.all(t.map(({animation:n,options:s})=>Wu(e,n,s)))}function Yu(e){let t=Xu(e),n=Di(),s=!0;const i=l=>(u,c)=>{const d=st(e,c,l==="exit"?e.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:p,...y}=d;u={...u,...y,...p}}return u};function r(l){t=l(e)}function o(l){const{props:u}=e,c=Rr(e.parent)||{},d=[],f=new Set;let p={},y=1/0;for(let b=0;b<Hu;b++){const v=Ku[b],w=n[v],T=u[v]!==void 0?u[v]:c[v],M=Tt(T),P=v===l?w.isActive:null;P===!1&&(y=b);let V=T===c[v]&&T!==u[v]&&M;if(V&&s&&e.manuallyAnimateOnMount&&(V=!1),w.protectedKeys={...p},!w.isActive&&P===null||!T&&!w.prevProp||nn(T)||typeof T=="boolean")continue;const D=Gu(w.prevProp,T);let A=D||v===l&&w.isActive&&!V&&M||b>y&&M,B=!1;const I=Array.isArray(T)?T:[T];let ee=I.reduce(i(v),{});P===!1&&(ee={});const{prevResolvedValues:ve={}}=w,be={...ve,...ee},ke=$=>{A=!0,f.has($)&&(B=!0,f.delete($)),w.needsAnimating[$]=!0;const R=e.getValue($);R&&(R.liveStyle=!1)};for(const $ in be){const R=ee[$],se=ve[$];if(p.hasOwnProperty($))continue;let K=!1;Hn(R)&&Hn(se)?K=!kr(R,se):K=R!==se,K?R!=null?ke($):f.add($):R!==void 0&&f.has($)?ke($):w.protectedKeys[$]=!0}w.prevProp=T,w.prevResolvedValues=ee,w.isActive&&(p={...p,...ee}),s&&e.blockInitialAnimation&&(A=!1);const me=V&&D;A&&(!me||B)&&d.push(...I.map($=>{const R={type:v};if(typeof $=="string"&&s&&!me&&e.manuallyAnimateOnMount&&e.parent){const{parent:se}=e,K=st(se,$);if(se.enteringChildren&&K){const{delayChildren:we}=K.transition||{};R.delay=Vr(se.enteringChildren,e,we)}}return{animation:$,options:R}}))}if(f.size){const b={};if(typeof u.initial!="boolean"){const v=st(e,Array.isArray(u.initial)?u.initial[0]:u.initial);v&&v.transition&&(b.transition=v.transition)}f.forEach(v=>{const w=e.getBaseTarget(v),T=e.getValue(v);T&&(T.liveStyle=!0),b[v]=w??null}),d.push({animation:b})}let x=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(x=!1),s=!1,x?t(d):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();e.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;const c=o(l);for(const d in n)n[d].protectedKeys={};return c}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Di()}}}function Gu(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!kr(t,e):!1}function ze(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Di(){return{animate:ze(!0),whileInView:ze(),whileHover:ze(),whileTap:ze(),whileDrag:ze(),whileFocus:ze(),exit:ze()}}class Ve{constructor(t){this.isMounted=!1,this.node=t}update(){}}class qu extends Ve{constructor(t){super(t),t.animationState||(t.animationState=Yu(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();nn(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Zu=0;class Ju extends Ve{constructor(){super(...arguments),this.id=Zu++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Nr={animation:{Feature:qu},exit:{Feature:Ju}};function Ct(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function jt(e){return{point:{x:e.pageX,y:e.pageY}}}const Qu=e=>t=>Ts(t)&&e(t,jt(t));function pt(e,t,n,s){return Ct(e,t,Qu(n),s)}const Ir=1e-4,ed=1-Ir,td=1+Ir,Lr=.01,nd=0-Lr,sd=0+Lr;function ne(e){return e.max-e.min}function id(e,t,n){return Math.abs(e-t)<=n}function Ei(e,t,n,s=.5){e.origin=s,e.originPoint=_(t.min,t.max,e.origin),e.scale=ne(n)/ne(t),e.translate=_(n.min,n.max,e.origin)-e.originPoint,(e.scale>=ed&&e.scale<=td||isNaN(e.scale))&&(e.scale=1),(e.translate>=nd&&e.translate<=sd||isNaN(e.translate))&&(e.translate=0)}function gt(e,t,n,s){Ei(e.x,t.x,n.x,s?s.originX:void 0),Ei(e.y,t.y,n.y,s?s.originY:void 0)}function Vi(e,t,n){e.min=n.min+t.min,e.max=e.min+ne(t)}function od(e,t,n){Vi(e.x,t.x,n.x),Vi(e.y,t.y,n.y)}function ki(e,t,n){e.min=t.min-n.min,e.max=e.min+ne(t)}function yt(e,t,n){ki(e.x,t.x,n.x),ki(e.y,t.y,n.y)}function ae(e){return[e("x"),e("y")]}const Or=({current:e})=>e?e.ownerDocument.defaultView:null,Ri=(e,t)=>Math.abs(e-t);function rd(e,t){const n=Ri(e.x,t.x),s=Ri(e.y,t.y);return Math.sqrt(n**2+s**2)}class Fr{constructor(t,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:r=!1,distanceThreshold:o=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=Tn(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,y=rd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!y)return;const{point:x}=f,{timestamp:b}=q;this.history.push({...x,timestamp:b});const{onStart:v,onMove:w}=this.handlers;p||(v&&v(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,p)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=wn(p,this.transformPagePoint),z.update(this.updatePoint,!0)},this.handlePointerUp=(f,p)=>{this.end();const{onEnd:y,onSessionEnd:x,resumeAnimation:b}=this.handlers;if(this.dragSnapToOrigin&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=Tn(f.type==="pointercancel"?this.lastMoveEventInfo:wn(p,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,v),x&&x(f,v)},!Ts(t))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=jt(t),l=wn(a,this.transformPagePoint),{point:u}=l,{timestamp:c}=q;this.history=[{...u,timestamp:c}];const{onSessionStart:d}=n;d&&d(t,Tn(l,this.history)),this.removeListeners=Pt(pt(this.contextWindow,"pointermove",this.handlePointerMove),pt(this.contextWindow,"pointerup",this.handlePointerUp),pt(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),De(this.updatePoint)}}function wn(e,t){return t?{point:t(e.point)}:e}function Ni(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Tn({point:e},t){return{point:e,delta:Ni(e,Br(t)),offset:Ni(e,ad(t)),velocity:ld(t,.1)}}function ad(e){return e[0]}function Br(e){return e[e.length-1]}function ld(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const i=Br(e);for(;n>=0&&(s=e[n],!(i.timestamp-s.timestamp>fe(t)));)n--;if(!s)return{x:0,y:0};const r=le(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function cd(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?_(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?_(n,e,s.max):Math.min(e,n)),e}function Ii(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function ud(e,{top:t,left:n,bottom:s,right:i}){return{x:Ii(e.x,n,i),y:Ii(e.y,t,s)}}function Li(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function dd(e,t){return{x:Li(e.x,t.x),y:Li(e.y,t.y)}}function hd(e,t){let n=.5;const s=ne(e),i=ne(t);return i>s?n=vt(t.min,t.max-s,e.min):s>i&&(n=vt(e.min,e.max-i,t.min)),Te(0,1,n)}function fd(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const Gn=.35;function md(e=Gn){return e===!1?e=0:e===!0&&(e=Gn),{x:Oi(e,"left","right"),y:Oi(e,"top","bottom")}}function Oi(e,t,n){return{min:Fi(e,t),max:Fi(e,n)}}function Fi(e,t){return typeof e=="number"?e:e[t]||0}const pd=new WeakMap;class gd{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=X(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const r=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(jt(d).point)},o=(d,f)=>{const{drag:p,dragPropagation:y,onDragStart:x}=this.getProps();if(p&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Sc(p),!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),ae(v=>{let w=this.getAxisMotionValue(v).get()||0;if(xe.test(w)){const{projection:T}=this.visualElement;if(T&&T.layout){const M=T.layout.layoutBox[v];M&&(w=ne(M)*(parseFloat(w)/100))}}this.originPoint[v]=w}),x&&z.postRender(()=>x(d,f)),Xn(this.visualElement,"transform");const{animationState:b}=this.visualElement;b&&b.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:p,dragDirectionLock:y,onDirectionLock:x,onDrag:b}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:v}=f;if(y&&this.currentDirection===null){this.currentDirection=yd(v),this.currentDirection!==null&&x&&x(this.currentDirection);return}this.updateAxis("x",f.point,v),this.updateAxis("y",f.point,v),this.visualElement.render(),b&&b(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>ae(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new Fr(t,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:s,contextWindow:Or(this.visualElement)})}stop(t,n){const s=t||this.latestPointerEvent,i=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!i||!s)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&z.postRender(()=>a(s,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.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(t,n,s){const{drag:i}=this.getProps();if(!s||!Bt(t,i,this.currentDirection))return;const r=this.getAxisMotionValue(t);let o=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(o=cd(o,this.constraints[t],this.elastic[t])),r.set(o)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;t&&Je(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=ud(s.layoutBox,t):this.constraints=!1,this.elastic=md(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&ae(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=fd(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Je(t))return!1;const s=t.current;Se(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 r=bu(s,i.root,this.visualElement.getTransformPagePoint());let o=dd(i.layout.layoutBox,r);if(n){const a=n(yu(o));this.hasMutatedConstraints=!!a,a&&(o=br(a))}return o}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=ae(c=>{if(!Bt(c,n,this.currentDirection))return;let d=l&&l[c]||{};o&&(d={min:0,max:0});const f=i?200:1e6,p=i?40:1e7,y={type:"inertia",velocity:s?t[c]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(c,y)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return Xn(this.visualElement,t),s.start(Rs(t,s,0,n,this.visualElement,!1))}stopAnimation(){ae(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){ae(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){ae(n=>{const{drag:s}=this.getProps();if(!Bt(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n];r.set(t[n]-_(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Je(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};ae(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=hd({min:l,max:l},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),ae(o=>{if(!Bt(o,t,null))return;const a=this.getAxisMotionValue(o),{min:l,max:u}=this.constraints[o];a.set(_(l,u,i[o]))})}addListeners(){if(!this.visualElement.current)return;pd.set(this.visualElement,this);const t=this.visualElement.current,n=pt(t,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Je(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,r=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),z.read(s);const o=Ct(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(ae(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())}));return()=>{o(),n(),r(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=Gn,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function Bt(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function yd(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class xd extends Ve{constructor(t){super(t),this.removeGroupControls=ce,this.removeListeners=ce,this.controls=new gd(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ce}unmount(){this.removeGroupControls(),this.removeListeners()}}const Bi=e=>(t,n)=>{e&&z.postRender(()=>e(t,n))};class vd extends Ve{constructor(){super(...arguments),this.removePointerDownListener=ce}onPointerDown(t){this.session=new Fr(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Or(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Bi(t),onStart:Bi(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&z.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=pt(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Kt={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function zi(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const ht={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(j.test(e))e=parseFloat(e);else return e;const n=zi(e,t.target.x),s=zi(e,t.target.y);return`${n}% ${s}%`}},bd={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,i=Ee.parse(e);if(i.length>5)return s;const r=Ee.createTransformer(e),o=typeof i[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;i[0+o]/=a,i[1+o]/=l;const u=_(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=u),typeof i[3+o]=="number"&&(i[3+o]/=u),r(i)}};let Sn=!1;class wd extends m.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=t;Kc(Td),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),Sn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),Kt.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,Sn=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==r?o.willUpdate():this.safeToRemove(),t.isPresent!==r&&(r?o.promote():o.relegate()||z.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),ws.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=t;Sn=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function zr(e){const[t,n]=ar(),s=m.useContext(Qn);return h.jsx(wd,{...e,layoutGroup:s,switchLayoutGroup:m.useContext(xr),isPresent:t,safeToRemove:n})}const Td={borderRadius:{...ht,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:ht,borderTopRightRadius:ht,borderBottomLeftRadius:ht,borderBottomRightRadius:ht,boxShadow:bd};function Sd(e,t,n){const s=Q(e)?e:it(e);return s.start(Rs("",s,t,n)),s.animation}const Cd=(e,t)=>e.depth-t.depth;class Pd{constructor(){this.children=[],this.isDirty=!1}add(t){ns(this.children,t),this.isDirty=!0}remove(t){ss(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Cd),this.isDirty=!1,this.children.forEach(t)}}function Ad(e,t){const n=ie.now(),s=({timestamp:i})=>{const r=i-n;r>=t&&(De(s),e(r-t))};return z.setup(s,!0),()=>De(s)}const $r=["TopLeft","TopRight","BottomLeft","BottomRight"],Md=$r.length,$i=e=>typeof e=="string"?parseFloat(e):e,Ui=e=>typeof e=="number"||j.test(e);function jd(e,t,n,s,i,r){i?(e.opacity=_(0,n.opacity??1,Dd(s)),e.opacityExit=_(t.opacity??1,0,Ed(s))):r&&(e.opacity=_(t.opacity??1,n.opacity??1,s));for(let o=0;o<Md;o++){const a=`border${$r[o]}Radius`;let l=Wi(t,a),u=Wi(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Ui(l)===Ui(u)?(e[a]=Math.max(_($i(l),$i(u),s),0),(xe.test(u)||xe.test(l))&&(e[a]+="%")):e[a]=u}(t.rotate||n.rotate)&&(e.rotate=_(t.rotate||0,n.rotate||0,s))}function Wi(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const Dd=Ur(0,.5,Mo),Ed=Ur(.5,.95,ce);function Ur(e,t,n){return s=>s<e?0:s>t?1:n(vt(e,t,s))}function _i(e,t){e.min=t.min,e.max=t.max}function re(e,t){_i(e.x,t.x),_i(e.y,t.y)}function Ki(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function Hi(e,t,n,s,i){return e-=t,e=Jt(e,1/n,s),i!==void 0&&(e=Jt(e,1/i,s)),e}function Vd(e,t=0,n=1,s=.5,i,r=e,o=e){if(xe.test(t)&&(t=parseFloat(t),t=_(o.min,o.max,t/100)-o.min),typeof t!="number")return;let a=_(r.min,r.max,s);e===r&&(a-=t),e.min=Hi(e.min,t,n,a,i),e.max=Hi(e.max,t,n,a,i)}function Xi(e,t,[n,s,i],r,o){Vd(e,t[n],t[s],t[i],t.scale,r,o)}const kd=["x","scaleX","originX"],Rd=["y","scaleY","originY"];function Yi(e,t,n,s){Xi(e.x,t,kd,n?n.x:void 0,s?s.x:void 0),Xi(e.y,t,Rd,n?n.y:void 0,s?s.y:void 0)}function Gi(e){return e.translate===0&&e.scale===1}function Wr(e){return Gi(e.x)&&Gi(e.y)}function qi(e,t){return e.min===t.min&&e.max===t.max}function Nd(e,t){return qi(e.x,t.x)&&qi(e.y,t.y)}function Zi(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function _r(e,t){return Zi(e.x,t.x)&&Zi(e.y,t.y)}function Ji(e){return ne(e.x)/ne(e.y)}function Qi(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Id{constructor(){this.members=[]}add(t){ns(this.members,t),t.scheduleRender()}remove(t){if(ss(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(i=>t===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const r=this.members[i];if(r.isPresent!==!1){s=r;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender(),t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:i}=t.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Ld(e,t,n){let s="";const i=e.x.translate/t.x,r=e.y.translate/t.y,o=n?.z||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:d,rotateY:f,skewX:p,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),c&&(s+=`rotate(${c}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),p&&(s+=`skewX(${p}deg) `),y&&(s+=`skewY(${y}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const Cn=["","X","Y","Z"],Od=1e3;let Fd=0;function Pn(e,t,n,s){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),s&&(s[e]=0))}function Kr(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Dr(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",z,!(i||r))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&Kr(s)}function Hr({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=t?.()){this.id=Fd++,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($d),this.nodes.forEach(Kd),this.nodes.forEach(Hd),this.nodes.forEach(Ud)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,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 l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Pd)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new os),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=rr(o)&&!Dc(o),this.instance=o;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let c,d=0;const f=()=>this.root.updateBlockedByResize=!1;z.read(()=>{d=window.innerWidth}),e(o,()=>{const p=window.innerWidth;p!==d&&(d=p,this.root.updateBlockedByResize=!0,c&&c(),c=Ad(f,250),Kt.hasAnimatedSinceResize&&(Kt.hasAnimatedSinceResize=!1,this.nodes.forEach(no)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||Zd,{onLayoutAnimationStart:x,onLayoutAnimationComplete:b}=u.getProps(),v=!this.targetLayout||!_r(this.targetLayout,p),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const T={...vs(y,"layout"),onPlay:x,onComplete:b};(u.shouldReduceMotion||this.options.layoutRoot)&&(T.delay=0,T.type=!1),this.startAnimation(T),this.setAnimationOrigin(c,w)}else d||no(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),De(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(Xd),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Kr(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const d=this.path[c];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(eo);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(to);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(_d),this.nodes.forEach(Bd),this.nodes.forEach(zd)):this.nodes.forEach(to),this.clearAllSnapshots();const a=ie.now();q.delta=Te(0,1e3/60,a-q.timestamp),q.timestamp=a,q.isProcessing=!0,fn.update.process(q),fn.preRender.process(q),fn.render.process(q),q.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,ws.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Wd),this.sharedNodes.forEach(Yd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,z.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){z.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ne(this.snapshot.measuredBox.x)&&!ne(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 l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=X(),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,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Wr(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;o&&this.instance&&(a||$e(this.latestValues)||c)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),Jd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return X();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Qd))){const{scroll:u}=this.root;u&&(Qe(a.x,u.offset.x),Qe(a.y,u.offset.y))}return a}removeElementScroll(o){const a=X();if(re(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:d}=u;u!==this.root&&c&&d.layoutScroll&&(c.wasRoot&&re(a,o),Qe(a.x,c.offset.x),Qe(a.y,c.offset.y))}return a}applyTransform(o,a=!1){const l=X();re(l,o);for(let u=0;u<this.path.length;u++){const c=this.path[u];!a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&et(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),$e(c.latestValues)&&et(l,c.latestValues)}return $e(this.latestValues)&&et(l,this.latestValues),l}removeTransform(o){const a=X();re(a,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!$e(u.latestValues))continue;Wn(u.latestValues)&&u.updateSnapshot();const c=X(),d=u.measurePageBox();re(c,d),Yi(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return $e(this.latestValues)&&Yi(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.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!==q.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:d}=this.options;if(!(!this.layout||!(c||d))){if(this.resolvedRelativeTargetAt=q.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=X(),this.relativeTargetOrigin=X(),yt(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),re(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=X(),this.targetWithTransforms=X()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),od(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):re(this.target,this.layout.layoutBox),Tr(this.target,this.targetDelta)):re(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=X(),this.relativeTargetOrigin=X(),yt(this.relativeTargetOrigin,this.target,f.target),re(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Wn(this.parent.latestValues)||wr(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 o=this.getLead(),a=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===q.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=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||c))return;re(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;vu(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=X());const{target:p}=o;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Ki(this.prevProjectionDelta.x,this.projectionDelta.x),Ki(this.prevProjectionDelta.y,this.projectionDelta.y)),gt(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Qi(this.projectionDelta.x,this.prevProjectionDelta.x)||!Qi(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=tt(),this.projectionDelta=tt(),this.projectionDeltaWithTransform=tt()}setAnimationOrigin(o,a=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},d=tt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=X(),p=l?l.source:void 0,y=this.layout?this.layout.source:void 0,x=p!==y,b=this.getStack(),v=!b||b.members.length<=1,w=!!(x&&!v&&this.options.crossfade===!0&&!this.path.some(qd));this.animationProgress=0;let T;this.mixTargetDelta=M=>{const P=M/1e3;so(d.x,o.x,P),so(d.y,o.y,P),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(yt(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Gd(this.relativeTarget,this.relativeTargetOrigin,f,P),T&&Nd(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=X()),re(T,this.relativeTarget)),x&&(this.animationValues=c,jd(c,u,this.latestValues,P,w,v)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(De(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=z.update(()=>{Kt.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=it(0)),this.currentAnimation=Sd(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.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 o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Od),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:c}=o;if(!(!a||!l||!u)){if(this!==o&&this.layout&&u&&Xr(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||X();const d=ne(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=ne(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}re(a,l),et(a,c),gt(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Id),this.sharedNodes.get(o).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 o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&Pn("z",o,u,this.animationValues);for(let c=0;c<Cn.length;c++)Pn(`rotate${Cn[c]}`,o,u,this.animationValues),Pn(`skew${Cn[c]}`,o,u,this.animationValues);o.render();for(const c in u)o.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Wt(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Wt(a?.pointerEvents)||""),this.hasProjected&&!$e(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=Ld(this.projectionDeltaWithTransform,this.treeScale,c);l&&(d=l(c,d)),o.transform=d;const{x:f,y:p}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${p.origin*100}% 0`,u.animationValues?o.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:o.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const y in St){if(c[y]===void 0)continue;const{correct:x,applyTo:b,isCSSVariable:v}=St[y],w=d==="none"?c[y]:x(c[y],u);if(b){const T=b.length;for(let M=0;M<T;M++)o[b[M]]=w}else v?this.options.visualElement.renderState.vars[y]=w:o[y]=w}this.options.layoutId&&(o.pointerEvents=u===this?Wt(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(eo),this.root.sharedNodes.clear()}}}function Bd(e){e.updateLayout()}function zd(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=e.layout,{animationType:i}=e.options,r=t.source!==e.layout.source;i==="size"?ae(c=>{const d=r?t.measuredBox[c]:t.layoutBox[c],f=ne(d);d.min=n[c].min,d.max=d.min+f}):Xr(i,t.layoutBox,n)&&ae(c=>{const d=r?t.measuredBox[c]:t.layoutBox[c],f=ne(n[c]);d.max=d.min+f,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[c].max=e.relativeTarget[c].min+f)});const o=tt();gt(o,n,t.layoutBox);const a=tt();r?gt(a,e.applyTransform(s,!0),t.measuredBox):gt(a,n,t.layoutBox);const l=!Wr(o);let u=!1;if(!e.resumeFrom){const c=e.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:d,layout:f}=c;if(d&&f){const p=X();yt(p,t.layoutBox,d.layoutBox);const y=X();yt(y,n,f.layoutBox),_r(p,y)||(u=!0),c.options.layoutRoot&&(e.relativeTarget=y,e.relativeTargetOrigin=p,e.relativeParent=c)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function $d(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function Ud(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Wd(e){e.clearSnapshot()}function eo(e){e.clearMeasurements()}function to(e){e.isLayoutDirty=!1}function _d(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function no(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Kd(e){e.resolveTargetDelta()}function Hd(e){e.calcProjection()}function Xd(e){e.resetSkewAndRotation()}function Yd(e){e.removeLeadSnapshot()}function so(e,t,n){e.translate=_(t.translate,0,n),e.scale=_(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function io(e,t,n,s){e.min=_(t.min,n.min,s),e.max=_(t.max,n.max,s)}function Gd(e,t,n,s){io(e.x,t.x,n.x,s),io(e.y,t.y,n.y,s)}function qd(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const Zd={duration:.45,ease:[.4,0,.1,1]},oo=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),ro=oo("applewebkit/")&&!oo("chrome/")?Math.round:ce;function ao(e){e.min=ro(e.min),e.max=ro(e.max)}function Jd(e){ao(e.x),ao(e.y)}function Xr(e,t,n){return e==="position"||e==="preserve-aspect"&&!id(Ji(t),Ji(n),.2)}function Qd(e){return e!==e.root&&e.scroll?.wasRoot}const eh=Hr({attachResizeListener:(e,t)=>Ct(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),An={current:void 0},Yr=Hr({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!An.current){const e=new eh({});e.mount(window),e.setOptions({layoutScroll:!0}),An.current=e}return An.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),th={pan:{Feature:vd},drag:{Feature:xd,ProjectionNode:Yr,MeasureLayout:zr}};function lo(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&z.postRender(()=>r(t,jt(t)))}class nh extends Ve{mount(){const{current:t}=this.node;t&&(this.unmount=Cc(t,(n,s)=>(lo(this.node,s,"Start"),i=>lo(this.node,i,"End"))))}unmount(){}}class sh extends Ve{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Pt(Ct(this.node.current,"focus",()=>this.onFocus()),Ct(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function co(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),r=s[i];r&&z.postRender(()=>r(t,jt(t)))}class ih extends Ve{mount(){const{current:t}=this.node;t&&(this.unmount=jc(t,(n,s)=>(co(this.node,s,"Start"),(i,{success:r})=>co(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const qn=new WeakMap,Mn=new WeakMap,oh=e=>{const t=qn.get(e.target);t&&t(e)},rh=e=>{e.forEach(oh)};function ah({root:e,...t}){const n=e||document;Mn.has(n)||Mn.set(n,{});const s=Mn.get(n),i=JSON.stringify(t);return s[i]||(s[i]=new IntersectionObserver(rh,{root:e,...t})),s[i]}function lh(e,t,n){const s=ah(t);return qn.set(e,n),s.observe(e),()=>{qn.delete(e),s.unobserve(e)}}const ch={some:0,all:1};class uh extends Ve{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:r}=t,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:ch[i]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,r&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=u?c:d;f&&f(l)};return lh(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(dh(t,n))&&this.startObserver()}unmount(){}}function dh({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Gr={inView:{Feature:uh},tap:{Feature:ih},focus:{Feature:sh},hover:{Feature:nh}},hh={layout:{ProjectionNode:Yr,MeasureLayout:zr}},fh={...Nr,...Gr,...th,...hh},mh=gu(fh,jr),ph={renderer:jr,...Nr,...Gr};function qr(e,t){return _t(e,t)}const zt=qr("div"),gh=qr("p");let Ht=null;function yh(){try{return require("../../.arcten/tool-types.json")?.functions||null}catch{return null}}Ht=yh();function Zn(e){let t;switch(e.type){case"string":t=N.z.string();break;case"number":t=N.z.number();break;case"boolean":t=N.z.boolean();break;case"enum":e.values&&e.values.length>0?t=N.z.enum(e.values):t=N.z.string();break;case"array":if(e.arrayItemType){const n=Zn(e.arrayItemType);t=N.z.array(n)}else t=N.z.array(N.z.any());break;case"object":if(e.properties){const n={};for(const[s,i]of Object.entries(e.properties))n[s]=Zn(i);t=N.z.object(n)}else t=N.z.object({}).passthrough();break;default:t=N.z.any()}return e.required||(t=t.optional()),e.description&&(t=t.describe(e.description)),t}function xh(e,t){const n={},s={};for(const[i,r]of Object.entries(t.parameters))n[i]=Zn(r),s[i]={type:r.type,description:r.description||i,required:r.required};return{name:e,description:t.description,parameters:N.z.object(n),parametersDef:s}}function vh(e){const t=e.name||"unnamed";if(Ht&&Ht[t])return xh(t,Ht[t]);const{description:n,paramDescriptions:s,paramTypes:i}=bh(e),{schema:r,def:o}=Th(e,s,i);return{name:t,description:n,parameters:r,parametersDef:o}}function bh(e){const t=e.toString(),n=new Map,s=new Map,i=t.match(/\/\*\*[\s\S]*?\*\//);if(i){const r=i[0],a=r.match(/\/\*\*\s*\n\s*\*\s*([^\n@]+)/)?.[1]?.trim()||`Execute ${e.name||"function"}`,l=/@param\s+(?:\{([^}]+)\}\s+)?(\w+)(?:\s+-\s+(.+))?/g;let u;for(;(u=l.exec(r))!==null;){const[,c,d,f]=u;c&&d&&s.set(d,c.trim()),f&&d&&n.set(d,f.trim())}return{description:a,paramDescriptions:n,paramTypes:s}}return{description:`Execute ${e.name||"function"}`,paramDescriptions:n,paramTypes:s}}function wh(e){try{let t=e;e.includes("=>")?t=`(${e})`:!e.startsWith("function")&&!e.startsWith("async")&&(t=`function ${e}`);const n=ka.parse(t,{ecmaVersion:"latest",sourceType:"module"});let s=null;if(n.body[0]?.type==="ExpressionStatement"){const i=n.body[0].expression;(i.type==="FunctionExpression"||i.type==="ArrowFunctionExpression")&&(s=i)}else n.body[0]?.type==="FunctionDeclaration"&&(s=n.body[0]);if(s&&s.params)return s.params}catch(t){console.warn("Failed to parse function with acorn:",t)}return[]}function uo(e,t,n,s){if(t){const i=t.toLowerCase();return i.includes("string")?"string":i.includes("number")?"number":i.includes("boolean")?"boolean":i.includes("array")?"array":i.includes("object")?"object":t}if(n&&s){if(s==="true"||s==="false")return"boolean";if(/^\d+$/.test(s))return"number";if(/^["']/.test(s))return"string";if(s==="[]"||s.startsWith("["))return"array";if(s==="{}"||s.startsWith("{"))return"object"}return e.endsWith("Id")||e.endsWith("Name")||e.includes("status")?"string":e.includes("count")||e.includes("amount")||e.includes("price")?"number":e.startsWith("is")||e.startsWith("has")||e.startsWith("should")?"boolean":"string"}function Th(e,t,n){const s=e.toString(),i=wh(s);if(i.length===0)return{schema:N.z.object({}),def:{}};const r={},o={};for(const a of i){const l=a;if(l.type==="Identifier"){const u=l.name,c=s.includes(`${u} =`)||s.includes(`${u}=`),f=s.match(new RegExp(`${u}\\s*=\\s*([^,)]+)`))?.[1]?.trim(),p=n.get(u),y=uo(u,p,c,f),x=t.get(u)||u,b=!c;let v;switch(y){case"string":v=N.z.string();break;case"number":v=N.z.number();break;case"boolean":v=N.z.boolean();break;case"array":v=N.z.array(N.z.any());break;case"object":v=N.z.object({}).passthrough();break;default:v=N.z.any()}b||(v=v.optional()),v=v.describe(x),r[u]=v,o[u]={type:y,description:x,required:b}}else if(l.type==="AssignmentPattern"){const u=l.left;if(u.type==="Identifier"){const c=u.name,d=s.match(new RegExp(`${c}\\s*=\\s*([^,)]+)`))?.[1]?.trim(),f=n.get(c),p=uo(c,f,!0,d),y=t.get(c)||c;let x;switch(p){case"string":x=N.z.string().optional();break;case"number":x=N.z.number().optional();break;case"boolean":x=N.z.boolean().optional();break;case"array":x=N.z.array(N.z.any()).optional();break;case"object":x=N.z.object({}).passthrough().optional();break;default:x=N.z.any().optional()}x=x.describe(y),r[c]=x,o[c]={type:p,description:y,required:!1}}}else if(l.type==="RestElement"){const u=l.argument.name,c=t.get(u)||`${u} (rest parameters)`,d=N.z.array(N.z.any()).describe(c);r[u]=d,o[u]={type:"array",description:c,required:!1}}else if(l.type==="ObjectPattern"){const u="params",c=t.get(u)||"Parameters object",d=N.z.object({}).passthrough().describe(c);r[u]=d,o[u]={type:"object",description:c,required:!0}}}return{schema:N.z.object(r),def:o}}function Zr(e){return e.map(vh)}function Sh({toolName:e,description:t,args:n,onApprove:s,onDeny:i}){const r=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:e})}),r&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([o,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:[o,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},o))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(xt,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(G.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(xt,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(G.X,{className:"h-3 w-3"})})]})]})})}function Ch({toolName:e,args:t,isDenied:n,isSafe:s}){const[i,r]=m.useState(!1);if(e==="fetchDocContent")return null;const o=["k","maxResults","_organizationId"];e==="searchDocs"&&o.push("filters");const a=Object.fromEntries(Object.entries(t).filter(([u])=>!o.includes(u))),l=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>l&&r(!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"} ${l?"cursor-pointer hover:bg-opacity-80":""}`,children:[l&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(G.ChevronDown,{className:"h-3 w-3"}):h.jsx(G.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(G.X,{className:"h-3 w-3"}):s?h.jsx(G.Zap,{className:"h-3 w-3"}):h.jsx(G.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",e]})]}),i&&l&&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,c])=>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 c=="string"?c:JSON.stringify(c)})]},u))})})]})}function Ph({...e}){return h.jsx(Jn.Root,{"data-slot":"collapsible",...e})}function Ah({...e}){return h.jsx(Jn.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function Mh({...e}){return h.jsx(Jn.CollapsibleContent,{"data-slot":"collapsible-content",...e})}const jh=m.lazy(()=>import("streamdown").then(e=>({default:e.Streamdown}))),Ns=m.memo(({className:e,...t})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(jh,{className:J("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t})}),(e,t)=>e.children===t.children);Ns.displayName="Response";const Dh=Object.freeze(Object.defineProperty({__proto__:null,Response:Ns},Symbol.toStringTag,{value:"Module"})),Eh=({children:e,as:t="p",className:n,duration:s=2,spread:i=2})=>{const r=mh.create(t),o=m.useMemo(()=>(e?.length??0)*i,[e,i]);return h.jsx(r,{animate:{backgroundPosition:"0% center"},className:J("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":`${o}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:e})},Vh=m.memo(Eh),Jr=m.createContext(null),kh=()=>{const e=m.useContext(Jr);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Rh=1e3,Nh=1e3,Qr=m.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:r,children:o,...a})=>{const[l,u]=Xs.useControllableState({prop:n,defaultProp:s,onChange:i}),[c,d]=Xs.useControllableState({prop:r,defaultProp:0}),[f,p]=m.useState(!1),[y,x]=m.useState(null);m.useEffect(()=>{t?y===null&&x(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/Nh)),x(null))},[t,y,d]),m.useEffect(()=>{if(s&&!t&&l&&!f){const v=setTimeout(()=>{u(!1),p(!0)},Rh);return()=>clearTimeout(v)}},[t,l,s,u,f]);const b=v=>{u(v)};return h.jsx(Jr.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:c},children:h.jsx(Ph,{className:J("not-prose mb-4",e),onOpenChange:b,open:l,...a,children:o})})}),Ih=(e,t)=>e||t===0?h.jsx(Vh,{duration:1,children:"Thinking..."}):t===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",t," seconds"]}),ea=m.memo(({className:e,children:t,...n})=>{const{isStreaming:s,isOpen:i,duration:r}=kh();return h.jsx(Ah,{className:J("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??h.jsxs(h.Fragment,{children:[h.jsx(G.BrainIcon,{className:"size-4"}),Ih(s,r),h.jsx(G.ChevronDownIcon,{className:J("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),ta=m.memo(({className:e,children:t,...n})=>h.jsx(Mh,{className:J("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",e),...n,children:h.jsx(Ns,{className:"grid gap-2",children:t})}));Qr.displayName="Reasoning";ea.displayName="ReasoningTrigger";ta.displayName="ReasoningContent";function Lh({theme:e="auto",layout:t="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:r=void 0,defaultWidth:o=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:c=[],safeTools:d=[],systemPrompt:f="",tokenEndpoint:p="/api/arcten/token",apiBaseUrl:y="https://api.arcten.com",user:x}){const[b,v]=m.useState(null),w=m.useRef(null),[T,M]=m.useState(null),[P,V]=m.useState(null),D=m.useRef(null),[A,B]=m.useState(u),[I,ee]=m.useState(o),[ve,be]=m.useState(600),[ke,me]=m.useState(!1),[L,$]=m.useState(!1),[R,se]=m.useState(!1),[K,we]=m.useState({x:100,y:100}),[Dt,Pe]=m.useState(!1),[Re,Et]=m.useState({x:0,y:0}),[on,rn]=m.useState(!1),He=m.useRef(null),Xe=m.useRef(null),[E,k]=m.useState(""),[H,oe]=m.useState(null),[te,ue]=m.useState("Thinking..."),[an,ln]=m.useState(new Set),[na,sa]=m.useState(""),[Ne,ia]=m.useState([]),[cn,Is]=m.useState(!1),[un,Ls]=m.useState([]),[Os,dn]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Ye,Vt]=m.useState(!1),[Fh,kt]=m.useState(!1),[Bh,Rt]=m.useState([]),Ie=m.useMemo(()=>[...c,...d],[c,d]),Fs=m.useMemo(()=>Zr(Ie),[Ie]),Bs=m.useMemo(()=>{const g=new Map;return Ie.forEach(C=>g.set(C.name,C)),g},[Ie]),zs=m.useMemo(()=>new Set(d.map(g=>g.name)),[d]),$s=["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 g=localStorage.getItem("arcten-sidebar-expanded");g&&B(JSON.parse(g));const C=localStorage.getItem("arcten-sidebar-width");C&&ee(parseInt(C));const O=localStorage.getItem("arcten-sidebar-height");O&&be(parseInt(O));const S=localStorage.getItem("arcten-sidebar-detached");S&&$(JSON.parse(S));const U=localStorage.getItem("arcten-sidebar-position");if(U){const Ae=JSON.parse(U),ge=50,Me=Math.max(ge-o,Math.min(Ae.x,window.innerWidth-ge)),Z=Math.max(0,Math.min(Ae.y,window.innerHeight-ge));we({x:Me,y:Z})}const F=localStorage.getItem("arcten-sidebar-minimized");F&&se(JSON.parse(F)),rn(!0)}},[]),m.useEffect(()=>((async()=>{try{const C=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:x})});if(!C.ok)throw new Error("Failed to fetch token");const O=await C.json();v(O.clientToken),w.current=O.clientToken,V(O.expiresAt),M(null)}catch(C){M(C instanceof Error?C.message:"Failed to fetch token")}})(),()=>{D.current&&clearTimeout(D.current)}),[p,x]),m.useEffect(()=>{if(!P)return;D.current&&clearTimeout(D.current);const g=Math.floor(Date.now()/1e3),C=P-g,S=Math.max(0,C-5);return console.log(`Token expires at ${new Date(P*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${S} seconds`),D.current=setTimeout(async()=>{console.log("Refreshing token...");try{const U=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:x})});if(!U.ok)throw new Error("Failed to refresh token");const F=await U.json();v(F.clientToken),w.current=F.clientToken,V(F.expiresAt),M(null),console.log("Token refreshed successfully")}catch(U){console.error("Token refresh failed:",U),M(U instanceof Error?U.message:"Failed to refresh token")}},S*1e3),()=>{D.current&&clearTimeout(D.current)}},[P,p,x]),m.useEffect(()=>{(async()=>{if(Ie.length!==0)try{const C=Ie.map(S=>({name:S.name,code:S.toString()})),O=await fetch(`${y}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:C})});if(O.ok){const S=await O.json();ia(S.tools)}}catch(C){console.error("Failed to fetch tool descriptions:",C)}})()},[Ie]),m.useEffect(()=>{Promise.resolve().then(()=>Dh).then(g=>{oe(()=>g.Response)})},[]),m.useEffect(()=>{const g=()=>{sa(window.location.pathname)};g(),window.addEventListener("popstate",g);const C=setInterval(g,500);return()=>{window.removeEventListener("popstate",g),clearInterval(C)}},[]);async function Us(){if(!(!x?.id||!b)){kt(!0);try{const C=await(await fetch(`${y}/conversations`,{headers:{Authorization:`Bearer ${b}`}})).json();Ls(C.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{kt(!1)}}}m.useEffect(()=>{x?.id&&b&&Us()},[x,b]);function oa(g){const C=Math.floor((Date.now()-g)/1e3);return C<60?"now":C<3600?`${Math.floor(C/60)}m`:C<86400?`${Math.floor(C/3600)}h`:`${Math.floor(C/86400)}d`}function ra(){const g=crypto.randomUUID();dn(g),It([]),Rt([]),Vt(!1)}async function aa(g){if(b)try{await fetch(`${y}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${b}`}}),Ls(un.filter(C=>C._id!==g)),g===Os&&ra()}catch(C){console.error("Failed to delete conversation:",C)}}async function la(g){dn(g.chatId),Vt(!1),kt(!0);try{const C=await fetch(`${y}/conversations/${g.chatId}/messages`,{headers:{Authorization:`Bearer ${w.current}`}});if(!C.ok)throw new Error(`Failed to fetch messages: ${C.statusText}`);const S=(await C.json()).messages||[];It(S),Rt(S)}catch(C){console.error("Failed to load conversation messages:",C);const O=g.messages||[];It(O),Rt(O)}finally{kt(!1)}}const ca=(async(g,C={})=>{const O=C.headers?new Headers(C.headers):new Headers;return O.delete("user-agent"),O.delete("User-Agent"),fetch(g,{...C,headers:O})}),{messages:ut,sendMessage:ua,status:pe,error:Ws,stop:Nt,addToolResult:dt,setMessages:It}=ho.useChat({id:Os||void 0,transport:new Xt.DefaultChatTransport({api:`${y}/chat`,fetch:ca,headers:()=>{const g={};return w.current&&(g.Authorization=`Bearer ${w.current}`),g},body:()=>({tools:Fs.map(g=>({name:g.name,description:g.description,parameters:g.parametersDef})),systemPrompt:f,currentRoute:na})}),sendAutomaticallyWhen:Xt.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{A&&Xe.current&&Xe.current.focus()},[A,ut]);function da(){B(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function ha(){B(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[A]),m.useEffect(()=>{He.current&&He.current.scrollIntoView({behavior:"smooth"})},[ut]),m.useEffect(()=>{function g(C){C.key==="Escape"&&(pe==="streaming"||pe==="submitted")&&(C.preventDefault(),Nt())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[pe,Nt]);function fa(){const g=crypto.randomUUID();dn(g),It([]),Rt([]),Vt(!1)}function _s(g){if(g.preventDefault(),!E.trim())return;(pe==="streaming"||pe==="submitted")&&Nt();const C=$s[Math.floor(Math.random()*$s.length)]||"Thinking...";ue(C),ua({text:E}),k("")}function ma(g){const C=g.target.value;k(C)}m.useEffect(()=>{if(!ke)return;function g(O){if(L){const S=O.clientX-K.x,U=O.clientY-K.y;S>=a&&S<=l&&ee(S),U>=400&&U<=1e3&&be(U)}else{const S=window.innerWidth-O.clientX;S>=a&&S<=l&&ee(S)}}function C(){me(!1),localStorage.setItem("arcten-sidebar-width",I.toString()),localStorage.setItem("arcten-sidebar-height",ve.toString())}return window.addEventListener("mousemove",g),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",C)}},[ke,I,ve,L,K,a,l]);function pa(g){g.preventDefault(),me(!0)}function ga(){$(!0),se(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function ya(){$(!1),se(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ks(){se(!R),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!R))}function xa(g){L&&(Pe(!0),Et({x:g.clientX-K.x,y:g.clientY-K.y}))}return m.useEffect(()=>{if(!L)return;function g(){we(C=>{const S=window.innerWidth-50,U=window.innerHeight-50,F=50-I,Ae=0,ge=Math.max(F,Math.min(C.x,S)),Me=Math.max(Ae,Math.min(C.y,U));if(ge!==C.x||Me!==C.y){const Z={x:ge,y:Me};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(Z)),Z}return C})}return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[L,I]),m.useEffect(()=>{if(!Dt)return;function g(O){const S=O.clientX-Re.x,U=O.clientY-Re.y,F=50,Ae=window.innerWidth-F,ge=window.innerHeight-F,Me=F-I,Z=0,ye=Math.max(Me,Math.min(S,Ae)),Le=Math.max(Z,Math.min(U,ge));we({x:ye,y:Le})}function C(){Pe(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(K))}return window.addEventListener("mousemove",g),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",C)}},[Dt,Re,K,I]),on?T?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: ",T]})}):b?h.jsx(Bc,{features:ph,children:h.jsx(zt,{id:"arcten-sidebar","data-theme":e,"data-layout":t,"data-model":n,initial:L?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:L?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
9
+ `),()=>{b.contains(x)&&b.removeChild(x)}},[e]),h.jsx(Nc,{isPresent:e,childRef:r,sizeRef:o,children:ht.cloneElement(t,{ref:l})})}const Lc=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const u=ts(Oc),c=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:c,initial:e,isPresent:n,custom:i,onExitComplete:p=>{u.set(p,!0);for(const y of u.values())if(!y)return;s&&s()},register:p=>(u.set(p,!1),()=>u.delete(p))}),[n,u,s]);return r&&d&&(f={...f}),m.useMemo(()=>{u.forEach((p,y)=>u.set(y,!1))},[n]),ht.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),o==="popLayout"&&(t=h.jsx(Ic,{isPresent:n,anchorX:a,root:l,children:t})),h.jsx(tn.Provider,{value:f,children:t})};function Oc(){return new Map}function ar(t=!0){const e=m.useContext(tn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,r=m.useId();m.useEffect(()=>{if(t)return i(r)},[t]);const o=m.useCallback(()=>t&&s&&s(r),[r,s,t]);return!n&&s?[!1,o]:[!0]}const Oe=t=>t.key||"";function yi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Fc=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[u,c]=ar(o),d=m.useMemo(()=>yi(t),[t]),f=o&&!u?[]:d.map(Oe),p=m.useRef(!0),y=m.useRef(d),x=ts(()=>new Map),[b,v]=m.useState(d),[w,T]=m.useState(d);go(()=>{p.current=!1,y.current=d;for(let V=0;V<w.length;V++){const D=Oe(w[V]);f.includes(D)?x.delete(D):x.get(D)!==!0&&x.set(D,!1)}},[w,f.length,f.join("-")]);const M=[];if(d!==b){let V=[...d];for(let D=0;D<w.length;D++){const A=w[D],B=Oe(A);f.includes(B)||(V.splice(D,0,A),M.push(A))}return r==="wait"&&M.length&&(V=M),T(yi(V)),v(d),null}process.env.NODE_ENV!=="production"&&r==="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:P}=m.useContext(Qn);return h.jsx(h.Fragment,{children:w.map(V=>{const D=Oe(V),A=o&&!u?!1:d===w||f.includes(D),B=()=>{if(x.has(D))x.set(D,!0);else return;let I=!0;x.forEach(tt=>{tt||(I=!1)}),I&&(P?.(),T(y.current),o&&c?.(),s&&s())};return h.jsx(Lc,{isPresent:A,initial:!p.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:A?void 0:B,anchorX:a,children:V},D)})})},Cs=m.createContext({strict:!1}),xi={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"]},oe={};for(const t in xi)oe[t]={isEnabled:e=>xi[t].some(n=>!!e[n])};function Un(t){for(const e in t)oe[e]={...oe[e],...t[e]}}function Bc({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!vn(e)),i=m.useRef(void 0);if(!vn(e)){const{renderer:r,...o}=e;i.current=r,Un(o)}return m.useEffect(()=>{vn(e)&&e().then(({renderer:r,...o})=>{Un(o),i.current=r,s(!0)})},[]),h.jsx(Cs.Provider,{value:{renderer:i.current,strict:n},children:t})}function vn(t){return typeof t=="function"}const zc=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 Ze(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||zc.has(t)}let lr=t=>!Ze(t);function $c(t){typeof t=="function"&&(lr=e=>e.startsWith("on")?!Ze(e):t(e))}try{$c(require("@emotion/is-prop-valid").default)}catch{}function Uc(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(lr(i)||n===!0&&Ze(i)||!e&&!Ze(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const en=m.createContext({});function nn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function we(t){return typeof t=="string"||Array.isArray(t)}const Ps=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],As=["initial",...Ps];function sn(t){return nn(t.animate)||As.some(e=>we(t[e]))}function cr(t){return!!(sn(t)||t.variants)}function Wc(t,e){if(sn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||we(n)?n:void 0,animate:we(s)?s:void 0}}return t.inherit!==!1?e:{}}function _c(t){const{initial:e,animate:n}=Wc(t,m.useContext(en));return m.useMemo(()=>({initial:e,animate:n}),[vi(e),vi(n)])}function vi(t){return Array.isArray(t)?t.join(" "):t}const Te={};function Kc(t){for(const e in t)Te[e]=t[e],cs(e)&&(Te[e].isCSSVariable=!0)}function ur(t,{layout:e,layoutId:n}){return ce.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Te[t]||t==="opacity")}const Hc={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Xc=le.length;function Yc(t,e,n){let s="",i=!0;for(let r=0;r<Xc;r++){const o=le[r],a=t[o];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(o.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=er(a,bs[o]);if(!l){i=!1;const c=Hc[o]||o;s+=`${c}(${u}) `}n&&(e[o]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function Ms(t,e,n){const{style:s,vars:i,transformOrigin:r}=t;let o=!1,a=!1;for(const l in e){const u=e[l];if(ce.has(l)){o=!0;continue}else if(cs(l)){i[l]=u;continue}else{const c=er(u,bs[l]);l.startsWith("origin")?(a=!0,r[l]=c):s[l]=c}}if(e.transform||(o||n?s.transform=Yc(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:c=0}=r;s.transformOrigin=`${l} ${u} ${c}`}}const js=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function dr(t,e,n){for(const s in e)!Q(e[s])&&!ur(s,n)&&(t[s]=e[s])}function Gc({transformTemplate:t},e){return m.useMemo(()=>{const n=js();return Ms(n,e,t),Object.assign({},n.vars,n.style)},[e])}function qc(t,e){const n=t.style||{},s={};return dr(s,n,t),Object.assign(s,Gc(t,e)),s}function Zc(t,e){const n={},s=qc(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 Jc={offset:"stroke-dashoffset",array:"stroke-dasharray"},Qc={offset:"strokeDashoffset",array:"strokeDasharray"};function tu(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?Jc:Qc;t[r.offset]=j.transform(-s);const o=j.transform(e),a=j.transform(n);t[r.array]=`${o} ${a}`}function hr(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,u,c){if(Ms(t,a,u),l){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=c?.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&&tu(d,i,r,o,!1)}const fr=()=>({...js(),attrs:{}}),mr=t=>typeof t=="string"&&t.toLowerCase()==="svg";function eu(t,e,n,s){const i=m.useMemo(()=>{const r=fr();return hr(r,e,mr(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};dr(r,t.style,t),i.style={...r,...i.style}}return i}const nu=["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 Ds(t){return typeof t!="string"||t.includes("-")?!1:!!(nu.indexOf(t)>-1||/[A-Z]/u.test(t))}function su(t,e,n,{latestValues:s},i,r=!1){const a=(Ds(t)?eu:Zc)(e,s,i,t),l=Uc(e,typeof t=="string",r),u=t!==m.Fragment?{...l,...a,ref:n}:{},{children:c}=e,d=m.useMemo(()=>Q(c)?c.get():c,[c]);return m.createElement(t,{...u,children:d})}function bi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function Es(t,e,n,s){if(typeof e=="function"){const[i,r]=bi(s);e=e(n!==void 0?n:t.custom,i,r)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,r]=bi(s);e=e(n!==void 0?n:t.custom,i,r)}return e}function Ue(t){return Q(t)?t.get():t}function iu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:ou(n,s,i,t),renderState:e()}}function ou(t,e,n,s){const i={},r=s(t,{});for(const f in r)i[f]=Ue(r[f]);let{initial:o,animate:a}=t;const l=sn(t),u=cr(t);e&&u&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let c=n?n.initial===!1:!1;c=c||o===!1;const d=c?a:o;if(d&&typeof d!="boolean"&&!nn(d)){const f=Array.isArray(d)?d:[d];for(let p=0;p<f.length;p++){const y=Es(t,f[p]);if(y){const{transitionEnd:x,transition:b,...v}=y;for(const w in v){let T=v[w];if(Array.isArray(T)){const M=c?T.length-1:0;T=T[M]}T!==null&&(i[w]=T)}for(const w in x)i[w]=x[w]}}}return i}const pr=t=>(e,n)=>{const s=m.useContext(en),i=m.useContext(tn),r=()=>iu(t,e,s,i);return n?r():ts(r)};function Vs(t,e,n){const{style:s}=t,i={};for(const r in s)(Q(s[r])||e.style&&Q(e.style[r])||ur(r,t)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const ru=pr({scrapeMotionValuesFromProps:Vs,createRenderState:js});function gr(t,e,n){const s=Vs(t,e,n);for(const i in t)if(Q(t[i])||Q(e[i])){const r=le.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}const au=pr({scrapeMotionValuesFromProps:gr,createRenderState:fr}),lu=Symbol.for("motionComponentSymbol");function Jt(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function cu(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):Jt(n)&&(n.current=s))},[e])}const ks=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),uu="framerAppearId",yr="data-"+ks(uu),xr=m.createContext({});function du(t,e,n,s,i){const{visualElement:r}=m.useContext(en),o=m.useContext(Cs),a=m.useContext(tn),l=m.useContext(Ss).reducedMotion,u=m.useRef(null);s=s||o.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const c=u.current,d=m.useContext(xr);c&&!c.projection&&i&&(c.type==="html"||c.type==="svg")&&hu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{c&&f.current&&c.update(n,a)});const p=n[yr],y=m.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return go(()=>{c&&(f.current=!0,window.MotionIsMounted=!0,c.updateFeatures(),c.scheduleRenderMicrotask(),y.current&&c.animationState&&c.animationState.animateChanges())}),m.useEffect(()=>{c&&(!y.current&&c.animationState&&c.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(p)}),y.current=!1),c.enteringChildren=void 0)}),c}function hu(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:vr(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&Jt(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u})}function vr(t){if(t)return t.options.allowProjection!==!1?t.projection:vr(t.parent)}function We(t,{forwardMotionProps:e=!1}={},n,s){n&&Un(n);const i=Ds(t)?au:ru;function r(a,l){let u;const c={...m.useContext(Ss),...a,layoutId:fu(a)},{isStatic:d}=c,f=_c(a),p=i(a,d);if(!d&&es){mu(c,n);const y=pu(c);u=y.MeasureLayout,f.visualElement=du(t,p,c,s,y.ProjectionNode)}return h.jsxs(en.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...c}):null,su(t,a,cu(p,f.visualElement,l),p,d,e)]})}r.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const o=m.forwardRef(r);return o[lu]=t,o}function fu({layoutId:t}){const e=m.useContext(Qn).id;return e&&t!==void 0?e+"-"+t:t}function mu(t,e){const n=m.useContext(Cs).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?re(!1,s,"lazy-strict-mode"):St(!1,s,"lazy-strict-mode")}}function pu(t){const{drag:e,layout:n}=oe;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function gu(t,e){if(typeof Proxy>"u")return We;const n=new Map,s=(r,o)=>We(r,o,t,e),i=(r,o)=>(process.env.NODE_ENV!=="production"&&rs(!1,"motion() is deprecated. Use motion.create() instead."),s(r,o));return new Proxy(i,{get:(r,o)=>o==="create"?s:(n.has(o)||n.set(o,We(o,void 0,t,e)),n.get(o))})}function br({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function yu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function xu(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 bn(t){return t===void 0||t===1}function Wn({scale:t,scaleX:e,scaleY:n}){return!bn(t)||!bn(e)||!bn(n)}function Ut(t){return Wn(t)||wr(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function wr(t){return wi(t.x)||wi(t.y)}function wi(t){return t&&t!=="0%"}function Je(t,e,n){const s=t-n,i=e*s;return n+i}function Ti(t,e,n,s,i){return i!==void 0&&(t=Je(t,i,s)),Je(t,n,s)+e}function _n(t,e=0,n=1,s,i){t.min=Ti(t.min,e,n,s,i),t.max=Ti(t.max,e,n,s,i)}function Tr(t,{x:e,y:n}){_n(t.x,e.translate,e.scale,e.originPoint),_n(t.y,n.translate,n.scale,n.originPoint)}const Si=.999999999999,Ci=1.0000000000001;function vu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let r,o;for(let a=0;a<i;a++){r=n[a],o=r.projectionDelta;const{visualElement:l}=r.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&te(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,Tr(t,o)),s&&Ut(r.latestValues)&&te(t,r.latestValues))}e.x<Ci&&e.x>Si&&(e.x=1),e.y<Ci&&e.y>Si&&(e.y=1)}function Qt(t,e){t.min=t.min+e,t.max=t.max+e}function Pi(t,e,n,s,i=.5){const r=_(t.min,t.max,i);_n(t,e,n,r,s)}function te(t,e){Pi(t.x,e.x,e.scaleX,e.scale,e.originX),Pi(t.y,e.y,e.scaleY,e.scale,e.originY)}function Sr(t,e){return br(xu(t.getBoundingClientRect(),e))}function bu(t,e,n){const s=Sr(t,n),{scroll:i}=e;return i&&(Qt(s.x,i.offset.x),Qt(s.y,i.offset.y)),s}const Ai=()=>({translate:0,scale:1,origin:0,originPoint:0}),ee=()=>({x:Ai(),y:Ai()}),Mi=()=>({min:0,max:0}),X=()=>({x:Mi(),y:Mi()}),Kn={current:null},Cr={current:!1};function wu(){if(Cr.current=!0,!!es)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Kn.current=t.matches;t.addEventListener("change",e),e()}else Kn.current=!1}const Tu=new WeakMap;function Su(t,e,n){for(const s in e){const i=e[s],r=n[s];if(Q(i))t.addValue(s,i);else if(Q(r))t.addValue(s,ie(i,{owner:t}));else if(r!==i)if(t.hasValue(s)){const o=t.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(s);t.addValue(s,ie(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const ji=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Cu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:r,visualState:o},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=it.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,z.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},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=!!r,this.isControllingVariants=sn(n),this.isVariantNode=cr(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const p=d[f];l[f]!==void 0&&Q(p)&&p.set(l[f])}}mount(e){this.current=e,Tu.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)),Cr.current||wu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Kn.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(),Dt(this.notifyUpdate),Dt(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=ce.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&z.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),r&&r(),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 oe){const n=oe[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 r=this.features[e];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):X()}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<ji.length;s++){const i=ji[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=e[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=Su(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=ie(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"&&(yo(s)||vo(s))?s=parseFloat(s):!Vc(s)&&Et.test(n)&&(s=tr(e,n)),this.setBaseTarget(e,Q(s)?s.get():s)),Q(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 r=Es(this.props,n,this.presenceContext?.custom);r&&(s=r[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!Q(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 os),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){ws.render(this.render)}}class Pr extends Cu{constructor(){super(...arguments),this.KeyframeResolver=vc}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;Q(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Ar(t,{style:e,vars:n},s,i){const r=t.style;let o;for(o in e)r[o]=e[o];i?.applyProjectionStyles(r,s);for(o in n)r.setProperty(o,n[o])}function Pu(t){return window.getComputedStyle(t)}class Au extends Pr{constructor(){super(...arguments),this.type="html",this.renderInstance=Ar}readValueFromInstance(e,n){if(ce.has(n))return this.projection?.isProjecting?In(n):Ol(e,n);{const s=Pu(e),i=(cs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Sr(e,n)}build(e,n,s){Ms(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return Vs(e,n,s)}}const Mr=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 Mu(t,e,n,s){Ar(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Mr.has(i)?i:ks(i),e.attrs[i])}class ju extends Pr{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=X}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(ce.has(n)){const s=Qo(n);return s&&s.default||0}return n=Mr.has(n)?n:ks(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return gr(e,n,s)}build(e,n,s){hr(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Mu(e,n,s,i)}mount(e){this.isSVGTag=mr(e.tagName),super.mount(e)}}const jr=(t,e)=>Ds(t)?new ju(e):new Au(e,{allowProjection:t!==m.Fragment});function se(t,e,n){const s=t.getProps();return Es(s,e,n!==void 0?n:s.custom,t)}const Hn=t=>Array.isArray(t);function Du(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,ie(n))}function Eu(t){return Hn(t)?t[t.length-1]||0:t}function Vu(t,e){const n=se(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=Eu(r[o]);Du(t,o,a)}}function ku(t){return!!(Q(t)&&t.add)}function Xn(t,e){const n=t.getValue("willChange");if(ku(n))return n.add(e);if(!n&&Ct.WillChange){const s=new Ct.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Dr(t){return t.props[yr]}const Ru=t=>t!==null;function Nu(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Ru),r=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[r]}const Iu={type:"spring",stiffness:500,damping:25,restSpeed:10},Lu=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Ou={type:"keyframes",duration:.8},Fu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Bu=(t,{keyframes:e})=>e.length>2?Ou:ce.has(t)?t.startsWith("scale")?Lu(e[1]):Iu:Fu;function zu({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const Rs=(t,e,n,s={},i,r)=>o=>{const a=vs(s,t)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-ft(l);const c={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:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:r?void 0:i};zu(a)||Object.assign(c,Bu(t,c)),c.duration&&(c.duration=ft(c.duration)),c.repeatDelay&&(c.repeatDelay=ft(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(zn(c),c.delay===0&&(d=!0)),(Ct.instantAnimations||Ct.skipAnimations)&&(d=!0,zn(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,d&&!r&&e.get()!==void 0){const f=Nu(c.keyframes,a);if(f!==void 0){z.update(()=>{c.onUpdate(f),c.onComplete()});return}}return a.isSync?new ys(c):new rc(c)};function $u({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Er(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=t.getDefaultTransition(),transitionEnd:o,...a}=e;s&&(r=s);const l=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const c in a){const d=t.getValue(c,t.latestValues[c]??null),f=a[c];if(f===void 0||u&&$u(u,c))continue;const p={delay:n,...vs(r||{},c)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!p.velocity)continue;let x=!1;if(window.MotionHandoffAnimation){const v=Dr(t);if(v){const w=window.MotionHandoffAnimation(v,c,z);w!==null&&(p.startTime=w,x=!0)}}Xn(t,c),d.start(Rs(c,d,f,t.shouldReduceMotion&&qo.has(c)?{type:!1}:p,t,x));const b=d.animation;b&&l.push(b)}return o&&Promise.all(l).then(()=>{z.update(()=>{o&&Vu(t,o)})}),l}function Vr(t,e,n,s=0,i=1){const r=Array.from(t).sort((u,c)=>u.sortNodePosition(c)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Yn(t,e,n={}){const s=se(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const r=s?()=>Promise.all(Er(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=i;return Uu(t,e,l,u,c,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,u]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>u())}else return Promise.all([r(),o(n.delay)])}function Uu(t,e,n=0,s=0,i=0,r=1,o){const a=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),a.push(Yn(l,e,{...o,delay:n+(typeof s=="function"?0:s)+Vr(t.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function Wu(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(r=>Yn(t,r,n));s=Promise.all(i)}else if(typeof e=="string")s=Yn(t,e,n);else{const i=typeof e=="function"?se(t,e,n.custom):e;s=Promise.all(Er(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function kr(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 _u=As.length;function Rr(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Rr(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<_u;n++){const s=As[n],i=t.props[s];(we(i)||i===!1)&&(e[s]=i)}return e}const Ku=[...Ps].reverse(),Hu=Ps.length;function Xu(t){return e=>Promise.all(e.map(({animation:n,options:s})=>Wu(t,n,s)))}function Yu(t){let e=Xu(t),n=Di(),s=!0;const i=l=>(u,c)=>{const d=se(t,c,l==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:p,...y}=d;u={...u,...y,...p}}return u};function r(l){e=l(t)}function o(l){const{props:u}=t,c=Rr(t.parent)||{},d=[],f=new Set;let p={},y=1/0;for(let b=0;b<Hu;b++){const v=Ku[b],w=n[v],T=u[v]!==void 0?u[v]:c[v],M=we(T),P=v===l?w.isActive:null;P===!1&&(y=b);let V=T===c[v]&&T!==u[v]&&M;if(V&&s&&t.manuallyAnimateOnMount&&(V=!1),w.protectedKeys={...p},!w.isActive&&P===null||!T&&!w.prevProp||nn(T)||typeof T=="boolean")continue;const D=Gu(w.prevProp,T);let A=D||v===l&&w.isActive&&!V&&M||b>y&&M,B=!1;const I=Array.isArray(T)?T:[T];let tt=I.reduce(i(v),{});P===!1&&(tt={});const{prevResolvedValues:vt={}}=w,bt={...vt,...tt},kt=$=>{A=!0,f.has($)&&(B=!0,f.delete($)),w.needsAnimating[$]=!0;const R=t.getValue($);R&&(R.liveStyle=!1)};for(const $ in bt){const R=tt[$],st=vt[$];if(p.hasOwnProperty($))continue;let K=!1;Hn(R)&&Hn(st)?K=!kr(R,st):K=R!==st,K?R!=null?kt($):f.add($):R!==void 0&&f.has($)?kt($):w.protectedKeys[$]=!0}w.prevProp=T,w.prevResolvedValues=tt,w.isActive&&(p={...p,...tt}),s&&t.blockInitialAnimation&&(A=!1);const mt=V&&D;A&&(!mt||B)&&d.push(...I.map($=>{const R={type:v};if(typeof $=="string"&&s&&!mt&&t.manuallyAnimateOnMount&&t.parent){const{parent:st}=t,K=se(st,$);if(st.enteringChildren&&K){const{delayChildren:wt}=K.transition||{};R.delay=Vr(st.enteringChildren,t,wt)}}return{animation:$,options:R}}))}if(f.size){const b={};if(typeof u.initial!="boolean"){const v=se(t,Array.isArray(u.initial)?u.initial[0]:u.initial);v&&v.transition&&(b.transition=v.transition)}f.forEach(v=>{const w=t.getBaseTarget(v),T=t.getValue(v);T&&(T.liveStyle=!0),b[v]=w??null}),d.push({animation:b})}let x=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(x=!1),s=!1,x?e(d):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;const c=o(l);for(const d in n)n[d].protectedKeys={};return c}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Di()}}}function Gu(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!kr(e,t):!1}function zt(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Di(){return{animate:zt(!0),whileInView:zt(),whileHover:zt(),whileTap:zt(),whileDrag:zt(),whileFocus:zt(),exit:zt()}}class Vt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class qu extends Vt{constructor(e){super(e),e.animationState||(e.animationState=Yu(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();nn(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 Zu=0;class Ju extends Vt{constructor(){super(...arguments),this.id=Zu++}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 Nr={animation:{Feature:qu},exit:{Feature:Ju}};function Se(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function Me(t){return{point:{x:t.pageX,y:t.pageY}}}const Qu=t=>e=>Ts(e)&&t(e,Me(e));function pe(t,e,n,s){return Se(t,e,Qu(n),s)}const Ir=1e-4,td=1-Ir,ed=1+Ir,Lr=.01,nd=0-Lr,sd=0+Lr;function nt(t){return t.max-t.min}function id(t,e,n){return Math.abs(t-e)<=n}function Ei(t,e,n,s=.5){t.origin=s,t.originPoint=_(e.min,e.max,t.origin),t.scale=nt(n)/nt(e),t.translate=_(n.min,n.max,t.origin)-t.originPoint,(t.scale>=td&&t.scale<=ed||isNaN(t.scale))&&(t.scale=1),(t.translate>=nd&&t.translate<=sd||isNaN(t.translate))&&(t.translate=0)}function ge(t,e,n,s){Ei(t.x,e.x,n.x,s?s.originX:void 0),Ei(t.y,e.y,n.y,s?s.originY:void 0)}function Vi(t,e,n){t.min=n.min+e.min,t.max=t.min+nt(e)}function od(t,e,n){Vi(t.x,e.x,n.x),Vi(t.y,e.y,n.y)}function ki(t,e,n){t.min=e.min-n.min,t.max=t.min+nt(e)}function ye(t,e,n){ki(t.x,e.x,n.x),ki(t.y,e.y,n.y)}function at(t){return[t("x"),t("y")]}const Or=({current:t})=>t?t.ownerDocument.defaultView:null,Ri=(t,e)=>Math.abs(t-e);function rd(t,e){const n=Ri(t.x,e.x),s=Ri(t.y,e.y);return Math.sqrt(n**2+s**2)}class Fr{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:r=!1,distanceThreshold:o=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=Tn(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,y=rd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!y)return;const{point:x}=f,{timestamp:b}=q;this.history.push({...x,timestamp:b});const{onStart:v,onMove:w}=this.handlers;p||(v&&v(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,p)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=wn(p,this.transformPagePoint),z.update(this.updatePoint,!0)},this.handlePointerUp=(f,p)=>{this.end();const{onEnd:y,onSessionEnd:x,resumeAnimation:b}=this.handlers;if(this.dragSnapToOrigin&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=Tn(f.type==="pointercancel"?this.lastMoveEventInfo:wn(p,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,v),x&&x(f,v)},!Ts(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=Me(e),l=wn(a,this.transformPagePoint),{point:u}=l,{timestamp:c}=q;this.history=[{...u,timestamp:c}];const{onSessionStart:d}=n;d&&d(e,Tn(l,this.history)),this.removeListeners=Ce(pe(this.contextWindow,"pointermove",this.handlePointerMove),pe(this.contextWindow,"pointerup",this.handlePointerUp),pe(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Dt(this.updatePoint)}}function wn(t,e){return e?{point:e(t.point)}:t}function Ni(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Tn({point:t},e){return{point:t,delta:Ni(t,Br(e)),offset:Ni(t,ad(e)),velocity:ld(e,.1)}}function ad(t){return t[0]}function Br(t){return t[t.length-1]}function ld(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Br(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>ft(e)));)n--;if(!s)return{x:0,y:0};const r=lt(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function cd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?_(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?_(n,t,s.max):Math.min(t,n)),t}function Ii(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 ud(t,{top:e,left:n,bottom:s,right:i}){return{x:Ii(t.x,n,i),y:Ii(t.y,e,s)}}function Li(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:Li(t.x,e.x),y:Li(t.y,e.y)}}function hd(t,e){let n=.5;const s=nt(t),i=nt(e);return i>s?n=xe(e.min,e.max-s,t.min):s>i&&(n=xe(t.min,t.max-i,e.min)),Tt(0,1,n)}function fd(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 Gn=.35;function md(t=Gn){return t===!1?t=0:t===!0&&(t=Gn),{x:Oi(t,"left","right"),y:Oi(t,"top","bottom")}}function Oi(t,e,n){return{min:Fi(t,e),max:Fi(t,n)}}function Fi(t,e){return typeof t=="number"?t:t[e]||0}const pd=new WeakMap;class gd{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=X(),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 r=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Me(d).point)},o=(d,f)=>{const{drag:p,dragPropagation:y,onDragStart:x}=this.getProps();if(p&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Sc(p),!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),at(v=>{let w=this.getAxisMotionValue(v).get()||0;if(xt.test(w)){const{projection:T}=this.visualElement;if(T&&T.layout){const M=T.layout.layoutBox[v];M&&(w=nt(M)*(parseFloat(w)/100))}}this.originPoint[v]=w}),x&&z.postRender(()=>x(d,f)),Xn(this.visualElement,"transform");const{animationState:b}=this.visualElement;b&&b.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:p,dragDirectionLock:y,onDirectionLock:x,onDrag:b}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:v}=f;if(y&&this.currentDirection===null){this.currentDirection=yd(v),this.currentDirection!==null&&x&&x(this.currentDirection);return}this.updateAxis("x",f.point,v),this.updateAxis("y",f.point,v),this.visualElement.render(),b&&b(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>at(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new Fr(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:s,contextWindow:Or(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!i||!s)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&z.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||!Fe(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=cd(o,this.constraints[e],this.elastic[e])),r.set(o)}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&&Jt(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=ud(s.layoutBox,e):this.constraints=!1,this.elastic=md(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&at(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=fd(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Jt(e))return!1;const s=e.current;St(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 r=bu(s,i.root,this.visualElement.getTransformPagePoint());let o=dd(i.layout.layoutBox,r);if(n){const a=n(yu(o));this.hasMutatedConstraints=!!a,a&&(o=br(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=at(c=>{if(!Fe(c,n,this.currentDirection))return;let d=l&&l[c]||{};o&&(d={min:0,max:0});const f=i?200:1e6,p=i?40:1e7,y={type:"inertia",velocity:s?e[c]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(c,y)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Xn(this.visualElement,e),s.start(Rs(e,s,0,n,this.visualElement,!1))}stopAnimation(){at(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){at(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){at(n=>{const{drag:s}=this.getProps();if(!Fe(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n];r.set(e[n]-_(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Jt(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};at(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=hd({min:l,max:l},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),at(o=>{if(!Fe(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:u}=this.constraints[o];a.set(_(l,u,i[o]))})}addListeners(){if(!this.visualElement.current)return;pd.set(this.visualElement,this);const e=this.visualElement.current,n=pe(e,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Jt(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,r=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),z.read(s);const o=Se(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(at(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())}));return()=>{o(),n(),r(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=Gn,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function Fe(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function yd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class xd extends Vt{constructor(e){super(e),this.removeGroupControls=ct,this.removeListeners=ct,this.controls=new gd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ct}unmount(){this.removeGroupControls(),this.removeListeners()}}const Bi=t=>(e,n)=>{t&&z.postRender(()=>t(e,n))};class vd extends Vt{constructor(){super(...arguments),this.removePointerDownListener=ct}onPointerDown(e){this.session=new Fr(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Or(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Bi(e),onStart:Bi(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&z.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=pe(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 _e={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function zi(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const he={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(j.test(t))t=parseFloat(t);else return t;const n=zi(t,e.target.x),s=zi(t,e.target.y);return`${n}% ${s}%`}},bd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Et.parse(t);if(i.length>5)return s;const r=Et.createTransformer(t),o=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,l=n.y.scale*e.y;i[0+o]/=a,i[1+o]/=l;const u=_(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=u),typeof i[3+o]=="number"&&(i[3+o]/=u),r(i)}};let Sn=!1;class wd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=e;Kc(Td),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),Sn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),_e.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,Sn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==r?o.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?o.promote():o.relegate()||z.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),ws.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;Sn=!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 zr(t){const[e,n]=ar(),s=m.useContext(Qn);return h.jsx(wd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(xr),isPresent:e,safeToRemove:n})}const Td={borderRadius:{...he,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:he,borderTopRightRadius:he,borderBottomLeftRadius:he,borderBottomRightRadius:he,boxShadow:bd};function Sd(t,e,n){const s=Q(t)?t:ie(t);return s.start(Rs("",s,e,n)),s.animation}const Cd=(t,e)=>t.depth-e.depth;class Pd{constructor(){this.children=[],this.isDirty=!1}add(e){ns(this.children,e),this.isDirty=!0}remove(e){ss(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Cd),this.isDirty=!1,this.children.forEach(e)}}function Ad(t,e){const n=it.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(Dt(s),t(r-e))};return z.setup(s,!0),()=>Dt(s)}const $r=["TopLeft","TopRight","BottomLeft","BottomRight"],Md=$r.length,$i=t=>typeof t=="string"?parseFloat(t):t,Ui=t=>typeof t=="number"||j.test(t);function jd(t,e,n,s,i,r){i?(t.opacity=_(0,n.opacity??1,Dd(s)),t.opacityExit=_(e.opacity??1,0,Ed(s))):r&&(t.opacity=_(e.opacity??1,n.opacity??1,s));for(let o=0;o<Md;o++){const a=`border${$r[o]}Radius`;let l=Wi(e,a),u=Wi(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Ui(l)===Ui(u)?(t[a]=Math.max(_($i(l),$i(u),s),0),(xt.test(u)||xt.test(l))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=_(e.rotate||0,n.rotate||0,s))}function Wi(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Dd=Ur(0,.5,Mo),Ed=Ur(.5,.95,ct);function Ur(t,e,n){return s=>s<t?0:s>e?1:n(xe(t,e,s))}function _i(t,e){t.min=e.min,t.max=e.max}function rt(t,e){_i(t.x,e.x),_i(t.y,e.y)}function Ki(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function Hi(t,e,n,s,i){return t-=e,t=Je(t,1/n,s),i!==void 0&&(t=Je(t,1/i,s)),t}function Vd(t,e=0,n=1,s=.5,i,r=t,o=t){if(xt.test(e)&&(e=parseFloat(e),e=_(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=_(r.min,r.max,s);t===r&&(a-=e),t.min=Hi(t.min,e,n,a,i),t.max=Hi(t.max,e,n,a,i)}function Xi(t,e,[n,s,i],r,o){Vd(t,e[n],e[s],e[i],e.scale,r,o)}const kd=["x","scaleX","originX"],Rd=["y","scaleY","originY"];function Yi(t,e,n,s){Xi(t.x,e,kd,n?n.x:void 0,s?s.x:void 0),Xi(t.y,e,Rd,n?n.y:void 0,s?s.y:void 0)}function Gi(t){return t.translate===0&&t.scale===1}function Wr(t){return Gi(t.x)&&Gi(t.y)}function qi(t,e){return t.min===e.min&&t.max===e.max}function Nd(t,e){return qi(t.x,e.x)&&qi(t.y,e.y)}function Zi(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function _r(t,e){return Zi(t.x,e.x)&&Zi(t.y,e.y)}function Ji(t){return nt(t.x)/nt(t.y)}function Qi(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Id{constructor(){this.members=[]}add(e){ns(this.members,e),e.scheduleRender()}remove(e){if(ss(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 r=this.members[i];if(r.isPresent!==!1){s=r;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 Ld(t,e,n){let s="";const i=t.x.translate/e.x,r=t.y.translate/e.y,o=n?.z||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:d,rotateY:f,skewX:p,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),c&&(s+=`rotate(${c}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),p&&(s+=`skewX(${p}deg) `),y&&(s+=`skewY(${y}deg) `)}const a=t.x.scale*e.x,l=t.y.scale*e.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const Cn=["","X","Y","Z"],Od=1e3;let Fd=0;function Pn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function Kr(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Dr(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",z,!(i||r))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&Kr(s)}function Hr({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Fd++,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($d),this.nodes.forEach(Kd),this.nodes.forEach(Hd),this.nodes.forEach(Ud)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,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 l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Pd)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new os),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=rr(o)&&!Dc(o),this.instance=o;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let c,d=0;const f=()=>this.root.updateBlockedByResize=!1;z.read(()=>{d=window.innerWidth}),t(o,()=>{const p=window.innerWidth;p!==d&&(d=p,this.root.updateBlockedByResize=!0,c&&c(),c=Ad(f,250),_e.hasAnimatedSinceResize&&(_e.hasAnimatedSinceResize=!1,this.nodes.forEach(no)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||Zd,{onLayoutAnimationStart:x,onLayoutAnimationComplete:b}=u.getProps(),v=!this.targetLayout||!_r(this.targetLayout,p),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const T={...vs(y,"layout"),onPlay:x,onComplete:b};(u.shouldReduceMotion||this.options.layoutRoot)&&(T.delay=0,T.type=!1),this.startAnimation(T),this.setAnimationOrigin(c,w)}else d||no(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Dt(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(Xd),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Kr(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const d=this.path[c];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(to);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(eo);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(_d),this.nodes.forEach(Bd),this.nodes.forEach(zd)):this.nodes.forEach(eo),this.clearAllSnapshots();const a=it.now();q.delta=Tt(0,1e3/60,a-q.timestamp),q.timestamp=a,q.isProcessing=!0,fn.update.process(q),fn.preRender.process(q),fn.render.process(q),q.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,ws.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Wd),this.sharedNodes.forEach(Yd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,z.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){z.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!nt(this.snapshot.measuredBox.x)&&!nt(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 l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=X(),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,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Wr(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;o&&this.instance&&(a||Ut(this.latestValues)||c)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),Jd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return X();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Qd))){const{scroll:u}=this.root;u&&(Qt(a.x,u.offset.x),Qt(a.y,u.offset.y))}return a}removeElementScroll(o){const a=X();if(rt(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:d}=u;u!==this.root&&c&&d.layoutScroll&&(c.wasRoot&&rt(a,o),Qt(a.x,c.offset.x),Qt(a.y,c.offset.y))}return a}applyTransform(o,a=!1){const l=X();rt(l,o);for(let u=0;u<this.path.length;u++){const c=this.path[u];!a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&te(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),Ut(c.latestValues)&&te(l,c.latestValues)}return Ut(this.latestValues)&&te(l,this.latestValues),l}removeTransform(o){const a=X();rt(a,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Ut(u.latestValues))continue;Wn(u.latestValues)&&u.updateSnapshot();const c=X(),d=u.measurePageBox();rt(c,d),Yi(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return Ut(this.latestValues)&&Yi(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.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!==q.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:d}=this.options;if(!(!this.layout||!(c||d))){if(this.resolvedRelativeTargetAt=q.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=X(),this.relativeTargetOrigin=X(),ye(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),rt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=X(),this.targetWithTransforms=X()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),od(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):rt(this.target,this.layout.layoutBox),Tr(this.target,this.targetDelta)):rt(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=X(),this.relativeTargetOrigin=X(),ye(this.relativeTargetOrigin,this.target,f.target),rt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Wn(this.parent.latestValues)||wr(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 o=this.getLead(),a=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===q.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=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||c))return;rt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;vu(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=X());const{target:p}=o;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Ki(this.prevProjectionDelta.x,this.projectionDelta.x),Ki(this.prevProjectionDelta.y,this.projectionDelta.y)),ge(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Qi(this.projectionDelta.x,this.prevProjectionDelta.x)||!Qi(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ee(),this.projectionDelta=ee(),this.projectionDeltaWithTransform=ee()}setAnimationOrigin(o,a=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},d=ee();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=X(),p=l?l.source:void 0,y=this.layout?this.layout.source:void 0,x=p!==y,b=this.getStack(),v=!b||b.members.length<=1,w=!!(x&&!v&&this.options.crossfade===!0&&!this.path.some(qd));this.animationProgress=0;let T;this.mixTargetDelta=M=>{const P=M/1e3;so(d.x,o.x,P),so(d.y,o.y,P),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ye(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Gd(this.relativeTarget,this.relativeTargetOrigin,f,P),T&&Nd(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=X()),rt(T,this.relativeTarget)),x&&(this.animationValues=c,jd(c,u,this.latestValues,P,w,v)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Dt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=z.update(()=>{_e.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=ie(0)),this.currentAnimation=Sd(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.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 o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Od),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:c}=o;if(!(!a||!l||!u)){if(this!==o&&this.layout&&u&&Xr(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||X();const d=nt(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=nt(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}rt(a,l),te(a,c),ge(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Id),this.sharedNodes.get(o).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 o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&Pn("z",o,u,this.animationValues);for(let c=0;c<Cn.length;c++)Pn(`rotate${Cn[c]}`,o,u,this.animationValues),Pn(`skew${Cn[c]}`,o,u,this.animationValues);o.render();for(const c in u)o.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Ue(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Ue(a?.pointerEvents)||""),this.hasProjected&&!Ut(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=Ld(this.projectionDeltaWithTransform,this.treeScale,c);l&&(d=l(c,d)),o.transform=d;const{x:f,y:p}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${p.origin*100}% 0`,u.animationValues?o.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:o.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const y in Te){if(c[y]===void 0)continue;const{correct:x,applyTo:b,isCSSVariable:v}=Te[y],w=d==="none"?c[y]:x(c[y],u);if(b){const T=b.length;for(let M=0;M<T;M++)o[b[M]]=w}else v?this.options.visualElement.renderState.vars[y]=w:o[y]=w}this.options.layoutId&&(o.pointerEvents=u===this?Ue(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(to),this.root.sharedNodes.clear()}}}function Bd(t){t.updateLayout()}function zd(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,r=e.source!==t.layout.source;i==="size"?at(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=nt(d);d.min=n[c].min,d.max=d.min+f}):Xr(i,e.layoutBox,n)&&at(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=nt(n[c]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[c].max=t.relativeTarget[c].min+f)});const o=ee();ge(o,n,e.layoutBox);const a=ee();r?ge(a,t.applyTransform(s,!0),e.measuredBox):ge(a,n,e.layoutBox);const l=!Wr(o);let u=!1;if(!t.resumeFrom){const c=t.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:d,layout:f}=c;if(d&&f){const p=X();ye(p,e.layoutBox,d.layoutBox);const y=X();ye(y,n,f.layoutBox),_r(p,y)||(u=!0),c.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=p,t.relativeParent=c)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function $d(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 Ud(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Wd(t){t.clearSnapshot()}function to(t){t.clearMeasurements()}function eo(t){t.isLayoutDirty=!1}function _d(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function no(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Kd(t){t.resolveTargetDelta()}function Hd(t){t.calcProjection()}function Xd(t){t.resetSkewAndRotation()}function Yd(t){t.removeLeadSnapshot()}function so(t,e,n){t.translate=_(e.translate,0,n),t.scale=_(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function io(t,e,n,s){t.min=_(e.min,n.min,s),t.max=_(e.max,n.max,s)}function Gd(t,e,n,s){io(t.x,e.x,n.x,s),io(t.y,e.y,n.y,s)}function qd(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Zd={duration:.45,ease:[.4,0,.1,1]},oo=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),ro=oo("applewebkit/")&&!oo("chrome/")?Math.round:ct;function ao(t){t.min=ro(t.min),t.max=ro(t.max)}function Jd(t){ao(t.x),ao(t.y)}function Xr(t,e,n){return t==="position"||t==="preserve-aspect"&&!id(Ji(e),Ji(n),.2)}function Qd(t){return t!==t.root&&t.scroll?.wasRoot}const th=Hr({attachResizeListener:(t,e)=>Se(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),An={current:void 0},Yr=Hr({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!An.current){const t=new th({});t.mount(window),t.setOptions({layoutScroll:!0}),An.current=t}return An.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),eh={pan:{Feature:vd},drag:{Feature:xd,ProjectionNode:Yr,MeasureLayout:zr}};function lo(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&z.postRender(()=>r(e,Me(e)))}class nh extends Vt{mount(){const{current:e}=this.node;e&&(this.unmount=Cc(e,(n,s)=>(lo(this.node,s,"Start"),i=>lo(this.node,i,"End"))))}unmount(){}}class sh extends Vt{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=Ce(Se(this.node.current,"focus",()=>this.onFocus()),Se(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function co(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),r=s[i];r&&z.postRender(()=>r(e,Me(e)))}class ih extends Vt{mount(){const{current:e}=this.node;e&&(this.unmount=jc(e,(n,s)=>(co(this.node,s,"Start"),(i,{success:r})=>co(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const qn=new WeakMap,Mn=new WeakMap,oh=t=>{const e=qn.get(t.target);e&&e(t)},rh=t=>{t.forEach(oh)};function ah({root:t,...e}){const n=t||document;Mn.has(n)||Mn.set(n,{});const s=Mn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(rh,{root:t,...e})),s[i]}function lh(t,e,n){const s=ah(e);return qn.set(t,n),s.observe(t),()=>{qn.delete(t),s.unobserve(t)}}const ch={some:0,all:1};class uh extends Vt{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:r}=e,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:ch[i]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,r&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=u?c:d;f&&f(l)};return lh(this.node.current,o,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 Gr={inView:{Feature:uh},tap:{Feature:ih},focus:{Feature:sh},hover:{Feature:nh}},hh={layout:{ProjectionNode:Yr,MeasureLayout:zr}},fh={...Nr,...Gr,...eh,...hh},mh=gu(fh,jr),ph={renderer:jr,...Nr,...Gr};function qr(t,e){return We(t,e)}const Be=qr("div"),gh=qr("p");let Ke=null;function yh(){try{return require("../../.arcten/tool-types.json")?.functions||null}catch{return null}}Ke=yh();function Zn(t){let e;switch(t.type){case"string":e=N.z.string();break;case"number":e=N.z.number();break;case"boolean":e=N.z.boolean();break;case"enum":t.values&&t.values.length>0?e=N.z.enum(t.values):e=N.z.string();break;case"array":if(t.arrayItemType){const n=Zn(t.arrayItemType);e=N.z.array(n)}else e=N.z.array(N.z.any());break;case"object":if(t.properties){const n={};for(const[s,i]of Object.entries(t.properties))n[s]=Zn(i);e=N.z.object(n)}else e=N.z.object({}).passthrough();break;default:e=N.z.any()}return t.required||(e=e.optional()),t.description&&(e=e.describe(t.description)),e}function xh(t,e){const n={},s={};for(const[i,r]of Object.entries(e.parameters))n[i]=Zn(r),s[i]={type:r.type,description:r.description||i,required:r.required};return{name:t,description:e.description,parameters:N.z.object(n),parametersDef:s}}function vh(t){const e=t.name||"unnamed";if(Ke&&Ke[e])return xh(e,Ke[e]);const{description:n,paramDescriptions:s,paramTypes:i}=bh(t),{schema:r,def:o}=Th(t,s,i);return{name:e,description:n,parameters:r,parametersDef:o}}function bh(t){const e=t.toString(),n=new Map,s=new Map,i=e.match(/\/\*\*[\s\S]*?\*\//);if(i){const r=i[0],a=r.match(/\/\*\*\s*\n\s*\*\s*([^\n@]+)/)?.[1]?.trim()||`Execute ${t.name||"function"}`,l=/@param\s+(?:\{([^}]+)\}\s+)?(\w+)(?:\s+-\s+(.+))?/g;let u;for(;(u=l.exec(r))!==null;){const[,c,d,f]=u;c&&d&&s.set(d,c.trim()),f&&d&&n.set(d,f.trim())}return{description:a,paramDescriptions:n,paramTypes:s}}return{description:`Execute ${t.name||"function"}`,paramDescriptions:n,paramTypes:s}}function wh(t){try{let e=t;t.includes("=>")?e=`(${t})`:!t.startsWith("function")&&!t.startsWith("async")&&(e=`function ${t}`);const n=ka.parse(e,{ecmaVersion:"latest",sourceType:"module"});let s=null;if(n.body[0]?.type==="ExpressionStatement"){const i=n.body[0].expression;(i.type==="FunctionExpression"||i.type==="ArrowFunctionExpression")&&(s=i)}else n.body[0]?.type==="FunctionDeclaration"&&(s=n.body[0]);if(s&&s.params)return s.params}catch(e){console.warn("Failed to parse function with acorn:",e)}return[]}function uo(t,e,n,s){if(e){const i=e.toLowerCase();return i.includes("string")?"string":i.includes("number")?"number":i.includes("boolean")?"boolean":i.includes("array")?"array":i.includes("object")?"object":e}if(n&&s){if(s==="true"||s==="false")return"boolean";if(/^\d+$/.test(s))return"number";if(/^["']/.test(s))return"string";if(s==="[]"||s.startsWith("["))return"array";if(s==="{}"||s.startsWith("{"))return"object"}return t.endsWith("Id")||t.endsWith("Name")||t.includes("status")?"string":t.includes("count")||t.includes("amount")||t.includes("price")?"number":t.startsWith("is")||t.startsWith("has")||t.startsWith("should")?"boolean":"string"}function Th(t,e,n){const s=t.toString(),i=wh(s);if(i.length===0)return{schema:N.z.object({}),def:{}};const r={},o={};for(const a of i){const l=a;if(l.type==="Identifier"){const u=l.name,c=s.includes(`${u} =`)||s.includes(`${u}=`),f=s.match(new RegExp(`${u}\\s*=\\s*([^,)]+)`))?.[1]?.trim(),p=n.get(u),y=uo(u,p,c,f),x=e.get(u)||u,b=!c;let v;switch(y){case"string":v=N.z.string();break;case"number":v=N.z.number();break;case"boolean":v=N.z.boolean();break;case"array":v=N.z.array(N.z.any());break;case"object":v=N.z.object({}).passthrough();break;default:v=N.z.any()}b||(v=v.optional()),v=v.describe(x),r[u]=v,o[u]={type:y,description:x,required:b}}else if(l.type==="AssignmentPattern"){const u=l.left;if(u.type==="Identifier"){const c=u.name,d=s.match(new RegExp(`${c}\\s*=\\s*([^,)]+)`))?.[1]?.trim(),f=n.get(c),p=uo(c,f,!0,d),y=e.get(c)||c;let x;switch(p){case"string":x=N.z.string().optional();break;case"number":x=N.z.number().optional();break;case"boolean":x=N.z.boolean().optional();break;case"array":x=N.z.array(N.z.any()).optional();break;case"object":x=N.z.object({}).passthrough().optional();break;default:x=N.z.any().optional()}x=x.describe(y),r[c]=x,o[c]={type:p,description:y,required:!1}}}else if(l.type==="RestElement"){const u=l.argument.name,c=e.get(u)||`${u} (rest parameters)`,d=N.z.array(N.z.any()).describe(c);r[u]=d,o[u]={type:"array",description:c,required:!1}}else if(l.type==="ObjectPattern"){const u="params",c=e.get(u)||"Parameters object",d=N.z.object({}).passthrough().describe(c);r[u]=d,o[u]={type:"object",description:c,required:!0}}}return{schema:N.z.object(r),def:o}}function Zr(t){return t.map(vh)}function Sh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const r=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})}),r&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([o,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:[o,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},o))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(Xe,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(G.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(Xe,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(G.X,{className:"h-3 w-3"})})]})]})})}function Ch({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,r]=m.useState(!1);if(t==="fetchDocContent")return null;const o=["k","maxResults","_organizationId"];t==="searchDocs"&&o.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!o.includes(u))),l=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>l&&r(!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"} ${l?"cursor-pointer hover:bg-opacity-80":""}`,children:[l&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(G.ChevronDown,{className:"h-3 w-3"}):h.jsx(G.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(G.X,{className:"h-3 w-3"}):s?h.jsx(G.Zap,{className:"h-3 w-3"}):h.jsx(G.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&l&&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,c])=>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 c=="string"?c:JSON.stringify(c)})]},u))})})]})}function Ph({...t}){return h.jsx(Jn.Root,{"data-slot":"collapsible",...t})}function Ah({...t}){return h.jsx(Jn.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Mh({...t}){return h.jsx(Jn.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const jh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),Ns=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(jh,{className:Z("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);Ns.displayName="Response";const Dh=Object.freeze(Object.defineProperty({__proto__:null,Response:Ns},Symbol.toStringTag,{value:"Module"})),Eh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const r=mh.create(e),o=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(r,{animate:{backgroundPosition:"0% center"},className:Z("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":`${o}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})},Vh=m.memo(Eh),Jr=m.createContext(null),kh=()=>{const t=m.useContext(Jr);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Rh=1e3,Nh=1e3,Qr=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:r,children:o,...a})=>{const[l,u]=Xs.useControllableState({prop:n,defaultProp:s,onChange:i}),[c,d]=Xs.useControllableState({prop:r,defaultProp:0}),[f,p]=m.useState(!1),[y,x]=m.useState(null);m.useEffect(()=>{e?y===null&&x(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/Nh)),x(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&l&&!f){const v=setTimeout(()=>{u(!1),p(!0)},Rh);return()=>clearTimeout(v)}},[e,l,s,u,f]);const b=v=>{u(v)};return h.jsx(Jr.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:u,duration:c},children:h.jsx(Ph,{className:Z("not-prose mb-4",t),onOpenChange:b,open:l,...a,children:o})})}),Ih=(t,e)=>t||e===0?h.jsx(Vh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),ta=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:r}=kh();return h.jsx(Ah,{className:Z("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(G.BrainIcon,{className:"size-4"}),Ih(s,r),h.jsx(G.ChevronDownIcon,{className:Z("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),ea=m.memo(({className:t,children:e,...n})=>h.jsx(Mh,{className:Z("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(Ns,{className:"grid gap-2",children:e})}));Qr.displayName="Reasoning";ta.displayName="ReasoningTrigger";ea.displayName="ReasoningContent";function Lh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:r=void 0,defaultWidth:o=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:c=[],safeTools:d=[],systemPrompt:f="",tokenEndpoint:p="/api/arcten/token",apiBaseUrl:y="https://api.arcten.com",user:x}){const[b,v]=m.useState(null),w=m.useRef(null),[T,M]=m.useState(null),[P,V]=m.useState(null),D=m.useRef(null),[A,B]=m.useState(u),[I,tt]=m.useState(o),[vt,bt]=m.useState(600),[kt,mt]=m.useState(!1),[L,$]=m.useState(!1),[R,st]=m.useState(!1),[K,wt]=m.useState({x:100,y:100}),[je,Pt]=m.useState(!1),[Rt,De]=m.useState({x:0,y:0}),[on,rn]=m.useState(!1),Xt=m.useRef(null),Yt=m.useRef(null),[E,k]=m.useState(""),[H,ot]=m.useState(null),[et,ut]=m.useState("Thinking..."),[an,ln]=m.useState(new Set),[na,sa]=m.useState(""),[Nt,ia]=m.useState([]),[cn,Is]=m.useState(!1),[un,Ls]=m.useState([]),[Os,dn]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Gt,Ee]=m.useState(!1),[Fh,Ve]=m.useState(!1),[Bh,ke]=m.useState([]),It=m.useMemo(()=>[...c,...d],[c,d]),Fs=m.useMemo(()=>Zr(It),[It]),Bs=m.useMemo(()=>{const g=new Map;return It.forEach(C=>g.set(C.name,C)),g},[It]),zs=m.useMemo(()=>new Set(d.map(g=>g.name)),[d]),$s=["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 g=localStorage.getItem("arcten-sidebar-expanded");g&&B(JSON.parse(g));const C=localStorage.getItem("arcten-sidebar-width");C&&tt(parseInt(C));const O=localStorage.getItem("arcten-sidebar-height");O&&bt(parseInt(O));const S=localStorage.getItem("arcten-sidebar-detached");S&&$(JSON.parse(S));const U=localStorage.getItem("arcten-sidebar-position");if(U){const At=JSON.parse(U),gt=50,Mt=Math.max(gt-o,Math.min(At.x,window.innerWidth-gt)),J=Math.max(0,Math.min(At.y,window.innerHeight-gt));wt({x:Mt,y:J})}const F=localStorage.getItem("arcten-sidebar-minimized");F&&st(JSON.parse(F)),rn(!0)}},[]),m.useEffect(()=>((async()=>{try{const C=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:x})});if(!C.ok)throw new Error("Failed to fetch token");const O=await C.json();v(O.clientToken),w.current=O.clientToken,V(O.expiresAt),M(null)}catch(C){M(C instanceof Error?C.message:"Failed to fetch token")}})(),()=>{D.current&&clearTimeout(D.current)}),[p,x]),m.useEffect(()=>{if(!P)return;D.current&&clearTimeout(D.current);const g=Math.floor(Date.now()/1e3),C=P-g,S=Math.max(0,C-5);return console.log(`Token expires at ${new Date(P*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${S} seconds`),D.current=setTimeout(async()=>{console.log("Refreshing token...");try{const U=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:x})});if(!U.ok)throw new Error("Failed to refresh token");const F=await U.json();v(F.clientToken),w.current=F.clientToken,V(F.expiresAt),M(null),console.log("Token refreshed successfully")}catch(U){console.error("Token refresh failed:",U),M(U instanceof Error?U.message:"Failed to refresh token")}},S*1e3),()=>{D.current&&clearTimeout(D.current)}},[P,p,x]),m.useEffect(()=>{(async()=>{if(It.length!==0)try{const C=It.map(S=>({name:S.name,code:S.toString()})),O=await fetch(`${y}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:C})});if(O.ok){const S=await O.json();ia(S.tools)}}catch(C){console.error("Failed to fetch tool descriptions:",C)}})()},[It]),m.useEffect(()=>{Promise.resolve().then(()=>Dh).then(g=>{ot(()=>g.Response)})},[]),m.useEffect(()=>{const g=()=>{sa(window.location.pathname)};g(),window.addEventListener("popstate",g);const C=setInterval(g,500);return()=>{window.removeEventListener("popstate",g),clearInterval(C)}},[]);async function Us(){if(!(!x?.id||!b)){Ve(!0);try{const C=await(await fetch(`${y}/conversations`,{headers:{Authorization:`Bearer ${b}`}})).json();Ls(C.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{Ve(!1)}}}m.useEffect(()=>{x?.id&&b&&Us()},[x,b]);function oa(g){const C=Math.floor((Date.now()-g)/1e3);return C<60?"now":C<3600?`${Math.floor(C/60)}m`:C<86400?`${Math.floor(C/3600)}h`:`${Math.floor(C/86400)}d`}function ra(){const g=crypto.randomUUID();dn(g),Ne([]),ke([]),Ee(!1)}async function aa(g){if(b)try{await fetch(`${y}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${b}`}}),Ls(un.filter(C=>C._id!==g)),g===Os&&ra()}catch(C){console.error("Failed to delete conversation:",C)}}async function la(g){dn(g.chatId),Ee(!1),Ve(!0);try{const C=await fetch(`${y}/conversations/${g.chatId}/messages`,{headers:{Authorization:`Bearer ${w.current}`}});if(!C.ok)throw new Error(`Failed to fetch messages: ${C.statusText}`);const S=(await C.json()).messages||[];Ne(S),ke(S)}catch(C){console.error("Failed to load conversation messages:",C);const O=g.messages||[];Ne(O),ke(O)}finally{Ve(!1)}}const ca=(async(g,C={})=>{const O=C.headers?new Headers(C.headers):new Headers;return O.delete("user-agent"),O.delete("User-Agent"),fetch(g,{...C,headers:O})}),{messages:ue,sendMessage:ua,status:pt,error:Ws,stop:Re,addToolResult:de,setMessages:Ne}=ho.useChat({id:Os||void 0,transport:new He.DefaultChatTransport({api:`${y}/chat`,fetch:ca,headers:()=>{const g={};return w.current&&(g.Authorization=`Bearer ${w.current}`),g},body:()=>({tools:Fs.map(g=>({name:g.name,description:g.description,parameters:g.parametersDef})),systemPrompt:f,currentRoute:na})}),sendAutomaticallyWhen:He.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{A&&Yt.current&&Yt.current.focus()},[A,ue]);function da(){B(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function ha(){B(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[A]),m.useEffect(()=>{Xt.current&&Xt.current.scrollIntoView({behavior:"smooth"})},[ue]),m.useEffect(()=>{function g(C){C.key==="Escape"&&(pt==="streaming"||pt==="submitted")&&(C.preventDefault(),Re())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[pt,Re]);function fa(){const g=crypto.randomUUID();dn(g),Ne([]),ke([]),Ee(!1)}function _s(g){if(g.preventDefault(),!E.trim())return;(pt==="streaming"||pt==="submitted")&&Re();const C=$s[Math.floor(Math.random()*$s.length)]||"Thinking...";ut(C),ua({text:E}),k("")}function ma(g){const C=g.target.value;k(C)}m.useEffect(()=>{if(!kt)return;function g(O){if(L){const S=O.clientX-K.x,U=O.clientY-K.y;S>=a&&S<=l&&tt(S),U>=400&&U<=1e3&&bt(U)}else{const S=window.innerWidth-O.clientX;S>=a&&S<=l&&tt(S)}}function C(){mt(!1),localStorage.setItem("arcten-sidebar-width",I.toString()),localStorage.setItem("arcten-sidebar-height",vt.toString())}return window.addEventListener("mousemove",g),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",C)}},[kt,I,vt,L,K,a,l]);function pa(g){g.preventDefault(),mt(!0)}function ga(){$(!0),st(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function ya(){$(!1),st(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ks(){st(!R),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!R))}function xa(g){L&&(Pt(!0),De({x:g.clientX-K.x,y:g.clientY-K.y}))}return m.useEffect(()=>{if(!L)return;function g(){wt(C=>{const S=window.innerWidth-50,U=window.innerHeight-50,F=50-I,At=0,gt=Math.max(F,Math.min(C.x,S)),Mt=Math.max(At,Math.min(C.y,U));if(gt!==C.x||Mt!==C.y){const J={x:gt,y:Mt};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(J)),J}return C})}return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[L,I]),m.useEffect(()=>{if(!je)return;function g(O){const S=O.clientX-Rt.x,U=O.clientY-Rt.y,F=50,At=window.innerWidth-F,gt=window.innerHeight-F,Mt=F-I,J=0,yt=Math.max(Mt,Math.min(S,At)),Lt=Math.max(J,Math.min(U,gt));wt({x:yt,y:Lt})}function C(){Pt(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(K))}return window.addEventListener("mousemove",g),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",C)}},[je,Rt,K,I]),on?T?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: ",T]})}):b?h.jsx(Bc,{features:ph,children:h.jsx(Be,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:L?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:L?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
10
10
  ${L?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
11
11
  ${A?"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"}
12
12
  ${L?"border border-border":"border-l border-border"}
13
13
  ${A?"":"w-[30px]"}
14
- `,style:A?L?{width:`${I}px`,height:R?"auto":`${ve}px`,left:`${K.x}px`,top:`${K.y}px`}:{width:`${I}px`}:void 0,onClick:A?void 0:da,children:A?h.jsxs(h.Fragment,{children:[!L&&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:pa,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),L&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:g=>{g.preventDefault(),me(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:g=>{g.preventDefault(),g.stopPropagation(),Pe(!0),Et({x:g.clientX-K.x,y:g.clientY-K.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:g=>{g.preventDefault(),me(!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 ${L?"cursor-move":""}`,onMouseDown:L?xa:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${L&&R?"cursor-pointer":""}`,onClick:L&&R?g=>{g.stopPropagation(),Ks()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:g=>g.stopPropagation(),children:[h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx("button",{type:"button",className:J(Ge({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:fa,"aria-label":"New chat",children:h.jsx(G.Plus,{className:"h-4 w-4"})})}),h.jsx(Be,{children:"Start a new conversation"})]}),h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx("button",{type:"button",className:J(Ge({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:L?ya:ga,"aria-label":L?"Dock sidebar":"Float sidebar",children:L?h.jsx(G.Dock,{className:"h-4 w-4"}):h.jsx(G.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Be,{children:L?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx("button",{type:"button",className:J(Ge({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:L?Ks:ha,"aria-label":L?R?"Maximize":"Minimize":"Close sidebar",children:L?R?h.jsx(G.Maximize2,{className:"h-4 w-4"}):h.jsx(G.Minimize2,{className:"h-4 w-4"}):h.jsx(G.X,{className:"h-4 w-4"})})}),h.jsx(Be,{children:L?R?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!R&&h.jsxs(h.Fragment,{children:[x&&un.length>0&&h.jsxs("div",{className:`border-b border-border ${Ye?"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(xt,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Ye||Us(),Vt(!Ye)},children:Ye?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Ye?"flex-1 overflow-y-auto":""}`,children:un.slice(0,Ye?void 0:3).map(g=>h.jsxs("div",{className:"group relative",children:[h.jsxs(xt,{variant:"ghost",className:"w-full justify-between h-auto py-1 px-3 font-normal",onClick:()=>la(g),children:[h.jsx("span",{className:"text-xs truncate",children:g.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:oa(g.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:C=>{C.stopPropagation(),aa(g._id)},"aria-label":"Delete conversation",children:h.jsx(G.X,{className:"h-3 w-3"})})]},g._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:ut.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r&&h.jsx("div",{className:"mb-6",children:r}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),Ne.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:[(cn?Ne:Ne.slice(0,10)).map(g=>h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx(hn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{k(g.sampleUsage),Xe.current?.focus()},children:g.friendlyName})}),h.jsx(Be,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:g.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',g.sampleUsage,'"']}),g.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",g.params.join(", ")]})]})})]},g.name)),Ne.length>10&&!cn&&h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsxs(hn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Is(!0),children:["+",Ne.length-10," more"]})}),h.jsx(Be,{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:Ne.slice(10).map(g=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[g.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:g.description})]},g.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),cn&&Ne.length>10&&h.jsx(hn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Is(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[ut.map(g=>{const O=g.parts.filter(S=>S.type==="text").map(S=>S.text).join("");return h.jsx("div",{className:`${g.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${g.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:g.role==="user"?h.jsx(gh,{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:O}):h.jsx("div",{className:"space-y-2",children:g.parts.map((S,U)=>{if(S.type?.startsWith("tool-")){const F=S.type?.replace("tool-","")||"",Ae=Fs.find(Z=>Z.name===F),ge=S.state==="input-available",Me=S.state==="output-available";if(ge)return zs.has(F)?((async()=>{if(an.has(S.toolCallId))return;ln(Le=>new Set(Le).add(S.toolCallId));const ye=Bs.get(F);if(ye)try{console.log("Auto-executing safe tool:",F);const Le=await ye(...Object.values(S.input||{}));dt({toolCallId:S.toolCallId,tool:F,output:Le}),console.log("Safe tool result added:",S.toolCallId)}catch(Le){dt({toolCallId:S.toolCallId,tool:F,output:`Error: ${Le}`}),console.log("Safe tool error result added:",S.toolCallId)}})(),null):h.jsx(zt,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(Sh,{toolName:F,description:Ae?.description||"",args:S.input||{},onApprove:async()=>{if(an.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}ln(ye=>new Set(ye).add(S.toolCallId));const Z=Bs.get(F);if(Z)try{const ye=await Z(...Object.values(S.input||{}));dt({toolCallId:S.toolCallId,tool:F,output:ye}),console.log("Tool result added:",S.toolCallId)}catch(ye){dt({toolCallId:S.toolCallId,tool:F,output:`Error: ${ye}`}),console.log("Tool error result added:",S.toolCallId)}},onDeny:async()=>{if(an.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}ln(Z=>new Set(Z).add(S.toolCallId)),dt({toolCallId:S.toolCallId,tool:F,output:"User denied tool execution"}),console.log("Tool denied:",S.toolCallId)}})},`${S.toolCallId}-${U}`);if(Me){const Z=S.output==="User denied tool execution";return h.jsx(Ch,{toolName:F,args:S.input||{},isDenied:Z,isSafe:zs.has(F)},`${S.toolCallId}-${U}`)}return null}return S.type==="text"&&S.text&&H?h.jsx(H,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:S.text},`${g.id}-${U}`):S.type==="reasoning"&&S.text?h.jsxs(Qr,{className:"w-full",isStreaming:pe==="streaming"&&U===g.parts.length-1&&g.id===ut.at(-1)?.id,children:[h.jsx(ea,{}),h.jsx(ta,{children:S.text})]},`${g.id}-${U}`):null})})})},g.id)}),h.jsx("div",{ref:He})]})}),Ws&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",Ws.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Fc,{mode:"wait",children:(pe==="streaming"||pe==="submitted")&&h.jsxs(zt,{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(zt,{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:te})]})}),h.jsxs("form",{onSubmit:_s,className:"relative",children:[h.jsx(po,{ref:Xe,value:E,onChange:ma,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),_s(g))}}),pe==="streaming"||pe==="submitted"?h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx("button",{type:"button",className:J(Ge({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Nt,children:h.jsx(G.Square,{className:"h-4 w-4"})})}),h.jsxs(Be,{children:[h.jsx(Ys,{children:"Escape"})," to stop"]})]}):h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx("button",{type:"submit",className:J(Ge({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!E.trim(),children:h.jsx(G.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Be,{children:[h.jsx(Ys,{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 overflow-hidden",children:[h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 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:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(G.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 Oh({apiBaseUrl:e="https://api.arcten.com",tokenEndpoint:t="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:r=[],safeTools:o=[],systemPrompt:a="",initialMessages:l=[],conversationId:u,onToolCall:c,onFinish:d,ragFilters:f}={}){console.log("[useAgent] Hook initialized",{apiBaseUrl:e,tokenEndpoint:t,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[p,y]=m.useState(n||null),x=m.useRef(n||null),[b,v]=m.useState(null),[w,T]=m.useState(null),M=m.useRef(null),[P,V]=m.useState([]),[D,A]=m.useState(u||(typeof window<"u"?crypto.randomUUID():null)),[B,I]=m.useState(!1),[ee,ve]=m.useState(new Set),be=m.useMemo(()=>[...r,...o],[r,o]),ke=m.useMemo(()=>Zr(be),[be]),me=m.useMemo(()=>{const E=new Map;return be.forEach(k=>E.set(k.name,k)),E},[be]),L=m.useMemo(()=>new Set(o.map(E=>E.name)),[o]);m.useEffect(()=>{if(console.log("[useAgent] Token fetch effect running",{skipTokenFetch:s,hasProvidedToken:!!n,user:i?.id,tokenEndpoint:t}),s||n){console.log("[useAgent] Skipping token fetch",{reason:s?"skipTokenFetch=true":"token provided"});return}return(async()=>{console.log("[useAgent] Fetching initial token from",t);try{const k=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!k.ok)throw new Error("Failed to fetch token");const H=await k.json();console.log("[useAgent] Token fetched successfully",{expiresAt:H.expiresAt,expiresIn:H.expiresAt?`${H.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),y(H.clientToken),x.current=H.clientToken,T(H.expiresAt),v(null)}catch(k){console.error("[useAgent] Token fetch failed:",k),v(k instanceof Error?k.message:"Failed to fetch token")}})(),()=>{console.log("[useAgent] Cleaning up token fetch effect"),M.current&&clearTimeout(M.current)}},[t,JSON.stringify(i),s,n]),m.useEffect(()=>{if(console.log("[useAgent] Token refresh effect running",{hasTokenExpiresAt:!!w,tokenExpiresAt:w,skipTokenFetch:s,hasProvidedToken:!!n}),!w||s||n){console.log("[useAgent] Skipping token refresh setup",{reason:w?s?"skipTokenFetch=true":"token provided":"no expiry"});return}M.current&&(console.log("[useAgent] Clearing existing token refresh timeout"),clearTimeout(M.current));const E=Math.floor(Date.now()/1e3),k=w-E,oe=Math.max(0,k-5);return console.log("[useAgent] Scheduling token refresh",{expiresAt:w,now:E,timeUntilExpiry:`${k}s`,timeUntilRefresh:`${oe}s`,refreshAt:new Date((E+oe)*1e3).toISOString()}),M.current=setTimeout(async()=>{console.log("[useAgent] Refreshing token...");try{const te=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!te.ok)throw new Error("Failed to refresh token");const ue=await te.json();console.log("[useAgent] Token refreshed successfully",{newExpiresAt:ue.expiresAt,expiresIn:`${ue.expiresAt-Math.floor(Date.now()/1e3)}s`}),y(ue.clientToken),x.current=ue.clientToken,T(ue.expiresAt),v(null)}catch(te){console.error("[useAgent] Token refresh failed:",te),v(te instanceof Error?te.message:"Failed to refresh token")}},oe*1e3),()=>{console.log("[useAgent] Cleaning up token refresh effect"),M.current&&clearTimeout(M.current)}},[w,t,JSON.stringify(i),s,n]);const $=(async(E,k={})=>{const H=k.headers?new Headers(k.headers):new Headers;return H.delete("user-agent"),H.delete("User-Agent"),fetch(E,{...k,headers:H})}),{messages:R,sendMessage:se,status:K,error:we,stop:Dt,addToolResult:Pe,setMessages:Re}=ho.useChat({id:D||void 0,messages:l,transport:new Xt.DefaultChatTransport({api:`${e}/chat`,fetch:$,headers:()=>{const E={};return x.current&&(E.Authorization=`Bearer ${x.current}`),E},body:()=>({tools:ke.map(E=>({name:E.name,description:E.description,parameters:E.parametersDef})),systemPrompt:a,...f&&{ragFilters:f}})}),sendAutomaticallyWhen:Xt.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{R.forEach(E=>{E.role==="assistant"&&E.parts.forEach(k=>{if(!k.type?.startsWith("tool-")||k.state!=="input-available")return;const H=k.type.replace("tool-",""),oe=k.toolCallId;if(!ee.has(oe)){if(ve(te=>new Set(te).add(oe)),L.has(H)){const te=me.get(H);te&&(async()=>{try{const ue=await te(...Object.values(k.input||{}));Pe({toolCallId:oe,tool:H,output:ue})}catch(ue){Pe({toolCallId:oe,tool:H,output:`Error: ${ue}`})}})()}else if(c){const te={toolCallId:oe,toolName:H,args:k.input||{}};c({toolCall:te})}}})})},[R,L,me,c,Pe,ee]),m.useEffect(()=>{if(K==="ready"&&R.length>0&&d){const E=R[R.length-1];E&&E.role==="assistant"&&d({message:E,messages:R,isAbort:!1,isDisconnect:!1,isError:!!we})}},[K,R,we,d]);async function Et(){if(!(!i?.id||!p)){console.log("[useAgent] Fetching conversations for user:",i?.id),I(!0);try{const k=await(await fetch(`${e}/conversations`,{headers:{Authorization:`Bearer ${p}`}})).json();V(k.conversations||[])}catch(E){console.error("Failed to fetch conversations:",E)}finally{I(!1)}}}m.useEffect(()=>{i?.id&&p&&Et()},[JSON.stringify(i),p,e]);async function on(E){A(E),I(!0);try{const k=await fetch(`${e}/conversations/${E}/messages`,{headers:{Authorization:`Bearer ${x.current}`}});if(!k.ok)throw new Error(`Failed to fetch messages: ${k.statusText}`);const oe=(await k.json()).messages||[];Re(oe)}catch(k){console.error("Failed to load conversation messages:",k)}finally{I(!1)}}async function rn(E){if(p)try{await fetch(`${e}/conversations/${E}`,{method:"DELETE",headers:{Authorization:`Bearer ${p}`}}),V(P.filter(k=>k._id!==E)),E===D&&He()}catch(k){console.error("Failed to delete conversation:",k)}}function He(){const E=crypto.randomUUID();A(E),Re([]),ve(new Set)}function Xe(E){Pe(E)}return{id:D,messages:R,status:K,error:we,sendMessage:se,stop:Dt,addToolOutput:Xe,setMessages:Re,conversations:P,loadConversation:on,deleteConversation:rn,startNewConversation:He,isLoadingConversations:B,clientToken:p,tokenError:b}}exports.verifyToken=Va.verifyToken;exports.ArctenAgent=Lh;exports.useAgent=Oh;
14
+ `,style:A?L?{width:`${I}px`,height:R?"auto":`${vt}px`,left:`${K.x}px`,top:`${K.y}px`}:{width:`${I}px`}:void 0,onClick:A?void 0:da,children:A?h.jsxs(h.Fragment,{children:[!L&&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:pa,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),L&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:g=>{g.preventDefault(),mt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:g=>{g.preventDefault(),g.stopPropagation(),Pt(!0),De({x:g.clientX-K.x,y:g.clientY-K.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:g=>{g.preventDefault(),mt(!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 ${L?"cursor-move":""}`,onMouseDown:L?xa:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${L&&R?"cursor-pointer":""}`,onClick:L&&R?g=>{g.stopPropagation(),Ks()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:g=>g.stopPropagation(),children:[h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Z($t({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:fa,"aria-label":"New chat",children:h.jsx(G.Plus,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:"Start a new conversation"})]}),h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Z($t({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:L?ya:ga,"aria-label":L?"Dock sidebar":"Float sidebar",children:L?h.jsx(G.Dock,{className:"h-4 w-4"}):h.jsx(G.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:L?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Z($t({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:L?Ks:ha,"aria-label":L?R?"Maximize":"Minimize":"Close sidebar",children:L?R?h.jsx(G.Maximize2,{className:"h-4 w-4"}):h.jsx(G.Minimize2,{className:"h-4 w-4"}):h.jsx(G.X,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:L?R?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!R&&h.jsxs(h.Fragment,{children:[x&&un.length>0&&h.jsxs("div",{className:`border-b border-border ${Gt?"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(Xe,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Gt||Us(),Ee(!Gt)},children:Gt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Gt?"flex-1 overflow-y-auto":""}`,children:un.slice(0,Gt?void 0:3).map(g=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:Z($t({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>la(g),children:[h.jsx("span",{className:"text-xs truncate",children:g.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:oa(g.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:C=>{C.stopPropagation(),aa(g._id)},"aria-label":"Delete conversation",children:h.jsx(G.X,{className:"h-3 w-3"})})]},g._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:ue.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r&&h.jsx("div",{className:"mb-6",children:r}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),Nt.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:[(cn?Nt:Nt.slice(0,10)).map(g=>h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(hn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{k(g.sampleUsage),Yt.current?.focus()},children:g.friendlyName})}),h.jsx(Bt,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:g.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',g.sampleUsage,'"']}),g.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",g.params.join(", ")]})]})})]},g.name)),Nt.length>10&&!cn&&h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsxs(hn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Is(!0),children:["+",Nt.length-10," more"]})}),h.jsx(Bt,{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:Nt.slice(10).map(g=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[g.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:g.description})]},g.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),cn&&Nt.length>10&&h.jsx(hn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Is(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[ue.map(g=>{const O=g.parts.filter(S=>S.type==="text").map(S=>S.text).join("");return h.jsx("div",{className:`${g.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${g.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:g.role==="user"?h.jsx(gh,{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:O}):h.jsx("div",{className:"space-y-2",children:g.parts.map((S,U)=>{if(S.type?.startsWith("tool-")){const F=S.type?.replace("tool-","")||"",At=Fs.find(J=>J.name===F),gt=S.state==="input-available",Mt=S.state==="output-available";if(gt)return zs.has(F)?((async()=>{if(an.has(S.toolCallId))return;ln(Lt=>new Set(Lt).add(S.toolCallId));const yt=Bs.get(F);if(yt)try{console.log("Auto-executing safe tool:",F);const Lt=await yt(...Object.values(S.input||{}));de({toolCallId:S.toolCallId,tool:F,output:Lt}),console.log("Safe tool result added:",S.toolCallId)}catch(Lt){de({toolCallId:S.toolCallId,tool:F,output:`Error: ${Lt}`}),console.log("Safe tool error result added:",S.toolCallId)}})(),null):h.jsx(Be,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(Sh,{toolName:F,description:At?.description||"",args:S.input||{},onApprove:async()=>{if(an.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}ln(yt=>new Set(yt).add(S.toolCallId));const J=Bs.get(F);if(J)try{const yt=await J(...Object.values(S.input||{}));de({toolCallId:S.toolCallId,tool:F,output:yt}),console.log("Tool result added:",S.toolCallId)}catch(yt){de({toolCallId:S.toolCallId,tool:F,output:`Error: ${yt}`}),console.log("Tool error result added:",S.toolCallId)}},onDeny:async()=>{if(an.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}ln(J=>new Set(J).add(S.toolCallId)),de({toolCallId:S.toolCallId,tool:F,output:"User denied tool execution"}),console.log("Tool denied:",S.toolCallId)}})},`${S.toolCallId}-${U}`);if(Mt){const J=S.output==="User denied tool execution";return h.jsx(Ch,{toolName:F,args:S.input||{},isDenied:J,isSafe:zs.has(F)},`${S.toolCallId}-${U}`)}return null}return S.type==="text"&&S.text&&H?h.jsx(H,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:S.text},`${g.id}-${U}`):S.type==="reasoning"&&S.text?h.jsxs(Qr,{className:"w-full",isStreaming:pt==="streaming"&&U===g.parts.length-1&&g.id===ue.at(-1)?.id,children:[h.jsx(ta,{}),h.jsx(ea,{children:S.text})]},`${g.id}-${U}`):null})})})},g.id)}),h.jsx("div",{ref:Xt})]})}),Ws&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",Ws.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Fc,{mode:"wait",children:(pt==="streaming"||pt==="submitted")&&h.jsxs(Be,{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(Be,{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:et})]})}),h.jsxs("form",{onSubmit:_s,className:"relative",children:[h.jsx(po,{ref:Yt,value:E,onChange:ma,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),_s(g))}}),pt==="streaming"||pt==="submitted"?h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Z($t({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Re,children:h.jsx(G.Square,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Ys,{children:"Escape"})," to stop"]})]}):h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"submit",className:Z($t({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!E.trim(),children:h.jsx(G.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Ys,{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 overflow-hidden",children:[h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 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:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(G.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 Oh({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:r=[],safeTools:o=[],systemPrompt:a="",initialMessages:l=[],conversationId:u,onToolCall:c,onFinish:d,ragFilters:f}={}){console.log("[useAgent] Hook initialized",{apiBaseUrl:t,tokenEndpoint:e,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[p,y]=m.useState(n||null),x=m.useRef(n||null),[b,v]=m.useState(null),[w,T]=m.useState(null),M=m.useRef(null),[P,V]=m.useState([]),[D,A]=m.useState(u||(typeof window<"u"?crypto.randomUUID():null)),[B,I]=m.useState(!1),[tt,vt]=m.useState(new Set),bt=m.useMemo(()=>[...r,...o],[r,o]),kt=m.useMemo(()=>Zr(bt),[bt]),mt=m.useMemo(()=>{const E=new Map;return bt.forEach(k=>E.set(k.name,k)),E},[bt]),L=m.useMemo(()=>new Set(o.map(E=>E.name)),[o]);m.useEffect(()=>{if(console.log("[useAgent] Token fetch effect running",{skipTokenFetch:s,hasProvidedToken:!!n,user:i?.id,tokenEndpoint:e}),s||n){console.log("[useAgent] Skipping token fetch",{reason:s?"skipTokenFetch=true":"token provided"});return}return(async()=>{console.log("[useAgent] Fetching initial token from",e);try{const k=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!k.ok)throw new Error("Failed to fetch token");const H=await k.json();console.log("[useAgent] Token fetched successfully",{expiresAt:H.expiresAt,expiresIn:H.expiresAt?`${H.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),y(H.clientToken),x.current=H.clientToken,T(H.expiresAt),v(null)}catch(k){console.error("[useAgent] Token fetch failed:",k),v(k instanceof Error?k.message:"Failed to fetch token")}})(),()=>{console.log("[useAgent] Cleaning up token fetch effect"),M.current&&clearTimeout(M.current)}},[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(console.log("[useAgent] Token refresh effect running",{hasTokenExpiresAt:!!w,tokenExpiresAt:w,skipTokenFetch:s,hasProvidedToken:!!n}),!w||s||n){console.log("[useAgent] Skipping token refresh setup",{reason:w?s?"skipTokenFetch=true":"token provided":"no expiry"});return}M.current&&(console.log("[useAgent] Clearing existing token refresh timeout"),clearTimeout(M.current));const E=Math.floor(Date.now()/1e3),k=w-E,ot=Math.max(0,k-5);return console.log("[useAgent] Scheduling token refresh",{expiresAt:w,now:E,timeUntilExpiry:`${k}s`,timeUntilRefresh:`${ot}s`,refreshAt:new Date((E+ot)*1e3).toISOString()}),M.current=setTimeout(async()=>{console.log("[useAgent] Refreshing token...");try{const et=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!et.ok)throw new Error("Failed to refresh token");const ut=await et.json();console.log("[useAgent] Token refreshed successfully",{newExpiresAt:ut.expiresAt,expiresIn:`${ut.expiresAt-Math.floor(Date.now()/1e3)}s`}),y(ut.clientToken),x.current=ut.clientToken,T(ut.expiresAt),v(null)}catch(et){console.error("[useAgent] Token refresh failed:",et),v(et instanceof Error?et.message:"Failed to refresh token")}},ot*1e3),()=>{console.log("[useAgent] Cleaning up token refresh effect"),M.current&&clearTimeout(M.current)}},[w,e,JSON.stringify(i),s,n]);const $=(async(E,k={})=>{const H=k.headers?new Headers(k.headers):new Headers;return H.delete("user-agent"),H.delete("User-Agent"),fetch(E,{...k,headers:H})}),{messages:R,sendMessage:st,status:K,error:wt,stop:je,addToolResult:Pt,setMessages:Rt}=ho.useChat({id:D||void 0,messages:l,transport:new He.DefaultChatTransport({api:`${t}/chat`,fetch:$,headers:()=>{const E={};return x.current&&(E.Authorization=`Bearer ${x.current}`),E},body:()=>({tools:kt.map(E=>({name:E.name,description:E.description,parameters:E.parametersDef})),systemPrompt:a,...f&&{ragFilters:f}})}),sendAutomaticallyWhen:He.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{R.forEach(E=>{E.role==="assistant"&&E.parts.forEach(k=>{if(!k.type?.startsWith("tool-")||k.state!=="input-available")return;const H=k.type.replace("tool-",""),ot=k.toolCallId;if(!tt.has(ot)){if(vt(et=>new Set(et).add(ot)),L.has(H)){const et=mt.get(H);et&&(async()=>{try{const ut=await et(...Object.values(k.input||{}));Pt({toolCallId:ot,tool:H,output:ut})}catch(ut){Pt({toolCallId:ot,tool:H,output:`Error: ${ut}`})}})()}else if(c){const et={toolCallId:ot,toolName:H,args:k.input||{}};c({toolCall:et})}}})})},[R,L,mt,c,Pt,tt]),m.useEffect(()=>{if(K==="ready"&&R.length>0&&d){const E=R[R.length-1];E&&E.role==="assistant"&&d({message:E,messages:R,isAbort:!1,isDisconnect:!1,isError:!!wt})}},[K,R,wt,d]);async function De(){if(!(!i?.id||!p)){console.log("[useAgent] Fetching conversations for user:",i?.id),I(!0);try{const k=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${p}`}})).json();V(k.conversations||[])}catch(E){console.error("Failed to fetch conversations:",E)}finally{I(!1)}}}m.useEffect(()=>{i?.id&&p&&De()},[JSON.stringify(i),p,t]);async function on(E){A(E),I(!0);try{const k=await fetch(`${t}/conversations/${E}/messages`,{headers:{Authorization:`Bearer ${x.current}`}});if(!k.ok)throw new Error(`Failed to fetch messages: ${k.statusText}`);const ot=(await k.json()).messages||[];Rt(ot)}catch(k){console.error("Failed to load conversation messages:",k)}finally{I(!1)}}async function rn(E){if(p)try{await fetch(`${t}/conversations/${E}`,{method:"DELETE",headers:{Authorization:`Bearer ${p}`}}),V(P.filter(k=>k._id!==E)),E===D&&Xt()}catch(k){console.error("Failed to delete conversation:",k)}}function Xt(){const E=crypto.randomUUID();A(E),Rt([]),vt(new Set)}function Yt(E){Pt(E)}return{id:D,messages:R,status:K,error:wt,sendMessage:st,stop:je,addToolOutput:Yt,setMessages:Rt,conversations:P,loadConversation:on,deleteConversation:rn,startNewConversation:Xt,isLoadingConversations:B,clientToken:p,tokenError:b}}exports.verifyToken=Va.verifyToken;exports.ArctenAgent=Lh;exports.useAgent=Oh;