@arcteninc/core 0.0.13 → 0.0.14
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/components/ArctenAgent.d.ts.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +1987 -1984
- package/dist/lib/useAgent.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ya=Object.create;var _s=Object.defineProperty;var xa=Object.getOwnPropertyDescriptor;var va=Object.getOwnPropertyNames;var ba=Object.getPrototypeOf,wa=Object.prototype.hasOwnProperty;var Ta=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of va(e))!wa.call(t,i)&&i!==n&&_s(t,i,{get:()=>e[i],enumerable:!(s=xa(e,i))||s.enumerable});return t};var Sa=(t,e,n)=>(n=t!=null?ya(ba(t)):{},Ta(e||!t||!t.__esModule?_s(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"),lo=require("@ai-sdk/react"),He=require("ai"),co=require("@radix-ui/react-slot"),uo=require("class-variance-authority"),Ca=require("clsx"),Pa=require("tailwind-merge"),Aa=require("@radix-ui/react-tooltip"),Mt=require("zod"),Ks=require("@radix-ui/react-use-controllable-state"),Ma=require("@radix-ui/react-collapsible"),ja=require("./server.cjs");function Gn(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 xt=Gn(m),te=Gn(Aa),qn=Gn(Ma);function mt(...t){return Pa.twMerge(Ca.clsx(t))}const Da=uo.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"}});function yt({className:t,variant:e,size:n,asChild:s=!1,...i}){const r=s?co.Slot:"button";return h.jsx(r,{"data-slot":"button",className:mt(Da({variant:e,size:n,className:t})),...i})}const Va=uo.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 un({className:t,variant:e,asChild:n=!1,...s}){const i=n?co.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:mt(Va({variant:e}),t),...s})}const Ea=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=xt.useState(!0);xt.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])},ho=xt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...r},o)=>{const a=xt.useRef(null),[l,c]=xt.useState("");return Ea({textAreaRef:a,triggerAutoSize:l,maxHeight:t,minHeight:e}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),xt.useEffect(()=>{c(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,value:i,ref:a,className:mt("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:u=>{c(u.target.value),s?.(u)}})});ho.displayName="AutosizeTextarea";function ka({delayDuration:t=0,...e}){return h.jsx(te.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Ot({...t}){return h.jsx(ka,{children:h.jsx(te.Root,{"data-slot":"tooltip",...t})})}function Ft({...t}){return h.jsx(te.Trigger,{"data-slot":"tooltip-trigger",...t})}function Bt({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(te.Portal,{children:h.jsxs(te.Content,{"data-slot":"tooltip-content",sideOffset:e,className:mt("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(te.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Hs({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:mt("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 Zn=m.createContext({});function Jn(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const Qn=typeof window<"u",fo=Qn?m.useLayoutEffect:m.useEffect,Je=m.createContext(null);function ts(t,e){t.indexOf(e)===-1&&t.push(e)}function es(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const bt=(t,e,n)=>n>e?e:n<t?t:n;function An(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let ie=()=>{},wt=()=>{};process.env.NODE_ENV!=="production"&&(ie=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(An(e,n))},wt=(t,e,n)=>{if(!t)throw new Error(An(e,n))});const Tt={},mo=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function po(t){return typeof t=="object"&&t!==null}const go=t=>/^0[^.\s]+$/u.test(t);function ns(t){let e;return()=>(e===void 0&&(e=t()),e)}const lt=t=>t,Ra=(t,e)=>n=>e(t(n)),Pe=(...t)=>t.reduce(Ra),ve=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class ss{constructor(){this.subscriptions=[]}add(e){return ts(this.subscriptions,e),()=>es(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,at=t=>t/1e3;function yo(t,e){return e?t*(1e3/e):0}const Xs=new Set;function is(t,e,n){t||Xs.has(e)||(console.warn(An(e,n)),Xs.add(e))}const xo=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Na=1e-7,Ia=12;function La(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=xo(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>Na&&++a<Ia);return o}function Ae(t,e,n,s){if(t===e&&n===s)return lt;const i=r=>La(r,0,1,t,n);return r=>r===0||r===1?r:xo(i(r),e,s)}const vo=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,bo=t=>e=>1-t(1-e),wo=Ae(.33,1.53,.69,.99),os=bo(wo),To=vo(os),So=t=>(t*=2)<1?.5*os(t):.5*(2-Math.pow(2,-10*(t-1))),rs=t=>1-Math.sin(Math.acos(t)),Co=bo(rs),Po=vo(rs),Oa=Ae(.42,0,1,1),Fa=Ae(0,0,.58,1),Ao=Ae(.42,0,.58,1),Ba=t=>Array.isArray(t)&&typeof t[0]!="number",Mo=t=>Array.isArray(t)&&typeof t[0]=="number",Ys={linear:lt,easeIn:Oa,easeInOut:Ao,easeOut:Fa,circIn:rs,circInOut:Po,circOut:Co,backIn:os,backInOut:To,backOut:wo,anticipate:So},$a=t=>typeof t=="string",Gs=t=>{if(Mo(t)){wt(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return Ae(e,n,s,i)}else if($a(t))return wt(Ys[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Ys[t];return t},Le=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function za(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(u){o.has(u)&&(c.schedule(u),t()),u(a)}const c={schedule:(u,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(u),y.has(u)||y.add(u),u},cancel:u=>{s.delete(u),o.delete(u)},process:u=>{if(a=u,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,c.process(u))}};return c}const Ua=40;function jo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Le.reduce((b,j)=>(b[j]=za(r),b),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:d,preRender:f,render:g,postRender:y}=o,v=()=>{const b=Tt.useManualTiming?i.timestamp:performance.now();n=!1,Tt.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(b-i.timestamp,Ua),1)),i.timestamp=b,i.isProcessing=!0,a.process(i),l.process(i),c.process(i),u.process(i),d.process(i),f.process(i),g.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},w=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:Le.reduce((b,j)=>{const P=o[j];return b[j]=(V,D=!1,A=!1)=>(n||w(),P.schedule(V,D,A)),b},{}),cancel:b=>{for(let j=0;j<Le.length;j++)o[Le[j]].cancel(b)},state:i,steps:o}}const{schedule:$,cancel:Dt,state:q,steps:dn}=jo(typeof requestAnimationFrame<"u"?requestAnimationFrame:lt,!0);let ze;function Wa(){ze=void 0}const st={now:()=>(ze===void 0&&st.set(q.isProcessing||Tt.useManualTiming?q.timestamp:performance.now()),ze),set:t=>{ze=t,queueMicrotask(Wa)}},Do=t=>e=>typeof e=="string"&&e.startsWith(t),as=Do("--"),_a=Do("var(--"),ls=t=>_a(t)?Ka.test(t.split("/*")[0].trim()):!1,Ka=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,oe={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},be={...oe,transform:t=>bt(0,1,t)},Oe={...oe,default:1},pe=t=>Math.round(t*1e5)/1e5,cs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ha(t){return t==null}const Xa=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,us=(t,e)=>n=>!!(typeof n=="string"&&Xa.test(n)&&n.startsWith(t)||e&&!Ha(n)&&Object.prototype.hasOwnProperty.call(n,e)),Vo=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(cs);return{[t]:parseFloat(i),[e]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Ya=t=>bt(0,255,t),hn={...oe,transform:t=>Math.round(Ya(t))},Ut={test:us("rgb","red"),parse:Vo("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+hn.transform(t)+", "+hn.transform(e)+", "+hn.transform(n)+", "+pe(be.transform(s))+")"};function Ga(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 Mn={test:us("#"),parse:Ga,transform:Ut.transform},Me=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),jt=Me("deg"),vt=Me("%"),M=Me("px"),qa=Me("vh"),Za=Me("vw"),qs={...vt,parse:t=>vt.parse(t)/100,transform:t=>vt.transform(t*100)},Yt={test:us("hsl","hue"),parse:Vo("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+vt.transform(pe(e))+", "+vt.transform(pe(n))+", "+pe(be.transform(s))+")"},X={test:t=>Ut.test(t)||Mn.test(t)||Yt.test(t),parse:t=>Ut.test(t)?Ut.parse(t):Yt.test(t)?Yt.parse(t):Mn.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Ut.transform(t):Yt.transform(t),getAnimatableNone:t=>{const e=X.parse(t);return e.alpha=0,X.transform(e)}},Ja=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Qa(t){return isNaN(t)&&typeof t=="string"&&(t.match(cs)?.length||0)+(t.match(Ja)?.length||0)>0}const Eo="number",ko="color",tl="var",el="var(",Zs="${}",nl=/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 we(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(nl,l=>(X.test(l)?(s.color.push(r),i.push(ko),n.push(X.parse(l))):l.startsWith(el)?(s.var.push(r),i.push(tl),n.push(l)):(s.number.push(r),i.push(Eo),n.push(parseFloat(l))),++r,Zs)).split(Zs);return{values:n,split:a,indexes:s,types:i}}function Ro(t){return we(t).values}function No(t){const{split:e,types:n}=we(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===Eo?r+=pe(i[o]):a===ko?r+=X.transform(i[o]):r+=i[o]}return r}}const sl=t=>typeof t=="number"?0:X.test(t)?X.getAnimatableNone(t):t;function il(t){const e=Ro(t);return No(t)(e.map(sl))}const Vt={test:Qa,parse:Ro,createTransformer:No,getAnimatableNone:il};function fn(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 ol({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=fn(l,a,t+1/3),r=fn(l,a,t),o=fn(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Xe(t,e){return n=>n>0?e:t}const U=(t,e,n)=>t+(e-t)*n,mn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},rl=[Mn,Ut,Yt],al=t=>rl.find(e=>e.test(t));function Js(t){const e=al(t);if(ie(!!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===Yt&&(n=ol(n)),n}const Qs=(t,e)=>{const n=Js(t),s=Js(e);if(!n||!s)return Xe(t,e);const i={...n};return r=>(i.red=mn(n.red,s.red,r),i.green=mn(n.green,s.green,r),i.blue=mn(n.blue,s.blue,r),i.alpha=U(n.alpha,s.alpha,r),Ut.transform(i))},jn=new Set(["none","hidden"]);function ll(t,e){return jn.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function cl(t,e){return n=>U(t,e,n)}function ds(t){return typeof t=="number"?cl:typeof t=="string"?ls(t)?Xe:X.test(t)?Qs:hl:Array.isArray(t)?Io:typeof t=="object"?X.test(t)?Qs:ul:Xe}function Io(t,e){const n=[...t],s=n.length,i=t.map((r,o)=>ds(r)(r,e[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function ul(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=ds(t[i])(t[i],e[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function dl(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 hl=(t,e)=>{const n=Vt.createTransformer(e),s=we(t),i=we(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?jn.has(t)&&!i.values.length||jn.has(e)&&!s.values.length?ll(t,e):Pe(Io(dl(s,i),i.values),n):(ie(!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"),Xe(t,e))};function Lo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?U(t,e,n):ds(t)(t,e)}const fl=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>$.update(e,n),stop:()=>Dt(e),now:()=>q.isProcessing?q.timestamp:st.now()}},Oo=(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)})`},Ye=2e4;function hs(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Ye;)e+=n,s=t.next(e);return e>=Ye?1/0:e}function ml(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(hs(s),Ye);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:at(i)}}const pl=5;function Fo(t,e,n){const s=Math.max(e-pl,0);return yo(n-t(s),e-s)}const z={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},pn=.001;function gl({duration:t=z.duration,bounce:e=z.bounce,velocity:n=z.velocity,mass:s=z.mass}){let i,r;ie(t<=ft(z.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=bt(z.minDamping,z.maxDamping,o),t=bt(z.minDuration,z.maxDuration,at(t)),o<1?(i=c=>{const u=c*o,d=u*t,f=u-n,g=Dn(c,o),y=Math.exp(-d);return pn-f/g*y},r=c=>{const d=c*o*t,f=d*n+n,g=Math.pow(o,2)*Math.pow(c,2)*t,y=Math.exp(-d),v=Dn(Math.pow(c,2),o);return(-i(c)+pn>0?-1:1)*((f-g)*y)/v}):(i=c=>{const u=Math.exp(-c*t),d=(c-n)*t+1;return-pn+u*d},r=c=>{const u=Math.exp(-c*t),d=(n-c)*(t*t);return u*d});const a=5/t,l=xl(i,r,a);if(t=ft(t),isNaN(l))return{stiffness:z.stiffness,damping:z.damping,duration:t};{const c=Math.pow(l,2)*s;return{stiffness:c,damping:o*2*Math.sqrt(s*c),duration:t}}}const yl=12;function xl(t,e,n){let s=n;for(let i=1;i<yl;i++)s=s-t(s)/e(s);return s}function Dn(t,e){return t*Math.sqrt(1-e*e)}const vl=["duration","bounce"],bl=["stiffness","damping","mass"];function ti(t,e){return e.some(n=>t[n]!==void 0)}function wl(t){let e={velocity:z.velocity,stiffness:z.stiffness,damping:z.damping,mass:z.mass,isResolvedFromDuration:!1,...t};if(!ti(t,bl)&&ti(t,vl))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*bt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:z.mass,stiffness:i,damping:r}}else{const n=gl(t);e={...e,...n,mass:z.mass},e.isResolvedFromDuration=!0}return e}function Ge(t=z.visualDuration,e=z.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:c,mass:u,duration:d,velocity:f,isResolvedFromDuration:g}=wl({...n,velocity:-at(n.velocity||0)}),y=f||0,v=c/(2*Math.sqrt(l*u)),w=o-r,x=at(Math.sqrt(l/u)),T=Math.abs(w)<5;s||(s=T?z.restSpeed.granular:z.restSpeed.default),i||(i=T?z.restDelta.granular:z.restDelta.default);let b;if(v<1){const P=Dn(x,v);b=V=>{const D=Math.exp(-v*x*V);return o-D*((y+v*x*w)/P*Math.sin(P*V)+w*Math.cos(P*V))}}else if(v===1)b=P=>o-Math.exp(-x*P)*(w+(y+x*w)*P);else{const P=x*Math.sqrt(v*v-1);b=V=>{const D=Math.exp(-v*x*V),A=Math.min(P*V,300);return o-D*((y+v*x*w)*Math.sinh(A)+P*w*Math.cosh(A))/P}}const j={calculatedDuration:g&&d||null,next:P=>{const V=b(P);if(g)a.done=P>=d;else{let D=P===0?y:0;v<1&&(D=P===0?ft(y):Fo(b,P,V));const A=Math.abs(D)<=s,I=Math.abs(o-V)<=i;a.done=A&&I}return a.value=a.done?o:V,a},toString:()=>{const P=Math.min(hs(j),Ye),V=Oo(D=>j.next(P*D).value,P,30);return P+"ms "+V},toTransition:()=>{}};return j}Ge.applyToOptions=t=>{const e=ml(t,100,Ge);return t.ease=e.ease,t.duration=ft(e.duration),t.type="keyframes",t};function Vn({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:c=.5,restSpeed:u}){const d=t[0],f={done:!1,value:d},g=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 v=n*e;const w=d+v,x=o===void 0?w:o(w);x!==w&&(v=x-d);const T=A=>-v*Math.exp(-A/s),b=A=>x+T(A),j=A=>{const I=T(A),L=b(A);f.done=Math.abs(I)<=c,f.value=f.done?x:L};let P,V;const D=A=>{g(f.value)&&(P=A,V=Ge({keyframes:[f.value,y(f.value)],velocity:Fo(b,A,f.value),damping:i,stiffness:r,restDelta:c,restSpeed:u}))};return D(0),{calculatedDuration:null,next:A=>{let I=!1;return!V&&P===void 0&&(I=!0,j(A),D(A)),P!==void 0&&A>=P?V.next(A-P):(!I&&j(A),f)}}}function Tl(t,e,n){const s=[],i=n||Tt.mix||Lo,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]||lt:e;a=Pe(l,a)}s.push(a)}return s}function Sl(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(wt(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=Tl(e,s,i),l=a.length,c=u=>{if(o&&u<t[0])return e[0];let d=0;if(l>1)for(;d<t.length-2&&!(u<t[d+1]);d++);const f=ve(t[d],t[d+1],u);return a[d](f)};return n?u=>c(bt(t[0],t[r-1],u)):c}function Cl(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=ve(0,e,s);t.push(U(n,1,i))}}function Pl(t){const e=[0];return Cl(e,t.length-1),e}function Al(t,e){return t.map(n=>n*e)}function Ml(t,e){return t.map(()=>e||Ao).splice(0,t.length-1)}function Gt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=Ba(s)?s.map(Gs):Gs(s),r={done:!1,value:e[0]},o=Al(n&&n.length===e.length?n:Pl(e),t),a=Sl(o,e,{ease:Array.isArray(i)?i:Ml(e,i)});return{calculatedDuration:t,next:l=>(r.value=a(l),r.done=l>=t,r)}}const jl=t=>t!==null;function fs(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(jl),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Dl={decay:Vn,inertia:Vn,tween:Gt,keyframes:Gt,spring:Ge};function Bo(t){typeof t.type=="string"&&(t.type=Dl[t.type])}class ms{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const Vl=t=>t/100;class ps extends ms{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!==st.now()&&this.tick(st.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;Bo(e);const{type:n=Gt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const l=n||Gt;process.env.NODE_ENV!=="production"&&l!==Gt&&wt(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Gt&&typeof a[0]!="number"&&(this.mixKeyframes=Pe(Vl,Lo(a[0],a[1])),a=[0,100]);const c=l({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-o})),c.calculatedDuration===null&&(c.calculatedDuration=hs(c));const{calculatedDuration:u}=c;this.calculatedDuration=u,this.resolvedDuration=u+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=c}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:c=0,keyframes:u,repeat:d,repeatType:f,repeatDelay:g,type:y,onUpdate:v,finalKeyframe:w}=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 x=this.currentTime-c*(this.playbackSpeed>=0?1:-1),T=this.playbackSpeed>=0?x<0:x>i;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let b=this.currentTime,j=s;if(d){const A=Math.min(this.currentTime,i)/a;let I=Math.floor(A),L=A%1;!L&&A>=1&&(L=1),L===1&&I--,I=Math.min(I,d+1),!!(I%2)&&(f==="reverse"?(L=1-L,g&&(L-=g/a)):f==="mirror"&&(j=o)),b=bt(0,1,L)*a}const P=T?{done:!1,value:u[0]}:j.next(b);r&&(P.value=r(P.value));let{done:V}=P;!T&&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!==Vn&&(P.value=fs(u,this.options,w,this.speed)),v&&v(P.value),D&&this.finish(),P}then(e,n){return this.finished.then(e,n)}get duration(){return at(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+at(e)}get time(){return at(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(st.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=at(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=fl,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(st.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 El(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Wt=t=>t*180/Math.PI,En=t=>{const e=Wt(Math.atan2(t[1],t[0]));return kn(e)},kl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:En,rotateZ:En,skewX:t=>Wt(Math.atan(t[1])),skewY:t=>Wt(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},kn=t=>(t=t%360,t<0&&(t+=360),t),ei=En,ni=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),si=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Rl={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ni,scaleY:si,scale:t=>(ni(t)+si(t))/2,rotateX:t=>kn(Wt(Math.atan2(t[6],t[5]))),rotateY:t=>kn(Wt(Math.atan2(-t[2],t[0]))),rotateZ:ei,rotate:ei,skewX:t=>Wt(Math.atan(t[4])),skewY:t=>Wt(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Rn(t){return t.includes("scale")?1:0}function Nn(t,e){if(!t||t==="none")return Rn(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Rl,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=kl,i=a}if(!i)return Rn(e);const r=s[e],o=i[1].split(",").map(Il);return typeof r=="function"?r(o):o[r]}const Nl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return Nn(n,e)};function Il(t){return parseFloat(t.trim())}const re=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ae=new Set(re),ii=t=>t===oe||t===M,Ll=new Set(["x","y","z"]),Ol=re.filter(t=>!Ll.has(t));function Fl(t){const e=[];return Ol.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const _t={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})=>Nn(e,"x"),y:(t,{transform:e})=>Nn(e,"y")};_t.translateX=_t.x;_t.translateY=_t.y;const Kt=new Set;let In=!1,Ln=!1,On=!1;function $o(){if(Ln){const t=Array.from(Kt).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Fl(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)})}Ln=!1,In=!1,Kt.forEach(t=>t.complete(On)),Kt.clear()}function zo(){Kt.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Ln=!0)})}function Bl(){On=!0,zo(),$o(),On=!1}class gs{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?(Kt.add(this),In||(In=!0,$.read(zo),$.resolveKeyframes($o))):(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])}El(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Kt.delete(this)}cancel(){this.state==="scheduled"&&(Kt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const $l=t=>t.startsWith("--");function zl(t,e,n){$l(e)?t.style.setProperty(e,n):t.style[e]=n}const Ul=ns(()=>window.ScrollTimeline!==void 0),Wl={};function _l(t,e){const n=ns(t);return()=>Wl[e]??n()}const Uo=_l(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),me=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,oi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:me([0,.65,.55,1]),circOut:me([.55,0,1,.45]),backIn:me([.31,.01,.66,-.59]),backOut:me([.33,1.53,.69,.99])};function Wo(t,e){if(t)return typeof t=="function"?Uo()?Oo(t,e):"ease-out":Mo(t)?me(t):Array.isArray(t)?t.map(n=>Wo(n,e)||oi.easeOut):oi[t]}function Kl(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},c=void 0){const u={[e]:n};l&&(u.offset=l);const d=Wo(a,i);Array.isArray(d)&&(u.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 c&&(f.pseudoElement=c),t.animate(u,f)}function _o(t){return typeof t=="function"&&"applyToOptions"in t}function Hl({type:t,...e}){return _o(t)&&Uo()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Xl extends ms{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,wt(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const c=Hl(e);this.animation=Kl(n,s,i,c,r),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const u=fs(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(u):zl(n,s,u),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 at(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+at(e)}get time(){return at(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&&Ul()?(this.animation.timeline=e,lt):n(this)}}const Ko={anticipate:So,backInOut:To,circInOut:Po};function Yl(t){return t in Ko}function Gl(t){typeof t.ease=="string"&&Yl(t.ease)&&(t.ease=Ko[t.ease])}const ri=10;class ql extends Xl{constructor(e){Gl(e),Bo(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 ps({...o,autoplay:!1}),l=ft(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-ri).value,a.sample(l).value,ri),a.stop()}}const ai=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Vt.test(t)||t==="0")&&!t.startsWith("url("));function Zl(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 Jl(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=ai(i,e),a=ai(r,e);return ie(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:Zl(t)||(n==="spring"||_o(n))&&s}function Fn(t){t.duration=0,t.type="keyframes"}const Ql=new Set(["opacity","clipPath","filter","transform"]),tc=ns(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function ec(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:c}=e.owner.getProps();return tc()&&n&&Ql.has(n)&&(n!=="transform"||!c)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const nc=40;class sc extends ms{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:c,element:u,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=st.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:l,motionValue:c,element:u,...d},g=u?.KeyframeResolver||gs;this.keyframeResolver=new g(a,(y,v,w)=>this.onKeyframesResolved(y,v,f,!w),l,c,u),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:c,onUpdate:u}=s;this.resolvedAt=st.now(),Jl(e,r,o,a)||((Tt.instantAnimations||!l)&&u?.(fs(e,s,n)),e[0]=e[e.length-1],Fn(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>nc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!c&&ec(f)?new ql({...f,element:f.motionValue.owner.current}):new ps(f);g.finished.then(()=>this.notifyFinished()).catch(lt),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Bl()),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 ic=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function oc(t){const e=ic.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const rc=4;function Ho(t,e,n=1){wt(n<=rc,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=oc(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const o=r.trim();return mo(o)?parseFloat(o):o}return ls(i)?Ho(i,e,n+1):i}function ys(t,e){return t?.[e]??t?.default??t}const Xo=new Set(["width","height","top","left","right","bottom",...re]),ac={test:t=>t==="auto",parse:t=>t},Yo=t=>e=>e.test(t),Go=[oe,M,vt,jt,Za,qa,ac],li=t=>Go.find(Yo(t));function lc(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||go(t):!0}const cc=new Set(["brightness","contrast","saturate","opacity"]);function uc(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(cs)||[];if(!s)return t;const i=n.replace(s,"");let r=cc.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const dc=/\b([a-z-]*)\(.*?\)/gu,Bn={...Vt,getAnimatableNone:t=>{const e=t.match(dc);return e?e.map(uc).join(" "):t}},ci={...oe,transform:Math.round},hc={rotate:jt,rotateX:jt,rotateY:jt,rotateZ:jt,scale:Oe,scaleX:Oe,scaleY:Oe,scaleZ:Oe,skew:jt,skewX:jt,skewY:jt,distance:M,translateX:M,translateY:M,translateZ:M,x:M,y:M,z:M,perspective:M,transformPerspective:M,opacity:be,originX:qs,originY:qs,originZ:M},xs={borderWidth:M,borderTopWidth:M,borderRightWidth:M,borderBottomWidth:M,borderLeftWidth:M,borderRadius:M,radius:M,borderTopLeftRadius:M,borderTopRightRadius:M,borderBottomRightRadius:M,borderBottomLeftRadius:M,width:M,maxWidth:M,height:M,maxHeight:M,top:M,right:M,bottom:M,left:M,padding:M,paddingTop:M,paddingRight:M,paddingBottom:M,paddingLeft:M,margin:M,marginTop:M,marginRight:M,marginBottom:M,marginLeft:M,backgroundPositionX:M,backgroundPositionY:M,...hc,zIndex:ci,fillOpacity:be,strokeOpacity:be,numOctaves:ci},fc={...xs,color:X,backgroundColor:X,outlineColor:X,fill:X,stroke:X,borderColor:X,borderTopColor:X,borderRightColor:X,borderBottomColor:X,borderLeftColor:X,filter:Bn,WebkitFilter:Bn},qo=t=>fc[t];function Zo(t,e){let n=qo(t);return n!==Bn&&(n=Vt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const mc=new Set(["auto","none","0"]);function pc(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!mc.has(r)&&we(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=Zo(n,i)}class gc extends gs{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 c=e[l];if(typeof c=="string"&&(c=c.trim(),ls(c))){const u=Ho(c,n.current);u!==void 0&&(e[l]=u),l===e.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!Xo.has(s)||e.length!==2)return;const[i,r]=e,o=li(i),a=li(r);if(o!==a)if(ii(o)&&ii(a))for(let l=0;l<e.length;l++){const c=e[l];typeof c=="string"&&(e[l]=parseFloat(c))}else _t[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||lc(e[i]))&&s.push(i);s.length&&pc(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=_t[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]=_t[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 yc(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 Jo=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Qo(t){return po(t)&&"offsetHeight"in t}const ui=30,xc=t=>!isNaN(parseFloat(t));class vc{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=st.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=st.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=xc(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&is(!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 ss);const s=this.events[e].add(n);return e==="change"?()=>{s(),$.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=st.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>ui)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,ui);return yo(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 ne(t,e){return new vc(t,e)}const{schedule:vs}=jo(queueMicrotask,!1),ht={x:!1,y:!1};function tr(){return ht.x||ht.y}function bc(t){return t==="x"||t==="y"?ht[t]?null:(ht[t]=!0,()=>{ht[t]=!1}):ht.x||ht.y?null:(ht.x=ht.y=!0,()=>{ht.x=ht.y=!1})}function er(t,e){const n=yc(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function di(t){return!(t.pointerType==="touch"||tr())}function wc(t,e,n={}){const[s,i,r]=er(t,n),o=a=>{if(!di(a))return;const{target:l}=a,c=e(l,a);if(typeof c!="function"||!l)return;const u=d=>{di(d)&&(c(d),l.removeEventListener("pointerleave",u))};l.addEventListener("pointerleave",u,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const nr=(t,e)=>e?t===e?!0:nr(t,e.parentElement):!1,bs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Tc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Sc(t){return Tc.has(t.tagName)||t.tabIndex!==-1}const Ue=new WeakSet;function hi(t){return e=>{e.key==="Enter"&&t(e)}}function gn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Cc=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=hi(()=>{if(Ue.has(n))return;gn(n,"down");const i=hi(()=>{gn(n,"up")}),r=()=>gn(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 fi(t){return bs(t)&&!tr()}function Pc(t,e,n={}){const[s,i,r]=er(t,n),o=a=>{const l=a.currentTarget;if(!fi(a))return;Ue.add(l);const c=e(l,a),u=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),Ue.has(l)&&Ue.delete(l),fi(g)&&typeof c=="function"&&c(g,{success:y})},d=g=>{u(g,l===window||l===document||n.useGlobalTarget||nr(l,g.target))},f=g=>{u(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),Qo(a)&&(a.addEventListener("focus",c=>Cc(c,i)),!Sc(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function sr(t){return po(t)&&"ownerSVGElement"in t}function Ac(t){return sr(t)&&t.tagName==="svg"}const J=t=>!!(t&&t.getVelocity),Mc=[...Go,X,Vt],jc=t=>Mc.find(Yo(t)),ws=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function mi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Dc(...t){return e=>{let n=!1;const s=t.map(i=>{const r=mi(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():mi(t[i],null)}}}}function Vc(...t){return xt.useCallback(Dc(...t),t)}class Ec extends xt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=Qo(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 kc({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(ws),l=Vc(r,t?.ref);return m.useInsertionEffect(()=>{const{width:c,height:u,top:d,left:f,right:g}=o.current;if(e||!r.current||!c||!u)return;const y=n==="left"?`left: ${f}`:`right: ${g}`;r.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const w=s??document.head;return w.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
1
|
+
"use strict";var xa=Object.create;var Ks=Object.defineProperty;var va=Object.getOwnPropertyDescriptor;var ba=Object.getOwnPropertyNames;var wa=Object.getPrototypeOf,Ta=Object.prototype.hasOwnProperty;var Sa=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ba(e))!Ta.call(t,i)&&i!==n&&Ks(t,i,{get:()=>e[i],enumerable:!(s=va(e,i))||s.enumerable});return t};var Ca=(t,e,n)=>(n=t!=null?xa(wa(t)):{},Sa(e||!t||!t.__esModule?Ks(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),Y=require("lucide-react"),co=require("@ai-sdk/react"),Xe=require("ai"),uo=require("@radix-ui/react-slot"),ho=require("class-variance-authority"),Pa=require("clsx"),Aa=require("tailwind-merge"),Ma=require("@radix-ui/react-tooltip"),Dt=require("zod"),Hs=require("@radix-ui/react-use-controllable-state"),Da=require("@radix-ui/react-collapsible"),ja=require("./server.cjs");function qn(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 vt=qn(m),ee=qn(Ma),Zn=qn(Da);function pt(...t){return Aa.twMerge(Pa.clsx(t))}const Va=ho.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"}});function xt({className:t,variant:e,size:n,asChild:s=!1,...i}){const r=s?uo.Slot:"button";return h.jsx(r,{"data-slot":"button",className:pt(Va({variant:e,size:n,className:t})),...i})}const Ea=ho.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 dn({className:t,variant:e,asChild:n=!1,...s}){const i=n?uo.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:pt(Ea({variant:e}),t),...s})}const ka=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=vt.useState(!0);vt.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])},fo=vt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...r},o)=>{const a=vt.useRef(null),[l,c]=vt.useState("");return ka({textAreaRef:a,triggerAutoSize:l,maxHeight:t,minHeight:e}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),vt.useEffect(()=>{c(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,value:i,ref:a,className:pt("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:u=>{c(u.target.value),s?.(u)}})});fo.displayName="AutosizeTextarea";function Ra({delayDuration:t=0,...e}){return h.jsx(ee.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Ft({...t}){return h.jsx(Ra,{children:h.jsx(ee.Root,{"data-slot":"tooltip",...t})})}function Bt({...t}){return h.jsx(ee.Trigger,{"data-slot":"tooltip-trigger",...t})}function $t({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(ee.Portal,{children:h.jsxs(ee.Content,{"data-slot":"tooltip-content",sideOffset:e,className:pt("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(ee.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Xs({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:pt("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 Jn=m.createContext({});function Qn(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const ts=typeof window<"u",mo=ts?m.useLayoutEffect:m.useEffect,Qe=m.createContext(null);function es(t,e){t.indexOf(e)===-1&&t.push(e)}function ns(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const wt=(t,e,n)=>n>e?e:n<t?t:n;function Mn(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let oe=()=>{},Tt=()=>{};process.env.NODE_ENV!=="production"&&(oe=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(Mn(e,n))},Tt=(t,e,n)=>{if(!t)throw new Error(Mn(e,n))});const St={},po=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function go(t){return typeof t=="object"&&t!==null}const yo=t=>/^0[^.\s]+$/u.test(t);function ss(t){let e;return()=>(e===void 0&&(e=t()),e)}const ct=t=>t,Na=(t,e)=>n=>e(t(n)),Ae=(...t)=>t.reduce(Na),be=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class is{constructor(){this.subscriptions=[]}add(e){return es(this.subscriptions,e),()=>ns(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 mt=t=>t*1e3,lt=t=>t/1e3;function xo(t,e){return e?t*(1e3/e):0}const Gs=new Set;function os(t,e,n){t||Gs.has(e)||(console.warn(Mn(e,n)),Gs.add(e))}const vo=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Ia=1e-7,La=12;function Oa(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=vo(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>Ia&&++a<La);return o}function Me(t,e,n,s){if(t===e&&n===s)return ct;const i=r=>Oa(r,0,1,t,n);return r=>r===0||r===1?r:vo(i(r),e,s)}const bo=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,wo=t=>e=>1-t(1-e),To=Me(.33,1.53,.69,.99),rs=wo(To),So=bo(rs),Co=t=>(t*=2)<1?.5*rs(t):.5*(2-Math.pow(2,-10*(t-1))),as=t=>1-Math.sin(Math.acos(t)),Po=wo(as),Ao=bo(as),Fa=Me(.42,0,1,1),Ba=Me(0,0,.58,1),Mo=Me(.42,0,.58,1),$a=t=>Array.isArray(t)&&typeof t[0]!="number",Do=t=>Array.isArray(t)&&typeof t[0]=="number",Ys={linear:ct,easeIn:Fa,easeInOut:Mo,easeOut:Ba,circIn:as,circInOut:Ao,circOut:Po,backIn:rs,backInOut:So,backOut:To,anticipate:Co},za=t=>typeof t=="string",qs=t=>{if(Do(t)){Tt(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return Me(e,n,s,i)}else if(za(t))return Tt(Ys[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Ys[t];return t},Oe=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Ua(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(u){o.has(u)&&(c.schedule(u),t()),u(a)}const c={schedule:(u,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(u),y.has(u)||y.add(u),u},cancel:u=>{s.delete(u),o.delete(u)},process:u=>{if(a=u,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,c.process(u))}};return c}const _a=40;function jo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Oe.reduce((b,D)=>(b[D]=Ua(r),b),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:d,preRender:f,render:g,postRender:y}=o,v=()=>{const b=St.useManualTiming?i.timestamp:performance.now();n=!1,St.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(b-i.timestamp,_a),1)),i.timestamp=b,i.isProcessing=!0,a.process(i),l.process(i),c.process(i),u.process(i),d.process(i),f.process(i),g.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},w=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:Oe.reduce((b,D)=>{const P=o[D];return b[D]=(V,j=!1,A=!1)=>(n||w(),P.schedule(V,j,A)),b},{}),cancel:b=>{for(let D=0;D<Oe.length;D++)o[Oe[D]].cancel(b)},state:i,steps:o}}const{schedule:$,cancel:Vt,state:q,steps:hn}=jo(typeof requestAnimationFrame<"u"?requestAnimationFrame:ct,!0);let Ue;function Wa(){Ue=void 0}const it={now:()=>(Ue===void 0&&it.set(q.isProcessing||St.useManualTiming?q.timestamp:performance.now()),Ue),set:t=>{Ue=t,queueMicrotask(Wa)}},Vo=t=>e=>typeof e=="string"&&e.startsWith(t),ls=Vo("--"),Ka=Vo("var(--"),cs=t=>Ka(t)?Ha.test(t.split("/*")[0].trim()):!1,Ha=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,re={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},we={...re,transform:t=>wt(0,1,t)},Fe={...re,default:1},ge=t=>Math.round(t*1e5)/1e5,us=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Xa(t){return t==null}const Ga=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ds=(t,e)=>n=>!!(typeof n=="string"&&Ga.test(n)&&n.startsWith(t)||e&&!Xa(n)&&Object.prototype.hasOwnProperty.call(n,e)),Eo=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(us);return{[t]:parseFloat(i),[e]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Ya=t=>wt(0,255,t),fn={...re,transform:t=>Math.round(Ya(t))},_t={test:ds("rgb","red"),parse:Eo("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+fn.transform(t)+", "+fn.transform(e)+", "+fn.transform(n)+", "+ge(we.transform(s))+")"};function qa(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:ds("#"),parse:qa,transform:_t.transform},De=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),jt=De("deg"),bt=De("%"),M=De("px"),Za=De("vh"),Ja=De("vw"),Zs={...bt,parse:t=>bt.parse(t)/100,transform:t=>bt.transform(t*100)},Yt={test:ds("hsl","hue"),parse:Eo("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+bt.transform(ge(e))+", "+bt.transform(ge(n))+", "+ge(we.transform(s))+")"},X={test:t=>_t.test(t)||Dn.test(t)||Yt.test(t),parse:t=>_t.test(t)?_t.parse(t):Yt.test(t)?Yt.parse(t):Dn.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?_t.transform(t):Yt.transform(t),getAnimatableNone:t=>{const e=X.parse(t);return e.alpha=0,X.transform(e)}},Qa=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function tl(t){return isNaN(t)&&typeof t=="string"&&(t.match(us)?.length||0)+(t.match(Qa)?.length||0)>0}const ko="number",Ro="color",el="var",nl="var(",Js="${}",sl=/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 Te(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(sl,l=>(X.test(l)?(s.color.push(r),i.push(Ro),n.push(X.parse(l))):l.startsWith(nl)?(s.var.push(r),i.push(el),n.push(l)):(s.number.push(r),i.push(ko),n.push(parseFloat(l))),++r,Js)).split(Js);return{values:n,split:a,indexes:s,types:i}}function No(t){return Te(t).values}function Io(t){const{split:e,types:n}=Te(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===ko?r+=ge(i[o]):a===Ro?r+=X.transform(i[o]):r+=i[o]}return r}}const il=t=>typeof t=="number"?0:X.test(t)?X.getAnimatableNone(t):t;function ol(t){const e=No(t);return Io(t)(e.map(il))}const Et={test:tl,parse:No,createTransformer:Io,getAnimatableNone:ol};function mn(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 rl({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=mn(l,a,t+1/3),r=mn(l,a,t),o=mn(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Ge(t,e){return n=>n>0?e:t}const U=(t,e,n)=>t+(e-t)*n,pn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},al=[Dn,_t,Yt],ll=t=>al.find(e=>e.test(t));function Qs(t){const e=ll(t);if(oe(!!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===Yt&&(n=rl(n)),n}const ti=(t,e)=>{const n=Qs(t),s=Qs(e);if(!n||!s)return Ge(t,e);const i={...n};return r=>(i.red=pn(n.red,s.red,r),i.green=pn(n.green,s.green,r),i.blue=pn(n.blue,s.blue,r),i.alpha=U(n.alpha,s.alpha,r),_t.transform(i))},jn=new Set(["none","hidden"]);function cl(t,e){return jn.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function ul(t,e){return n=>U(t,e,n)}function hs(t){return typeof t=="number"?ul:typeof t=="string"?cs(t)?Ge:X.test(t)?ti:fl:Array.isArray(t)?Lo:typeof t=="object"?X.test(t)?ti:dl:Ge}function Lo(t,e){const n=[...t],s=n.length,i=t.map((r,o)=>hs(r)(r,e[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function dl(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=hs(t[i])(t[i],e[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function hl(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 fl=(t,e)=>{const n=Et.createTransformer(e),s=Te(t),i=Te(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?jn.has(t)&&!i.values.length||jn.has(e)&&!s.values.length?cl(t,e):Ae(Lo(hl(s,i),i.values),n):(oe(!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"),Ge(t,e))};function Oo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?U(t,e,n):hs(t)(t,e)}const ml=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>$.update(e,n),stop:()=>Vt(e),now:()=>q.isProcessing?q.timestamp:it.now()}},Fo=(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)})`},Ye=2e4;function fs(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Ye;)e+=n,s=t.next(e);return e>=Ye?1/0:e}function pl(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(fs(s),Ye);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:lt(i)}}const gl=5;function Bo(t,e,n){const s=Math.max(e-gl,0);return xo(n-t(s),e-s)}const z={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},gn=.001;function yl({duration:t=z.duration,bounce:e=z.bounce,velocity:n=z.velocity,mass:s=z.mass}){let i,r;oe(t<=mt(z.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=wt(z.minDamping,z.maxDamping,o),t=wt(z.minDuration,z.maxDuration,lt(t)),o<1?(i=c=>{const u=c*o,d=u*t,f=u-n,g=Vn(c,o),y=Math.exp(-d);return gn-f/g*y},r=c=>{const d=c*o*t,f=d*n+n,g=Math.pow(o,2)*Math.pow(c,2)*t,y=Math.exp(-d),v=Vn(Math.pow(c,2),o);return(-i(c)+gn>0?-1:1)*((f-g)*y)/v}):(i=c=>{const u=Math.exp(-c*t),d=(c-n)*t+1;return-gn+u*d},r=c=>{const u=Math.exp(-c*t),d=(n-c)*(t*t);return u*d});const a=5/t,l=vl(i,r,a);if(t=mt(t),isNaN(l))return{stiffness:z.stiffness,damping:z.damping,duration:t};{const c=Math.pow(l,2)*s;return{stiffness:c,damping:o*2*Math.sqrt(s*c),duration:t}}}const xl=12;function vl(t,e,n){let s=n;for(let i=1;i<xl;i++)s=s-t(s)/e(s);return s}function Vn(t,e){return t*Math.sqrt(1-e*e)}const bl=["duration","bounce"],wl=["stiffness","damping","mass"];function ei(t,e){return e.some(n=>t[n]!==void 0)}function Tl(t){let e={velocity:z.velocity,stiffness:z.stiffness,damping:z.damping,mass:z.mass,isResolvedFromDuration:!1,...t};if(!ei(t,wl)&&ei(t,bl))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*wt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:z.mass,stiffness:i,damping:r}}else{const n=yl(t);e={...e,...n,mass:z.mass},e.isResolvedFromDuration=!0}return e}function qe(t=z.visualDuration,e=z.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:c,mass:u,duration:d,velocity:f,isResolvedFromDuration:g}=Tl({...n,velocity:-lt(n.velocity||0)}),y=f||0,v=c/(2*Math.sqrt(l*u)),w=o-r,x=lt(Math.sqrt(l/u)),T=Math.abs(w)<5;s||(s=T?z.restSpeed.granular:z.restSpeed.default),i||(i=T?z.restDelta.granular:z.restDelta.default);let b;if(v<1){const P=Vn(x,v);b=V=>{const j=Math.exp(-v*x*V);return o-j*((y+v*x*w)/P*Math.sin(P*V)+w*Math.cos(P*V))}}else if(v===1)b=P=>o-Math.exp(-x*P)*(w+(y+x*w)*P);else{const P=x*Math.sqrt(v*v-1);b=V=>{const j=Math.exp(-v*x*V),A=Math.min(P*V,300);return o-j*((y+v*x*w)*Math.sinh(A)+P*w*Math.cosh(A))/P}}const D={calculatedDuration:g&&d||null,next:P=>{const V=b(P);if(g)a.done=P>=d;else{let j=P===0?y:0;v<1&&(j=P===0?mt(y):Bo(b,P,V));const A=Math.abs(j)<=s,I=Math.abs(o-V)<=i;a.done=A&&I}return a.value=a.done?o:V,a},toString:()=>{const P=Math.min(fs(D),Ye),V=Fo(j=>D.next(P*j).value,P,30);return P+"ms "+V},toTransition:()=>{}};return D}qe.applyToOptions=t=>{const e=pl(t,100,qe);return t.ease=e.ease,t.duration=mt(e.duration),t.type="keyframes",t};function En({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:c=.5,restSpeed:u}){const d=t[0],f={done:!1,value:d},g=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 v=n*e;const w=d+v,x=o===void 0?w:o(w);x!==w&&(v=x-d);const T=A=>-v*Math.exp(-A/s),b=A=>x+T(A),D=A=>{const I=T(A),L=b(A);f.done=Math.abs(I)<=c,f.value=f.done?x:L};let P,V;const j=A=>{g(f.value)&&(P=A,V=qe({keyframes:[f.value,y(f.value)],velocity:Bo(b,A,f.value),damping:i,stiffness:r,restDelta:c,restSpeed:u}))};return j(0),{calculatedDuration:null,next:A=>{let I=!1;return!V&&P===void 0&&(I=!0,D(A),j(A)),P!==void 0&&A>=P?V.next(A-P):(!I&&D(A),f)}}}function Sl(t,e,n){const s=[],i=n||St.mix||Oo,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=Ae(l,a)}s.push(a)}return s}function Cl(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(Tt(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=Sl(e,s,i),l=a.length,c=u=>{if(o&&u<t[0])return e[0];let d=0;if(l>1)for(;d<t.length-2&&!(u<t[d+1]);d++);const f=be(t[d],t[d+1],u);return a[d](f)};return n?u=>c(wt(t[0],t[r-1],u)):c}function Pl(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=be(0,e,s);t.push(U(n,1,i))}}function Al(t){const e=[0];return Pl(e,t.length-1),e}function Ml(t,e){return t.map(n=>n*e)}function Dl(t,e){return t.map(()=>e||Mo).splice(0,t.length-1)}function qt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=$a(s)?s.map(qs):qs(s),r={done:!1,value:e[0]},o=Ml(n&&n.length===e.length?n:Al(e),t),a=Cl(o,e,{ease:Array.isArray(i)?i:Dl(e,i)});return{calculatedDuration:t,next:l=>(r.value=a(l),r.done=l>=t,r)}}const jl=t=>t!==null;function ms(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(jl),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Vl={decay:En,inertia:En,tween:qt,keyframes:qt,spring:qe};function $o(t){typeof t.type=="string"&&(t.type=Vl[t.type])}class ps{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 El=t=>t/100;class gs extends ps{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;$o(e);const{type:n=qt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const l=n||qt;process.env.NODE_ENV!=="production"&&l!==qt&&Tt(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==qt&&typeof a[0]!="number"&&(this.mixKeyframes=Ae(El,Oo(a[0],a[1])),a=[0,100]);const c=l({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-o})),c.calculatedDuration===null&&(c.calculatedDuration=fs(c));const{calculatedDuration:u}=c;this.calculatedDuration=u,this.resolvedDuration=u+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=c}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:c=0,keyframes:u,repeat:d,repeatType:f,repeatDelay:g,type:y,onUpdate:v,finalKeyframe:w}=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 x=this.currentTime-c*(this.playbackSpeed>=0?1:-1),T=this.playbackSpeed>=0?x<0:x>i;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let b=this.currentTime,D=s;if(d){const A=Math.min(this.currentTime,i)/a;let I=Math.floor(A),L=A%1;!L&&A>=1&&(L=1),L===1&&I--,I=Math.min(I,d+1),!!(I%2)&&(f==="reverse"?(L=1-L,g&&(L-=g/a)):f==="mirror"&&(D=o)),b=wt(0,1,L)*a}const P=T?{done:!1,value:u[0]}:D.next(b);r&&(P.value=r(P.value));let{done:V}=P;!T&&l!==null&&(V=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const j=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&V);return j&&y!==En&&(P.value=ms(u,this.options,w,this.speed)),v&&v(P.value),j&&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=mt(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=ml,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 kl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Wt=t=>t*180/Math.PI,kn=t=>{const e=Wt(Math.atan2(t[1],t[0]));return Rn(e)},Rl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:kn,rotateZ:kn,skewX:t=>Wt(Math.atan(t[1])),skewY:t=>Wt(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Rn=t=>(t=t%360,t<0&&(t+=360),t),ni=kn,si=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),ii=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Nl={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:si,scaleY:ii,scale:t=>(si(t)+ii(t))/2,rotateX:t=>Rn(Wt(Math.atan2(t[6],t[5]))),rotateY:t=>Rn(Wt(Math.atan2(-t[2],t[0]))),rotateZ:ni,rotate:ni,skewX:t=>Wt(Math.atan(t[4])),skewY:t=>Wt(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Nn(t){return t.includes("scale")?1:0}function In(t,e){if(!t||t==="none")return Nn(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Nl,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Rl,i=a}if(!i)return Nn(e);const r=s[e],o=i[1].split(",").map(Ll);return typeof r=="function"?r(o):o[r]}const Il=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return In(n,e)};function Ll(t){return parseFloat(t.trim())}const ae=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],le=new Set(ae),oi=t=>t===re||t===M,Ol=new Set(["x","y","z"]),Fl=ae.filter(t=>!Ol.has(t));function Bl(t){const e=[];return Fl.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})=>In(e,"x"),y:(t,{transform:e})=>In(e,"y")};Kt.translateX=Kt.x;Kt.translateY=Kt.y;const Ht=new Set;let Ln=!1,On=!1,Fn=!1;function zo(){if(On){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=Bl(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)})}On=!1,Ln=!1,Ht.forEach(t=>t.complete(Fn)),Ht.clear()}function Uo(){Ht.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(On=!0)})}function $l(){Fn=!0,Uo(),zo(),Fn=!1}class ys{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),Ln||(Ln=!0,$.read(Uo),$.resolveKeyframes(zo))):(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])}kl(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 zl=t=>t.startsWith("--");function Ul(t,e,n){zl(e)?t.style.setProperty(e,n):t.style[e]=n}const _l=ss(()=>window.ScrollTimeline!==void 0),Wl={};function Kl(t,e){const n=ss(t);return()=>Wl[e]??n()}const _o=Kl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),pe=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,ri={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:pe([0,.65,.55,1]),circOut:pe([.55,0,1,.45]),backIn:pe([.31,.01,.66,-.59]),backOut:pe([.33,1.53,.69,.99])};function Wo(t,e){if(t)return typeof t=="function"?_o()?Fo(t,e):"ease-out":Do(t)?pe(t):Array.isArray(t)?t.map(n=>Wo(n,e)||ri.easeOut):ri[t]}function Hl(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},c=void 0){const u={[e]:n};l&&(u.offset=l);const d=Wo(a,i);Array.isArray(d)&&(u.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 c&&(f.pseudoElement=c),t.animate(u,f)}function Ko(t){return typeof t=="function"&&"applyToOptions"in t}function Xl({type:t,...e}){return Ko(t)&&_o()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Gl extends ps{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,Tt(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const c=Xl(e);this.animation=Hl(n,s,i,c,r),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const u=ms(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(u):Ul(n,s,u),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=mt(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&&_l()?(this.animation.timeline=e,ct):n(this)}}const Ho={anticipate:Co,backInOut:So,circInOut:Ao};function Yl(t){return t in Ho}function ql(t){typeof t.ease=="string"&&Yl(t.ease)&&(t.ease=Ho[t.ease])}const ai=10;class Zl extends Gl{constructor(e){ql(e),$o(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 gs({...o,autoplay:!1}),l=mt(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-ai).value,a.sample(l).value,ai),a.stop()}}const li=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Et.test(t)||t==="0")&&!t.startsWith("url("));function Jl(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 Ql(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=li(i,e),a=li(r,e);return oe(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:Jl(t)||(n==="spring"||Ko(n))&&s}function Bn(t){t.duration=0,t.type="keyframes"}const tc=new Set(["opacity","clipPath","filter","transform"]),ec=ss(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function nc(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:c}=e.owner.getProps();return ec()&&n&&tc.has(n)&&(n!=="transform"||!c)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const sc=40;class ic extends ps{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:c,element:u,...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:c,element:u,...d},g=u?.KeyframeResolver||ys;this.keyframeResolver=new g(a,(y,v,w)=>this.onKeyframesResolved(y,v,f,!w),l,c,u),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:c,onUpdate:u}=s;this.resolvedAt=it.now(),Ql(e,r,o,a)||((St.instantAnimations||!l)&&u?.(ms(e,s,n)),e[0]=e[e.length-1],Bn(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>sc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!c&&nc(f)?new Zl({...f,element:f.motionValue.owner.current}):new gs(f);g.finished.then(()=>this.notifyFinished()).catch(ct),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),$l()),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 oc=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function rc(t){const e=oc.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const ac=4;function Xo(t,e,n=1){Tt(n<=ac,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=rc(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const o=r.trim();return po(o)?parseFloat(o):o}return cs(i)?Xo(i,e,n+1):i}function xs(t,e){return t?.[e]??t?.default??t}const Go=new Set(["width","height","top","left","right","bottom",...ae]),lc={test:t=>t==="auto",parse:t=>t},Yo=t=>e=>e.test(t),qo=[re,M,bt,jt,Ja,Za,lc],ci=t=>qo.find(Yo(t));function cc(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||yo(t):!0}const uc=new Set(["brightness","contrast","saturate","opacity"]);function dc(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(us)||[];if(!s)return t;const i=n.replace(s,"");let r=uc.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const hc=/\b([a-z-]*)\(.*?\)/gu,$n={...Et,getAnimatableNone:t=>{const e=t.match(hc);return e?e.map(dc).join(" "):t}},ui={...re,transform:Math.round},fc={rotate:jt,rotateX:jt,rotateY:jt,rotateZ:jt,scale:Fe,scaleX:Fe,scaleY:Fe,scaleZ:Fe,skew:jt,skewX:jt,skewY:jt,distance:M,translateX:M,translateY:M,translateZ:M,x:M,y:M,z:M,perspective:M,transformPerspective:M,opacity:we,originX:Zs,originY:Zs,originZ:M},vs={borderWidth:M,borderTopWidth:M,borderRightWidth:M,borderBottomWidth:M,borderLeftWidth:M,borderRadius:M,radius:M,borderTopLeftRadius:M,borderTopRightRadius:M,borderBottomRightRadius:M,borderBottomLeftRadius:M,width:M,maxWidth:M,height:M,maxHeight:M,top:M,right:M,bottom:M,left:M,padding:M,paddingTop:M,paddingRight:M,paddingBottom:M,paddingLeft:M,margin:M,marginTop:M,marginRight:M,marginBottom:M,marginLeft:M,backgroundPositionX:M,backgroundPositionY:M,...fc,zIndex:ui,fillOpacity:we,strokeOpacity:we,numOctaves:ui},mc={...vs,color:X,backgroundColor:X,outlineColor:X,fill:X,stroke:X,borderColor:X,borderTopColor:X,borderRightColor:X,borderBottomColor:X,borderLeftColor:X,filter:$n,WebkitFilter:$n},Zo=t=>mc[t];function Jo(t,e){let n=Zo(t);return n!==$n&&(n=Et),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const pc=new Set(["auto","none","0"]);function gc(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!pc.has(r)&&Te(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=Jo(n,i)}class yc extends ys{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 c=e[l];if(typeof c=="string"&&(c=c.trim(),cs(c))){const u=Xo(c,n.current);u!==void 0&&(e[l]=u),l===e.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!Go.has(s)||e.length!==2)return;const[i,r]=e,o=ci(i),a=ci(r);if(o!==a)if(oi(o)&&oi(a))for(let l=0;l<e.length;l++){const c=e[l];typeof c=="string"&&(e[l]=parseFloat(c))}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||cc(e[i]))&&s.push(i);s.length&&gc(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 xc(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 Qo=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function tr(t){return go(t)&&"offsetHeight"in t}const di=30,vc=t=>!isNaN(parseFloat(t));class bc{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=vc(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&os(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new is);const s=this.events[e].add(n);return e==="change"?()=>{s(),$.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>di)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,di);return xo(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 se(t,e){return new bc(t,e)}const{schedule:bs}=jo(queueMicrotask,!1),ft={x:!1,y:!1};function er(){return ft.x||ft.y}function wc(t){return t==="x"||t==="y"?ft[t]?null:(ft[t]=!0,()=>{ft[t]=!1}):ft.x||ft.y?null:(ft.x=ft.y=!0,()=>{ft.x=ft.y=!1})}function nr(t,e){const n=xc(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function hi(t){return!(t.pointerType==="touch"||er())}function Tc(t,e,n={}){const[s,i,r]=nr(t,n),o=a=>{if(!hi(a))return;const{target:l}=a,c=e(l,a);if(typeof c!="function"||!l)return;const u=d=>{hi(d)&&(c(d),l.removeEventListener("pointerleave",u))};l.addEventListener("pointerleave",u,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const sr=(t,e)=>e?t===e?!0:sr(t,e.parentElement):!1,ws=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Sc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Cc(t){return Sc.has(t.tagName)||t.tabIndex!==-1}const _e=new WeakSet;function fi(t){return e=>{e.key==="Enter"&&t(e)}}function yn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Pc=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=fi(()=>{if(_e.has(n))return;yn(n,"down");const i=fi(()=>{yn(n,"up")}),r=()=>yn(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 mi(t){return ws(t)&&!er()}function Ac(t,e,n={}){const[s,i,r]=nr(t,n),o=a=>{const l=a.currentTarget;if(!mi(a))return;_e.add(l);const c=e(l,a),u=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),_e.has(l)&&_e.delete(l),mi(g)&&typeof c=="function"&&c(g,{success:y})},d=g=>{u(g,l===window||l===document||n.useGlobalTarget||sr(l,g.target))},f=g=>{u(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),tr(a)&&(a.addEventListener("focus",c=>Pc(c,i)),!Cc(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function ir(t){return go(t)&&"ownerSVGElement"in t}function Mc(t){return ir(t)&&t.tagName==="svg"}const J=t=>!!(t&&t.getVelocity),Dc=[...qo,X,Et],jc=t=>Dc.find(Yo(t)),Ts=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function pi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Vc(...t){return e=>{let n=!1;const s=t.map(i=>{const r=pi(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():pi(t[i],null)}}}}function Ec(...t){return vt.useCallback(Vc(...t),t)}class kc extends vt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=tr(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 Rc({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(Ts),l=Ec(r,t?.ref);return m.useInsertionEffect(()=>{const{width:c,height:u,top:d,left:f,right:g}=o.current;if(e||!r.current||!c||!u)return;const y=n==="left"?`left: ${f}`:`right: ${g}`;r.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const w=s??document.head;return w.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
2
2
|
[data-motion-pop-id="${i}"] {
|
|
3
3
|
position: absolute !important;
|
|
4
4
|
width: ${c}px !important;
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
${y}px !important;
|
|
7
7
|
top: ${d}px !important;
|
|
8
8
|
}
|
|
9
|
-
`),()=>{w.contains(v)&&w.removeChild(v)}},[e]),h.jsx(Ec,{isPresent:e,childRef:r,sizeRef:o,children:xt.cloneElement(t,{ref:l})})}const Rc=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const c=Jn(Nc),u=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:u,initial:e,isPresent:n,custom:i,onExitComplete:g=>{c.set(g,!0);for(const y of c.values())if(!y)return;s&&s()},register:g=>(c.set(g,!1),()=>c.delete(g))}),[n,c,s]);return r&&d&&(f={...f}),m.useMemo(()=>{c.forEach((g,y)=>c.set(y,!1))},[n]),xt.useEffect(()=>{!n&&!c.size&&s&&s()},[n]),o==="popLayout"&&(t=h.jsx(kc,{isPresent:n,anchorX:a,root:l,children:t})),h.jsx(Je.Provider,{value:f,children:t})};function Nc(){return new Map}function ir(t=!0){const e=m.useContext(Je);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 Fe=t=>t.key||"";function pi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Ic=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[c,u]=ir(o),d=m.useMemo(()=>pi(t),[t]),f=o&&!c?[]:d.map(Fe),g=m.useRef(!0),y=m.useRef(d),v=Jn(()=>new Map),[w,x]=m.useState(d),[T,b]=m.useState(d);fo(()=>{g.current=!1,y.current=d;for(let V=0;V<T.length;V++){const D=Fe(T[V]);f.includes(D)?v.delete(D):v.get(D)!==!0&&v.set(D,!1)}},[T,f.length,f.join("-")]);const j=[];if(d!==w){let V=[...d];for(let D=0;D<T.length;D++){const A=T[D],I=Fe(A);f.includes(I)||(V.splice(D,0,A),j.push(A))}return r==="wait"&&j.length&&(V=j),b(pi(V)),x(d),null}process.env.NODE_ENV!=="production"&&r==="wait"&&T.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(Zn);return h.jsx(h.Fragment,{children:T.map(V=>{const D=Fe(V),A=o&&!c?!1:d===T||f.includes(D),I=()=>{if(v.has(D))v.set(D,!0);else return;let L=!0;v.forEach(Q=>{Q||(L=!1)}),L&&(P?.(),b(y.current),o&&u?.(),s&&s())};return h.jsx(Rc,{isPresent:A,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:A?void 0:I,anchorX:a,children:V},D)})})},Ts=m.createContext({strict:!1}),gi={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"]},se={};for(const t in gi)se[t]={isEnabled:e=>gi[t].some(n=>!!e[n])};function $n(t){for(const e in t)se[e]={...se[e],...t[e]}}function Lc({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!yn(e)),i=m.useRef(void 0);if(!yn(e)){const{renderer:r,...o}=e;i.current=r,$n(o)}return m.useEffect(()=>{yn(e)&&e().then(({renderer:r,...o})=>{$n(o),i.current=r,s(!0)})},[]),h.jsx(Ts.Provider,{value:{renderer:i.current,strict:n},children:t})}function yn(t){return typeof t=="function"}const Oc=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 qe(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Oc.has(t)}let or=t=>!qe(t);function Fc(t){typeof t=="function"&&(or=e=>e.startsWith("on")?!qe(e):t(e))}try{Fc(require("@emotion/is-prop-valid").default)}catch{}function Bc(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(or(i)||n===!0&&qe(i)||!e&&!qe(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const Qe=m.createContext({});function tn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Te(t){return typeof t=="string"||Array.isArray(t)}const Ss=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Cs=["initial",...Ss];function en(t){return tn(t.animate)||Cs.some(e=>Te(t[e]))}function rr(t){return!!(en(t)||t.variants)}function $c(t,e){if(en(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Te(n)?n:void 0,animate:Te(s)?s:void 0}}return t.inherit!==!1?e:{}}function zc(t){const{initial:e,animate:n}=$c(t,m.useContext(Qe));return m.useMemo(()=>({initial:e,animate:n}),[yi(e),yi(n)])}function yi(t){return Array.isArray(t)?t.join(" "):t}const Se={};function Uc(t){for(const e in t)Se[e]=t[e],as(e)&&(Se[e].isCSSVariable=!0)}function ar(t,{layout:e,layoutId:n}){return ae.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Se[t]||t==="opacity")}const Wc={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},_c=re.length;function Kc(t,e,n){let s="",i=!0;for(let r=0;r<_c;r++){const o=re[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 c=Jo(a,xs[o]);if(!l){i=!1;const u=Wc[o]||o;s+=`${u}(${c}) `}n&&(e[o]=c)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function Ps(t,e,n){const{style:s,vars:i,transformOrigin:r}=t;let o=!1,a=!1;for(const l in e){const c=e[l];if(ae.has(l)){o=!0;continue}else if(as(l)){i[l]=c;continue}else{const u=Jo(c,xs[l]);l.startsWith("origin")?(a=!0,r[l]=u):s[l]=u}}if(e.transform||(o||n?s.transform=Kc(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:u=0}=r;s.transformOrigin=`${l} ${c} ${u}`}}const As=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function lr(t,e,n){for(const s in e)!J(e[s])&&!ar(s,n)&&(t[s]=e[s])}function Hc({transformTemplate:t},e){return m.useMemo(()=>{const n=As();return Ps(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Xc(t,e){const n=t.style||{},s={};return lr(s,n,t),Object.assign(s,Hc(t,e)),s}function Yc(t,e){const n={},s=Xc(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 Gc={offset:"stroke-dashoffset",array:"stroke-dasharray"},qc={offset:"strokeDashoffset",array:"strokeDasharray"};function Zc(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?Gc:qc;t[r.offset]=M.transform(-s);const o=M.transform(e),a=M.transform(n);t[r.array]=`${o} ${a}`}function cr(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,c,u){if(Ps(t,a,c),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=u?.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&&Zc(d,i,r,o,!1)}const ur=()=>({...As(),attrs:{}}),dr=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Jc(t,e,n,s){const i=m.useMemo(()=>{const r=ur();return cr(r,e,dr(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};lr(r,t.style,t),i.style={...r,...i.style}}return i}const Qc=["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 Ms(t){return typeof t!="string"||t.includes("-")?!1:!!(Qc.indexOf(t)>-1||/[A-Z]/u.test(t))}function tu(t,e,n,{latestValues:s},i,r=!1){const a=(Ms(t)?Jc:Yc)(e,s,i,t),l=Bc(e,typeof t=="string",r),c=t!==m.Fragment?{...l,...a,ref:n}:{},{children:u}=e,d=m.useMemo(()=>J(u)?u.get():u,[u]);return m.createElement(t,{...c,children:d})}function xi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function js(t,e,n,s){if(typeof e=="function"){const[i,r]=xi(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]=xi(s);e=e(n!==void 0?n:t.custom,i,r)}return e}function We(t){return J(t)?t.get():t}function eu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:nu(n,s,i,t),renderState:e()}}function nu(t,e,n,s){const i={},r=s(t,{});for(const f in r)i[f]=We(r[f]);let{initial:o,animate:a}=t;const l=en(t),c=rr(t);e&&c&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let u=n?n.initial===!1:!1;u=u||o===!1;const d=u?a:o;if(d&&typeof d!="boolean"&&!tn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=js(t,f[g]);if(y){const{transitionEnd:v,transition:w,...x}=y;for(const T in x){let b=x[T];if(Array.isArray(b)){const j=u?b.length-1:0;b=b[j]}b!==null&&(i[T]=b)}for(const T in v)i[T]=v[T]}}}return i}const hr=t=>(e,n)=>{const s=m.useContext(Qe),i=m.useContext(Je),r=()=>eu(t,e,s,i);return n?r():Jn(r)};function Ds(t,e,n){const{style:s}=t,i={};for(const r in s)(J(s[r])||e.style&&J(e.style[r])||ar(r,t)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const su=hr({scrapeMotionValuesFromProps:Ds,createRenderState:As});function fr(t,e,n){const s=Ds(t,e,n);for(const i in t)if(J(t[i])||J(e[i])){const r=re.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}const iu=hr({scrapeMotionValuesFromProps:fr,createRenderState:ur}),ou=Symbol.for("motionComponentSymbol");function qt(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function ru(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):qt(n)&&(n.current=s))},[e])}const Vs=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),au="framerAppearId",mr="data-"+Vs(au),pr=m.createContext({});function lu(t,e,n,s,i){const{visualElement:r}=m.useContext(Qe),o=m.useContext(Ts),a=m.useContext(Je),l=m.useContext(ws).reducedMotion,c=m.useRef(null);s=s||o.renderer,!c.current&&s&&(c.current=s(t,{visualState:e,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const u=c.current,d=m.useContext(pr);u&&!u.projection&&i&&(u.type==="html"||u.type==="svg")&&cu(c.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{u&&f.current&&u.update(n,a)});const g=n[mr],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return fo(()=>{u&&(f.current=!0,window.MotionIsMounted=!0,u.updateFeatures(),u.scheduleRenderMicrotask(),y.current&&u.animationState&&u.animationState.animateChanges())}),m.useEffect(()=>{u&&(!y.current&&u.animationState&&u.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),u.enteringChildren=void 0)}),u}function cu(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:c,layoutCrossfade:u}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:gr(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&qt(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:u,layoutScroll:l,layoutRoot:c})}function gr(t){if(t)return t.options.allowProjection!==!1?t.projection:gr(t.parent)}function _e(t,{forwardMotionProps:e=!1}={},n,s){n&&$n(n);const i=Ms(t)?iu:su;function r(a,l){let c;const u={...m.useContext(ws),...a,layoutId:uu(a)},{isStatic:d}=u,f=zc(a),g=i(a,d);if(!d&&Qn){du(u,n);const y=hu(u);c=y.MeasureLayout,f.visualElement=lu(t,g,u,s,y.ProjectionNode)}return h.jsxs(Qe.Provider,{value:f,children:[c&&f.visualElement?h.jsx(c,{visualElement:f.visualElement,...u}):null,tu(t,a,ru(g,f.visualElement,l),g,d,e)]})}r.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const o=m.forwardRef(r);return o[ou]=t,o}function uu({layoutId:t}){const e=m.useContext(Zn).id;return e&&t!==void 0?e+"-"+t:t}function du(t,e){const n=m.useContext(Ts).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?ie(!1,s,"lazy-strict-mode"):wt(!1,s,"lazy-strict-mode")}}function hu(t){const{drag:e,layout:n}=se;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function fu(t,e){if(typeof Proxy>"u")return _e;const n=new Map,s=(r,o)=>_e(r,o,t,e),i=(r,o)=>(process.env.NODE_ENV!=="production"&&is(!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,_e(o,void 0,t,e)),n.get(o))})}function yr({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function mu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function pu(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 xn(t){return t===void 0||t===1}function zn({scale:t,scaleX:e,scaleY:n}){return!xn(t)||!xn(e)||!xn(n)}function zt(t){return zn(t)||xr(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function xr(t){return vi(t.x)||vi(t.y)}function vi(t){return t&&t!=="0%"}function Ze(t,e,n){const s=t-n,i=e*s;return n+i}function bi(t,e,n,s,i){return i!==void 0&&(t=Ze(t,i,s)),Ze(t,n,s)+e}function Un(t,e=0,n=1,s,i){t.min=bi(t.min,e,n,s,i),t.max=bi(t.max,e,n,s,i)}function vr(t,{x:e,y:n}){Un(t.x,e.translate,e.scale,e.originPoint),Un(t.y,n.translate,n.scale,n.originPoint)}const wi=.999999999999,Ti=1.0000000000001;function gu(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&&Jt(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,vr(t,o)),s&&zt(r.latestValues)&&Jt(t,r.latestValues))}e.x<Ti&&e.x>wi&&(e.x=1),e.y<Ti&&e.y>wi&&(e.y=1)}function Zt(t,e){t.min=t.min+e,t.max=t.max+e}function Si(t,e,n,s,i=.5){const r=U(t.min,t.max,i);Un(t,e,n,r,s)}function Jt(t,e){Si(t.x,e.x,e.scaleX,e.scale,e.originX),Si(t.y,e.y,e.scaleY,e.scale,e.originY)}function br(t,e){return yr(pu(t.getBoundingClientRect(),e))}function yu(t,e,n){const s=br(t,n),{scroll:i}=e;return i&&(Zt(s.x,i.offset.x),Zt(s.y,i.offset.y)),s}const Ci=()=>({translate:0,scale:1,origin:0,originPoint:0}),Qt=()=>({x:Ci(),y:Ci()}),Pi=()=>({min:0,max:0}),H=()=>({x:Pi(),y:Pi()}),Wn={current:null},wr={current:!1};function xu(){if(wr.current=!0,!!Qn)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Wn.current=t.matches;t.addEventListener("change",e),e()}else Wn.current=!1}const vu=new WeakMap;function bu(t,e,n){for(const s in e){const i=e[s],r=n[s];if(J(i))t.addValue(s,i);else if(J(r))t.addValue(s,ne(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,ne(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Ai=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class wu{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=gs,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=st.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,$.render(this.render,!1,!0))};const{latestValues:l,renderState:c}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=c,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=en(n),this.isVariantNode=rr(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:u,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];l[f]!==void 0&&J(g)&&g.set(l[f])}}mount(e){this.current=e,vu.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)),wr.current||xu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Wn.current,process.env.NODE_ENV!=="production"&&is(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=ae.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&$.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 se){const n=se[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):H()}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<Ai.length;s++){const i=Ai[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=bu(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=ne(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"&&(mo(s)||go(s))?s=parseFloat(s):!jc(s)&&Vt.test(n)&&(s=Zo(e,n)),this.setBaseTarget(e,J(s)?s.get():s)),J(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=js(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&&!J(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 ss),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){vs.render(this.render)}}class Tr extends wu{constructor(){super(...arguments),this.KeyframeResolver=gc}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;J(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Sr(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 Tu(t){return window.getComputedStyle(t)}class Su extends Tr{constructor(){super(...arguments),this.type="html",this.renderInstance=Sr}readValueFromInstance(e,n){if(ae.has(n))return this.projection?.isProjecting?Rn(n):Nl(e,n);{const s=Tu(e),i=(as(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return br(e,n)}build(e,n,s){Ps(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return Ds(e,n,s)}}const Cr=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 Cu(t,e,n,s){Sr(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Cr.has(i)?i:Vs(i),e.attrs[i])}class Pu extends Tr{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=H}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(ae.has(n)){const s=qo(n);return s&&s.default||0}return n=Cr.has(n)?n:Vs(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return fr(e,n,s)}build(e,n,s){cr(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Cu(e,n,s,i)}mount(e){this.isSVGTag=dr(e.tagName),super.mount(e)}}const Pr=(t,e)=>Ms(t)?new Pu(e):new Su(e,{allowProjection:t!==m.Fragment});function ee(t,e,n){const s=t.getProps();return js(s,e,n!==void 0?n:s.custom,t)}const _n=t=>Array.isArray(t);function Au(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,ne(n))}function Mu(t){return _n(t)?t[t.length-1]||0:t}function ju(t,e){const n=ee(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=Mu(r[o]);Au(t,o,a)}}function Du(t){return!!(J(t)&&t.add)}function Kn(t,e){const n=t.getValue("willChange");if(Du(n))return n.add(e);if(!n&&Tt.WillChange){const s=new Tt.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Ar(t){return t.props[mr]}const Vu=t=>t!==null;function Eu(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Vu),r=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[r]}const ku={type:"spring",stiffness:500,damping:25,restSpeed:10},Ru=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Nu={type:"keyframes",duration:.8},Iu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Lu=(t,{keyframes:e})=>e.length>2?Nu:ae.has(t)?t.startsWith("scale")?Ru(e[1]):ku:Iu;function Ou({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:c,...u}){return!!Object.keys(u).length}const Es=(t,e,n,s={},i,r)=>o=>{const a=ys(s,t)||{},l=a.delay||s.delay||0;let{elapsed:c=0}=s;c=c-ft(l);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-c,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};Ou(a)||Object.assign(u,Lu(t,u)),u.duration&&(u.duration=ft(u.duration)),u.repeatDelay&&(u.repeatDelay=ft(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Fn(u),u.delay===0&&(d=!0)),(Tt.instantAnimations||Tt.skipAnimations)&&(d=!0,Fn(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,d&&!r&&e.get()!==void 0){const f=Eu(u.keyframes,a);if(f!==void 0){$.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new ps(u):new sc(u)};function Fu({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Mr(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=t.getDefaultTransition(),transitionEnd:o,...a}=e;s&&(r=s);const l=[],c=i&&t.animationState&&t.animationState.getState()[i];for(const u in a){const d=t.getValue(u,t.latestValues[u]??null),f=a[u];if(f===void 0||c&&Fu(c,u))continue;const g={delay:n,...ys(r||{},u)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=Ar(t);if(x){const T=window.MotionHandoffAnimation(x,u,$);T!==null&&(g.startTime=T,v=!0)}}Kn(t,u),d.start(Es(u,d,f,t.shouldReduceMotion&&Xo.has(u)?{type:!1}:g,t,v));const w=d.animation;w&&l.push(w)}return o&&Promise.all(l).then(()=>{$.update(()=>{o&&ju(t,o)})}),l}function jr(t,e,n,s=0,i=1){const r=Array.from(t).sort((c,u)=>c.sortNodePosition(u)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Hn(t,e,n={}){const s=ee(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(Mr(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:c=0,staggerChildren:u,staggerDirection:d}=i;return Bu(t,e,l,c,u,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,c]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>c())}else return Promise.all([r(),o(n.delay)])}function Bu(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(Hn(l,e,{...o,delay:n+(typeof s=="function"?0:s)+jr(t.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function $u(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(r=>Hn(t,r,n));s=Promise.all(i)}else if(typeof e=="string")s=Hn(t,e,n);else{const i=typeof e=="function"?ee(t,e,n.custom):e;s=Promise.all(Mr(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function Dr(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 zu=Cs.length;function Vr(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Vr(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<zu;n++){const s=Cs[n],i=t.props[s];(Te(i)||i===!1)&&(e[s]=i)}return e}const Uu=[...Ss].reverse(),Wu=Ss.length;function _u(t){return e=>Promise.all(e.map(({animation:n,options:s})=>$u(t,n,s)))}function Ku(t){let e=_u(t),n=Mi(),s=!0;const i=l=>(c,u)=>{const d=ee(t,u,l==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;c={...c,...y,...g}}return c};function r(l){e=l(t)}function o(l){const{props:c}=t,u=Vr(t.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let w=0;w<Wu;w++){const x=Uu[w],T=n[x],b=c[x]!==void 0?c[x]:u[x],j=Te(b),P=x===l?T.isActive:null;P===!1&&(y=w);let V=b===u[x]&&b!==c[x]&&j;if(V&&s&&t.manuallyAnimateOnMount&&(V=!1),T.protectedKeys={...g},!T.isActive&&P===null||!b&&!T.prevProp||tn(b)||typeof b=="boolean")continue;const D=Hu(T.prevProp,b);let A=D||x===l&&T.isActive&&!V&&j||w>y&&j,I=!1;const L=Array.isArray(b)?b:[b];let Q=L.reduce(i(x),{});P===!1&&(Q={});const{prevResolvedValues:ct={}}=T,Ht={...ct,...Q},St=R=>{A=!0,f.has(R)&&(I=!0,f.delete(R)),T.needsAnimating[R]=!0;const B=t.getValue(R);B&&(B.liveStyle=!1)};for(const R in Ht){const B=Q[R],Z=ct[R];if(g.hasOwnProperty(R))continue;let W=!1;_n(B)&&_n(Z)?W=!Dr(B,Z):W=B!==Z,W?B!=null?St(R):f.add(R):B!==void 0&&f.has(R)?St(R):T.protectedKeys[R]=!0}T.prevProp=b,T.prevResolvedValues=Q,T.isActive&&(g={...g,...Q}),s&&t.blockInitialAnimation&&(A=!1);const pt=V&&D;A&&(!pt||I)&&d.push(...L.map(R=>{const B={type:x};if(typeof R=="string"&&s&&!pt&&t.manuallyAnimateOnMount&&t.parent){const{parent:Z}=t,W=ee(Z,R);if(Z.enteringChildren&&W){const{delayChildren:kt}=W.transition||{};B.delay=jr(Z.enteringChildren,t,kt)}}return{animation:R,options:B}}))}if(f.size){const w={};if(typeof c.initial!="boolean"){const x=ee(t,Array.isArray(c.initial)?c.initial[0]:c.initial);x&&x.transition&&(w.transition=x.transition)}f.forEach(x=>{const T=t.getBaseTarget(x),b=t.getValue(x);b&&(b.liveStyle=!0),w[x]=T??null}),d.push({animation:w})}let v=!!d.length;return s&&(c.initial===!1||c.initial===c.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(l,c){if(n[l].isActive===c)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(l,c)),n[l].isActive=c;const u=o(l);for(const d in n)n[d].protectedKeys={};return u}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Mi()}}}function Hu(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Dr(e,t):!1}function $t(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Mi(){return{animate:$t(!0),whileInView:$t(),whileHover:$t(),whileTap:$t(),whileDrag:$t(),whileFocus:$t(),exit:$t()}}class Et{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Xu extends Et{constructor(e){super(e),e.animationState||(e.animationState=Ku(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();tn(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 Yu=0;class Gu extends Et{constructor(){super(...arguments),this.id=Yu++}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 Er={animation:{Feature:Xu},exit:{Feature:Gu}};function Ce(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function je(t){return{point:{x:t.pageX,y:t.pageY}}}const qu=t=>e=>bs(e)&&t(e,je(e));function ge(t,e,n,s){return Ce(t,e,qu(n),s)}const kr=1e-4,Zu=1-kr,Ju=1+kr,Rr=.01,Qu=0-Rr,td=0+Rr;function et(t){return t.max-t.min}function ed(t,e,n){return Math.abs(t-e)<=n}function ji(t,e,n,s=.5){t.origin=s,t.originPoint=U(e.min,e.max,t.origin),t.scale=et(n)/et(e),t.translate=U(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Zu&&t.scale<=Ju||isNaN(t.scale))&&(t.scale=1),(t.translate>=Qu&&t.translate<=td||isNaN(t.translate))&&(t.translate=0)}function ye(t,e,n,s){ji(t.x,e.x,n.x,s?s.originX:void 0),ji(t.y,e.y,n.y,s?s.originY:void 0)}function Di(t,e,n){t.min=n.min+e.min,t.max=t.min+et(e)}function nd(t,e,n){Di(t.x,e.x,n.x),Di(t.y,e.y,n.y)}function Vi(t,e,n){t.min=e.min-n.min,t.max=t.min+et(e)}function xe(t,e,n){Vi(t.x,e.x,n.x),Vi(t.y,e.y,n.y)}function rt(t){return[t("x"),t("y")]}const Nr=({current:t})=>t?t.ownerDocument.defaultView:null,Ei=(t,e)=>Math.abs(t-e);function sd(t,e){const n=Ei(t.x,e.x),s=Ei(t.y,e.y);return Math.sqrt(n**2+s**2)}class Ir{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=bn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=sd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:v}=f,{timestamp:w}=q;this.history.push({...v,timestamp:w});const{onStart:x,onMove:T}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=vn(g,this.transformPagePoint),$.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:v,resumeAnimation:w}=this.handlers;if(this.dragSnapToOrigin&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=bn(f.type==="pointercancel"?this.lastMoveEventInfo:vn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!bs(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=je(e),l=vn(a,this.transformPagePoint),{point:c}=l,{timestamp:u}=q;this.history=[{...c,timestamp:u}];const{onSessionStart:d}=n;d&&d(e,bn(l,this.history)),this.removeListeners=Pe(ge(this.contextWindow,"pointermove",this.handlePointerMove),ge(this.contextWindow,"pointerup",this.handlePointerUp),ge(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Dt(this.updatePoint)}}function vn(t,e){return e?{point:e(t.point)}:t}function ki(t,e){return{x:t.x-e.x,y:t.y-e.y}}function bn({point:t},e){return{point:t,delta:ki(t,Lr(e)),offset:ki(t,id(e)),velocity:od(e,.1)}}function id(t){return t[0]}function Lr(t){return t[t.length-1]}function od(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Lr(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>ft(e)));)n--;if(!s)return{x:0,y:0};const r=at(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 rd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?U(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?U(n,t,s.max):Math.min(t,n)),t}function Ri(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 ad(t,{top:e,left:n,bottom:s,right:i}){return{x:Ri(t.x,n,i),y:Ri(t.y,e,s)}}function Ni(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 ld(t,e){return{x:Ni(t.x,e.x),y:Ni(t.y,e.y)}}function cd(t,e){let n=.5;const s=et(t),i=et(e);return i>s?n=ve(e.min,e.max-s,t.min):s>i&&(n=ve(t.min,t.max-i,e.min)),bt(0,1,n)}function ud(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 Xn=.35;function dd(t=Xn){return t===!1?t=0:t===!0&&(t=Xn),{x:Ii(t,"left","right"),y:Ii(t,"top","bottom")}}function Ii(t,e,n){return{min:Li(t,e),max:Li(t,n)}}function Li(t,e){return typeof t=="number"?t:t[e]||0}const hd=new WeakMap;class fd{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=H(),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(je(d).point)},o=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=bc(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),rt(x=>{let T=this.getAxisMotionValue(x).get()||0;if(vt.test(T)){const{projection:b}=this.visualElement;if(b&&b.layout){const j=b.layout.layoutBox[x];j&&(T=et(j)*(parseFloat(T)/100))}}this.originPoint[x]=T}),v&&$.postRender(()=>v(d,f)),Kn(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:v,onDrag:w}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:x}=f;if(y&&this.currentDirection===null){this.currentDirection=md(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),w&&w(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>rt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:u}=this.getProps();this.panSession=new Ir(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:s,contextWindow:Nr(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&&$.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||!Be(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=rd(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&&qt(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=ad(s.layoutBox,e):this.constraints=!1,this.elastic=dd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&rt(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=ud(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!qt(e))return!1;const s=e.current;wt(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=yu(s,i.root,this.visualElement.getTransformPagePoint());let o=ld(i.layout.layoutBox,r);if(n){const a=n(mu(o));this.hasMutatedConstraints=!!a,a&&(o=yr(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=rt(u=>{if(!Be(u,n,this.currentDirection))return;let d=l&&l[u]||{};o&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?e[u]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(u,y)});return Promise.all(c).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Kn(this.visualElement,e),s.start(Es(e,s,0,n,this.visualElement,!1))}stopAnimation(){rt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){rt(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){rt(n=>{const{drag:s}=this.getProps();if(!Be(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]-U(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!qt(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};rt(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=cd({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(),rt(o=>{if(!Be(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:c}=this.constraints[o];a.set(U(l,c,i[o]))})}addListeners(){if(!this.visualElement.current)return;hd.set(this.visualElement,this);const e=this.visualElement.current,n=ge(e,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps();c&&u&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();qt(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()),$.read(s);const o=Ce(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(rt(u=>{const d=this.getAxisMotionValue(u);d&&(this.originPoint[u]+=l[u].translate,d.set(d.get()+l[u].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=Xn,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function Be(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function md(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class pd extends Et{constructor(e){super(e),this.removeGroupControls=lt,this.removeListeners=lt,this.controls=new fd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||lt}unmount(){this.removeGroupControls(),this.removeListeners()}}const Oi=t=>(e,n)=>{t&&$.postRender(()=>t(e,n))};class gd extends Et{constructor(){super(...arguments),this.removePointerDownListener=lt}onPointerDown(e){this.session=new Ir(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Nr(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Oi(e),onStart:Oi(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&$.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=ge(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 Ke={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Fi(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const fe={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(M.test(t))t=parseFloat(t);else return t;const n=Fi(t,e.target.x),s=Fi(t,e.target.y);return`${n}% ${s}%`}},yd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Vt.parse(t);if(i.length>5)return s;const r=Vt.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 c=U(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=c),typeof i[3+o]=="number"&&(i[3+o]/=c),r(i)}};let wn=!1;class xd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=e;Uc(vd),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),wn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),Ke.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,wn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==r?o.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?o.promote():o.relegate()||$.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),vs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;wn=!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 Or(t){const[e,n]=ir(),s=m.useContext(Zn);return h.jsx(xd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(pr),isPresent:e,safeToRemove:n})}const vd={borderRadius:{...fe,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:fe,borderTopRightRadius:fe,borderBottomLeftRadius:fe,borderBottomRightRadius:fe,boxShadow:yd};function bd(t,e,n){const s=J(t)?t:ne(t);return s.start(Es("",s,e,n)),s.animation}const wd=(t,e)=>t.depth-e.depth;class Td{constructor(){this.children=[],this.isDirty=!1}add(e){ts(this.children,e),this.isDirty=!0}remove(e){es(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(wd),this.isDirty=!1,this.children.forEach(e)}}function Sd(t,e){const n=st.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(Dt(s),t(r-e))};return $.setup(s,!0),()=>Dt(s)}const Fr=["TopLeft","TopRight","BottomLeft","BottomRight"],Cd=Fr.length,Bi=t=>typeof t=="string"?parseFloat(t):t,$i=t=>typeof t=="number"||M.test(t);function Pd(t,e,n,s,i,r){i?(t.opacity=U(0,n.opacity??1,Ad(s)),t.opacityExit=U(e.opacity??1,0,Md(s))):r&&(t.opacity=U(e.opacity??1,n.opacity??1,s));for(let o=0;o<Cd;o++){const a=`border${Fr[o]}Radius`;let l=zi(e,a),c=zi(n,a);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||$i(l)===$i(c)?(t[a]=Math.max(U(Bi(l),Bi(c),s),0),(vt.test(c)||vt.test(l))&&(t[a]+="%")):t[a]=c}(e.rotate||n.rotate)&&(t.rotate=U(e.rotate||0,n.rotate||0,s))}function zi(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Ad=Br(0,.5,Co),Md=Br(.5,.95,lt);function Br(t,e,n){return s=>s<t?0:s>e?1:n(ve(t,e,s))}function Ui(t,e){t.min=e.min,t.max=e.max}function ot(t,e){Ui(t.x,e.x),Ui(t.y,e.y)}function Wi(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function _i(t,e,n,s,i){return t-=e,t=Ze(t,1/n,s),i!==void 0&&(t=Ze(t,1/i,s)),t}function jd(t,e=0,n=1,s=.5,i,r=t,o=t){if(vt.test(e)&&(e=parseFloat(e),e=U(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=U(r.min,r.max,s);t===r&&(a-=e),t.min=_i(t.min,e,n,a,i),t.max=_i(t.max,e,n,a,i)}function Ki(t,e,[n,s,i],r,o){jd(t,e[n],e[s],e[i],e.scale,r,o)}const Dd=["x","scaleX","originX"],Vd=["y","scaleY","originY"];function Hi(t,e,n,s){Ki(t.x,e,Dd,n?n.x:void 0,s?s.x:void 0),Ki(t.y,e,Vd,n?n.y:void 0,s?s.y:void 0)}function Xi(t){return t.translate===0&&t.scale===1}function $r(t){return Xi(t.x)&&Xi(t.y)}function Yi(t,e){return t.min===e.min&&t.max===e.max}function Ed(t,e){return Yi(t.x,e.x)&&Yi(t.y,e.y)}function Gi(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function zr(t,e){return Gi(t.x,e.x)&&Gi(t.y,e.y)}function qi(t){return et(t.x)/et(t.y)}function Zi(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class kd{constructor(){this.members=[]}add(e){ts(this.members,e),e.scheduleRender()}remove(e){if(es(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 Rd(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:c,rotate:u,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;c&&(s=`perspective(${c}px) ${s}`),u&&(s+=`rotate(${u}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}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 Tn=["","X","Y","Z"],Nd=1e3;let Id=0;function Sn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function Ur(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Ar(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",$,!(i||r))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&Ur(s)}function Wr({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Id++,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(Fd),this.nodes.forEach(Ud),this.nodes.forEach(Wd),this.nodes.forEach(Bd)},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 Td)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new ss),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=sr(o)&&!Ac(o),this.instance=o;const{layoutId:a,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let u,d=0;const f=()=>this.root.updateBlockedByResize=!1;$.read(()=>{d=window.innerWidth}),t(o,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,u&&u(),u=Sd(f,250),Ke.hasAnimatedSinceResize&&(Ke.hasAnimatedSinceResize=!1,this.nodes.forEach(to)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||c.getDefaultTransition()||Yd,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=c.getProps(),x=!this.targetLayout||!zr(this.targetLayout,g),T=!d&&f;if(this.options.layoutRoot||this.resumeFrom||T||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...ys(y,"layout"),onPlay:v,onComplete:w};(c.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(u,T)}else d||to(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}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(_d),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&&Ur(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const d=this.path[u];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 c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Ji);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Qi);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(zd),this.nodes.forEach(Ld),this.nodes.forEach(Od)):this.nodes.forEach(Qi),this.clearAllSnapshots();const a=st.now();q.delta=bt(0,1e3/60,a-q.timestamp),q.timestamp=a,q.isProcessing=!0,dn.update.process(q),dn.preRender.process(q),dn.render.process(q),q.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,vs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach($d),this.sharedNodes.forEach(Kd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,$.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){$.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!et(this.snapshot.measuredBox.x)&&!et(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=H(),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&&!$r(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;o&&this.instance&&(a||zt(this.latestValues)||u)&&(i(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),Gd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return H();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(qd))){const{scroll:c}=this.root;c&&(Zt(a.x,c.offset.x),Zt(a.y,c.offset.y))}return a}removeElementScroll(o){const a=H();if(ot(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const c=this.path[l],{scroll:u,options:d}=c;c!==this.root&&u&&d.layoutScroll&&(u.wasRoot&&ot(a,o),Zt(a.x,u.offset.x),Zt(a.y,u.offset.y))}return a}applyTransform(o,a=!1){const l=H();ot(l,o);for(let c=0;c<this.path.length;c++){const u=this.path[c];!a&&u.options.layoutScroll&&u.scroll&&u!==u.root&&Jt(l,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),zt(u.latestValues)&&Jt(l,u.latestValues)}return zt(this.latestValues)&&Jt(l,this.latestValues),l}removeTransform(o){const a=H();ot(a,o);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!c.instance||!zt(c.latestValues))continue;zn(c.latestValues)&&c.updateSnapshot();const u=H(),d=c.measurePageBox();ot(u,d),Hi(a,c.latestValues,c.snapshot?c.snapshot.layoutBox:void 0,u)}return zt(this.latestValues)&&Hi(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:u,layoutId:d}=this.options;if(!(!this.layout||!(u||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=H(),this.relativeTargetOrigin=H(),xe(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),ot(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=H(),this.targetWithTransforms=H()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),nd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):ot(this.target,this.layout.layoutBox),vr(this.target,this.targetDelta)):ot(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=H(),this.relativeTargetOrigin=H(),xe(this.relativeTargetOrigin,this.target,f.target),ot(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||zn(this.parent.latestValues)||xr(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:c,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||u))return;ot(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;gu(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=H());const{target:g}=o;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Wi(this.prevProjectionDelta.x,this.projectionDelta.x),Wi(this.prevProjectionDelta.y,this.projectionDelta.y)),ye(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Zi(this.projectionDelta.x,this.prevProjectionDelta.x)||!Zi(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}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=Qt(),this.projectionDelta=Qt(),this.projectionDeltaWithTransform=Qt()}setAnimationOrigin(o,a=!1){const l=this.snapshot,c=l?l.latestValues:{},u={...this.latestValues},d=Qt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=H(),g=l?l.source:void 0,y=this.layout?this.layout.source:void 0,v=g!==y,w=this.getStack(),x=!w||w.members.length<=1,T=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(Xd));this.animationProgress=0;let b;this.mixTargetDelta=j=>{const P=j/1e3;eo(d.x,o.x,P),eo(d.y,o.y,P),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(xe(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Hd(this.relativeTarget,this.relativeTargetOrigin,f,P),b&&Ed(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=H()),ot(b,this.relativeTarget)),v&&(this.animationValues=u,Pd(u,c,this.latestValues,P,T,x)),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=$.update(()=>{Ke.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=ne(0)),this.currentAnimation=bd(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(Nd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:c,latestValues:u}=o;if(!(!a||!l||!c)){if(this!==o&&this.layout&&c&&_r(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||H();const d=et(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=et(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}ot(a,l),Jt(a,u),ye(this.projectionDeltaWithTransform,this.layoutCorrected,a,u)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new kd),this.sharedNodes.get(o).add(a);const c=a.options.initialPromotionConfig;a.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.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 c=this.getStack();c&&c.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 c={};l.z&&Sn("z",o,c,this.animationValues);for(let u=0;u<Tn.length;u++)Sn(`rotate${Tn[u]}`,o,c,this.animationValues),Sn(`skew${Tn[u]}`,o,c,this.animationValues);o.render();for(const u in c)o.setStaticValue(u,c[u]),this.animationValues&&(this.animationValues[u]=c[u]);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=We(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=We(a?.pointerEvents)||""),this.hasProjected&&!zt(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let d=Rd(this.projectionDeltaWithTransform,this.treeScale,u);l&&(d=l(u,d)),o.transform=d;const{x:f,y:g}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,c.animationValues?o.opacity=c===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:o.opacity=c===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const y in Se){if(u[y]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:x}=Se[y],T=d==="none"?u[y]:v(u[y],c);if(w){const b=w.length;for(let j=0;j<b;j++)o[w[j]]=T}else x?this.options.visualElement.renderState.vars[y]=T:o[y]=T}this.options.layoutId&&(o.pointerEvents=c===this?We(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(Ji),this.root.sharedNodes.clear()}}}function Ld(t){t.updateLayout()}function Od(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"?rt(u=>{const d=r?e.measuredBox[u]:e.layoutBox[u],f=et(d);d.min=n[u].min,d.max=d.min+f}):_r(i,e.layoutBox,n)&&rt(u=>{const d=r?e.measuredBox[u]:e.layoutBox[u],f=et(n[u]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[u].max=t.relativeTarget[u].min+f)});const o=Qt();ye(o,n,e.layoutBox);const a=Qt();r?ye(a,t.applyTransform(s,!0),e.measuredBox):ye(a,n,e.layoutBox);const l=!$r(o);let c=!1;if(!t.resumeFrom){const u=t.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:d,layout:f}=u;if(d&&f){const g=H();xe(g,e.layoutBox,d.layoutBox);const y=H();xe(y,n,f.layoutBox),zr(g,y)||(c=!0),u.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=g,t.relativeParent=u)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Fd(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 Bd(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function $d(t){t.clearSnapshot()}function Ji(t){t.clearMeasurements()}function Qi(t){t.isLayoutDirty=!1}function zd(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function to(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Ud(t){t.resolveTargetDelta()}function Wd(t){t.calcProjection()}function _d(t){t.resetSkewAndRotation()}function Kd(t){t.removeLeadSnapshot()}function eo(t,e,n){t.translate=U(e.translate,0,n),t.scale=U(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function no(t,e,n,s){t.min=U(e.min,n.min,s),t.max=U(e.max,n.max,s)}function Hd(t,e,n,s){no(t.x,e.x,n.x,s),no(t.y,e.y,n.y,s)}function Xd(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Yd={duration:.45,ease:[.4,0,.1,1]},so=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),io=so("applewebkit/")&&!so("chrome/")?Math.round:lt;function oo(t){t.min=io(t.min),t.max=io(t.max)}function Gd(t){oo(t.x),oo(t.y)}function _r(t,e,n){return t==="position"||t==="preserve-aspect"&&!ed(qi(e),qi(n),.2)}function qd(t){return t!==t.root&&t.scroll?.wasRoot}const Zd=Wr({attachResizeListener:(t,e)=>Ce(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Cn={current:void 0},Kr=Wr({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Cn.current){const t=new Zd({});t.mount(window),t.setOptions({layoutScroll:!0}),Cn.current=t}return Cn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Jd={pan:{Feature:gd},drag:{Feature:pd,ProjectionNode:Kr,MeasureLayout:Or}};function ro(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&&$.postRender(()=>r(e,je(e)))}class Qd extends Et{mount(){const{current:e}=this.node;e&&(this.unmount=wc(e,(n,s)=>(ro(this.node,s,"Start"),i=>ro(this.node,i,"End"))))}unmount(){}}class th extends Et{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=Pe(Ce(this.node.current,"focus",()=>this.onFocus()),Ce(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function ao(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&&$.postRender(()=>r(e,je(e)))}class eh extends Et{mount(){const{current:e}=this.node;e&&(this.unmount=Pc(e,(n,s)=>(ao(this.node,s,"Start"),(i,{success:r})=>ao(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Yn=new WeakMap,Pn=new WeakMap,nh=t=>{const e=Yn.get(t.target);e&&e(t)},sh=t=>{t.forEach(nh)};function ih({root:t,...e}){const n=t||document;Pn.has(n)||Pn.set(n,{});const s=Pn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(sh,{root:t,...e})),s[i]}function oh(t,e,n){const s=ih(e);return Yn.set(t,n),s.observe(t),()=>{Yn.delete(t),s.unobserve(t)}}const rh={some:0,all:1};class ah extends Et{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:rh[i]},a=l=>{const{isIntersecting:c}=l;if(this.isInView===c||(this.isInView=c,r&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:u,onViewportLeave:d}=this.node.getProps(),f=c?u:d;f&&f(l)};return oh(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(lh(e,n))&&this.startObserver()}unmount(){}}function lh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Hr={inView:{Feature:ah},tap:{Feature:eh},focus:{Feature:th},hover:{Feature:Qd}},ch={layout:{ProjectionNode:Kr,MeasureLayout:Or}},uh={...Er,...Hr,...Jd,...ch},dh=fu(uh,Pr),hh={renderer:Pr,...Er,...Hr};function Xr(t,e){return _e(t,e)}const $e=Xr("div"),fh=Xr("p");function mh(t){const e=t.name||"unnamed",n=ph(t),{schema:s,def:i}=gh(t);return{name:e,description:n,parameters:s,parametersDef:i}}function ph(t){const n=t.toString().match(/\/\*\*\s*\n([^*]|\*[^/])*\*\//);if(n){const i=n[0].match(/\/\*\*\s*\n\s*\*\s*([^\n@]+)/);if(i&&i[1])return i[1].trim()}return`Execute ${t.name||"function"}`}function gh(t){const n=t.toString().match(/\(([^)]*)\)/);if(!n||!n[1]||!n[1].trim())return{schema:Mt.z.object({}),def:{}};const i=n[1].split(",").map(a=>a.trim()),r={},o={};for(const a of i){const l=a.match(/(\w+)\s*:\s*(\w+)/);if(l&&l[1]&&l[2]){const c=l[1];switch(l[2].toLowerCase()){case"string":r[c]=Mt.z.string().describe(c),o[c]={type:"string",description:c};break;case"number":r[c]=Mt.z.number().describe(c),o[c]={type:"number",description:c};break;case"boolean":r[c]=Mt.z.boolean().describe(c),o[c]={type:"boolean",description:c};break;case"any":r[c]=Mt.z.any().describe(c),o[c]={type:"any",description:c};break;default:r[c]=Mt.z.string().describe(c),o[c]={type:"string",description:c}}}else{const c=a.match(/(\w+)/);if(c&&c[1]){const u=c[1];r[u]=Mt.z.string().describe(u),o[u]={type:"string",description:u}}}}return{schema:Mt.z.object(r),def:o}}function Yr(t){return t.map(mh)}function yh({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(yt,{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(yt,{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 xh({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,r]=m.useState(!1),o=Object.keys(e).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>o&&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"} ${o?"cursor-pointer hover:bg-opacity-80":""}`,children:[o&&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&&o&&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(e).map(([a,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[a,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},a))})})]})}function vh({...t}){return h.jsx(qn.Root,{"data-slot":"collapsible",...t})}function bh({...t}){return h.jsx(qn.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function wh({...t}){return h.jsx(qn.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Th=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ks=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Th,{className:mt("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ks.displayName="Response";const Sh=Object.freeze(Object.defineProperty({__proto__:null,Response:ks},Symbol.toStringTag,{value:"Module"})),Ch=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const r=dh.create(e),o=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(r,{animate:{backgroundPosition:"0% center"},className:mt("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})},Ph=m.memo(Ch),Gr=m.createContext(null),Ah=()=>{const t=m.useContext(Gr);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Mh=1e3,jh=1e3,qr=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:r,children:o,...a})=>{const[l,c]=Ks.useControllableState({prop:n,defaultProp:s,onChange:i}),[u,d]=Ks.useControllableState({prop:r,defaultProp:0}),[f,g]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{e?y===null&&v(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/jh)),v(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&l&&!f){const x=setTimeout(()=>{c(!1),g(!0)},Mh);return()=>clearTimeout(x)}},[e,l,s,c,f]);const w=x=>{c(x)};return h.jsx(Gr.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:c,duration:u},children:h.jsx(vh,{className:mt("not-prose mb-4",t),onOpenChange:w,open:l,...a,children:o})})}),Dh=(t,e)=>t||e===0?h.jsx(Ph,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Zr=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:r}=Ah();return h.jsx(bh,{className:mt("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"}),Dh(s,r),h.jsx(G.ChevronDownIcon,{className:mt("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Jr=m.memo(({className:t,children:e,...n})=>h.jsx(wh,{className:mt("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(ks,{className:"grid gap-2",children:e})}));qr.displayName="Reasoning";Zr.displayName="ReasoningTrigger";Jr.displayName="ReasoningContent";function Vh({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:c=!1,tools:u=[],safeTools:d=[],systemPrompt:f="",tokenEndpoint:g="/api/arcten/token",apiBaseUrl:y="https://api.arcten.com",user:v}){const[w,x]=m.useState(null),T=m.useRef(null),[b,j]=m.useState(null),[P,V]=m.useState(null),D=m.useRef(null),[A,I]=m.useState(c),[L,Q]=m.useState(o),[ct,Ht]=m.useState(600),[St,pt]=m.useState(!1),[O,R]=m.useState(!1),[B,Z]=m.useState(!1),[W,kt]=m.useState({x:100,y:100}),[Rt,Nt]=m.useState(!1),[le,De]=m.useState({x:0,y:0}),[nn,Ve]=m.useState(!1),ce=m.useRef(null),E=m.useRef(null),[k,_]=m.useState(""),[nt,tt]=m.useState(null),[ut,Qr]=m.useState("Thinking..."),[sn,on]=m.useState(new Set),[ta,ea]=m.useState(""),[It,na]=m.useState([]),[rn,Rs]=m.useState(!1),[an,Ns]=m.useState([]),[Is,ln]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Xt,Ee]=m.useState(!1),[kh,ke]=m.useState(!1),[Rh,Re]=m.useState([]),Lt=m.useMemo(()=>[...u,...d],[u,d]),Ls=m.useMemo(()=>Yr(Lt),[Lt]),Os=m.useMemo(()=>{const p=new Map;return Lt.forEach(S=>p.set(S.name,S)),p},[Lt]),Fs=m.useMemo(()=>new Set(d.map(p=>p.name)),[d]),Bs=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&I(JSON.parse(p));const S=localStorage.getItem("arcten-sidebar-width");S&&Q(parseInt(S));const N=localStorage.getItem("arcten-sidebar-height");N&&Ht(parseInt(N));const F=localStorage.getItem("arcten-sidebar-detached");F&&R(JSON.parse(F));const Y=localStorage.getItem("arcten-sidebar-position");if(Y){const it=JSON.parse(Y),K=50,Ct=Math.max(K-o,Math.min(it.x,window.innerWidth-K)),Pt=Math.max(0,Math.min(it.y,window.innerHeight-K));kt({x:Ct,y:Pt})}const C=localStorage.getItem("arcten-sidebar-minimized");C&&Z(JSON.parse(C)),Ve(!0)}},[]),m.useEffect(()=>((async()=>{try{const S=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:v})});if(!S.ok)throw new Error("Failed to fetch token");const N=await S.json();x(N.clientToken),T.current=N.clientToken,V(N.expiresAt),j(null)}catch(S){j(S instanceof Error?S.message:"Failed to fetch token")}})(),()=>{D.current&&clearTimeout(D.current)}),[g,v]),m.useEffect(()=>{if(!P)return;D.current&&clearTimeout(D.current);const p=Math.floor(Date.now()/1e3),S=P-p,F=Math.max(0,S-5);return console.log(`Token expires at ${new Date(P*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${F} seconds`),D.current=setTimeout(async()=>{console.log("Refreshing token...");try{const Y=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:v})});if(!Y.ok)throw new Error("Failed to refresh token");const C=await Y.json();x(C.clientToken),T.current=C.clientToken,V(C.expiresAt),j(null),console.log("Token refreshed successfully")}catch(Y){console.error("Token refresh failed:",Y),j(Y instanceof Error?Y.message:"Failed to refresh token")}},F*1e3),()=>{D.current&&clearTimeout(D.current)}},[P,g,v]),m.useEffect(()=>{(async()=>{if(Lt.length!==0)try{const S=Lt.map(F=>({name:F.name,code:F.toString()})),N=await fetch(`${y}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:S})});if(N.ok){const F=await N.json();na(F.tools)}}catch(S){console.error("Failed to fetch tool descriptions:",S)}})()},[Lt]),m.useEffect(()=>{Promise.resolve().then(()=>Sh).then(p=>{tt(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{ea(window.location.pathname)};p(),window.addEventListener("popstate",p);const S=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(S)}},[]);async function $s(){if(!(!v?.id||!w)){ke(!0);try{const S=await(await fetch(`${y}/conversations`,{headers:{Authorization:`Bearer ${w}`}})).json();Ns(S.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{ke(!1)}}}m.useEffect(()=>{v?.id&&w&&$s()},[v,w]);function sa(p){const S=Math.floor((Date.now()-p)/1e3);return S<60?"now":S<3600?`${Math.floor(S/60)}m`:S<86400?`${Math.floor(S/3600)}h`:`${Math.floor(S/86400)}d`}function ia(){const p=crypto.randomUUID();ln(p),Ie([]),Re([]),Ee(!1)}async function oa(p){if(w)try{await fetch(`${y}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${w}`}}),Ns(an.filter(S=>S._id!==p)),p===Is&&ia()}catch(S){console.error("Failed to delete conversation:",S)}}async function ra(p){ln(p.chatId),Ee(!1),ke(!0);try{const S=await fetch(`${y}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${T.current}`}});if(!S.ok)throw new Error(`Failed to fetch messages: ${S.statusText}`);const F=(await S.json()).messages||[];Ie(F),Re(F)}catch(S){console.error("Failed to load conversation messages:",S);const N=p.messages||[];Ie(N),Re(N)}finally{ke(!1)}}const aa=(async(p,S={})=>{const N=S.headers?new Headers(S.headers):new Headers;return N.delete("user-agent"),N.delete("User-Agent"),fetch(p,{...S,headers:N})}),{messages:ue,sendMessage:la,status:gt,error:zs,stop:Ne,addToolResult:de,setMessages:Ie}=lo.useChat({id:Is||void 0,transport:new He.DefaultChatTransport({api:`${y}/chat`,fetch:aa,headers:()=>{const p={};return T.current&&(p.Authorization=`Bearer ${T.current}`),p},body:()=>({tools:Ls.map(p=>({name:p.name,description:p.description,parameters:p.parametersDef})),systemPrompt:f,currentRoute:ta})}),sendAutomaticallyWhen:He.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{A&&E.current&&E.current.focus()},[A,ue]);function ca(){I(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function ua(){I(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[A]),m.useEffect(()=>{ce.current&&ce.current.scrollIntoView({behavior:"smooth"})},[ue]),m.useEffect(()=>{function p(S){S.key==="Escape"&&(gt==="streaming"||gt==="submitted")&&(S.preventDefault(),Ne())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[gt,Ne]);function da(){const p=crypto.randomUUID();ln(p),Ie([]),Re([]),Ee(!1)}function Us(p){if(p.preventDefault(),!k.trim())return;(gt==="streaming"||gt==="submitted")&&Ne();const S=Bs[Math.floor(Math.random()*Bs.length)]||"Thinking...";Qr(S),la({text:k}),_("")}function ha(p){const S=p.target.value;_(S)}m.useEffect(()=>{if(!St)return;function p(N){if(O){const F=N.clientX-W.x,Y=N.clientY-W.y;F>=a&&F<=l&&Q(F),Y>=400&&Y<=1e3&&Ht(Y)}else{const F=window.innerWidth-N.clientX;F>=a&&F<=l&&Q(F)}}function S(){pt(!1),localStorage.setItem("arcten-sidebar-width",L.toString()),localStorage.setItem("arcten-sidebar-height",ct.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",S)}},[St,L,ct,O,W,a,l]);function fa(p){p.preventDefault(),pt(!0)}function ma(){R(!0),Z(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function pa(){R(!1),Z(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ws(){Z(!B),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!B))}function ga(p){O&&(Nt(!0),De({x:p.clientX-W.x,y:p.clientY-W.y}))}return m.useEffect(()=>{if(!O)return;function p(){kt(S=>{const F=window.innerWidth-50,Y=window.innerHeight-50,C=50-L,it=0,K=Math.max(C,Math.min(S.x,F)),Ct=Math.max(it,Math.min(S.y,Y));if(K!==S.x||Ct!==S.y){const Pt={x:K,y:Ct};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(Pt)),Pt}return S})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[O,L]),m.useEffect(()=>{if(!Rt)return;function p(N){const F=N.clientX-le.x,Y=N.clientY-le.y,C=50,it=window.innerWidth-C,K=window.innerHeight-C,Ct=C-L,Pt=0,cn=Math.max(Ct,Math.min(F,it)),dt=Math.max(Pt,Math.min(Y,K));kt({x:cn,y:dt})}function S(){Nt(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(W))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",S)}},[Rt,le,W,L]),nn?b?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: ",b]})}):w?h.jsx(Lc,{features:hh,children:h.jsx($e,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:O?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:O?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
9
|
+
`),()=>{w.contains(v)&&w.removeChild(v)}},[e]),h.jsx(kc,{isPresent:e,childRef:r,sizeRef:o,children:vt.cloneElement(t,{ref:l})})}const Nc=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const c=Qn(Ic),u=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:u,initial:e,isPresent:n,custom:i,onExitComplete:g=>{c.set(g,!0);for(const y of c.values())if(!y)return;s&&s()},register:g=>(c.set(g,!1),()=>c.delete(g))}),[n,c,s]);return r&&d&&(f={...f}),m.useMemo(()=>{c.forEach((g,y)=>c.set(y,!1))},[n]),vt.useEffect(()=>{!n&&!c.size&&s&&s()},[n]),o==="popLayout"&&(t=h.jsx(Rc,{isPresent:n,anchorX:a,root:l,children:t})),h.jsx(Qe.Provider,{value:f,children:t})};function Ic(){return new Map}function or(t=!0){const e=m.useContext(Qe);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 Be=t=>t.key||"";function gi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Lc=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[c,u]=or(o),d=m.useMemo(()=>gi(t),[t]),f=o&&!c?[]:d.map(Be),g=m.useRef(!0),y=m.useRef(d),v=Qn(()=>new Map),[w,x]=m.useState(d),[T,b]=m.useState(d);mo(()=>{g.current=!1,y.current=d;for(let V=0;V<T.length;V++){const j=Be(T[V]);f.includes(j)?v.delete(j):v.get(j)!==!0&&v.set(j,!1)}},[T,f.length,f.join("-")]);const D=[];if(d!==w){let V=[...d];for(let j=0;j<T.length;j++){const A=T[j],I=Be(A);f.includes(I)||(V.splice(j,0,A),D.push(A))}return r==="wait"&&D.length&&(V=D),b(gi(V)),x(d),null}process.env.NODE_ENV!=="production"&&r==="wait"&&T.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(Jn);return h.jsx(h.Fragment,{children:T.map(V=>{const j=Be(V),A=o&&!c?!1:d===T||f.includes(j),I=()=>{if(v.has(j))v.set(j,!0);else return;let L=!0;v.forEach(Q=>{Q||(L=!1)}),L&&(P?.(),b(y.current),o&&u?.(),s&&s())};return h.jsx(Nc,{isPresent:A,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:A?void 0:I,anchorX:a,children:V},j)})})},Ss=m.createContext({strict:!1}),yi={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"]},ie={};for(const t in yi)ie[t]={isEnabled:e=>yi[t].some(n=>!!e[n])};function zn(t){for(const e in t)ie[e]={...ie[e],...t[e]}}function Oc({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!xn(e)),i=m.useRef(void 0);if(!xn(e)){const{renderer:r,...o}=e;i.current=r,zn(o)}return m.useEffect(()=>{xn(e)&&e().then(({renderer:r,...o})=>{zn(o),i.current=r,s(!0)})},[]),h.jsx(Ss.Provider,{value:{renderer:i.current,strict:n},children:t})}function xn(t){return typeof t=="function"}const Fc=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")||Fc.has(t)}let rr=t=>!Ze(t);function Bc(t){typeof t=="function"&&(rr=e=>e.startsWith("on")?!Ze(e):t(e))}try{Bc(require("@emotion/is-prop-valid").default)}catch{}function $c(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(rr(i)||n===!0&&Ze(i)||!e&&!Ze(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const tn=m.createContext({});function en(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Se(t){return typeof t=="string"||Array.isArray(t)}const Cs=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Ps=["initial",...Cs];function nn(t){return en(t.animate)||Ps.some(e=>Se(t[e]))}function ar(t){return!!(nn(t)||t.variants)}function zc(t,e){if(nn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Se(n)?n:void 0,animate:Se(s)?s:void 0}}return t.inherit!==!1?e:{}}function Uc(t){const{initial:e,animate:n}=zc(t,m.useContext(tn));return m.useMemo(()=>({initial:e,animate:n}),[xi(e),xi(n)])}function xi(t){return Array.isArray(t)?t.join(" "):t}const Ce={};function _c(t){for(const e in t)Ce[e]=t[e],ls(e)&&(Ce[e].isCSSVariable=!0)}function lr(t,{layout:e,layoutId:n}){return le.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Ce[t]||t==="opacity")}const Wc={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Kc=ae.length;function Hc(t,e,n){let s="",i=!0;for(let r=0;r<Kc;r++){const o=ae[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 c=Qo(a,vs[o]);if(!l){i=!1;const u=Wc[o]||o;s+=`${u}(${c}) `}n&&(e[o]=c)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function As(t,e,n){const{style:s,vars:i,transformOrigin:r}=t;let o=!1,a=!1;for(const l in e){const c=e[l];if(le.has(l)){o=!0;continue}else if(ls(l)){i[l]=c;continue}else{const u=Qo(c,vs[l]);l.startsWith("origin")?(a=!0,r[l]=u):s[l]=u}}if(e.transform||(o||n?s.transform=Hc(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:u=0}=r;s.transformOrigin=`${l} ${c} ${u}`}}const Ms=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function cr(t,e,n){for(const s in e)!J(e[s])&&!lr(s,n)&&(t[s]=e[s])}function Xc({transformTemplate:t},e){return m.useMemo(()=>{const n=Ms();return As(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Gc(t,e){const n=t.style||{},s={};return cr(s,n,t),Object.assign(s,Xc(t,e)),s}function Yc(t,e){const n={},s=Gc(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 qc={offset:"stroke-dashoffset",array:"stroke-dasharray"},Zc={offset:"strokeDashoffset",array:"strokeDasharray"};function Jc(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?qc:Zc;t[r.offset]=M.transform(-s);const o=M.transform(e),a=M.transform(n);t[r.array]=`${o} ${a}`}function ur(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,c,u){if(As(t,a,c),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=u?.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&&Jc(d,i,r,o,!1)}const dr=()=>({...Ms(),attrs:{}}),hr=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Qc(t,e,n,s){const i=m.useMemo(()=>{const r=dr();return ur(r,e,hr(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};cr(r,t.style,t),i.style={...r,...i.style}}return i}const tu=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Ds(t){return typeof t!="string"||t.includes("-")?!1:!!(tu.indexOf(t)>-1||/[A-Z]/u.test(t))}function eu(t,e,n,{latestValues:s},i,r=!1){const a=(Ds(t)?Qc:Yc)(e,s,i,t),l=$c(e,typeof t=="string",r),c=t!==m.Fragment?{...l,...a,ref:n}:{},{children:u}=e,d=m.useMemo(()=>J(u)?u.get():u,[u]);return m.createElement(t,{...c,children:d})}function vi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function js(t,e,n,s){if(typeof e=="function"){const[i,r]=vi(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]=vi(s);e=e(n!==void 0?n:t.custom,i,r)}return e}function We(t){return J(t)?t.get():t}function nu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:su(n,s,i,t),renderState:e()}}function su(t,e,n,s){const i={},r=s(t,{});for(const f in r)i[f]=We(r[f]);let{initial:o,animate:a}=t;const l=nn(t),c=ar(t);e&&c&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let u=n?n.initial===!1:!1;u=u||o===!1;const d=u?a:o;if(d&&typeof d!="boolean"&&!en(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=js(t,f[g]);if(y){const{transitionEnd:v,transition:w,...x}=y;for(const T in x){let b=x[T];if(Array.isArray(b)){const D=u?b.length-1:0;b=b[D]}b!==null&&(i[T]=b)}for(const T in v)i[T]=v[T]}}}return i}const fr=t=>(e,n)=>{const s=m.useContext(tn),i=m.useContext(Qe),r=()=>nu(t,e,s,i);return n?r():Qn(r)};function Vs(t,e,n){const{style:s}=t,i={};for(const r in s)(J(s[r])||e.style&&J(e.style[r])||lr(r,t)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const iu=fr({scrapeMotionValuesFromProps:Vs,createRenderState:Ms});function mr(t,e,n){const s=Vs(t,e,n);for(const i in t)if(J(t[i])||J(e[i])){const r=ae.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}const ou=fr({scrapeMotionValuesFromProps:mr,createRenderState:dr}),ru=Symbol.for("motionComponentSymbol");function Zt(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function au(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):Zt(n)&&(n.current=s))},[e])}const Es=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),lu="framerAppearId",pr="data-"+Es(lu),gr=m.createContext({});function cu(t,e,n,s,i){const{visualElement:r}=m.useContext(tn),o=m.useContext(Ss),a=m.useContext(Qe),l=m.useContext(Ts).reducedMotion,c=m.useRef(null);s=s||o.renderer,!c.current&&s&&(c.current=s(t,{visualState:e,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const u=c.current,d=m.useContext(gr);u&&!u.projection&&i&&(u.type==="html"||u.type==="svg")&&uu(c.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{u&&f.current&&u.update(n,a)});const g=n[pr],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return mo(()=>{u&&(f.current=!0,window.MotionIsMounted=!0,u.updateFeatures(),u.scheduleRenderMicrotask(),y.current&&u.animationState&&u.animationState.animateChanges())}),m.useEffect(()=>{u&&(!y.current&&u.animationState&&u.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),u.enteringChildren=void 0)}),u}function uu(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:c,layoutCrossfade:u}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:yr(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&Zt(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:u,layoutScroll:l,layoutRoot:c})}function yr(t){if(t)return t.options.allowProjection!==!1?t.projection:yr(t.parent)}function Ke(t,{forwardMotionProps:e=!1}={},n,s){n&&zn(n);const i=Ds(t)?ou:iu;function r(a,l){let c;const u={...m.useContext(Ts),...a,layoutId:du(a)},{isStatic:d}=u,f=Uc(a),g=i(a,d);if(!d&&ts){hu(u,n);const y=fu(u);c=y.MeasureLayout,f.visualElement=cu(t,g,u,s,y.ProjectionNode)}return h.jsxs(tn.Provider,{value:f,children:[c&&f.visualElement?h.jsx(c,{visualElement:f.visualElement,...u}):null,eu(t,a,au(g,f.visualElement,l),g,d,e)]})}r.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const o=m.forwardRef(r);return o[ru]=t,o}function du({layoutId:t}){const e=m.useContext(Jn).id;return e&&t!==void 0?e+"-"+t:t}function hu(t,e){const n=m.useContext(Ss).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?oe(!1,s,"lazy-strict-mode"):Tt(!1,s,"lazy-strict-mode")}}function fu(t){const{drag:e,layout:n}=ie;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function mu(t,e){if(typeof Proxy>"u")return Ke;const n=new Map,s=(r,o)=>Ke(r,o,t,e),i=(r,o)=>(process.env.NODE_ENV!=="production"&&os(!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,Ke(o,void 0,t,e)),n.get(o))})}function xr({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function pu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function gu(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 vn(t){return t===void 0||t===1}function Un({scale:t,scaleX:e,scaleY:n}){return!vn(t)||!vn(e)||!vn(n)}function Ut(t){return Un(t)||vr(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function vr(t){return bi(t.x)||bi(t.y)}function bi(t){return t&&t!=="0%"}function Je(t,e,n){const s=t-n,i=e*s;return n+i}function wi(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=wi(t.min,e,n,s,i),t.max=wi(t.max,e,n,s,i)}function br(t,{x:e,y:n}){_n(t.x,e.translate,e.scale,e.originPoint),_n(t.y,n.translate,n.scale,n.originPoint)}const Ti=.999999999999,Si=1.0000000000001;function yu(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&&Qt(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,br(t,o)),s&&Ut(r.latestValues)&&Qt(t,r.latestValues))}e.x<Si&&e.x>Ti&&(e.x=1),e.y<Si&&e.y>Ti&&(e.y=1)}function Jt(t,e){t.min=t.min+e,t.max=t.max+e}function Ci(t,e,n,s,i=.5){const r=U(t.min,t.max,i);_n(t,e,n,r,s)}function Qt(t,e){Ci(t.x,e.x,e.scaleX,e.scale,e.originX),Ci(t.y,e.y,e.scaleY,e.scale,e.originY)}function wr(t,e){return xr(gu(t.getBoundingClientRect(),e))}function xu(t,e,n){const s=wr(t,n),{scroll:i}=e;return i&&(Jt(s.x,i.offset.x),Jt(s.y,i.offset.y)),s}const Pi=()=>({translate:0,scale:1,origin:0,originPoint:0}),te=()=>({x:Pi(),y:Pi()}),Ai=()=>({min:0,max:0}),H=()=>({x:Ai(),y:Ai()}),Wn={current:null},Tr={current:!1};function vu(){if(Tr.current=!0,!!ts)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Wn.current=t.matches;t.addEventListener("change",e),e()}else Wn.current=!1}const bu=new WeakMap;function wu(t,e,n){for(const s in e){const i=e[s],r=n[s];if(J(i))t.addValue(s,i);else if(J(r))t.addValue(s,se(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,se(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Mi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Tu{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=ys,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,$.render(this.render,!1,!0))};const{latestValues:l,renderState:c}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=c,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=nn(n),this.isVariantNode=ar(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:u,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];l[f]!==void 0&&J(g)&&g.set(l[f])}}mount(e){this.current=e,bu.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)),Tr.current||vu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Wn.current,process.env.NODE_ENV!=="production"&&os(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(),Vt(this.notifyUpdate),Vt(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=le.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&$.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 ie){const n=ie[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):H()}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<Mi.length;s++){const i=Mi[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=wu(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=se(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"&&(po(s)||yo(s))?s=parseFloat(s):!jc(s)&&Et.test(n)&&(s=Jo(e,n)),this.setBaseTarget(e,J(s)?s.get():s)),J(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=js(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&&!J(i)?i:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new is),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){bs.render(this.render)}}class Sr extends Tu{constructor(){super(...arguments),this.KeyframeResolver=yc}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;J(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Cr(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 Su(t){return window.getComputedStyle(t)}class Cu extends Sr{constructor(){super(...arguments),this.type="html",this.renderInstance=Cr}readValueFromInstance(e,n){if(le.has(n))return this.projection?.isProjecting?Nn(n):Il(e,n);{const s=Su(e),i=(ls(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return wr(e,n)}build(e,n,s){As(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return Vs(e,n,s)}}const Pr=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 Pu(t,e,n,s){Cr(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Pr.has(i)?i:Es(i),e.attrs[i])}class Au extends Sr{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=H}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(le.has(n)){const s=Zo(n);return s&&s.default||0}return n=Pr.has(n)?n:Es(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return mr(e,n,s)}build(e,n,s){ur(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Pu(e,n,s,i)}mount(e){this.isSVGTag=hr(e.tagName),super.mount(e)}}const Ar=(t,e)=>Ds(t)?new Au(e):new Cu(e,{allowProjection:t!==m.Fragment});function ne(t,e,n){const s=t.getProps();return js(s,e,n!==void 0?n:s.custom,t)}const Kn=t=>Array.isArray(t);function Mu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,se(n))}function Du(t){return Kn(t)?t[t.length-1]||0:t}function ju(t,e){const n=ne(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=Du(r[o]);Mu(t,o,a)}}function Vu(t){return!!(J(t)&&t.add)}function Hn(t,e){const n=t.getValue("willChange");if(Vu(n))return n.add(e);if(!n&&St.WillChange){const s=new St.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Mr(t){return t.props[pr]}const Eu=t=>t!==null;function ku(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Eu),r=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[r]}const Ru={type:"spring",stiffness:500,damping:25,restSpeed:10},Nu=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Iu={type:"keyframes",duration:.8},Lu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Ou=(t,{keyframes:e})=>e.length>2?Iu:le.has(t)?t.startsWith("scale")?Nu(e[1]):Ru:Lu;function Fu({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:c,...u}){return!!Object.keys(u).length}const ks=(t,e,n,s={},i,r)=>o=>{const a=xs(s,t)||{},l=a.delay||s.delay||0;let{elapsed:c=0}=s;c=c-mt(l);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-c,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};Fu(a)||Object.assign(u,Ou(t,u)),u.duration&&(u.duration=mt(u.duration)),u.repeatDelay&&(u.repeatDelay=mt(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Bn(u),u.delay===0&&(d=!0)),(St.instantAnimations||St.skipAnimations)&&(d=!0,Bn(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,d&&!r&&e.get()!==void 0){const f=ku(u.keyframes,a);if(f!==void 0){$.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new gs(u):new ic(u)};function Bu({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Dr(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=t.getDefaultTransition(),transitionEnd:o,...a}=e;s&&(r=s);const l=[],c=i&&t.animationState&&t.animationState.getState()[i];for(const u in a){const d=t.getValue(u,t.latestValues[u]??null),f=a[u];if(f===void 0||c&&Bu(c,u))continue;const g={delay:n,...xs(r||{},u)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=Mr(t);if(x){const T=window.MotionHandoffAnimation(x,u,$);T!==null&&(g.startTime=T,v=!0)}}Hn(t,u),d.start(ks(u,d,f,t.shouldReduceMotion&&Go.has(u)?{type:!1}:g,t,v));const w=d.animation;w&&l.push(w)}return o&&Promise.all(l).then(()=>{$.update(()=>{o&&ju(t,o)})}),l}function jr(t,e,n,s=0,i=1){const r=Array.from(t).sort((c,u)=>c.sortNodePosition(u)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Xn(t,e,n={}){const s=ne(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(Dr(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:c=0,staggerChildren:u,staggerDirection:d}=i;return $u(t,e,l,c,u,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,c]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>c())}else return Promise.all([r(),o(n.delay)])}function $u(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(Xn(l,e,{...o,delay:n+(typeof s=="function"?0:s)+jr(t.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function zu(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(r=>Xn(t,r,n));s=Promise.all(i)}else if(typeof e=="string")s=Xn(t,e,n);else{const i=typeof e=="function"?ne(t,e,n.custom):e;s=Promise.all(Dr(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function Vr(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 Uu=Ps.length;function Er(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Er(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Uu;n++){const s=Ps[n],i=t.props[s];(Se(i)||i===!1)&&(e[s]=i)}return e}const _u=[...Cs].reverse(),Wu=Cs.length;function Ku(t){return e=>Promise.all(e.map(({animation:n,options:s})=>zu(t,n,s)))}function Hu(t){let e=Ku(t),n=Di(),s=!0;const i=l=>(c,u)=>{const d=ne(t,u,l==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;c={...c,...y,...g}}return c};function r(l){e=l(t)}function o(l){const{props:c}=t,u=Er(t.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let w=0;w<Wu;w++){const x=_u[w],T=n[x],b=c[x]!==void 0?c[x]:u[x],D=Se(b),P=x===l?T.isActive:null;P===!1&&(y=w);let V=b===u[x]&&b!==c[x]&&D;if(V&&s&&t.manuallyAnimateOnMount&&(V=!1),T.protectedKeys={...g},!T.isActive&&P===null||!b&&!T.prevProp||en(b)||typeof b=="boolean")continue;const j=Xu(T.prevProp,b);let A=j||x===l&&T.isActive&&!V&&D||w>y&&D,I=!1;const L=Array.isArray(b)?b:[b];let Q=L.reduce(i(x),{});P===!1&&(Q={});const{prevResolvedValues:ut={}}=T,Xt={...ut,...Q},Ct=R=>{A=!0,f.has(R)&&(I=!0,f.delete(R)),T.needsAnimating[R]=!0;const B=t.getValue(R);B&&(B.liveStyle=!1)};for(const R in Xt){const B=Q[R],Z=ut[R];if(g.hasOwnProperty(R))continue;let _=!1;Kn(B)&&Kn(Z)?_=!Vr(B,Z):_=B!==Z,_?B!=null?Ct(R):f.add(R):B!==void 0&&f.has(R)?Ct(R):T.protectedKeys[R]=!0}T.prevProp=b,T.prevResolvedValues=Q,T.isActive&&(g={...g,...Q}),s&&t.blockInitialAnimation&&(A=!1);const gt=V&&j;A&&(!gt||I)&&d.push(...L.map(R=>{const B={type:x};if(typeof R=="string"&&s&&!gt&&t.manuallyAnimateOnMount&&t.parent){const{parent:Z}=t,_=ne(Z,R);if(Z.enteringChildren&&_){const{delayChildren:Rt}=_.transition||{};B.delay=jr(Z.enteringChildren,t,Rt)}}return{animation:R,options:B}}))}if(f.size){const w={};if(typeof c.initial!="boolean"){const x=ne(t,Array.isArray(c.initial)?c.initial[0]:c.initial);x&&x.transition&&(w.transition=x.transition)}f.forEach(x=>{const T=t.getBaseTarget(x),b=t.getValue(x);b&&(b.liveStyle=!0),w[x]=T??null}),d.push({animation:w})}let v=!!d.length;return s&&(c.initial===!1||c.initial===c.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(l,c){if(n[l].isActive===c)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(l,c)),n[l].isActive=c;const u=o(l);for(const d in n)n[d].protectedKeys={};return u}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Di()}}}function Xu(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Vr(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 kt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Gu extends kt{constructor(e){super(e),e.animationState||(e.animationState=Hu(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();en(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Yu=0;class qu extends kt{constructor(){super(...arguments),this.id=Yu++}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 kr={animation:{Feature:Gu},exit:{Feature:qu}};function Pe(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function je(t){return{point:{x:t.pageX,y:t.pageY}}}const Zu=t=>e=>ws(e)&&t(e,je(e));function ye(t,e,n,s){return Pe(t,e,Zu(n),s)}const Rr=1e-4,Ju=1-Rr,Qu=1+Rr,Nr=.01,td=0-Nr,ed=0+Nr;function et(t){return t.max-t.min}function nd(t,e,n){return Math.abs(t-e)<=n}function ji(t,e,n,s=.5){t.origin=s,t.originPoint=U(e.min,e.max,t.origin),t.scale=et(n)/et(e),t.translate=U(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Ju&&t.scale<=Qu||isNaN(t.scale))&&(t.scale=1),(t.translate>=td&&t.translate<=ed||isNaN(t.translate))&&(t.translate=0)}function xe(t,e,n,s){ji(t.x,e.x,n.x,s?s.originX:void 0),ji(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+et(e)}function sd(t,e,n){Vi(t.x,e.x,n.x),Vi(t.y,e.y,n.y)}function Ei(t,e,n){t.min=e.min-n.min,t.max=t.min+et(e)}function ve(t,e,n){Ei(t.x,e.x,n.x),Ei(t.y,e.y,n.y)}function at(t){return[t("x"),t("y")]}const Ir=({current:t})=>t?t.ownerDocument.defaultView:null,ki=(t,e)=>Math.abs(t-e);function id(t,e){const n=ki(t.x,e.x),s=ki(t.y,e.y);return Math.sqrt(n**2+s**2)}class Lr{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=wn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=id(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:v}=f,{timestamp:w}=q;this.history.push({...v,timestamp:w});const{onStart:x,onMove:T}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=bn(g,this.transformPagePoint),$.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:v,resumeAnimation:w}=this.handlers;if(this.dragSnapToOrigin&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=wn(f.type==="pointercancel"?this.lastMoveEventInfo:bn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!ws(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=je(e),l=bn(a,this.transformPagePoint),{point:c}=l,{timestamp:u}=q;this.history=[{...c,timestamp:u}];const{onSessionStart:d}=n;d&&d(e,wn(l,this.history)),this.removeListeners=Ae(ye(this.contextWindow,"pointermove",this.handlePointerMove),ye(this.contextWindow,"pointerup",this.handlePointerUp),ye(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Vt(this.updatePoint)}}function bn(t,e){return e?{point:e(t.point)}:t}function Ri(t,e){return{x:t.x-e.x,y:t.y-e.y}}function wn({point:t},e){return{point:t,delta:Ri(t,Or(e)),offset:Ri(t,od(e)),velocity:rd(e,.1)}}function od(t){return t[0]}function Or(t){return t[t.length-1]}function rd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Or(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>mt(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 ad(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?U(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?U(n,t,s.max):Math.min(t,n)),t}function Ni(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 ld(t,{top:e,left:n,bottom:s,right:i}){return{x:Ni(t.x,n,i),y:Ni(t.y,e,s)}}function Ii(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 cd(t,e){return{x:Ii(t.x,e.x),y:Ii(t.y,e.y)}}function ud(t,e){let n=.5;const s=et(t),i=et(e);return i>s?n=be(e.min,e.max-s,t.min):s>i&&(n=be(t.min,t.max-i,e.min)),wt(0,1,n)}function dd(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 hd(t=Gn){return t===!1?t=0:t===!0&&(t=Gn),{x:Li(t,"left","right"),y:Li(t,"top","bottom")}}function Li(t,e,n){return{min:Oi(t,e),max:Oi(t,n)}}function Oi(t,e){return typeof t=="number"?t:t[e]||0}const fd=new WeakMap;class md{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=H(),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(je(d).point)},o=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=wc(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),at(x=>{let T=this.getAxisMotionValue(x).get()||0;if(bt.test(T)){const{projection:b}=this.visualElement;if(b&&b.layout){const D=b.layout.layoutBox[x];D&&(T=et(D)*(parseFloat(T)/100))}}this.originPoint[x]=T}),v&&$.postRender(()=>v(d,f)),Hn(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:v,onDrag:w}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:x}=f;if(y&&this.currentDirection===null){this.currentDirection=pd(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),w&&w(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>at(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:u}=this.getProps();this.panSession=new Lr(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:s,contextWindow:Ir(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&&$.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||!$e(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=ad(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&&Zt(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=ld(s.layoutBox,e):this.constraints=!1,this.elastic=hd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&at(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=dd(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Zt(e))return!1;const s=e.current;Tt(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=xu(s,i.root,this.visualElement.getTransformPagePoint());let o=cd(i.layout.layoutBox,r);if(n){const a=n(pu(o));this.hasMutatedConstraints=!!a,a&&(o=xr(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=at(u=>{if(!$e(u,n,this.currentDirection))return;let d=l&&l[u]||{};o&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?e[u]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(u,y)});return Promise.all(c).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Hn(this.visualElement,e),s.start(ks(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(!$e(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]-U(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Zt(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]=ud({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(!$e(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:c}=this.constraints[o];a.set(U(l,c,i[o]))})}addListeners(){if(!this.visualElement.current)return;fd.set(this.visualElement,this);const e=this.visualElement.current,n=ye(e,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps();c&&u&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Zt(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()),$.read(s);const o=Pe(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(at(u=>{const d=this.getAxisMotionValue(u);d&&(this.originPoint[u]+=l[u].translate,d.set(d.get()+l[u].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 $e(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function pd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class gd extends kt{constructor(e){super(e),this.removeGroupControls=ct,this.removeListeners=ct,this.controls=new md(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 Fi=t=>(e,n)=>{t&&$.postRender(()=>t(e,n))};class yd extends kt{constructor(){super(...arguments),this.removePointerDownListener=ct}onPointerDown(e){this.session=new Lr(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ir(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Fi(e),onStart:Fi(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&$.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=ye(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 He={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Bi(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const me={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(M.test(t))t=parseFloat(t);else return t;const n=Bi(t,e.target.x),s=Bi(t,e.target.y);return`${n}% ${s}%`}},xd={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 c=U(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=c),typeof i[3+o]=="number"&&(i[3+o]/=c),r(i)}};let Tn=!1;class vd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=e;_c(bd),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),Tn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),He.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,Tn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==r?o.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?o.promote():o.relegate()||$.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),bs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;Tn=!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 Fr(t){const[e,n]=or(),s=m.useContext(Jn);return h.jsx(vd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(gr),isPresent:e,safeToRemove:n})}const bd={borderRadius:{...me,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:me,borderTopRightRadius:me,borderBottomLeftRadius:me,borderBottomRightRadius:me,boxShadow:xd};function wd(t,e,n){const s=J(t)?t:se(t);return s.start(ks("",s,e,n)),s.animation}const Td=(t,e)=>t.depth-e.depth;class Sd{constructor(){this.children=[],this.isDirty=!1}add(e){es(this.children,e),this.isDirty=!0}remove(e){ns(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Td),this.isDirty=!1,this.children.forEach(e)}}function Cd(t,e){const n=it.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(Vt(s),t(r-e))};return $.setup(s,!0),()=>Vt(s)}const Br=["TopLeft","TopRight","BottomLeft","BottomRight"],Pd=Br.length,$i=t=>typeof t=="string"?parseFloat(t):t,zi=t=>typeof t=="number"||M.test(t);function Ad(t,e,n,s,i,r){i?(t.opacity=U(0,n.opacity??1,Md(s)),t.opacityExit=U(e.opacity??1,0,Dd(s))):r&&(t.opacity=U(e.opacity??1,n.opacity??1,s));for(let o=0;o<Pd;o++){const a=`border${Br[o]}Radius`;let l=Ui(e,a),c=Ui(n,a);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||zi(l)===zi(c)?(t[a]=Math.max(U($i(l),$i(c),s),0),(bt.test(c)||bt.test(l))&&(t[a]+="%")):t[a]=c}(e.rotate||n.rotate)&&(t.rotate=U(e.rotate||0,n.rotate||0,s))}function Ui(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Md=$r(0,.5,Po),Dd=$r(.5,.95,ct);function $r(t,e,n){return s=>s<t?0:s>e?1:n(be(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 Wi(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function Ki(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 jd(t,e=0,n=1,s=.5,i,r=t,o=t){if(bt.test(e)&&(e=parseFloat(e),e=U(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=U(r.min,r.max,s);t===r&&(a-=e),t.min=Ki(t.min,e,n,a,i),t.max=Ki(t.max,e,n,a,i)}function Hi(t,e,[n,s,i],r,o){jd(t,e[n],e[s],e[i],e.scale,r,o)}const Vd=["x","scaleX","originX"],Ed=["y","scaleY","originY"];function Xi(t,e,n,s){Hi(t.x,e,Vd,n?n.x:void 0,s?s.x:void 0),Hi(t.y,e,Ed,n?n.y:void 0,s?s.y:void 0)}function Gi(t){return t.translate===0&&t.scale===1}function zr(t){return Gi(t.x)&&Gi(t.y)}function Yi(t,e){return t.min===e.min&&t.max===e.max}function kd(t,e){return Yi(t.x,e.x)&&Yi(t.y,e.y)}function qi(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Ur(t,e){return qi(t.x,e.x)&&qi(t.y,e.y)}function Zi(t){return et(t.x)/et(t.y)}function Ji(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Rd{constructor(){this.members=[]}add(e){es(this.members,e),e.scheduleRender()}remove(e){if(ns(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 Nd(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:c,rotate:u,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;c&&(s=`perspective(${c}px) ${s}`),u&&(s+=`rotate(${u}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}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 Sn=["","X","Y","Z"],Id=1e3;let Ld=0;function Cn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function _r(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Mr(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",$,!(i||r))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&_r(s)}function Wr({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Ld++,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(Bd),this.nodes.forEach(_d),this.nodes.forEach(Wd),this.nodes.forEach($d)},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 Sd)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new is),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=ir(o)&&!Mc(o),this.instance=o;const{layoutId:a,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let u,d=0;const f=()=>this.root.updateBlockedByResize=!1;$.read(()=>{d=window.innerWidth}),t(o,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,u&&u(),u=Cd(f,250),He.hasAnimatedSinceResize&&(He.hasAnimatedSinceResize=!1,this.nodes.forEach(eo)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||c.getDefaultTransition()||Yd,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=c.getProps(),x=!this.targetLayout||!Ur(this.targetLayout,g),T=!d&&f;if(this.options.layoutRoot||this.resumeFrom||T||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...xs(y,"layout"),onPlay:v,onComplete:w};(c.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(u,T)}else d||eo(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}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(),Vt(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(Kd),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&&_r(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const d=this.path[u];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 c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Qi);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(to);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Ud),this.nodes.forEach(Od),this.nodes.forEach(Fd)):this.nodes.forEach(to),this.clearAllSnapshots();const a=it.now();q.delta=wt(0,1e3/60,a-q.timestamp),q.timestamp=a,q.isProcessing=!0,hn.update.process(q),hn.preRender.process(q),hn.render.process(q),q.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,bs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(zd),this.sharedNodes.forEach(Hd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,$.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){$.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!et(this.snapshot.measuredBox.x)&&!et(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=H(),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&&!zr(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;o&&this.instance&&(a||Ut(this.latestValues)||u)&&(i(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),qd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return H();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Zd))){const{scroll:c}=this.root;c&&(Jt(a.x,c.offset.x),Jt(a.y,c.offset.y))}return a}removeElementScroll(o){const a=H();if(rt(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const c=this.path[l],{scroll:u,options:d}=c;c!==this.root&&u&&d.layoutScroll&&(u.wasRoot&&rt(a,o),Jt(a.x,u.offset.x),Jt(a.y,u.offset.y))}return a}applyTransform(o,a=!1){const l=H();rt(l,o);for(let c=0;c<this.path.length;c++){const u=this.path[c];!a&&u.options.layoutScroll&&u.scroll&&u!==u.root&&Qt(l,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),Ut(u.latestValues)&&Qt(l,u.latestValues)}return Ut(this.latestValues)&&Qt(l,this.latestValues),l}removeTransform(o){const a=H();rt(a,o);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!c.instance||!Ut(c.latestValues))continue;Un(c.latestValues)&&c.updateSnapshot();const u=H(),d=c.measurePageBox();rt(u,d),Xi(a,c.latestValues,c.snapshot?c.snapshot.layoutBox:void 0,u)}return Ut(this.latestValues)&&Xi(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:u,layoutId:d}=this.options;if(!(!this.layout||!(u||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=H(),this.relativeTargetOrigin=H(),ve(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=H(),this.targetWithTransforms=H()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),sd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):rt(this.target,this.layout.layoutBox),br(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=H(),this.relativeTargetOrigin=H(),ve(this.relativeTargetOrigin,this.target,f.target),rt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Un(this.parent.latestValues)||vr(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:c,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||u))return;rt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;yu(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=H());const{target:g}=o;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Wi(this.prevProjectionDelta.x,this.projectionDelta.x),Wi(this.prevProjectionDelta.y,this.projectionDelta.y)),xe(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Ji(this.projectionDelta.x,this.prevProjectionDelta.x)||!Ji(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}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=te(),this.projectionDelta=te(),this.projectionDeltaWithTransform=te()}setAnimationOrigin(o,a=!1){const l=this.snapshot,c=l?l.latestValues:{},u={...this.latestValues},d=te();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=H(),g=l?l.source:void 0,y=this.layout?this.layout.source:void 0,v=g!==y,w=this.getStack(),x=!w||w.members.length<=1,T=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(Gd));this.animationProgress=0;let b;this.mixTargetDelta=D=>{const P=D/1e3;no(d.x,o.x,P),no(d.y,o.y,P),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ve(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Xd(this.relativeTarget,this.relativeTargetOrigin,f,P),b&&kd(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=H()),rt(b,this.relativeTarget)),v&&(this.animationValues=u,Ad(u,c,this.latestValues,P,T,x)),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&&(Vt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=$.update(()=>{He.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=se(0)),this.currentAnimation=wd(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(Id),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:c,latestValues:u}=o;if(!(!a||!l||!c)){if(this!==o&&this.layout&&c&&Kr(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||H();const d=et(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=et(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}rt(a,l),Qt(a,u),xe(this.projectionDeltaWithTransform,this.layoutCorrected,a,u)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Rd),this.sharedNodes.get(o).add(a);const c=a.options.initialPromotionConfig;a.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.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 c=this.getStack();c&&c.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 c={};l.z&&Cn("z",o,c,this.animationValues);for(let u=0;u<Sn.length;u++)Cn(`rotate${Sn[u]}`,o,c,this.animationValues),Cn(`skew${Sn[u]}`,o,c,this.animationValues);o.render();for(const u in c)o.setStaticValue(u,c[u]),this.animationValues&&(this.animationValues[u]=c[u]);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=We(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=We(a?.pointerEvents)||""),this.hasProjected&&!Ut(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let d=Nd(this.projectionDeltaWithTransform,this.treeScale,u);l&&(d=l(u,d)),o.transform=d;const{x:f,y:g}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,c.animationValues?o.opacity=c===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:o.opacity=c===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const y in Ce){if(u[y]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:x}=Ce[y],T=d==="none"?u[y]:v(u[y],c);if(w){const b=w.length;for(let D=0;D<b;D++)o[w[D]]=T}else x?this.options.visualElement.renderState.vars[y]=T:o[y]=T}this.options.layoutId&&(o.pointerEvents=c===this?We(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(Qi),this.root.sharedNodes.clear()}}}function Od(t){t.updateLayout()}function Fd(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(u=>{const d=r?e.measuredBox[u]:e.layoutBox[u],f=et(d);d.min=n[u].min,d.max=d.min+f}):Kr(i,e.layoutBox,n)&&at(u=>{const d=r?e.measuredBox[u]:e.layoutBox[u],f=et(n[u]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[u].max=t.relativeTarget[u].min+f)});const o=te();xe(o,n,e.layoutBox);const a=te();r?xe(a,t.applyTransform(s,!0),e.measuredBox):xe(a,n,e.layoutBox);const l=!zr(o);let c=!1;if(!t.resumeFrom){const u=t.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:d,layout:f}=u;if(d&&f){const g=H();ve(g,e.layoutBox,d.layoutBox);const y=H();ve(y,n,f.layoutBox),Ur(g,y)||(c=!0),u.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=g,t.relativeParent=u)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Bd(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 $d(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function zd(t){t.clearSnapshot()}function Qi(t){t.clearMeasurements()}function to(t){t.isLayoutDirty=!1}function Ud(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function eo(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function _d(t){t.resolveTargetDelta()}function Wd(t){t.calcProjection()}function Kd(t){t.resetSkewAndRotation()}function Hd(t){t.removeLeadSnapshot()}function no(t,e,n){t.translate=U(e.translate,0,n),t.scale=U(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function so(t,e,n,s){t.min=U(e.min,n.min,s),t.max=U(e.max,n.max,s)}function Xd(t,e,n,s){so(t.x,e.x,n.x,s),so(t.y,e.y,n.y,s)}function Gd(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Yd={duration:.45,ease:[.4,0,.1,1]},io=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),oo=io("applewebkit/")&&!io("chrome/")?Math.round:ct;function ro(t){t.min=oo(t.min),t.max=oo(t.max)}function qd(t){ro(t.x),ro(t.y)}function Kr(t,e,n){return t==="position"||t==="preserve-aspect"&&!nd(Zi(e),Zi(n),.2)}function Zd(t){return t!==t.root&&t.scroll?.wasRoot}const Jd=Wr({attachResizeListener:(t,e)=>Pe(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Pn={current:void 0},Hr=Wr({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Pn.current){const t=new Jd({});t.mount(window),t.setOptions({layoutScroll:!0}),Pn.current=t}return Pn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Qd={pan:{Feature:yd},drag:{Feature:gd,ProjectionNode:Hr,MeasureLayout:Fr}};function ao(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&&$.postRender(()=>r(e,je(e)))}class th extends kt{mount(){const{current:e}=this.node;e&&(this.unmount=Tc(e,(n,s)=>(ao(this.node,s,"Start"),i=>ao(this.node,i,"End"))))}unmount(){}}class eh extends kt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Ae(Pe(this.node.current,"focus",()=>this.onFocus()),Pe(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function lo(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&&$.postRender(()=>r(e,je(e)))}class nh extends kt{mount(){const{current:e}=this.node;e&&(this.unmount=Ac(e,(n,s)=>(lo(this.node,s,"Start"),(i,{success:r})=>lo(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Yn=new WeakMap,An=new WeakMap,sh=t=>{const e=Yn.get(t.target);e&&e(t)},ih=t=>{t.forEach(sh)};function oh({root:t,...e}){const n=t||document;An.has(n)||An.set(n,{});const s=An.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(ih,{root:t,...e})),s[i]}function rh(t,e,n){const s=oh(e);return Yn.set(t,n),s.observe(t),()=>{Yn.delete(t),s.unobserve(t)}}const ah={some:0,all:1};class lh extends kt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:r}=e,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:ah[i]},a=l=>{const{isIntersecting:c}=l;if(this.isInView===c||(this.isInView=c,r&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:u,onViewportLeave:d}=this.node.getProps(),f=c?u:d;f&&f(l)};return rh(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(ch(e,n))&&this.startObserver()}unmount(){}}function ch({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Xr={inView:{Feature:lh},tap:{Feature:nh},focus:{Feature:eh},hover:{Feature:th}},uh={layout:{ProjectionNode:Hr,MeasureLayout:Fr}},dh={...kr,...Xr,...Qd,...uh},hh=mu(dh,Ar),fh={renderer:Ar,...kr,...Xr};function Gr(t,e){return Ke(t,e)}const ze=Gr("div"),mh=Gr("p");function ph(t){const e=t.name||"unnamed",n=gh(t),{schema:s,def:i}=yh(t);return{name:e,description:n,parameters:s,parametersDef:i}}function gh(t){const n=t.toString().match(/\/\*\*\s*\n([^*]|\*[^/])*\*\//);if(n){const i=n[0].match(/\/\*\*\s*\n\s*\*\s*([^\n@]+)/);if(i&&i[1])return i[1].trim()}return`Execute ${t.name||"function"}`}function yh(t){const n=t.toString().match(/\(([^)]*)\)/);if(!n||!n[1]||!n[1].trim())return{schema:Dt.z.object({}),def:{}};const i=n[1].split(",").map(a=>a.trim()),r={},o={};for(const a of i){const l=a.match(/(\w+)\s*:\s*(\w+)/);if(l&&l[1]&&l[2]){const c=l[1];switch(l[2].toLowerCase()){case"string":r[c]=Dt.z.string().describe(c),o[c]={type:"string",description:c};break;case"number":r[c]=Dt.z.number().describe(c),o[c]={type:"number",description:c};break;case"boolean":r[c]=Dt.z.boolean().describe(c),o[c]={type:"boolean",description:c};break;case"any":r[c]=Dt.z.any().describe(c),o[c]={type:"any",description:c};break;default:r[c]=Dt.z.string().describe(c),o[c]={type:"string",description:c}}}else{const c=a.match(/(\w+)/);if(c&&c[1]){const u=c[1];r[u]=Dt.z.string().describe(u),o[u]={type:"string",description:u}}}}return{schema:Dt.z.object(r),def:o}}function Yr(t){return t.map(ph)}function xh({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(xt,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(Y.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(Y.X,{className:"h-3 w-3"})})]})]})})}function vh({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,r]=m.useState(!1),o=Object.keys(e).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>o&&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"} ${o?"cursor-pointer hover:bg-opacity-80":""}`,children:[o&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(Y.ChevronDown,{className:"h-3 w-3"}):h.jsx(Y.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(Y.X,{className:"h-3 w-3"}):s?h.jsx(Y.Zap,{className:"h-3 w-3"}):h.jsx(Y.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&o&&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(e).map(([a,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[a,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},a))})})]})}function bh({...t}){return h.jsx(Zn.Root,{"data-slot":"collapsible",...t})}function wh({...t}){return h.jsx(Zn.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Th({...t}){return h.jsx(Zn.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Sh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),Rs=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Sh,{className:pt("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);Rs.displayName="Response";const Ch=Object.freeze(Object.defineProperty({__proto__:null,Response:Rs},Symbol.toStringTag,{value:"Module"})),Ph=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const r=hh.create(e),o=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(r,{animate:{backgroundPosition:"0% center"},className:pt("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})},Ah=m.memo(Ph),qr=m.createContext(null),Mh=()=>{const t=m.useContext(qr);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Dh=1e3,jh=1e3,Zr=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:r,children:o,...a})=>{const[l,c]=Hs.useControllableState({prop:n,defaultProp:s,onChange:i}),[u,d]=Hs.useControllableState({prop:r,defaultProp:0}),[f,g]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{e?y===null&&v(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/jh)),v(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&l&&!f){const x=setTimeout(()=>{c(!1),g(!0)},Dh);return()=>clearTimeout(x)}},[e,l,s,c,f]);const w=x=>{c(x)};return h.jsx(qr.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:c,duration:u},children:h.jsx(bh,{className:pt("not-prose mb-4",t),onOpenChange:w,open:l,...a,children:o})})}),Vh=(t,e)=>t||e===0?h.jsx(Ah,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Jr=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:r}=Mh();return h.jsx(wh,{className:pt("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(Y.BrainIcon,{className:"size-4"}),Vh(s,r),h.jsx(Y.ChevronDownIcon,{className:pt("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Qr=m.memo(({className:t,children:e,...n})=>h.jsx(Th,{className:pt("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(Rs,{className:"grid gap-2",children:e})}));Zr.displayName="Reasoning";Jr.displayName="ReasoningTrigger";Qr.displayName="ReasoningContent";function Eh({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:c=!1,tools:u=[],safeTools:d=[],systemPrompt:f="",tokenEndpoint:g="/api/arcten/token",apiBaseUrl:y="https://api.arcten.com",user:v}){const[w,x]=m.useState(null),T=m.useRef(null),[b,D]=m.useState(null),[P,V]=m.useState(null),j=m.useRef(null),[A,I]=m.useState(c),[L,Q]=m.useState(o),[ut,Xt]=m.useState(600),[Ct,gt]=m.useState(!1),[O,R]=m.useState(!1),[B,Z]=m.useState(!1),[_,Rt]=m.useState({x:100,y:100}),[Nt,It]=m.useState(!1),[ce,Ve]=m.useState({x:0,y:0}),[sn,Ee]=m.useState(!1),ue=m.useRef(null),E=m.useRef(null),[k,W]=m.useState(""),[nt,tt]=m.useState(null),[dt,ta]=m.useState("Thinking..."),[on,rn]=m.useState(new Set),[ea,na]=m.useState(""),[Lt,sa]=m.useState([]),[an,Ns]=m.useState(!1),[ln,Is]=m.useState([]),[Ls,cn]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Gt,ke]=m.useState(!1),[Nh,Re]=m.useState(!1),[Ih,Ne]=m.useState([]),Ot=m.useMemo(()=>[...u,...d],[u,d]),Os=m.useMemo(()=>Yr(Ot),[Ot]),Fs=m.useMemo(()=>{const p=new Map;return Ot.forEach(S=>p.set(S.name,S)),p},[Ot]),Bs=m.useMemo(()=>new Set(d.map(p=>p.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 p=localStorage.getItem("arcten-sidebar-expanded");p&&I(JSON.parse(p));const S=localStorage.getItem("arcten-sidebar-width");S&&Q(parseInt(S));const N=localStorage.getItem("arcten-sidebar-height");N&&Xt(parseInt(N));const F=localStorage.getItem("arcten-sidebar-detached");F&&R(JSON.parse(F));const G=localStorage.getItem("arcten-sidebar-position");if(G){const ot=JSON.parse(G),K=50,Pt=Math.max(K-o,Math.min(ot.x,window.innerWidth-K)),At=Math.max(0,Math.min(ot.y,window.innerHeight-K));Rt({x:Pt,y:At})}const C=localStorage.getItem("arcten-sidebar-minimized");C&&Z(JSON.parse(C)),Ee(!0)}},[]),m.useEffect(()=>((async()=>{try{const S=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:v})});if(!S.ok)throw new Error("Failed to fetch token");const N=await S.json();x(N.clientToken),T.current=N.clientToken,V(N.expiresAt),D(null)}catch(S){D(S instanceof Error?S.message:"Failed to fetch token")}})(),()=>{j.current&&clearTimeout(j.current)}),[g,v]),m.useEffect(()=>{if(!P)return;j.current&&clearTimeout(j.current);const p=Math.floor(Date.now()/1e3),S=P-p,F=Math.max(0,S-5);return console.log(`Token expires at ${new Date(P*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${F} seconds`),j.current=setTimeout(async()=>{console.log("Refreshing token...");try{const G=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:v})});if(!G.ok)throw new Error("Failed to refresh token");const C=await G.json();x(C.clientToken),T.current=C.clientToken,V(C.expiresAt),D(null),console.log("Token refreshed successfully")}catch(G){console.error("Token refresh failed:",G),D(G instanceof Error?G.message:"Failed to refresh token")}},F*1e3),()=>{j.current&&clearTimeout(j.current)}},[P,g,v]),m.useEffect(()=>{(async()=>{if(Ot.length!==0)try{const S=Ot.map(F=>({name:F.name,code:F.toString()})),N=await fetch(`${y}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:S})});if(N.ok){const F=await N.json();sa(F.tools)}}catch(S){console.error("Failed to fetch tool descriptions:",S)}})()},[Ot]),m.useEffect(()=>{Promise.resolve().then(()=>Ch).then(p=>{tt(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{na(window.location.pathname)};p(),window.addEventListener("popstate",p);const S=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(S)}},[]);async function zs(){if(!(!v?.id||!w)){Re(!0);try{const S=await(await fetch(`${y}/conversations`,{headers:{Authorization:`Bearer ${w}`}})).json();Is(S.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{Re(!1)}}}m.useEffect(()=>{v?.id&&w&&zs()},[v,w]);function ia(p){const S=Math.floor((Date.now()-p)/1e3);return S<60?"now":S<3600?`${Math.floor(S/60)}m`:S<86400?`${Math.floor(S/3600)}h`:`${Math.floor(S/86400)}d`}function oa(){const p=crypto.randomUUID();cn(p),Le([]),Ne([]),ke(!1)}async function ra(p){if(w)try{await fetch(`${y}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${w}`}}),Is(ln.filter(S=>S._id!==p)),p===Ls&&oa()}catch(S){console.error("Failed to delete conversation:",S)}}async function aa(p){cn(p.chatId),ke(!1),Re(!0);try{const S=await fetch(`${y}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${T.current}`}});if(!S.ok)throw new Error(`Failed to fetch messages: ${S.statusText}`);const F=(await S.json()).messages||[];Le(F),Ne(F)}catch(S){console.error("Failed to load conversation messages:",S);const N=p.messages||[];Le(N),Ne(N)}finally{Re(!1)}}const la=(async(p,S={})=>{const N=S.headers?new Headers(S.headers):new Headers;return N.delete("user-agent"),N.delete("User-Agent"),fetch(p,{...S,headers:N})}),{messages:de,sendMessage:ca,status:yt,error:Us,stop:Ie,addToolResult:he,setMessages:Le}=co.useChat({id:Ls||void 0,transport:new Xe.DefaultChatTransport({api:`${y}/chat`,fetch:la,headers:()=>{const p={};return T.current&&(p.Authorization=`Bearer ${T.current}`),p},body:()=>({tools:Os.map(p=>({name:p.name,description:p.description,parameters:p.parametersDef})),systemPrompt:f,currentRoute:ea})}),sendAutomaticallyWhen:Xe.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{A&&E.current&&E.current.focus()},[A,de]);function ua(){I(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function da(){I(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[A]),m.useEffect(()=>{ue.current&&ue.current.scrollIntoView({behavior:"smooth"})},[de]),m.useEffect(()=>{function p(S){S.key==="Escape"&&(yt==="streaming"||yt==="submitted")&&(S.preventDefault(),Ie())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[yt,Ie]);function ha(){const p=crypto.randomUUID();cn(p),Le([]),Ne([]),ke(!1)}function _s(p){if(p.preventDefault(),!k.trim())return;(yt==="streaming"||yt==="submitted")&&Ie();const S=$s[Math.floor(Math.random()*$s.length)]||"Thinking...";ta(S),ca({text:k}),W("")}function fa(p){const S=p.target.value;W(S)}m.useEffect(()=>{if(!Ct)return;function p(N){if(O){const F=N.clientX-_.x,G=N.clientY-_.y;F>=a&&F<=l&&Q(F),G>=400&&G<=1e3&&Xt(G)}else{const F=window.innerWidth-N.clientX;F>=a&&F<=l&&Q(F)}}function S(){gt(!1),localStorage.setItem("arcten-sidebar-width",L.toString()),localStorage.setItem("arcten-sidebar-height",ut.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",S)}},[Ct,L,ut,O,_,a,l]);function ma(p){p.preventDefault(),gt(!0)}function pa(){R(!0),Z(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function ga(){R(!1),Z(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ws(){Z(!B),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!B))}function ya(p){O&&(It(!0),Ve({x:p.clientX-_.x,y:p.clientY-_.y}))}return m.useEffect(()=>{if(!O)return;function p(){Rt(S=>{const F=window.innerWidth-50,G=window.innerHeight-50,C=50-L,ot=0,K=Math.max(C,Math.min(S.x,F)),Pt=Math.max(ot,Math.min(S.y,G));if(K!==S.x||Pt!==S.y){const At={x:K,y:Pt};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(At)),At}return S})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[O,L]),m.useEffect(()=>{if(!Nt)return;function p(N){const F=N.clientX-ce.x,G=N.clientY-ce.y,C=50,ot=window.innerWidth-C,K=window.innerHeight-C,Pt=C-L,At=0,un=Math.max(Pt,Math.min(F,ot)),ht=Math.max(At,Math.min(G,K));Rt({x:un,y:ht})}function S(){It(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(_))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",S)}},[Nt,ce,_,L]),sn?b?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: ",b]})}):w?h.jsx(Oc,{features:fh,children:h.jsx(ze,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:O?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:O?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
10
10
|
${O?"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
|
${O?"border border-border":"border-l border-border"}
|
|
13
13
|
${A?"":"w-[30px]"}
|
|
14
|
-
`,style:A?O?{width:`${L}px`,height:B?"auto":`${ct}px`,left:`${W.x}px`,top:`${W.y}px`}:{width:`${L}px`}:void 0,onClick:A?void 0:ca,children:A?h.jsxs(h.Fragment,{children:[!O&&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:fa,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),O&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),pt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),Nt(!0),De({x:p.clientX-W.x,y:p.clientY-W.y})},children:h.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),pt(!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 ${O?"cursor-move":""}`,onMouseDown:O?ga:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${O&&B?"cursor-pointer":""}`,onClick:O&&B?p=>{p.stopPropagation(),Ws()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(yt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:da,"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(yt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:O?pa:ma,"aria-label":O?"Dock sidebar":"Float sidebar",children:O?h.jsx(G.Dock,{className:"h-4 w-4"}):h.jsx(G.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:O?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(yt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:O?Ws:ua,"aria-label":O?B?"Maximize":"Minimize":"Close sidebar",children:O?B?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:O?B?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!B&&h.jsxs(h.Fragment,{children:[v&&an.length>0&&h.jsxs("div",{className:`border-b border-border ${Xt?"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(yt,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Xt||$s(),Ee(!Xt)},children:Xt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Xt?"flex-1 overflow-y-auto":""}`,children:an.slice(0,Xt?void 0:3).map(p=>h.jsx("div",{className:"group",children:h.jsxs(yt,{variant:"ghost",className:"w-full justify-between h-auto py-1 px-3 font-normal",onClick:()=>ra(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsxs("div",{className:"ml-2 flex items-center",children:[h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:sa(p.updatedAt)}),h.jsx(yt,{variant:"ghost",size:"icon",className:"h-2 w-2 p-0 hidden group-hover:flex text-muted-foreground hover:text-foreground",onClick:S=>{S.stopPropagation(),oa(p._id)},children:h.jsx(G.X,{className:"h-3 w-3"})})]})]})},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children: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?"}),It.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:[(rn?It:It.slice(0,10)).map(p=>h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(un,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{_(p.sampleUsage),E.current?.focus()},children:p.friendlyName})}),h.jsx(Bt,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),It.length>10&&!rn&&h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsxs(un,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Rs(!0),children:["+",It.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:It.slice(10).map(p=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[p.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:p.description})]},p.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),rn&&It.length>10&&h.jsx(un,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Rs(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[ue.map(p=>{const S=p.parts.filter(C=>C.type==="text");p.parts.filter(C=>C.type==="reasoning");const N=p.parts.filter(C=>C.type?.startsWith("tool-")),F=p.parts.filter(C=>C.type==="text"||C.type==="reasoning"),Y=S.map(C=>C.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(fh,{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:Y}):h.jsxs("div",{className:"space-y-2",children:[N.map((C,it)=>{const K=C.type?.replace("tool-","")||"",Ct=Ls.find(dt=>dt.name===K),Pt=C.state==="input-available",cn=C.state==="output-available";if(Pt)return Fs.has(K)?((async()=>{if(sn.has(C.toolCallId))return;on(he=>new Set(he).add(C.toolCallId));const At=Os.get(K);if(At)try{console.log("Auto-executing safe tool:",K);const he=await At(...Object.values(C.input||{}));de({toolCallId:C.toolCallId,tool:K,output:he}),console.log("Safe tool result added:",C.toolCallId)}catch(he){de({toolCallId:C.toolCallId,tool:K,output:`Error: ${he}`}),console.log("Safe tool error result added:",C.toolCallId)}})(),null):h.jsx($e,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(yh,{toolName:K,description:Ct?.description||"",args:C.input||{},onApprove:async()=>{if(sn.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}on(At=>new Set(At).add(C.toolCallId));const dt=Os.get(K);if(dt)try{const At=await dt(...Object.values(C.input||{}));de({toolCallId:C.toolCallId,tool:K,output:At}),console.log("Tool result added:",C.toolCallId)}catch(At){de({toolCallId:C.toolCallId,tool:K,output:`Error: ${At}`}),console.log("Tool error result added:",C.toolCallId)}},onDeny:async()=>{if(sn.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}on(dt=>new Set(dt).add(C.toolCallId)),de({toolCallId:C.toolCallId,tool:K,output:"User denied tool execution"}),console.log("Tool denied:",C.toolCallId)}})},`${C.toolCallId}-${it}`);if(cn){const dt=C.output==="User denied tool execution";return h.jsx(xh,{toolName:K,args:C.input||{},isDenied:dt,isSafe:Fs.has(K)},`${C.toolCallId}-${it}`)}return null}),F.map((C,it)=>C.type==="text"&&C.text&&nt?h.jsx(nt,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:C.text},`${p.id}-${it}`):C.type==="reasoning"&&C.text?h.jsxs(qr,{className:"w-full",isStreaming:gt==="streaming"&&it===p.parts.length-1&&p.id===ue.at(-1)?.id,children:[h.jsx(Zr,{}),h.jsx(Jr,{children:C.text})]},`${p.id}-${it}`):null)]})})},p.id)}),h.jsx("div",{ref:ce})]})}),zs&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",zs.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Ic,{mode:"wait",children:(gt==="streaming"||gt==="submitted")&&h.jsxs($e,{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($e,{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:ut})]})}),h.jsxs("form",{onSubmit:Us,className:"relative",children:[h.jsx(ho,{ref:E,value:k,onChange:ha,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),Us(p))}}),gt==="streaming"||gt==="submitted"?h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(yt,{type:"button",size:"icon",variant:"ghost",className:"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8",onClick:Ne,children:h.jsx(G.Square,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Hs,{children:"Escape"})," to stop"]})]}):h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(yt,{type:"submit",size:"icon",variant:"ghost",className:"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8",disabled:!k.trim(),children:h.jsx(G.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Hs,{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 Eh({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:c,onToolCall:u,onFinish:d}={}){console.log("[useAgent] Hook initialized",{apiBaseUrl:t,tokenEndpoint:e,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[f,g]=m.useState(n||null),y=m.useRef(n||null),[v,w]=m.useState(null),[x,T]=m.useState(null),b=m.useRef(null),[j,P]=m.useState([]),[V,D]=m.useState(c||(typeof window<"u"?crypto.randomUUID():null)),[A,I]=m.useState(!1),[L,Q]=m.useState(new Set),ct=m.useMemo(()=>[...r,...o],[r,o]),Ht=m.useMemo(()=>Yr(ct),[ct]),St=m.useMemo(()=>{const E=new Map;return ct.forEach(k=>E.set(k.name,k)),E},[ct]),pt=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 _=await k.json();console.log("[useAgent] Token fetched successfully",{expiresAt:_.expiresAt,expiresIn:_.expiresAt?`${_.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),g(_.clientToken),y.current=_.clientToken,T(_.expiresAt),w(null)}catch(k){console.error("[useAgent] Token fetch failed:",k),w(k instanceof Error?k.message:"Failed to fetch token")}})(),()=>{console.log("[useAgent] Cleaning up token fetch effect"),b.current&&clearTimeout(b.current)}},[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(console.log("[useAgent] Token refresh effect running",{hasTokenExpiresAt:!!x,tokenExpiresAt:x,skipTokenFetch:s,hasProvidedToken:!!n}),!x||s||n){console.log("[useAgent] Skipping token refresh setup",{reason:x?s?"skipTokenFetch=true":"token provided":"no expiry"});return}b.current&&(console.log("[useAgent] Clearing existing token refresh timeout"),clearTimeout(b.current));const E=Math.floor(Date.now()/1e3),k=x-E,nt=Math.max(0,k-5);return console.log("[useAgent] Scheduling token refresh",{expiresAt:x,now:E,timeUntilExpiry:`${k}s`,timeUntilRefresh:`${nt}s`,refreshAt:new Date((E+nt)*1e3).toISOString()}),b.current=setTimeout(async()=>{console.log("[useAgent] Refreshing token...");try{const tt=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!tt.ok)throw new Error("Failed to refresh token");const ut=await tt.json();console.log("[useAgent] Token refreshed successfully",{newExpiresAt:ut.expiresAt,expiresIn:`${ut.expiresAt-Math.floor(Date.now()/1e3)}s`}),g(ut.clientToken),y.current=ut.clientToken,T(ut.expiresAt),w(null)}catch(tt){console.error("[useAgent] Token refresh failed:",tt),w(tt instanceof Error?tt.message:"Failed to refresh token")}},nt*1e3),()=>{console.log("[useAgent] Cleaning up token refresh effect"),b.current&&clearTimeout(b.current)}},[x,e,JSON.stringify(i),s,n]);const O=(async(E,k={})=>{const _=k.headers?new Headers(k.headers):new Headers;return _.delete("user-agent"),_.delete("User-Agent"),fetch(E,{...k,headers:_})}),{messages:R,sendMessage:B,status:Z,error:W,stop:kt,addToolResult:Rt,setMessages:Nt}=lo.useChat({id:V||void 0,messages:l,transport:new He.DefaultChatTransport({api:`${t}/chat`,fetch:O,headers:()=>{const E={};return y.current&&(E.Authorization=`Bearer ${y.current}`),E},body:()=>({tools:Ht.map(E=>({name:E.name,description:E.description,parameters:E.parametersDef})),systemPrompt:a})}),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 _=k.type.replace("tool-",""),nt=k.toolCallId;if(!L.has(nt)){if(Q(tt=>new Set(tt).add(nt)),pt.has(_)){const tt=St.get(_);tt&&(async()=>{try{const ut=await tt(...Object.values(k.input||{}));Rt({toolCallId:nt,tool:_,output:ut})}catch(ut){Rt({toolCallId:nt,tool:_,output:`Error: ${ut}`})}})()}else if(u){const tt={toolCallId:nt,toolName:_,args:k.input||{}};u({toolCall:tt})}}})})},[R,pt,St,u,Rt,L]),m.useEffect(()=>{if(Z==="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:!!W})}},[Z,R,W,d]);async function le(){if(!(!i?.id||!f)){console.log("[useAgent] Fetching conversations for user:",i?.id),I(!0);try{const k=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${f}`}})).json();P(k.conversations||[])}catch(E){console.error("Failed to fetch conversations:",E)}finally{I(!1)}}}m.useEffect(()=>{i?.id&&f&&le()},[JSON.stringify(i),f,t]);async function De(E){D(E),I(!0);try{const k=await fetch(`${t}/conversations/${E}/messages`,{headers:{Authorization:`Bearer ${y.current}`}});if(!k.ok)throw new Error(`Failed to fetch messages: ${k.statusText}`);const nt=(await k.json()).messages||[];Nt(nt)}catch(k){console.error("Failed to load conversation messages:",k)}finally{I(!1)}}async function nn(E){if(f)try{await fetch(`${t}/conversations/${E}`,{method:"DELETE",headers:{Authorization:`Bearer ${f}`}}),P(j.filter(k=>k._id!==E)),E===V&&Ve()}catch(k){console.error("Failed to delete conversation:",k)}}function Ve(){const E=crypto.randomUUID();D(E),Nt([]),Q(new Set)}function ce(E){Rt(E)}return{id:V,messages:R,status:Z,error:W,sendMessage:B,stop:kt,addToolOutput:ce,setMessages:Nt,conversations:j,loadConversation:De,deleteConversation:nn,startNewConversation:Ve,isLoadingConversations:A,clientToken:f,tokenError:v}}exports.verifyToken=ja.verifyToken;exports.ArctenAgent=Vh;exports.useAgent=Eh;
|
|
14
|
+
`,style:A?O?{width:`${L}px`,height:B?"auto":`${ut}px`,left:`${_.x}px`,top:`${_.y}px`}:{width:`${L}px`}:void 0,onClick:A?void 0:ua,children:A?h.jsxs(h.Fragment,{children:[!O&&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:ma,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),O&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),gt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),It(!0),Ve({x:p.clientX-_.x,y:p.clientY-_.y})},children:h.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),gt(!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 ${O?"cursor-move":""}`,onMouseDown:O?ya:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${O&&B?"cursor-pointer":""}`,onClick:O&&B?p=>{p.stopPropagation(),Ws()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(xt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:ha,"aria-label":"New chat",children:h.jsx(Y.Plus,{className:"h-4 w-4"})})}),h.jsx($t,{children:"Start a new conversation"})]}),h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(xt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:O?ga:pa,"aria-label":O?"Dock sidebar":"Float sidebar",children:O?h.jsx(Y.Dock,{className:"h-4 w-4"}):h.jsx(Y.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx($t,{children:O?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(xt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:O?Ws:da,"aria-label":O?B?"Maximize":"Minimize":"Close sidebar",children:O?B?h.jsx(Y.Maximize2,{className:"h-4 w-4"}):h.jsx(Y.Minimize2,{className:"h-4 w-4"}):h.jsx(Y.X,{className:"h-4 w-4"})})}),h.jsx($t,{children:O?B?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!B&&h.jsxs(h.Fragment,{children:[v&&ln.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(xt,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Gt||zs(),ke(!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:ln.slice(0,Gt?void 0:3).map(p=>h.jsx("div",{className:"group",children:h.jsxs(xt,{variant:"ghost",className:"w-full justify-between h-auto py-1 px-3 font-normal",onClick:()=>aa(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsxs("div",{className:"ml-2 flex items-center",children:[h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:ia(p.updatedAt)}),h.jsx(xt,{variant:"ghost",size:"icon",className:"h-2 w-2 p-0 hidden group-hover:flex text-muted-foreground hover:text-foreground",onClick:S=>{S.stopPropagation(),ra(p._id)},children:h.jsx(Y.X,{className:"h-3 w-3"})})]})]})},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:de.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?"}),Lt.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:[(an?Lt:Lt.slice(0,10)).map(p=>h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(dn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{W(p.sampleUsage),E.current?.focus()},children:p.friendlyName})}),h.jsx($t,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),Lt.length>10&&!an&&h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsxs(dn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Ns(!0),children:["+",Lt.length-10," more"]})}),h.jsx($t,{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:Lt.slice(10).map(p=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[p.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:p.description})]},p.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),an&&Lt.length>10&&h.jsx(dn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Ns(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[de.map(p=>{const S=p.parts.filter(C=>C.type==="text");p.parts.filter(C=>C.type==="reasoning");const N=p.parts.filter(C=>C.type?.startsWith("tool-")),F=p.parts.filter(C=>C.type==="text"||C.type==="reasoning"),G=S.map(C=>C.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(mh,{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:G}):h.jsxs("div",{className:"space-y-2",children:[N.map((C,ot)=>{const K=C.type?.replace("tool-","")||"",Pt=Os.find(ht=>ht.name===K),At=C.state==="input-available",un=C.state==="output-available";if(At)return Bs.has(K)?((async()=>{if(on.has(C.toolCallId))return;rn(fe=>new Set(fe).add(C.toolCallId));const Mt=Fs.get(K);if(Mt)try{console.log("Auto-executing safe tool:",K);const fe=await Mt(...Object.values(C.input||{}));he({toolCallId:C.toolCallId,tool:K,output:fe}),console.log("Safe tool result added:",C.toolCallId)}catch(fe){he({toolCallId:C.toolCallId,tool:K,output:`Error: ${fe}`}),console.log("Safe tool error result added:",C.toolCallId)}})(),null):h.jsx(ze,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(xh,{toolName:K,description:Pt?.description||"",args:C.input||{},onApprove:async()=>{if(on.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}rn(Mt=>new Set(Mt).add(C.toolCallId));const ht=Fs.get(K);if(ht)try{const Mt=await ht(...Object.values(C.input||{}));he({toolCallId:C.toolCallId,tool:K,output:Mt}),console.log("Tool result added:",C.toolCallId)}catch(Mt){he({toolCallId:C.toolCallId,tool:K,output:`Error: ${Mt}`}),console.log("Tool error result added:",C.toolCallId)}},onDeny:async()=>{if(on.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}rn(ht=>new Set(ht).add(C.toolCallId)),he({toolCallId:C.toolCallId,tool:K,output:"User denied tool execution"}),console.log("Tool denied:",C.toolCallId)}})},`${C.toolCallId}-${ot}`);if(un){const ht=C.output==="User denied tool execution";return h.jsx(vh,{toolName:K,args:C.input||{},isDenied:ht,isSafe:Bs.has(K)},`${C.toolCallId}-${ot}`)}return null}),F.map((C,ot)=>C.type==="text"&&C.text&&nt?h.jsx(nt,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:C.text},`${p.id}-${ot}`):C.type==="reasoning"&&C.text?h.jsxs(Zr,{className:"w-full",isStreaming:yt==="streaming"&&ot===p.parts.length-1&&p.id===de.at(-1)?.id,children:[h.jsx(Jr,{}),h.jsx(Qr,{children:C.text})]},`${p.id}-${ot}`):null)]})})},p.id)}),h.jsx("div",{ref:ue})]})}),Us&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",Us.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Lc,{mode:"wait",children:(yt==="streaming"||yt==="submitted")&&h.jsxs(ze,{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(ze,{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:dt})]})}),h.jsxs("form",{onSubmit:_s,className:"relative",children:[h.jsx(fo,{ref:E,value:k,onChange:fa,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),_s(p))}}),yt==="streaming"||yt==="submitted"?h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(xt,{type:"button",size:"icon",variant:"ghost",className:"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8",onClick:Ie,children:h.jsx(Y.Square,{className:"h-4 w-4"})})}),h.jsxs($t,{children:[h.jsx(Xs,{children:"Escape"})," to stop"]})]}):h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(xt,{type:"submit",size:"icon",variant:"ghost",className:"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8",disabled:!k.trim(),children:h.jsx(Y.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs($t,{children:[h.jsx(Xs,{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(Y.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}const kh=typeof process<"u"&&(process.env.DEBUG_ARCTEN==="1"||process.env.DEBUG_ARCTEN==="true"),st=(...t)=>{kh&&console.log(...t)};function Rh({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:c,onToolCall:u,onFinish:d}={}){st("[useAgent] Hook initialized",{apiBaseUrl:t,tokenEndpoint:e,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[f,g]=m.useState(n||null),y=m.useRef(n||null),[v,w]=m.useState(null),[x,T]=m.useState(null),b=m.useRef(null),[D,P]=m.useState([]),[V,j]=m.useState(c||(typeof window<"u"?crypto.randomUUID():null)),[A,I]=m.useState(!1),[L,Q]=m.useState(new Set),ut=m.useMemo(()=>[...r,...o],[r,o]),Xt=m.useMemo(()=>Yr(ut),[ut]),Ct=m.useMemo(()=>{const E=new Map;return ut.forEach(k=>E.set(k.name,k)),E},[ut]),gt=m.useMemo(()=>new Set(o.map(E=>E.name)),[o]);m.useEffect(()=>{if(st("[useAgent] Token fetch effect running",{skipTokenFetch:s,hasProvidedToken:!!n,user:i?.id,tokenEndpoint:e}),s||n){st("[useAgent] Skipping token fetch",{reason:s?"skipTokenFetch=true":"token provided"});return}return(async()=>{st("[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 W=await k.json();st("[useAgent] Token fetched successfully",{expiresAt:W.expiresAt,expiresIn:W.expiresAt?`${W.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),g(W.clientToken),y.current=W.clientToken,T(W.expiresAt),w(null)}catch(k){console.error("[useAgent] Token fetch failed:",k),w(k instanceof Error?k.message:"Failed to fetch token")}})(),()=>{st("[useAgent] Cleaning up token fetch effect"),b.current&&clearTimeout(b.current)}},[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(st("[useAgent] Token refresh effect running",{hasTokenExpiresAt:!!x,tokenExpiresAt:x,skipTokenFetch:s,hasProvidedToken:!!n}),!x||s||n){st("[useAgent] Skipping token refresh setup",{reason:x?s?"skipTokenFetch=true":"token provided":"no expiry"});return}b.current&&(st("[useAgent] Clearing existing token refresh timeout"),clearTimeout(b.current));const E=Math.floor(Date.now()/1e3),k=x-E,nt=Math.max(0,k-5);return st("[useAgent] Scheduling token refresh",{expiresAt:x,now:E,timeUntilExpiry:`${k}s`,timeUntilRefresh:`${nt}s`,refreshAt:new Date((E+nt)*1e3).toISOString()}),b.current=setTimeout(async()=>{st("[useAgent] Refreshing token...");try{const tt=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!tt.ok)throw new Error("Failed to refresh token");const dt=await tt.json();st("[useAgent] Token refreshed successfully",{newExpiresAt:dt.expiresAt,expiresIn:`${dt.expiresAt-Math.floor(Date.now()/1e3)}s`}),g(dt.clientToken),y.current=dt.clientToken,T(dt.expiresAt),w(null)}catch(tt){console.error("[useAgent] Token refresh failed:",tt),w(tt instanceof Error?tt.message:"Failed to refresh token")}},nt*1e3),()=>{st("[useAgent] Cleaning up token refresh effect"),b.current&&clearTimeout(b.current)}},[x,e,JSON.stringify(i),s,n]);const O=(async(E,k={})=>{const W=k.headers?new Headers(k.headers):new Headers;return W.delete("user-agent"),W.delete("User-Agent"),fetch(E,{...k,headers:W})}),{messages:R,sendMessage:B,status:Z,error:_,stop:Rt,addToolResult:Nt,setMessages:It}=co.useChat({id:V||void 0,messages:l,transport:new Xe.DefaultChatTransport({api:`${t}/chat`,fetch:O,headers:()=>{const E={};return y.current&&(E.Authorization=`Bearer ${y.current}`),E},body:()=>({tools:Xt.map(E=>({name:E.name,description:E.description,parameters:E.parametersDef})),systemPrompt:a})}),sendAutomaticallyWhen:Xe.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{R.forEach(E=>{E.role==="assistant"&&E.parts.forEach(k=>{if(!k.type?.startsWith("tool-")||k.state!=="input-available")return;const W=k.type.replace("tool-",""),nt=k.toolCallId;if(!L.has(nt)){if(Q(tt=>new Set(tt).add(nt)),gt.has(W)){const tt=Ct.get(W);tt&&(async()=>{try{const dt=await tt(...Object.values(k.input||{}));Nt({toolCallId:nt,tool:W,output:dt})}catch(dt){Nt({toolCallId:nt,tool:W,output:`Error: ${dt}`})}})()}else if(u){const tt={toolCallId:nt,toolName:W,args:k.input||{}};u({toolCall:tt})}}})})},[R,gt,Ct,u,Nt,L]),m.useEffect(()=>{if(Z==="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:!!_})}},[Z,R,_,d]);async function ce(){if(!(!i?.id||!f)){st("[useAgent] Fetching conversations for user:",i?.id),I(!0);try{const k=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${f}`}})).json();P(k.conversations||[])}catch(E){console.error("Failed to fetch conversations:",E)}finally{I(!1)}}}m.useEffect(()=>{i?.id&&f&&ce()},[JSON.stringify(i),f,t]);async function Ve(E){j(E),I(!0);try{const k=await fetch(`${t}/conversations/${E}/messages`,{headers:{Authorization:`Bearer ${y.current}`}});if(!k.ok)throw new Error(`Failed to fetch messages: ${k.statusText}`);const nt=(await k.json()).messages||[];It(nt)}catch(k){console.error("Failed to load conversation messages:",k)}finally{I(!1)}}async function sn(E){if(f)try{await fetch(`${t}/conversations/${E}`,{method:"DELETE",headers:{Authorization:`Bearer ${f}`}}),P(D.filter(k=>k._id!==E)),E===V&&Ee()}catch(k){console.error("Failed to delete conversation:",k)}}function Ee(){const E=crypto.randomUUID();j(E),It([]),Q(new Set)}function ue(E){Nt(E)}return{id:V,messages:R,status:Z,error:_,sendMessage:B,stop:Rt,addToolOutput:ue,setMessages:It,conversations:D,loadConversation:Ve,deleteConversation:sn,startNewConversation:Ee,isLoadingConversations:A,clientToken:f,tokenError:v}}exports.verifyToken=ja.verifyToken;exports.ArctenAgent=Eh;exports.useAgent=Rh;
|