@arcteninc/core 0.0.69 → 0.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ArctenAgent.d.ts +4 -3
- package/dist/components/ArctenAgent.d.ts.map +1 -1
- package/dist/components/ai-elements/reasoning.d.ts.map +1 -1
- package/dist/components/ai-elements/shimmer.d.ts.map +1 -1
- package/dist/index.cjs +10 -10
- package/dist/index.mjs +2544 -2514
- package/dist/lib/useAgent.d.ts +1 -1
- package/dist/lib/useAgent.d.ts.map +1 -1
- package/dist/types/use-agent.d.ts +0 -1
- package/dist/types/use-agent.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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(`
|
|
1
|
+
"use strict";var _a=Object.create;var xi=Object.defineProperty;var Wa=Object.getOwnPropertyDescriptor;var Ka=Object.getOwnPropertyNames;var Ha=Object.getPrototypeOf,Ga=Object.prototype.hasOwnProperty;var Xa=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ka(e))!Ga.call(t,i)&&i!==n&&xi(t,i,{get:()=>e[i],enumerable:!(s=Wa(e,i))||s.enumerable});return t};var qa=(t,e,n)=>(n=t!=null?_a(Ha(t)):{},Xa(e||!t||!t.__esModule?xi(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),Y=require("lucide-react"),Lr=require("@ai-sdk/react"),bn=require("ai"),Or=require("@radix-ui/react-slot"),Fr=require("class-variance-authority"),Ya=require("clsx"),Ja=require("tailwind-merge"),Za=require("@radix-ui/react-tooltip"),vi=require("@radix-ui/react-use-controllable-state"),Qa=require("@radix-ui/react-collapsible"),tc=require("./server.cjs");function As(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Tt=As(m),Ae=As(Za),Cs=As(Qa);function Q(...t){return Ja.twMerge(Ya.clsx(t))}const se=Fr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),wn=Tt.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},o)=>{const r=s?Or.Slot:"button";return h.jsx(r,{ref:o,"data-slot":"button",className:Q(se({variant:e,size:n,className:t})),...i})});wn.displayName="Button";const ec=Fr.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function Fn({className:t,variant:e,asChild:n=!1,...s}){const i=n?Or.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:Q(ec({variant:e}),t),...s})}const nc=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,o]=Tt.useState(!0);Tt.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])},Br=Tt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...o},r)=>{const a=Tt.useRef(null),[c,u]=Tt.useState("");return nc({textAreaRef:a,triggerAutoSize:c,maxHeight:t,minHeight:e}),m.useImperativeHandle(r,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),Tt.useEffect(()=>{u(i)},[o?.defaultValue,i]),h.jsx("textarea",{...o,value:i,ref:a,className:Q("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)}})});Br.displayName="AutosizeTextarea";function sc({delayDuration:t=0,...e}){return h.jsx(Ae.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Qt({...t}){return h.jsx(sc,{children:h.jsx(Ae.Root,{"data-slot":"tooltip",...t})})}function te({...t}){return h.jsx(Ae.Trigger,{"data-slot":"tooltip-trigger",...t})}function ee({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(Ae.Portal,{children:h.jsxs(Ae.Content,{"data-slot":"tooltip-content",sideOffset:e,className:Q("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(Ae.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function bi({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:Q("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 Ps=m.createContext({});function Ms(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const js=typeof window<"u",$r=js?m.useLayoutEffect:m.useEffect,Mn=m.createContext(null);function Es(t,e){t.indexOf(e)===-1&&t.push(e)}function ks(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Nt=(t,e,n)=>n>e?e:n<t?t:n;function es(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let je=()=>{},It=()=>{};process.env.NODE_ENV!=="production"&&(je=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(es(e,n))},It=(t,e,n)=>{if(!t)throw new Error(es(e,n))});const Lt={},zr=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Ur(t){return typeof t=="object"&&t!==null}const _r=t=>/^0[^.\s]+$/u.test(t);function Ds(t){let e;return()=>(e===void 0&&(e=t()),e)}const vt=t=>t,ic=(t,e)=>n=>e(t(n)),Qe=(...t)=>t.reduce(ic),Ge=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Vs{constructor(){this.subscriptions=[]}add(e){return Es(this.subscriptions,e),()=>ks(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const St=t=>t*1e3,xt=t=>t/1e3;function Wr(t,e){return e?t*(1e3/e):0}const wi=new Set;function Rs(t,e,n){t||wi.has(e)||(console.warn(es(e,n)),wi.add(e))}const Kr=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,rc=1e-7,oc=12;function ac(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=Kr(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>rc&&++a<oc);return r}function tn(t,e,n,s){if(t===e&&n===s)return vt;const i=o=>ac(o,0,1,t,n);return o=>o===0||o===1?o:Kr(i(o),e,s)}const Hr=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Gr=t=>e=>1-t(1-e),Xr=tn(.33,1.53,.69,.99),Ns=Gr(Xr),qr=Hr(Ns),Yr=t=>(t*=2)<1?.5*Ns(t):.5*(2-Math.pow(2,-10*(t-1))),Is=t=>1-Math.sin(Math.acos(t)),Jr=Gr(Is),Zr=Hr(Is),cc=tn(.42,0,1,1),lc=tn(0,0,.58,1),Qr=tn(.42,0,.58,1),uc=t=>Array.isArray(t)&&typeof t[0]!="number",to=t=>Array.isArray(t)&&typeof t[0]=="number",Ti={linear:vt,easeIn:cc,easeInOut:Qr,easeOut:lc,circIn:Is,circInOut:Zr,circOut:Jr,backIn:Ns,backInOut:qr,backOut:Xr,anticipate:Yr},dc=t=>typeof t=="string",Si=t=>{if(to(t)){It(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return tn(e,n,s,i)}else if(dc(t))return It(Ti[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Ti[t];return t},un=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function hc(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(l){r.has(l)&&(u.schedule(l),t()),l(a)}const u={schedule:(l,d=!1,f=!1)=>{const x=f&&i?n:s;return d&&r.add(l),x.has(l)||x.add(l),l},cancel:l=>{s.delete(l),r.delete(l)},process:l=>{if(a=l,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(c),n.clear(),i=!1,o&&(o=!1,u.process(l))}};return u}const fc=40;function eo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=un.reduce((S,E)=>(S[E]=hc(o),S),{}),{setup:a,read:c,resolveKeyframes:u,preUpdate:l,update:d,preRender:f,render:g,postRender:x}=r,v=()=>{const S=Lt.useManualTiming?i.timestamp:performance.now();n=!1,Lt.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(S-i.timestamp,fc),1)),i.timestamp=S,i.isProcessing=!0,a.process(i),c.process(i),u.process(i),l.process(i),d.process(i),f.process(i),g.process(i),x.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},C=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:un.reduce((S,E)=>{const M=r[E];return S[E]=(j,L=!1,V=!1)=>(n||C(),M.schedule(j,L,V)),S},{}),cancel:S=>{for(let E=0;E<un.length;E++)r[un[E]].cancel(S)},state:i,steps:r}}const{schedule:W,cancel:Wt,state:Z,steps:Bn}=eo(typeof requestAnimationFrame<"u"?requestAnimationFrame:vt,!0);let pn;function mc(){pn=void 0}const ut={now:()=>(pn===void 0&&ut.set(Z.isProcessing||Lt.useManualTiming?Z.timestamp:performance.now()),pn),set:t=>{pn=t,queueMicrotask(mc)}},no=t=>e=>typeof e=="string"&&e.startsWith(t),Ls=no("--"),pc=no("var(--"),Os=t=>pc(t)?gc.test(t.split("/*")[0].trim()):!1,gc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Ee={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Xe={...Ee,transform:t=>Nt(0,1,t)},dn={...Ee,default:1},ze=t=>Math.round(t*1e5)/1e5,Fs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function yc(t){return t==null}const xc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Bs=(t,e)=>n=>!!(typeof n=="string"&&xc.test(n)&&n.startsWith(t)||e&&!yc(n)&&Object.prototype.hasOwnProperty.call(n,e)),so=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(Fs);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},vc=t=>Nt(0,255,t),$n={...Ee,transform:t=>Math.round(vc(t))},re={test:Bs("rgb","red"),parse:so("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+$n.transform(t)+", "+$n.transform(e)+", "+$n.transform(n)+", "+ze(Xe.transform(s))+")"};function bc(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const ns={test:Bs("#"),parse:bc,transform:re.transform},en=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),_t=en("deg"),Et=en("%"),R=en("px"),wc=en("vh"),Tc=en("vw"),Ai={...Et,parse:t=>Et.parse(t)/100,transform:t=>Et.transform(t*100)},xe={test:Bs("hsl","hue"),parse:so("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+Et.transform(ze(e))+", "+Et.transform(ze(n))+", "+ze(Xe.transform(s))+")"},q={test:t=>re.test(t)||ns.test(t)||xe.test(t),parse:t=>re.test(t)?re.parse(t):xe.test(t)?xe.parse(t):ns.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?re.transform(t):xe.transform(t),getAnimatableNone:t=>{const e=q.parse(t);return e.alpha=0,q.transform(e)}},Sc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Ac(t){return isNaN(t)&&typeof t=="string"&&(t.match(Fs)?.length||0)+(t.match(Sc)?.length||0)>0}const io="number",ro="color",Cc="var",Pc="var(",Ci="${}",Mc=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function qe(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const a=e.replace(Mc,c=>(q.test(c)?(s.color.push(o),i.push(ro),n.push(q.parse(c))):c.startsWith(Pc)?(s.var.push(o),i.push(Cc),n.push(c)):(s.number.push(o),i.push(io),n.push(parseFloat(c))),++o,Ci)).split(Ci);return{values:n,split:a,indexes:s,types:i}}function oo(t){return qe(t).values}function ao(t){const{split:e,types:n}=qe(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===io?o+=ze(i[r]):a===ro?o+=q.transform(i[r]):o+=i[r]}return o}}const jc=t=>typeof t=="number"?0:q.test(t)?q.getAnimatableNone(t):t;function Ec(t){const e=oo(t);return ao(t)(e.map(jc))}const Kt={test:Ac,parse:oo,createTransformer:ao,getAnimatableNone:Ec};function zn(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function kc({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=zn(c,a,t+1/3),o=zn(c,a,t),r=zn(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function Tn(t,e){return n=>n>0?e:t}const H=(t,e,n)=>t+(e-t)*n,Un=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},Dc=[ns,re,xe],Vc=t=>Dc.find(e=>e.test(t));function Pi(t){const e=Vc(t);if(je(!!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===xe&&(n=kc(n)),n}const Mi=(t,e)=>{const n=Pi(t),s=Pi(e);if(!n||!s)return Tn(t,e);const i={...n};return o=>(i.red=Un(n.red,s.red,o),i.green=Un(n.green,s.green,o),i.blue=Un(n.blue,s.blue,o),i.alpha=H(n.alpha,s.alpha,o),re.transform(i))},ss=new Set(["none","hidden"]);function Rc(t,e){return ss.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Nc(t,e){return n=>H(t,e,n)}function $s(t){return typeof t=="number"?Nc:typeof t=="string"?Os(t)?Tn:q.test(t)?Mi:Oc:Array.isArray(t)?co:typeof t=="object"?q.test(t)?Mi:Ic:Tn}function co(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>$s(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function Ic(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=$s(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function Lc(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 Oc=(t,e)=>{const n=Kt.createTransformer(e),s=qe(t),i=qe(e);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?ss.has(t)&&!i.values.length||ss.has(e)&&!s.values.length?Rc(t,e):Qe(co(Lc(s,i),i.values),n):(je(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Tn(t,e))};function lo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?H(t,e,n):$s(t)(t,e)}const Fc=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>W.update(e,n),stop:()=>Wt(e),now:()=>Z.isProcessing?Z.timestamp:ut.now()}},uo=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Sn=2e4;function zs(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Sn;)e+=n,s=t.next(e);return e>=Sn?1/0:e}function Bc(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(zs(s),Sn);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:xt(i)}}const $c=5;function ho(t,e,n){const s=Math.max(e-$c,0);return Wr(n-t(s),e-s)}const K={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},_n=.001;function zc({duration:t=K.duration,bounce:e=K.bounce,velocity:n=K.velocity,mass:s=K.mass}){let i,o;je(t<=St(K.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=Nt(K.minDamping,K.maxDamping,r),t=Nt(K.minDuration,K.maxDuration,xt(t)),r<1?(i=u=>{const l=u*r,d=l*t,f=l-n,g=is(u,r),x=Math.exp(-d);return _n-f/g*x},o=u=>{const d=u*r*t,f=d*n+n,g=Math.pow(r,2)*Math.pow(u,2)*t,x=Math.exp(-d),v=is(Math.pow(u,2),r);return(-i(u)+_n>0?-1:1)*((f-g)*x)/v}):(i=u=>{const l=Math.exp(-u*t),d=(u-n)*t+1;return-_n+l*d},o=u=>{const l=Math.exp(-u*t),d=(n-u)*(t*t);return l*d});const a=5/t,c=_c(i,o,a);if(t=St(t),isNaN(c))return{stiffness:K.stiffness,damping:K.damping,duration:t};{const u=Math.pow(c,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const Uc=12;function _c(t,e,n){let s=n;for(let i=1;i<Uc;i++)s=s-t(s)/e(s);return s}function is(t,e){return t*Math.sqrt(1-e*e)}const Wc=["duration","bounce"],Kc=["stiffness","damping","mass"];function ji(t,e){return e.some(n=>t[n]!==void 0)}function Hc(t){let e={velocity:K.velocity,stiffness:K.stiffness,damping:K.damping,mass:K.mass,isResolvedFromDuration:!1,...t};if(!ji(t,Kc)&&ji(t,Wc))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*Nt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:K.mass,stiffness:i,damping:o}}else{const n=zc(t);e={...e,...n,mass:K.mass},e.isResolvedFromDuration=!0}return e}function An(t=K.visualDuration,e=K.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:c,damping:u,mass:l,duration:d,velocity:f,isResolvedFromDuration:g}=Hc({...n,velocity:-xt(n.velocity||0)}),x=f||0,v=u/(2*Math.sqrt(c*l)),C=r-o,y=xt(Math.sqrt(c/l)),w=Math.abs(C)<5;s||(s=w?K.restSpeed.granular:K.restSpeed.default),i||(i=w?K.restDelta.granular:K.restDelta.default);let S;if(v<1){const M=is(y,v);S=j=>{const L=Math.exp(-v*y*j);return r-L*((x+v*y*C)/M*Math.sin(M*j)+C*Math.cos(M*j))}}else if(v===1)S=M=>r-Math.exp(-y*M)*(C+(x+y*C)*M);else{const M=y*Math.sqrt(v*v-1);S=j=>{const L=Math.exp(-v*y*j),V=Math.min(M*j,300);return r-L*((x+v*y*C)*Math.sinh(V)+M*C*Math.cosh(V))/M}}const E={calculatedDuration:g&&d||null,next:M=>{const j=S(M);if(g)a.done=M>=d;else{let L=M===0?x:0;v<1&&(L=M===0?St(x):ho(S,M,j));const V=Math.abs(L)<=s,F=Math.abs(r-j)<=i;a.done=V&&F}return a.value=a.done?r:j,a},toString:()=>{const M=Math.min(zs(E),Sn),j=uo(L=>E.next(M*L).value,M,30);return M+"ms "+j},toTransition:()=>{}};return E}An.applyToOptions=t=>{const e=Bc(t,100,An);return t.ease=e.ease,t.duration=St(e.duration),t.type="keyframes",t};function rs({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:c,restDelta:u=.5,restSpeed:l}){const d=t[0],f={done:!1,value:d},g=V=>a!==void 0&&V<a||c!==void 0&&V>c,x=V=>a===void 0?c:c===void 0||Math.abs(a-V)<Math.abs(c-V)?a:c;let v=n*e;const C=d+v,y=r===void 0?C:r(C);y!==C&&(v=y-d);const w=V=>-v*Math.exp(-V/s),S=V=>y+w(V),E=V=>{const F=w(V),G=S(V);f.done=Math.abs(F)<=u,f.value=f.done?y:G};let M,j;const L=V=>{g(f.value)&&(M=V,j=An({keyframes:[f.value,x(f.value)],velocity:ho(S,V,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:l}))};return L(0),{calculatedDuration:null,next:V=>{let F=!1;return!j&&M===void 0&&(F=!0,E(V),L(V)),M!==void 0&&V>=M?j.next(V-M):(!F&&E(V),f)}}}function Gc(t,e,n){const s=[],i=n||Lt.mix||lo,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]||vt:e;a=Qe(c,a)}s.push(a)}return s}function Xc(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(It(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=Gc(e,s,i),c=a.length,u=l=>{if(r&&l<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(l<t[d+1]);d++);const f=Ge(t[d],t[d+1],l);return a[d](f)};return n?l=>u(Nt(t[0],t[o-1],l)):u}function qc(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ge(0,e,s);t.push(H(n,1,i))}}function Yc(t){const e=[0];return qc(e,t.length-1),e}function Jc(t,e){return t.map(n=>n*e)}function Zc(t,e){return t.map(()=>e||Qr).splice(0,t.length-1)}function ve({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=uc(s)?s.map(Si):Si(s),o={done:!1,value:e[0]},r=Jc(n&&n.length===e.length?n:Yc(e),t),a=Xc(r,e,{ease:Array.isArray(i)?i:Zc(e,i)});return{calculatedDuration:t,next:c=>(o.value=a(c),o.done=c>=t,o)}}const Qc=t=>t!==null;function Us(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(Qc),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const tl={decay:rs,inertia:rs,tween:ve,keyframes:ve,spring:An};function fo(t){typeof t.type=="string"&&(t.type=tl[t.type])}class _s{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const el=t=>t/100;class Ws extends _s{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==ut.now()&&this.tick(ut.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;fo(e);const{type:n=ve,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const c=n||ve;process.env.NODE_ENV!=="production"&&c!==ve&&It(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==ve&&typeof a[0]!="number"&&(this.mixKeyframes=Qe(el,lo(a[0],a[1])),a=[0,100]);const u=c({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=zs(u));const{calculatedDuration:l}=u;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:l,repeat:d,repeatType:f,repeatDelay:g,type:x,onUpdate:v,finalKeyframe:C}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const y=this.currentTime-u*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?y<0:y>i;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let S=this.currentTime,E=s;if(d){const V=Math.min(this.currentTime,i)/a;let F=Math.floor(V),G=V%1;!G&&V>=1&&(G=1),G===1&&F--,F=Math.min(F,d+1),!!(F%2)&&(f==="reverse"?(G=1-G,g&&(G-=g/a)):f==="mirror"&&(E=r)),S=Nt(0,1,G)*a}const M=w?{done:!1,value:l[0]}:E.next(S);o&&(M.value=o(M.value));let{done:j}=M;!w&&c!==null&&(j=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const L=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&j);return L&&x!==rs&&(M.value=Us(l,this.options,C,this.speed)),v&&v(M.value),L&&this.finish(),M}then(e,n){return this.finished.then(e,n)}get duration(){return xt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+xt(e)}get time(){return xt(this.currentTime)}set time(e){e=St(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(ut.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=xt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Fc,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(ut.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function nl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const oe=t=>t*180/Math.PI,os=t=>{const e=oe(Math.atan2(t[1],t[0]));return as(e)},sl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:os,rotateZ:os,skewX:t=>oe(Math.atan(t[1])),skewY:t=>oe(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},as=t=>(t=t%360,t<0&&(t+=360),t),Ei=os,ki=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Di=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),il={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ki,scaleY:Di,scale:t=>(ki(t)+Di(t))/2,rotateX:t=>as(oe(Math.atan2(t[6],t[5]))),rotateY:t=>as(oe(Math.atan2(-t[2],t[0]))),rotateZ:Ei,rotate:Ei,skewX:t=>oe(Math.atan(t[4])),skewY:t=>oe(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function cs(t){return t.includes("scale")?1:0}function ls(t,e){if(!t||t==="none")return cs(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=il,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=sl,i=a}if(!i)return cs(e);const o=s[e],r=i[1].split(",").map(ol);return typeof o=="function"?o(r):r[o]}const rl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return ls(n,e)};function ol(t){return parseFloat(t.trim())}const ke=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],De=new Set(ke),Vi=t=>t===Ee||t===R,al=new Set(["x","y","z"]),cl=ke.filter(t=>!al.has(t));function ll(t){const e=[];return cl.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const ae={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>ls(e,"x"),y:(t,{transform:e})=>ls(e,"y")};ae.translateX=ae.x;ae.translateY=ae.y;const ce=new Set;let us=!1,ds=!1,hs=!1;function mo(){if(ds){const t=Array.from(ce).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=ll(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}ds=!1,us=!1,ce.forEach(t=>t.complete(hs)),ce.clear()}function po(){ce.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ds=!0)})}function ul(){hs=!0,po(),mo(),hs=!1}class Ks{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(ce.add(this),us||(us=!0,W.read(po),W.resolveKeyframes(mo))):(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])}nl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ce.delete(this)}cancel(){this.state==="scheduled"&&(ce.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const dl=t=>t.startsWith("--");function hl(t,e,n){dl(e)?t.style.setProperty(e,n):t.style[e]=n}const fl=Ds(()=>window.ScrollTimeline!==void 0),ml={};function pl(t,e){const n=Ds(t);return()=>ml[e]??n()}const go=pl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),$e=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,Ri={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:$e([0,.65,.55,1]),circOut:$e([.55,0,1,.45]),backIn:$e([.31,.01,.66,-.59]),backOut:$e([.33,1.53,.69,.99])};function yo(t,e){if(t)return typeof t=="function"?go()?uo(t,e):"ease-out":to(t)?$e(t):Array.isArray(t)?t.map(n=>yo(n,e)||Ri.easeOut):Ri[t]}function gl(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=yo(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 xo(t){return typeof t=="function"&&"applyToOptions"in t}function yl({type:t,...e}){return xo(t)&&go()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class xl extends _s{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,It(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=yl(e);this.animation=gl(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const l=Us(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(l):hl(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 xt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+xt(e)}get time(){return xt(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=St(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&&fl()?(this.animation.timeline=e,vt):n(this)}}const vo={anticipate:Yr,backInOut:qr,circInOut:Zr};function vl(t){return t in vo}function bl(t){typeof t.ease=="string"&&vl(t.ease)&&(t.ease=vo[t.ease])}const Ni=10;class wl extends xl{constructor(e){bl(e),fo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Ws({...r,autoplay:!1}),c=St(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-Ni).value,a.sample(c).value,Ni),a.stop()}}const Ii=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Kt.test(t)||t==="0")&&!t.startsWith("url("));function Tl(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 Sl(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=Ii(i,e),a=Ii(o,e);return je(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:Tl(t)||(n==="spring"||xo(n))&&s}function fs(t){t.duration=0,t.type="keyframes"}const Al=new Set(["opacity","clipPath","filter","transform"]),Cl=Ds(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Pl(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 Cl()&&n&&Al.has(n)&&(n!=="transform"||!u)&&!c&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const Ml=40;class jl extends _s{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:c,motionValue:u,element:l,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=ut.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:c,motionValue:u,element:l,...d},g=l?.KeyframeResolver||Ks;this.keyframeResolver=new g(a,(x,v,C)=>this.onKeyframesResolved(x,v,f,!C),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=ut.now(),Sl(e,o,r,a)||((Lt.instantAnimations||!c)&&l?.(Us(e,s,n)),e[0]=e[e.length-1],fs(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>Ml?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&Pl(f)?new wl({...f,element:f.motionValue.owner.current}):new Ws(f);g.finished.then(()=>this.notifyFinished()).catch(vt),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(),ul()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const El=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function kl(t){const e=El.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const Dl=4;function bo(t,e,n=1){It(n<=Dl,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=kl(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return zr(r)?parseFloat(r):r}return Os(i)?bo(i,e,n+1):i}function Hs(t,e){return t?.[e]??t?.default??t}const wo=new Set(["width","height","top","left","right","bottom",...ke]),Vl={test:t=>t==="auto",parse:t=>t},To=t=>e=>e.test(t),So=[Ee,R,Et,_t,Tc,wc,Vl],Li=t=>So.find(To(t));function Rl(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||_r(t):!0}const Nl=new Set(["brightness","contrast","saturate","opacity"]);function Il(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(Fs)||[];if(!s)return t;const i=n.replace(s,"");let o=Nl.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const Ll=/\b([a-z-]*)\(.*?\)/gu,ms={...Kt,getAnimatableNone:t=>{const e=t.match(Ll);return e?e.map(Il).join(" "):t}},Oi={...Ee,transform:Math.round},Ol={rotate:_t,rotateX:_t,rotateY:_t,rotateZ:_t,scale:dn,scaleX:dn,scaleY:dn,scaleZ:dn,skew:_t,skewX:_t,skewY:_t,distance:R,translateX:R,translateY:R,translateZ:R,x:R,y:R,z:R,perspective:R,transformPerspective:R,opacity:Xe,originX:Ai,originY:Ai,originZ:R},Gs={borderWidth:R,borderTopWidth:R,borderRightWidth:R,borderBottomWidth:R,borderLeftWidth:R,borderRadius:R,radius:R,borderTopLeftRadius:R,borderTopRightRadius:R,borderBottomRightRadius:R,borderBottomLeftRadius:R,width:R,maxWidth:R,height:R,maxHeight:R,top:R,right:R,bottom:R,left:R,padding:R,paddingTop:R,paddingRight:R,paddingBottom:R,paddingLeft:R,margin:R,marginTop:R,marginRight:R,marginBottom:R,marginLeft:R,backgroundPositionX:R,backgroundPositionY:R,...Ol,zIndex:Oi,fillOpacity:Xe,strokeOpacity:Xe,numOctaves:Oi},Fl={...Gs,color:q,backgroundColor:q,outlineColor:q,fill:q,stroke:q,borderColor:q,borderTopColor:q,borderRightColor:q,borderBottomColor:q,borderLeftColor:q,filter:ms,WebkitFilter:ms},Ao=t=>Fl[t];function Co(t,e){let n=Ao(t);return n!==ms&&(n=Kt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Bl=new Set(["auto","none","0"]);function $l(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!Bl.has(o)&&qe(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=Co(n,i)}class zl extends Ks{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let u=e[c];if(typeof u=="string"&&(u=u.trim(),Os(u))){const l=bo(u,n.current);l!==void 0&&(e[c]=l),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!wo.has(s)||e.length!==2)return;const[i,o]=e,r=Li(i),a=Li(o);if(r!==a)if(Vi(r)&&Vi(a))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else ae[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||Rl(e[i]))&&s.push(i);s.length&&$l(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=ae[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]=ae[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 Ul(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const Po=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Mo(t){return Ur(t)&&"offsetHeight"in t}const Fi=30,_l=t=>!isNaN(parseFloat(t));class Wl{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=ut.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=ut.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=_l(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Rs(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Vs);const s=this.events[e].add(n);return e==="change"?()=>{s(),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=ut.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Fi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Fi);return Wr(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 Pe(t,e){return new Wl(t,e)}const{schedule:Xs}=eo(queueMicrotask,!1),wt={x:!1,y:!1};function jo(){return wt.x||wt.y}function Kl(t){return t==="x"||t==="y"?wt[t]?null:(wt[t]=!0,()=>{wt[t]=!1}):wt.x||wt.y?null:(wt.x=wt.y=!0,()=>{wt.x=wt.y=!1})}function Eo(t,e){const n=Ul(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Bi(t){return!(t.pointerType==="touch"||jo())}function Hl(t,e,n={}){const[s,i,o]=Eo(t,n),r=a=>{if(!Bi(a))return;const{target:c}=a,u=e(c,a);if(typeof u!="function"||!c)return;const l=d=>{Bi(d)&&(u(d),c.removeEventListener("pointerleave",l))};c.addEventListener("pointerleave",l,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const ko=(t,e)=>e?t===e?!0:ko(t,e.parentElement):!1,qs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Gl=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Xl(t){return Gl.has(t.tagName)||t.tabIndex!==-1}const gn=new WeakSet;function $i(t){return e=>{e.key==="Enter"&&t(e)}}function Wn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const ql=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=$i(()=>{if(gn.has(n))return;Wn(n,"down");const i=$i(()=>{Wn(n,"up")}),o=()=>Wn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function zi(t){return qs(t)&&!jo()}function Yl(t,e,n={}){const[s,i,o]=Eo(t,n),r=a=>{const c=a.currentTarget;if(!zi(a))return;gn.add(c);const u=e(c,a),l=(g,x)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),gn.has(c)&&gn.delete(c),zi(g)&&typeof u=="function"&&u(g,{success:x})},d=g=>{l(g,c===window||c===document||n.useGlobalTarget||ko(c,g.target))},f=g=>{l(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),Mo(a)&&(a.addEventListener("focus",u=>ql(u,i)),!Xl(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Do(t){return Ur(t)&&"ownerSVGElement"in t}function Jl(t){return Do(t)&&t.tagName==="svg"}const nt=t=>!!(t&&t.getVelocity),Zl=[...So,q,Kt],Ql=t=>Zl.find(To(t)),Ys=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Ui(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function tu(...t){return e=>{let n=!1;const s=t.map(i=>{const o=Ui(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():Ui(t[i],null)}}}}function eu(...t){return Tt.useCallback(tu(...t),t)}class nu extends Tt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=Mo(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 su({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),o=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Ys),c=eu(o,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:l,top:d,left:f,right:g}=r.current;if(e||!o.current||!u||!l)return;const x=n==="left"?`left: ${f}`:`right: ${g}`;o.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const C=s??document.head;return C.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
5
|
height: ${l}px !important;
|
|
6
|
-
${
|
|
6
|
+
${x}px !important;
|
|
7
7
|
top: ${d}px !important;
|
|
8
8
|
}
|
|
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!
|
|
9
|
+
`),()=>{C.contains(v)&&C.removeChild(v)}},[e]),h.jsx(nu,{isPresent:e,childRef:o,sizeRef:r,children:Tt.cloneElement(t,{ref:c})})}const iu=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:a,root:c})=>{const u=Ms(ru),l=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:l,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const x of u.values())if(!x)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return o&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,x)=>u.set(x,!1))},[n]),Tt.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),r==="popLayout"&&(t=h.jsx(su,{isPresent:n,anchorX:a,root:c,children:t})),h.jsx(Mn.Provider,{value:f,children:t})};function ru(){return new Map}function Vo(t=!0){const e=m.useContext(Mn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=m.useId();m.useEffect(()=>{if(t)return i(o)},[t]);const r=m.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const hn=t=>t.key||"";function _i(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const ou=({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]=Vo(r),d=m.useMemo(()=>_i(t),[t]),f=r&&!u?[]:d.map(hn),g=m.useRef(!0),x=m.useRef(d),v=Ms(()=>new Map),[C,y]=m.useState(d),[w,S]=m.useState(d);$r(()=>{g.current=!1,x.current=d;for(let j=0;j<w.length;j++){const L=hn(w[j]);f.includes(L)?v.delete(L):v.get(L)!==!0&&v.set(L,!1)}},[w,f.length,f.join("-")]);const E=[];if(d!==C){let j=[...d];for(let L=0;L<w.length;L++){const V=w[L],F=hn(V);f.includes(F)||(j.splice(L,0,V),E.push(V))}return o==="wait"&&E.length&&(j=E),S(_i(j)),y(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&w.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:M}=m.useContext(Ps);return h.jsx(h.Fragment,{children:w.map(j=>{const L=hn(j),V=r&&!u?!1:d===w||f.includes(L),F=()=>{if(v.has(L))v.set(L,!0);else return;let G=!0;v.forEach(J=>{J||(G=!1)}),G&&(M?.(),S(x.current),r&&l?.(),s&&s())};return h.jsx(iu,{isPresent:V,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:o,root:c,onExitComplete:V?void 0:F,anchorX:a,children:j},L)})})},Js=m.createContext({strict:!1}),Wi={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"]},Me={};for(const t in Wi)Me[t]={isEnabled:e=>Wi[t].some(n=>!!e[n])};function ps(t){for(const e in t)Me[e]={...Me[e],...t[e]}}function au({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!Kn(e)),i=m.useRef(void 0);if(!Kn(e)){const{renderer:o,...r}=e;i.current=o,ps(r)}return m.useEffect(()=>{Kn(e)&&e().then(({renderer:o,...r})=>{ps(r),i.current=o,s(!0)})},[]),h.jsx(Js.Provider,{value:{renderer:i.current,strict:n},children:t})}function Kn(t){return typeof t=="function"}const cu=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 Cn(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||cu.has(t)}let Ro=t=>!Cn(t);function lu(t){typeof t=="function"&&(Ro=e=>e.startsWith("on")?!Cn(e):t(e))}try{lu(require("@emotion/is-prop-valid").default)}catch{}function uu(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(Ro(i)||n===!0&&Cn(i)||!e&&!Cn(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const jn=m.createContext({});function En(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Ye(t){return typeof t=="string"||Array.isArray(t)}const Zs=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Qs=["initial",...Zs];function kn(t){return En(t.animate)||Qs.some(e=>Ye(t[e]))}function No(t){return!!(kn(t)||t.variants)}function du(t,e){if(kn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Ye(n)?n:void 0,animate:Ye(s)?s:void 0}}return t.inherit!==!1?e:{}}function hu(t){const{initial:e,animate:n}=du(t,m.useContext(jn));return m.useMemo(()=>({initial:e,animate:n}),[Ki(e),Ki(n)])}function Ki(t){return Array.isArray(t)?t.join(" "):t}const Je={};function fu(t){for(const e in t)Je[e]=t[e],Ls(e)&&(Je[e].isCSSVariable=!0)}function Io(t,{layout:e,layoutId:n}){return De.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Je[t]||t==="opacity")}const mu={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},pu=ke.length;function gu(t,e,n){let s="",i=!0;for(let o=0;o<pu;o++){const r=ke[o],a=t[r];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(r.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const u=Po(a,Gs[r]);if(!c){i=!1;const l=mu[r]||r;s+=`${l}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function ti(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const c in e){const u=e[c];if(De.has(c)){r=!0;continue}else if(Ls(c)){i[c]=u;continue}else{const l=Po(u,Gs[c]);c.startsWith("origin")?(a=!0,o[c]=l):s[c]=l}}if(e.transform||(r||n?s.transform=gu(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:c="50%",originY:u="50%",originZ:l=0}=o;s.transformOrigin=`${c} ${u} ${l}`}}const ei=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Lo(t,e,n){for(const s in e)!nt(e[s])&&!Io(s,n)&&(t[s]=e[s])}function yu({transformTemplate:t},e){return m.useMemo(()=>{const n=ei();return ti(n,e,t),Object.assign({},n.vars,n.style)},[e])}function xu(t,e){const n=t.style||{},s={};return Lo(s,n,t),Object.assign(s,yu(t,e)),s}function vu(t,e){const n={},s=xu(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 bu={offset:"stroke-dashoffset",array:"stroke-dasharray"},wu={offset:"strokeDashoffset",array:"strokeDasharray"};function Tu(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?bu:wu;t[o.offset]=R.transform(-s);const r=R.transform(e),a=R.transform(n);t[o.array]=`${r} ${a}`}function Oo(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},c,u,l){if(ti(t,a,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=l?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&Tu(d,i,o,r,!1)}const Fo=()=>({...ei(),attrs:{}}),Bo=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Su(t,e,n,s){const i=m.useMemo(()=>{const o=Fo();return Oo(o,e,Bo(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};Lo(o,t.style,t),i.style={...o,...i.style}}return i}const Au=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function ni(t){return typeof t!="string"||t.includes("-")?!1:!!(Au.indexOf(t)>-1||/[A-Z]/u.test(t))}function Cu(t,e,n,{latestValues:s},i,o=!1){const a=(ni(t)?Su:vu)(e,s,i,t),c=uu(e,typeof t=="string",o),u=t!==m.Fragment?{...c,...a,ref:n}:{},{children:l}=e,d=m.useMemo(()=>nt(l)?l.get():l,[l]);return m.createElement(t,{...u,children:d})}function Hi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function si(t,e,n,s){if(typeof e=="function"){const[i,o]=Hi(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]=Hi(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function yn(t){return nt(t)?t.get():t}function Pu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:Mu(n,s,i,t),renderState:e()}}function Mu(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=yn(o[f]);let{initial:r,animate:a}=t;const c=kn(t),u=No(t);e&&u&&!c&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let l=n?n.initial===!1:!1;l=l||r===!1;const d=l?a:r;if(d&&typeof d!="boolean"&&!En(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const x=si(t,f[g]);if(x){const{transitionEnd:v,transition:C,...y}=x;for(const w in y){let S=y[w];if(Array.isArray(S)){const E=l?S.length-1:0;S=S[E]}S!==null&&(i[w]=S)}for(const w in v)i[w]=v[w]}}}return i}const $o=t=>(e,n)=>{const s=m.useContext(jn),i=m.useContext(Mn),o=()=>Pu(t,e,s,i);return n?o():Ms(o)};function ii(t,e,n){const{style:s}=t,i={};for(const o in s)(nt(s[o])||e.style&&nt(e.style[o])||Io(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const ju=$o({scrapeMotionValuesFromProps:ii,createRenderState:ei});function zo(t,e,n){const s=ii(t,e,n);for(const i in t)if(nt(t[i])||nt(e[i])){const o=ke.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const Eu=$o({scrapeMotionValuesFromProps:zo,createRenderState:Fo}),ku=Symbol.for("motionComponentSymbol");function be(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Du(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):be(n)&&(n.current=s))},[e])}const ri=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Vu="framerAppearId",Uo="data-"+ri(Vu),_o=m.createContext({});function Ru(t,e,n,s,i){const{visualElement:o}=m.useContext(jn),r=m.useContext(Js),a=m.useContext(Mn),c=m.useContext(Ys).reducedMotion,u=m.useRef(null);s=s||r.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const l=u.current,d=m.useContext(_o);l&&!l.projection&&i&&(l.type==="html"||l.type==="svg")&&Nu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{l&&f.current&&l.update(n,a)});const g=n[Uo],x=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return $r(()=>{l&&(f.current=!0,window.MotionIsMounted=!0,l.updateFeatures(),l.scheduleRenderMicrotask(),x.current&&l.animationState&&l.animationState.animateChanges())}),m.useEffect(()=>{l&&(!x.current&&l.animationState&&l.animationState.animateChanges(),x.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),x.current=!1),l.enteringChildren=void 0)}),l}function Nu(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:Wo(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&be(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:c,layoutRoot:u})}function Wo(t){if(t)return t.options.allowProjection!==!1?t.projection:Wo(t.parent)}function xn(t,{forwardMotionProps:e=!1}={},n,s){n&&ps(n);const i=ni(t)?Eu:ju;function o(a,c){let u;const l={...m.useContext(Ys),...a,layoutId:Iu(a)},{isStatic:d}=l,f=hu(a),g=i(a,d);if(!d&&js){Lu(l,n);const x=Ou(l);u=x.MeasureLayout,f.visualElement=Ru(t,g,l,s,x.ProjectionNode)}return h.jsxs(jn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...l}):null,Cu(t,a,Du(g,f.visualElement,c),g,d,e)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const r=m.forwardRef(o);return r[ku]=t,r}function Iu({layoutId:t}){const e=m.useContext(Ps).id;return e&&t!==void 0?e+"-"+t:t}function Lu(t,e){const n=m.useContext(Js).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?je(!1,s,"lazy-strict-mode"):It(!1,s,"lazy-strict-mode")}}function Ou(t){const{drag:e,layout:n}=Me;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Fu(t,e){if(typeof Proxy>"u")return xn;const n=new Map,s=(o,r)=>xn(o,r,t,e),i=(o,r)=>(process.env.NODE_ENV!=="production"&&Rs(!1,"motion() is deprecated. Use motion.create() instead."),s(o,r));return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,xn(r,void 0,t,e)),n.get(r))})}function Ko({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function Bu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function $u(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Hn(t){return t===void 0||t===1}function gs({scale:t,scaleX:e,scaleY:n}){return!Hn(t)||!Hn(e)||!Hn(n)}function ie(t){return gs(t)||Ho(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Ho(t){return Gi(t.x)||Gi(t.y)}function Gi(t){return t&&t!=="0%"}function Pn(t,e,n){const s=t-n,i=e*s;return n+i}function Xi(t,e,n,s,i){return i!==void 0&&(t=Pn(t,i,s)),Pn(t,n,s)+e}function ys(t,e=0,n=1,s,i){t.min=Xi(t.min,e,n,s,i),t.max=Xi(t.max,e,n,s,i)}function Go(t,{x:e,y:n}){ys(t.x,e.translate,e.scale,e.originPoint),ys(t.y,n.translate,n.scale,n.originPoint)}const qi=.999999999999,Yi=1.0000000000001;function zu(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&&Te(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,Go(t,r)),s&&ie(o.latestValues)&&Te(t,o.latestValues))}e.x<Yi&&e.x>qi&&(e.x=1),e.y<Yi&&e.y>qi&&(e.y=1)}function we(t,e){t.min=t.min+e,t.max=t.max+e}function Ji(t,e,n,s,i=.5){const o=H(t.min,t.max,i);ys(t,e,n,o,s)}function Te(t,e){Ji(t.x,e.x,e.scaleX,e.scale,e.originX),Ji(t.y,e.y,e.scaleY,e.scale,e.originY)}function Xo(t,e){return Ko($u(t.getBoundingClientRect(),e))}function Uu(t,e,n){const s=Xo(t,n),{scroll:i}=e;return i&&(we(s.x,i.offset.x),we(s.y,i.offset.y)),s}const Zi=()=>({translate:0,scale:1,origin:0,originPoint:0}),Se=()=>({x:Zi(),y:Zi()}),Qi=()=>({min:0,max:0}),X=()=>({x:Qi(),y:Qi()}),xs={current:null},qo={current:!1};function _u(){if(qo.current=!0,!!js)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>xs.current=t.matches;t.addEventListener("change",e),e()}else xs.current=!1}const Wu=new WeakMap;function Ku(t,e,n){for(const s in e){const i=e[s],o=n[s];if(nt(i))t.addValue(s,i);else if(nt(o))t.addValue(s,Pe(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,Pe(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const tr=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Hu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Ks,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=ut.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=kn(n),this.isVariantNode=No(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:l,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];c[f]!==void 0&&nt(g)&&g.set(c[f])}}mount(e){this.current=e,Wu.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)),qo.current||_u(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:xs.current,process.env.NODE_ENV!=="production"&&Rs(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Wt(this.notifyUpdate),Wt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=De.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 Me){const n=Me[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):X()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<tr.length;s++){const i=tr[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=Ku(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=Pe(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"&&(zr(s)||_r(s))?s=parseFloat(s):!Ql(s)&&Kt.test(n)&&(s=Co(e,n)),this.setBaseTarget(e,nt(s)?s.get():s)),nt(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=si(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!nt(i)?i:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Vs),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){Xs.render(this.render)}}class Yo extends Hu{constructor(){super(...arguments),this.KeyframeResolver=zl}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;nt(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Jo(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 Gu(t){return window.getComputedStyle(t)}class Xu extends Yo{constructor(){super(...arguments),this.type="html",this.renderInstance=Jo}readValueFromInstance(e,n){if(De.has(n))return this.projection?.isProjecting?cs(n):rl(e,n);{const s=Gu(e),i=(Ls(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Xo(e,n)}build(e,n,s){ti(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return ii(e,n,s)}}const Zo=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 qu(t,e,n,s){Jo(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Zo.has(i)?i:ri(i),e.attrs[i])}class Yu extends Yo{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=X}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(De.has(n)){const s=Ao(n);return s&&s.default||0}return n=Zo.has(n)?n:ri(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return zo(e,n,s)}build(e,n,s){Oo(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){qu(e,n,s,i)}mount(e){this.isSVGTag=Bo(e.tagName),super.mount(e)}}const Qo=(t,e)=>ni(t)?new Yu(e):new Xu(e,{allowProjection:t!==m.Fragment});function Ce(t,e,n){const s=t.getProps();return si(s,e,n!==void 0?n:s.custom,t)}const vs=t=>Array.isArray(t);function Ju(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Pe(n))}function Zu(t){return vs(t)?t[t.length-1]||0:t}function Qu(t,e){const n=Ce(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=Zu(o[r]);Ju(t,r,a)}}function td(t){return!!(nt(t)&&t.add)}function bs(t,e){const n=t.getValue("willChange");if(td(n))return n.add(e);if(!n&&Lt.WillChange){const s=new Lt.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function ta(t){return t.props[Uo]}const ed=t=>t!==null;function nd(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(ed),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const sd={type:"spring",stiffness:500,damping:25,restSpeed:10},id=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),rd={type:"keyframes",duration:.8},od={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ad=(t,{keyframes:e})=>e.length>2?rd:De.has(t)?t.startsWith("scale")?id(e[1]):sd:od;function cd({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:c,elapsed:u,...l}){return!!Object.keys(l).length}const oi=(t,e,n,s={},i,o)=>r=>{const a=Hs(s,t)||{},c=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-St(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};cd(a)||Object.assign(l,ad(t,l)),l.duration&&(l.duration=St(l.duration)),l.repeatDelay&&(l.repeatDelay=St(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let d=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(fs(l),l.delay===0&&(d=!0)),(Lt.instantAnimations||Lt.skipAnimations)&&(d=!0,fs(l),l.delay=0),l.allowFlatten=!a.type&&!a.ease,d&&!o&&e.get()!==void 0){const f=nd(l.keyframes,a);if(f!==void 0){W.update(()=>{l.onUpdate(f),l.onComplete()});return}}return a.isSync?new Ws(l):new jl(l)};function ld({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function ea(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&&ld(u,l))continue;const g={delay:n,...Hs(o||{},l)},x=d.get();if(x!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===x&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const y=ta(t);if(y){const w=window.MotionHandoffAnimation(y,l,W);w!==null&&(g.startTime=w,v=!0)}}bs(t,l),d.start(oi(l,d,f,t.shouldReduceMotion&&wo.has(l)?{type:!1}:g,t,v));const C=d.animation;C&&c.push(C)}return r&&Promise.all(c).then(()=>{W.update(()=>{r&&Qu(t,r)})}),c}function na(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,l)=>u.sortNodePosition(l)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function ws(t,e,n={}){const s=Ce(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(ea(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:l,staggerDirection:d}=i;return ud(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 ud(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(ws(c,e,{...r,delay:n+(typeof s=="function"?0:s)+na(t.variantChildren,c,s,i,o)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function dd(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>ws(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=ws(t,e,n);else{const i=typeof e=="function"?Ce(t,e,n.custom):e;s=Promise.all(ea(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function sa(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 hd=Qs.length;function ia(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?ia(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<hd;n++){const s=Qs[n],i=t.props[s];(Ye(i)||i===!1)&&(e[s]=i)}return e}const fd=[...Zs].reverse(),md=Zs.length;function pd(t){return e=>Promise.all(e.map(({animation:n,options:s})=>dd(t,n,s)))}function gd(t){let e=pd(t),n=er(),s=!0;const i=c=>(u,l)=>{const d=Ce(t,l,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...x}=d;u={...u,...x,...g}}return u};function o(c){e=c(t)}function r(c){const{props:u}=t,l=ia(t.parent)||{},d=[],f=new Set;let g={},x=1/0;for(let C=0;C<md;C++){const y=fd[C],w=n[y],S=u[y]!==void 0?u[y]:l[y],E=Ye(S),M=y===c?w.isActive:null;M===!1&&(x=C);let j=S===l[y]&&S!==u[y]&&E;if(j&&s&&t.manuallyAnimateOnMount&&(j=!1),w.protectedKeys={...g},!w.isActive&&M===null||!S&&!w.prevProp||En(S)||typeof S=="boolean")continue;const L=yd(w.prevProp,S);let V=L||y===c&&w.isActive&&!j&&E||C>x&&E,F=!1;const G=Array.isArray(S)?S:[S];let J=G.reduce(i(y),{});M===!1&&(J={});const{prevResolvedValues:z={}}=w,le={...z,...J},At=B=>{V=!0,f.has(B)&&(F=!0,f.delete(B)),w.needsAnimating[B]=!0;const it=t.getValue(B);it&&(it.liveStyle=!1)};for(const B in le){const it=J[B],rt=z[B];if(g.hasOwnProperty(B))continue;let ct=!1;vs(it)&&vs(rt)?ct=!sa(it,rt):ct=it!==rt,ct?it!=null?At(B):f.add(B):it!==void 0&&f.has(B)?At(B):w.protectedKeys[B]=!0}w.prevProp=S,w.prevResolvedValues=J,w.isActive&&(g={...g,...J}),s&&t.blockInitialAnimation&&(V=!1);const st=j&&L;V&&(!st||F)&&d.push(...G.map(B=>{const it={type:y};if(typeof B=="string"&&s&&!st&&t.manuallyAnimateOnMount&&t.parent){const{parent:rt}=t,ct=Ce(rt,B);if(rt.enteringChildren&&ct){const{delayChildren:ot}=ct.transition||{};it.delay=na(rt.enteringChildren,t,ot)}}return{animation:B,options:it}}))}if(f.size){const C={};if(typeof u.initial!="boolean"){const y=Ce(t,Array.isArray(u.initial)?u.initial[0]:u.initial);y&&y.transition&&(C.transition=y.transition)}f.forEach(y=>{const w=t.getBaseTarget(y),S=t.getValue(y);S&&(S.liveStyle=!0),C[y]=w??null}),d.push({animation:C})}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=er()}}}function yd(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!sa(e,t):!1}function ne(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function er(){return{animate:ne(!0),whileInView:ne(),whileHover:ne(),whileTap:ne(),whileDrag:ne(),whileFocus:ne(),exit:ne()}}class Ht{constructor(e){this.isMounted=!1,this.node=e}update(){}}class xd extends Ht{constructor(e){super(e),e.animationState||(e.animationState=gd(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();En(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let vd=0;class bd extends Ht{constructor(){super(...arguments),this.id=vd++}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 ra={animation:{Feature:xd},exit:{Feature:bd}};function Ze(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function nn(t){return{point:{x:t.pageX,y:t.pageY}}}const wd=t=>e=>qs(e)&&t(e,nn(e));function Ue(t,e,n,s){return Ze(t,e,wd(n),s)}const oa=1e-4,Td=1-oa,Sd=1+oa,aa=.01,Ad=0-aa,Cd=0+aa;function at(t){return t.max-t.min}function Pd(t,e,n){return Math.abs(t-e)<=n}function nr(t,e,n,s=.5){t.origin=s,t.originPoint=H(e.min,e.max,t.origin),t.scale=at(n)/at(e),t.translate=H(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Td&&t.scale<=Sd||isNaN(t.scale))&&(t.scale=1),(t.translate>=Ad&&t.translate<=Cd||isNaN(t.translate))&&(t.translate=0)}function _e(t,e,n,s){nr(t.x,e.x,n.x,s?s.originX:void 0),nr(t.y,e.y,n.y,s?s.originY:void 0)}function sr(t,e,n){t.min=n.min+e.min,t.max=t.min+at(e)}function Md(t,e,n){sr(t.x,e.x,n.x),sr(t.y,e.y,n.y)}function ir(t,e,n){t.min=e.min-n.min,t.max=t.min+at(e)}function We(t,e,n){ir(t.x,e.x,n.x),ir(t.y,e.y,n.y)}function yt(t){return[t("x"),t("y")]}const ca=({current:t})=>t?t.ownerDocument.defaultView:null,rr=(t,e)=>Math.abs(t-e);function jd(t,e){const n=rr(t.x,e.x),s=rr(t.y,e.y);return Math.sqrt(n**2+s**2)}class la{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=Xn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,x=jd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!x)return;const{point:v}=f,{timestamp:C}=Z;this.history.push({...v,timestamp:C});const{onStart:y,onMove:w}=this.handlers;g||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Gn(g,this.transformPagePoint),W.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:x,onSessionEnd:v,resumeAnimation:C}=this.handlers;if(this.dragSnapToOrigin&&C&&C(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=Xn(f.type==="pointercancel"?this.lastMoveEventInfo:Gn(g,this.transformPagePoint),this.history);this.startEvent&&x&&x(f,y),v&&v(f,y)},!qs(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const a=nn(e),c=Gn(a,this.transformPagePoint),{point:u}=c,{timestamp:l}=Z;this.history=[{...u,timestamp:l}];const{onSessionStart:d}=n;d&&d(e,Xn(c,this.history)),this.removeListeners=Qe(Ue(this.contextWindow,"pointermove",this.handlePointerMove),Ue(this.contextWindow,"pointerup",this.handlePointerUp),Ue(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Wt(this.updatePoint)}}function Gn(t,e){return e?{point:e(t.point)}:t}function or(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Xn({point:t},e){return{point:t,delta:or(t,ua(e)),offset:or(t,Ed(e)),velocity:kd(e,.1)}}function Ed(t){return t[0]}function ua(t){return t[t.length-1]}function kd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=ua(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>St(e)));)n--;if(!s)return{x:0,y:0};const o=xt(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 Dd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?H(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?H(n,t,s.max):Math.min(t,n)),t}function ar(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 Vd(t,{top:e,left:n,bottom:s,right:i}){return{x:ar(t.x,n,i),y:ar(t.y,e,s)}}function cr(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 Rd(t,e){return{x:cr(t.x,e.x),y:cr(t.y,e.y)}}function Nd(t,e){let n=.5;const s=at(t),i=at(e);return i>s?n=Ge(e.min,e.max-s,t.min):s>i&&(n=Ge(t.min,t.max-i,e.min)),Nt(0,1,n)}function Id(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Ts=.35;function Ld(t=Ts){return t===!1?t=0:t===!0&&(t=Ts),{x:lr(t,"left","right"),y:lr(t,"top","bottom")}}function lr(t,e,n){return{min:ur(t,e),max:ur(t,n)}}function ur(t,e){return typeof t=="number"?t:t[e]||0}const Od=new WeakMap;class Fd{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=X(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(nn(d).point)},r=(d,f)=>{const{drag:g,dragPropagation:x,onDragStart:v}=this.getProps();if(g&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Kl(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),yt(y=>{let w=this.getAxisMotionValue(y).get()||0;if(Et.test(w)){const{projection:S}=this.visualElement;if(S&&S.layout){const E=S.layout.layoutBox[y];E&&(w=at(E)*(parseFloat(w)/100))}}this.originPoint[y]=w}),v&&W.postRender(()=>v(d,f)),bs(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:x,onDirectionLock:v,onDrag:C}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:y}=f;if(x&&this.currentDirection===null){this.currentDirection=Bd(y),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),C&&C(d,f)},c=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>yt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:l}=this.getProps();this.panSession=new la(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:s,contextWindow:ca(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||!fn(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=Dd(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&&be(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=Vd(s.layoutBox,e):this.constraints=!1,this.elastic=Ld(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&yt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Id(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!be(e))return!1;const s=e.current;It(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=Uu(s,i.root,this.visualElement.getTransformPagePoint());let r=Rd(i.layout.layoutBox,o);if(n){const a=n(Bu(r));this.hasMutatedConstraints=!!a,a&&(r=Ko(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=yt(l=>{if(!fn(l,n,this.currentDirection))return;let d=c&&c[l]||{};r&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,x={type:"inertia",velocity:s?e[l]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(l,x)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return bs(this.visualElement,e),s.start(oi(e,s,0,n,this.visualElement,!1))}stopAnimation(){yt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){yt(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){yt(n=>{const{drag:s}=this.getProps();if(!fn(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n];o.set(e[n]-H(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!be(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};yt(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const c=a.get();i[r]=Nd({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(),yt(r=>{if(!fn(r,e,null))return;const a=this.getAxisMotionValue(r),{min:c,max:u}=this.constraints[r];a.set(H(c,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;Od.set(this.visualElement,this);const e=this.visualElement.current,n=Ue(e,"pointerdown",c=>{const{drag:u,dragListener:l=!0}=this.getProps();u&&l&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();be(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=Ze(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(yt(l=>{const d=this.getAxisMotionValue(l);d&&(this.originPoint[l]+=c[l].translate,d.set(d.get()+c[l].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=Ts,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function fn(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Bd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class $d extends Ht{constructor(e){super(e),this.removeGroupControls=vt,this.removeListeners=vt,this.controls=new Fd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||vt}unmount(){this.removeGroupControls(),this.removeListeners()}}const dr=t=>(e,n)=>{t&&W.postRender(()=>t(e,n))};class zd extends Ht{constructor(){super(...arguments),this.removePointerDownListener=vt}onPointerDown(e){this.session=new la(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ca(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:dr(e),onStart:dr(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&W.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=Ue(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const vn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function hr(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Be={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(R.test(t))t=parseFloat(t);else return t;const n=hr(t,e.target.x),s=hr(t,e.target.y);return`${n}% ${s}%`}},Ud={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Kt.parse(t);if(i.length>5)return s;const o=Kt.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=c;const u=H(a,c,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}};let qn=!1;class _d extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;fu(Wd),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),qn&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),vn.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,qn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||W.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Xs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;qn=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function da(t){const[e,n]=Vo(),s=m.useContext(Ps);return h.jsx(_d,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(_o),isPresent:e,safeToRemove:n})}const Wd={borderRadius:{...Be,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Be,borderTopRightRadius:Be,borderBottomLeftRadius:Be,borderBottomRightRadius:Be,boxShadow:Ud};function Kd(t,e,n){const s=nt(t)?t:Pe(t);return s.start(oi("",s,e,n)),s.animation}const Hd=(t,e)=>t.depth-e.depth;class Gd{constructor(){this.children=[],this.isDirty=!1}add(e){Es(this.children,e),this.isDirty=!0}remove(e){ks(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Hd),this.isDirty=!1,this.children.forEach(e)}}function Xd(t,e){const n=ut.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(Wt(s),t(o-e))};return W.setup(s,!0),()=>Wt(s)}const ha=["TopLeft","TopRight","BottomLeft","BottomRight"],qd=ha.length,fr=t=>typeof t=="string"?parseFloat(t):t,mr=t=>typeof t=="number"||R.test(t);function Yd(t,e,n,s,i,o){i?(t.opacity=H(0,n.opacity??1,Jd(s)),t.opacityExit=H(e.opacity??1,0,Zd(s))):o&&(t.opacity=H(e.opacity??1,n.opacity??1,s));for(let r=0;r<qd;r++){const a=`border${ha[r]}Radius`;let c=pr(e,a),u=pr(n,a);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||mr(c)===mr(u)?(t[a]=Math.max(H(fr(c),fr(u),s),0),(Et.test(u)||Et.test(c))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=H(e.rotate||0,n.rotate||0,s))}function pr(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Jd=fa(0,.5,Jr),Zd=fa(.5,.95,vt);function fa(t,e,n){return s=>s<t?0:s>e?1:n(Ge(t,e,s))}function gr(t,e){t.min=e.min,t.max=e.max}function gt(t,e){gr(t.x,e.x),gr(t.y,e.y)}function yr(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function xr(t,e,n,s,i){return t-=e,t=Pn(t,1/n,s),i!==void 0&&(t=Pn(t,1/i,s)),t}function Qd(t,e=0,n=1,s=.5,i,o=t,r=t){if(Et.test(e)&&(e=parseFloat(e),e=H(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=H(o.min,o.max,s);t===o&&(a-=e),t.min=xr(t.min,e,n,a,i),t.max=xr(t.max,e,n,a,i)}function vr(t,e,[n,s,i],o,r){Qd(t,e[n],e[s],e[i],e.scale,o,r)}const th=["x","scaleX","originX"],eh=["y","scaleY","originY"];function br(t,e,n,s){vr(t.x,e,th,n?n.x:void 0,s?s.x:void 0),vr(t.y,e,eh,n?n.y:void 0,s?s.y:void 0)}function wr(t){return t.translate===0&&t.scale===1}function ma(t){return wr(t.x)&&wr(t.y)}function Tr(t,e){return t.min===e.min&&t.max===e.max}function nh(t,e){return Tr(t.x,e.x)&&Tr(t.y,e.y)}function Sr(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function pa(t,e){return Sr(t.x,e.x)&&Sr(t.y,e.y)}function Ar(t){return at(t.x)/at(t.y)}function Cr(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class sh{constructor(){this.members=[]}add(e){Es(this.members,e),e.scheduleRender()}remove(e){if(ks(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function ih(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:l,rotateX:d,rotateY:f,skewX:g,skewY:x}=n;u&&(s=`perspective(${u}px) ${s}`),l&&(s+=`rotate(${l}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),x&&(s+=`skewY(${x}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(s+=`scale(${a}, ${c})`),s||"none"}const Yn=["","X","Y","Z"],rh=1e3;let oh=0;function Jn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function ga(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=ta(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&&ga(s)}function ya({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=oh++,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(lh),this.nodes.forEach(fh),this.nodes.forEach(mh),this.nodes.forEach(uh)},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 Gd)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new Vs),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const c=this.eventHandlers.get(r);c&&c.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=Do(r)&&!Jl(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 g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,l&&l(),l=Xd(f,250),vn.hasAnimatedSinceResize&&(vn.hasAnimatedSinceResize=!1,this.nodes.forEach(jr)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||c)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||u.getDefaultTransition()||vh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:C}=u.getProps(),y=!this.targetLayout||!pa(this.targetLayout,g),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...Hs(x,"layout"),onPlay:v,onComplete:C};(u.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(l,w)}else d||jr(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Wt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ph),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&&ga(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const d=this.path[l];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Pr);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Mr);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(hh),this.nodes.forEach(ah),this.nodes.forEach(ch)):this.nodes.forEach(Mr),this.clearAllSnapshots();const a=ut.now();Z.delta=Nt(0,1e3/60,a-Z.timestamp),Z.timestamp=a,Z.isProcessing=!0,Bn.update.process(Z),Bn.preRender.process(Z),Bn.render.process(Z),Z.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Xs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(dh),this.sharedNodes.forEach(gh)}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&&!at(this.snapshot.measuredBox.x)&&!at(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=X(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,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&&!ma(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,l=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||ie(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)),bh(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return X();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(wh))){const{scroll:u}=this.root;u&&(we(a.x,u.offset.x),we(a.y,u.offset.y))}return a}removeElementScroll(r){const a=X();if(gt(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&>(a,r),we(a.x,l.offset.x),we(a.y,l.offset.y))}return a}applyTransform(r,a=!1){const c=X();gt(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&&Te(c,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),ie(l.latestValues)&&Te(c,l.latestValues)}return ie(this.latestValues)&&Te(c,this.latestValues),c}removeTransform(r){const a=X();gt(a,r);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!ie(u.latestValues))continue;gs(u.latestValues)&&u.updateSnapshot();const l=X(),d=u.measurePageBox();gt(l,d),br(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,l)}return ie(this.latestValues)&&br(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!==Z.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=Z.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=X(),this.relativeTargetOrigin=X(),We(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),gt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=X(),this.targetWithTransforms=X()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Md(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):gt(this.target,this.layout.layoutBox),Go(this.target,this.targetDelta)):gt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=X(),this.relativeTargetOrigin=X(),We(this.relativeTargetOrigin,this.target,f.target),gt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||gs(this.parent.latestValues)||Ho(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===Z.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;gt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;zu(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=X());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(yr(this.prevProjectionDelta.x,this.projectionDelta.x),yr(this.prevProjectionDelta.y,this.projectionDelta.y)),_e(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Cr(this.projectionDelta.x,this.prevProjectionDelta.x)||!Cr(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=Se(),this.projectionDelta=Se(),this.projectionDeltaWithTransform=Se()}setAnimationOrigin(r,a=!1){const c=this.snapshot,u=c?c.latestValues:{},l={...this.latestValues},d=Se();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=X(),g=c?c.source:void 0,x=this.layout?this.layout.source:void 0,v=g!==x,C=this.getStack(),y=!C||C.members.length<=1,w=!!(v&&!y&&this.options.crossfade===!0&&!this.path.some(xh));this.animationProgress=0;let S;this.mixTargetDelta=E=>{const M=E/1e3;Er(d.x,r.x,M),Er(d.y,r.y,M),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(We(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),yh(this.relativeTarget,this.relativeTargetOrigin,f,M),S&&nh(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=X()),gt(S,this.relativeTarget)),v&&(this.animationValues=l,Yd(l,u,this.latestValues,M,w,y)),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&&(Wt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=W.update(()=>{vn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Pe(0)),this.currentAnimation=Kd(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(rh),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&&xa(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||X();const d=at(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+d;const f=at(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+f}gt(a,c),Te(a,l),_e(this.projectionDeltaWithTransform,this.layoutCorrected,a,l)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new sh),this.sharedNodes.get(r).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const u={};c.z&&Jn("z",r,u,this.animationValues);for(let l=0;l<Yn.length;l++)Jn(`rotate${Yn[l]}`,r,u,this.animationValues),Jn(`skew${Yn[l]}`,r,u,this.animationValues);r.render();for(const l in u)r.setStaticValue(l,u[l]),this.animationValues&&(this.animationValues[l]=u[l]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=yn(a?.pointerEvents)||"",r.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=yn(a?.pointerEvents)||""),this.hasProjected&&!ie(this.latestValues)&&(r.transform=c?c({},""):"none",this.hasProjected=!1);return}r.visibility="";const l=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=ih(this.projectionDeltaWithTransform,this.treeScale,l);c&&(d=c(l,d)),r.transform=d;const{x:f,y:g}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?r.opacity=u===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:r.opacity=u===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const x in Je){if(l[x]===void 0)continue;const{correct:v,applyTo:C,isCSSVariable:y}=Je[x],w=d==="none"?l[x]:v(l[x],u);if(C){const S=C.length;for(let E=0;E<S;E++)r[C[E]]=w}else y?this.options.visualElement.renderState.vars[x]=w:r[x]=w}this.options.layoutId&&(r.pointerEvents=u===this?yn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(Pr),this.root.sharedNodes.clear()}}}function ah(t){t.updateLayout()}function ch(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"?yt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=at(d);d.min=n[l].min,d.max=d.min+f}):xa(i,e.layoutBox,n)&&yt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=at(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=Se();_e(r,n,e.layoutBox);const a=Se();o?_e(a,t.applyTransform(s,!0),e.measuredBox):_e(a,n,e.layoutBox);const c=!ma(r);let u=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:d,layout:f}=l;if(d&&f){const g=X();We(g,e.layoutBox,d.layoutBox);const x=X();We(x,n,f.layoutBox),pa(g,x)||(u=!0),l.options.layoutRoot&&(t.relativeTarget=x,t.relativeTargetOrigin=g,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function lh(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 uh(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function dh(t){t.clearSnapshot()}function Pr(t){t.clearMeasurements()}function Mr(t){t.isLayoutDirty=!1}function hh(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function jr(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function fh(t){t.resolveTargetDelta()}function mh(t){t.calcProjection()}function ph(t){t.resetSkewAndRotation()}function gh(t){t.removeLeadSnapshot()}function Er(t,e,n){t.translate=H(e.translate,0,n),t.scale=H(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function kr(t,e,n,s){t.min=H(e.min,n.min,s),t.max=H(e.max,n.max,s)}function yh(t,e,n,s){kr(t.x,e.x,n.x,s),kr(t.y,e.y,n.y,s)}function xh(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const vh={duration:.45,ease:[.4,0,.1,1]},Dr=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Vr=Dr("applewebkit/")&&!Dr("chrome/")?Math.round:vt;function Rr(t){t.min=Vr(t.min),t.max=Vr(t.max)}function bh(t){Rr(t.x),Rr(t.y)}function xa(t,e,n){return t==="position"||t==="preserve-aspect"&&!Pd(Ar(e),Ar(n),.2)}function wh(t){return t!==t.root&&t.scroll?.wasRoot}const Th=ya({attachResizeListener:(t,e)=>Ze(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Zn={current:void 0},va=ya({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Zn.current){const t=new Th({});t.mount(window),t.setOptions({layoutScroll:!0}),Zn.current=t}return Zn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Sh={pan:{Feature:zd},drag:{Feature:$d,ProjectionNode:va,MeasureLayout:da}};function Nr(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,nn(e)))}class Ah extends Ht{mount(){const{current:e}=this.node;e&&(this.unmount=Hl(e,(n,s)=>(Nr(this.node,s,"Start"),i=>Nr(this.node,i,"End"))))}unmount(){}}class Ch extends Ht{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Qe(Ze(this.node.current,"focus",()=>this.onFocus()),Ze(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Ir(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,nn(e)))}class Ph extends Ht{mount(){const{current:e}=this.node;e&&(this.unmount=Yl(e,(n,s)=>(Ir(this.node,s,"Start"),(i,{success:o})=>Ir(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Ss=new WeakMap,Qn=new WeakMap,Mh=t=>{const e=Ss.get(t.target);e&&e(t)},jh=t=>{t.forEach(Mh)};function Eh({root:t,...e}){const n=t||document;Qn.has(n)||Qn.set(n,{});const s=Qn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(jh,{root:t,...e})),s[i]}function kh(t,e,n){const s=Eh(e);return Ss.set(t,n),s.observe(t),()=>{Ss.delete(t),s.unobserve(t)}}const Dh={some:0,all:1};class Vh extends Ht{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Dh[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 kh(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(Rh(e,n))&&this.startObserver()}unmount(){}}function Rh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const ba={inView:{Feature:Vh},tap:{Feature:Ph},focus:{Feature:Ch},hover:{Feature:Ah}},Nh={layout:{ProjectionNode:va,MeasureLayout:da}},Ih={...ra,...ba,...Sh,...Nh},Lh=Fu(Ih,Qo),Oh={renderer:Qo,...ra,...ba};function wa(t,e){return xn(t,e)}const mn=wa("div"),Fh=wa("p"),jt=Symbol.for("@arcteninc/core:originalName");function Bh(t,e){return t[jt]=e,t}function $h(t,e,n,s){if(typeof t!="function")return null;const i=t[jt];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[jt]=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[jt]=r.name,{fn:t,meta:r}}else if(r=Object.values(e).find(c=>!n.has(c.name)),r)return t[jt]=r.name,{fn:t,meta:r};return null}function Ta(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
|
|
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,""")}" 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,""")}" 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&>(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
|
-
${
|
|
21
|
-
${
|
|
22
|
-
${
|
|
23
|
-
${
|
|
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;
|
|
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=$h(o,n,i,s);if(!r){const a=o.name,u=o[jt]||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 zh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const o=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),o&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([r,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[r,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},r))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(wn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(Y.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(wn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(Y.X,{className:"h-3 w-3"})})]})]})})}function Uh({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(Y.ChevronDown,{className:"h-3 w-3"}):h.jsx(Y.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(Y.X,{className:"h-3 w-3"}):s?h.jsx(Y.Zap,{className:"h-3 w-3"}):h.jsx(Y.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&c&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},u))})})]})}function _h({...t}){return h.jsx(Cs.Root,{"data-slot":"collapsible",...t})}function Wh({...t}){return h.jsx(Cs.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Kh({...t}){return h.jsx(Cs.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Hh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ai=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Hh,{className:Q("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ai.displayName="Response";const Gh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const o=Lh.create(e),r=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(o,{animate:{backgroundPosition:"0% center"},className:Q("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})},Xh=m.memo(Gh),Sa=m.createContext(null),qh=()=>{const t=m.useContext(Sa);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Yh=1e3,Jh=1e3,Aa=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:o,children:r,...a})=>{const[c,u]=vi.useControllableState({prop:n,defaultProp:s,onChange:i}),[l,d]=vi.useControllableState({prop:o,defaultProp:0}),[f,g]=m.useState(!1),[x,v]=m.useState(null);m.useEffect(()=>{e?x===null&&v(Date.now()):x!==null&&(d(Math.ceil((Date.now()-x)/Jh)),v(null))},[e,x,d]),m.useEffect(()=>{if(s&&!e&&c&&!f){const y=setTimeout(()=>{u(!1),g(!0)},Yh);return()=>clearTimeout(y)}},[e,c,s,u,f]);const C=y=>{u(y)};return h.jsx(Sa.Provider,{value:{isStreaming:e,isOpen:c,setIsOpen:u,duration:l},children:h.jsx(_h,{className:Q("not-prose mb-4",t),onOpenChange:C,open:c,...a,children:r})})}),Zh=(t,e)=>t||e===0?h.jsx(Xh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Ca=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:o}=qh();return h.jsx(Wh,{className:Q("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...n,children:e??h.jsxs(h.Fragment,{children:[h.jsx(Y.BrainIcon,{className:"size-4"}),Zh(s,o),h.jsx(Y.ChevronDownIcon,{className:Q("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Pa=m.memo(({className:t,children:e,...n})=>h.jsx(Kh,{className:Q("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...n,children:h.jsx(ai,{className:"grid gap-2",children:e})}));Aa.displayName="Reasoning";Ca.displayName="ReasoningTrigger";Pa.displayName="ReasoningContent";function Qh(t){const e=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,n=t.match(e),s=new Map;if(n&&n[1]){const u=n[1],l=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let d;for(;(d=l.exec(u))!==null;)if(d[1]&&d[2]){const f=parseInt(d[1],10),g=d[2].replace(/[.,;:!?]+$/,"");s.set(f,g)}}const i=[];let o=0;const r=/```[\s\S]*?```|`[^`]+`/g;let a;for(;(a=r.exec(t))!==null;)a.index>o&&i.push({type:"text",content:t.slice(o,a.index),start:o,end:a.index}),i.push({type:"code",content:a[0],start:a.index,end:a.index+a[0].length}),o=a.index+a[0].length;return o<t.length&&i.push({type:"text",content:t.slice(o),start:o,end:t.length}),i.map(u=>{if(u.type==="code")return u.content;let l=u.content;l=l.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(v,C,y)=>{const w=parseInt(C,10);return`<sup><a href="${y.replace(/"/g,""")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${w}]</a></sup>`});const d=/\[([^\]]+)\]\([^\)]+\)/g,f=[];let g;for(;(g=d.exec(l))!==null;)f.push({start:g.index,end:g.index+g[0].length});return l.replace(/\[(\d+)\]/g,(v,C,y)=>{if(f.some(M=>y>=M.start&&y<M.end))return v;const S=parseInt(C,10),E=s.get(S);return E?`<sup><a href="${E.replace(/"/g,""")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${S}]</a></sup>`:v})}).join("")}function Ke(t){if(typeof t=="string")try{const e=JSON.parse(t);return Ke(e)}catch{return t}if(Array.isArray(t))return t.map(Ke);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=Ke(s);return e}return t}function ts(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return Ke(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?Ke(t):{}}function tf({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:o=void 0,defaultWidth:r=384,minWidth:a=300,maxWidth:c=800,initiallyExpanded:u=!1,tools:l=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:x="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:C,state:y,onStateChange:w,allowStateEdits:S=!0}){const[E,M]=m.useState(null),j=m.useRef(null),[L,V]=m.useState(null),[F,G]=m.useState(null),J=m.useRef(null),z=y!==void 0,[le,At]=m.useState({}),st=m.useRef({});z&&y?st.current=y:z||(st.current=le);const[Ot,B]=m.useState(!1),[it,rt]=m.useState(null),ct=m.useRef(!1),[ot,kt]=m.useState(u),[pt,ue]=m.useState(r),[Gt,Xt]=m.useState(600),[Ct,Dt]=m.useState(!1),[U,de]=m.useState(!1),[dt,qt]=m.useState(!1),[ht,he]=m.useState({x:100,y:100}),[bt,Ve]=m.useState(!1),[Yt,fe]=m.useState({x:0,y:0}),[Dn,me]=m.useState(!1),Jt=m.useRef(null),pe=m.useRef(null),[ge,Re]=m.useState(""),[sn,Vn]=m.useState("Thinking..."),[Ne,Ie]=m.useState(new Set),[Rn,P]=m.useState(""),[A,k]=m.useState([]),[I,$]=m.useState(!1),[_,tt]=m.useState([]),[lt,Ft]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Bt,ye]=m.useState(!1),[sf,rn]=m.useState(!1),[rf,on]=m.useState([]),ci=m.useCallback(async(p,b=3)=>{if(!lt||!j.current)return;const D=async()=>{const T=await fetch(`${v.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${j.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:lt,updates:p},format:"json"})});if(!T.ok){const O=await T.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${T.status} ${O}`)}};for(let T=0;T<b;T++)try{await D(),rt(null);return}catch(O){if(T===b-1){const et=O instanceof Error?O:new Error(String(O));throw rt(et),console.error("Failed to sync state to Convex after retries:",O),et}await new Promise(et=>setTimeout(et,Math.pow(2,T)*100))}},[lt,v,j]),li=m.useMemo(()=>function(){return st.current},[]),ui=m.useMemo(()=>async function(b){const D={...st.current,...b};st.current=D,z||At(D),w&&w(D);try{await ci(b)}catch(T){throw T}},[ci,w,z]);m.useEffect(()=>{z&&y&&(st.current=y)},[z,y]);const Zt=m.useMemo(()=>{const p=[...l,...d,li];return(!z||S)&&p.push(ui),p},[l,d,li,ui,z,S]),Nn=m.useMemo(()=>Ta(Zt,f),[Zt,f]),Vt=m.useMemo(()=>{const p=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}];return(!z||S)&&p.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}),[...Nn,...p]},[Nn,z,S]),di=m.useMemo(()=>new Set(Vt.map(p=>p.name)),[Vt]),In=m.useMemo(()=>Vt.filter(p=>p.name==="getState"?!0:p.name==="setState"?!z||S:di.has(p.name)),[Vt,di,z,S]),hi=m.useMemo(()=>{const p=new Map,b=new Map(Nn.map(D=>[D.name,D]));return Zt.forEach(D=>{const T=D[jt];if(T){const N=b.get(T);if(N){p.set(N.name,D);return}}const O=Vt.find(N=>N.name===D.name);O&&p.set(O.name,D)}),p},[Zt,Vt]),fi=m.useMemo(()=>{const p=new Set;p.add("getState"),p.add("setState");const b=new Map(Vt.map(D=>[D.name,D]));return d.forEach(D=>{const T=D[jt];if(T&&b.has(T))p.add(T);else{const O=Vt.find(N=>N.name===D.name);O&&p.add(O.name)}}),p},[d,Vt]),mi=["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&&kt(JSON.parse(p));const b=localStorage.getItem("arcten-sidebar-width");b&&ue(parseInt(b));const D=localStorage.getItem("arcten-sidebar-height");D&&Xt(parseInt(D));const T=localStorage.getItem("arcten-sidebar-detached");T&&de(JSON.parse(T));const O=localStorage.getItem("arcten-sidebar-position");if(O){const et=JSON.parse(O),Mt=50,zt=Math.max(Mt-r,Math.min(et.x,window.innerWidth-Mt)),ft=Math.max(0,Math.min(et.y,window.innerHeight-Mt));he({x:zt,y:ft})}const N=localStorage.getItem("arcten-sidebar-minimized");N&&qt(JSON.parse(N)),me(!0)}},[]);const $t=m.useMemo(()=>C,[C?.id]);m.useEffect(()=>((async()=>{try{const b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!b.ok)throw new Error("Failed to fetch token");const D=await b.json();M(D.clientToken),j.current=D.clientToken,G(D.expiresAt),V(null)}catch(b){V(b instanceof Error?b.message:"Failed to fetch token")}})(),()=>{J.current&&clearTimeout(J.current)}),[x,$t]),m.useEffect(()=>{if(!F)return;J.current&&clearTimeout(J.current);const p=Math.floor(Date.now()/1e3),b=F-p,T=Math.max(0,b-5);return J.current=setTimeout(async()=>{try{const O=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!O.ok)throw new Error("Failed to refresh token");const N=await O.json();M(N.clientToken),j.current=N.clientToken,G(N.expiresAt),V(null)}catch(O){console.error("Token refresh failed:",O),V(O instanceof Error?O.message:"Failed to refresh token")}},T*1e3),()=>{J.current&&clearTimeout(J.current)}},[F,x,$t]),m.useEffect(()=>{(async()=>{if(Zt.length!==0)try{const b=Zt.map(T=>({name:T.name,code:T.toString()})),D=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:b})});if(D.ok){const T=await D.json();k(T.tools)}}catch(b){console.error("Failed to fetch tool descriptions:",b)}})()},[Zt]),m.useEffect(()=>{const p=()=>{P(window.location.pathname)};p(),window.addEventListener("popstate",p);const b=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(b)}},[]);const Ln=m.useCallback(async()=>{if(!(!$t?.id||!E)){rn(!0);try{const b=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${E}`}})).json();tt(b.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{rn(!1)}}},[$t?.id,E,v]);m.useEffect(()=>{$t?.id&&E&&Ln()},[$t?.id,E,Ln]);function Ma(p){const b=Math.floor((Date.now()-p)/1e3);return b<60?"now":b<3600?`${Math.floor(b/60)}m`:b<86400?`${Math.floor(b/3600)}h`:`${Math.floor(b/86400)}d`}function ja(){const p=crypto.randomUUID();Ft(p),cn([]),on([]),ye(!1);const b=z?y||{}:{};st.current=b,z||At(b),w&&w(b),ct.current=!1}async function Ea(p){if(E)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${E}`}}),tt(_.filter(b=>b._id!==p)),p===lt&&ja()}catch(b){console.error("Failed to delete conversation:",b)}}async function ka(p){Ft(p.chatId),ye(!1),rn(!0);try{const b=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${j.current}`}});if(!b.ok)throw new Error(`Failed to fetch messages: ${b.statusText}`);const T=(await b.json()).messages||[];cn(T),on(T)}catch(b){console.error("Failed to load conversation messages:",b);const D=p.messages||[];cn(D),on(D)}finally{rn(!1)}}const Da=async(p,b={})=>{const D=b.headers?new Headers(b.headers):new Headers;return D.delete("user-agent"),D.delete("User-Agent"),fetch(p,{...b,headers:D})},{messages:Le,sendMessage:Va,status:Pt,error:pi,stop:an,addToolResult:Oe,setMessages:cn}=Lr.useChat({id:lt||void 0,transport:new bn.DefaultChatTransport({api:`${v}/chat`,fetch:Da,headers:()=>{const p={};return j.current&&(p.Authorization=`Bearer ${j.current}`),p},body:()=>({tools:In.map(b=>({name:b.name,description:b.description,inputSchema:b.jsonSchema})),systemPrompt:g,currentRoute:Rn,state:st.current})}),sendAutomaticallyWhen:bn.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{if(!lt||!j.current)return;(async()=>{B(!0),rt(null);try{const b=await fetch(`${v.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${j.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:lt},format:"json"})});if(!b.ok){const et=await b.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${b.status} ${et}`)}const T=(await b.json())?.value||{},O=!ct.current;let N;O?(N={...z?y||{}:{},...T},ct.current=!0):N=T,st.current=N,z||At(N),w&&w(N)}catch(b){console.error("Failed to fetch state:",b);const D=b instanceof Error?b:new Error(String(b));if(rt(D),!ct.current){const T=z?y||{}:{};st.current=T,z||At(T),w&&w(T),ct.current=!0}}finally{B(!1)}})()},[lt,v,z,y,w]),m.useEffect(()=>{ot&&pe.current&&pe.current.focus()},[ot,Le]);function Ra(){kt(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Na(){kt(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[ot]),m.useEffect(()=>{Jt.current&&Jt.current.scrollIntoView({behavior:"smooth"})},[Le]),m.useEffect(()=>{function p(b){b.key==="Escape"&&(Pt==="streaming"||Pt==="submitted")&&(b.preventDefault(),an())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[Pt,an]);function Ia(){const p=crypto.randomUUID();Ft(p),cn([]),on([]),ye(!1)}function gi(p){if(p.preventDefault(),!ge.trim())return;(Pt==="streaming"||Pt==="submitted")&&an();const b=mi[Math.floor(Math.random()*mi.length)]||"Thinking...";Vn(b),Va({text:ge}),Re("")}function La(p){const b=p.target.value;Re(b)}m.useEffect(()=>{if(!Ct)return;function p(D){if(U){const T=D.clientX-ht.x,O=D.clientY-ht.y;T>=a&&T<=c&&ue(T),O>=400&&O<=1e3&&Xt(O)}else{const T=window.innerWidth-D.clientX;T>=a&&T<=c&&ue(T)}}function b(){Dt(!1),localStorage.setItem("arcten-sidebar-width",pt.toString()),localStorage.setItem("arcten-sidebar-height",Gt.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[Ct,pt,Gt,U,ht,a,c]);function Oa(p){p.preventDefault(),Dt(!0)}function Fa(){de(!0),qt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ba(){de(!1),qt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function yi(){qt(!dt),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!dt))}function $a(p){U&&(Ve(!0),fe({x:p.clientX-ht.x,y:p.clientY-ht.y}))}return m.useEffect(()=>{if(!U)return;function p(){he(b=>{const T=window.innerWidth-50,O=window.innerHeight-50,N=50-pt,et=0,Mt=Math.max(N,Math.min(b.x,T)),zt=Math.max(et,Math.min(b.y,O));if(Mt!==b.x||zt!==b.y){const ft={x:Mt,y:zt};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(ft)),ft}return b})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[U,pt]),m.useEffect(()=>{if(!bt)return;function p(D){const T=D.clientX-Yt.x,O=D.clientY-Yt.y,N=50,et=window.innerWidth-N,Mt=window.innerHeight-N,zt=N-pt,ft=0,Rt=Math.max(zt,Math.min(T,et)),mt=Math.max(ft,Math.min(O,Mt));he({x:Rt,y:mt})}function b(){Ve(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(ht))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[bt,Yt,ht,pt]),Dn?L?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: ",L]})}):E?h.jsx(au,{features:Oh,children:h.jsx(mn,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:U?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:U?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
20
|
+
${U?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
|
|
21
|
+
${ot?"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
|
+
${U?"border border-border":"border-l border-border"}
|
|
23
|
+
${ot?"":"w-[30px]"}
|
|
24
|
+
`,style:ot?U?{width:`${pt}px`,height:dt?"auto":`${Gt}px`,left:`${ht.x}px`,top:`${ht.y}px`}:{width:`${pt}px`}:void 0,onClick:ot?void 0:Ra,children:ot?h.jsxs(h.Fragment,{children:[!U&&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:Oa,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),U&&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(),Dt(!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(),Ve(!0),fe({x:p.clientX-ht.x,y:p.clientY-ht.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(),Dt(!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 ${U?"cursor-move":""}`,onMouseDown:U?$a:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${U&&dt?"cursor-pointer":""}`,onClick:U&&dt?p=>{p.stopPropagation(),yi()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(se({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Ia,"aria-label":"New chat",children:h.jsx(Y.Plus,{className:"h-4 w-4"})})}),h.jsx(ee,{children:"Start a new conversation"})]}),h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(se({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:U?Ba:Fa,"aria-label":U?"Dock sidebar":"Float sidebar",children:U?h.jsx(Y.Dock,{className:"h-4 w-4"}):h.jsx(Y.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(ee,{children:U?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(se({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:U?yi:Na,"aria-label":U?dt?"Maximize":"Minimize":"Close sidebar",children:U?dt?h.jsx(Y.Maximize2,{className:"h-4 w-4"}):h.jsx(Y.Minimize2,{className:"h-4 w-4"}):h.jsx(Y.X,{className:"h-4 w-4"})})}),h.jsx(ee,{children:U?dt?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!dt&&h.jsxs(h.Fragment,{children:[C&&_.length>0&&h.jsxs("div",{className:`border-b border-border ${Bt?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(wn,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Bt||Ln(),ye(!Bt)},children:Bt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Bt?"flex-1 overflow-y-auto":""}`,children:_.slice(0,Bt?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:Q(se({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>ka(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:Ma(p.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:b=>{b.stopPropagation(),Ea(p._id)},"aria-label":"Delete conversation",children:h.jsx(Y.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:Le.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?"}),A.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:[(I?A:A.slice(0,10)).map(p=>h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Re(p.sampleUsage),pe.current?.focus()},children:p.friendlyName})}),h.jsx(ee,{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)),A.length>10&&!I&&h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsxs(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>$(!0),children:["+",A.length-10," more"]})}),h.jsx(ee,{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:A.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"})]})})]}),I&&A.length>10&&h.jsx(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>$(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[Le.map(p=>{const D=p.parts.filter(T=>T.type==="text").map(T=>T.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(Fh,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:D}):h.jsx("div",{className:"space-y-2",children:p.parts.map((T,O)=>{if(T.type?.startsWith("tool-")){const N=T.type?.replace("tool-","")||"",et=In.find(ft=>ft.name===N),Mt=T.state==="input-available",zt=T.state==="output-available";if(Mt){if(fi.has(N))return(async()=>{if(Ne.has(T.toolCallId))return;Ie(Ut=>new Set(Ut).add(T.toolCallId));const mt=hi.get(N);if(mt)try{const Ut=ts(T.input),On=In.find(ln=>ln.name===N);let Fe;if(On&&On.jsonSchema?.properties){const za=Object.keys(On.jsonSchema.properties).map(Ua=>Ut[Ua]);Fe=await mt(...za)}else if(N==="getState")Fe=mt();else if(N==="setState"){const ln=Ut.updates||Ut;Fe=await mt(ln)}else Fe=await mt(...Object.values(Ut));Oe({toolCallId:T.toolCallId,tool:N,output:Fe})}catch(Ut){Oe({toolCallId:T.toolCallId,tool:N,output:`Error: ${Ut}`})}})(),null;const ft=ts(T.input);return h.jsx(mn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(zh,{toolName:N,description:et?.description||"",args:ft,onApprove:async()=>{if(Ne.has(T.toolCallId))return;Ie(mt=>new Set(mt).add(T.toolCallId));const Rt=hi.get(N);if(Rt)try{const mt=await Rt(...Object.values(ft));Oe({toolCallId:T.toolCallId,tool:N,output:mt})}catch(mt){Oe({toolCallId:T.toolCallId,tool:N,output:`Error: ${mt}`})}},onDeny:async()=>{Ne.has(T.toolCallId)||(Ie(Rt=>new Set(Rt).add(T.toolCallId)),Oe({toolCallId:T.toolCallId,tool:N,output:"User denied tool execution"}))}})},`${T.toolCallId}-${O}`)}else if(zt){const ft=T.output==="User denied tool execution",Rt=ts(T.input);return h.jsx(Uh,{toolName:N,args:Rt,isDenied:ft,isSafe:fi.has(N)},`${T.toolCallId}-${O}`)}return null}if(T.type==="text"&&T.text){const N=Qh(T.text);return h.jsx(ai,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:N},`${p.id}-${O}`)}return T.type==="reasoning"&&T.text?h.jsxs(Aa,{className:"w-full",isStreaming:Pt==="streaming"&&O===p.parts.length-1&&p.id===Le.at(-1)?.id,children:[h.jsx(Ca,{}),h.jsx(Pa,{children:T.text})]},`${p.id}-${O}`):null})})})},p.id)}),h.jsx("div",{ref:Jt})]})}),pi&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",pi.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(ou,{mode:"wait",children:(Pt==="streaming"||Pt==="submitted")&&h.jsxs(mn,{initial:{opacity:0,filter:"blur(4px)",y:5},animate:{opacity:1,filter:"blur(0px)",y:0},exit:{opacity:0,filter:"blur(4px)",y:5},transition:{duration:.2,ease:"easeOut"},className:"absolute left-1/2 -translate-x-1/2 -top-6 flex items-center gap-1.5 bg-stone-100 dark:bg-stone-800 px-3 py-1.5 rounded-full shadow-lg border border-border z-50",children:[h.jsx(mn,{className:"w-2 h-2 bg-stone-400 dark:bg-stone-600",animate:{rotate:[0,0,90,90],borderRadius:["50%","30%","30%","50%"],scale:[.75,1,1,.75]},transition:{duration:2,repeat:1/0,ease:"easeInOut",times:[0,.4,.6,1]}}),h.jsx("p",{className:"text-xs text-muted-foreground",children:sn})]})}),h.jsxs("form",{onSubmit:gi,className:"relative",children:[h.jsx(Br,{ref:pe,value:ge,onChange:La,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(),gi(p))}}),Pt==="streaming"||Pt==="submitted"?h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(se({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:an,children:h.jsx(Y.Square,{className:"h-4 w-4"})})}),h.jsxs(ee,{children:[h.jsx(bi,{children:"Escape"})," to stop"]})]}):h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx("button",{type:"submit",className:Q(se({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!ge.trim(),children:h.jsx(Y.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(ee,{children:[h.jsx(bi,{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(Y.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),h.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function He(t){if(typeof t=="string")try{const e=JSON.parse(t);return He(e)}catch{return t}if(Array.isArray(t))return t.map(He);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=He(s);return e}return t}function ef(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return He(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?He(t):{}}function nf({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:o=[],safeTools:r=[],toolMetadata:a,systemPrompt:c="",initialMessages:u=[],conversationId:l,initialState:d={},onToolCall:f,onFinish:g,ragFilters:x}={}){const[v,C]=m.useState(n||null),y=m.useRef(n||null),[w,S]=m.useState(null),[E,M]=m.useState(null),j=m.useRef(null),[L,V]=m.useState([]),[F,G]=m.useState(l||(typeof window<"u"?crypto.randomUUID():null)),[J,z]=m.useState(!1),[le,At]=m.useState(new Set),[st,Ot]=m.useState(d),B=m.useRef(d),[it,rt]=m.useState(!1),[ct,ot]=m.useState(null),kt=m.useRef(!1),pt=m.useCallback(async(P,A=3)=>{if(!F||!y.current)return;const k=async()=>{const I=await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:F,updates:P},format:"json"})});if(!I.ok){const $=await I.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${I.status} ${$}`)}};for(let I=0;I<A;I++)try{await k(),ot(null);return}catch($){if(I===A-1){const tt=$ instanceof Error?$:new Error(String($));throw ot(tt),console.error("Failed to sync state to Convex after retries:",$),tt}await new Promise(tt=>setTimeout(tt,Math.pow(2,I)*100))}},[F,t,y]),ue=m.useMemo(()=>function(){return B.current},[]),Gt=m.useMemo(()=>async function(A){const k={...B.current,...A};B.current=k,Ot(k);try{await pt(A)}catch(I){throw I}},[pt]),Xt=m.useMemo(()=>[...o,...r,ue,Gt],[o,r,ue,Gt]),Ct=m.useMemo(()=>Ta(Xt,a),[Xt,a]),Dt=m.useMemo(()=>{const P=new Map,A=new Map(Ct.map(k=>[k.name,k]));return Xt.forEach(k=>{const I=k[jt];if(I){const _=A.get(I);if(_){P.set(_.name,k);return}}const $=Ct.find(_=>_.name===k.name);$&&P.set($.name,k)}),P},[Xt,Ct]),U=m.useMemo(()=>new Set(Ct.map(P=>P.name)),[Ct]),de=m.useMemo(()=>{const P=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}},{name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}];return[...Ct,...P]},[Ct]),dt=m.useMemo(()=>de.filter(P=>P.name==="getState"||P.name==="setState"?!0:U.has(P.name)),[de,U]),qt=m.useMemo(()=>{const P=new Set;return P.add("getState"),P.add("setState"),r.forEach(A=>{for(const[k,I]of Dt.entries())if(I===A){P.add(k);break}}),P},[r,Dt]);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 k=await A.json();C(k.clientToken),y.current=k.clientToken,M(k.expiresAt),S(null)}catch(A){console.error("[useAgent] Token fetch failed:",A),S(A instanceof Error?A.message:"Failed to fetch token")}})(),()=>{j.current&&clearTimeout(j.current)}),[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(!E||s||n)return;j.current&&clearTimeout(j.current);const P=Math.floor(Date.now()/1e3),A=E-P,I=Math.max(0,A-5);return j.current=setTimeout(async()=>{try{const $=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!$.ok)throw new Error("Failed to refresh token");const _=await $.json();C(_.clientToken),y.current=_.clientToken,M(_.expiresAt),S(null)}catch($){console.error("[useAgent] Token refresh failed:",$),S($ instanceof Error?$.message:"Failed to refresh token")}},I*1e3),()=>{j.current&&clearTimeout(j.current)}},[E,e,JSON.stringify(i),s,n]);const ht=async(P,A={})=>{const k=A.headers?new Headers(A.headers):new Headers;k.delete("user-agent"),k.delete("User-Agent"),console.log("[useAgent] Making request to:",P),console.log("[useAgent] Method:",A.method||"GET"),console.log("[useAgent] Has Authorization header:",k.has("Authorization")),console.log("[useAgent] Client token available:",!!y.current);try{const I=await fetch(P,{...A,headers:k});if(!I.ok){console.error("[useAgent] Request failed:",I.status,I.statusText);const $=await I.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",$)}return I}catch(I){throw console.error("[useAgent] Fetch error:",I),I}},he=`${t}/chat`;console.log("[useAgent] Chat API URL:",he);const{messages:bt,sendMessage:Ve,status:Yt,error:fe,stop:Dn,addToolResult:me,setMessages:Jt}=Lr.useChat({id:F||void 0,messages:u,transport:new bn.DefaultChatTransport({api:he,fetch:ht,headers:()=>{const P={};return y.current?(P.Authorization=`Bearer ${y.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),P},body:()=>{const P=dt.map(k=>({name:k.name,description:k.description,inputSchema:k.jsonSchema})),A=P.filter(k=>k.name==="getState"||k.name==="setState").map(k=>k.name);return A.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",A),{tools:P,systemPrompt:c,state:B.current,...x&&{ragFilters:x}}}}),sendAutomaticallyWhen:bn.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{bt.forEach(P=>{P.role==="assistant"&&P.parts.forEach(A=>{if(!A.type?.startsWith("tool-")||A.state!=="input-available")return;const k=A.type.replace("tool-",""),I=A.toolCallId;if(le.has(I))return;At(_=>new Set(_).add(I));const $=ef(A.input);if(qt.has(k)){const _=Dt.get(k);_?(async()=>{try{const tt=dt.find(Ft=>Ft.name===k);let lt;if(tt&&tt.jsonSchema?.properties){const Bt=Object.keys(tt.jsonSchema.properties).map(ye=>$[ye]);lt=await _(...Bt)}else if(k==="getState")lt=_();else if(k==="setState"){const Ft=$.updates||$;lt=await _(Ft)}else lt=await _(...Object.values($));me({toolCallId:I,tool:k,output:lt})}catch(tt){console.error(`[useAgent] Error executing tool ${k}:`,tt),me({toolCallId:I,tool:k,output:`Error: ${tt}`})}})():console.warn(`[useAgent] Tool ${k} not found in toolsMap`)}else f&&f({toolCall:{toolCallId:I,toolName:k,args:$}})})})},[bt,qt,Dt,f,me,le,Gt,dt]),m.useEffect(()=>{if(Yt==="ready"&&bt.length>0&&g){const P=bt[bt.length-1];P&&P.role==="assistant"&&g({message:P,messages:bt,isAbort:!1,isDisconnect:!1,isError:!!fe})}},[Yt,bt,fe,g]);async function pe(){if(!(!i?.id||!v)){z(!0);try{const A=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${v}`}})).json();V(A.conversations||[])}catch(P){console.error("Failed to fetch conversations:",P)}finally{z(!1)}}}m.useEffect(()=>{i?.id&&v&&pe()},[JSON.stringify(i),v,t]),m.useEffect(()=>{if(!F||!y.current)return;(async()=>{rt(!0),ot(null);try{const A=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:F},format:"json"})});if(!A.ok){const tt=await A.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${A.status} ${tt}`)}const I=(await A.json())?.value||{},$=!kt.current;let _;$?(_={...d,...I},kt.current=!0):_=I,B.current=_,Ot(_)}catch(A){console.error("Failed to fetch state:",A);const k=A instanceof Error?A:new Error(String(A));ot(k),kt.current||(B.current=d,Ot(d),kt.current=!0)}finally{rt(!1)}})()},[F,t]);async function ge(P){G(P),z(!0);try{const A=await fetch(`${t}/conversations/${P}/messages`,{headers:{Authorization:`Bearer ${y.current}`}});if(!A.ok)throw new Error(`Failed to fetch messages: ${A.statusText}`);const I=(await A.json()).messages||[];Jt(I)}catch(A){console.error("Failed to load conversation messages:",A)}finally{z(!1)}}async function Re(P){if(v)try{await fetch(`${t}/conversations/${P}`,{method:"DELETE",headers:{Authorization:`Bearer ${v}`}}),V(L.filter(A=>A._id!==P)),P===F&&sn()}catch(A){console.error("Failed to delete conversation:",A)}}function sn(){const P=crypto.randomUUID();G(P),Jt([]),At(new Set),B.current=d,Ot(d),kt.current=!1}function Vn(P){me(P)}async function Ne(P){const A={...B.current,...P};B.current=A,Ot(A);try{await pt(P)}catch(k){throw k}}async function Ie(){if(!i?.id||!y.current)throw new Error("User authentication required to share state");const P=`shared_${crypto.randomUUID()}`;try{return await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:create",args:{stateId:P,state:B.current,projectId:"default",createdBy:i.id},format:"json"})}),P}catch(A){throw console.error("Failed to share state:",A),A}}async function Rn(P){if(!y.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 ${y.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:P},format:"json"})});if(!A.ok)throw new Error("Failed to fetch shared state");const I=(await A.json())?.value||{};B.current=I,Ot(I)}catch(A){throw console.error("Failed to import state:",A),A}}return{id:F,messages:bt,status:Yt,error:fe,sendMessage:Ve,stop:Dn,addToolOutput:Vn,setMessages:Jt,conversations:L,loadConversation:ge,deleteConversation:Re,startNewConversation:sn,isLoadingConversations:J,clientToken:v,tokenError:w,state:st,setState:Ne,shareState:Ie,importState:Rn,isStateLoading:it,stateError:ct}}exports.verifyToken=tc.verifyToken;exports.ARCTEN_ORIGINAL_NAME=jt;exports.ArctenAgent=tf;exports.preserveToolName=Bh;exports.useAgent=nf;
|