@arcteninc/core 0.0.68 → 0.0.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,12 +1,12 @@
1
- "use strict";var Pa=Object.create;var Qs=Object.defineProperty;var Aa=Object.getOwnPropertyDescriptor;var Ma=Object.getOwnPropertyNames;var ja=Object.getPrototypeOf,Ea=Object.prototype.hasOwnProperty;var Va=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ma(e))!Ea.call(t,i)&&i!==n&&Qs(t,i,{get:()=>e[i],enumerable:!(s=Aa(e,i))||s.enumerable});return t};var Da=(t,e,n)=>(n=t!=null?Pa(ja(t)):{},Va(e||!t||!t.__esModule?Qs(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"),yr=require("@ai-sdk/react"),en=require("ai"),xr=require("@radix-ui/react-slot"),vr=require("class-variance-authority"),ka=require("clsx"),Ra=require("tailwind-merge"),Na=require("@radix-ui/react-tooltip"),ti=require("@radix-ui/react-use-controllable-state"),Ia=require("@radix-ui/react-collapsible"),La=require("./server.cjs");function is(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const ht=is(m),re=is(Na),rs=is(Ia);function Z(...t){return Ra.twMerge(ka.clsx(t))}const Wt=vr.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"}}),nn=ht.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},o)=>{const r=s?xr.Slot:"button";return h.jsx(r,{ref:o,"data-slot":"button",className:Z(Wt({variant:e,size:n,className:t})),...i})});nn.displayName="Button";const Oa=vr.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 xn({className:t,variant:e,asChild:n=!1,...s}){const i=n?xr.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:Z(Oa({variant:e}),t),...s})}const Fa=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,o]=ht.useState(!0);ht.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!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])},br=ht.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...o},r)=>{const a=ht.useRef(null),[l,u]=ht.useState("");return Fa({textAreaRef:a,triggerAutoSize:l,maxHeight:t,minHeight:e}),m.useImperativeHandle(r,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),ht.useEffect(()=>{u(i)},[o?.defaultValue,i]),h.jsx("textarea",{...o,value:i,ref:a,className:Z("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:c=>{u(c.target.value),s?.(c)}})});br.displayName="AutosizeTextarea";function Ba({delayDuration:t=0,...e}){return h.jsx(re.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function $t({...t}){return h.jsx(Ba,{children:h.jsx(re.Root,{"data-slot":"tooltip",...t})})}function zt({...t}){return h.jsx(re.Trigger,{"data-slot":"tooltip-trigger",...t})}function Ut({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(re.Portal,{children:h.jsxs(re.Content,{"data-slot":"tooltip-content",sideOffset:e,className:Z("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...s,children:[n,h.jsx(re.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function ei({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:Z("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",t),...e})}const os=m.createContext({});function as(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const ls=typeof window<"u",wr=ls?m.useLayoutEffect:m.useEffect,cn=m.createContext(null);function cs(t,e){t.indexOf(e)===-1&&t.push(e)}function us(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Ct=(t,e,n)=>n>e?e:n<t?t:n;function In(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let ce=()=>{},Pt=()=>{};process.env.NODE_ENV!=="production"&&(ce=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(In(e,n))},Pt=(t,e,n)=>{if(!t)throw new Error(In(e,n))});const At={},Tr=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Sr(t){return typeof t=="object"&&t!==null}const Cr=t=>/^0[^.\s]+$/u.test(t);function ds(t){let e;return()=>(e===void 0&&(e=t()),e)}const ut=t=>t,$a=(t,e)=>n=>e(t(n)),Le=(...t)=>t.reduce($a),Ve=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class hs{constructor(){this.subscriptions=[]}add(e){return cs(this.subscriptions,e),()=>us(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const ft=t=>t*1e3,ct=t=>t/1e3;function Pr(t,e){return e?t*(1e3/e):0}const ni=new Set;function fs(t,e,n){t||ni.has(e)||(console.warn(In(e,n)),ni.add(e))}const Ar=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,za=1e-7,Ua=12;function _a(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=Ar(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>za&&++a<Ua);return r}function Oe(t,e,n,s){if(t===e&&n===s)return ut;const i=o=>_a(o,0,1,t,n);return o=>o===0||o===1?o:Ar(i(o),e,s)}const Mr=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,jr=t=>e=>1-t(1-e),Er=Oe(.33,1.53,.69,.99),ms=jr(Er),Vr=Mr(ms),Dr=t=>(t*=2)<1?.5*ms(t):.5*(2-Math.pow(2,-10*(t-1))),ps=t=>1-Math.sin(Math.acos(t)),kr=jr(ps),Rr=Mr(ps),Wa=Oe(.42,0,1,1),Ka=Oe(0,0,.58,1),Nr=Oe(.42,0,.58,1),Ha=t=>Array.isArray(t)&&typeof t[0]!="number",Ir=t=>Array.isArray(t)&&typeof t[0]=="number",si={linear:ut,easeIn:Wa,easeInOut:Nr,easeOut:Ka,circIn:ps,circInOut:Rr,circOut:kr,backIn:ms,backInOut:Vr,backOut:Er,anticipate:Dr},Xa=t=>typeof t=="string",ii=t=>{if(Ir(t)){Pt(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return Oe(e,n,s,i)}else if(Xa(t))return Pt(si[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),si[t];return t},Ke=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Ga(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(c){r.has(c)&&(u.schedule(c),t()),c(a)}const u={schedule:(c,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&r.add(c),y.has(c)||y.add(c),c},cancel:c=>{s.delete(c),r.delete(c)},process:c=>{if(a=c,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,o&&(o=!1,u.process(c))}};return u}const Ya=40;function Lr(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=Ke.reduce((b,V)=>(b[V]=Ga(o),b),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:c,update:d,preRender:f,render:g,postRender:y}=r,v=()=>{const b=At.useManualTiming?i.timestamp:performance.now();n=!1,At.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(b-i.timestamp,Ya),1)),i.timestamp=b,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),c.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:Ke.reduce((b,V)=>{const P=r[V];return b[V]=(E,R=!1,A=!1)=>(n||w(),P.schedule(E,R,A)),b},{}),cancel:b=>{for(let V=0;V<Ke.length;V++)r[Ke[V]].cancel(b)},state:i,steps:r}}const{schedule:B,cancel:kt,state:J,steps:vn}=Lr(typeof requestAnimationFrame<"u"?requestAnimationFrame:ut,!0);let qe;function qa(){qe=void 0}const st={now:()=>(qe===void 0&&st.set(J.isProcessing||At.useManualTiming?J.timestamp:performance.now()),qe),set:t=>{qe=t,queueMicrotask(qa)}},Or=t=>e=>typeof e=="string"&&e.startsWith(t),gs=Or("--"),Ja=Or("var(--"),ys=t=>Ja(t)?Za.test(t.split("/*")[0].trim()):!1,Za=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ue={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},De={...ue,transform:t=>Ct(0,1,t)},He={...ue,default:1},Ce=t=>Math.round(t*1e5)/1e5,xs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Qa(t){return t==null}const tl=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,vs=(t,e)=>n=>!!(typeof n=="string"&&tl.test(n)&&n.startsWith(t)||e&&!Qa(n)&&Object.prototype.hasOwnProperty.call(n,e)),Fr=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(xs);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},el=t=>Ct(0,255,t),bn={...ue,transform:t=>Math.round(el(t))},Ht={test:vs("rgb","red"),parse:Fr("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+bn.transform(t)+", "+bn.transform(e)+", "+bn.transform(n)+", "+Ce(De.transform(s))+")"};function nl(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 Ln={test:vs("#"),parse:nl,transform:Ht.transform},Fe=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Dt=Fe("deg"),wt=Fe("%"),M=Fe("px"),sl=Fe("vh"),il=Fe("vw"),ri={...wt,parse:t=>wt.parse(t)/100,transform:t=>wt.transform(t*100)},Qt={test:vs("hsl","hue"),parse:Fr("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+wt.transform(Ce(e))+", "+wt.transform(Ce(n))+", "+Ce(De.transform(s))+")"},X={test:t=>Ht.test(t)||Ln.test(t)||Qt.test(t),parse:t=>Ht.test(t)?Ht.parse(t):Qt.test(t)?Qt.parse(t):Ln.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Ht.transform(t):Qt.transform(t),getAnimatableNone:t=>{const e=X.parse(t);return e.alpha=0,X.transform(e)}},rl=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function ol(t){return isNaN(t)&&typeof t=="string"&&(t.match(xs)?.length||0)+(t.match(rl)?.length||0)>0}const Br="number",$r="color",al="var",ll="var(",oi="${}",cl=/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 ke(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const a=e.replace(cl,l=>(X.test(l)?(s.color.push(o),i.push($r),n.push(X.parse(l))):l.startsWith(ll)?(s.var.push(o),i.push(al),n.push(l)):(s.number.push(o),i.push(Br),n.push(parseFloat(l))),++o,oi)).split(oi);return{values:n,split:a,indexes:s,types:i}}function zr(t){return ke(t).values}function Ur(t){const{split:e,types:n}=ke(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===Br?o+=Ce(i[r]):a===$r?o+=X.transform(i[r]):o+=i[r]}return o}}const ul=t=>typeof t=="number"?0:X.test(t)?X.getAnimatableNone(t):t;function dl(t){const e=zr(t);return Ur(t)(e.map(ul))}const Rt={test:ol,parse:zr,createTransformer:Ur,getAnimatableNone:dl};function wn(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function hl({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;i=wn(l,a,t+1/3),o=wn(l,a,t),r=wn(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function sn(t,e){return n=>n>0?e:t}const z=(t,e,n)=>t+(e-t)*n,Tn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},fl=[Ln,Ht,Qt],ml=t=>fl.find(e=>e.test(t));function ai(t){const e=ml(t);if(ce(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===Qt&&(n=hl(n)),n}const li=(t,e)=>{const n=ai(t),s=ai(e);if(!n||!s)return sn(t,e);const i={...n};return o=>(i.red=Tn(n.red,s.red,o),i.green=Tn(n.green,s.green,o),i.blue=Tn(n.blue,s.blue,o),i.alpha=z(n.alpha,s.alpha,o),Ht.transform(i))},On=new Set(["none","hidden"]);function pl(t,e){return On.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function gl(t,e){return n=>z(t,e,n)}function bs(t){return typeof t=="number"?gl:typeof t=="string"?ys(t)?sn:X.test(t)?li:vl:Array.isArray(t)?_r:typeof t=="object"?X.test(t)?li:yl:sn}function _r(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>bs(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function yl(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=bs(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function xl(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],r=t.indexes[o][s[o]],a=t.values[r]??0;n[i]=a,s[o]++}return n}const vl=(t,e)=>{const n=Rt.createTransformer(e),s=ke(t),i=ke(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?On.has(t)&&!i.values.length||On.has(e)&&!s.values.length?pl(t,e):Le(_r(xl(s,i),i.values),n):(ce(!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"),sn(t,e))};function Wr(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?z(t,e,n):bs(t)(t,e)}const bl=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>B.update(e,n),stop:()=>kt(e),now:()=>J.isProcessing?J.timestamp:st.now()}},Kr=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},rn=2e4;function ws(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<rn;)e+=n,s=t.next(e);return e>=rn?1/0:e}function wl(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(ws(s),rn);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:ct(i)}}const Tl=5;function Hr(t,e,n){const s=Math.max(e-Tl,0);return Pr(n-t(s),e-s)}const $={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},Sn=.001;function Sl({duration:t=$.duration,bounce:e=$.bounce,velocity:n=$.velocity,mass:s=$.mass}){let i,o;ce(t<=ft($.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=Ct($.minDamping,$.maxDamping,r),t=Ct($.minDuration,$.maxDuration,ct(t)),r<1?(i=u=>{const c=u*r,d=c*t,f=c-n,g=Fn(u,r),y=Math.exp(-d);return Sn-f/g*y},o=u=>{const d=u*r*t,f=d*n+n,g=Math.pow(r,2)*Math.pow(u,2)*t,y=Math.exp(-d),v=Fn(Math.pow(u,2),r);return(-i(u)+Sn>0?-1:1)*((f-g)*y)/v}):(i=u=>{const c=Math.exp(-u*t),d=(u-n)*t+1;return-Sn+c*d},o=u=>{const c=Math.exp(-u*t),d=(n-u)*(t*t);return c*d});const a=5/t,l=Pl(i,o,a);if(t=ft(t),isNaN(l))return{stiffness:$.stiffness,damping:$.damping,duration:t};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const Cl=12;function Pl(t,e,n){let s=n;for(let i=1;i<Cl;i++)s=s-t(s)/e(s);return s}function Fn(t,e){return t*Math.sqrt(1-e*e)}const Al=["duration","bounce"],Ml=["stiffness","damping","mass"];function ci(t,e){return e.some(n=>t[n]!==void 0)}function jl(t){let e={velocity:$.velocity,stiffness:$.stiffness,damping:$.damping,mass:$.mass,isResolvedFromDuration:!1,...t};if(!ci(t,Ml)&&ci(t,Al))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*Ct(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:$.mass,stiffness:i,damping:o}}else{const n=Sl(t);e={...e,...n,mass:$.mass},e.isResolvedFromDuration=!0}return e}function on(t=$.visualDuration,e=$.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:l,damping:u,mass:c,duration:d,velocity:f,isResolvedFromDuration:g}=jl({...n,velocity:-ct(n.velocity||0)}),y=f||0,v=u/(2*Math.sqrt(l*c)),w=r-o,x=ct(Math.sqrt(l/c)),S=Math.abs(w)<5;s||(s=S?$.restSpeed.granular:$.restSpeed.default),i||(i=S?$.restDelta.granular:$.restDelta.default);let b;if(v<1){const P=Fn(x,v);b=E=>{const R=Math.exp(-v*x*E);return r-R*((y+v*x*w)/P*Math.sin(P*E)+w*Math.cos(P*E))}}else if(v===1)b=P=>r-Math.exp(-x*P)*(w+(y+x*w)*P);else{const P=x*Math.sqrt(v*v-1);b=E=>{const R=Math.exp(-v*x*E),A=Math.min(P*E,300);return r-R*((y+v*x*w)*Math.sinh(A)+P*w*Math.cosh(A))/P}}const V={calculatedDuration:g&&d||null,next:P=>{const E=b(P);if(g)a.done=P>=d;else{let R=P===0?y:0;v<1&&(R=P===0?ft(y):Hr(b,P,E));const A=Math.abs(R)<=s,L=Math.abs(r-E)<=i;a.done=A&&L}return a.value=a.done?r:E,a},toString:()=>{const P=Math.min(ws(V),rn),E=Kr(R=>V.next(P*R).value,P,30);return P+"ms "+E},toTransition:()=>{}};return V}on.applyToOptions=t=>{const e=wl(t,100,on);return t.ease=e.ease,t.duration=ft(e.duration),t.type="keyframes",t};function Bn({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:l,restDelta:u=.5,restSpeed:c}){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=r===void 0?w:r(w);x!==w&&(v=x-d);const S=A=>-v*Math.exp(-A/s),b=A=>x+S(A),V=A=>{const L=S(A),W=b(A);f.done=Math.abs(L)<=u,f.value=f.done?x:W};let P,E;const R=A=>{g(f.value)&&(P=A,E=on({keyframes:[f.value,y(f.value)],velocity:Hr(b,A,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:c}))};return R(0),{calculatedDuration:null,next:A=>{let L=!1;return!E&&P===void 0&&(L=!0,V(A),R(A)),P!==void 0&&A>=P?E.next(A-P):(!L&&V(A),f)}}}function El(t,e,n){const s=[],i=n||At.mix||Wr,o=t.length-1;for(let r=0;r<o;r++){let a=i(t[r],t[r+1]);if(e){const l=Array.isArray(e)?e[r]||ut:e;a=Le(l,a)}s.push(a)}return s}function Vl(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(Pt(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=El(e,s,i),l=a.length,u=c=>{if(r&&c<t[0])return e[0];let d=0;if(l>1)for(;d<t.length-2&&!(c<t[d+1]);d++);const f=Ve(t[d],t[d+1],c);return a[d](f)};return n?c=>u(Ct(t[0],t[o-1],c)):u}function Dl(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ve(0,e,s);t.push(z(n,1,i))}}function kl(t){const e=[0];return Dl(e,t.length-1),e}function Rl(t,e){return t.map(n=>n*e)}function Nl(t,e){return t.map(()=>e||Nr).splice(0,t.length-1)}function te({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=Ha(s)?s.map(ii):ii(s),o={done:!1,value:e[0]},r=Rl(n&&n.length===e.length?n:kl(e),t),a=Vl(r,e,{ease:Array.isArray(i)?i:Nl(e,i)});return{calculatedDuration:t,next:l=>(o.value=a(l),o.done=l>=t,o)}}const Il=t=>t!==null;function Ts(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(Il),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Ll={decay:Bn,inertia:Bn,tween:te,keyframes:te,spring:on};function Xr(t){typeof t.type=="string"&&(t.type=Ll[t.type])}class Ss{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 Ol=t=>t/100;class Cs extends Ss{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;Xr(e);const{type:n=te,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const l=n||te;process.env.NODE_ENV!=="production"&&l!==te&&Pt(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==te&&typeof a[0]!="number"&&(this.mixKeyframes=Le(Ol,Wr(a[0],a[1])),a=[0,100]);const u=l({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=ws(u));const{calculatedDuration:c}=u;this.calculatedDuration=c,this.resolvedDuration=c+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:c,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-u*(this.playbackSpeed>=0?1:-1),S=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,V=s;if(d){const A=Math.min(this.currentTime,i)/a;let L=Math.floor(A),W=A%1;!W&&A>=1&&(W=1),W===1&&L--,L=Math.min(L,d+1),!!(L%2)&&(f==="reverse"?(W=1-W,g&&(W-=g/a)):f==="mirror"&&(V=r)),b=Ct(0,1,W)*a}const P=S?{done:!1,value:c[0]}:V.next(b);o&&(P.value=o(P.value));let{done:E}=P;!S&&l!==null&&(E=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const R=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return R&&y!==Bn&&(P.value=Ts(c,this.options,w,this.speed)),v&&v(P.value),R&&this.finish(),P}then(e,n){return this.finished.then(e,n)}get duration(){return ct(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ct(e)}get time(){return ct(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=ct(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=bl,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 Fl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Xt=t=>t*180/Math.PI,$n=t=>{const e=Xt(Math.atan2(t[1],t[0]));return zn(e)},Bl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:$n,rotateZ:$n,skewX:t=>Xt(Math.atan(t[1])),skewY:t=>Xt(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},zn=t=>(t=t%360,t<0&&(t+=360),t),ui=$n,di=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),hi=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),$l={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:di,scaleY:hi,scale:t=>(di(t)+hi(t))/2,rotateX:t=>zn(Xt(Math.atan2(t[6],t[5]))),rotateY:t=>zn(Xt(Math.atan2(-t[2],t[0]))),rotateZ:ui,rotate:ui,skewX:t=>Xt(Math.atan(t[4])),skewY:t=>Xt(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Un(t){return t.includes("scale")?1:0}function _n(t,e){if(!t||t==="none")return Un(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=$l,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Bl,i=a}if(!i)return Un(e);const o=s[e],r=i[1].split(",").map(Ul);return typeof o=="function"?o(r):r[o]}const zl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return _n(n,e)};function Ul(t){return parseFloat(t.trim())}const de=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],he=new Set(de),fi=t=>t===ue||t===M,_l=new Set(["x","y","z"]),Wl=de.filter(t=>!_l.has(t));function Kl(t){const e=[];return Wl.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const Gt={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})=>_n(e,"x"),y:(t,{transform:e})=>_n(e,"y")};Gt.translateX=Gt.x;Gt.translateY=Gt.y;const Yt=new Set;let Wn=!1,Kn=!1,Hn=!1;function Gr(){if(Kn){const t=Array.from(Yt).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Kl(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Kn=!1,Wn=!1,Yt.forEach(t=>t.complete(Hn)),Yt.clear()}function Yr(){Yt.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Kn=!0)})}function Hl(){Hn=!0,Yr(),Gr(),Hn=!1}class Ps{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(Yt.add(this),Wn||(Wn=!0,B.read(Yr),B.resolveKeyframes(Gr))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const o=i?.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(s&&n){const a=s.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),i&&o===void 0&&i.set(e[0])}Fl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Yt.delete(this)}cancel(){this.state==="scheduled"&&(Yt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Xl=t=>t.startsWith("--");function Gl(t,e,n){Xl(e)?t.style.setProperty(e,n):t.style[e]=n}const Yl=ds(()=>window.ScrollTimeline!==void 0),ql={};function Jl(t,e){const n=ds(t);return()=>ql[e]??n()}const qr=Jl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Se=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,mi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Se([0,.65,.55,1]),circOut:Se([.55,0,1,.45]),backIn:Se([.31,.01,.66,-.59]),backOut:Se([.33,1.53,.69,.99])};function Jr(t,e){if(t)return typeof t=="function"?qr()?Kr(t,e):"ease-out":Ir(t)?Se(t):Array.isArray(t)?t.map(n=>Jr(n,e)||mi.easeOut):mi[t]}function Zl(t,e,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:l}={},u=void 0){const c={[e]:n};l&&(c.offset=l);const d=Jr(a,i);Array.isArray(d)&&(c.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(c,f)}function Zr(t){return typeof t=="function"&&"applyToOptions"in t}function Ql({type:t,...e}){return Zr(t)&&qr()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class tc extends Ss{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:l}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,Pt(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=Ql(e);this.animation=Zl(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const c=Ts(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(c):Gl(n,s,c),this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return ct(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ct(e)}get time(){return ct(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&&Yl()?(this.animation.timeline=e,ut):n(this)}}const Qr={anticipate:Dr,backInOut:Vr,circInOut:Rr};function ec(t){return t in Qr}function nc(t){typeof t.ease=="string"&&ec(t.ease)&&(t.ease=Qr[t.ease])}const pi=10;class sc extends tc{constructor(e){nc(e),Xr(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Cs({...r,autoplay:!1}),l=ft(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-pi).value,a.sample(l).value,pi),a.stop()}}const gi=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Rt.test(t)||t==="0")&&!t.startsWith("url("));function ic(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 rc(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=gi(i,e),a=gi(o,e);return ce(r===a,`You are trying to animate ${e} from "${i}" to "${o}". "${r?o:i}" is not an animatable value.`,"value-not-animatable"),!r||!a?!1:ic(t)||(n==="spring"||Zr(n))&&s}function Xn(t){t.duration=0,t.type="keyframes"}const oc=new Set(["opacity","clipPath","filter","transform"]),ac=ds(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function lc(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=e.owner.getProps();return ac()&&n&&oc.has(n)&&(n!=="transform"||!u)&&!l&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const cc=40;class uc extends Ss{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:l,motionValue:u,element:c,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=st.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:l,motionValue:u,element:c,...d},g=c?.KeyframeResolver||Ps;this.keyframeResolver=new g(a,(y,v,w)=>this.onKeyframesResolved(y,v,f,!w),l,u,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:l,isHandoff:u,onUpdate:c}=s;this.resolvedAt=st.now(),rc(e,o,r,a)||((At.instantAnimations||!l)&&c?.(Ts(e,s,n)),e[0]=e[e.length-1],Xn(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>cc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&lc(f)?new sc({...f,element:f.motionValue.owner.current}):new Cs(f);g.finished.then(()=>this.notifyFinished()).catch(ut),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(),Hl()),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 dc=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function hc(t){const e=dc.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const fc=4;function to(t,e,n=1){Pt(n<=fc,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=hc(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return Tr(r)?parseFloat(r):r}return ys(i)?to(i,e,n+1):i}function As(t,e){return t?.[e]??t?.default??t}const eo=new Set(["width","height","top","left","right","bottom",...de]),mc={test:t=>t==="auto",parse:t=>t},no=t=>e=>e.test(t),so=[ue,M,wt,Dt,il,sl,mc],yi=t=>so.find(no(t));function pc(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Cr(t):!0}const gc=new Set(["brightness","contrast","saturate","opacity"]);function yc(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(xs)||[];if(!s)return t;const i=n.replace(s,"");let o=gc.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const xc=/\b([a-z-]*)\(.*?\)/gu,Gn={...Rt,getAnimatableNone:t=>{const e=t.match(xc);return e?e.map(yc).join(" "):t}},xi={...ue,transform:Math.round},vc={rotate:Dt,rotateX:Dt,rotateY:Dt,rotateZ:Dt,scale:He,scaleX:He,scaleY:He,scaleZ:He,skew:Dt,skewX:Dt,skewY:Dt,distance:M,translateX:M,translateY:M,translateZ:M,x:M,y:M,z:M,perspective:M,transformPerspective:M,opacity:De,originX:ri,originY:ri,originZ:M},Ms={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,...vc,zIndex:xi,fillOpacity:De,strokeOpacity:De,numOctaves:xi},bc={...Ms,color:X,backgroundColor:X,outlineColor:X,fill:X,stroke:X,borderColor:X,borderTopColor:X,borderRightColor:X,borderBottomColor:X,borderLeftColor:X,filter:Gn,WebkitFilter:Gn},io=t=>bc[t];function ro(t,e){let n=io(t);return n!==Gn&&(n=Rt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const wc=new Set(["auto","none","0"]);function Tc(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!wc.has(o)&&ke(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=ro(n,i)}class Sc extends Ps{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<e.length;l++){let u=e[l];if(typeof u=="string"&&(u=u.trim(),ys(u))){const c=to(u,n.current);c!==void 0&&(e[l]=c),l===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!eo.has(s)||e.length!==2)return;const[i,o]=e,r=yi(i),a=yi(o);if(r!==a)if(fi(r)&&fi(a))for(let l=0;l<e.length;l++){const u=e[l];typeof u=="string"&&(e[l]=parseFloat(u))}else Gt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||pc(e[i]))&&s.push(i);s.length&&Tc(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=Gt[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=Gt[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{e.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function Cc(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 oo=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function ao(t){return Sr(t)&&"offsetHeight"in t}const vi=30,Pc=t=>!isNaN(parseFloat(t));class Ac{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 o of this.dependents)o.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=Pc(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&fs(!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 hs);const s=this.events[e].add(n);return e==="change"?()=>{s(),B.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>vi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,vi);return Pr(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 ae(t,e){return new Ac(t,e)}const{schedule:js}=Lr(queueMicrotask,!1),dt={x:!1,y:!1};function lo(){return dt.x||dt.y}function Mc(t){return t==="x"||t==="y"?dt[t]?null:(dt[t]=!0,()=>{dt[t]=!1}):dt.x||dt.y?null:(dt.x=dt.y=!0,()=>{dt.x=dt.y=!1})}function co(t,e){const n=Cc(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function bi(t){return!(t.pointerType==="touch"||lo())}function jc(t,e,n={}){const[s,i,o]=co(t,n),r=a=>{if(!bi(a))return;const{target:l}=a,u=e(l,a);if(typeof u!="function"||!l)return;const c=d=>{bi(d)&&(u(d),l.removeEventListener("pointerleave",c))};l.addEventListener("pointerleave",c,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const uo=(t,e)=>e?t===e?!0:uo(t,e.parentElement):!1,Es=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Ec=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Vc(t){return Ec.has(t.tagName)||t.tabIndex!==-1}const Je=new WeakSet;function wi(t){return e=>{e.key==="Enter"&&t(e)}}function Cn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Dc=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=wi(()=>{if(Je.has(n))return;Cn(n,"down");const i=wi(()=>{Cn(n,"up")}),o=()=>Cn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function Ti(t){return Es(t)&&!lo()}function kc(t,e,n={}){const[s,i,o]=co(t,n),r=a=>{const l=a.currentTarget;if(!Ti(a))return;Je.add(l);const u=e(l,a),c=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),Je.has(l)&&Je.delete(l),Ti(g)&&typeof u=="function"&&u(g,{success:y})},d=g=>{c(g,l===window||l===document||n.useGlobalTarget||uo(l,g.target))},f=g=>{c(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),ao(a)&&(a.addEventListener("focus",u=>Dc(u,i)),!Vc(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function ho(t){return Sr(t)&&"ownerSVGElement"in t}function Rc(t){return ho(t)&&t.tagName==="svg"}const et=t=>!!(t&&t.getVelocity),Nc=[...so,X,Rt],Ic=t=>Nc.find(no(t)),Vs=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Si(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Lc(...t){return e=>{let n=!1;const s=t.map(i=>{const o=Si(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():Si(t[i],null)}}}}function Oc(...t){return ht.useCallback(Lc(...t),t)}class Fc extends ht.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=ao(s)&&s.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=i-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Bc({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),o=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Vs),l=Oc(o,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:c,top:d,left:f,right:g}=r.current;if(e||!o.current||!u||!c)return;const y=n==="left"?`left: ${f}`:`right: ${g}`;o.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 La=Object.create;var hi=Object.defineProperty;var Oa=Object.getOwnPropertyDescriptor;var Fa=Object.getOwnPropertyNames;var Ba=Object.getPrototypeOf,$a=Object.prototype.hasOwnProperty;var za=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Fa(e))!$a.call(t,i)&&i!==n&&hi(t,i,{get:()=>e[i],enumerable:!(s=Oa(e,i))||s.enumerable});return t};var Ua=(t,e,n)=>(n=t!=null?La(Ba(t)):{},za(e||!t||!t.__esModule?hi(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),J=require("lucide-react"),kr=require("@ai-sdk/react"),pn=require("ai"),Dr=require("@radix-ui/react-slot"),Vr=require("class-variance-authority"),_a=require("clsx"),Wa=require("tailwind-merge"),Ka=require("@radix-ui/react-tooltip"),fi=require("@radix-ui/react-use-controllable-state"),Ha=require("@radix-ui/react-collapsible"),Xa=require("./server.cjs");function vs(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 bt=vs(m),ye=vs(Ka),bs=vs(Ha);function tt(...t){return Wa.twMerge(_a.clsx(t))}const te=Vr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),gn=bt.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},o)=>{const r=s?Dr.Slot:"button";return h.jsx(r,{ref:o,"data-slot":"button",className:tt(te({variant:e,size:n,className:t})),...i})});gn.displayName="Button";const Ga=Vr.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 Rn({className:t,variant:e,asChild:n=!1,...s}){const i=n?Dr.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:tt(Ga({variant:e}),t),...s})}const qa=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,o]=bt.useState(!0);bt.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const c=a.scrollHeight;c>n?a.style.height=`${n}px`:a.style.height=`${c+6}px`}},[t.current,e])},Rr=bt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...o},r)=>{const a=bt.useRef(null),[c,u]=bt.useState("");return qa({textAreaRef:a,triggerAutoSize:c,maxHeight:t,minHeight:e}),m.useImperativeHandle(r,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),bt.useEffect(()=>{u(i)},[o?.defaultValue,i]),h.jsx("textarea",{...o,value:i,ref:a,className:tt("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:l=>{u(l.target.value),s?.(l)}})});Rr.displayName="AutosizeTextarea";function Ya({delayDuration:t=0,...e}){return h.jsx(ye.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Yt({...t}){return h.jsx(Ya,{children:h.jsx(ye.Root,{"data-slot":"tooltip",...t})})}function Jt({...t}){return h.jsx(ye.Trigger,{"data-slot":"tooltip-trigger",...t})}function Zt({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(ye.Portal,{children:h.jsxs(ye.Content,{"data-slot":"tooltip-content",sideOffset:e,className:tt("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(ye.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function mi({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:tt("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 ws=m.createContext({});function Ts(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const Ss=typeof window<"u",Nr=Ss?m.useLayoutEffect:m.useEffect,Tn=m.createContext(null);function Cs(t,e){t.indexOf(e)===-1&&t.push(e)}function As(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Vt=(t,e,n)=>n>e?e:n<t?t:n;function Yn(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let we=()=>{},Rt=()=>{};process.env.NODE_ENV!=="production"&&(we=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(Yn(e,n))},Rt=(t,e,n)=>{if(!t)throw new Error(Yn(e,n))});const Nt={},Ir=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Lr(t){return typeof t=="object"&&t!==null}const Or=t=>/^0[^.\s]+$/u.test(t);function Ps(t){let e;return()=>(e===void 0&&(e=t()),e)}const mt=t=>t,Ja=(t,e)=>n=>e(t(n)),Ge=(...t)=>t.reduce(Ja),Ue=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Ms{constructor(){this.subscriptions=[]}add(e){return Cs(this.subscriptions,e),()=>As(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const wt=t=>t*1e3,ft=t=>t/1e3;function Fr(t,e){return e?t*(1e3/e):0}const pi=new Set;function js(t,e,n){t||pi.has(e)||(console.warn(Yn(e,n)),pi.add(e))}const Br=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Za=1e-7,Qa=12;function tc(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=Br(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>Za&&++a<Qa);return r}function qe(t,e,n,s){if(t===e&&n===s)return mt;const i=o=>tc(o,0,1,t,n);return o=>o===0||o===1?o:Br(i(o),e,s)}const $r=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,zr=t=>e=>1-t(1-e),Ur=qe(.33,1.53,.69,.99),Es=zr(Ur),_r=$r(Es),Wr=t=>(t*=2)<1?.5*Es(t):.5*(2-Math.pow(2,-10*(t-1))),ks=t=>1-Math.sin(Math.acos(t)),Kr=zr(ks),Hr=$r(ks),ec=qe(.42,0,1,1),nc=qe(0,0,.58,1),Xr=qe(.42,0,.58,1),sc=t=>Array.isArray(t)&&typeof t[0]!="number",Gr=t=>Array.isArray(t)&&typeof t[0]=="number",gi={linear:mt,easeIn:ec,easeInOut:Xr,easeOut:nc,circIn:ks,circInOut:Hr,circOut:Kr,backIn:Es,backInOut:_r,backOut:Ur,anticipate:Wr},ic=t=>typeof t=="string",yi=t=>{if(Gr(t)){Rt(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return qe(e,n,s,i)}else if(ic(t))return Rt(gi[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),gi[t];return t},rn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function rc(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(l){r.has(l)&&(u.schedule(l),t()),l(a)}const u={schedule:(l,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&r.add(l),y.has(l)||y.add(l),l},cancel:l=>{s.delete(l),r.delete(l)},process:l=>{if(a=l,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(c),n.clear(),i=!1,o&&(o=!1,u.process(l))}};return u}const oc=40;function qr(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=rn.reduce((T,D)=>(T[D]=rc(o),T),{}),{setup:a,read:c,resolveKeyframes:u,preUpdate:l,update:d,preRender:f,render:p,postRender:y}=r,v=()=>{const T=Nt.useManualTiming?i.timestamp:performance.now();n=!1,Nt.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(T-i.timestamp,oc),1)),i.timestamp=T,i.isProcessing=!0,a.process(i),c.process(i),u.process(i),l.process(i),d.process(i),f.process(i),p.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},S=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:rn.reduce((T,D)=>{const M=r[D];return T[D]=(I,R=!1,E=!1)=>(n||S(),M.schedule(I,R,E)),T},{}),cancel:T=>{for(let D=0;D<rn.length;D++)r[rn[D]].cancel(T)},state:i,steps:r}}const{schedule:W,cancel:Ut,state:Q,steps:Nn}=qr(typeof requestAnimationFrame<"u"?requestAnimationFrame:mt,!0);let un;function ac(){un=void 0}const rt={now:()=>(un===void 0&&rt.set(Q.isProcessing||Nt.useManualTiming?Q.timestamp:performance.now()),un),set:t=>{un=t,queueMicrotask(ac)}},Yr=t=>e=>typeof e=="string"&&e.startsWith(t),Ds=Yr("--"),cc=Yr("var(--"),Vs=t=>cc(t)?lc.test(t.split("/*")[0].trim()):!1,lc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Te={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},_e={...Te,transform:t=>Vt(0,1,t)},on={...Te,default:1},Le=t=>Math.round(t*1e5)/1e5,Rs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function uc(t){return t==null}const dc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ns=(t,e)=>n=>!!(typeof n=="string"&&dc.test(n)&&n.startsWith(t)||e&&!uc(n)&&Object.prototype.hasOwnProperty.call(n,e)),Jr=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(Rs);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},hc=t=>Vt(0,255,t),In={...Te,transform:t=>Math.round(hc(t))},ne={test:Ns("rgb","red"),parse:Jr("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+In.transform(t)+", "+In.transform(e)+", "+In.transform(n)+", "+Le(_e.transform(s))+")"};function fc(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 Jn={test:Ns("#"),parse:fc,transform:ne.transform},Ye=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),zt=Ye("deg"),Mt=Ye("%"),V=Ye("px"),mc=Ye("vh"),pc=Ye("vw"),xi={...Mt,parse:t=>Mt.parse(t)/100,transform:t=>Mt.transform(t*100)},de={test:Ns("hsl","hue"),parse:Jr("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+Mt.transform(Le(e))+", "+Mt.transform(Le(n))+", "+Le(_e.transform(s))+")"},Y={test:t=>ne.test(t)||Jn.test(t)||de.test(t),parse:t=>ne.test(t)?ne.parse(t):de.test(t)?de.parse(t):Jn.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ne.transform(t):de.transform(t),getAnimatableNone:t=>{const e=Y.parse(t);return e.alpha=0,Y.transform(e)}},gc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function yc(t){return isNaN(t)&&typeof t=="string"&&(t.match(Rs)?.length||0)+(t.match(gc)?.length||0)>0}const Zr="number",Qr="color",xc="var",vc="var(",vi="${}",bc=/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 o=0;const a=e.replace(bc,c=>(Y.test(c)?(s.color.push(o),i.push(Qr),n.push(Y.parse(c))):c.startsWith(vc)?(s.var.push(o),i.push(xc),n.push(c)):(s.number.push(o),i.push(Zr),n.push(parseFloat(c))),++o,vi)).split(vi);return{values:n,split:a,indexes:s,types:i}}function to(t){return We(t).values}function eo(t){const{split:e,types:n}=We(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===Zr?o+=Le(i[r]):a===Qr?o+=Y.transform(i[r]):o+=i[r]}return o}}const wc=t=>typeof t=="number"?0:Y.test(t)?Y.getAnimatableNone(t):t;function Tc(t){const e=to(t);return eo(t)(e.map(wc))}const _t={test:yc,parse:to,createTransformer:eo,getAnimatableNone:Tc};function Ln(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 Sc({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=Ln(c,a,t+1/3),o=Ln(c,a,t),r=Ln(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function yn(t,e){return n=>n>0?e:t}const X=(t,e,n)=>t+(e-t)*n,On=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},Cc=[Jn,ne,de],Ac=t=>Cc.find(e=>e.test(t));function bi(t){const e=Ac(t);if(we(!!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===de&&(n=Sc(n)),n}const wi=(t,e)=>{const n=bi(t),s=bi(e);if(!n||!s)return yn(t,e);const i={...n};return o=>(i.red=On(n.red,s.red,o),i.green=On(n.green,s.green,o),i.blue=On(n.blue,s.blue,o),i.alpha=X(n.alpha,s.alpha,o),ne.transform(i))},Zn=new Set(["none","hidden"]);function Pc(t,e){return Zn.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Mc(t,e){return n=>X(t,e,n)}function Is(t){return typeof t=="number"?Mc:typeof t=="string"?Vs(t)?yn:Y.test(t)?wi:kc:Array.isArray(t)?no:typeof t=="object"?Y.test(t)?wi:jc:yn}function no(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>Is(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function jc(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=Is(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function Ec(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],r=t.indexes[o][s[o]],a=t.values[r]??0;n[i]=a,s[o]++}return n}const kc=(t,e)=>{const n=_t.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?Zn.has(t)&&!i.values.length||Zn.has(e)&&!s.values.length?Pc(t,e):Ge(no(Ec(s,i),i.values),n):(we(!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"),yn(t,e))};function so(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?X(t,e,n):Is(t)(t,e)}const Dc=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>W.update(e,n),stop:()=>Ut(e),now:()=>Q.isProcessing?Q.timestamp:rt.now()}},io=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},xn=2e4;function Ls(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<xn;)e+=n,s=t.next(e);return e>=xn?1/0:e}function Vc(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(Ls(s),xn);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:ft(i)}}const Rc=5;function ro(t,e,n){const s=Math.max(e-Rc,0);return Fr(n-t(s),e-s)}const H={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},Fn=.001;function Nc({duration:t=H.duration,bounce:e=H.bounce,velocity:n=H.velocity,mass:s=H.mass}){let i,o;we(t<=wt(H.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=Vt(H.minDamping,H.maxDamping,r),t=Vt(H.minDuration,H.maxDuration,ft(t)),r<1?(i=u=>{const l=u*r,d=l*t,f=l-n,p=Qn(u,r),y=Math.exp(-d);return Fn-f/p*y},o=u=>{const d=u*r*t,f=d*n+n,p=Math.pow(r,2)*Math.pow(u,2)*t,y=Math.exp(-d),v=Qn(Math.pow(u,2),r);return(-i(u)+Fn>0?-1:1)*((f-p)*y)/v}):(i=u=>{const l=Math.exp(-u*t),d=(u-n)*t+1;return-Fn+l*d},o=u=>{const l=Math.exp(-u*t),d=(n-u)*(t*t);return l*d});const a=5/t,c=Lc(i,o,a);if(t=wt(t),isNaN(c))return{stiffness:H.stiffness,damping:H.damping,duration:t};{const u=Math.pow(c,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const Ic=12;function Lc(t,e,n){let s=n;for(let i=1;i<Ic;i++)s=s-t(s)/e(s);return s}function Qn(t,e){return t*Math.sqrt(1-e*e)}const Oc=["duration","bounce"],Fc=["stiffness","damping","mass"];function Ti(t,e){return e.some(n=>t[n]!==void 0)}function Bc(t){let e={velocity:H.velocity,stiffness:H.stiffness,damping:H.damping,mass:H.mass,isResolvedFromDuration:!1,...t};if(!Ti(t,Fc)&&Ti(t,Oc))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*Vt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:H.mass,stiffness:i,damping:o}}else{const n=Nc(t);e={...e,...n,mass:H.mass},e.isResolvedFromDuration=!0}return e}function vn(t=H.visualDuration,e=H.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:c,damping:u,mass:l,duration:d,velocity:f,isResolvedFromDuration:p}=Bc({...n,velocity:-ft(n.velocity||0)}),y=f||0,v=u/(2*Math.sqrt(c*l)),S=r-o,x=ft(Math.sqrt(c/l)),b=Math.abs(S)<5;s||(s=b?H.restSpeed.granular:H.restSpeed.default),i||(i=b?H.restDelta.granular:H.restDelta.default);let T;if(v<1){const M=Qn(x,v);T=I=>{const R=Math.exp(-v*x*I);return r-R*((y+v*x*S)/M*Math.sin(M*I)+S*Math.cos(M*I))}}else if(v===1)T=M=>r-Math.exp(-x*M)*(S+(y+x*S)*M);else{const M=x*Math.sqrt(v*v-1);T=I=>{const R=Math.exp(-v*x*I),E=Math.min(M*I,300);return r-R*((y+v*x*S)*Math.sinh(E)+M*S*Math.cosh(E))/M}}const D={calculatedDuration:p&&d||null,next:M=>{const I=T(M);if(p)a.done=M>=d;else{let R=M===0?y:0;v<1&&(R=M===0?wt(y):ro(T,M,I));const E=Math.abs(R)<=s,_=Math.abs(r-I)<=i;a.done=E&&_}return a.value=a.done?r:I,a},toString:()=>{const M=Math.min(Ls(D),xn),I=io(R=>D.next(M*R).value,M,30);return M+"ms "+I},toTransition:()=>{}};return D}vn.applyToOptions=t=>{const e=Vc(t,100,vn);return t.ease=e.ease,t.duration=wt(e.duration),t.type="keyframes",t};function ts({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:c,restDelta:u=.5,restSpeed:l}){const d=t[0],f={done:!1,value:d},p=E=>a!==void 0&&E<a||c!==void 0&&E>c,y=E=>a===void 0?c:c===void 0||Math.abs(a-E)<Math.abs(c-E)?a:c;let v=n*e;const S=d+v,x=r===void 0?S:r(S);x!==S&&(v=x-d);const b=E=>-v*Math.exp(-E/s),T=E=>x+b(E),D=E=>{const _=b(E),B=T(E);f.done=Math.abs(_)<=u,f.value=f.done?x:B};let M,I;const R=E=>{p(f.value)&&(M=E,I=vn({keyframes:[f.value,y(f.value)],velocity:ro(T,E,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:l}))};return R(0),{calculatedDuration:null,next:E=>{let _=!1;return!I&&M===void 0&&(_=!0,D(E),R(E)),M!==void 0&&E>=M?I.next(E-M):(!_&&D(E),f)}}}function $c(t,e,n){const s=[],i=n||Nt.mix||so,o=t.length-1;for(let r=0;r<o;r++){let a=i(t[r],t[r+1]);if(e){const c=Array.isArray(e)?e[r]||mt:e;a=Ge(c,a)}s.push(a)}return s}function zc(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(Rt(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=$c(e,s,i),c=a.length,u=l=>{if(r&&l<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(l<t[d+1]);d++);const f=Ue(t[d],t[d+1],l);return a[d](f)};return n?l=>u(Vt(t[0],t[o-1],l)):u}function Uc(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ue(0,e,s);t.push(X(n,1,i))}}function _c(t){const e=[0];return Uc(e,t.length-1),e}function Wc(t,e){return t.map(n=>n*e)}function Kc(t,e){return t.map(()=>e||Xr).splice(0,t.length-1)}function he({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=sc(s)?s.map(yi):yi(s),o={done:!1,value:e[0]},r=Wc(n&&n.length===e.length?n:_c(e),t),a=zc(r,e,{ease:Array.isArray(i)?i:Kc(e,i)});return{calculatedDuration:t,next:c=>(o.value=a(c),o.done=c>=t,o)}}const Hc=t=>t!==null;function Os(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(Hc),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Xc={decay:ts,inertia:ts,tween:he,keyframes:he,spring:vn};function oo(t){typeof t.type=="string"&&(t.type=Xc[t.type])}class Fs{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 Gc=t=>t/100;class Bs extends Fs{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!==rt.now()&&this.tick(rt.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;oo(e);const{type:n=he,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const c=n||he;process.env.NODE_ENV!=="production"&&c!==he&&Rt(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==he&&typeof a[0]!="number"&&(this.mixKeyframes=Ge(Gc,so(a[0],a[1])),a=[0,100]);const u=c({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=Ls(u));const{calculatedDuration:l}=u;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:l,repeat:d,repeatType:f,repeatDelay:p,type:y,onUpdate:v,finalKeyframe:S}=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-u*(this.playbackSpeed>=0?1:-1),b=this.playbackSpeed>=0?x<0:x>i;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let T=this.currentTime,D=s;if(d){const E=Math.min(this.currentTime,i)/a;let _=Math.floor(E),B=E%1;!B&&E>=1&&(B=1),B===1&&_--,_=Math.min(_,d+1),!!(_%2)&&(f==="reverse"?(B=1-B,p&&(B-=p/a)):f==="mirror"&&(D=r)),T=Vt(0,1,B)*a}const M=b?{done:!1,value:l[0]}:D.next(T);o&&(M.value=o(M.value));let{done:I}=M;!b&&c!==null&&(I=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const R=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&I);return R&&y!==ts&&(M.value=Os(l,this.options,S,this.speed)),v&&v(M.value),R&&this.finish(),M}then(e,n){return this.finished.then(e,n)}get duration(){return ft(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ft(e)}get time(){return ft(this.currentTime)}set time(e){e=wt(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(rt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=ft(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Dc,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(rt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function qc(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const se=t=>t*180/Math.PI,es=t=>{const e=se(Math.atan2(t[1],t[0]));return ns(e)},Yc={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:es,rotateZ:es,skewX:t=>se(Math.atan(t[1])),skewY:t=>se(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},ns=t=>(t=t%360,t<0&&(t+=360),t),Si=es,Ci=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Ai=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Jc={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ci,scaleY:Ai,scale:t=>(Ci(t)+Ai(t))/2,rotateX:t=>ns(se(Math.atan2(t[6],t[5]))),rotateY:t=>ns(se(Math.atan2(-t[2],t[0]))),rotateZ:Si,rotate:Si,skewX:t=>se(Math.atan(t[4])),skewY:t=>se(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function ss(t){return t.includes("scale")?1:0}function is(t,e){if(!t||t==="none")return ss(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Jc,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Yc,i=a}if(!i)return ss(e);const o=s[e],r=i[1].split(",").map(Qc);return typeof o=="function"?o(r):r[o]}const Zc=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return is(n,e)};function Qc(t){return parseFloat(t.trim())}const Se=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Ce=new Set(Se),Pi=t=>t===Te||t===V,tl=new Set(["x","y","z"]),el=Se.filter(t=>!tl.has(t));function nl(t){const e=[];return el.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const ie={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})=>is(e,"x"),y:(t,{transform:e})=>is(e,"y")};ie.translateX=ie.x;ie.translateY=ie.y;const re=new Set;let rs=!1,os=!1,as=!1;function ao(){if(os){const t=Array.from(re).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=nl(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}os=!1,rs=!1,re.forEach(t=>t.complete(as)),re.clear()}function co(){re.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(os=!0)})}function sl(){as=!0,co(),ao(),as=!1}class $s{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(re.add(this),rs||(rs=!0,W.read(co),W.resolveKeyframes(ao))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const o=i?.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(s&&n){const a=s.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),i&&o===void 0&&i.set(e[0])}qc(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),re.delete(this)}cancel(){this.state==="scheduled"&&(re.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const il=t=>t.startsWith("--");function rl(t,e,n){il(e)?t.style.setProperty(e,n):t.style[e]=n}const ol=Ps(()=>window.ScrollTimeline!==void 0),al={};function cl(t,e){const n=Ps(t);return()=>al[e]??n()}const lo=cl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Ie=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,Mi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Ie([0,.65,.55,1]),circOut:Ie([.55,0,1,.45]),backIn:Ie([.31,.01,.66,-.59]),backOut:Ie([.33,1.53,.69,.99])};function uo(t,e){if(t)return typeof t=="function"?lo()?io(t,e):"ease-out":Gr(t)?Ie(t):Array.isArray(t)?t.map(n=>uo(n,e)||Mi.easeOut):Mi[t]}function ll(t,e,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:c}={},u=void 0){const l={[e]:n};c&&(l.offset=c);const d=uo(a,i);Array.isArray(d)&&(l.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(l,f)}function ho(t){return typeof t=="function"&&"applyToOptions"in t}function ul({type:t,...e}){return ho(t)&&lo()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class dl extends Fs{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,Rt(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=ul(e);this.animation=ll(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const l=Os(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(l):rl(n,s,l),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return ft(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ft(e)}get time(){return ft(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=wt(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&&ol()?(this.animation.timeline=e,mt):n(this)}}const fo={anticipate:Wr,backInOut:_r,circInOut:Hr};function hl(t){return t in fo}function fl(t){typeof t.ease=="string"&&hl(t.ease)&&(t.ease=fo[t.ease])}const ji=10;class ml extends dl{constructor(e){fl(e),oo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Bs({...r,autoplay:!1}),c=wt(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-ji).value,a.sample(c).value,ji),a.stop()}}const Ei=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(_t.test(t)||t==="0")&&!t.startsWith("url("));function pl(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 gl(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=Ei(i,e),a=Ei(o,e);return we(r===a,`You are trying to animate ${e} from "${i}" to "${o}". "${r?o:i}" is not an animatable value.`,"value-not-animatable"),!r||!a?!1:pl(t)||(n==="spring"||ho(n))&&s}function cs(t){t.duration=0,t.type="keyframes"}const yl=new Set(["opacity","clipPath","filter","transform"]),xl=Ps(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function vl(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return xl()&&n&&yl.has(n)&&(n!=="transform"||!u)&&!c&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const bl=40;class wl extends Fs{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:c,motionValue:u,element:l,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=rt.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:c,motionValue:u,element:l,...d},p=l?.KeyframeResolver||$s;this.keyframeResolver=new p(a,(y,v,S)=>this.onKeyframesResolved(y,v,f,!S),c,u,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:c,isHandoff:u,onUpdate:l}=s;this.resolvedAt=rt.now(),gl(e,o,r,a)||((Nt.instantAnimations||!c)&&l?.(Os(e,s,n)),e[0]=e[e.length-1],cs(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>bl?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},p=!u&&vl(f)?new ml({...f,element:f.motionValue.owner.current}):new Bs(f);p.finished.then(()=>this.notifyFinished()).catch(mt),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),sl()),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 Tl=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Sl(t){const e=Tl.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const Cl=4;function mo(t,e,n=1){Rt(n<=Cl,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=Sl(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return Ir(r)?parseFloat(r):r}return Vs(i)?mo(i,e,n+1):i}function zs(t,e){return t?.[e]??t?.default??t}const po=new Set(["width","height","top","left","right","bottom",...Se]),Al={test:t=>t==="auto",parse:t=>t},go=t=>e=>e.test(t),yo=[Te,V,Mt,zt,pc,mc,Al],ki=t=>yo.find(go(t));function Pl(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Or(t):!0}const Ml=new Set(["brightness","contrast","saturate","opacity"]);function jl(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(Rs)||[];if(!s)return t;const i=n.replace(s,"");let o=Ml.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const El=/\b([a-z-]*)\(.*?\)/gu,ls={..._t,getAnimatableNone:t=>{const e=t.match(El);return e?e.map(jl).join(" "):t}},Di={...Te,transform:Math.round},kl={rotate:zt,rotateX:zt,rotateY:zt,rotateZ:zt,scale:on,scaleX:on,scaleY:on,scaleZ:on,skew:zt,skewX:zt,skewY:zt,distance:V,translateX:V,translateY:V,translateZ:V,x:V,y:V,z:V,perspective:V,transformPerspective:V,opacity:_e,originX:xi,originY:xi,originZ:V},Us={borderWidth:V,borderTopWidth:V,borderRightWidth:V,borderBottomWidth:V,borderLeftWidth:V,borderRadius:V,radius:V,borderTopLeftRadius:V,borderTopRightRadius:V,borderBottomRightRadius:V,borderBottomLeftRadius:V,width:V,maxWidth:V,height:V,maxHeight:V,top:V,right:V,bottom:V,left:V,padding:V,paddingTop:V,paddingRight:V,paddingBottom:V,paddingLeft:V,margin:V,marginTop:V,marginRight:V,marginBottom:V,marginLeft:V,backgroundPositionX:V,backgroundPositionY:V,...kl,zIndex:Di,fillOpacity:_e,strokeOpacity:_e,numOctaves:Di},Dl={...Us,color:Y,backgroundColor:Y,outlineColor:Y,fill:Y,stroke:Y,borderColor:Y,borderTopColor:Y,borderRightColor:Y,borderBottomColor:Y,borderLeftColor:Y,filter:ls,WebkitFilter:ls},xo=t=>Dl[t];function vo(t,e){let n=xo(t);return n!==ls&&(n=_t),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Vl=new Set(["auto","none","0"]);function Rl(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!Vl.has(o)&&We(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=vo(n,i)}class Nl extends $s{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let u=e[c];if(typeof u=="string"&&(u=u.trim(),Vs(u))){const l=mo(u,n.current);l!==void 0&&(e[c]=l),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!po.has(s)||e.length!==2)return;const[i,o]=e,r=ki(i),a=ki(o);if(r!==a)if(Pi(r)&&Pi(a))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else ie[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||Pl(e[i]))&&s.push(i);s.length&&Rl(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=ie[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=ie[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}function Il(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 bo=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function wo(t){return Lr(t)&&"offsetHeight"in t}const Vi=30,Ll=t=>!isNaN(parseFloat(t));class Ol{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=rt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=rt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Ll(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&js(!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 Ms);const s=this.events[e].add(n);return e==="change"?()=>{s(),W.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=rt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Vi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Vi);return Fr(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 ve(t,e){return new Ol(t,e)}const{schedule:_s}=qr(queueMicrotask,!1),vt={x:!1,y:!1};function To(){return vt.x||vt.y}function Fl(t){return t==="x"||t==="y"?vt[t]?null:(vt[t]=!0,()=>{vt[t]=!1}):vt.x||vt.y?null:(vt.x=vt.y=!0,()=>{vt.x=vt.y=!1})}function So(t,e){const n=Il(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Ri(t){return!(t.pointerType==="touch"||To())}function Bl(t,e,n={}){const[s,i,o]=So(t,n),r=a=>{if(!Ri(a))return;const{target:c}=a,u=e(c,a);if(typeof u!="function"||!c)return;const l=d=>{Ri(d)&&(u(d),c.removeEventListener("pointerleave",l))};c.addEventListener("pointerleave",l,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const Co=(t,e)=>e?t===e?!0:Co(t,e.parentElement):!1,Ws=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,$l=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function zl(t){return $l.has(t.tagName)||t.tabIndex!==-1}const dn=new WeakSet;function Ni(t){return e=>{e.key==="Enter"&&t(e)}}function Bn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Ul=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=Ni(()=>{if(dn.has(n))return;Bn(n,"down");const i=Ni(()=>{Bn(n,"up")}),o=()=>Bn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function Ii(t){return Ws(t)&&!To()}function _l(t,e,n={}){const[s,i,o]=So(t,n),r=a=>{const c=a.currentTarget;if(!Ii(a))return;dn.add(c);const u=e(c,a),l=(p,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),dn.has(c)&&dn.delete(c),Ii(p)&&typeof u=="function"&&u(p,{success:y})},d=p=>{l(p,c===window||c===document||n.useGlobalTarget||Co(c,p.target))},f=p=>{l(p,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),wo(a)&&(a.addEventListener("focus",u=>Ul(u,i)),!zl(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Ao(t){return Lr(t)&&"ownerSVGElement"in t}function Wl(t){return Ao(t)&&t.tagName==="svg"}const et=t=>!!(t&&t.getVelocity),Kl=[...yo,Y,_t],Hl=t=>Kl.find(go(t)),Ks=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Li(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Xl(...t){return e=>{let n=!1;const s=t.map(i=>{const o=Li(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():Li(t[i],null)}}}}function Gl(...t){return bt.useCallback(Xl(...t),t)}class ql extends bt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=wo(s)&&s.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=i-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Yl({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),o=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Ks),c=Gl(o,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:l,top:d,left:f,right:p}=r.current;if(e||!o.current||!u||!l)return;const y=n==="left"?`left: ${f}`:`right: ${p}`;o.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const S=s??document.head;return S.appendChild(v),v.sheet&&v.sheet.insertRule(`
2
2
  [data-motion-pop-id="${i}"] {
3
3
  position: absolute !important;
4
4
  width: ${u}px !important;
5
- height: ${c}px !important;
5
+ height: ${l}px !important;
6
6
  ${y}px !important;
7
7
  top: ${d}px !important;
8
8
  }
9
- `),()=>{w.contains(v)&&w.removeChild(v)}},[e]),h.jsx(Fc,{isPresent:e,childRef:o,sizeRef:r,children:ht.cloneElement(t,{ref:l})})}const $c=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:a,root:l})=>{const u=as(zc),c=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:c,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const y of u.values())if(!y)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return o&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,y)=>u.set(y,!1))},[n]),ht.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),r==="popLayout"&&(t=h.jsx(Bc,{isPresent:n,anchorX:a,root:l,children:t})),h.jsx(cn.Provider,{value:f,children:t})};function zc(){return new Map}function fo(t=!0){const e=m.useContext(cn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=m.useId();m.useEffect(()=>{if(t)return i(o)},[t]);const r=m.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const Xe=t=>t.key||"";function Ci(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Uc=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:l})=>{const[u,c]=fo(r),d=m.useMemo(()=>Ci(t),[t]),f=r&&!u?[]:d.map(Xe),g=m.useRef(!0),y=m.useRef(d),v=as(()=>new Map),[w,x]=m.useState(d),[S,b]=m.useState(d);wr(()=>{g.current=!1,y.current=d;for(let E=0;E<S.length;E++){const R=Xe(S[E]);f.includes(R)?v.delete(R):v.get(R)!==!0&&v.set(R,!1)}},[S,f.length,f.join("-")]);const V=[];if(d!==w){let E=[...d];for(let R=0;R<S.length;R++){const A=S[R],L=Xe(A);f.includes(L)||(E.splice(R,0,A),V.push(A))}return o==="wait"&&V.length&&(E=V),b(Ci(E)),x(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&S.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(os);return h.jsx(h.Fragment,{children:S.map(E=>{const R=Xe(E),A=r&&!u?!1:d===S||f.includes(R),L=()=>{if(v.has(R))v.set(R,!0);else return;let W=!0;v.forEach(U=>{U||(W=!1)}),W&&(P?.(),b(y.current),r&&c?.(),s&&s())};return h.jsx($c,{isPresent:A,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:o,root:l,onExitComplete:A?void 0:L,anchorX:a,children:E},R)})})},Ds=m.createContext({strict:!1}),Pi={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"]},le={};for(const t in Pi)le[t]={isEnabled:e=>Pi[t].some(n=>!!e[n])};function Yn(t){for(const e in t)le[e]={...le[e],...t[e]}}function _c({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!Pn(e)),i=m.useRef(void 0);if(!Pn(e)){const{renderer:o,...r}=e;i.current=o,Yn(r)}return m.useEffect(()=>{Pn(e)&&e().then(({renderer:o,...r})=>{Yn(r),i.current=o,s(!0)})},[]),h.jsx(Ds.Provider,{value:{renderer:i.current,strict:n},children:t})}function Pn(t){return typeof t=="function"}const Wc=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 an(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Wc.has(t)}let mo=t=>!an(t);function Kc(t){typeof t=="function"&&(mo=e=>e.startsWith("on")?!an(e):t(e))}try{Kc(require("@emotion/is-prop-valid").default)}catch{}function Hc(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(mo(i)||n===!0&&an(i)||!e&&!an(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const un=m.createContext({});function dn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Re(t){return typeof t=="string"||Array.isArray(t)}const ks=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Rs=["initial",...ks];function hn(t){return dn(t.animate)||Rs.some(e=>Re(t[e]))}function po(t){return!!(hn(t)||t.variants)}function Xc(t,e){if(hn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Re(n)?n:void 0,animate:Re(s)?s:void 0}}return t.inherit!==!1?e:{}}function Gc(t){const{initial:e,animate:n}=Xc(t,m.useContext(un));return m.useMemo(()=>({initial:e,animate:n}),[Ai(e),Ai(n)])}function Ai(t){return Array.isArray(t)?t.join(" "):t}const Ne={};function Yc(t){for(const e in t)Ne[e]=t[e],gs(e)&&(Ne[e].isCSSVariable=!0)}function go(t,{layout:e,layoutId:n}){return he.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Ne[t]||t==="opacity")}const qc={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Jc=de.length;function Zc(t,e,n){let s="",i=!0;for(let o=0;o<Jc;o++){const r=de[o],a=t[r];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(r.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=oo(a,Ms[r]);if(!l){i=!1;const c=qc[r]||r;s+=`${c}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function Ns(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const l in e){const u=e[l];if(he.has(l)){r=!0;continue}else if(gs(l)){i[l]=u;continue}else{const c=oo(u,Ms[l]);l.startsWith("origin")?(a=!0,o[l]=c):s[l]=c}}if(e.transform||(r||n?s.transform=Zc(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:c=0}=o;s.transformOrigin=`${l} ${u} ${c}`}}const Is=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function yo(t,e,n){for(const s in e)!et(e[s])&&!go(s,n)&&(t[s]=e[s])}function Qc({transformTemplate:t},e){return m.useMemo(()=>{const n=Is();return Ns(n,e,t),Object.assign({},n.vars,n.style)},[e])}function tu(t,e){const n=t.style||{},s={};return yo(s,n,t),Object.assign(s,Qc(t,e)),s}function eu(t,e){const n={},s=tu(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 nu={offset:"stroke-dashoffset",array:"stroke-dasharray"},su={offset:"strokeDashoffset",array:"strokeDasharray"};function iu(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?nu:su;t[o.offset]=M.transform(-s);const r=M.transform(e),a=M.transform(n);t[o.array]=`${r} ${a}`}function xo(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},l,u,c){if(Ns(t,a,u),l){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=c?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&iu(d,i,o,r,!1)}const vo=()=>({...Is(),attrs:{}}),bo=t=>typeof t=="string"&&t.toLowerCase()==="svg";function ru(t,e,n,s){const i=m.useMemo(()=>{const o=vo();return xo(o,e,bo(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};yo(o,t.style,t),i.style={...o,...i.style}}return i}const ou=["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 Ls(t){return typeof t!="string"||t.includes("-")?!1:!!(ou.indexOf(t)>-1||/[A-Z]/u.test(t))}function au(t,e,n,{latestValues:s},i,o=!1){const a=(Ls(t)?ru:eu)(e,s,i,t),l=Hc(e,typeof t=="string",o),u=t!==m.Fragment?{...l,...a,ref:n}:{},{children:c}=e,d=m.useMemo(()=>et(c)?c.get():c,[c]);return m.createElement(t,{...u,children:d})}function Mi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function Os(t,e,n,s){if(typeof e=="function"){const[i,o]=Mi(s);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=Mi(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function Ze(t){return et(t)?t.get():t}function lu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:cu(n,s,i,t),renderState:e()}}function cu(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=Ze(o[f]);let{initial:r,animate:a}=t;const l=hn(t),u=po(t);e&&u&&!l&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let c=n?n.initial===!1:!1;c=c||r===!1;const d=c?a:r;if(d&&typeof d!="boolean"&&!dn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=Os(t,f[g]);if(y){const{transitionEnd:v,transition:w,...x}=y;for(const S in x){let b=x[S];if(Array.isArray(b)){const V=c?b.length-1:0;b=b[V]}b!==null&&(i[S]=b)}for(const S in v)i[S]=v[S]}}}return i}const wo=t=>(e,n)=>{const s=m.useContext(un),i=m.useContext(cn),o=()=>lu(t,e,s,i);return n?o():as(o)};function Fs(t,e,n){const{style:s}=t,i={};for(const o in s)(et(s[o])||e.style&&et(e.style[o])||go(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const uu=wo({scrapeMotionValuesFromProps:Fs,createRenderState:Is});function To(t,e,n){const s=Fs(t,e,n);for(const i in t)if(et(t[i])||et(e[i])){const o=de.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const du=wo({scrapeMotionValuesFromProps:To,createRenderState:vo}),hu=Symbol.for("motionComponentSymbol");function ee(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function fu(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):ee(n)&&(n.current=s))},[e])}const Bs=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),mu="framerAppearId",So="data-"+Bs(mu),Co=m.createContext({});function pu(t,e,n,s,i){const{visualElement:o}=m.useContext(un),r=m.useContext(Ds),a=m.useContext(cn),l=m.useContext(Vs).reducedMotion,u=m.useRef(null);s=s||r.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const c=u.current,d=m.useContext(Co);c&&!c.projection&&i&&(c.type==="html"||c.type==="svg")&&gu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{c&&f.current&&c.update(n,a)});const g=n[So],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return wr(()=>{c&&(f.current=!0,window.MotionIsMounted=!0,c.updateFeatures(),c.scheduleRenderMicrotask(),y.current&&c.animationState&&c.animationState.animateChanges())}),m.useEffect(()=>{c&&(!y.current&&c.animationState&&c.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),c.enteringChildren=void 0)}),c}function gu(t,e,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Po(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&ee(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u})}function Po(t){if(t)return t.options.allowProjection!==!1?t.projection:Po(t.parent)}function Qe(t,{forwardMotionProps:e=!1}={},n,s){n&&Yn(n);const i=Ls(t)?du:uu;function o(a,l){let u;const c={...m.useContext(Vs),...a,layoutId:yu(a)},{isStatic:d}=c,f=Gc(a),g=i(a,d);if(!d&&ls){xu(c,n);const y=vu(c);u=y.MeasureLayout,f.visualElement=pu(t,g,c,s,y.ProjectionNode)}return h.jsxs(un.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...c}):null,au(t,a,fu(g,f.visualElement,l),g,d,e)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const r=m.forwardRef(o);return r[hu]=t,r}function yu({layoutId:t}){const e=m.useContext(os).id;return e&&t!==void 0?e+"-"+t:t}function xu(t,e){const n=m.useContext(Ds).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?ce(!1,s,"lazy-strict-mode"):Pt(!1,s,"lazy-strict-mode")}}function vu(t){const{drag:e,layout:n}=le;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function bu(t,e){if(typeof Proxy>"u")return Qe;const n=new Map,s=(o,r)=>Qe(o,r,t,e),i=(o,r)=>(process.env.NODE_ENV!=="production"&&fs(!1,"motion() is deprecated. Use motion.create() instead."),s(o,r));return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,Qe(r,void 0,t,e)),n.get(r))})}function Ao({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function wu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function Tu(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 An(t){return t===void 0||t===1}function qn({scale:t,scaleX:e,scaleY:n}){return!An(t)||!An(e)||!An(n)}function Kt(t){return qn(t)||Mo(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Mo(t){return ji(t.x)||ji(t.y)}function ji(t){return t&&t!=="0%"}function ln(t,e,n){const s=t-n,i=e*s;return n+i}function Ei(t,e,n,s,i){return i!==void 0&&(t=ln(t,i,s)),ln(t,n,s)+e}function Jn(t,e=0,n=1,s,i){t.min=Ei(t.min,e,n,s,i),t.max=Ei(t.max,e,n,s,i)}function jo(t,{x:e,y:n}){Jn(t.x,e.translate,e.scale,e.originPoint),Jn(t.y,n.translate,n.scale,n.originPoint)}const Vi=.999999999999,Di=1.0000000000001;function Su(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,r;for(let a=0;a<i;a++){o=n[a],r=o.projectionDelta;const{visualElement:l}=o.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&se(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,jo(t,r)),s&&Kt(o.latestValues)&&se(t,o.latestValues))}e.x<Di&&e.x>Vi&&(e.x=1),e.y<Di&&e.y>Vi&&(e.y=1)}function ne(t,e){t.min=t.min+e,t.max=t.max+e}function ki(t,e,n,s,i=.5){const o=z(t.min,t.max,i);Jn(t,e,n,o,s)}function se(t,e){ki(t.x,e.x,e.scaleX,e.scale,e.originX),ki(t.y,e.y,e.scaleY,e.scale,e.originY)}function Eo(t,e){return Ao(Tu(t.getBoundingClientRect(),e))}function Cu(t,e,n){const s=Eo(t,n),{scroll:i}=e;return i&&(ne(s.x,i.offset.x),ne(s.y,i.offset.y)),s}const Ri=()=>({translate:0,scale:1,origin:0,originPoint:0}),ie=()=>({x:Ri(),y:Ri()}),Ni=()=>({min:0,max:0}),K=()=>({x:Ni(),y:Ni()}),Zn={current:null},Vo={current:!1};function Pu(){if(Vo.current=!0,!!ls)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Zn.current=t.matches;t.addEventListener("change",e),e()}else Zn.current=!1}const Au=new WeakMap;function Mu(t,e,n){for(const s in e){const i=e[s],o=n[s];if(et(i))t.addValue(s,i);else if(et(o))t.addValue(s,ae(i,{owner:t}));else if(o!==i)if(t.hasValue(s)){const r=t.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=t.getStaticValue(s);t.addValue(s,ae(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Ii=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class ju{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Ps,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,B.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=r;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=hn(n),this.isVariantNode=po(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];l[f]!==void 0&&et(g)&&g.set(l[f])}}mount(e){this.current=e,Au.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)),Vo.current||Pu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Zn.current,process.env.NODE_ENV!=="production"&&fs(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(),kt(this.notifyUpdate),kt(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=he.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&B.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in le){const n=le[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):K()}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<Ii.length;s++){const i=Ii[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=e[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=Mu(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=ae(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"&&(Tr(s)||Cr(s))?s=parseFloat(s):!Ic(s)&&Rt.test(n)&&(s=ro(e,n)),this.setBaseTarget(e,et(s)?s.get():s)),et(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=Os(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!et(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 hs),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){js.render(this.render)}}class Do extends ju{constructor(){super(...arguments),this.KeyframeResolver=Sc}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;et(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function ko(t,{style:e,vars:n},s,i){const o=t.style;let r;for(r in e)o[r]=e[r];i?.applyProjectionStyles(o,s);for(r in n)o.setProperty(r,n[r])}function Eu(t){return window.getComputedStyle(t)}class Vu extends Do{constructor(){super(...arguments),this.type="html",this.renderInstance=ko}readValueFromInstance(e,n){if(he.has(n))return this.projection?.isProjecting?Un(n):zl(e,n);{const s=Eu(e),i=(gs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Eo(e,n)}build(e,n,s){Ns(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return Fs(e,n,s)}}const Ro=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 Du(t,e,n,s){ko(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Ro.has(i)?i:Bs(i),e.attrs[i])}class ku extends Do{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=K}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(he.has(n)){const s=io(n);return s&&s.default||0}return n=Ro.has(n)?n:Bs(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return To(e,n,s)}build(e,n,s){xo(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Du(e,n,s,i)}mount(e){this.isSVGTag=bo(e.tagName),super.mount(e)}}const No=(t,e)=>Ls(t)?new ku(e):new Vu(e,{allowProjection:t!==m.Fragment});function oe(t,e,n){const s=t.getProps();return Os(s,e,n!==void 0?n:s.custom,t)}const Qn=t=>Array.isArray(t);function Ru(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,ae(n))}function Nu(t){return Qn(t)?t[t.length-1]||0:t}function Iu(t,e){const n=oe(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=Nu(o[r]);Ru(t,r,a)}}function Lu(t){return!!(et(t)&&t.add)}function ts(t,e){const n=t.getValue("willChange");if(Lu(n))return n.add(e);if(!n&&At.WillChange){const s=new At.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Io(t){return t.props[So]}const Ou=t=>t!==null;function Fu(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Ou),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const Bu={type:"spring",stiffness:500,damping:25,restSpeed:10},$u=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),zu={type:"keyframes",duration:.8},Uu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},_u=(t,{keyframes:e})=>e.length>2?zu:he.has(t)?t.startsWith("scale")?$u(e[1]):Bu:Uu;function Wu({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const $s=(t,e,n,s={},i,o)=>r=>{const a=As(s,t)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-ft(l);const c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:i};Wu(a)||Object.assign(c,_u(t,c)),c.duration&&(c.duration=ft(c.duration)),c.repeatDelay&&(c.repeatDelay=ft(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(Xn(c),c.delay===0&&(d=!0)),(At.instantAnimations||At.skipAnimations)&&(d=!0,Xn(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,d&&!o&&e.get()!==void 0){const f=Fu(c.keyframes,a);if(f!==void 0){B.update(()=>{c.onUpdate(f),c.onComplete()});return}}return a.isSync?new Cs(c):new uc(c)};function Ku({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Lo(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;s&&(o=s);const l=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const c in a){const d=t.getValue(c,t.latestValues[c]??null),f=a[c];if(f===void 0||u&&Ku(u,c))continue;const g={delay:n,...As(o||{},c)},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=Io(t);if(x){const S=window.MotionHandoffAnimation(x,c,B);S!==null&&(g.startTime=S,v=!0)}}ts(t,c),d.start($s(c,d,f,t.shouldReduceMotion&&eo.has(c)?{type:!1}:g,t,v));const w=d.animation;w&&l.push(w)}return r&&Promise.all(l).then(()=>{B.update(()=>{r&&Iu(t,r)})}),l}function Oo(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,c)=>u.sortNodePosition(c)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function es(t,e,n={}){const s=oe(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(Lo(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=i;return Hu(t,e,l,u,c,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,u]=a==="beforeChildren"?[o,r]:[r,o];return l().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function Hu(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),a.push(es(l,e,{...r,delay:n+(typeof s=="function"?0:s)+Oo(t.variantChildren,l,s,i,o)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function Xu(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>es(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=es(t,e,n);else{const i=typeof e=="function"?oe(t,e,n.custom):e;s=Promise.all(Lo(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function Fo(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 Gu=Rs.length;function Bo(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Bo(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Gu;n++){const s=Rs[n],i=t.props[s];(Re(i)||i===!1)&&(e[s]=i)}return e}const Yu=[...ks].reverse(),qu=ks.length;function Ju(t){return e=>Promise.all(e.map(({animation:n,options:s})=>Xu(t,n,s)))}function Zu(t){let e=Ju(t),n=Li(),s=!0;const i=l=>(u,c)=>{const d=oe(t,c,l==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;u={...u,...y,...g}}return u};function o(l){e=l(t)}function r(l){const{props:u}=t,c=Bo(t.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let w=0;w<qu;w++){const x=Yu[w],S=n[x],b=u[x]!==void 0?u[x]:c[x],V=Re(b),P=x===l?S.isActive:null;P===!1&&(y=w);let E=b===c[x]&&b!==u[x]&&V;if(E&&s&&t.manuallyAnimateOnMount&&(E=!1),S.protectedKeys={...g},!S.isActive&&P===null||!b&&!S.prevProp||dn(b)||typeof b=="boolean")continue;const R=Qu(S.prevProp,b);let A=R||x===l&&S.isActive&&!E&&V||w>y&&V,L=!1;const W=Array.isArray(b)?b:[b];let U=W.reduce(i(x),{});P===!1&&(U={});const{prevResolvedValues:Tt={}}=S,Mt={...Tt,...U},mt=j=>{A=!0,f.has(j)&&(L=!0,f.delete(j)),S.needsAnimating[j]=!0;const Y=t.getValue(j);Y&&(Y.liveStyle=!1)};for(const j in Mt){const Y=U[j],H=Tt[j];if(g.hasOwnProperty(j))continue;let rt=!1;Qn(Y)&&Qn(H)?rt=!Fo(Y,H):rt=Y!==H,rt?Y!=null?mt(j):f.add(j):Y!==void 0&&f.has(j)?mt(j):S.protectedKeys[j]=!0}S.prevProp=b,S.prevResolvedValues=U,S.isActive&&(g={...g,...U}),s&&t.blockInitialAnimation&&(A=!1);const it=E&&R;A&&(!it||L)&&d.push(...W.map(j=>{const Y={type:x};if(typeof j=="string"&&s&&!it&&t.manuallyAnimateOnMount&&t.parent){const{parent:H}=t,rt=oe(H,j);if(H.enteringChildren&&rt){const{delayChildren:_}=rt.transition||{};Y.delay=Oo(H.enteringChildren,t,_)}}return{animation:j,options:Y}}))}if(f.size){const w={};if(typeof u.initial!="boolean"){const x=oe(t,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(w.transition=x.transition)}f.forEach(x=>{const S=t.getBaseTarget(x),b=t.getValue(x);b&&(b.liveStyle=!0),w[x]=S??null}),d.push({animation:w})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;const c=r(l);for(const d in n)n[d].protectedKeys={};return c}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Li()}}}function Qu(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Fo(e,t):!1}function _t(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Li(){return{animate:_t(!0),whileInView:_t(),whileHover:_t(),whileTap:_t(),whileDrag:_t(),whileFocus:_t(),exit:_t()}}class Nt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class td extends Nt{constructor(e){super(e),e.animationState||(e.animationState=Zu(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();dn(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 ed=0;class nd extends Nt{constructor(){super(...arguments),this.id=ed++}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 $o={animation:{Feature:td},exit:{Feature:nd}};function Ie(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function Be(t){return{point:{x:t.pageX,y:t.pageY}}}const sd=t=>e=>Es(e)&&t(e,Be(e));function Pe(t,e,n,s){return Ie(t,e,sd(n),s)}const zo=1e-4,id=1-zo,rd=1+zo,Uo=.01,od=0-Uo,ad=0+Uo;function nt(t){return t.max-t.min}function ld(t,e,n){return Math.abs(t-e)<=n}function Oi(t,e,n,s=.5){t.origin=s,t.originPoint=z(e.min,e.max,t.origin),t.scale=nt(n)/nt(e),t.translate=z(n.min,n.max,t.origin)-t.originPoint,(t.scale>=id&&t.scale<=rd||isNaN(t.scale))&&(t.scale=1),(t.translate>=od&&t.translate<=ad||isNaN(t.translate))&&(t.translate=0)}function Ae(t,e,n,s){Oi(t.x,e.x,n.x,s?s.originX:void 0),Oi(t.y,e.y,n.y,s?s.originY:void 0)}function Fi(t,e,n){t.min=n.min+e.min,t.max=t.min+nt(e)}function cd(t,e,n){Fi(t.x,e.x,n.x),Fi(t.y,e.y,n.y)}function Bi(t,e,n){t.min=e.min-n.min,t.max=t.min+nt(e)}function Me(t,e,n){Bi(t.x,e.x,n.x),Bi(t.y,e.y,n.y)}function lt(t){return[t("x"),t("y")]}const _o=({current:t})=>t?t.ownerDocument.defaultView:null,$i=(t,e)=>Math.abs(t-e);function ud(t,e){const n=$i(t.x,e.x),s=$i(t.y,e.y);return Math.sqrt(n**2+s**2)}class Wo{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=jn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=ud(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:v}=f,{timestamp:w}=J;this.history.push({...v,timestamp:w});const{onStart:x,onMove:S}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Mn(g,this.transformPagePoint),B.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=jn(f.type==="pointercancel"?this.lastMoveEventInfo:Mn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!Es(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const a=Be(e),l=Mn(a,this.transformPagePoint),{point:u}=l,{timestamp:c}=J;this.history=[{...u,timestamp:c}];const{onSessionStart:d}=n;d&&d(e,jn(l,this.history)),this.removeListeners=Le(Pe(this.contextWindow,"pointermove",this.handlePointerMove),Pe(this.contextWindow,"pointerup",this.handlePointerUp),Pe(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),kt(this.updatePoint)}}function Mn(t,e){return e?{point:e(t.point)}:t}function zi(t,e){return{x:t.x-e.x,y:t.y-e.y}}function jn({point:t},e){return{point:t,delta:zi(t,Ko(e)),offset:zi(t,dd(e)),velocity:hd(e,.1)}}function dd(t){return t[0]}function Ko(t){return t[t.length-1]}function hd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Ko(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>ft(e)));)n--;if(!s)return{x:0,y:0};const o=ct(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const r={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function fd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?z(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?z(n,t,s.max):Math.min(t,n)),t}function Ui(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 md(t,{top:e,left:n,bottom:s,right:i}){return{x:Ui(t.x,n,i),y:Ui(t.y,e,s)}}function _i(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 pd(t,e){return{x:_i(t.x,e.x),y:_i(t.y,e.y)}}function gd(t,e){let n=.5;const s=nt(t),i=nt(e);return i>s?n=Ve(e.min,e.max-s,t.min):s>i&&(n=Ve(t.min,t.max-i,e.min)),Ct(0,1,n)}function yd(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 ns=.35;function xd(t=ns){return t===!1?t=0:t===!0&&(t=ns),{x:Wi(t,"left","right"),y:Wi(t,"top","bottom")}}function Wi(t,e,n){return{min:Ki(t,e),max:Ki(t,n)}}function Ki(t,e){return typeof t=="number"?t:t[e]||0}const vd=new WeakMap;class bd{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=K(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Be(d).point)},r=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Mc(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),lt(x=>{let S=this.getAxisMotionValue(x).get()||0;if(wt.test(S)){const{projection:b}=this.visualElement;if(b&&b.layout){const V=b.layout.layoutBox[x];V&&(S=nt(V)*(parseFloat(S)/100))}}this.originPoint[x]=S}),v&&B.postRender(()=>v(d,f)),ts(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=wd(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},u=()=>lt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new Wo(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:s,contextWindow:_o(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:r}=i;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&B.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||!Ge(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=fd(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&ee(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=md(s.layoutBox,e):this.constraints=!1,this.elastic=xd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&lt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=yd(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!ee(e))return!1;const s=e.current;Pt(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=Cu(s,i.root,this.visualElement.getTransformPagePoint());let r=pd(i.layout.layoutBox,o);if(n){const a=n(wu(r));this.hasMutatedConstraints=!!a,a&&(r=Ao(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=lt(c=>{if(!Ge(c,n,this.currentDirection))return;let d=l&&l[c]||{};r&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?e[c]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(c,y)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return ts(this.visualElement,e),s.start($s(e,s,0,n,this.visualElement,!1))}stopAnimation(){lt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){lt(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){lt(n=>{const{drag:s}=this.getProps();if(!Ge(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n];o.set(e[n]-z(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!ee(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};lt(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const l=a.get();i[r]=gd({min:l,max:l},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),lt(r=>{if(!Ge(r,e,null))return;const a=this.getAxisMotionValue(r),{min:l,max:u}=this.constraints[r];a.set(z(l,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;vd.set(this.visualElement,this);const e=this.visualElement.current,n=Pe(e,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();ee(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),B.read(s);const r=Ie(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(lt(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=ns,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function Ge(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function wd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class Td extends Nt{constructor(e){super(e),this.removeGroupControls=ut,this.removeListeners=ut,this.controls=new bd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ut}unmount(){this.removeGroupControls(),this.removeListeners()}}const Hi=t=>(e,n)=>{t&&B.postRender(()=>t(e,n))};class Sd extends Nt{constructor(){super(...arguments),this.removePointerDownListener=ut}onPointerDown(e){this.session=new Wo(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:_o(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Hi(e),onStart:Hi(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&B.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=Pe(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const tn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Xi(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Te={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(M.test(t))t=parseFloat(t);else return t;const n=Xi(t,e.target.x),s=Xi(t,e.target.y);return`${n}% ${s}%`}},Cd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Rt.parse(t);if(i.length>5)return s;const o=Rt.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,l=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=l;const u=z(a,l,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}};let En=!1;class Pd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;Yc(Ad),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),En&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),tn.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,En=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||B.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),js.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;En=!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 Ho(t){const[e,n]=fo(),s=m.useContext(os);return h.jsx(Pd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(Co),isPresent:e,safeToRemove:n})}const Ad={borderRadius:{...Te,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Te,borderTopRightRadius:Te,borderBottomLeftRadius:Te,borderBottomRightRadius:Te,boxShadow:Cd};function Md(t,e,n){const s=et(t)?t:ae(t);return s.start($s("",s,e,n)),s.animation}const jd=(t,e)=>t.depth-e.depth;class Ed{constructor(){this.children=[],this.isDirty=!1}add(e){cs(this.children,e),this.isDirty=!0}remove(e){us(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(jd),this.isDirty=!1,this.children.forEach(e)}}function Vd(t,e){const n=st.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(kt(s),t(o-e))};return B.setup(s,!0),()=>kt(s)}const Xo=["TopLeft","TopRight","BottomLeft","BottomRight"],Dd=Xo.length,Gi=t=>typeof t=="string"?parseFloat(t):t,Yi=t=>typeof t=="number"||M.test(t);function kd(t,e,n,s,i,o){i?(t.opacity=z(0,n.opacity??1,Rd(s)),t.opacityExit=z(e.opacity??1,0,Nd(s))):o&&(t.opacity=z(e.opacity??1,n.opacity??1,s));for(let r=0;r<Dd;r++){const a=`border${Xo[r]}Radius`;let l=qi(e,a),u=qi(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Yi(l)===Yi(u)?(t[a]=Math.max(z(Gi(l),Gi(u),s),0),(wt.test(u)||wt.test(l))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=z(e.rotate||0,n.rotate||0,s))}function qi(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Rd=Go(0,.5,kr),Nd=Go(.5,.95,ut);function Go(t,e,n){return s=>s<t?0:s>e?1:n(Ve(t,e,s))}function Ji(t,e){t.min=e.min,t.max=e.max}function at(t,e){Ji(t.x,e.x),Ji(t.y,e.y)}function Zi(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function Qi(t,e,n,s,i){return t-=e,t=ln(t,1/n,s),i!==void 0&&(t=ln(t,1/i,s)),t}function Id(t,e=0,n=1,s=.5,i,o=t,r=t){if(wt.test(e)&&(e=parseFloat(e),e=z(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=z(o.min,o.max,s);t===o&&(a-=e),t.min=Qi(t.min,e,n,a,i),t.max=Qi(t.max,e,n,a,i)}function tr(t,e,[n,s,i],o,r){Id(t,e[n],e[s],e[i],e.scale,o,r)}const Ld=["x","scaleX","originX"],Od=["y","scaleY","originY"];function er(t,e,n,s){tr(t.x,e,Ld,n?n.x:void 0,s?s.x:void 0),tr(t.y,e,Od,n?n.y:void 0,s?s.y:void 0)}function nr(t){return t.translate===0&&t.scale===1}function Yo(t){return nr(t.x)&&nr(t.y)}function sr(t,e){return t.min===e.min&&t.max===e.max}function Fd(t,e){return sr(t.x,e.x)&&sr(t.y,e.y)}function ir(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function qo(t,e){return ir(t.x,e.x)&&ir(t.y,e.y)}function rr(t){return nt(t.x)/nt(t.y)}function or(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Bd{constructor(){this.members=[]}add(e){cs(this.members,e),e.scheduleRender()}remove(e){if(us(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function $d(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),c&&(s+=`rotate(${c}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 Vn=["","X","Y","Z"],zd=1e3;let Ud=0;function Dn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function Jo(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Io(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",B,!(i||o))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&Jo(s)}function Zo({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=Ud++,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(Kd),this.nodes.forEach(Yd),this.nodes.forEach(qd),this.nodes.forEach(Hd)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Ed)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new hs),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const l=this.eventHandlers.get(r);l&&l.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=ho(r)&&!Rc(r),this.instance=r;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let c,d=0;const f=()=>this.root.updateBlockedByResize=!1;B.read(()=>{d=window.innerWidth}),t(r,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,c&&c(),c=Vd(f,250),tn.hasAnimatedSinceResize&&(tn.hasAnimatedSinceResize=!1,this.nodes.forEach(cr)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||eh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=u.getProps(),x=!this.targetLayout||!qo(this.targetLayout,g),S=!d&&f;if(this.options.layoutRoot||this.resumeFrom||S||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...As(y,"layout"),onPlay:v,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(c,S)}else d||cr(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),kt(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(Jd),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Jo(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const d=this.path[c];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(ar);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(lr);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Gd),this.nodes.forEach(_d),this.nodes.forEach(Wd)):this.nodes.forEach(lr),this.clearAllSnapshots();const a=st.now();J.delta=Ct(0,1e3/60,a-J.timestamp),J.timestamp=a,J.isProcessing=!0,vn.update.process(J),vn.preRender.process(J),vn.render.process(J),J.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,js.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Xd),this.sharedNodes.forEach(Zd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,B.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){B.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!nt(this.snapshot.measuredBox.x)&&!nt(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutCorrected=K(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Yo(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||Kt(this.latestValues)||c)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return r&&(l=this.removeTransform(l)),nh(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return K();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(sh))){const{scroll:u}=this.root;u&&(ne(a.x,u.offset.x),ne(a.y,u.offset.y))}return a}removeElementScroll(r){const a=K();if(at(a,r),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:d}=u;u!==this.root&&c&&d.layoutScroll&&(c.wasRoot&&at(a,r),ne(a.x,c.offset.x),ne(a.y,c.offset.y))}return a}applyTransform(r,a=!1){const l=K();at(l,r);for(let u=0;u<this.path.length;u++){const c=this.path[u];!a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&se(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),Kt(c.latestValues)&&se(l,c.latestValues)}return Kt(this.latestValues)&&se(l,this.latestValues),l}removeTransform(r){const a=K();at(a,r);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Kt(u.latestValues))continue;qn(u.latestValues)&&u.updateSnapshot();const c=K(),d=u.measurePageBox();at(c,d),er(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return Kt(this.latestValues)&&er(a,this.latestValues),a}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==J.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(r||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:d}=this.options;if(!(!this.layout||!(c||d))){if(this.resolvedRelativeTargetAt=J.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=K(),this.relativeTargetOrigin=K(),Me(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),at(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=K(),this.targetWithTransforms=K()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),cd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):at(this.target,this.layout.layoutBox),jo(this.target,this.targetDelta)):at(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=K(),this.relativeTargetOrigin=K(),Me(this.relativeTargetOrigin,this.target,f.target),at(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||qn(this.parent.latestValues)||Mo(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const r=this.getLead(),a=!!this.resumingFrom||this!==r;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===J.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||c))return;at(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;Su(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=K());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Zi(this.prevProjectionDelta.x,this.projectionDelta.x),Zi(this.prevProjectionDelta.y,this.projectionDelta.y)),Ae(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!or(this.projectionDelta.x,this.prevProjectionDelta.x)||!or(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){if(this.options.visualElement?.scheduleRender(),r){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ie(),this.projectionDelta=ie(),this.projectionDeltaWithTransform=ie()}setAnimationOrigin(r,a=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},d=ie();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=K(),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,S=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(th));this.animationProgress=0;let b;this.mixTargetDelta=V=>{const P=V/1e3;ur(d.x,r.x,P),ur(d.y,r.y,P),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Me(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Qd(this.relativeTarget,this.relativeTargetOrigin,f,P),b&&Fd(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=K()),at(b,this.relativeTarget)),v&&(this.animationValues=c,kd(c,u,this.latestValues,P,S,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(kt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=B.update(()=>{tn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=ae(0)),this.currentAnimation=Md(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),r.onUpdate&&r.onUpdate(a)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(zd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:c}=r;if(!(!a||!l||!u)){if(this!==r&&this.layout&&u&&Qo(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||K();const d=nt(this.layout.layoutBox.x);l.x.min=r.target.x.min,l.x.max=l.x.min+d;const f=nt(this.layout.layoutBox.y);l.y.min=r.target.y.min,l.y.max=l.y.min+f}at(a,l),se(a,c),Ae(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new Bd),this.sharedNodes.get(r).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:l}=r;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&Dn("z",r,u,this.animationValues);for(let c=0;c<Vn.length;c++)Dn(`rotate${Vn[c]}`,r,u,this.animationValues),Dn(`skew${Vn[c]}`,r,u,this.animationValues);r.render();for(const c in u)r.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=Ze(a?.pointerEvents)||"",r.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=Ze(a?.pointerEvents)||""),this.hasProjected&&!Kt(this.latestValues)&&(r.transform=l?l({},""):"none",this.hasProjected=!1);return}r.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=$d(this.projectionDeltaWithTransform,this.treeScale,c);l&&(d=l(c,d)),r.transform=d;const{x:f,y:g}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?r.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:r.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const y in Ne){if(c[y]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:x}=Ne[y],S=d==="none"?c[y]:v(c[y],u);if(w){const b=w.length;for(let V=0;V<b;V++)r[w[V]]=S}else x?this.options.visualElement.renderState.vars[y]=S:r[y]=S}this.options.layoutId&&(r.pointerEvents=u===this?Ze(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(ar),this.root.sharedNodes.clear()}}}function _d(t){t.updateLayout()}function Wd(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?lt(c=>{const d=o?e.measuredBox[c]:e.layoutBox[c],f=nt(d);d.min=n[c].min,d.max=d.min+f}):Qo(i,e.layoutBox,n)&&lt(c=>{const d=o?e.measuredBox[c]:e.layoutBox[c],f=nt(n[c]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[c].max=t.relativeTarget[c].min+f)});const r=ie();Ae(r,n,e.layoutBox);const a=ie();o?Ae(a,t.applyTransform(s,!0),e.measuredBox):Ae(a,n,e.layoutBox);const l=!Yo(r);let u=!1;if(!t.resumeFrom){const c=t.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:d,layout:f}=c;if(d&&f){const g=K();Me(g,e.layoutBox,d.layoutBox);const y=K();Me(y,n,f.layoutBox),qo(g,y)||(u=!0),c.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=g,t.relativeParent=c)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Kd(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 Hd(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Xd(t){t.clearSnapshot()}function ar(t){t.clearMeasurements()}function lr(t){t.isLayoutDirty=!1}function Gd(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function cr(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Yd(t){t.resolveTargetDelta()}function qd(t){t.calcProjection()}function Jd(t){t.resetSkewAndRotation()}function Zd(t){t.removeLeadSnapshot()}function ur(t,e,n){t.translate=z(e.translate,0,n),t.scale=z(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function dr(t,e,n,s){t.min=z(e.min,n.min,s),t.max=z(e.max,n.max,s)}function Qd(t,e,n,s){dr(t.x,e.x,n.x,s),dr(t.y,e.y,n.y,s)}function th(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const eh={duration:.45,ease:[.4,0,.1,1]},hr=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),fr=hr("applewebkit/")&&!hr("chrome/")?Math.round:ut;function mr(t){t.min=fr(t.min),t.max=fr(t.max)}function nh(t){mr(t.x),mr(t.y)}function Qo(t,e,n){return t==="position"||t==="preserve-aspect"&&!ld(rr(e),rr(n),.2)}function sh(t){return t!==t.root&&t.scroll?.wasRoot}const ih=Zo({attachResizeListener:(t,e)=>Ie(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),kn={current:void 0},ta=Zo({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!kn.current){const t=new ih({});t.mount(window),t.setOptions({layoutScroll:!0}),kn.current=t}return kn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),rh={pan:{Feature:Sd},drag:{Feature:Td,ProjectionNode:ta,MeasureLayout:Ho}};function pr(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&B.postRender(()=>o(e,Be(e)))}class oh extends Nt{mount(){const{current:e}=this.node;e&&(this.unmount=jc(e,(n,s)=>(pr(this.node,s,"Start"),i=>pr(this.node,i,"End"))))}unmount(){}}class ah extends Nt{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=Le(Ie(this.node.current,"focus",()=>this.onFocus()),Ie(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function gr(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&B.postRender(()=>o(e,Be(e)))}class lh extends Nt{mount(){const{current:e}=this.node;e&&(this.unmount=kc(e,(n,s)=>(gr(this.node,s,"Start"),(i,{success:o})=>gr(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const ss=new WeakMap,Rn=new WeakMap,ch=t=>{const e=ss.get(t.target);e&&e(t)},uh=t=>{t.forEach(ch)};function dh({root:t,...e}){const n=t||document;Rn.has(n)||Rn.set(n,{});const s=Rn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(uh,{root:t,...e})),s[i]}function hh(t,e,n){const s=dh(e);return ss.set(t,n),s.observe(t),()=>{ss.delete(t),s.unobserve(t)}}const fh={some:0,all:1};class mh extends Nt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:fh[i]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=u?c:d;f&&f(l)};return hh(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(ph(e,n))&&this.startObserver()}unmount(){}}function ph({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const ea={inView:{Feature:mh},tap:{Feature:lh},focus:{Feature:ah},hover:{Feature:oh}},gh={layout:{ProjectionNode:ta,MeasureLayout:Ho}},yh={...$o,...ea,...rh,...gh},xh=bu(yh,No),vh={renderer:No,...$o,...ea};function na(t,e){return Qe(t,e)}const Ye=na("div"),bh=na("p"),bt=Symbol.for("@arcteninc/core:originalName");function wh(t,e){return t[bt]=e,t}function Th(t,e,n,s){if(typeof t!="function")return null;const i=t[bt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const o=t.name;let r;if(o&&(r=e[o],r&&!n.has(r.name)))return t[bt]=r.name,{fn:t,meta:r};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(r=e[a],r))return t[bt]=r.name,{fn:t,meta:r}}else if(r=Object.values(e).find(l=>!n.has(l.name)),r)return t[bt]=r.name,{fn:t,meta:r};return null}function sa(t,e){let n,s;if(!e)throw new Error(`❌ toolMetadata is required!
9
+ `),()=>{S.contains(v)&&S.removeChild(v)}},[e]),h.jsx(ql,{isPresent:e,childRef:o,sizeRef:r,children:bt.cloneElement(t,{ref:c})})}const Jl=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:a,root:c})=>{const u=Ts(Zl),l=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:l,initial:e,isPresent:n,custom:i,onExitComplete:p=>{u.set(p,!0);for(const y of u.values())if(!y)return;s&&s()},register:p=>(u.set(p,!1),()=>u.delete(p))}),[n,u,s]);return o&&d&&(f={...f}),m.useMemo(()=>{u.forEach((p,y)=>u.set(y,!1))},[n]),bt.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),r==="popLayout"&&(t=h.jsx(Yl,{isPresent:n,anchorX:a,root:c,children:t})),h.jsx(Tn.Provider,{value:f,children:t})};function Zl(){return new Map}function Po(t=!0){const e=m.useContext(Tn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=m.useId();m.useEffect(()=>{if(t)return i(o)},[t]);const r=m.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const an=t=>t.key||"";function Oi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Ql=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:c})=>{const[u,l]=Po(r),d=m.useMemo(()=>Oi(t),[t]),f=r&&!u?[]:d.map(an),p=m.useRef(!0),y=m.useRef(d),v=Ts(()=>new Map),[S,x]=m.useState(d),[b,T]=m.useState(d);Nr(()=>{p.current=!1,y.current=d;for(let I=0;I<b.length;I++){const R=an(b[I]);f.includes(R)?v.delete(R):v.get(R)!==!0&&v.set(R,!1)}},[b,f.length,f.join("-")]);const D=[];if(d!==S){let I=[...d];for(let R=0;R<b.length;R++){const E=b[R],_=an(E);f.includes(_)||(I.splice(R,0,E),D.push(E))}return o==="wait"&&D.length&&(I=D),T(Oi(I)),x(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&b.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:M}=m.useContext(ws);return h.jsx(h.Fragment,{children:b.map(I=>{const R=an(I),E=r&&!u?!1:d===b||f.includes(R),_=()=>{if(v.has(R))v.set(R,!0);else return;let B=!0;v.forEach(ct=>{ct||(B=!1)}),B&&(M?.(),T(y.current),r&&l?.(),s&&s())};return h.jsx(Jl,{isPresent:E,initial:!p.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:o,root:c,onExitComplete:E?void 0:_,anchorX:a,children:I},R)})})},Hs=m.createContext({strict:!1}),Fi={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"]},be={};for(const t in Fi)be[t]={isEnabled:e=>Fi[t].some(n=>!!e[n])};function us(t){for(const e in t)be[e]={...be[e],...t[e]}}function tu({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!$n(e)),i=m.useRef(void 0);if(!$n(e)){const{renderer:o,...r}=e;i.current=o,us(r)}return m.useEffect(()=>{$n(e)&&e().then(({renderer:o,...r})=>{us(r),i.current=o,s(!0)})},[]),h.jsx(Hs.Provider,{value:{renderer:i.current,strict:n},children:t})}function $n(t){return typeof t=="function"}const eu=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 bn(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||eu.has(t)}let Mo=t=>!bn(t);function nu(t){typeof t=="function"&&(Mo=e=>e.startsWith("on")?!bn(e):t(e))}try{nu(require("@emotion/is-prop-valid").default)}catch{}function su(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(Mo(i)||n===!0&&bn(i)||!e&&!bn(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const Sn=m.createContext({});function Cn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Ke(t){return typeof t=="string"||Array.isArray(t)}const Xs=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Gs=["initial",...Xs];function An(t){return Cn(t.animate)||Gs.some(e=>Ke(t[e]))}function jo(t){return!!(An(t)||t.variants)}function iu(t,e){if(An(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Ke(n)?n:void 0,animate:Ke(s)?s:void 0}}return t.inherit!==!1?e:{}}function ru(t){const{initial:e,animate:n}=iu(t,m.useContext(Sn));return m.useMemo(()=>({initial:e,animate:n}),[Bi(e),Bi(n)])}function Bi(t){return Array.isArray(t)?t.join(" "):t}const He={};function ou(t){for(const e in t)He[e]=t[e],Ds(e)&&(He[e].isCSSVariable=!0)}function Eo(t,{layout:e,layoutId:n}){return Ce.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!He[t]||t==="opacity")}const au={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},cu=Se.length;function lu(t,e,n){let s="",i=!0;for(let o=0;o<cu;o++){const r=Se[o],a=t[r];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(r.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const u=bo(a,Us[r]);if(!c){i=!1;const l=au[r]||r;s+=`${l}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function qs(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const c in e){const u=e[c];if(Ce.has(c)){r=!0;continue}else if(Ds(c)){i[c]=u;continue}else{const l=bo(u,Us[c]);c.startsWith("origin")?(a=!0,o[c]=l):s[c]=l}}if(e.transform||(r||n?s.transform=lu(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:c="50%",originY:u="50%",originZ:l=0}=o;s.transformOrigin=`${c} ${u} ${l}`}}const Ys=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ko(t,e,n){for(const s in e)!et(e[s])&&!Eo(s,n)&&(t[s]=e[s])}function uu({transformTemplate:t},e){return m.useMemo(()=>{const n=Ys();return qs(n,e,t),Object.assign({},n.vars,n.style)},[e])}function du(t,e){const n=t.style||{},s={};return ko(s,n,t),Object.assign(s,uu(t,e)),s}function hu(t,e){const n={},s=du(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 fu={offset:"stroke-dashoffset",array:"stroke-dasharray"},mu={offset:"strokeDashoffset",array:"strokeDasharray"};function pu(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?fu:mu;t[o.offset]=V.transform(-s);const r=V.transform(e),a=V.transform(n);t[o.array]=`${r} ${a}`}function Do(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},c,u,l){if(qs(t,a,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=l?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&pu(d,i,o,r,!1)}const Vo=()=>({...Ys(),attrs:{}}),Ro=t=>typeof t=="string"&&t.toLowerCase()==="svg";function gu(t,e,n,s){const i=m.useMemo(()=>{const o=Vo();return Do(o,e,Ro(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};ko(o,t.style,t),i.style={...o,...i.style}}return i}const yu=["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 Js(t){return typeof t!="string"||t.includes("-")?!1:!!(yu.indexOf(t)>-1||/[A-Z]/u.test(t))}function xu(t,e,n,{latestValues:s},i,o=!1){const a=(Js(t)?gu:hu)(e,s,i,t),c=su(e,typeof t=="string",o),u=t!==m.Fragment?{...c,...a,ref:n}:{},{children:l}=e,d=m.useMemo(()=>et(l)?l.get():l,[l]);return m.createElement(t,{...u,children:d})}function $i(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function Zs(t,e,n,s){if(typeof e=="function"){const[i,o]=$i(s);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=$i(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function hn(t){return et(t)?t.get():t}function vu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:bu(n,s,i,t),renderState:e()}}function bu(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=hn(o[f]);let{initial:r,animate:a}=t;const c=An(t),u=jo(t);e&&u&&!c&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let l=n?n.initial===!1:!1;l=l||r===!1;const d=l?a:r;if(d&&typeof d!="boolean"&&!Cn(d)){const f=Array.isArray(d)?d:[d];for(let p=0;p<f.length;p++){const y=Zs(t,f[p]);if(y){const{transitionEnd:v,transition:S,...x}=y;for(const b in x){let T=x[b];if(Array.isArray(T)){const D=l?T.length-1:0;T=T[D]}T!==null&&(i[b]=T)}for(const b in v)i[b]=v[b]}}}return i}const No=t=>(e,n)=>{const s=m.useContext(Sn),i=m.useContext(Tn),o=()=>vu(t,e,s,i);return n?o():Ts(o)};function Qs(t,e,n){const{style:s}=t,i={};for(const o in s)(et(s[o])||e.style&&et(e.style[o])||Eo(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const wu=No({scrapeMotionValuesFromProps:Qs,createRenderState:Ys});function Io(t,e,n){const s=Qs(t,e,n);for(const i in t)if(et(t[i])||et(e[i])){const o=Se.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const Tu=No({scrapeMotionValuesFromProps:Io,createRenderState:Vo}),Su=Symbol.for("motionComponentSymbol");function fe(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Cu(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):fe(n)&&(n.current=s))},[e])}const ti=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Au="framerAppearId",Lo="data-"+ti(Au),Oo=m.createContext({});function Pu(t,e,n,s,i){const{visualElement:o}=m.useContext(Sn),r=m.useContext(Hs),a=m.useContext(Tn),c=m.useContext(Ks).reducedMotion,u=m.useRef(null);s=s||r.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const l=u.current,d=m.useContext(Oo);l&&!l.projection&&i&&(l.type==="html"||l.type==="svg")&&Mu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{l&&f.current&&l.update(n,a)});const p=n[Lo],y=m.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return Nr(()=>{l&&(f.current=!0,window.MotionIsMounted=!0,l.updateFeatures(),l.scheduleRenderMicrotask(),y.current&&l.animationState&&l.animationState.animateChanges())}),m.useEffect(()=>{l&&(!y.current&&l.animationState&&l.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(p)}),y.current=!1),l.enteringChildren=void 0)}),l}function Mu(t,e,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:l}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Fo(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&fe(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:c,layoutRoot:u})}function Fo(t){if(t)return t.options.allowProjection!==!1?t.projection:Fo(t.parent)}function fn(t,{forwardMotionProps:e=!1}={},n,s){n&&us(n);const i=Js(t)?Tu:wu;function o(a,c){let u;const l={...m.useContext(Ks),...a,layoutId:ju(a)},{isStatic:d}=l,f=ru(a),p=i(a,d);if(!d&&Ss){Eu(l,n);const y=ku(l);u=y.MeasureLayout,f.visualElement=Pu(t,p,l,s,y.ProjectionNode)}return h.jsxs(Sn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...l}):null,xu(t,a,Cu(p,f.visualElement,c),p,d,e)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const r=m.forwardRef(o);return r[Su]=t,r}function ju({layoutId:t}){const e=m.useContext(ws).id;return e&&t!==void 0?e+"-"+t:t}function Eu(t,e){const n=m.useContext(Hs).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?we(!1,s,"lazy-strict-mode"):Rt(!1,s,"lazy-strict-mode")}}function ku(t){const{drag:e,layout:n}=be;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Du(t,e){if(typeof Proxy>"u")return fn;const n=new Map,s=(o,r)=>fn(o,r,t,e),i=(o,r)=>(process.env.NODE_ENV!=="production"&&js(!1,"motion() is deprecated. Use motion.create() instead."),s(o,r));return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,fn(r,void 0,t,e)),n.get(r))})}function Bo({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function Vu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function Ru(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 zn(t){return t===void 0||t===1}function ds({scale:t,scaleX:e,scaleY:n}){return!zn(t)||!zn(e)||!zn(n)}function ee(t){return ds(t)||$o(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function $o(t){return zi(t.x)||zi(t.y)}function zi(t){return t&&t!=="0%"}function wn(t,e,n){const s=t-n,i=e*s;return n+i}function Ui(t,e,n,s,i){return i!==void 0&&(t=wn(t,i,s)),wn(t,n,s)+e}function hs(t,e=0,n=1,s,i){t.min=Ui(t.min,e,n,s,i),t.max=Ui(t.max,e,n,s,i)}function zo(t,{x:e,y:n}){hs(t.x,e.translate,e.scale,e.originPoint),hs(t.y,n.translate,n.scale,n.originPoint)}const _i=.999999999999,Wi=1.0000000000001;function Nu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,r;for(let a=0;a<i;a++){o=n[a],r=o.projectionDelta;const{visualElement:c}=o.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&pe(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,zo(t,r)),s&&ee(o.latestValues)&&pe(t,o.latestValues))}e.x<Wi&&e.x>_i&&(e.x=1),e.y<Wi&&e.y>_i&&(e.y=1)}function me(t,e){t.min=t.min+e,t.max=t.max+e}function Ki(t,e,n,s,i=.5){const o=X(t.min,t.max,i);hs(t,e,n,o,s)}function pe(t,e){Ki(t.x,e.x,e.scaleX,e.scale,e.originX),Ki(t.y,e.y,e.scaleY,e.scale,e.originY)}function Uo(t,e){return Bo(Ru(t.getBoundingClientRect(),e))}function Iu(t,e,n){const s=Uo(t,n),{scroll:i}=e;return i&&(me(s.x,i.offset.x),me(s.y,i.offset.y)),s}const Hi=()=>({translate:0,scale:1,origin:0,originPoint:0}),ge=()=>({x:Hi(),y:Hi()}),Xi=()=>({min:0,max:0}),q=()=>({x:Xi(),y:Xi()}),fs={current:null},_o={current:!1};function Lu(){if(_o.current=!0,!!Ss)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>fs.current=t.matches;t.addEventListener("change",e),e()}else fs.current=!1}const Ou=new WeakMap;function Fu(t,e,n){for(const s in e){const i=e[s],o=n[s];if(et(i))t.addValue(s,i);else if(et(o))t.addValue(s,ve(i,{owner:t}));else if(o!==i)if(t.hasValue(s)){const r=t.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=t.getStaticValue(s);t.addValue(s,ve(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Gi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Bu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=$s,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=rt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,W.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=r;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=An(n),this.isVariantNode=jo(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:l,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const p=d[f];c[f]!==void 0&&et(p)&&p.set(c[f])}}mount(e){this.current=e,Ou.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)),_o.current||Lu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:fs.current,process.env.NODE_ENV!=="production"&&js(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(),Ut(this.notifyUpdate),Ut(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=Ce.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&W.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in be){const n=be[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):q()}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<Gi.length;s++){const i=Gi[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=e[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=Fu(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=ve(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"&&(Ir(s)||Or(s))?s=parseFloat(s):!Hl(s)&&_t.test(n)&&(s=vo(e,n)),this.setBaseTarget(e,et(s)?s.get():s)),et(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=Zs(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!et(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 Ms),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){_s.render(this.render)}}class Wo extends Bu{constructor(){super(...arguments),this.KeyframeResolver=Nl}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;et(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Ko(t,{style:e,vars:n},s,i){const o=t.style;let r;for(r in e)o[r]=e[r];i?.applyProjectionStyles(o,s);for(r in n)o.setProperty(r,n[r])}function $u(t){return window.getComputedStyle(t)}class zu extends Wo{constructor(){super(...arguments),this.type="html",this.renderInstance=Ko}readValueFromInstance(e,n){if(Ce.has(n))return this.projection?.isProjecting?ss(n):Zc(e,n);{const s=$u(e),i=(Ds(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Uo(e,n)}build(e,n,s){qs(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return Qs(e,n,s)}}const Ho=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 Uu(t,e,n,s){Ko(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Ho.has(i)?i:ti(i),e.attrs[i])}class _u extends Wo{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=q}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Ce.has(n)){const s=xo(n);return s&&s.default||0}return n=Ho.has(n)?n:ti(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return Io(e,n,s)}build(e,n,s){Do(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Uu(e,n,s,i)}mount(e){this.isSVGTag=Ro(e.tagName),super.mount(e)}}const Xo=(t,e)=>Js(t)?new _u(e):new zu(e,{allowProjection:t!==m.Fragment});function xe(t,e,n){const s=t.getProps();return Zs(s,e,n!==void 0?n:s.custom,t)}const ms=t=>Array.isArray(t);function Wu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,ve(n))}function Ku(t){return ms(t)?t[t.length-1]||0:t}function Hu(t,e){const n=xe(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=Ku(o[r]);Wu(t,r,a)}}function Xu(t){return!!(et(t)&&t.add)}function ps(t,e){const n=t.getValue("willChange");if(Xu(n))return n.add(e);if(!n&&Nt.WillChange){const s=new Nt.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Go(t){return t.props[Lo]}const Gu=t=>t!==null;function qu(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Gu),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const Yu={type:"spring",stiffness:500,damping:25,restSpeed:10},Ju=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Zu={type:"keyframes",duration:.8},Qu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},td=(t,{keyframes:e})=>e.length>2?Zu:Ce.has(t)?t.startsWith("scale")?Ju(e[1]):Yu:Qu;function ed({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:c,elapsed:u,...l}){return!!Object.keys(l).length}const ei=(t,e,n,s={},i,o)=>r=>{const a=zs(s,t)||{},c=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-wt(c);const l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:i};ed(a)||Object.assign(l,td(t,l)),l.duration&&(l.duration=wt(l.duration)),l.repeatDelay&&(l.repeatDelay=wt(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let d=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(cs(l),l.delay===0&&(d=!0)),(Nt.instantAnimations||Nt.skipAnimations)&&(d=!0,cs(l),l.delay=0),l.allowFlatten=!a.type&&!a.ease,d&&!o&&e.get()!==void 0){const f=qu(l.keyframes,a);if(f!==void 0){W.update(()=>{l.onUpdate(f),l.onComplete()});return}}return a.isSync?new Bs(l):new wl(l)};function nd({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function qo(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;s&&(o=s);const c=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const l in a){const d=t.getValue(l,t.latestValues[l]??null),f=a[l];if(f===void 0||u&&nd(u,l))continue;const p={delay:n,...zs(o||{},l)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!p.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=Go(t);if(x){const b=window.MotionHandoffAnimation(x,l,W);b!==null&&(p.startTime=b,v=!0)}}ps(t,l),d.start(ei(l,d,f,t.shouldReduceMotion&&po.has(l)?{type:!1}:p,t,v));const S=d.animation;S&&c.push(S)}return r&&Promise.all(c).then(()=>{W.update(()=>{r&&Hu(t,r)})}),c}function Yo(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,l)=>u.sortNodePosition(l)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function gs(t,e,n={}){const s=xe(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(qo(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:l,staggerDirection:d}=i;return sd(t,e,c,u,l,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[o,r]:[r,o];return c().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function sd(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(gs(c,e,{...r,delay:n+(typeof s=="function"?0:s)+Yo(t.variantChildren,c,s,i,o)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function id(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>gs(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=gs(t,e,n);else{const i=typeof e=="function"?xe(t,e,n.custom):e;s=Promise.all(qo(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function Jo(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 rd=Gs.length;function Zo(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Zo(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<rd;n++){const s=Gs[n],i=t.props[s];(Ke(i)||i===!1)&&(e[s]=i)}return e}const od=[...Xs].reverse(),ad=Xs.length;function cd(t){return e=>Promise.all(e.map(({animation:n,options:s})=>id(t,n,s)))}function ld(t){let e=cd(t),n=qi(),s=!0;const i=c=>(u,l)=>{const d=xe(t,l,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:p,...y}=d;u={...u,...y,...p}}return u};function o(c){e=c(t)}function r(c){const{props:u}=t,l=Zo(t.parent)||{},d=[],f=new Set;let p={},y=1/0;for(let S=0;S<ad;S++){const x=od[S],b=n[x],T=u[x]!==void 0?u[x]:l[x],D=Ke(T),M=x===c?b.isActive:null;M===!1&&(y=S);let I=T===l[x]&&T!==u[x]&&D;if(I&&s&&t.manuallyAnimateOnMount&&(I=!1),b.protectedKeys={...p},!b.isActive&&M===null||!T&&!b.prevProp||Cn(T)||typeof T=="boolean")continue;const R=ud(b.prevProp,T);let E=R||x===c&&b.isActive&&!I&&D||S>y&&D,_=!1;const B=Array.isArray(T)?T:[T];let ct=B.reduce(i(x),{});M===!1&&(ct={});const{prevResolvedValues:It={}}=b,pt={...It,...ct},oe=U=>{E=!0,f.has(U)&&(_=!0,f.delete(U)),b.needsAnimating[U]=!0;const $=t.getValue(U);$&&($.liveStyle=!1)};for(const U in pt){const $=ct[U],Z=It[U];if(p.hasOwnProperty(U))continue;let ot=!1;ms($)&&ms(Z)?ot=!Jo($,Z):ot=$!==Z,ot?$!=null?oe(U):f.add(U):$!==void 0&&f.has(U)?oe(U):b.protectedKeys[U]=!0}b.prevProp=T,b.prevResolvedValues=ct,b.isActive&&(p={...p,...ct}),s&&t.blockInitialAnimation&&(E=!1);const Lt=I&&R;E&&(!Lt||_)&&d.push(...B.map(U=>{const $={type:x};if(typeof U=="string"&&s&&!Lt&&t.manuallyAnimateOnMount&&t.parent){const{parent:Z}=t,ot=xe(Z,U);if(Z.enteringChildren&&ot){const{delayChildren:lt}=ot.transition||{};$.delay=Yo(Z.enteringChildren,t,lt)}}return{animation:U,options:$}}))}if(f.size){const S={};if(typeof u.initial!="boolean"){const x=xe(t,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(S.transition=x.transition)}f.forEach(x=>{const b=t.getBaseTarget(x),T=t.getValue(x);T&&(T.liveStyle=!0),S[x]=b??null}),d.push({animation:S})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(c,u){if(n[c].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(c,u)),n[c].isActive=u;const l=r(c);for(const d in n)n[d].protectedKeys={};return l}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=qi()}}}function ud(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Jo(e,t):!1}function Qt(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function qi(){return{animate:Qt(!0),whileInView:Qt(),whileHover:Qt(),whileTap:Qt(),whileDrag:Qt(),whileFocus:Qt(),exit:Qt()}}class Wt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class dd extends Wt{constructor(e){super(e),e.animationState||(e.animationState=ld(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Cn(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 hd=0;class fd extends Wt{constructor(){super(...arguments),this.id=hd++}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 Qo={animation:{Feature:dd},exit:{Feature:fd}};function Xe(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 md=t=>e=>Ws(e)&&t(e,Je(e));function Oe(t,e,n,s){return Xe(t,e,md(n),s)}const ta=1e-4,pd=1-ta,gd=1+ta,ea=.01,yd=0-ea,xd=0+ea;function nt(t){return t.max-t.min}function vd(t,e,n){return Math.abs(t-e)<=n}function Yi(t,e,n,s=.5){t.origin=s,t.originPoint=X(e.min,e.max,t.origin),t.scale=nt(n)/nt(e),t.translate=X(n.min,n.max,t.origin)-t.originPoint,(t.scale>=pd&&t.scale<=gd||isNaN(t.scale))&&(t.scale=1),(t.translate>=yd&&t.translate<=xd||isNaN(t.translate))&&(t.translate=0)}function Fe(t,e,n,s){Yi(t.x,e.x,n.x,s?s.originX:void 0),Yi(t.y,e.y,n.y,s?s.originY:void 0)}function Ji(t,e,n){t.min=n.min+e.min,t.max=t.min+nt(e)}function bd(t,e,n){Ji(t.x,e.x,n.x),Ji(t.y,e.y,n.y)}function Zi(t,e,n){t.min=e.min-n.min,t.max=t.min+nt(e)}function Be(t,e,n){Zi(t.x,e.x,n.x),Zi(t.y,e.y,n.y)}function ht(t){return[t("x"),t("y")]}const na=({current:t})=>t?t.ownerDocument.defaultView:null,Qi=(t,e)=>Math.abs(t-e);function wd(t,e){const n=Qi(t.x,e.x),s=Qi(t.y,e.y);return Math.sqrt(n**2+s**2)}class sa{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=_n(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,y=wd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!y)return;const{point:v}=f,{timestamp:S}=Q;this.history.push({...v,timestamp:S});const{onStart:x,onMove:b}=this.handlers;p||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),b&&b(this.lastMoveEvent,f)},this.handlePointerMove=(f,p)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Un(p,this.transformPagePoint),W.update(this.updatePoint,!0)},this.handlePointerUp=(f,p)=>{this.end();const{onEnd:y,onSessionEnd:v,resumeAnimation:S}=this.handlers;if(this.dragSnapToOrigin&&S&&S(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=_n(f.type==="pointercancel"?this.lastMoveEventInfo:Un(p,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!Ws(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const a=Je(e),c=Un(a,this.transformPagePoint),{point:u}=c,{timestamp:l}=Q;this.history=[{...u,timestamp:l}];const{onSessionStart:d}=n;d&&d(e,_n(c,this.history)),this.removeListeners=Ge(Oe(this.contextWindow,"pointermove",this.handlePointerMove),Oe(this.contextWindow,"pointerup",this.handlePointerUp),Oe(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Ut(this.updatePoint)}}function Un(t,e){return e?{point:e(t.point)}:t}function tr(t,e){return{x:t.x-e.x,y:t.y-e.y}}function _n({point:t},e){return{point:t,delta:tr(t,ia(e)),offset:tr(t,Td(e)),velocity:Sd(e,.1)}}function Td(t){return t[0]}function ia(t){return t[t.length-1]}function Sd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=ia(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>wt(e)));)n--;if(!s)return{x:0,y:0};const o=ft(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const r={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function Cd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?X(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?X(n,t,s.max):Math.min(t,n)),t}function er(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:er(t.x,n,i),y:er(t.y,e,s)}}function nr(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 Pd(t,e){return{x:nr(t.x,e.x),y:nr(t.y,e.y)}}function Md(t,e){let n=.5;const s=nt(t),i=nt(e);return i>s?n=Ue(e.min,e.max-s,t.min):s>i&&(n=Ue(t.min,t.max-i,e.min)),Vt(0,1,n)}function jd(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 ys=.35;function Ed(t=ys){return t===!1?t=0:t===!0&&(t=ys),{x:sr(t,"left","right"),y:sr(t,"top","bottom")}}function sr(t,e,n){return{min:ir(t,e),max:ir(t,n)}}function ir(t,e){return typeof t=="number"?t:t[e]||0}const kd=new WeakMap;class Dd{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=q(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Je(d).point)},r=(d,f)=>{const{drag:p,dragPropagation:y,onDragStart:v}=this.getProps();if(p&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Fl(p),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),ht(x=>{let b=this.getAxisMotionValue(x).get()||0;if(Mt.test(b)){const{projection:T}=this.visualElement;if(T&&T.layout){const D=T.layout.layoutBox[x];D&&(b=nt(D)*(parseFloat(b)/100))}}this.originPoint[x]=b}),v&&W.postRender(()=>v(d,f)),ps(this.visualElement,"transform");const{animationState:S}=this.visualElement;S&&S.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:p,dragDirectionLock:y,onDirectionLock:v,onDrag:S}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:x}=f;if(y&&this.currentDirection===null){this.currentDirection=Vd(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),S&&S(d,f)},c=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>ht(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:l}=this.getProps();this.panSession=new sa(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:s,contextWindow:na(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:r}=i;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&W.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||!cn(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=Cd(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&fe(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=Ad(s.layoutBox,e):this.constraints=!1,this.elastic=Ed(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&ht(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=jd(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!fe(e))return!1;const s=e.current;Rt(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=Iu(s,i.root,this.visualElement.getTransformPagePoint());let r=Pd(i.layout.layoutBox,o);if(n){const a=n(Vu(r));this.hasMutatedConstraints=!!a,a&&(r=Bo(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=ht(l=>{if(!cn(l,n,this.currentDirection))return;let d=c&&c[l]||{};r&&(d={min:0,max:0});const f=i?200:1e6,p=i?40:1e7,y={type:"inertia",velocity:s?e[l]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(l,y)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return ps(this.visualElement,e),s.start(ei(e,s,0,n,this.visualElement,!1))}stopAnimation(){ht(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){ht(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){ht(n=>{const{drag:s}=this.getProps();if(!cn(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n];o.set(e[n]-X(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!fe(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};ht(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const c=a.get();i[r]=Md({min:c,max:c},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),ht(r=>{if(!cn(r,e,null))return;const a=this.getAxisMotionValue(r),{min:c,max:u}=this.constraints[r];a.set(X(c,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;kd.set(this.visualElement,this);const e=this.visualElement.current,n=Oe(e,"pointerdown",c=>{const{drag:u,dragListener:l=!0}=this.getProps();u&&l&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();fe(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),W.read(s);const r=Xe(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(ht(l=>{const d=this.getAxisMotionValue(l);d&&(this.originPoint[l]+=c[l].translate,d.set(d.get()+c[l].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=ys,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function cn(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Vd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class Rd extends Wt{constructor(e){super(e),this.removeGroupControls=mt,this.removeListeners=mt,this.controls=new Dd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||mt}unmount(){this.removeGroupControls(),this.removeListeners()}}const rr=t=>(e,n)=>{t&&W.postRender(()=>t(e,n))};class Nd extends Wt{constructor(){super(...arguments),this.removePointerDownListener=mt}onPointerDown(e){this.session=new sa(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:na(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:rr(e),onStart:rr(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&W.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=Oe(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 mn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function or(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Ne={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(V.test(t))t=parseFloat(t);else return t;const n=or(t,e.target.x),s=or(t,e.target.y);return`${n}% ${s}%`}},Id={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=_t.parse(t);if(i.length>5)return s;const o=_t.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=c;const u=X(a,c,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}};let Wn=!1;class Ld extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;ou(Od),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),Wn&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),mn.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,Wn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||W.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),_s.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 ra(t){const[e,n]=Po(),s=m.useContext(ws);return h.jsx(Ld,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(Oo),isPresent:e,safeToRemove:n})}const Od={borderRadius:{...Ne,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ne,borderTopRightRadius:Ne,borderBottomLeftRadius:Ne,borderBottomRightRadius:Ne,boxShadow:Id};function Fd(t,e,n){const s=et(t)?t:ve(t);return s.start(ei("",s,e,n)),s.animation}const Bd=(t,e)=>t.depth-e.depth;class $d{constructor(){this.children=[],this.isDirty=!1}add(e){Cs(this.children,e),this.isDirty=!0}remove(e){As(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Bd),this.isDirty=!1,this.children.forEach(e)}}function zd(t,e){const n=rt.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(Ut(s),t(o-e))};return W.setup(s,!0),()=>Ut(s)}const oa=["TopLeft","TopRight","BottomLeft","BottomRight"],Ud=oa.length,ar=t=>typeof t=="string"?parseFloat(t):t,cr=t=>typeof t=="number"||V.test(t);function _d(t,e,n,s,i,o){i?(t.opacity=X(0,n.opacity??1,Wd(s)),t.opacityExit=X(e.opacity??1,0,Kd(s))):o&&(t.opacity=X(e.opacity??1,n.opacity??1,s));for(let r=0;r<Ud;r++){const a=`border${oa[r]}Radius`;let c=lr(e,a),u=lr(n,a);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||cr(c)===cr(u)?(t[a]=Math.max(X(ar(c),ar(u),s),0),(Mt.test(u)||Mt.test(c))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=X(e.rotate||0,n.rotate||0,s))}function lr(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Wd=aa(0,.5,Kr),Kd=aa(.5,.95,mt);function aa(t,e,n){return s=>s<t?0:s>e?1:n(Ue(t,e,s))}function ur(t,e){t.min=e.min,t.max=e.max}function dt(t,e){ur(t.x,e.x),ur(t.y,e.y)}function dr(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function hr(t,e,n,s,i){return t-=e,t=wn(t,1/n,s),i!==void 0&&(t=wn(t,1/i,s)),t}function Hd(t,e=0,n=1,s=.5,i,o=t,r=t){if(Mt.test(e)&&(e=parseFloat(e),e=X(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=X(o.min,o.max,s);t===o&&(a-=e),t.min=hr(t.min,e,n,a,i),t.max=hr(t.max,e,n,a,i)}function fr(t,e,[n,s,i],o,r){Hd(t,e[n],e[s],e[i],e.scale,o,r)}const Xd=["x","scaleX","originX"],Gd=["y","scaleY","originY"];function mr(t,e,n,s){fr(t.x,e,Xd,n?n.x:void 0,s?s.x:void 0),fr(t.y,e,Gd,n?n.y:void 0,s?s.y:void 0)}function pr(t){return t.translate===0&&t.scale===1}function ca(t){return pr(t.x)&&pr(t.y)}function gr(t,e){return t.min===e.min&&t.max===e.max}function qd(t,e){return gr(t.x,e.x)&&gr(t.y,e.y)}function yr(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function la(t,e){return yr(t.x,e.x)&&yr(t.y,e.y)}function xr(t){return nt(t.x)/nt(t.y)}function vr(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Yd{constructor(){this.members=[]}add(e){Cs(this.members,e),e.scheduleRender()}remove(e){if(As(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Jd(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:l,rotateX:d,rotateY:f,skewX:p,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),l&&(s+=`rotate(${l}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),p&&(s+=`skewX(${p}deg) `),y&&(s+=`skewY(${y}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(s+=`scale(${a}, ${c})`),s||"none"}const Kn=["","X","Y","Z"],Zd=1e3;let Qd=0;function Hn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function ua(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Go(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",W,!(i||o))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&ua(s)}function da({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=Qd++,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(nh),this.nodes.forEach(oh),this.nodes.forEach(ah),this.nodes.forEach(sh)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new $d)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new Ms),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const c=this.eventHandlers.get(r);c&&c.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=Ao(r)&&!Wl(r),this.instance=r;const{layoutId:a,layout:c,visualElement:u}=this.options;if(u&&!u.current&&u.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let l,d=0;const f=()=>this.root.updateBlockedByResize=!1;W.read(()=>{d=window.innerWidth}),t(r,()=>{const p=window.innerWidth;p!==d&&(d=p,this.root.updateBlockedByResize=!0,l&&l(),l=zd(f,250),mn.hasAnimatedSinceResize&&(mn.hasAnimatedSinceResize=!1,this.nodes.forEach(Tr)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||c)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||hh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:S}=u.getProps(),x=!this.targetLayout||!la(this.targetLayout,p),b=!d&&f;if(this.options.layoutRoot||this.resumeFrom||b||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const T={...zs(y,"layout"),onPlay:v,onComplete:S};(u.shouldReduceMotion||this.options.layoutRoot)&&(T.delay=0,T.type=!1),this.startAnimation(T),this.setAnimationOrigin(l,b)}else d||Tr(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Ut(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(ch),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&ua(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const d=this.path[l];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(br);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(wr);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(rh),this.nodes.forEach(th),this.nodes.forEach(eh)):this.nodes.forEach(wr),this.clearAllSnapshots();const a=rt.now();Q.delta=Vt(0,1e3/60,a-Q.timestamp),Q.timestamp=a,Q.isProcessing=!0,Nn.update.process(Q),Nn.preRender.process(Q),Nn.render.process(Q),Q.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,_s.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(ih),this.sharedNodes.forEach(lh)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,W.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){W.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!nt(this.snapshot.measuredBox.x)&&!nt(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutCorrected=q(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&this.instance){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!ca(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,l=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||ee(this.latestValues)||l)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return r&&(c=this.removeTransform(c)),fh(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return q();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(mh))){const{scroll:u}=this.root;u&&(me(a.x,u.offset.x),me(a.y,u.offset.y))}return a}removeElementScroll(r){const a=q();if(dt(a,r),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:l,options:d}=u;u!==this.root&&l&&d.layoutScroll&&(l.wasRoot&&dt(a,r),me(a.x,l.offset.x),me(a.y,l.offset.y))}return a}applyTransform(r,a=!1){const c=q();dt(c,r);for(let u=0;u<this.path.length;u++){const l=this.path[u];!a&&l.options.layoutScroll&&l.scroll&&l!==l.root&&pe(c,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),ee(l.latestValues)&&pe(c,l.latestValues)}return ee(this.latestValues)&&pe(c,this.latestValues),c}removeTransform(r){const a=q();dt(a,r);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!ee(u.latestValues))continue;ds(u.latestValues)&&u.updateSnapshot();const l=q(),d=u.measurePageBox();dt(l,d),mr(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,l)}return ee(this.latestValues)&&mr(a,this.latestValues),a}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Q.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(r||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:l,layoutId:d}=this.options;if(!(!this.layout||!(l||d))){if(this.resolvedRelativeTargetAt=Q.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=q(),this.relativeTargetOrigin=q(),Be(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),dt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=q(),this.targetWithTransforms=q()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),bd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):dt(this.target,this.layout.layoutBox),zo(this.target,this.targetDelta)):dt(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=q(),this.relativeTargetOrigin=q(),Be(this.relativeTargetOrigin,this.target,f.target),dt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||ds(this.parent.latestValues)||$o(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const r=this.getLead(),a=!!this.resumingFrom||this!==r;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===Q.timestamp&&(c=!1),c)return;const{layout:u,layoutId:l}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||l))return;dt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;Nu(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=q());const{target:p}=r;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(dr(this.prevProjectionDelta.x,this.projectionDelta.x),dr(this.prevProjectionDelta.y,this.projectionDelta.y)),Fe(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!vr(this.projectionDelta.x,this.prevProjectionDelta.x)||!vr(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){if(this.options.visualElement?.scheduleRender(),r){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ge(),this.projectionDelta=ge(),this.projectionDeltaWithTransform=ge()}setAnimationOrigin(r,a=!1){const c=this.snapshot,u=c?c.latestValues:{},l={...this.latestValues},d=ge();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=q(),p=c?c.source:void 0,y=this.layout?this.layout.source:void 0,v=p!==y,S=this.getStack(),x=!S||S.members.length<=1,b=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(dh));this.animationProgress=0;let T;this.mixTargetDelta=D=>{const M=D/1e3;Sr(d.x,r.x,M),Sr(d.y,r.y,M),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Be(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),uh(this.relativeTarget,this.relativeTargetOrigin,f,M),T&&qd(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=q()),dt(T,this.relativeTarget)),v&&(this.animationValues=l,_d(l,u,this.latestValues,M,b,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=M},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Ut(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=W.update(()=>{mn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=ve(0)),this.currentAnimation=Fd(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),r.onUpdate&&r.onUpdate(a)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Zd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:c,layout:u,latestValues:l}=r;if(!(!a||!c||!u)){if(this!==r&&this.layout&&u&&ha(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||q();const d=nt(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+d;const f=nt(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+f}dt(a,c),pe(a,l),Fe(this.projectionDeltaWithTransform,this.layoutCorrected,a,l)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new Yd),this.sharedNodes.get(r).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const u={};c.z&&Hn("z",r,u,this.animationValues);for(let l=0;l<Kn.length;l++)Hn(`rotate${Kn[l]}`,r,u,this.animationValues),Hn(`skew${Kn[l]}`,r,u,this.animationValues);r.render();for(const l in u)r.setStaticValue(l,u[l]),this.animationValues&&(this.animationValues[l]=u[l]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=hn(a?.pointerEvents)||"",r.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=hn(a?.pointerEvents)||""),this.hasProjected&&!ee(this.latestValues)&&(r.transform=c?c({},""):"none",this.hasProjected=!1);return}r.visibility="";const l=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=Jd(this.projectionDeltaWithTransform,this.treeScale,l);c&&(d=c(l,d)),r.transform=d;const{x:f,y:p}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${p.origin*100}% 0`,u.animationValues?r.opacity=u===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:r.opacity=u===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const y in He){if(l[y]===void 0)continue;const{correct:v,applyTo:S,isCSSVariable:x}=He[y],b=d==="none"?l[y]:v(l[y],u);if(S){const T=S.length;for(let D=0;D<T;D++)r[S[D]]=b}else x?this.options.visualElement.renderState.vars[y]=b:r[y]=b}this.options.layoutId&&(r.pointerEvents=u===this?hn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(br),this.root.sharedNodes.clear()}}}function th(t){t.updateLayout()}function eh(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?ht(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=nt(d);d.min=n[l].min,d.max=d.min+f}):ha(i,e.layoutBox,n)&&ht(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=nt(n[l]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[l].max=t.relativeTarget[l].min+f)});const r=ge();Fe(r,n,e.layoutBox);const a=ge();o?Fe(a,t.applyTransform(s,!0),e.measuredBox):Fe(a,n,e.layoutBox);const c=!ca(r);let u=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:d,layout:f}=l;if(d&&f){const p=q();Be(p,e.layoutBox,d.layoutBox);const y=q();Be(y,n,f.layoutBox),la(p,y)||(u=!0),l.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=p,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function nh(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 sh(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function ih(t){t.clearSnapshot()}function br(t){t.clearMeasurements()}function wr(t){t.isLayoutDirty=!1}function rh(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Tr(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function oh(t){t.resolveTargetDelta()}function ah(t){t.calcProjection()}function ch(t){t.resetSkewAndRotation()}function lh(t){t.removeLeadSnapshot()}function Sr(t,e,n){t.translate=X(e.translate,0,n),t.scale=X(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Cr(t,e,n,s){t.min=X(e.min,n.min,s),t.max=X(e.max,n.max,s)}function uh(t,e,n,s){Cr(t.x,e.x,n.x,s),Cr(t.y,e.y,n.y,s)}function dh(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const hh={duration:.45,ease:[.4,0,.1,1]},Ar=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Pr=Ar("applewebkit/")&&!Ar("chrome/")?Math.round:mt;function Mr(t){t.min=Pr(t.min),t.max=Pr(t.max)}function fh(t){Mr(t.x),Mr(t.y)}function ha(t,e,n){return t==="position"||t==="preserve-aspect"&&!vd(xr(e),xr(n),.2)}function mh(t){return t!==t.root&&t.scroll?.wasRoot}const ph=da({attachResizeListener:(t,e)=>Xe(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Xn={current:void 0},fa=da({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Xn.current){const t=new ph({});t.mount(window),t.setOptions({layoutScroll:!0}),Xn.current=t}return Xn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),gh={pan:{Feature:Nd},drag:{Feature:Rd,ProjectionNode:fa,MeasureLayout:ra}};function jr(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&W.postRender(()=>o(e,Je(e)))}class yh extends Wt{mount(){const{current:e}=this.node;e&&(this.unmount=Bl(e,(n,s)=>(jr(this.node,s,"Start"),i=>jr(this.node,i,"End"))))}unmount(){}}class xh extends Wt{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=Ge(Xe(this.node.current,"focus",()=>this.onFocus()),Xe(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Er(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&W.postRender(()=>o(e,Je(e)))}class vh extends Wt{mount(){const{current:e}=this.node;e&&(this.unmount=_l(e,(n,s)=>(Er(this.node,s,"Start"),(i,{success:o})=>Er(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const xs=new WeakMap,Gn=new WeakMap,bh=t=>{const e=xs.get(t.target);e&&e(t)},wh=t=>{t.forEach(bh)};function Th({root:t,...e}){const n=t||document;Gn.has(n)||Gn.set(n,{});const s=Gn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(wh,{root:t,...e})),s[i]}function Sh(t,e,n){const s=Th(e);return xs.set(t,n),s.observe(t),()=>{xs.delete(t),s.unobserve(t)}}const Ch={some:0,all:1};class Ah extends Wt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Ch[i]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:l,onViewportLeave:d}=this.node.getProps(),f=u?l:d;f&&f(c)};return Sh(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(Ph(e,n))&&this.startObserver()}unmount(){}}function Ph({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const ma={inView:{Feature:Ah},tap:{Feature:vh},focus:{Feature:xh},hover:{Feature:yh}},Mh={layout:{ProjectionNode:fa,MeasureLayout:ra}},jh={...Qo,...ma,...gh,...Mh},Eh=Du(jh,Xo),kh={renderer:Xo,...Qo,...ma};function pa(t,e){return fn(t,e)}const ln=pa("div"),Dh=pa("p"),Pt=Symbol.for("@arcteninc/core:originalName");function Vh(t,e){return t[Pt]=e,t}function Rh(t,e,n,s){if(typeof t!="function")return null;const i=t[Pt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const o=t.name;let r;if(o&&(r=e[o],r&&!n.has(r.name)))return t[Pt]=r.name,{fn:t,meta:r};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(r=e[a],r))return t[Pt]=r.name,{fn:t,meta:r}}else if(r=Object.values(e).find(c=>!n.has(c.name)),r)return t[Pt]=r.name,{fn:t,meta:r};return null}function ga(t,e){let n,s;if(!e)throw new Error(`❌ toolMetadata is required!
10
10
 
11
11
  Please:
12
12
  1. Run "arcten-extract-types ." before build (add to package.json scripts)
@@ -15,10 +15,10 @@ Please:
15
15
  3. Pass it to useAgent/ArctenAgent:
16
16
  useAgent({ tools: [...], toolMetadata: toolMetadata })
17
17
  (Pass the full object for better minification support, or toolMetadata.functions for backward compatibility)
18
- `);if("functions"in e&&typeof e.functions=="object"){const o=e;n=o.functions,s=o.toolOrder}else n=e,s=void 0;const i=new Set;return t.map(o=>{const r=Th(o,n,i,s);if(!r){const a=o.name,u=o[bt]||a||"unnamed";return typeof process<"u"&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production")&&typeof console<"u"&&console.warn&&console.warn(`⚠️ [@arcteninc/core] No metadata found for tool "${u}". This tool will be excluded.
19
- To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return i.add(r.meta.name),{name:r.meta.name,description:r.meta.description,jsonSchema:r.meta.parameters}}).filter(o=>o!==null)}function Sh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const o=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),o&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([r,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[r,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},r))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(nn,{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(nn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(G.X,{className:"h-3 w-3"})})]})]})})}function Ch({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,o]=m.useState(!1);if(t==="fetchDocContent")return null;const r=["k","maxResults","_organizationId"];t==="searchDocs"&&r.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!r.includes(u))),l=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>l&&o(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${l?"cursor-pointer hover:bg-opacity-80":""}`,children:[l&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(G.ChevronDown,{className:"h-3 w-3"}):h.jsx(G.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(G.X,{className:"h-3 w-3"}):s?h.jsx(G.Zap,{className:"h-3 w-3"}):h.jsx(G.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&l&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,c])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof c=="string"?c:JSON.stringify(c)})]},u))})})]})}function Ph({...t}){return h.jsx(rs.Root,{"data-slot":"collapsible",...t})}function Ah({...t}){return h.jsx(rs.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Mh({...t}){return h.jsx(rs.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const jh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),zs=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(jh,{className:Z("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);zs.displayName="Response";const Eh=Object.freeze(Object.defineProperty({__proto__:null,Response:zs},Symbol.toStringTag,{value:"Module"})),Vh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const o=xh.create(e),r=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(o,{animate:{backgroundPosition:"0% center"},className:Z("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${r}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},Dh=m.memo(Vh),ia=m.createContext(null),kh=()=>{const t=m.useContext(ia);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Rh=1e3,Nh=1e3,ra=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:o,children:r,...a})=>{const[l,u]=ti.useControllableState({prop:n,defaultProp:s,onChange:i}),[c,d]=ti.useControllableState({prop:o,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)/Nh)),v(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&l&&!f){const x=setTimeout(()=>{u(!1),g(!0)},Rh);return()=>clearTimeout(x)}},[e,l,s,u,f]);const w=x=>{u(x)};return h.jsx(ia.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:u,duration:c},children:h.jsx(Ph,{className:Z("not-prose mb-4",t),onOpenChange:w,open:l,...a,children:r})})}),Ih=(t,e)=>t||e===0?h.jsx(Dh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),oa=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:o}=kh();return h.jsx(Ah,{className:Z("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...n,children:e??h.jsxs(h.Fragment,{children:[h.jsx(G.BrainIcon,{className:"size-4"}),Ih(s,o),h.jsx(G.ChevronDownIcon,{className:Z("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),aa=m.memo(({className:t,children:e,...n})=>h.jsx(Mh,{className:Z("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...n,children:h.jsx(zs,{className:"grid gap-2",children:e})}));ra.displayName="Reasoning";oa.displayName="ReasoningTrigger";aa.displayName="ReasoningContent";function je(t){if(typeof t=="string")try{const e=JSON.parse(t);return je(e)}catch{return t}if(Array.isArray(t))return t.map(je);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=je(s);return e}return t}function Nn(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return je(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?je(t):{}}function Lh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:o=void 0,defaultWidth:r=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:c=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:y="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:w}){const[x,S]=m.useState(null),b=m.useRef(null),[V,P]=m.useState(null),[E,R]=m.useState(null),A=m.useRef(null),[L,W]=m.useState(u),[U,Tt]=m.useState(r),[Mt,mt]=m.useState(600),[it,pt]=m.useState(!1),[j,Y]=m.useState(!1),[H,rt]=m.useState(!1),[_,fe]=m.useState({x:100,y:100}),[qt,It]=m.useState(!1),[me,Lt]=m.useState({x:0,y:0}),[pe,fn]=m.useState(!1),ge=m.useRef(null),Jt=m.useRef(null),[Ot,ye]=m.useState(""),[D,N]=m.useState(null),[F,Q]=m.useState("Thinking..."),[tt,q]=m.useState(new Set),[xe,la]=m.useState(""),[Ft,ca]=m.useState([]),[mn,Us]=m.useState(!1),[pn,_s]=m.useState([]),[Ws,gn]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Zt,$e]=m.useState(!1),[Bh,ze]=m.useState(!1),[$h,Ue]=m.useState([]),Bt=m.useMemo(()=>[...c,...d],[c,d]),gt=m.useMemo(()=>sa(Bt,f),[Bt,f]),Ks=m.useMemo(()=>new Set(gt.map(p=>p.name)),[gt]),Hs=m.useMemo(()=>gt.filter(p=>Ks.has(p.name)),[gt,Ks]),Xs=m.useMemo(()=>{const p=new Map,T=new Map(gt.map(k=>[k.name,k]));return Bt.forEach(k=>{const C=k[bt];if(C){const I=T.get(C);if(I){p.set(I.name,k);return}}const O=gt.find(I=>I.name===k.name);O&&p.set(O.name,k)}),p},[Bt,gt]),Gs=m.useMemo(()=>{const p=new Set,T=new Map(gt.map(k=>[k.name,k]));return d.forEach(k=>{const C=k[bt];if(C&&T.has(C))p.add(C);else{const O=gt.find(I=>I.name===k.name);O&&p.add(O.name)}}),p},[d,gt]),Ys=["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&&W(JSON.parse(p));const T=localStorage.getItem("arcten-sidebar-width");T&&Tt(parseInt(T));const k=localStorage.getItem("arcten-sidebar-height");k&&mt(parseInt(k));const C=localStorage.getItem("arcten-sidebar-detached");C&&Y(JSON.parse(C));const O=localStorage.getItem("arcten-sidebar-position");if(O){const Et=JSON.parse(O),xt=50,Vt=Math.max(xt-r,Math.min(Et.x,window.innerWidth-xt)),ot=Math.max(0,Math.min(Et.y,window.innerHeight-xt));fe({x:Vt,y:ot})}const I=localStorage.getItem("arcten-sidebar-minimized");I&&rt(JSON.parse(I)),fn(!0)}},[]);const jt=m.useMemo(()=>w,[w?.id]);m.useEffect(()=>((async()=>{try{const T=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:jt})});if(!T.ok)throw new Error("Failed to fetch token");const k=await T.json();S(k.clientToken),b.current=k.clientToken,R(k.expiresAt),P(null)}catch(T){P(T instanceof Error?T.message:"Failed to fetch token")}})(),()=>{A.current&&clearTimeout(A.current)}),[y,jt]),m.useEffect(()=>{if(!E)return;A.current&&clearTimeout(A.current);const p=Math.floor(Date.now()/1e3),T=E-p,C=Math.max(0,T-5);return A.current=setTimeout(async()=>{try{const O=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:jt})});if(!O.ok)throw new Error("Failed to refresh token");const I=await O.json();S(I.clientToken),b.current=I.clientToken,R(I.expiresAt),P(null)}catch(O){console.error("Token refresh failed:",O),P(O instanceof Error?O.message:"Failed to refresh token")}},C*1e3),()=>{A.current&&clearTimeout(A.current)}},[E,y,jt]),m.useEffect(()=>{(async()=>{if(Bt.length!==0)try{const T=Bt.map(C=>({name:C.name,code:C.toString()})),k=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:T})});if(k.ok){const C=await k.json();ca(C.tools)}}catch(T){console.error("Failed to fetch tool descriptions:",T)}})()},[Bt]),m.useEffect(()=>{Promise.resolve().then(()=>Eh).then(p=>{N(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{la(window.location.pathname)};p(),window.addEventListener("popstate",p);const T=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(T)}},[]);const yn=m.useCallback(async()=>{if(!(!jt?.id||!x)){ze(!0);try{const T=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${x}`}})).json();_s(T.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{ze(!1)}}},[jt?.id,x,v]);m.useEffect(()=>{jt?.id&&x&&yn()},[jt?.id,x,yn]);function ua(p){const T=Math.floor((Date.now()-p)/1e3);return T<60?"now":T<3600?`${Math.floor(T/60)}m`:T<86400?`${Math.floor(T/3600)}h`:`${Math.floor(T/86400)}d`}function da(){const p=crypto.randomUUID();gn(p),We([]),Ue([]),$e(!1)}async function ha(p){if(x)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${x}`}}),_s(pn.filter(T=>T._id!==p)),p===Ws&&da()}catch(T){console.error("Failed to delete conversation:",T)}}async function fa(p){gn(p.chatId),$e(!1),ze(!0);try{const T=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${b.current}`}});if(!T.ok)throw new Error(`Failed to fetch messages: ${T.statusText}`);const C=(await T.json()).messages||[];We(C),Ue(C)}catch(T){console.error("Failed to load conversation messages:",T);const k=p.messages||[];We(k),Ue(k)}finally{ze(!1)}}const ma=async(p,T={})=>{const k=T.headers?new Headers(T.headers):new Headers;return k.delete("user-agent"),k.delete("User-Agent"),fetch(p,{...T,headers:k})},{messages:ve,sendMessage:pa,status:yt,error:qs,stop:_e,addToolResult:be,setMessages:We}=yr.useChat({id:Ws||void 0,transport:new en.DefaultChatTransport({api:`${v}/chat`,fetch:ma,headers:()=>{const p={};return b.current&&(p.Authorization=`Bearer ${b.current}`),p},body:()=>({tools:Hs.map(T=>({name:T.name,description:T.description,inputSchema:T.jsonSchema})),systemPrompt:g,currentRoute:xe})}),sendAutomaticallyWhen:en.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{L&&Jt.current&&Jt.current.focus()},[L,ve]);function ga(){W(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function ya(){W(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[L]),m.useEffect(()=>{ge.current&&ge.current.scrollIntoView({behavior:"smooth"})},[ve]),m.useEffect(()=>{function p(T){T.key==="Escape"&&(yt==="streaming"||yt==="submitted")&&(T.preventDefault(),_e())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[yt,_e]);function xa(){const p=crypto.randomUUID();gn(p),We([]),Ue([]),$e(!1)}function Js(p){if(p.preventDefault(),!Ot.trim())return;(yt==="streaming"||yt==="submitted")&&_e();const T=Ys[Math.floor(Math.random()*Ys.length)]||"Thinking...";Q(T),pa({text:Ot}),ye("")}function va(p){const T=p.target.value;ye(T)}m.useEffect(()=>{if(!it)return;function p(k){if(j){const C=k.clientX-_.x,O=k.clientY-_.y;C>=a&&C<=l&&Tt(C),O>=400&&O<=1e3&&mt(O)}else{const C=window.innerWidth-k.clientX;C>=a&&C<=l&&Tt(C)}}function T(){pt(!1),localStorage.setItem("arcten-sidebar-width",U.toString()),localStorage.setItem("arcten-sidebar-height",Mt.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[it,U,Mt,j,_,a,l]);function ba(p){p.preventDefault(),pt(!0)}function wa(){Y(!0),rt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ta(){Y(!1),rt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Zs(){rt(!H),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!H))}function Sa(p){j&&(It(!0),Lt({x:p.clientX-_.x,y:p.clientY-_.y}))}return m.useEffect(()=>{if(!j)return;function p(){fe(T=>{const C=window.innerWidth-50,O=window.innerHeight-50,I=50-U,Et=0,xt=Math.max(I,Math.min(T.x,C)),Vt=Math.max(Et,Math.min(T.y,O));if(xt!==T.x||Vt!==T.y){const ot={x:xt,y:Vt};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(ot)),ot}return T})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[j,U]),m.useEffect(()=>{if(!qt)return;function p(k){const C=k.clientX-me.x,O=k.clientY-me.y,I=50,Et=window.innerWidth-I,xt=window.innerHeight-I,Vt=I-U,ot=0,St=Math.max(Vt,Math.min(C,Et)),vt=Math.max(ot,Math.min(O,xt));fe({x:St,y:vt})}function T(){It(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(_))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[qt,me,_,U]),pe?V?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: ",V]})}):x?h.jsx(_c,{features:vh,children:h.jsx(Ye,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:j?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:j?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
20
- ${j?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
21
- ${L?"bg-stone-50 dark:bg-stone-900":"bg-stone-100 dark:bg-stone-800 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors duration-200"}
22
- ${j?"border border-border":"border-l border-border"}
23
- ${L?"":"w-[30px]"}
24
- `,style:L?j?{width:`${U}px`,height:H?"auto":`${Mt}px`,left:`${_.x}px`,top:`${_.y}px`}:{width:`${U}px`}:void 0,onClick:L?void 0:ga,children:L?h.jsxs(h.Fragment,{children:[!j&&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:ba,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),j&&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(),It(!0),Lt({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(),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 ${j?"cursor-move":""}`,onMouseDown:j?Sa:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${j&&H?"cursor-pointer":""}`,onClick:j&&H?p=>{p.stopPropagation(),Zs()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs($t,{children:[h.jsx(zt,{asChild:!0,children:h.jsx("button",{type:"button",className:Z(Wt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:xa,"aria-label":"New chat",children:h.jsx(G.Plus,{className:"h-4 w-4"})})}),h.jsx(Ut,{children:"Start a new conversation"})]}),h.jsxs($t,{children:[h.jsx(zt,{asChild:!0,children:h.jsx("button",{type:"button",className:Z(Wt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:j?Ta:wa,"aria-label":j?"Dock sidebar":"Float sidebar",children:j?h.jsx(G.Dock,{className:"h-4 w-4"}):h.jsx(G.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Ut,{children:j?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs($t,{children:[h.jsx(zt,{asChild:!0,children:h.jsx("button",{type:"button",className:Z(Wt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:j?Zs:ya,"aria-label":j?H?"Maximize":"Minimize":"Close sidebar",children:j?H?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(Ut,{children:j?H?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!H&&h.jsxs(h.Fragment,{children:[w&&pn.length>0&&h.jsxs("div",{className:`border-b border-border ${Zt?"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(nn,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Zt||yn(),$e(!Zt)},children:Zt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Zt?"flex-1 overflow-y-auto":""}`,children:pn.slice(0,Zt?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:Z(Wt({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>fa(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:ua(p.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:T=>{T.stopPropagation(),ha(p._id)},"aria-label":"Delete conversation",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:ve.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&h.jsx("div",{className:"mb-6",children:o}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),Ft.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:[(mn?Ft:Ft.slice(0,10)).map(p=>h.jsxs($t,{children:[h.jsx(zt,{asChild:!0,children:h.jsx(xn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{ye(p.sampleUsage),Jt.current?.focus()},children:p.friendlyName})}),h.jsx(Ut,{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)),Ft.length>10&&!mn&&h.jsxs($t,{children:[h.jsx(zt,{asChild:!0,children:h.jsxs(xn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Us(!0),children:["+",Ft.length-10," more"]})}),h.jsx(Ut,{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:Ft.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"})]})})]}),mn&&Ft.length>10&&h.jsx(xn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Us(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[ve.map(p=>{const k=p.parts.filter(C=>C.type==="text").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(bh,{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:k}):h.jsx("div",{className:"space-y-2",children:p.parts.map((C,O)=>{if(C.type?.startsWith("tool-")){const I=C.type?.replace("tool-","")||"",Et=Hs.find(ot=>ot.name===I),xt=C.state==="input-available",Vt=C.state==="output-available";if(xt){if(Gs.has(I))return(async()=>{if(tt.has(C.toolCallId))return;q(we=>new Set(we).add(C.toolCallId));const vt=Xs.get(I);if(vt)try{const we=Nn(C.input),Ca=await vt(...Object.values(we));be({toolCallId:C.toolCallId,tool:I,output:Ca})}catch(we){be({toolCallId:C.toolCallId,tool:I,output:`Error: ${we}`})}})(),null;const ot=Nn(C.input);return h.jsx(Ye,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(Sh,{toolName:I,description:Et?.description||"",args:ot,onApprove:async()=>{if(tt.has(C.toolCallId))return;q(vt=>new Set(vt).add(C.toolCallId));const St=Xs.get(I);if(St)try{const vt=await St(...Object.values(ot));be({toolCallId:C.toolCallId,tool:I,output:vt})}catch(vt){be({toolCallId:C.toolCallId,tool:I,output:`Error: ${vt}`})}},onDeny:async()=>{tt.has(C.toolCallId)||(q(St=>new Set(St).add(C.toolCallId)),be({toolCallId:C.toolCallId,tool:I,output:"User denied tool execution"}))}})},`${C.toolCallId}-${O}`)}else if(Vt){const ot=C.output==="User denied tool execution",St=Nn(C.input);return h.jsx(Ch,{toolName:I,args:St,isDenied:ot,isSafe:Gs.has(I)},`${C.toolCallId}-${O}`)}return null}return C.type==="text"&&C.text&&D?h.jsx(D,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:C.text},`${p.id}-${O}`):C.type==="reasoning"&&C.text?h.jsxs(ra,{className:"w-full",isStreaming:yt==="streaming"&&O===p.parts.length-1&&p.id===ve.at(-1)?.id,children:[h.jsx(oa,{}),h.jsx(aa,{children:C.text})]},`${p.id}-${O}`):null})})})},p.id)}),h.jsx("div",{ref:ge})]})}),qs&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",qs.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Uc,{mode:"wait",children:(yt==="streaming"||yt==="submitted")&&h.jsxs(Ye,{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(Ye,{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:F})]})}),h.jsxs("form",{onSubmit:Js,className:"relative",children:[h.jsx(br,{ref:Jt,value:Ot,onChange:va,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(),Js(p))}}),yt==="streaming"||yt==="submitted"?h.jsxs($t,{children:[h.jsx(zt,{asChild:!0,children:h.jsx("button",{type:"button",className:Z(Wt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:_e,children:h.jsx(G.Square,{className:"h-4 w-4"})})}),h.jsxs(Ut,{children:[h.jsx(ei,{children:"Escape"})," to stop"]})]}):h.jsxs($t,{children:[h.jsx(zt,{asChild:!0,children:h.jsx("button",{type:"submit",className:Z(Wt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!Ot.trim(),children:h.jsx(G.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Ut,{children:[h.jsx(ei,{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 Ee(t){if(typeof t=="string")try{const e=JSON.parse(t);return Ee(e)}catch{return t}if(Array.isArray(t))return t.map(Ee);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=Ee(s);return e}return t}function Oh(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return Ee(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?Ee(t):{}}function Fh({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:o=[],safeTools:r=[],toolMetadata:a,systemPrompt:l="",initialMessages:u=[],conversationId:c,onToolCall:d,onFinish:f,ragFilters:g}={}){const[y,v]=m.useState(n||null),w=m.useRef(n||null),[x,S]=m.useState(null),[b,V]=m.useState(null),P=m.useRef(null),[E,R]=m.useState([]),[A,L]=m.useState(c||(typeof window<"u"?crypto.randomUUID():null)),[W,U]=m.useState(!1),[Tt,Mt]=m.useState(new Set),mt=m.useMemo(()=>[...o,...r],[o,r]),it=m.useMemo(()=>sa(mt,a),[mt,a]),pt=m.useMemo(()=>{const D=new Map,N=new Map(it.map(F=>[F.name,F]));return mt.forEach(F=>{const Q=F[bt];if(Q){const q=N.get(Q);if(q){D.set(q.name,F);return}}const tt=it.find(q=>q.name===F.name);tt&&D.set(tt.name,F)}),D},[mt,it]),j=m.useMemo(()=>new Set(it.map(D=>D.name)),[it]),Y=m.useMemo(()=>it.filter(D=>j.has(D.name)),[it,j]),H=m.useMemo(()=>{const D=new Set;return r.forEach(N=>{for(const[F,Q]of pt.entries())if(Q===N){D.add(F);break}}),D},[r,pt]);m.useEffect(()=>s||n?void 0:((async()=>{try{const N=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!N.ok)throw new Error("Failed to fetch token");const F=await N.json();v(F.clientToken),w.current=F.clientToken,V(F.expiresAt),S(null)}catch(N){console.error("[useAgent] Token fetch failed:",N),S(N instanceof Error?N.message:"Failed to fetch token")}})(),()=>{P.current&&clearTimeout(P.current)}),[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(!b||s||n)return;P.current&&clearTimeout(P.current);const D=Math.floor(Date.now()/1e3),N=b-D,Q=Math.max(0,N-5);return P.current=setTimeout(async()=>{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 q=await tt.json();v(q.clientToken),w.current=q.clientToken,V(q.expiresAt),S(null)}catch(tt){console.error("[useAgent] Token refresh failed:",tt),S(tt instanceof Error?tt.message:"Failed to refresh token")}},Q*1e3),()=>{P.current&&clearTimeout(P.current)}},[b,e,JSON.stringify(i),s,n]);const rt=async(D,N={})=>{const F=N.headers?new Headers(N.headers):new Headers;return F.delete("user-agent"),F.delete("User-Agent"),fetch(D,{...N,headers:F})},{messages:_,sendMessage:fe,status:qt,error:It,stop:me,addToolResult:Lt,setMessages:pe}=yr.useChat({id:A||void 0,messages:u,transport:new en.DefaultChatTransport({api:`${t}/chat`,fetch:rt,headers:()=>{const D={};return w.current&&(D.Authorization=`Bearer ${w.current}`),D},body:()=>({tools:Y.map(N=>({name:N.name,description:N.description,inputSchema:N.jsonSchema})),systemPrompt:l,...g&&{ragFilters:g}})}),sendAutomaticallyWhen:en.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{_.forEach(D=>{D.role==="assistant"&&D.parts.forEach(N=>{if(!N.type?.startsWith("tool-")||N.state!=="input-available")return;const F=N.type.replace("tool-",""),Q=N.toolCallId;if(Tt.has(Q))return;Mt(q=>new Set(q).add(Q));const tt=Oh(N.input);if(H.has(F)){const q=pt.get(F);q&&(async()=>{try{const xe=await q(...Object.values(tt));Lt({toolCallId:Q,tool:F,output:xe})}catch(xe){Lt({toolCallId:Q,tool:F,output:`Error: ${xe}`})}})()}else d&&d({toolCall:{toolCallId:Q,toolName:F,args:tt}})})})},[_,H,pt,d,Lt,Tt]),m.useEffect(()=>{if(qt==="ready"&&_.length>0&&f){const D=_[_.length-1];D&&D.role==="assistant"&&f({message:D,messages:_,isAbort:!1,isDisconnect:!1,isError:!!It})}},[qt,_,It,f]);async function fn(){if(!(!i?.id||!y)){U(!0);try{const N=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${y}`}})).json();R(N.conversations||[])}catch(D){console.error("Failed to fetch conversations:",D)}finally{U(!1)}}}m.useEffect(()=>{i?.id&&y&&fn()},[JSON.stringify(i),y,t]);async function ge(D){L(D),U(!0);try{const N=await fetch(`${t}/conversations/${D}/messages`,{headers:{Authorization:`Bearer ${w.current}`}});if(!N.ok)throw new Error(`Failed to fetch messages: ${N.statusText}`);const Q=(await N.json()).messages||[];pe(Q)}catch(N){console.error("Failed to load conversation messages:",N)}finally{U(!1)}}async function Jt(D){if(y)try{await fetch(`${t}/conversations/${D}`,{method:"DELETE",headers:{Authorization:`Bearer ${y}`}}),R(E.filter(N=>N._id!==D)),D===A&&Ot()}catch(N){console.error("Failed to delete conversation:",N)}}function Ot(){const D=crypto.randomUUID();L(D),pe([]),Mt(new Set)}function ye(D){Lt(D)}return{id:A,messages:_,status:qt,error:It,sendMessage:fe,stop:me,addToolOutput:ye,setMessages:pe,conversations:E,loadConversation:ge,deleteConversation:Jt,startNewConversation:Ot,isLoadingConversations:W,clientToken:y,tokenError:x}}exports.verifyToken=La.verifyToken;exports.ARCTEN_ORIGINAL_NAME=bt;exports.ArctenAgent=Lh;exports.preserveToolName=wh;exports.useAgent=Fh;
18
+ `);if("functions"in e&&typeof e.functions=="object"){const o=e;n=o.functions,s=o.toolOrder}else n=e,s=void 0;const i=new Set;return t.map(o=>{const r=Rh(o,n,i,s);if(!r){const a=o.name,u=o[Pt]||a||"unnamed";return typeof process<"u"&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production")&&typeof console<"u"&&console.warn&&console.warn(`⚠️ [@arcteninc/core] No metadata found for tool "${u}". This tool will be excluded.
19
+ To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return i.add(r.meta.name),{name:r.meta.name,description:r.meta.description,jsonSchema:r.meta.parameters}}).filter(o=>o!==null)}function Nh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const o=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),o&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([r,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[r,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},r))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(gn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(J.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(gn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(J.X,{className:"h-3 w-3"})})]})]})})}function Ih({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,o]=m.useState(!1);if(t==="fetchDocContent")return null;const r=["k","maxResults","_organizationId"];t==="searchDocs"&&r.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!r.includes(u))),c=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>c&&o(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${c?"cursor-pointer hover:bg-opacity-80":""}`,children:[c&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(J.ChevronDown,{className:"h-3 w-3"}):h.jsx(J.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(J.X,{className:"h-3 w-3"}):s?h.jsx(J.Zap,{className:"h-3 w-3"}):h.jsx(J.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&c&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},u))})})]})}function Lh({...t}){return h.jsx(bs.Root,{"data-slot":"collapsible",...t})}function Oh({...t}){return h.jsx(bs.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Fh({...t}){return h.jsx(bs.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Bh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ni=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Bh,{className:tt("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ni.displayName="Response";const $h=Object.freeze(Object.defineProperty({__proto__:null,Response:ni},Symbol.toStringTag,{value:"Module"})),zh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const o=Eh.create(e),r=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(o,{animate:{backgroundPosition:"0% center"},className:tt("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${r}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},Uh=m.memo(zh),ya=m.createContext(null),_h=()=>{const t=m.useContext(ya);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Wh=1e3,Kh=1e3,xa=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:o,children:r,...a})=>{const[c,u]=fi.useControllableState({prop:n,defaultProp:s,onChange:i}),[l,d]=fi.useControllableState({prop:o,defaultProp:0}),[f,p]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{e?y===null&&v(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/Kh)),v(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&c&&!f){const x=setTimeout(()=>{u(!1),p(!0)},Wh);return()=>clearTimeout(x)}},[e,c,s,u,f]);const S=x=>{u(x)};return h.jsx(ya.Provider,{value:{isStreaming:e,isOpen:c,setIsOpen:u,duration:l},children:h.jsx(Lh,{className:tt("not-prose mb-4",t),onOpenChange:S,open:c,...a,children:r})})}),Hh=(t,e)=>t||e===0?h.jsx(Uh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),va=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:o}=_h();return h.jsx(Oh,{className:tt("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(J.BrainIcon,{className:"size-4"}),Hh(s,o),h.jsx(J.ChevronDownIcon,{className:tt("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),ba=m.memo(({className:t,children:e,...n})=>h.jsx(Fh,{className:tt("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(ni,{className:"grid gap-2",children:e})}));xa.displayName="Reasoning";va.displayName="ReasoningTrigger";ba.displayName="ReasoningContent";function Xh(t){const e=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,n=t.match(e),s=new Map;if(n){const u=n[1],l=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let d;for(;(d=l.exec(u))!==null;){const f=parseInt(d[1],10),p=d[2].replace(/[.,;:!?]+$/,"");s.set(f,p)}}const i=[];let o=0;const r=/```[\s\S]*?```|`[^`]+`/g;let a;for(;(a=r.exec(t))!==null;)a.index>o&&i.push({type:"text",content:t.slice(o,a.index),start:o,end:a.index}),i.push({type:"code",content:a[0],start:a.index,end:a.index+a[0].length}),o=a.index+a[0].length;return o<t.length&&i.push({type:"text",content:t.slice(o),start:o,end:t.length}),i.map(u=>{if(u.type==="code")return u.content;let l=u.content;l=l.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(v,S,x)=>{const b=parseInt(S,10);return`<sup><a href="${x.replace(/"/g,"&quot;")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${b}]</a></sup>`});const d=/\[([^\]]+)\]\([^\)]+\)/g,f=[];let p;for(;(p=d.exec(l))!==null;)f.push({start:p.index,end:p.index+p[0].length});return l.replace(/\[(\d+)\]/g,(v,S,x)=>{if(f.some(M=>x>=M.start&&x<M.end))return v;const T=parseInt(S,10),D=s.get(T);return D?`<sup><a href="${D.replace(/"/g,"&quot;")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${T}]</a></sup>`:v})}).join("")}function $e(t){if(typeof t=="string")try{const e=JSON.parse(t);return $e(e)}catch{return t}if(Array.isArray(t))return t.map($e);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=$e(s);return e}return t}function qn(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return $e(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?$e(t):{}}function Gh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:o=void 0,defaultWidth:r=384,minWidth:a=300,maxWidth:c=800,initiallyExpanded:u=!1,tools:l=[],safeTools:d=[],toolMetadata:f,systemPrompt:p="",tokenEndpoint:y="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:S,initialState:x={},sharedStateId:b}){const[T,D]=m.useState(null),M=m.useRef(null),[I,R]=m.useState(null),[E,_]=m.useState(null),B=m.useRef(null),[ct,It]=m.useState(x),pt=m.useRef(x),[oe,Lt]=m.useState(!1),[Pn,U]=m.useState(null),$=m.useRef(!1),[Z,ot]=m.useState(u),[lt,Ot]=m.useState(r),[jt,ae]=m.useState(600),[Ae,Ft]=m.useState(!1),[z,gt]=m.useState(!1),[st,Kt]=m.useState(!1),[it,Ht]=m.useState({x:100,y:100}),[Pe,Me]=m.useState(!1),[ce,yt]=m.useState({x:0,y:0}),[Mn,je]=m.useState(!1),Xt=m.useRef(null),le=m.useRef(null),[Et,Gt]=m.useState(""),[Ze,jn]=m.useState(null),[En,Qe]=m.useState("Thinking..."),[Ee,ke]=m.useState(new Set),[kn,Dn]=m.useState(""),[C,A]=m.useState([]),[j,k]=m.useState(!1),[L,K]=m.useState([]),[G,kt]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[xt,ue]=m.useState(!1),[si,tn]=m.useState(!1),[Jh,en]=m.useState([]),qt=m.useMemo(()=>[...l,...d],[l,d]),Tt=m.useMemo(()=>ga(qt,f),[qt,f]),ii=m.useMemo(()=>new Set(Tt.map(g=>g.name)),[Tt]),ri=m.useMemo(()=>Tt.filter(g=>ii.has(g.name)),[Tt,ii]),oi=m.useMemo(()=>{const g=new Map,w=new Map(Tt.map(N=>[N.name,N]));return qt.forEach(N=>{const P=N[Pt];if(P){const F=w.get(P);if(F){g.set(F.name,N);return}}const O=Tt.find(F=>F.name===N.name);O&&g.set(O.name,N)}),g},[qt,Tt]),ai=m.useMemo(()=>{const g=new Set,w=new Map(Tt.map(N=>[N.name,N]));return d.forEach(N=>{const P=N[Pt];if(P&&w.has(P))g.add(P);else{const O=Tt.find(F=>F.name===N.name);O&&g.add(O.name)}}),g},[d,Tt]),ci=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];m.useEffect(()=>{if(typeof window<"u"){const g=localStorage.getItem("arcten-sidebar-expanded");g&&ot(JSON.parse(g));const w=localStorage.getItem("arcten-sidebar-width");w&&Ot(parseInt(w));const N=localStorage.getItem("arcten-sidebar-height");N&&ae(parseInt(N));const P=localStorage.getItem("arcten-sidebar-detached");P&&gt(JSON.parse(P));const O=localStorage.getItem("arcten-sidebar-position");if(O){const ut=JSON.parse(O),Ct=50,$t=Math.max(Ct-r,Math.min(ut.x,window.innerWidth-Ct)),at=Math.max(0,Math.min(ut.y,window.innerHeight-Ct));Ht({x:$t,y:at})}const F=localStorage.getItem("arcten-sidebar-minimized");F&&Kt(JSON.parse(F)),je(!0)}},[]);const Bt=m.useMemo(()=>S,[S?.id]);m.useEffect(()=>((async()=>{try{const w=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:Bt})});if(!w.ok)throw new Error("Failed to fetch token");const N=await w.json();D(N.clientToken),M.current=N.clientToken,_(N.expiresAt),R(null)}catch(w){R(w instanceof Error?w.message:"Failed to fetch token")}})(),()=>{B.current&&clearTimeout(B.current)}),[y,Bt]),m.useEffect(()=>{if(!E)return;B.current&&clearTimeout(B.current);const g=Math.floor(Date.now()/1e3),w=E-g,P=Math.max(0,w-5);return B.current=setTimeout(async()=>{try{const O=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:Bt})});if(!O.ok)throw new Error("Failed to refresh token");const F=await O.json();D(F.clientToken),M.current=F.clientToken,_(F.expiresAt),R(null)}catch(O){console.error("Token refresh failed:",O),R(O instanceof Error?O.message:"Failed to refresh token")}},P*1e3),()=>{B.current&&clearTimeout(B.current)}},[E,y,Bt]),m.useEffect(()=>{(async()=>{if(qt.length!==0)try{const w=qt.map(P=>({name:P.name,code:P.toString()})),N=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:w})});if(N.ok){const P=await N.json();A(P.tools)}}catch(w){console.error("Failed to fetch tool descriptions:",w)}})()},[qt]),m.useEffect(()=>{Promise.resolve().then(()=>$h).then(g=>{jn(()=>g.Response)})},[]),m.useEffect(()=>{const g=()=>{Dn(window.location.pathname)};g(),window.addEventListener("popstate",g);const w=setInterval(g,500);return()=>{window.removeEventListener("popstate",g),clearInterval(w)}},[]);const Vn=m.useCallback(async()=>{if(!(!Bt?.id||!T)){tn(!0);try{const w=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${T}`}})).json();K(w.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{tn(!1)}}},[Bt?.id,T,v]);m.useEffect(()=>{Bt?.id&&T&&Vn()},[Bt?.id,T,Vn]);function wa(g){const w=Math.floor((Date.now()-g)/1e3);return w<60?"now":w<3600?`${Math.floor(w/60)}m`:w<86400?`${Math.floor(w/3600)}h`:`${Math.floor(w/86400)}d`}function Ta(){const g=crypto.randomUUID();kt(g),sn([]),en([]),ue(!1),b||(pt.current=x,It(x),$.current=!1)}async function Sa(g){if(T)try{await fetch(`${v}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${T}`}}),K(L.filter(w=>w._id!==g)),g===G&&Ta()}catch(w){console.error("Failed to delete conversation:",w)}}async function Ca(g){kt(g.chatId),ue(!1),tn(!0);try{const w=await fetch(`${v}/conversations/${g.chatId}/messages`,{headers:{Authorization:`Bearer ${M.current}`}});if(!w.ok)throw new Error(`Failed to fetch messages: ${w.statusText}`);const P=(await w.json()).messages||[];sn(P),en(P)}catch(w){console.error("Failed to load conversation messages:",w);const N=g.messages||[];sn(N),en(N)}finally{tn(!1)}}const Aa=async(g,w={})=>{const N=w.headers?new Headers(w.headers):new Headers;return N.delete("user-agent"),N.delete("User-Agent"),fetch(g,{...w,headers:N})},{messages:De,sendMessage:Pa,status:St,error:li,stop:nn,addToolResult:Ve,setMessages:sn}=kr.useChat({id:G||void 0,transport:new pn.DefaultChatTransport({api:`${v}/chat`,fetch:Aa,headers:()=>{const g={};return M.current&&(g.Authorization=`Bearer ${M.current}`),g},body:()=>({tools:ri.map(w=>({name:w.name,description:w.description,inputSchema:w.jsonSchema})),systemPrompt:p,currentRoute:kn,state:pt.current})}),sendAutomaticallyWhen:pn.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{if(!G||!M.current)return;(async()=>{Lt(!0),U(null);try{let w={};if(b){const O=await fetch(`${v.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${M.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:b},format:"json"})});if(!O.ok){const ut=await O.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch shared state: ${O.status} ${ut}`)}w=(await O.json())?.value||{}}else{const O=await fetch(`${v.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${M.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:G},format:"json"})});if(!O.ok){const ut=await O.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${O.status} ${ut}`)}w=(await O.json())?.value||{}}const N=!$.current;let P;N?(P={...x,...w},$.current=!0):P=w,pt.current=P,It(P)}catch(w){console.error("Failed to fetch state:",w);const N=w instanceof Error?w:new Error(String(w));U(N),$.current||(pt.current=x,It(x),$.current=!0)}finally{Lt(!1)}})()},[G,b,v]),m.useEffect(()=>{Z&&le.current&&le.current.focus()},[Z,De]);function Ma(){ot(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function ja(){ot(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[Z]),m.useEffect(()=>{Xt.current&&Xt.current.scrollIntoView({behavior:"smooth"})},[De]),m.useEffect(()=>{function g(w){w.key==="Escape"&&(St==="streaming"||St==="submitted")&&(w.preventDefault(),nn())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[St,nn]);function Ea(){const g=crypto.randomUUID();kt(g),sn([]),en([]),ue(!1)}function ui(g){if(g.preventDefault(),!Et.trim())return;(St==="streaming"||St==="submitted")&&nn();const w=ci[Math.floor(Math.random()*ci.length)]||"Thinking...";Qe(w),Pa({text:Et}),Gt("")}function ka(g){const w=g.target.value;Gt(w)}m.useEffect(()=>{if(!Ae)return;function g(N){if(z){const P=N.clientX-it.x,O=N.clientY-it.y;P>=a&&P<=c&&Ot(P),O>=400&&O<=1e3&&ae(O)}else{const P=window.innerWidth-N.clientX;P>=a&&P<=c&&Ot(P)}}function w(){Ft(!1),localStorage.setItem("arcten-sidebar-width",lt.toString()),localStorage.setItem("arcten-sidebar-height",jt.toString())}return window.addEventListener("mousemove",g),window.addEventListener("mouseup",w),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",w)}},[Ae,lt,jt,z,it,a,c]);function Da(g){g.preventDefault(),Ft(!0)}function Va(){gt(!0),Kt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ra(){gt(!1),Kt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function di(){Kt(!st),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!st))}function Na(g){z&&(Me(!0),yt({x:g.clientX-it.x,y:g.clientY-it.y}))}return m.useEffect(()=>{if(!z)return;function g(){Ht(w=>{const P=window.innerWidth-50,O=window.innerHeight-50,F=50-lt,ut=0,Ct=Math.max(F,Math.min(w.x,P)),$t=Math.max(ut,Math.min(w.y,O));if(Ct!==w.x||$t!==w.y){const at={x:Ct,y:$t};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(at)),at}return w})}return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[z,lt]),m.useEffect(()=>{if(!Pe)return;function g(N){const P=N.clientX-ce.x,O=N.clientY-ce.y,F=50,ut=window.innerWidth-F,Ct=window.innerHeight-F,$t=F-lt,at=0,Dt=Math.max($t,Math.min(P,ut)),At=Math.max(at,Math.min(O,Ct));Ht({x:Dt,y:At})}function w(){Me(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(it))}return window.addEventListener("mousemove",g),window.addEventListener("mouseup",w),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",w)}},[Pe,ce,it,lt]),Mn?I?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: ",I]})}):T?h.jsx(tu,{features:kh,children:h.jsx(ln,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:z?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:z?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
20
+ ${z?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
21
+ ${Z?"bg-stone-50 dark:bg-stone-900":"bg-stone-100 dark:bg-stone-800 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors duration-200"}
22
+ ${z?"border border-border":"border-l border-border"}
23
+ ${Z?"":"w-[30px]"}
24
+ `,style:Z?z?{width:`${lt}px`,height:st?"auto":`${jt}px`,left:`${it.x}px`,top:`${it.y}px`}:{width:`${lt}px`}:void 0,onClick:Z?void 0:Ma,children:Z?h.jsxs(h.Fragment,{children:[!z&&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:Da,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),z&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:g=>{g.preventDefault(),Ft(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:g=>{g.preventDefault(),g.stopPropagation(),Me(!0),yt({x:g.clientX-it.x,y:g.clientY-it.y})},children:h.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:g=>{g.preventDefault(),Ft(!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 ${z?"cursor-move":""}`,onMouseDown:z?Na:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${z&&st?"cursor-pointer":""}`,onClick:z&&st?g=>{g.stopPropagation(),di()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:g=>g.stopPropagation(),children:[h.jsxs(Yt,{children:[h.jsx(Jt,{asChild:!0,children:h.jsx("button",{type:"button",className:tt(te({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Ea,"aria-label":"New chat",children:h.jsx(J.Plus,{className:"h-4 w-4"})})}),h.jsx(Zt,{children:"Start a new conversation"})]}),h.jsxs(Yt,{children:[h.jsx(Jt,{asChild:!0,children:h.jsx("button",{type:"button",className:tt(te({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:z?Ra:Va,"aria-label":z?"Dock sidebar":"Float sidebar",children:z?h.jsx(J.Dock,{className:"h-4 w-4"}):h.jsx(J.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Zt,{children:z?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Yt,{children:[h.jsx(Jt,{asChild:!0,children:h.jsx("button",{type:"button",className:tt(te({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:z?di:ja,"aria-label":z?st?"Maximize":"Minimize":"Close sidebar",children:z?st?h.jsx(J.Maximize2,{className:"h-4 w-4"}):h.jsx(J.Minimize2,{className:"h-4 w-4"}):h.jsx(J.X,{className:"h-4 w-4"})})}),h.jsx(Zt,{children:z?st?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!st&&h.jsxs(h.Fragment,{children:[S&&L.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(gn,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{xt||Vn(),ue(!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:L.slice(0,xt?void 0:3).map(g=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:tt(te({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>Ca(g),children:[h.jsx("span",{className:"text-xs truncate",children:g.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:wa(g.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:w=>{w.stopPropagation(),Sa(g._id)},"aria-label":"Delete conversation",children:h.jsx(J.X,{className:"h-3 w-3"})})]},g._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:De.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&h.jsx("div",{className:"mb-6",children:o}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),C.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:[(j?C:C.slice(0,10)).map(g=>h.jsxs(Yt,{children:[h.jsx(Jt,{asChild:!0,children:h.jsx(Rn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Gt(g.sampleUsage),le.current?.focus()},children:g.friendlyName})}),h.jsx(Zt,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:g.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',g.sampleUsage,'"']}),g.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",g.params.join(", ")]})]})})]},g.name)),C.length>10&&!j&&h.jsxs(Yt,{children:[h.jsx(Jt,{asChild:!0,children:h.jsxs(Rn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>k(!0),children:["+",C.length-10," more"]})}),h.jsx(Zt,{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:C.slice(10).map(g=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[g.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:g.description})]},g.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),j&&C.length>10&&h.jsx(Rn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>k(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[De.map(g=>{const N=g.parts.filter(P=>P.type==="text").map(P=>P.text).join("");return h.jsx("div",{className:`${g.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${g.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:g.role==="user"?h.jsx(Dh,{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:N}):h.jsx("div",{className:"space-y-2",children:g.parts.map((P,O)=>{if(P.type?.startsWith("tool-")){const F=P.type?.replace("tool-","")||"",ut=ri.find(at=>at.name===F),Ct=P.state==="input-available",$t=P.state==="output-available";if(Ct){if(ai.has(F))return(async()=>{if(Ee.has(P.toolCallId))return;ke(Re=>new Set(Re).add(P.toolCallId));const At=oi.get(F);if(At)try{const Re=qn(P.input),Ia=await At(...Object.values(Re));Ve({toolCallId:P.toolCallId,tool:F,output:Ia})}catch(Re){Ve({toolCallId:P.toolCallId,tool:F,output:`Error: ${Re}`})}})(),null;const at=qn(P.input);return h.jsx(ln,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(Nh,{toolName:F,description:ut?.description||"",args:at,onApprove:async()=>{if(Ee.has(P.toolCallId))return;ke(At=>new Set(At).add(P.toolCallId));const Dt=oi.get(F);if(Dt)try{const At=await Dt(...Object.values(at));Ve({toolCallId:P.toolCallId,tool:F,output:At})}catch(At){Ve({toolCallId:P.toolCallId,tool:F,output:`Error: ${At}`})}},onDeny:async()=>{Ee.has(P.toolCallId)||(ke(Dt=>new Set(Dt).add(P.toolCallId)),Ve({toolCallId:P.toolCallId,tool:F,output:"User denied tool execution"}))}})},`${P.toolCallId}-${O}`)}else if($t){const at=P.output==="User denied tool execution",Dt=qn(P.input);return h.jsx(Ih,{toolName:F,args:Dt,isDenied:at,isSafe:ai.has(F)},`${P.toolCallId}-${O}`)}return null}if(P.type==="text"&&P.text&&Ze){const F=Xh(P.text);return h.jsx(Ze,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:F},`${g.id}-${O}`)}return P.type==="reasoning"&&P.text?h.jsxs(xa,{className:"w-full",isStreaming:St==="streaming"&&O===g.parts.length-1&&g.id===De.at(-1)?.id,children:[h.jsx(va,{}),h.jsx(ba,{children:P.text})]},`${g.id}-${O}`):null})})})},g.id)}),h.jsx("div",{ref:Xt})]})}),li&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",li.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Ql,{mode:"wait",children:(St==="streaming"||St==="submitted")&&h.jsxs(ln,{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(ln,{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:En})]})}),h.jsxs("form",{onSubmit:ui,className:"relative",children:[h.jsx(Rr,{ref:le,value:Et,onChange:ka,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),ui(g))}}),St==="streaming"||St==="submitted"?h.jsxs(Yt,{children:[h.jsx(Jt,{asChild:!0,children:h.jsx("button",{type:"button",className:tt(te({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:nn,children:h.jsx(J.Square,{className:"h-4 w-4"})})}),h.jsxs(Zt,{children:[h.jsx(mi,{children:"Escape"})," to stop"]})]}):h.jsxs(Yt,{children:[h.jsx(Jt,{asChild:!0,children:h.jsx("button",{type:"submit",className:tt(te({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!Et.trim(),children:h.jsx(J.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Zt,{children:[h.jsx(mi,{children:"Enter"})," to send"]})]})]})]})]}),h.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[h.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(J.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 ze(t){if(typeof t=="string")try{const e=JSON.parse(t);return ze(e)}catch{return t}if(Array.isArray(t))return t.map(ze);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=ze(s);return e}return t}function qh(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return ze(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?ze(t):{}}function Yh({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:o=[],safeTools:r=[],toolMetadata:a,systemPrompt:c="",initialMessages:u=[],conversationId:l,initialState:d={},sharedStateId:f,onToolCall:p,onFinish:y,ragFilters:v}={}){const[S,x]=m.useState(n||null),b=m.useRef(n||null),[T,D]=m.useState(null),[M,I]=m.useState(null),R=m.useRef(null),[E,_]=m.useState([]),[B,ct]=m.useState(l||(typeof window<"u"?crypto.randomUUID():null)),[It,pt]=m.useState(!1),[oe,Lt]=m.useState(new Set),[Pn,U]=m.useState(d),$=m.useRef(d),[Z,ot]=m.useState(!1),[lt,Ot]=m.useState(null),jt=m.useRef(!1),ae=m.useCallback(async(C,A=3)=>{if(!B||!b.current)return;const j=async()=>{if(f){const k=await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.current}`},body:JSON.stringify({path:"sharedStates:merge",args:{stateId:f,updates:C},format:"json"})});if(!k.ok){const L=await k.text().catch(()=>"Unknown error");throw new Error(`Failed to sync shared state: ${k.status} ${L}`)}}else{const k=await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:B,updates:C},format:"json"})});if(!k.ok){const L=await k.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${k.status} ${L}`)}}};for(let k=0;k<A;k++)try{await j(),Ot(null);return}catch(L){if(k===A-1){const G=L instanceof Error?L:new Error(String(L));throw Ot(G),console.error("Failed to sync state to Convex after retries:",L),G}await new Promise(G=>setTimeout(G,Math.pow(2,k)*100))}},[B,f,t,b]),Ae=m.useMemo(()=>function(){return $.current},[]),Ft=m.useMemo(()=>async function(A){const j={...$.current,...A};$.current=j,U(j);try{await ae(A)}catch(k){throw k}},[ae]),z=m.useMemo(()=>[...o,...r,Ae,Ft],[o,r,Ae,Ft]),gt=m.useMemo(()=>ga(z,a),[z,a]),st=m.useMemo(()=>{const C=new Map,A=new Map(gt.map(j=>[j.name,j]));return z.forEach(j=>{const k=j[Pt];if(k){const K=A.get(k);if(K){C.set(K.name,j);return}}const L=gt.find(K=>K.name===j.name);L&&C.set(L.name,j)}),C},[z,gt]),Kt=m.useMemo(()=>new Set(gt.map(C=>C.name)),[gt]),it=m.useMemo(()=>{const C=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}},{name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}];return[...gt,...C]},[gt]),Ht=m.useMemo(()=>it.filter(C=>C.name==="getState"||C.name==="setState"?!0:Kt.has(C.name)),[it,Kt]),Pe=m.useMemo(()=>{const C=new Set;return C.add("getState"),C.add("setState"),r.forEach(A=>{for(const[j,k]of st.entries())if(k===A){C.add(j);break}}),C},[r,st]);m.useEffect(()=>s||n?void 0:((async()=>{try{const A=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!A.ok)throw new Error("Failed to fetch token");const j=await A.json();x(j.clientToken),b.current=j.clientToken,I(j.expiresAt),D(null)}catch(A){console.error("[useAgent] Token fetch failed:",A),D(A instanceof Error?A.message:"Failed to fetch token")}})(),()=>{R.current&&clearTimeout(R.current)}),[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(!M||s||n)return;R.current&&clearTimeout(R.current);const C=Math.floor(Date.now()/1e3),A=M-C,k=Math.max(0,A-5);return R.current=setTimeout(async()=>{try{const L=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!L.ok)throw new Error("Failed to refresh token");const K=await L.json();x(K.clientToken),b.current=K.clientToken,I(K.expiresAt),D(null)}catch(L){console.error("[useAgent] Token refresh failed:",L),D(L instanceof Error?L.message:"Failed to refresh token")}},k*1e3),()=>{R.current&&clearTimeout(R.current)}},[M,e,JSON.stringify(i),s,n]);const Me=async(C,A={})=>{const j=A.headers?new Headers(A.headers):new Headers;j.delete("user-agent"),j.delete("User-Agent"),console.log("[useAgent] Making request to:",C),console.log("[useAgent] Method:",A.method||"GET"),console.log("[useAgent] Has Authorization header:",j.has("Authorization")),console.log("[useAgent] Client token available:",!!b.current);try{const k=await fetch(C,{...A,headers:j});if(!k.ok){console.error("[useAgent] Request failed:",k.status,k.statusText);const L=await k.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",L)}return k}catch(k){throw console.error("[useAgent] Fetch error:",k),k}},ce=`${t}/chat`;console.log("[useAgent] Chat API URL:",ce);const{messages:yt,sendMessage:Mn,status:je,error:Xt,stop:le,addToolResult:Et,setMessages:Gt}=kr.useChat({id:B||void 0,messages:u,transport:new pn.DefaultChatTransport({api:ce,fetch:Me,headers:()=>{const C={};return b.current?(C.Authorization=`Bearer ${b.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),C},body:()=>{const C=Ht.map(j=>({name:j.name,description:j.description,inputSchema:j.jsonSchema})),A=C.filter(j=>j.name==="getState"||j.name==="setState").map(j=>j.name);return A.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",A),{tools:C,systemPrompt:c,state:$.current,...v&&{ragFilters:v}}}}),sendAutomaticallyWhen:pn.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{yt.forEach(C=>{C.role==="assistant"&&C.parts.forEach(A=>{if(!A.type?.startsWith("tool-")||A.state!=="input-available")return;const j=A.type.replace("tool-",""),k=A.toolCallId;if(oe.has(k))return;Lt(K=>new Set(K).add(k));const L=qh(A.input);if(Pe.has(j)){const K=st.get(j);K?(async()=>{try{const G=Ht.find(xt=>xt.name===j);let kt;if(G&&G.jsonSchema?.properties){const ue=Object.keys(G.jsonSchema.properties).map(si=>L[si]);kt=await K(...ue)}else if(j==="getState")kt=K();else if(j==="setState"){const xt=L.updates||L;kt=await K(xt)}else kt=await K(...Object.values(L));Et({toolCallId:k,tool:j,output:kt})}catch(G){console.error(`[useAgent] Error executing tool ${j}:`,G),Et({toolCallId:k,tool:j,output:`Error: ${G}`})}})():console.warn(`[useAgent] Tool ${j} not found in toolsMap`)}else p&&p({toolCall:{toolCallId:k,toolName:j,args:L}})})})},[yt,Pe,st,p,Et,oe,Ft,Ht]),m.useEffect(()=>{if(je==="ready"&&yt.length>0&&y){const C=yt[yt.length-1];C&&C.role==="assistant"&&y({message:C,messages:yt,isAbort:!1,isDisconnect:!1,isError:!!Xt})}},[je,yt,Xt,y]);async function Ze(){if(!(!i?.id||!S)){pt(!0);try{const A=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${S}`}})).json();_(A.conversations||[])}catch(C){console.error("Failed to fetch conversations:",C)}finally{pt(!1)}}}m.useEffect(()=>{i?.id&&S&&Ze()},[JSON.stringify(i),S,t]),m.useEffect(()=>{if(!B||!b.current)return;(async()=>{ot(!0),Ot(null);try{let A={};if(f){const L=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:f},format:"json"})});if(!L.ok){const G=await L.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch shared state: ${L.status} ${G}`)}A=(await L.json())?.value||{}}else{const L=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:B},format:"json"})});if(!L.ok){const G=await L.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${L.status} ${G}`)}A=(await L.json())?.value||{}}const j=!jt.current;let k;j?(k={...d,...A},jt.current=!0):k=A,$.current=k,U(k)}catch(A){console.error("Failed to fetch state:",A);const j=A instanceof Error?A:new Error(String(A));Ot(j),jt.current||($.current=d,U(d),jt.current=!0)}finally{ot(!1)}})()},[B,f,t]);async function jn(C){ct(C),pt(!0);try{const A=await fetch(`${t}/conversations/${C}/messages`,{headers:{Authorization:`Bearer ${b.current}`}});if(!A.ok)throw new Error(`Failed to fetch messages: ${A.statusText}`);const k=(await A.json()).messages||[];Gt(k)}catch(A){console.error("Failed to load conversation messages:",A)}finally{pt(!1)}}async function En(C){if(S)try{await fetch(`${t}/conversations/${C}`,{method:"DELETE",headers:{Authorization:`Bearer ${S}`}}),_(E.filter(A=>A._id!==C)),C===B&&Qe()}catch(A){console.error("Failed to delete conversation:",A)}}function Qe(){const C=crypto.randomUUID();ct(C),Gt([]),Lt(new Set),f||($.current=d,U(d),jt.current=!1)}function Ee(C){Et(C)}async function ke(C){const A={...$.current,...C};$.current=A,U(A);try{await ae(C)}catch(j){throw j}}async function kn(){if(!i?.id||!b.current)throw new Error("User authentication required to share state");const C=`shared_${crypto.randomUUID()}`;try{return await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.current}`},body:JSON.stringify({path:"sharedStates:create",args:{stateId:C,state:$.current,projectId:"default",createdBy:i.id},format:"json"})}),C}catch(A){throw console.error("Failed to share state:",A),A}}async function Dn(C){if(!b.current)throw new Error("Authentication required to import state");try{const A=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:C},format:"json"})});if(!A.ok)throw new Error("Failed to fetch shared state");const k=(await A.json())?.value||{};$.current=k,U(k)}catch(A){throw console.error("Failed to import state:",A),A}}return{id:B,messages:yt,status:je,error:Xt,sendMessage:Mn,stop:le,addToolOutput:Ee,setMessages:Gt,conversations:E,loadConversation:jn,deleteConversation:En,startNewConversation:Qe,isLoadingConversations:It,clientToken:S,tokenError:T,state:Pn,setState:ke,shareState:kn,importState:Dn,isStateLoading:Z,stateError:lt}}exports.verifyToken=Xa.verifyToken;exports.ARCTEN_ORIGINAL_NAME=Pt;exports.ArctenAgent=Gh;exports.preserveToolName=Vh;exports.useAgent=Yh;