@arcteninc/core 0.0.41 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +7 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1236 -1214
- package/dist/utils/extract-tool-metadata.d.ts +15 -0
- package/dist/utils/extract-tool-metadata.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var xa=Object.create;var Hs=Object.defineProperty;var va=Object.getOwnPropertyDescriptor;var ba=Object.getOwnPropertyNames;var wa=Object.getPrototypeOf,Ta=Object.prototype.hasOwnProperty;var Sa=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ba(e))!Ta.call(t,i)&&i!==n&&Hs(t,i,{get:()=>e[i],enumerable:!(s=va(e,i))||s.enumerable});return t};var Ca=(t,e,n)=>(n=t!=null?xa(wa(t)):{},Sa(e||!t||!t.__esModule?Hs(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),q=require("lucide-react"),uo=require("@ai-sdk/react"),Ye=require("ai"),ho=require("@radix-ui/react-slot"),fo=require("class-variance-authority"),Aa=require("clsx"),Pa=require("tailwind-merge"),Ma=require("@radix-ui/react-tooltip"),Xs=require("@radix-ui/react-use-controllable-state"),ja=require("@radix-ui/react-collapsible"),Da=require("./server.cjs");function qn(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const ft=qn(m),ne=qn(Ma),Zn=qn(ja);function Q(...t){return Pa.twMerge(Aa.clsx(t))}const zt=fo.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),Ge=ft.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},r)=>{const o=s?ho.Slot:"button";return h.jsx(o,{ref:r,"data-slot":"button",className:Q(zt({variant:e,size:n,className:t})),...i})});Ge.displayName="Button";const Va=fo.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function dn({className:t,variant:e,asChild:n=!1,...s}){const i=n?ho.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:Q(Va({variant:e}),t),...s})}const Ea=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=ft.useState(!0);ft.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),r(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[t.current,e])},mo=ft.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...r},o)=>{const a=ft.useRef(null),[l,u]=ft.useState("");return Ea({textAreaRef:a,triggerAutoSize:l,maxHeight:t,minHeight:e}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),ft.useEffect(()=>{u(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,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:c=>{u(c.target.value),s?.(c)}})});mo.displayName="AutosizeTextarea";function ka({delayDuration:t=0,...e}){return h.jsx(ne.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Ot({...t}){return h.jsx(ka,{children:h.jsx(ne.Root,{"data-slot":"tooltip",...t})})}function Ft({...t}){return h.jsx(ne.Trigger,{"data-slot":"tooltip-trigger",...t})}function Bt({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(ne.Portal,{children:h.jsxs(ne.Content,{"data-slot":"tooltip-content",sideOffset:e,className: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(ne.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Ys({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className: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 Jn=m.createContext({});function Qn(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const ts=typeof window<"u",po=ts?m.useLayoutEffect:m.useEffect,en=m.createContext(null);function es(t,e){t.indexOf(e)===-1&&t.push(e)}function ns(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Tt=(t,e,n)=>n>e?e:n<t?t:n;function Mn(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let re=()=>{},St=()=>{};process.env.NODE_ENV!=="production"&&(re=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(Mn(e,n))},St=(t,e,n)=>{if(!t)throw new Error(Mn(e,n))});const Ct={},go=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function yo(t){return typeof t=="object"&&t!==null}const xo=t=>/^0[^.\s]+$/u.test(t);function ss(t){let e;return()=>(e===void 0&&(e=t()),e)}const ut=t=>t,Ra=(t,e)=>n=>e(t(n)),De=(...t)=>t.reduce(Ra),Se=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class is{constructor(){this.subscriptions=[]}add(e){return es(this.subscriptions,e),()=>ns(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let r=0;r<i;r++){const o=this.subscriptions[r];o&&o(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const mt=t=>t*1e3,ct=t=>t/1e3;function vo(t,e){return e?t*(1e3/e):0}const Gs=new Set;function os(t,e,n){t||Gs.has(e)||(console.warn(Mn(e,n)),Gs.add(e))}const bo=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Na=1e-7,Ia=12;function La(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=bo(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>Na&&++a<Ia);return o}function Ve(t,e,n,s){if(t===e&&n===s)return ut;const i=r=>La(r,0,1,t,n);return r=>r===0||r===1?r:bo(i(r),e,s)}const wo=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,To=t=>e=>1-t(1-e),So=Ve(.33,1.53,.69,.99),rs=To(So),Co=wo(rs),Ao=t=>(t*=2)<1?.5*rs(t):.5*(2-Math.pow(2,-10*(t-1))),as=t=>1-Math.sin(Math.acos(t)),Po=To(as),Mo=wo(as),Oa=Ve(.42,0,1,1),Fa=Ve(0,0,.58,1),jo=Ve(.42,0,.58,1),Ba=t=>Array.isArray(t)&&typeof t[0]!="number",Do=t=>Array.isArray(t)&&typeof t[0]=="number",qs={linear:ut,easeIn:Oa,easeInOut:jo,easeOut:Fa,circIn:as,circInOut:Mo,circOut:Po,backIn:rs,backInOut:Co,backOut:So,anticipate:Ao},$a=t=>typeof t=="string",Zs=t=>{if(Do(t)){St(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return Ve(e,n,s,i)}else if($a(t))return St(qs[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),qs[t];return t},Fe=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function za(t,e){let n=new Set,s=new Set,i=!1,r=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(c){o.has(c)&&(u.schedule(c),t()),c(a)}const u={schedule:(c,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(c),y.has(c)||y.add(c),c},cancel:c=>{s.delete(c),o.delete(c)},process:c=>{if(a=c,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,u.process(c))}};return u}const Ua=40;function Vo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Fe.reduce((b,k)=>(b[k]=za(r),b),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:c,update:d,preRender:f,render:g,postRender:y}=o,v=()=>{const b=Ct.useManualTiming?i.timestamp:performance.now();n=!1,Ct.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(b-i.timestamp,Ua),1)),i.timestamp=b,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),c.process(i),d.process(i),f.process(i),g.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},w=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:Fe.reduce((b,k)=>{const A=o[k];return b[k]=(V,R=!1,P=!1)=>(n||w(),A.schedule(V,R,P)),b},{}),cancel:b=>{for(let k=0;k<Fe.length;k++)o[Fe[k]].cancel(b)},state:i,steps:o}}const{schedule:F,cancel:Dt,state:J,steps:hn}=Vo(typeof requestAnimationFrame<"u"?requestAnimationFrame:ut,!0);let _e;function _a(){_e=void 0}const it={now:()=>(_e===void 0&&it.set(J.isProcessing||Ct.useManualTiming?J.timestamp:performance.now()),_e),set:t=>{_e=t,queueMicrotask(_a)}},Eo=t=>e=>typeof e=="string"&&e.startsWith(t),ls=Eo("--"),Wa=Eo("var(--"),cs=t=>Wa(t)?Ka.test(t.split("/*")[0].trim()):!1,Ka=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ae={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Ce={...ae,transform:t=>Tt(0,1,t)},Be={...ae,default:1},ve=t=>Math.round(t*1e5)/1e5,us=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ha(t){return t==null}const Xa=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ds=(t,e)=>n=>!!(typeof n=="string"&&Xa.test(n)&&n.startsWith(t)||e&&!Ha(n)&&Object.prototype.hasOwnProperty.call(n,e)),ko=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(us);return{[t]:parseFloat(i),[e]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Ya=t=>Tt(0,255,t),fn={...ae,transform:t=>Math.round(Ya(t))},_t={test:ds("rgb","red"),parse:ko("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+fn.transform(t)+", "+fn.transform(e)+", "+fn.transform(n)+", "+ve(Ce.transform(s))+")"};function Ga(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const jn={test:ds("#"),parse:Ga,transform:_t.transform},Ee=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),jt=Ee("deg"),bt=Ee("%"),D=Ee("px"),qa=Ee("vh"),Za=Ee("vw"),Js={...bt,parse:t=>bt.parse(t)/100,transform:t=>bt.transform(t*100)},qt={test:ds("hsl","hue"),parse:ko("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+bt.transform(ve(e))+", "+bt.transform(ve(n))+", "+ve(Ce.transform(s))+")"},Y={test:t=>_t.test(t)||jn.test(t)||qt.test(t),parse:t=>_t.test(t)?_t.parse(t):qt.test(t)?qt.parse(t):jn.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?_t.transform(t):qt.transform(t),getAnimatableNone:t=>{const e=Y.parse(t);return e.alpha=0,Y.transform(e)}},Ja=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Qa(t){return isNaN(t)&&typeof t=="string"&&(t.match(us)?.length||0)+(t.match(Ja)?.length||0)>0}const Ro="number",No="color",tl="var",el="var(",Qs="${}",nl=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ae(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(nl,l=>(Y.test(l)?(s.color.push(r),i.push(No),n.push(Y.parse(l))):l.startsWith(el)?(s.var.push(r),i.push(tl),n.push(l)):(s.number.push(r),i.push(Ro),n.push(parseFloat(l))),++r,Qs)).split(Qs);return{values:n,split:a,indexes:s,types:i}}function Io(t){return Ae(t).values}function Lo(t){const{split:e,types:n}=Ae(t),s=e.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=e[o],i[o]!==void 0){const a=n[o];a===Ro?r+=ve(i[o]):a===No?r+=Y.transform(i[o]):r+=i[o]}return r}}const sl=t=>typeof t=="number"?0:Y.test(t)?Y.getAnimatableNone(t):t;function il(t){const e=Io(t);return Lo(t)(e.map(sl))}const Vt={test:Qa,parse:Io,createTransformer:Lo,getAnimatableNone:il};function mn(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function ol({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,r=0,o=0;if(!e)i=r=o=n;else{const a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;i=mn(l,a,t+1/3),r=mn(l,a,t),o=mn(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function qe(t,e){return n=>n>0?e:t}const z=(t,e,n)=>t+(e-t)*n,pn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},rl=[jn,_t,qt],al=t=>rl.find(e=>e.test(t));function ti(t){const e=al(t);if(re(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===qt&&(n=ol(n)),n}const ei=(t,e)=>{const n=ti(t),s=ti(e);if(!n||!s)return qe(t,e);const i={...n};return r=>(i.red=pn(n.red,s.red,r),i.green=pn(n.green,s.green,r),i.blue=pn(n.blue,s.blue,r),i.alpha=z(n.alpha,s.alpha,r),_t.transform(i))},Dn=new Set(["none","hidden"]);function ll(t,e){return Dn.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function cl(t,e){return n=>z(t,e,n)}function hs(t){return typeof t=="number"?cl:typeof t=="string"?cs(t)?qe:Y.test(t)?ei:hl:Array.isArray(t)?Oo:typeof t=="object"?Y.test(t)?ei:ul:qe}function Oo(t,e){const n=[...t],s=n.length,i=t.map((r,o)=>hs(r)(r,e[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function ul(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=hs(t[i])(t[i],e[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function dl(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const r=e.types[i],o=t.indexes[r][s[r]],a=t.values[o]??0;n[i]=a,s[r]++}return n}const hl=(t,e)=>{const n=Vt.createTransformer(e),s=Ae(t),i=Ae(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?Dn.has(t)&&!i.values.length||Dn.has(e)&&!s.values.length?ll(t,e):De(Oo(dl(s,i),i.values),n):(re(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),qe(t,e))};function Fo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?z(t,e,n):hs(t)(t,e)}const fl=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>F.update(e,n),stop:()=>Dt(e),now:()=>J.isProcessing?J.timestamp:it.now()}},Bo=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let r=0;r<i;r++)s+=Math.round(t(r/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Ze=2e4;function fs(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Ze;)e+=n,s=t.next(e);return e>=Ze?1/0:e}function ml(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(fs(s),Ze);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:ct(i)}}const pl=5;function $o(t,e,n){const s=Math.max(e-pl,0);return vo(n-t(s),e-s)}const $={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},gn=.001;function gl({duration:t=$.duration,bounce:e=$.bounce,velocity:n=$.velocity,mass:s=$.mass}){let i,r;re(t<=mt($.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=Tt($.minDamping,$.maxDamping,o),t=Tt($.minDuration,$.maxDuration,ct(t)),o<1?(i=u=>{const c=u*o,d=c*t,f=c-n,g=Vn(u,o),y=Math.exp(-d);return gn-f/g*y},r=u=>{const d=u*o*t,f=d*n+n,g=Math.pow(o,2)*Math.pow(u,2)*t,y=Math.exp(-d),v=Vn(Math.pow(u,2),o);return(-i(u)+gn>0?-1:1)*((f-g)*y)/v}):(i=u=>{const c=Math.exp(-u*t),d=(u-n)*t+1;return-gn+c*d},r=u=>{const c=Math.exp(-u*t),d=(n-u)*(t*t);return c*d});const a=5/t,l=xl(i,r,a);if(t=mt(t),isNaN(l))return{stiffness:$.stiffness,damping:$.damping,duration:t};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:o*2*Math.sqrt(s*u),duration:t}}}const yl=12;function xl(t,e,n){let s=n;for(let i=1;i<yl;i++)s=s-t(s)/e(s);return s}function Vn(t,e){return t*Math.sqrt(1-e*e)}const vl=["duration","bounce"],bl=["stiffness","damping","mass"];function ni(t,e){return e.some(n=>t[n]!==void 0)}function wl(t){let e={velocity:$.velocity,stiffness:$.stiffness,damping:$.damping,mass:$.mass,isResolvedFromDuration:!1,...t};if(!ni(t,bl)&&ni(t,vl))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*Tt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:$.mass,stiffness:i,damping:r}}else{const n=gl(t);e={...e,...n,mass:$.mass},e.isResolvedFromDuration=!0}return e}function Je(t=$.visualDuration,e=$.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:l,damping:u,mass:c,duration:d,velocity:f,isResolvedFromDuration:g}=wl({...n,velocity:-ct(n.velocity||0)}),y=f||0,v=u/(2*Math.sqrt(l*c)),w=o-r,x=ct(Math.sqrt(l/c)),S=Math.abs(w)<5;s||(s=S?$.restSpeed.granular:$.restSpeed.default),i||(i=S?$.restDelta.granular:$.restDelta.default);let b;if(v<1){const A=Vn(x,v);b=V=>{const R=Math.exp(-v*x*V);return o-R*((y+v*x*w)/A*Math.sin(A*V)+w*Math.cos(A*V))}}else if(v===1)b=A=>o-Math.exp(-x*A)*(w+(y+x*w)*A);else{const A=x*Math.sqrt(v*v-1);b=V=>{const R=Math.exp(-v*x*V),P=Math.min(A*V,300);return o-R*((y+v*x*w)*Math.sinh(P)+A*w*Math.cosh(P))/A}}const k={calculatedDuration:g&&d||null,next:A=>{const V=b(A);if(g)a.done=A>=d;else{let R=A===0?y:0;v<1&&(R=A===0?mt(y):$o(b,A,V));const P=Math.abs(R)<=s,N=Math.abs(o-V)<=i;a.done=P&&N}return a.value=a.done?o:V,a},toString:()=>{const A=Math.min(fs(k),Ze),V=Bo(R=>k.next(A*R).value,A,30);return A+"ms "+V},toTransition:()=>{}};return k}Je.applyToOptions=t=>{const e=ml(t,100,Je);return t.ease=e.ease,t.duration=mt(e.duration),t.type="keyframes",t};function En({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:u=.5,restSpeed:c}){const d=t[0],f={done:!1,value:d},g=P=>a!==void 0&&P<a||l!==void 0&&P>l,y=P=>a===void 0?l:l===void 0||Math.abs(a-P)<Math.abs(l-P)?a:l;let v=n*e;const w=d+v,x=o===void 0?w:o(w);x!==w&&(v=x-d);const S=P=>-v*Math.exp(-P/s),b=P=>x+S(P),k=P=>{const N=S(P),W=b(P);f.done=Math.abs(N)<=u,f.value=f.done?x:W};let A,V;const R=P=>{g(f.value)&&(A=P,V=Je({keyframes:[f.value,y(f.value)],velocity:$o(b,P,f.value),damping:i,stiffness:r,restDelta:u,restSpeed:c}))};return R(0),{calculatedDuration:null,next:P=>{let N=!1;return!V&&A===void 0&&(N=!0,k(P),R(P)),A!==void 0&&P>=A?V.next(P-A):(!N&&k(P),f)}}}function Tl(t,e,n){const s=[],i=n||Ct.mix||Fo,r=t.length-1;for(let o=0;o<r;o++){let a=i(t[o],t[o+1]);if(e){const l=Array.isArray(e)?e[o]||ut:e;a=De(l,a)}s.push(a)}return s}function Sl(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(St(r===e.length,"Both input and output ranges must be the same length","range-length"),r===1)return()=>e[0];if(r===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[r-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Tl(e,s,i),l=a.length,u=c=>{if(o&&c<t[0])return e[0];let d=0;if(l>1)for(;d<t.length-2&&!(c<t[d+1]);d++);const f=Se(t[d],t[d+1],c);return a[d](f)};return n?c=>u(Tt(t[0],t[r-1],c)):u}function Cl(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Se(0,e,s);t.push(z(n,1,i))}}function Al(t){const e=[0];return Cl(e,t.length-1),e}function Pl(t,e){return t.map(n=>n*e)}function Ml(t,e){return t.map(()=>e||jo).splice(0,t.length-1)}function Zt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=Ba(s)?s.map(Zs):Zs(s),r={done:!1,value:e[0]},o=Pl(n&&n.length===e.length?n:Al(e),t),a=Sl(o,e,{ease:Array.isArray(i)?i:Ml(e,i)});return{calculatedDuration:t,next:l=>(r.value=a(l),r.done=l>=t,r)}}const jl=t=>t!==null;function ms(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(jl),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Dl={decay:En,inertia:En,tween:Zt,keyframes:Zt,spring:Je};function zo(t){typeof t.type=="string"&&(t.type=Dl[t.type])}class ps{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const Vl=t=>t/100;class gs extends ps{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==it.now()&&this.tick(it.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;zo(e);const{type:n=Zt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const l=n||Zt;process.env.NODE_ENV!=="production"&&l!==Zt&&St(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Zt&&typeof a[0]!="number"&&(this.mixKeyframes=De(Vl,Fo(a[0],a[1])),a=[0,100]);const u=l({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-o})),u.calculatedDuration===null&&(u.calculatedDuration=fs(u));const{calculatedDuration:c}=u;this.calculatedDuration=c,this.resolvedDuration=c+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:r,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:c,repeat:d,repeatType:f,repeatDelay:g,type:y,onUpdate:v,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const x=this.currentTime-u*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?x<0:x>i;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let b=this.currentTime,k=s;if(d){const P=Math.min(this.currentTime,i)/a;let N=Math.floor(P),W=P%1;!W&&P>=1&&(W=1),W===1&&N--,N=Math.min(N,d+1),!!(N%2)&&(f==="reverse"?(W=1-W,g&&(W-=g/a)):f==="mirror"&&(k=o)),b=Tt(0,1,W)*a}const A=S?{done:!1,value:c[0]}:k.next(b);r&&(A.value=r(A.value));let{done:V}=A;!S&&l!==null&&(V=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const R=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&V);return R&&y!==En&&(A.value=ms(c,this.options,w,this.speed)),v&&v(A.value),R&&this.finish(),A}then(e,n){return this.finished.then(e,n)}get duration(){return ct(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ct(e)}get time(){return ct(this.currentTime)}set time(e){e=mt(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(it.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=ct(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=fl,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(it.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function El(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Wt=t=>t*180/Math.PI,kn=t=>{const e=Wt(Math.atan2(t[1],t[0]));return Rn(e)},kl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:kn,rotateZ:kn,skewX:t=>Wt(Math.atan(t[1])),skewY:t=>Wt(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Rn=t=>(t=t%360,t<0&&(t+=360),t),si=kn,ii=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),oi=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Rl={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ii,scaleY:oi,scale:t=>(ii(t)+oi(t))/2,rotateX:t=>Rn(Wt(Math.atan2(t[6],t[5]))),rotateY:t=>Rn(Wt(Math.atan2(-t[2],t[0]))),rotateZ:si,rotate:si,skewX:t=>Wt(Math.atan(t[4])),skewY:t=>Wt(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Nn(t){return t.includes("scale")?1:0}function In(t,e){if(!t||t==="none")return Nn(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Rl,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=kl,i=a}if(!i)return Nn(e);const r=s[e],o=i[1].split(",").map(Il);return typeof r=="function"?r(o):o[r]}const Nl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return In(n,e)};function Il(t){return parseFloat(t.trim())}const le=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ce=new Set(le),ri=t=>t===ae||t===D,Ll=new Set(["x","y","z"]),Ol=le.filter(t=>!Ll.has(t));function Fl(t){const e=[];return Ol.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const Kt={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>In(e,"x"),y:(t,{transform:e})=>In(e,"y")};Kt.translateX=Kt.x;Kt.translateY=Kt.y;const Ht=new Set;let Ln=!1,On=!1,Fn=!1;function Uo(){if(On){const t=Array.from(Ht).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Fl(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([r,o])=>{s.getValue(r)?.set(o)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}On=!1,Ln=!1,Ht.forEach(t=>t.complete(Fn)),Ht.clear()}function _o(){Ht.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(On=!0)})}function Bl(){Fn=!0,_o(),Uo(),Fn=!1}class ys{constructor(e,n,s,i,r,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Ht.add(this),Ln||(Ln=!0,F.read(_o),F.resolveKeyframes(Uo))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const r=i?.get(),o=e[e.length-1];if(r!==void 0)e[0]=r;else if(s&&n){const a=s.readValue(n,o);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=o),i&&r===void 0&&i.set(e[0])}El(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ht.delete(this)}cancel(){this.state==="scheduled"&&(Ht.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const $l=t=>t.startsWith("--");function zl(t,e,n){$l(e)?t.style.setProperty(e,n):t.style[e]=n}const Ul=ss(()=>window.ScrollTimeline!==void 0),_l={};function Wl(t,e){const n=ss(t);return()=>_l[e]??n()}const Wo=Wl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),xe=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,ai={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:xe([0,.65,.55,1]),circOut:xe([.55,0,1,.45]),backIn:xe([.31,.01,.66,-.59]),backOut:xe([.33,1.53,.69,.99])};function Ko(t,e){if(t)return typeof t=="function"?Wo()?Bo(t,e):"ease-out":Do(t)?xe(t):Array.isArray(t)?t.map(n=>Ko(n,e)||ai.easeOut):ai[t]}function Kl(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},u=void 0){const c={[e]:n};l&&(c.offset=l);const d=Ko(a,i);Array.isArray(d)&&(c.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(c,f)}function Ho(t){return typeof t=="function"&&"applyToOptions"in t}function Hl({type:t,...e}){return Ho(t)&&Wo()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Xl extends ps{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:r,allowFlatten:o=!1,finalKeyframe:a,onComplete:l}=e;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=e,St(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=Hl(e);this.animation=Kl(n,s,i,u,r),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const c=ms(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(c):zl(n,s,c),this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return ct(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ct(e)}get time(){return ct(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=mt(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&Ul()?(this.animation.timeline=e,ut):n(this)}}const Xo={anticipate:Ao,backInOut:Co,circInOut:Mo};function Yl(t){return t in Xo}function Gl(t){typeof t.ease=="string"&&Yl(t.ease)&&(t.ease=Xo[t.ease])}const li=10;class ql extends Xl{constructor(e){Gl(e),zo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:r,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new gs({...o,autoplay:!1}),l=mt(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-li).value,a.sample(l).value,li),a.stop()}}const ci=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Vt.test(t)||t==="0")&&!t.startsWith("url("));function Zl(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function Jl(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const r=t[t.length-1],o=ci(i,e),a=ci(r,e);return re(o===a,`You are trying to animate ${e} from "${i}" to "${r}". "${o?r:i}" is not an animatable value.`,"value-not-animatable"),!o||!a?!1:Zl(t)||(n==="spring"||Ho(n))&&s}function Bn(t){t.duration=0,t.type="keyframes"}const Ql=new Set(["opacity","clipPath","filter","transform"]),tc=ss(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function ec(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:r,type:o}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=e.owner.getProps();return tc()&&n&&Ql.has(n)&&(n!=="transform"||!u)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const nc=40;class sc extends ps{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:u,element:c,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=it.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:l,motionValue:u,element:c,...d},g=c?.KeyframeResolver||ys;this.keyframeResolver=new g(a,(y,v,w)=>this.onKeyframesResolved(y,v,f,!w),l,u,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:u,onUpdate:c}=s;this.resolvedAt=it.now(),Jl(e,r,o,a)||((Ct.instantAnimations||!l)&&c?.(ms(e,s,n)),e[0]=e[e.length-1],Bn(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>nc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&ec(f)?new ql({...f,element:f.motionValue.owner.current}):new gs(f);g.finished.then(()=>this.notifyFinished()).catch(ut),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Bl()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const ic=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function oc(t){const e=ic.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const rc=4;function Yo(t,e,n=1){St(n<=rc,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=oc(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const o=r.trim();return go(o)?parseFloat(o):o}return cs(i)?Yo(i,e,n+1):i}function xs(t,e){return t?.[e]??t?.default??t}const Go=new Set(["width","height","top","left","right","bottom",...le]),ac={test:t=>t==="auto",parse:t=>t},qo=t=>e=>e.test(t),Zo=[ae,D,bt,jt,Za,qa,ac],ui=t=>Zo.find(qo(t));function lc(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||xo(t):!0}const cc=new Set(["brightness","contrast","saturate","opacity"]);function uc(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(us)||[];if(!s)return t;const i=n.replace(s,"");let r=cc.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const dc=/\b([a-z-]*)\(.*?\)/gu,$n={...Vt,getAnimatableNone:t=>{const e=t.match(dc);return e?e.map(uc).join(" "):t}},di={...ae,transform:Math.round},hc={rotate:jt,rotateX:jt,rotateY:jt,rotateZ:jt,scale:Be,scaleX:Be,scaleY:Be,scaleZ:Be,skew:jt,skewX:jt,skewY:jt,distance:D,translateX:D,translateY:D,translateZ:D,x:D,y:D,z:D,perspective:D,transformPerspective:D,opacity:Ce,originX:Js,originY:Js,originZ:D},vs={borderWidth:D,borderTopWidth:D,borderRightWidth:D,borderBottomWidth:D,borderLeftWidth:D,borderRadius:D,radius:D,borderTopLeftRadius:D,borderTopRightRadius:D,borderBottomRightRadius:D,borderBottomLeftRadius:D,width:D,maxWidth:D,height:D,maxHeight:D,top:D,right:D,bottom:D,left:D,padding:D,paddingTop:D,paddingRight:D,paddingBottom:D,paddingLeft:D,margin:D,marginTop:D,marginRight:D,marginBottom:D,marginLeft:D,backgroundPositionX:D,backgroundPositionY:D,...hc,zIndex:di,fillOpacity:Ce,strokeOpacity:Ce,numOctaves:di},fc={...vs,color:Y,backgroundColor:Y,outlineColor:Y,fill:Y,stroke:Y,borderColor:Y,borderTopColor:Y,borderRightColor:Y,borderBottomColor:Y,borderLeftColor:Y,filter:$n,WebkitFilter:$n},Jo=t=>fc[t];function Qo(t,e){let n=Jo(t);return n!==$n&&(n=Vt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const mc=new Set(["auto","none","0"]);function pc(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!mc.has(r)&&Ae(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=Qo(n,i)}class gc extends ys{constructor(e,n,s,i,r){super(e,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<e.length;l++){let u=e[l];if(typeof u=="string"&&(u=u.trim(),cs(u))){const c=Yo(u,n.current);c!==void 0&&(e[l]=c),l===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!Go.has(s)||e.length!==2)return;const[i,r]=e,o=ui(i),a=ui(r);if(o!==a)if(ri(o)&&ri(a))for(let l=0;l<e.length;l++){const u=e[l];typeof u=="string"&&(e[l]=parseFloat(u))}else Kt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||lc(e[i]))&&s.push(i);s.length&&pc(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Kt[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const r=s.length-1,o=s[r];s[r]=Kt[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{e.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function yc(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const tr=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function er(t){return yo(t)&&"offsetHeight"in t}const hi=30,xc=t=>!isNaN(parseFloat(t));class vc{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=it.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const r of this.dependents)r.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=it.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=xc(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&os(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new is);const s=this.events[e].add(n);return e==="change"?()=>{s(),F.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=it.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>hi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,hi);return vo(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function ie(t,e){return new vc(t,e)}const{schedule:bs}=Vo(queueMicrotask,!1),ht={x:!1,y:!1};function nr(){return ht.x||ht.y}function bc(t){return t==="x"||t==="y"?ht[t]?null:(ht[t]=!0,()=>{ht[t]=!1}):ht.x||ht.y?null:(ht.x=ht.y=!0,()=>{ht.x=ht.y=!1})}function sr(t,e){const n=yc(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function fi(t){return!(t.pointerType==="touch"||nr())}function wc(t,e,n={}){const[s,i,r]=sr(t,n),o=a=>{if(!fi(a))return;const{target:l}=a,u=e(l,a);if(typeof u!="function"||!l)return;const c=d=>{fi(d)&&(u(d),l.removeEventListener("pointerleave",c))};l.addEventListener("pointerleave",c,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const ir=(t,e)=>e?t===e?!0:ir(t,e.parentElement):!1,ws=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Tc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Sc(t){return Tc.has(t.tagName)||t.tabIndex!==-1}const We=new WeakSet;function mi(t){return e=>{e.key==="Enter"&&t(e)}}function yn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Cc=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=mi(()=>{if(We.has(n))return;yn(n,"down");const i=mi(()=>{yn(n,"up")}),r=()=>yn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",r,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function pi(t){return ws(t)&&!nr()}function Ac(t,e,n={}){const[s,i,r]=sr(t,n),o=a=>{const l=a.currentTarget;if(!pi(a))return;We.add(l);const u=e(l,a),c=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),We.has(l)&&We.delete(l),pi(g)&&typeof u=="function"&&u(g,{success:y})},d=g=>{c(g,l===window||l===document||n.useGlobalTarget||ir(l,g.target))},f=g=>{c(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),er(a)&&(a.addEventListener("focus",u=>Cc(u,i)),!Sc(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function or(t){return yo(t)&&"ownerSVGElement"in t}function Pc(t){return or(t)&&t.tagName==="svg"}const et=t=>!!(t&&t.getVelocity),Mc=[...Zo,Y,Vt],jc=t=>Mc.find(qo(t)),Ts=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function gi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Dc(...t){return e=>{let n=!1;const s=t.map(i=>{const r=gi(i,e);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<s.length;i++){const r=s[i];typeof r=="function"?r():gi(t[i],null)}}}}function Vc(...t){return ft.useCallback(Dc(...t),t)}class Ec extends ft.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=er(s)&&s.offsetWidth||0,r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft,r.right=i-r.width-r.left}return null}componentDidUpdate(){}render(){return this.props.children}}function kc({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),r=m.useRef(null),o=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Ts),l=Vc(r,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:c,top:d,left:f,right:g}=o.current;if(e||!r.current||!u||!c)return;const y=n==="left"?`left: ${f}`:`right: ${g}`;r.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const w=s??document.head;return w.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
1
|
+
"use strict";var va=Object.create;var Xs=Object.defineProperty;var ba=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var Ta=Object.getPrototypeOf,Sa=Object.prototype.hasOwnProperty;var Ca=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of wa(t))!Sa.call(e,i)&&i!==n&&Xs(e,i,{get:()=>t[i],enumerable:!(s=ba(t,i))||s.enumerable});return e};var Aa=(e,t,n)=>(n=e!=null?va(Ta(e)):{},Ca(t||!e||!e.__esModule?Xs(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),q=require("lucide-react"),ho=require("@ai-sdk/react"),Yt=require("ai"),fo=require("@radix-ui/react-slot"),mo=require("class-variance-authority"),Pa=require("clsx"),Ma=require("tailwind-merge"),ja=require("@radix-ui/react-tooltip"),Gs=require("@radix-ui/react-use-controllable-state"),Ea=require("@radix-ui/react-collapsible"),Da=require("./server.cjs");function Zn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const fe=Zn(m),nt=Zn(ja),Jn=Zn(Ea);function Q(...e){return Ma.twMerge(Pa.clsx(e))}const ze=mo.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),qt=fe.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...i},r)=>{const o=s?fo.Slot:"button";return h.jsx(o,{ref:r,"data-slot":"button",className:Q(ze({variant:t,size:n,className:e})),...i})});qt.displayName="Button";const Va=mo.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function hn({className:e,variant:t,asChild:n=!1,...s}){const i=n?fo.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:Q(Va({variant:t}),e),...s})}const ka=({textAreaRef:e,triggerAutoSize:t,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=fe.useState(!0);fe.useEffect(()=>{const a=e.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),r(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[e.current,t])},po=fe.forwardRef(({maxHeight:e=Number.MAX_SAFE_INTEGER,minHeight:t=52,className:n,onChange:s,value:i,...r},o)=>{const a=fe.useRef(null),[l,u]=fe.useState("");return ka({textAreaRef:a,triggerAutoSize:l,maxHeight:e,minHeight:t}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:e,minHeight:t})),fe.useEffect(()=>{u(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,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:c=>{u(c.target.value),s?.(c)}})});po.displayName="AutosizeTextarea";function Ra({delayDuration:e=0,...t}){return h.jsx(nt.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Oe({...e}){return h.jsx(Ra,{children:h.jsx(nt.Root,{"data-slot":"tooltip",...e})})}function Fe({...e}){return h.jsx(nt.Trigger,{"data-slot":"tooltip-trigger",...e})}function Be({className:e,sideOffset:t=0,children:n,...s}){return h.jsx(nt.Portal,{children:h.jsxs(nt.Content,{"data-slot":"tooltip-content",sideOffset:t,className: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",e),...s,children:[n,h.jsx(nt.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Ys({className:e,...t}){return h.jsx("kbd",{"data-slot":"kbd",className: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",e),...t})}const Qn=m.createContext({});function es(e){const t=m.useRef(null);return t.current===null&&(t.current=e()),t.current}const ts=typeof window<"u",go=ts?m.useLayoutEffect:m.useEffect,nn=m.createContext(null);function ns(e,t){e.indexOf(t)===-1&&e.push(t)}function ss(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const Te=(e,t,n)=>n>t?t:n<e?e:n;function jn(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let rt=()=>{},Se=()=>{};process.env.NODE_ENV!=="production"&&(rt=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(jn(t,n))},Se=(e,t,n)=>{if(!e)throw new Error(jn(t,n))});const Ce={},yo=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function xo(e){return typeof e=="object"&&e!==null}const vo=e=>/^0[^.\s]+$/u.test(e);function is(e){let t;return()=>(t===void 0&&(t=e()),t)}const ue=e=>e,Na=(e,t)=>n=>t(e(n)),Dt=(...e)=>e.reduce(Na),St=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class os{constructor(){this.subscriptions=[]}add(t){return ns(this.subscriptions,t),()=>ss(this.subscriptions,t)}notify(t,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,s);else for(let r=0;r<i;r++){const o=this.subscriptions[r];o&&o(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const me=e=>e*1e3,ce=e=>e/1e3;function bo(e,t){return t?e*(1e3/t):0}const qs=new Set;function rs(e,t,n){e||qs.has(t)||(console.warn(jn(t,n)),qs.add(t))}const wo=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Ia=1e-7,La=12;function Oa(e,t,n,s,i){let r,o,a=0;do o=t+(n-t)/2,r=wo(o,s,i)-e,r>0?n=o:t=o;while(Math.abs(r)>Ia&&++a<La);return o}function Vt(e,t,n,s){if(e===t&&n===s)return ue;const i=r=>Oa(r,0,1,e,n);return r=>r===0||r===1?r:wo(i(r),t,s)}const To=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,So=e=>t=>1-e(1-t),Co=Vt(.33,1.53,.69,.99),as=So(Co),Ao=To(as),Po=e=>(e*=2)<1?.5*as(e):.5*(2-Math.pow(2,-10*(e-1))),ls=e=>1-Math.sin(Math.acos(e)),Mo=So(ls),jo=To(ls),Fa=Vt(.42,0,1,1),Ba=Vt(0,0,.58,1),Eo=Vt(.42,0,.58,1),$a=e=>Array.isArray(e)&&typeof e[0]!="number",Do=e=>Array.isArray(e)&&typeof e[0]=="number",Zs={linear:ue,easeIn:Fa,easeInOut:Eo,easeOut:Ba,circIn:ls,circInOut:jo,circOut:Mo,backIn:as,backInOut:Ao,backOut:Co,anticipate:Po},za=e=>typeof e=="string",Js=e=>{if(Do(e)){Se(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,i]=e;return Vt(t,n,s,i)}else if(za(e))return Se(Zs[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),Zs[e];return e},Bt=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Ua(e,t){let n=new Set,s=new Set,i=!1,r=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(c){o.has(c)&&(u.schedule(c),e()),c(a)}const u={schedule:(c,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(c),y.has(c)||y.add(c),c},cancel:c=>{s.delete(c),o.delete(c)},process:c=>{if(a=c,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,u.process(c))}};return u}const _a=40;function Vo(e,t){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Bt.reduce((b,k)=>(b[k]=Ua(r),b),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:c,update:d,preRender:f,render:g,postRender:y}=o,v=()=>{const b=Ce.useManualTiming?i.timestamp:performance.now();n=!1,Ce.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(b-i.timestamp,_a),1)),i.timestamp=b,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),c.process(i),d.process(i),f.process(i),g.process(i),y.process(i),i.isProcessing=!1,n&&t&&(s=!1,e(v))},w=()=>{n=!0,s=!0,i.isProcessing||e(v)};return{schedule:Bt.reduce((b,k)=>{const A=o[k];return b[k]=(D,R=!1,P=!1)=>(n||w(),A.schedule(D,R,P)),b},{}),cancel:b=>{for(let k=0;k<Bt.length;k++)o[Bt[k]].cancel(b)},state:i,steps:o}}const{schedule:F,cancel:Ee,state:J,steps:fn}=Vo(typeof requestAnimationFrame<"u"?requestAnimationFrame:ue,!0);let Wt;function Wa(){Wt=void 0}const ie={now:()=>(Wt===void 0&&ie.set(J.isProcessing||Ce.useManualTiming?J.timestamp:performance.now()),Wt),set:e=>{Wt=e,queueMicrotask(Wa)}},ko=e=>t=>typeof t=="string"&&t.startsWith(e),cs=ko("--"),Ka=ko("var(--"),us=e=>Ka(e)?Ha.test(e.split("/*")[0].trim()):!1,Ha=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,at={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Ct={...at,transform:e=>Te(0,1,e)},$t={...at,default:1},vt=e=>Math.round(e*1e5)/1e5,ds=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Xa(e){return e==null}const Ga=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,hs=(e,t)=>n=>!!(typeof n=="string"&&Ga.test(n)&&n.startsWith(e)||t&&!Xa(n)&&Object.prototype.hasOwnProperty.call(n,t)),Ro=(e,t,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(ds);return{[e]:parseFloat(i),[t]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Ya=e=>Te(0,255,e),mn={...at,transform:e=>Math.round(Ya(e))},_e={test:hs("rgb","red"),parse:Ro("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+mn.transform(e)+", "+mn.transform(t)+", "+mn.transform(n)+", "+vt(Ct.transform(s))+")"};function qa(e){let t="",n="",s="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,s+=s,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const En={test:hs("#"),parse:qa,transform:_e.transform},kt=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),je=kt("deg"),be=kt("%"),E=kt("px"),Za=kt("vh"),Ja=kt("vw"),Qs={...be,parse:e=>be.parse(e)/100,transform:e=>be.transform(e*100)},qe={test:hs("hsl","hue"),parse:Ro("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+be.transform(vt(t))+", "+be.transform(vt(n))+", "+vt(Ct.transform(s))+")"},G={test:e=>_e.test(e)||En.test(e)||qe.test(e),parse:e=>_e.test(e)?_e.parse(e):qe.test(e)?qe.parse(e):En.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?_e.transform(e):qe.transform(e),getAnimatableNone:e=>{const t=G.parse(e);return t.alpha=0,G.transform(t)}},Qa=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function el(e){return isNaN(e)&&typeof e=="string"&&(e.match(ds)?.length||0)+(e.match(Qa)?.length||0)>0}const No="number",Io="color",tl="var",nl="var(",ei="${}",sl=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function At(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=t.replace(sl,l=>(G.test(l)?(s.color.push(r),i.push(Io),n.push(G.parse(l))):l.startsWith(nl)?(s.var.push(r),i.push(tl),n.push(l)):(s.number.push(r),i.push(No),n.push(parseFloat(l))),++r,ei)).split(ei);return{values:n,split:a,indexes:s,types:i}}function Lo(e){return At(e).values}function Oo(e){const{split:t,types:n}=At(e),s=t.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=t[o],i[o]!==void 0){const a=n[o];a===No?r+=vt(i[o]):a===Io?r+=G.transform(i[o]):r+=i[o]}return r}}const il=e=>typeof e=="number"?0:G.test(e)?G.getAnimatableNone(e):e;function ol(e){const t=Lo(e);return Oo(e)(t.map(il))}const De={test:el,parse:Lo,createTransformer:Oo,getAnimatableNone:ol};function pn(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function rl({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let i=0,r=0,o=0;if(!t)i=r=o=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;i=pn(l,a,e+1/3),r=pn(l,a,e),o=pn(l,a,e-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Zt(e,t){return n=>n>0?t:e}const z=(e,t,n)=>e+(t-e)*n,gn=(e,t,n)=>{const s=e*e,i=n*(t*t-s)+s;return i<0?0:Math.sqrt(i)},al=[En,_e,qe],ll=e=>al.find(t=>t.test(e));function ti(e){const t=ll(e);if(rt(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!t)return!1;let n=t.parse(e);return t===qe&&(n=rl(n)),n}const ni=(e,t)=>{const n=ti(e),s=ti(t);if(!n||!s)return Zt(e,t);const i={...n};return r=>(i.red=gn(n.red,s.red,r),i.green=gn(n.green,s.green,r),i.blue=gn(n.blue,s.blue,r),i.alpha=z(n.alpha,s.alpha,r),_e.transform(i))},Dn=new Set(["none","hidden"]);function cl(e,t){return Dn.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function ul(e,t){return n=>z(e,t,n)}function fs(e){return typeof e=="number"?ul:typeof e=="string"?us(e)?Zt:G.test(e)?ni:fl:Array.isArray(e)?Fo:typeof e=="object"?G.test(e)?ni:dl:Zt}function Fo(e,t){const n=[...e],s=n.length,i=e.map((r,o)=>fs(r)(r,t[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function dl(e,t){const n={...e,...t},s={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(s[i]=fs(e[i])(e[i],t[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function hl(e,t){const n=[],s={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const r=t.types[i],o=e.indexes[r][s[r]],a=e.values[o]??0;n[i]=a,s[r]++}return n}const fl=(e,t)=>{const n=De.createTransformer(t),s=At(e),i=At(t);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?Dn.has(e)&&!i.values.length||Dn.has(t)&&!s.values.length?cl(e,t):Dt(Fo(hl(s,i),i.values),n):(rt(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Zt(e,t))};function Bo(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?z(e,t,n):fs(e)(e,t)}const ml=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>F.update(t,n),stop:()=>Ee(t),now:()=>J.isProcessing?J.timestamp:ie.now()}},$o=(e,t,n=10)=>{let s="";const i=Math.max(Math.round(t/n),2);for(let r=0;r<i;r++)s+=Math.round(e(r/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Jt=2e4;function ms(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<Jt;)t+=n,s=e.next(t);return t>=Jt?1/0:t}function pl(e,t=100,n){const s=n({...e,keyframes:[0,t]}),i=Math.min(ms(s),Jt);return{type:"keyframes",ease:r=>s.next(i*r).value/t,duration:ce(i)}}const gl=5;function zo(e,t,n){const s=Math.max(t-gl,0);return bo(n-e(s),t-s)}const $={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},yn=.001;function yl({duration:e=$.duration,bounce:t=$.bounce,velocity:n=$.velocity,mass:s=$.mass}){let i,r;rt(e<=me($.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-t;o=Te($.minDamping,$.maxDamping,o),e=Te($.minDuration,$.maxDuration,ce(e)),o<1?(i=u=>{const c=u*o,d=c*e,f=c-n,g=Vn(u,o),y=Math.exp(-d);return yn-f/g*y},r=u=>{const d=u*o*e,f=d*n+n,g=Math.pow(o,2)*Math.pow(u,2)*e,y=Math.exp(-d),v=Vn(Math.pow(u,2),o);return(-i(u)+yn>0?-1:1)*((f-g)*y)/v}):(i=u=>{const c=Math.exp(-u*e),d=(u-n)*e+1;return-yn+c*d},r=u=>{const c=Math.exp(-u*e),d=(n-u)*(e*e);return c*d});const a=5/e,l=vl(i,r,a);if(e=me(e),isNaN(l))return{stiffness:$.stiffness,damping:$.damping,duration:e};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:o*2*Math.sqrt(s*u),duration:e}}}const xl=12;function vl(e,t,n){let s=n;for(let i=1;i<xl;i++)s=s-e(s)/t(s);return s}function Vn(e,t){return e*Math.sqrt(1-t*t)}const bl=["duration","bounce"],wl=["stiffness","damping","mass"];function si(e,t){return t.some(n=>e[n]!==void 0)}function Tl(e){let t={velocity:$.velocity,stiffness:$.stiffness,damping:$.damping,mass:$.mass,isResolvedFromDuration:!1,...e};if(!si(e,wl)&&si(e,bl))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*Te(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:$.mass,stiffness:i,damping:r}}else{const n=yl(e);t={...t,...n,mass:$.mass},t.isResolvedFromDuration=!0}return t}function Qt(e=$.visualDuration,t=$.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:l,damping:u,mass:c,duration:d,velocity:f,isResolvedFromDuration:g}=Tl({...n,velocity:-ce(n.velocity||0)}),y=f||0,v=u/(2*Math.sqrt(l*c)),w=o-r,x=ce(Math.sqrt(l/c)),S=Math.abs(w)<5;s||(s=S?$.restSpeed.granular:$.restSpeed.default),i||(i=S?$.restDelta.granular:$.restDelta.default);let b;if(v<1){const A=Vn(x,v);b=D=>{const R=Math.exp(-v*x*D);return o-R*((y+v*x*w)/A*Math.sin(A*D)+w*Math.cos(A*D))}}else if(v===1)b=A=>o-Math.exp(-x*A)*(w+(y+x*w)*A);else{const A=x*Math.sqrt(v*v-1);b=D=>{const R=Math.exp(-v*x*D),P=Math.min(A*D,300);return o-R*((y+v*x*w)*Math.sinh(P)+A*w*Math.cosh(P))/A}}const k={calculatedDuration:g&&d||null,next:A=>{const D=b(A);if(g)a.done=A>=d;else{let R=A===0?y:0;v<1&&(R=A===0?me(y):zo(b,A,D));const P=Math.abs(R)<=s,N=Math.abs(o-D)<=i;a.done=P&&N}return a.value=a.done?o:D,a},toString:()=>{const A=Math.min(ms(k),Jt),D=$o(R=>k.next(A*R).value,A,30);return A+"ms "+D},toTransition:()=>{}};return k}Qt.applyToOptions=e=>{const t=pl(e,100,Qt);return e.ease=t.ease,e.duration=me(t.duration),e.type="keyframes",e};function kn({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:u=.5,restSpeed:c}){const d=e[0],f={done:!1,value:d},g=P=>a!==void 0&&P<a||l!==void 0&&P>l,y=P=>a===void 0?l:l===void 0||Math.abs(a-P)<Math.abs(l-P)?a:l;let v=n*t;const w=d+v,x=o===void 0?w:o(w);x!==w&&(v=x-d);const S=P=>-v*Math.exp(-P/s),b=P=>x+S(P),k=P=>{const N=S(P),W=b(P);f.done=Math.abs(N)<=u,f.value=f.done?x:W};let A,D;const R=P=>{g(f.value)&&(A=P,D=Qt({keyframes:[f.value,y(f.value)],velocity:zo(b,P,f.value),damping:i,stiffness:r,restDelta:u,restSpeed:c}))};return R(0),{calculatedDuration:null,next:P=>{let N=!1;return!D&&A===void 0&&(N=!0,k(P),R(P)),A!==void 0&&P>=A?D.next(P-A):(!N&&k(P),f)}}}function Sl(e,t,n){const s=[],i=n||Ce.mix||Bo,r=e.length-1;for(let o=0;o<r;o++){let a=i(e[o],e[o+1]);if(t){const l=Array.isArray(t)?t[o]||ue:t;a=Dt(l,a)}s.push(a)}return s}function Cl(e,t,{clamp:n=!0,ease:s,mixer:i}={}){const r=e.length;if(Se(r===t.length,"Both input and output ranges must be the same length","range-length"),r===1)return()=>t[0];if(r===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[r-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=Sl(t,s,i),l=a.length,u=c=>{if(o&&c<e[0])return t[0];let d=0;if(l>1)for(;d<e.length-2&&!(c<e[d+1]);d++);const f=St(e[d],e[d+1],c);return a[d](f)};return n?c=>u(Te(e[0],e[r-1],c)):u}function Al(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const i=St(0,t,s);e.push(z(n,1,i))}}function Pl(e){const t=[0];return Al(t,e.length-1),t}function Ml(e,t){return e.map(n=>n*t)}function jl(e,t){return e.map(()=>t||Eo).splice(0,e.length-1)}function Ze({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const i=$a(s)?s.map(Js):Js(s),r={done:!1,value:t[0]},o=Ml(n&&n.length===t.length?n:Pl(t),e),a=Cl(o,t,{ease:Array.isArray(i)?i:jl(t,i)});return{calculatedDuration:e,next:l=>(r.value=a(l),r.done=l>=e,r)}}const El=e=>e!==null;function ps(e,{repeat:t,repeatType:n="loop"},s,i=1){const r=e.filter(El),a=i<0||t&&n!=="loop"&&t%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Dl={decay:kn,inertia:kn,tween:Ze,keyframes:Ze,spring:Qt};function Uo(e){typeof e.type=="string"&&(e.type=Dl[e.type])}class gs{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Vl=e=>e/100;class ys extends gs{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==ie.now()&&this.tick(ie.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;Uo(t);const{type:n=Ze,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=t;let{keyframes:a}=t;const l=n||Ze;process.env.NODE_ENV!=="production"&&l!==Ze&&Se(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Ze&&typeof a[0]!="number"&&(this.mixKeyframes=Dt(Vl,Bo(a[0],a[1])),a=[0,100]);const u=l({...t,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-o})),u.calculatedDuration===null&&(u.calculatedDuration=ms(u));const{calculatedDuration:c}=u;this.calculatedDuration=c,this.resolvedDuration=c+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:s,totalDuration:i,mixKeyframes:r,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:c,repeat:d,repeatType:f,repeatDelay:g,type:y,onUpdate:v,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const x=this.currentTime-u*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?x<0:x>i;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let b=this.currentTime,k=s;if(d){const P=Math.min(this.currentTime,i)/a;let N=Math.floor(P),W=P%1;!W&&P>=1&&(W=1),W===1&&N--,N=Math.min(N,d+1),!!(N%2)&&(f==="reverse"?(W=1-W,g&&(W-=g/a)):f==="mirror"&&(k=o)),b=Te(0,1,W)*a}const A=S?{done:!1,value:c[0]}:k.next(b);r&&(A.value=r(A.value));let{done:D}=A;!S&&l!==null&&(D=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const R=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&D);return R&&y!==kn&&(A.value=ps(c,this.options,w,this.speed)),v&&v(A.value),R&&this.finish(),A}then(t,n){return this.finished.then(t,n)}get duration(){return ce(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+ce(t)}get time(){return ce(this.currentTime)}set time(t){t=me(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(ie.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=ce(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=ml,startTime:n}=this.options;this.driver||(this.driver=t(i=>this.tick(i))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(ie.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}function kl(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const We=e=>e*180/Math.PI,Rn=e=>{const t=We(Math.atan2(e[1],e[0]));return Nn(t)},Rl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Rn,rotateZ:Rn,skewX:e=>We(Math.atan(e[1])),skewY:e=>We(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Nn=e=>(e=e%360,e<0&&(e+=360),e),ii=Rn,oi=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),ri=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Nl={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:oi,scaleY:ri,scale:e=>(oi(e)+ri(e))/2,rotateX:e=>Nn(We(Math.atan2(e[6],e[5]))),rotateY:e=>Nn(We(Math.atan2(-e[2],e[0]))),rotateZ:ii,rotate:ii,skewX:e=>We(Math.atan(e[4])),skewY:e=>We(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function In(e){return e.includes("scale")?1:0}function Ln(e,t){if(!e||e==="none")return In(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Nl,i=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Rl,i=a}if(!i)return In(t);const r=s[t],o=i[1].split(",").map(Ll);return typeof r=="function"?r(o):o[r]}const Il=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Ln(n,t)};function Ll(e){return parseFloat(e.trim())}const lt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ct=new Set(lt),ai=e=>e===at||e===E,Ol=new Set(["x","y","z"]),Fl=lt.filter(e=>!Ol.has(e));function Bl(e){const t=[];return Fl.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Ke={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Ln(t,"x"),y:(e,{transform:t})=>Ln(t,"y")};Ke.translateX=Ke.x;Ke.translateY=Ke.y;const He=new Set;let On=!1,Fn=!1,Bn=!1;function _o(){if(Fn){const e=Array.from(He).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const i=Bl(s);i.length&&(n.set(s,i),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([r,o])=>{s.getValue(r)?.set(o)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Fn=!1,On=!1,He.forEach(e=>e.complete(Bn)),He.clear()}function Wo(){He.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Fn=!0)})}function $l(){Bn=!0,Wo(),_o(),Bn=!1}class xs{constructor(t,n,s,i,r,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(He.add(this),On||(On=!0,F.read(Wo),F.resolveKeyframes(_o))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:i}=this;if(t[0]===null){const r=i?.get(),o=t[t.length-1];if(r!==void 0)t[0]=r;else if(s&&n){const a=s.readValue(n,o);a!=null&&(t[0]=a)}t[0]===void 0&&(t[0]=o),i&&r===void 0&&i.set(t[0])}kl(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),He.delete(this)}cancel(){this.state==="scheduled"&&(He.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const zl=e=>e.startsWith("--");function Ul(e,t,n){zl(t)?e.style.setProperty(t,n):e.style[t]=n}const _l=is(()=>window.ScrollTimeline!==void 0),Wl={};function Kl(e,t){const n=is(e);return()=>Wl[t]??n()}const Ko=Kl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),xt=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,li={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:xt([0,.65,.55,1]),circOut:xt([.55,0,1,.45]),backIn:xt([.31,.01,.66,-.59]),backOut:xt([.33,1.53,.69,.99])};function Ho(e,t){if(e)return typeof e=="function"?Ko()?$o(e,t):"ease-out":Do(e)?xt(e):Array.isArray(e)?e.map(n=>Ho(n,t)||li.easeOut):li[e]}function Hl(e,t,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},u=void 0){const c={[t]:n};l&&(c.offset=l);const d=Ho(a,i);Array.isArray(d)&&(c.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),e.animate(c,f)}function Xo(e){return typeof e=="function"&&"applyToOptions"in e}function Xl({type:e,...t}){return Xo(e)&&Ko()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class Gl extends gs{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:s,keyframes:i,pseudoElement:r,allowFlatten:o=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=t,Se(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=Xl(t);this.animation=Hl(n,s,i,u,r),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const c=ps(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(c):Ul(n,s,c),this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return ce(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+ce(t)}get time(){return ce(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=me(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&_l()?(this.animation.timeline=t,ue):n(this)}}const Go={anticipate:Po,backInOut:Ao,circInOut:jo};function Yl(e){return e in Go}function ql(e){typeof e.ease=="string"&&Yl(e.ease)&&(e.ease=Go[e.ease])}const ci=10;class Zl extends Gl{constructor(t){ql(t),Uo(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:s,onComplete:i,element:r,...o}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const a=new ys({...o,autoplay:!1}),l=me(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-ci).value,a.sample(l).value,ci),a.stop()}}const ui=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(De.test(e)||e==="0")&&!e.startsWith("url("));function Jl(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function Ql(e,t,n,s){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const r=e[e.length-1],o=ui(i,t),a=ui(r,t);return rt(o===a,`You are trying to animate ${t} from "${i}" to "${r}". "${o?r:i}" is not an animatable value.`,"value-not-animatable"),!o||!a?!1:Jl(e)||(n==="spring"||Xo(n))&&s}function $n(e){e.duration=0,e.type="keyframes"}const ec=new Set(["opacity","clipPath","filter","transform"]),tc=is(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function nc(e){const{motionValue:t,name:n,repeatDelay:s,repeatType:i,damping:r,type:o}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=t.owner.getProps();return tc()&&n&&ec.has(n)&&(n!=="transform"||!u)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const sc=40;class ic extends gs{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:u,element:c,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=ie.now();const f={autoplay:t,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:l,motionValue:u,element:c,...d},g=c?.KeyframeResolver||xs;this.keyframeResolver=new g(a,(y,v,w)=>this.onKeyframesResolved(y,v,f,!w),l,u,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:u,onUpdate:c}=s;this.resolvedAt=ie.now(),Ql(t,r,o,a)||((Ce.instantAnimations||!l)&&c?.(ps(t,s,n)),t[0]=t[t.length-1],$n(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>sc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},g=!u&&nc(f)?new Zl({...f,element:f.motionValue.owner.current}):new ys(f);g.finished.then(()=>this.notifyFinished()).catch(ue),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(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),$l()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const oc=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function rc(e){const t=oc.exec(e);if(!t)return[,];const[,n,s,i]=t;return[`--${n??s}`,i]}const ac=4;function Yo(e,t,n=1){Se(n<=ac,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=rc(e);if(!s)return;const r=window.getComputedStyle(t).getPropertyValue(s);if(r){const o=r.trim();return yo(o)?parseFloat(o):o}return us(i)?Yo(i,t,n+1):i}function vs(e,t){return e?.[t]??e?.default??e}const qo=new Set(["width","height","top","left","right","bottom",...lt]),lc={test:e=>e==="auto",parse:e=>e},Zo=e=>t=>t.test(e),Jo=[at,E,be,je,Ja,Za,lc],di=e=>Jo.find(Zo(e));function cc(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||vo(e):!0}const uc=new Set(["brightness","contrast","saturate","opacity"]);function dc(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(ds)||[];if(!s)return e;const i=n.replace(s,"");let r=uc.has(t)?1:0;return s!==n&&(r*=100),t+"("+r+i+")"}const hc=/\b([a-z-]*)\(.*?\)/gu,zn={...De,getAnimatableNone:e=>{const t=e.match(hc);return t?t.map(dc).join(" "):e}},hi={...at,transform:Math.round},fc={rotate:je,rotateX:je,rotateY:je,rotateZ:je,scale:$t,scaleX:$t,scaleY:$t,scaleZ:$t,skew:je,skewX:je,skewY:je,distance:E,translateX:E,translateY:E,translateZ:E,x:E,y:E,z:E,perspective:E,transformPerspective:E,opacity:Ct,originX:Qs,originY:Qs,originZ:E},bs={borderWidth:E,borderTopWidth:E,borderRightWidth:E,borderBottomWidth:E,borderLeftWidth:E,borderRadius:E,radius:E,borderTopLeftRadius:E,borderTopRightRadius:E,borderBottomRightRadius:E,borderBottomLeftRadius:E,width:E,maxWidth:E,height:E,maxHeight:E,top:E,right:E,bottom:E,left:E,padding:E,paddingTop:E,paddingRight:E,paddingBottom:E,paddingLeft:E,margin:E,marginTop:E,marginRight:E,marginBottom:E,marginLeft:E,backgroundPositionX:E,backgroundPositionY:E,...fc,zIndex:hi,fillOpacity:Ct,strokeOpacity:Ct,numOctaves:hi},mc={...bs,color:G,backgroundColor:G,outlineColor:G,fill:G,stroke:G,borderColor:G,borderTopColor:G,borderRightColor:G,borderBottomColor:G,borderLeftColor:G,filter:zn,WebkitFilter:zn},Qo=e=>mc[e];function er(e,t){let n=Qo(e);return n!==zn&&(n=De),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const pc=new Set(["auto","none","0"]);function gc(e,t,n){let s=0,i;for(;s<e.length&&!i;){const r=e[s];typeof r=="string"&&!pc.has(r)&&At(r).values.length&&(i=e[s]),s++}if(i&&n)for(const r of t)e[r]=er(n,i)}class yc extends xs{constructor(t,n,s,i,r){super(t,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<t.length;l++){let u=t[l];if(typeof u=="string"&&(u=u.trim(),us(u))){const c=Yo(u,n.current);c!==void 0&&(t[l]=c),l===t.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!qo.has(s)||t.length!==2)return;const[i,r]=t,o=di(i),a=di(r);if(o!==a)if(ai(o)&&ai(a))for(let l=0;l<t.length;l++){const u=t[l];typeof u=="string"&&(t[l]=parseFloat(u))}else Ke[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let i=0;i<t.length;i++)(t[i]===null||cc(t[i]))&&s.push(i);s.length&&gc(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Ke[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(s,i).jump(i,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const i=t.getValue(n);i&&i.jump(this.measuredOrigin,!1);const r=s.length-1,o=s[r];s[r]=Ke[n](t.measureViewportBox(),window.getComputedStyle(t.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{t.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function xc(e,t,n){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let s=document;const i=n?.[e]??s.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e)}const tr=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function nr(e){return xo(e)&&"offsetHeight"in e}const fi=30,vc=e=>!isNaN(parseFloat(e));class bc{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=ie.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const r of this.dependents)r.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=ie.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=vc(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&rs(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new os);const s=this.events[t].add(n);return t==="change"?()=>{s(),F.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=ie.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>fi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,fi);return bo(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function it(e,t){return new bc(e,t)}const{schedule:ws}=Vo(queueMicrotask,!1),he={x:!1,y:!1};function sr(){return he.x||he.y}function wc(e){return e==="x"||e==="y"?he[e]?null:(he[e]=!0,()=>{he[e]=!1}):he.x||he.y?null:(he.x=he.y=!0,()=>{he.x=he.y=!1})}function ir(e,t){const n=xc(e),s=new AbortController,i={passive:!0,...t,signal:s.signal};return[n,i,()=>s.abort()]}function mi(e){return!(e.pointerType==="touch"||sr())}function Tc(e,t,n={}){const[s,i,r]=ir(e,n),o=a=>{if(!mi(a))return;const{target:l}=a,u=t(l,a);if(typeof u!="function"||!l)return;const c=d=>{mi(d)&&(u(d),l.removeEventListener("pointerleave",c))};l.addEventListener("pointerleave",c,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const or=(e,t)=>t?e===t?!0:or(e,t.parentElement):!1,Ts=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Sc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Cc(e){return Sc.has(e.tagName)||e.tabIndex!==-1}const Kt=new WeakSet;function pi(e){return t=>{t.key==="Enter"&&e(t)}}function xn(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Ac=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=pi(()=>{if(Kt.has(n))return;xn(n,"down");const i=pi(()=>{xn(n,"up")}),r=()=>xn(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",r,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function gi(e){return Ts(e)&&!sr()}function Pc(e,t,n={}){const[s,i,r]=ir(e,n),o=a=>{const l=a.currentTarget;if(!gi(a))return;Kt.add(l);const u=t(l,a),c=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),Kt.has(l)&&Kt.delete(l),gi(g)&&typeof u=="function"&&u(g,{success:y})},d=g=>{c(g,l===window||l===document||n.useGlobalTarget||or(l,g.target))},f=g=>{c(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),nr(a)&&(a.addEventListener("focus",u=>Ac(u,i)),!Cc(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function rr(e){return xo(e)&&"ownerSVGElement"in e}function Mc(e){return rr(e)&&e.tagName==="svg"}const te=e=>!!(e&&e.getVelocity),jc=[...Jo,G,De],Ec=e=>jc.find(Zo(e)),Ss=m.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function yi(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dc(...e){return t=>{let n=!1;const s=e.map(i=>{const r=yi(i,t);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<s.length;i++){const r=s[i];typeof r=="function"?r():yi(e[i],null)}}}}function Vc(...e){return fe.useCallback(Dc(...e),e)}class kc extends fe.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=nr(s)&&s.offsetWidth||0,r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft,r.right=i-r.width-r.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Rc({children:e,isPresent:t,anchorX:n,root:s}){const i=m.useId(),r=m.useRef(null),o=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Ss),l=Vc(r,e?.ref);return m.useInsertionEffect(()=>{const{width:u,height:c,top:d,left:f,right:g}=o.current;if(t||!r.current||!u||!c)return;const y=n==="left"?`left: ${f}`:`right: ${g}`;r.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const w=s??document.head;return w.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
2
2
|
[data-motion-pop-id="${i}"] {
|
|
3
3
|
position: absolute !important;
|
|
4
4
|
width: ${u}px !important;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
${y}px !important;
|
|
7
7
|
top: ${d}px !important;
|
|
8
8
|
}
|
|
9
|
-
`),()=>{w.contains(v)&&w.removeChild(v)}},[e]),h.jsx(Ec,{isPresent:e,childRef:r,sizeRef:o,children:ft.cloneElement(t,{ref:l})})}const Rc=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const u=Qn(Nc),c=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:c,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const y of u.values())if(!y)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return r&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,y)=>u.set(y,!1))},[n]),ft.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),o==="popLayout"&&(t=h.jsx(kc,{isPresent:n,anchorX:a,root:l,children:t})),h.jsx(en.Provider,{value:f,children:t})};function Nc(){return new Map}function rr(t=!0){const e=m.useContext(en);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,r=m.useId();m.useEffect(()=>{if(t)return i(r)},[t]);const o=m.useCallback(()=>t&&s&&s(r),[r,s,t]);return!n&&s?[!1,o]:[!0]}const $e=t=>t.key||"";function yi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Ic=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[u,c]=rr(o),d=m.useMemo(()=>yi(t),[t]),f=o&&!u?[]:d.map($e),g=m.useRef(!0),y=m.useRef(d),v=Qn(()=>new Map),[w,x]=m.useState(d),[S,b]=m.useState(d);po(()=>{g.current=!1,y.current=d;for(let V=0;V<S.length;V++){const R=$e(S[V]);f.includes(R)?v.delete(R):v.get(R)!==!0&&v.set(R,!1)}},[S,f.length,f.join("-")]);const k=[];if(d!==w){let V=[...d];for(let R=0;R<S.length;R++){const P=S[R],N=$e(P);f.includes(N)||(V.splice(R,0,P),k.push(P))}return r==="wait"&&k.length&&(V=k),b(yi(V)),x(d),null}process.env.NODE_ENV!=="production"&&r==="wait"&&S.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:A}=m.useContext(Jn);return h.jsx(h.Fragment,{children:S.map(V=>{const R=$e(V),P=o&&!u?!1:d===S||f.includes(R),N=()=>{if(v.has(R))v.set(R,!0);else return;let W=!0;v.forEach(U=>{U||(W=!1)}),W&&(A?.(),b(y.current),o&&c?.(),s&&s())};return h.jsx(Rc,{isPresent:P,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:P?void 0:N,anchorX:a,children:V},R)})})},Ss=m.createContext({strict:!1}),xi={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},oe={};for(const t in xi)oe[t]={isEnabled:e=>xi[t].some(n=>!!e[n])};function zn(t){for(const e in t)oe[e]={...oe[e],...t[e]}}function Lc({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!xn(e)),i=m.useRef(void 0);if(!xn(e)){const{renderer:r,...o}=e;i.current=r,zn(o)}return m.useEffect(()=>{xn(e)&&e().then(({renderer:r,...o})=>{zn(o),i.current=r,s(!0)})},[]),h.jsx(Ss.Provider,{value:{renderer:i.current,strict:n},children:t})}function xn(t){return typeof t=="function"}const Oc=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Qe(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Oc.has(t)}let ar=t=>!Qe(t);function Fc(t){typeof t=="function"&&(ar=e=>e.startsWith("on")?!Qe(e):t(e))}try{Fc(require("@emotion/is-prop-valid").default)}catch{}function Bc(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(ar(i)||n===!0&&Qe(i)||!e&&!Qe(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const nn=m.createContext({});function sn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Pe(t){return typeof t=="string"||Array.isArray(t)}const Cs=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],As=["initial",...Cs];function on(t){return sn(t.animate)||As.some(e=>Pe(t[e]))}function lr(t){return!!(on(t)||t.variants)}function $c(t,e){if(on(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Pe(n)?n:void 0,animate:Pe(s)?s:void 0}}return t.inherit!==!1?e:{}}function zc(t){const{initial:e,animate:n}=$c(t,m.useContext(nn));return m.useMemo(()=>({initial:e,animate:n}),[vi(e),vi(n)])}function vi(t){return Array.isArray(t)?t.join(" "):t}const Me={};function Uc(t){for(const e in t)Me[e]=t[e],ls(e)&&(Me[e].isCSSVariable=!0)}function cr(t,{layout:e,layoutId:n}){return ce.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Me[t]||t==="opacity")}const _c={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Wc=le.length;function Kc(t,e,n){let s="",i=!0;for(let r=0;r<Wc;r++){const o=le[r],a=t[o];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(o.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=tr(a,vs[o]);if(!l){i=!1;const c=_c[o]||o;s+=`${c}(${u}) `}n&&(e[o]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function Ps(t,e,n){const{style:s,vars:i,transformOrigin:r}=t;let o=!1,a=!1;for(const l in e){const u=e[l];if(ce.has(l)){o=!0;continue}else if(ls(l)){i[l]=u;continue}else{const c=tr(u,vs[l]);l.startsWith("origin")?(a=!0,r[l]=c):s[l]=c}}if(e.transform||(o||n?s.transform=Kc(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:c=0}=r;s.transformOrigin=`${l} ${u} ${c}`}}const Ms=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ur(t,e,n){for(const s in e)!et(e[s])&&!cr(s,n)&&(t[s]=e[s])}function Hc({transformTemplate:t},e){return m.useMemo(()=>{const n=Ms();return Ps(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Xc(t,e){const n=t.style||{},s={};return ur(s,n,t),Object.assign(s,Hc(t,e)),s}function Yc(t,e){const n={},s=Xc(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const Gc={offset:"stroke-dashoffset",array:"stroke-dasharray"},qc={offset:"strokeDashoffset",array:"strokeDasharray"};function Zc(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?Gc:qc;t[r.offset]=D.transform(-s);const o=D.transform(e),a=D.transform(n);t[r.array]=`${o} ${a}`}function dr(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,u,c){if(Ps(t,a,u),l){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=c?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&Zc(d,i,r,o,!1)}const hr=()=>({...Ms(),attrs:{}}),fr=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Jc(t,e,n,s){const i=m.useMemo(()=>{const r=hr();return dr(r,e,fr(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};ur(r,t.style,t),i.style={...r,...i.style}}return i}const Qc=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function js(t){return typeof t!="string"||t.includes("-")?!1:!!(Qc.indexOf(t)>-1||/[A-Z]/u.test(t))}function tu(t,e,n,{latestValues:s},i,r=!1){const a=(js(t)?Jc:Yc)(e,s,i,t),l=Bc(e,typeof t=="string",r),u=t!==m.Fragment?{...l,...a,ref:n}:{},{children:c}=e,d=m.useMemo(()=>et(c)?c.get():c,[c]);return m.createElement(t,{...u,children:d})}function bi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function Ds(t,e,n,s){if(typeof e=="function"){const[i,r]=bi(s);e=e(n!==void 0?n:t.custom,i,r)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,r]=bi(s);e=e(n!==void 0?n:t.custom,i,r)}return e}function Ke(t){return et(t)?t.get():t}function eu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:nu(n,s,i,t),renderState:e()}}function nu(t,e,n,s){const i={},r=s(t,{});for(const f in r)i[f]=Ke(r[f]);let{initial:o,animate:a}=t;const l=on(t),u=lr(t);e&&u&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let c=n?n.initial===!1:!1;c=c||o===!1;const d=c?a:o;if(d&&typeof d!="boolean"&&!sn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=Ds(t,f[g]);if(y){const{transitionEnd:v,transition:w,...x}=y;for(const S in x){let b=x[S];if(Array.isArray(b)){const k=c?b.length-1:0;b=b[k]}b!==null&&(i[S]=b)}for(const S in v)i[S]=v[S]}}}return i}const mr=t=>(e,n)=>{const s=m.useContext(nn),i=m.useContext(en),r=()=>eu(t,e,s,i);return n?r():Qn(r)};function Vs(t,e,n){const{style:s}=t,i={};for(const r in s)(et(s[r])||e.style&&et(e.style[r])||cr(r,t)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const su=mr({scrapeMotionValuesFromProps:Vs,createRenderState:Ms});function pr(t,e,n){const s=Vs(t,e,n);for(const i in t)if(et(t[i])||et(e[i])){const r=le.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}const iu=mr({scrapeMotionValuesFromProps:pr,createRenderState:hr}),ou=Symbol.for("motionComponentSymbol");function Jt(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function ru(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):Jt(n)&&(n.current=s))},[e])}const Es=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),au="framerAppearId",gr="data-"+Es(au),yr=m.createContext({});function lu(t,e,n,s,i){const{visualElement:r}=m.useContext(nn),o=m.useContext(Ss),a=m.useContext(en),l=m.useContext(Ts).reducedMotion,u=m.useRef(null);s=s||o.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const c=u.current,d=m.useContext(yr);c&&!c.projection&&i&&(c.type==="html"||c.type==="svg")&&cu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{c&&f.current&&c.update(n,a)});const g=n[gr],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return po(()=>{c&&(f.current=!0,window.MotionIsMounted=!0,c.updateFeatures(),c.scheduleRenderMicrotask(),y.current&&c.animationState&&c.animationState.animateChanges())}),m.useEffect(()=>{c&&(!y.current&&c.animationState&&c.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),c.enteringChildren=void 0)}),c}function cu(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:xr(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&Jt(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u})}function xr(t){if(t)return t.options.allowProjection!==!1?t.projection:xr(t.parent)}function He(t,{forwardMotionProps:e=!1}={},n,s){n&&zn(n);const i=js(t)?iu:su;function r(a,l){let u;const c={...m.useContext(Ts),...a,layoutId:uu(a)},{isStatic:d}=c,f=zc(a),g=i(a,d);if(!d&&ts){du(c,n);const y=hu(c);u=y.MeasureLayout,f.visualElement=lu(t,g,c,s,y.ProjectionNode)}return h.jsxs(nn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...c}):null,tu(t,a,ru(g,f.visualElement,l),g,d,e)]})}r.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const o=m.forwardRef(r);return o[ou]=t,o}function uu({layoutId:t}){const e=m.useContext(Jn).id;return e&&t!==void 0?e+"-"+t:t}function du(t,e){const n=m.useContext(Ss).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?re(!1,s,"lazy-strict-mode"):St(!1,s,"lazy-strict-mode")}}function hu(t){const{drag:e,layout:n}=oe;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function fu(t,e){if(typeof Proxy>"u")return He;const n=new Map,s=(r,o)=>He(r,o,t,e),i=(r,o)=>(process.env.NODE_ENV!=="production"&&os(!1,"motion() is deprecated. Use motion.create() instead."),s(r,o));return new Proxy(i,{get:(r,o)=>o==="create"?s:(n.has(o)||n.set(o,He(o,void 0,t,e)),n.get(o))})}function vr({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function mu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function pu(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function vn(t){return t===void 0||t===1}function Un({scale:t,scaleX:e,scaleY:n}){return!vn(t)||!vn(e)||!vn(n)}function Ut(t){return Un(t)||br(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function br(t){return wi(t.x)||wi(t.y)}function wi(t){return t&&t!=="0%"}function tn(t,e,n){const s=t-n,i=e*s;return n+i}function Ti(t,e,n,s,i){return i!==void 0&&(t=tn(t,i,s)),tn(t,n,s)+e}function _n(t,e=0,n=1,s,i){t.min=Ti(t.min,e,n,s,i),t.max=Ti(t.max,e,n,s,i)}function wr(t,{x:e,y:n}){_n(t.x,e.translate,e.scale,e.originPoint),_n(t.y,n.translate,n.scale,n.originPoint)}const Si=.999999999999,Ci=1.0000000000001;function gu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let r,o;for(let a=0;a<i;a++){r=n[a],o=r.projectionDelta;const{visualElement:l}=r.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&te(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,wr(t,o)),s&&Ut(r.latestValues)&&te(t,r.latestValues))}e.x<Ci&&e.x>Si&&(e.x=1),e.y<Ci&&e.y>Si&&(e.y=1)}function Qt(t,e){t.min=t.min+e,t.max=t.max+e}function Ai(t,e,n,s,i=.5){const r=z(t.min,t.max,i);_n(t,e,n,r,s)}function te(t,e){Ai(t.x,e.x,e.scaleX,e.scale,e.originX),Ai(t.y,e.y,e.scaleY,e.scale,e.originY)}function Tr(t,e){return vr(pu(t.getBoundingClientRect(),e))}function yu(t,e,n){const s=Tr(t,n),{scroll:i}=e;return i&&(Qt(s.x,i.offset.x),Qt(s.y,i.offset.y)),s}const Pi=()=>({translate:0,scale:1,origin:0,originPoint:0}),ee=()=>({x:Pi(),y:Pi()}),Mi=()=>({min:0,max:0}),H=()=>({x:Mi(),y:Mi()}),Wn={current:null},Sr={current:!1};function xu(){if(Sr.current=!0,!!ts)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Wn.current=t.matches;t.addEventListener("change",e),e()}else Wn.current=!1}const vu=new WeakMap;function bu(t,e,n){for(const s in e){const i=e[s],r=n[s];if(et(i))t.addValue(s,i);else if(et(r))t.addValue(s,ie(i,{owner:t}));else if(r!==i)if(t.hasValue(s)){const o=t.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(s);t.addValue(s,ie(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const ji=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class wu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:r,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=ys,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=it.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,F.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!r,this.isControllingVariants=on(n),this.isVariantNode=lr(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];l[f]!==void 0&&et(g)&&g.set(l[f])}}mount(e){this.current=e,vu.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Sr.current||xu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Wn.current,process.env.NODE_ENV!=="production"&&os(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Dt(this.notifyUpdate),Dt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=ce.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&F.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),r&&r(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in oe){const n=oe[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const r=this.features[e];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):H()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<ji.length;s++){const i=ji[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=e[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=bu(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=ie(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(go(s)||xo(s))?s=parseFloat(s):!jc(s)&&Vt.test(n)&&(s=Qo(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 r=Ds(this.props,n,this.presenceContext?.custom);r&&(s=r[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!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 is),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){bs.render(this.render)}}class Cr extends wu{constructor(){super(...arguments),this.KeyframeResolver=gc}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;et(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Ar(t,{style:e,vars:n},s,i){const r=t.style;let o;for(o in e)r[o]=e[o];i?.applyProjectionStyles(r,s);for(o in n)r.setProperty(o,n[o])}function Tu(t){return window.getComputedStyle(t)}class Su extends Cr{constructor(){super(...arguments),this.type="html",this.renderInstance=Ar}readValueFromInstance(e,n){if(ce.has(n))return this.projection?.isProjecting?Nn(n):Nl(e,n);{const s=Tu(e),i=(ls(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Tr(e,n)}build(e,n,s){Ps(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return Vs(e,n,s)}}const Pr=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Cu(t,e,n,s){Ar(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Pr.has(i)?i:Es(i),e.attrs[i])}class Au extends Cr{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=H}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(ce.has(n)){const s=Jo(n);return s&&s.default||0}return n=Pr.has(n)?n:Es(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return pr(e,n,s)}build(e,n,s){dr(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Cu(e,n,s,i)}mount(e){this.isSVGTag=fr(e.tagName),super.mount(e)}}const Mr=(t,e)=>js(t)?new Au(e):new Su(e,{allowProjection:t!==m.Fragment});function se(t,e,n){const s=t.getProps();return Ds(s,e,n!==void 0?n:s.custom,t)}const Kn=t=>Array.isArray(t);function Pu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,ie(n))}function Mu(t){return Kn(t)?t[t.length-1]||0:t}function ju(t,e){const n=se(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=Mu(r[o]);Pu(t,o,a)}}function Du(t){return!!(et(t)&&t.add)}function Hn(t,e){const n=t.getValue("willChange");if(Du(n))return n.add(e);if(!n&&Ct.WillChange){const s=new Ct.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function jr(t){return t.props[gr]}const Vu=t=>t!==null;function Eu(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Vu),r=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[r]}const ku={type:"spring",stiffness:500,damping:25,restSpeed:10},Ru=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Nu={type:"keyframes",duration:.8},Iu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Lu=(t,{keyframes:e})=>e.length>2?Nu:ce.has(t)?t.startsWith("scale")?Ru(e[1]):ku:Iu;function Ou({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const ks=(t,e,n,s={},i,r)=>o=>{const a=xs(s,t)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-mt(l);const c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:r?void 0:i};Ou(a)||Object.assign(c,Lu(t,c)),c.duration&&(c.duration=mt(c.duration)),c.repeatDelay&&(c.repeatDelay=mt(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(Bn(c),c.delay===0&&(d=!0)),(Ct.instantAnimations||Ct.skipAnimations)&&(d=!0,Bn(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,d&&!r&&e.get()!==void 0){const f=Eu(c.keyframes,a);if(f!==void 0){F.update(()=>{c.onUpdate(f),c.onComplete()});return}}return a.isSync?new gs(c):new sc(c)};function Fu({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Dr(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=t.getDefaultTransition(),transitionEnd:o,...a}=e;s&&(r=s);const l=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const c in a){const d=t.getValue(c,t.latestValues[c]??null),f=a[c];if(f===void 0||u&&Fu(u,c))continue;const g={delay:n,...xs(r||{},c)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=jr(t);if(x){const S=window.MotionHandoffAnimation(x,c,F);S!==null&&(g.startTime=S,v=!0)}}Hn(t,c),d.start(ks(c,d,f,t.shouldReduceMotion&&Go.has(c)?{type:!1}:g,t,v));const w=d.animation;w&&l.push(w)}return o&&Promise.all(l).then(()=>{F.update(()=>{o&&ju(t,o)})}),l}function Vr(t,e,n,s=0,i=1){const r=Array.from(t).sort((u,c)=>u.sortNodePosition(c)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Xn(t,e,n={}){const s=se(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const r=s?()=>Promise.all(Dr(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=i;return Bu(t,e,l,u,c,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,u]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>u())}else return Promise.all([r(),o(n.delay)])}function Bu(t,e,n=0,s=0,i=0,r=1,o){const a=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),a.push(Xn(l,e,{...o,delay:n+(typeof s=="function"?0:s)+Vr(t.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function $u(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(r=>Xn(t,r,n));s=Promise.all(i)}else if(typeof e=="string")s=Xn(t,e,n);else{const i=typeof e=="function"?se(t,e,n.custom):e;s=Promise.all(Dr(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function Er(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const zu=As.length;function kr(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?kr(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<zu;n++){const s=As[n],i=t.props[s];(Pe(i)||i===!1)&&(e[s]=i)}return e}const Uu=[...Cs].reverse(),_u=Cs.length;function Wu(t){return e=>Promise.all(e.map(({animation:n,options:s})=>$u(t,n,s)))}function Ku(t){let e=Wu(t),n=Di(),s=!0;const i=l=>(u,c)=>{const d=se(t,c,l==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;u={...u,...y,...g}}return u};function r(l){e=l(t)}function o(l){const{props:u}=t,c=kr(t.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let w=0;w<_u;w++){const x=Uu[w],S=n[x],b=u[x]!==void 0?u[x]:c[x],k=Pe(b),A=x===l?S.isActive:null;A===!1&&(y=w);let V=b===c[x]&&b!==u[x]&&k;if(V&&s&&t.manuallyAnimateOnMount&&(V=!1),S.protectedKeys={...g},!S.isActive&&A===null||!b&&!S.prevProp||sn(b)||typeof b=="boolean")continue;const R=Hu(S.prevProp,b);let P=R||x===l&&S.isActive&&!V&&k||w>y&&k,N=!1;const W=Array.isArray(b)?b:[b];let U=W.reduce(i(x),{});A===!1&&(U={});const{prevResolvedValues:wt={}}=S,At={...wt,...U},dt=E=>{P=!0,f.has(E)&&(N=!0,f.delete(E)),S.needsAnimating[E]=!0;const G=t.getValue(E);G&&(G.liveStyle=!1)};for(const E in At){const G=U[E],X=wt[E];if(g.hasOwnProperty(E))continue;let ot=!1;Kn(G)&&Kn(X)?ot=!Er(G,X):ot=G!==X,ot?G!=null?dt(E):f.add(E):G!==void 0&&f.has(E)?dt(E):S.protectedKeys[E]=!0}S.prevProp=b,S.prevResolvedValues=U,S.isActive&&(g={...g,...U}),s&&t.blockInitialAnimation&&(P=!1);const st=V&&R;P&&(!st||N)&&d.push(...W.map(E=>{const G={type:x};if(typeof E=="string"&&s&&!st&&t.manuallyAnimateOnMount&&t.parent){const{parent:X}=t,ot=se(X,E);if(X.enteringChildren&&ot){const{delayChildren:_}=ot.transition||{};G.delay=Vr(X.enteringChildren,t,_)}}return{animation:E,options:G}}))}if(f.size){const w={};if(typeof u.initial!="boolean"){const x=se(t,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(w.transition=x.transition)}f.forEach(x=>{const S=t.getBaseTarget(x),b=t.getValue(x);b&&(b.liveStyle=!0),w[x]=S??null}),d.push({animation:w})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;const c=o(l);for(const d in n)n[d].protectedKeys={};return c}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Di()}}}function Hu(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Er(e,t):!1}function $t(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Di(){return{animate:$t(!0),whileInView:$t(),whileHover:$t(),whileTap:$t(),whileDrag:$t(),whileFocus:$t(),exit:$t()}}class Et{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Xu extends Et{constructor(e){super(e),e.animationState||(e.animationState=Ku(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();sn(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Yu=0;class Gu extends Et{constructor(){super(...arguments),this.id=Yu++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Rr={animation:{Feature:Xu},exit:{Feature:Gu}};function je(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function ke(t){return{point:{x:t.pageX,y:t.pageY}}}const qu=t=>e=>ws(e)&&t(e,ke(e));function be(t,e,n,s){return je(t,e,qu(n),s)}const Nr=1e-4,Zu=1-Nr,Ju=1+Nr,Ir=.01,Qu=0-Ir,td=0+Ir;function nt(t){return t.max-t.min}function ed(t,e,n){return Math.abs(t-e)<=n}function Vi(t,e,n,s=.5){t.origin=s,t.originPoint=z(e.min,e.max,t.origin),t.scale=nt(n)/nt(e),t.translate=z(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Zu&&t.scale<=Ju||isNaN(t.scale))&&(t.scale=1),(t.translate>=Qu&&t.translate<=td||isNaN(t.translate))&&(t.translate=0)}function we(t,e,n,s){Vi(t.x,e.x,n.x,s?s.originX:void 0),Vi(t.y,e.y,n.y,s?s.originY:void 0)}function Ei(t,e,n){t.min=n.min+e.min,t.max=t.min+nt(e)}function nd(t,e,n){Ei(t.x,e.x,n.x),Ei(t.y,e.y,n.y)}function ki(t,e,n){t.min=e.min-n.min,t.max=t.min+nt(e)}function Te(t,e,n){ki(t.x,e.x,n.x),ki(t.y,e.y,n.y)}function lt(t){return[t("x"),t("y")]}const Lr=({current:t})=>t?t.ownerDocument.defaultView:null,Ri=(t,e)=>Math.abs(t-e);function sd(t,e){const n=Ri(t.x,e.x),s=Ri(t.y,e.y);return Math.sqrt(n**2+s**2)}class Or{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:r=!1,distanceThreshold:o=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=wn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=sd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:v}=f,{timestamp:w}=J;this.history.push({...v,timestamp:w});const{onStart:x,onMove:S}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=bn(g,this.transformPagePoint),F.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:v,resumeAnimation:w}=this.handlers;if(this.dragSnapToOrigin&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=wn(f.type==="pointercancel"?this.lastMoveEventInfo:bn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!ws(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=ke(e),l=bn(a,this.transformPagePoint),{point:u}=l,{timestamp:c}=J;this.history=[{...u,timestamp:c}];const{onSessionStart:d}=n;d&&d(e,wn(l,this.history)),this.removeListeners=De(be(this.contextWindow,"pointermove",this.handlePointerMove),be(this.contextWindow,"pointerup",this.handlePointerUp),be(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Dt(this.updatePoint)}}function bn(t,e){return e?{point:e(t.point)}:t}function Ni(t,e){return{x:t.x-e.x,y:t.y-e.y}}function wn({point:t},e){return{point:t,delta:Ni(t,Fr(e)),offset:Ni(t,id(e)),velocity:od(e,.1)}}function id(t){return t[0]}function Fr(t){return t[t.length-1]}function od(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Fr(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>mt(e)));)n--;if(!s)return{x:0,y:0};const r=ct(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function rd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?z(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?z(n,t,s.max):Math.min(t,n)),t}function Ii(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function ad(t,{top:e,left:n,bottom:s,right:i}){return{x:Ii(t.x,n,i),y:Ii(t.y,e,s)}}function Li(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function ld(t,e){return{x:Li(t.x,e.x),y:Li(t.y,e.y)}}function cd(t,e){let n=.5;const s=nt(t),i=nt(e);return i>s?n=Se(e.min,e.max-s,t.min):s>i&&(n=Se(t.min,t.max-i,e.min)),Tt(0,1,n)}function ud(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Yn=.35;function dd(t=Yn){return t===!1?t=0:t===!0&&(t=Yn),{x:Oi(t,"left","right"),y:Oi(t,"top","bottom")}}function Oi(t,e,n){return{min:Fi(t,e),max:Fi(t,n)}}function Fi(t,e){return typeof t=="number"?t:t[e]||0}const hd=new WeakMap;class fd{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=H(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const r=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(ke(d).point)},o=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=bc(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),lt(x=>{let S=this.getAxisMotionValue(x).get()||0;if(bt.test(S)){const{projection:b}=this.visualElement;if(b&&b.layout){const k=b.layout.layoutBox[x];k&&(S=nt(k)*(parseFloat(S)/100))}}this.originPoint[x]=S}),v&&F.postRender(()=>v(d,f)),Hn(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:v,onDrag:w}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:x}=f;if(y&&this.currentDirection===null){this.currentDirection=md(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),w&&w(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>lt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new Or(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:s,contextWindow:Lr(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!i||!s)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&F.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||!ze(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=rd(o,this.constraints[e],this.elastic[e])),r.set(o)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&Jt(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=ad(s.layoutBox,e):this.constraints=!1,this.elastic=dd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&<(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=ud(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Jt(e))return!1;const s=e.current;St(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const r=yu(s,i.root,this.visualElement.getTransformPagePoint());let o=ld(i.layout.layoutBox,r);if(n){const a=n(mu(o));this.hasMutatedConstraints=!!a,a&&(o=vr(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=lt(c=>{if(!ze(c,n,this.currentDirection))return;let d=l&&l[c]||{};o&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?e[c]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(c,y)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Hn(this.visualElement,e),s.start(ks(e,s,0,n,this.visualElement,!1))}stopAnimation(){lt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){lt(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){lt(n=>{const{drag:s}=this.getProps();if(!ze(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n];r.set(e[n]-z(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Jt(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};lt(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=cd({min:l,max:l},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),lt(o=>{if(!ze(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:u}=this.constraints[o];a.set(z(l,u,i[o]))})}addListeners(){if(!this.visualElement.current)return;hd.set(this.visualElement,this);const e=this.visualElement.current,n=be(e,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Jt(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,r=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),F.read(s);const o=je(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(lt(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())});return()=>{o(),n(),r(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=Yn,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function ze(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function md(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class pd extends Et{constructor(e){super(e),this.removeGroupControls=ut,this.removeListeners=ut,this.controls=new fd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ut}unmount(){this.removeGroupControls(),this.removeListeners()}}const Bi=t=>(e,n)=>{t&&F.postRender(()=>t(e,n))};class gd extends Et{constructor(){super(...arguments),this.removePointerDownListener=ut}onPointerDown(e){this.session=new Or(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Lr(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Bi(e),onStart:Bi(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&F.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=be(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 Xe={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function $i(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const ye={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(D.test(t))t=parseFloat(t);else return t;const n=$i(t,e.target.x),s=$i(t,e.target.y);return`${n}% ${s}%`}},yd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Vt.parse(t);if(i.length>5)return s;const r=Vt.createTransformer(t),o=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,l=n.y.scale*e.y;i[0+o]/=a,i[1+o]/=l;const u=z(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=u),typeof i[3+o]=="number"&&(i[3+o]/=u),r(i)}};let Tn=!1;class xd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=e;Uc(vd),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),Tn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),Xe.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,Tn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==r?o.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?o.promote():o.relegate()||F.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),bs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;Tn=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Br(t){const[e,n]=rr(),s=m.useContext(Jn);return h.jsx(xd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(yr),isPresent:e,safeToRemove:n})}const vd={borderRadius:{...ye,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:ye,borderTopRightRadius:ye,borderBottomLeftRadius:ye,borderBottomRightRadius:ye,boxShadow:yd};function bd(t,e,n){const s=et(t)?t:ie(t);return s.start(ks("",s,e,n)),s.animation}const wd=(t,e)=>t.depth-e.depth;class Td{constructor(){this.children=[],this.isDirty=!1}add(e){es(this.children,e),this.isDirty=!0}remove(e){ns(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(wd),this.isDirty=!1,this.children.forEach(e)}}function Sd(t,e){const n=it.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(Dt(s),t(r-e))};return F.setup(s,!0),()=>Dt(s)}const $r=["TopLeft","TopRight","BottomLeft","BottomRight"],Cd=$r.length,zi=t=>typeof t=="string"?parseFloat(t):t,Ui=t=>typeof t=="number"||D.test(t);function Ad(t,e,n,s,i,r){i?(t.opacity=z(0,n.opacity??1,Pd(s)),t.opacityExit=z(e.opacity??1,0,Md(s))):r&&(t.opacity=z(e.opacity??1,n.opacity??1,s));for(let o=0;o<Cd;o++){const a=`border${$r[o]}Radius`;let l=_i(e,a),u=_i(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Ui(l)===Ui(u)?(t[a]=Math.max(z(zi(l),zi(u),s),0),(bt.test(u)||bt.test(l))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=z(e.rotate||0,n.rotate||0,s))}function _i(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Pd=zr(0,.5,Po),Md=zr(.5,.95,ut);function zr(t,e,n){return s=>s<t?0:s>e?1:n(Se(t,e,s))}function Wi(t,e){t.min=e.min,t.max=e.max}function at(t,e){Wi(t.x,e.x),Wi(t.y,e.y)}function Ki(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function Hi(t,e,n,s,i){return t-=e,t=tn(t,1/n,s),i!==void 0&&(t=tn(t,1/i,s)),t}function jd(t,e=0,n=1,s=.5,i,r=t,o=t){if(bt.test(e)&&(e=parseFloat(e),e=z(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=z(r.min,r.max,s);t===r&&(a-=e),t.min=Hi(t.min,e,n,a,i),t.max=Hi(t.max,e,n,a,i)}function Xi(t,e,[n,s,i],r,o){jd(t,e[n],e[s],e[i],e.scale,r,o)}const Dd=["x","scaleX","originX"],Vd=["y","scaleY","originY"];function Yi(t,e,n,s){Xi(t.x,e,Dd,n?n.x:void 0,s?s.x:void 0),Xi(t.y,e,Vd,n?n.y:void 0,s?s.y:void 0)}function Gi(t){return t.translate===0&&t.scale===1}function Ur(t){return Gi(t.x)&&Gi(t.y)}function qi(t,e){return t.min===e.min&&t.max===e.max}function Ed(t,e){return qi(t.x,e.x)&&qi(t.y,e.y)}function Zi(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function _r(t,e){return Zi(t.x,e.x)&&Zi(t.y,e.y)}function Ji(t){return nt(t.x)/nt(t.y)}function Qi(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class kd{constructor(){this.members=[]}add(e){es(this.members,e),e.scheduleRender()}remove(e){if(ns(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const r=this.members[i];if(r.isPresent!==!1){s=r;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Rd(t,e,n){let s="";const i=t.x.translate/e.x,r=t.y.translate/e.y,o=n?.z||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),c&&(s+=`rotate(${c}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),y&&(s+=`skewY(${y}deg) `)}const a=t.x.scale*e.x,l=t.y.scale*e.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const Sn=["","X","Y","Z"],Nd=1e3;let Id=0;function Cn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function Wr(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=jr(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",F,!(i||r))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&Wr(s)}function Kr({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Id++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Fd),this.nodes.forEach(Ud),this.nodes.forEach(_d),this.nodes.forEach(Bd)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Td)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new is),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=or(o)&&!Pc(o),this.instance=o;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let c,d=0;const f=()=>this.root.updateBlockedByResize=!1;F.read(()=>{d=window.innerWidth}),t(o,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,c&&c(),c=Sd(f,250),Xe.hasAnimatedSinceResize&&(Xe.hasAnimatedSinceResize=!1,this.nodes.forEach(no)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||Yd,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=u.getProps(),x=!this.targetLayout||!_r(this.targetLayout,g),S=!d&&f;if(this.options.layoutRoot||this.resumeFrom||S||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...xs(y,"layout"),onPlay:v,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(c,S)}else d||no(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Dt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Wd),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Wr(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const d=this.path[c];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(to);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(eo);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(zd),this.nodes.forEach(Ld),this.nodes.forEach(Od)):this.nodes.forEach(eo),this.clearAllSnapshots();const a=it.now();J.delta=Tt(0,1e3/60,a-J.timestamp),J.timestamp=a,J.isProcessing=!0,hn.update.process(J),hn.preRender.process(J),hn.render.process(J),J.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,bs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach($d),this.sharedNodes.forEach(Kd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,F.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){F.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!nt(this.snapshot.measuredBox.x)&&!nt(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=H(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Ur(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;o&&this.instance&&(a||Ut(this.latestValues)||c)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),Gd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return H();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(qd))){const{scroll:u}=this.root;u&&(Qt(a.x,u.offset.x),Qt(a.y,u.offset.y))}return a}removeElementScroll(o){const a=H();if(at(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:d}=u;u!==this.root&&c&&d.layoutScroll&&(c.wasRoot&&at(a,o),Qt(a.x,c.offset.x),Qt(a.y,c.offset.y))}return a}applyTransform(o,a=!1){const l=H();at(l,o);for(let u=0;u<this.path.length;u++){const c=this.path[u];!a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&te(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),Ut(c.latestValues)&&te(l,c.latestValues)}return Ut(this.latestValues)&&te(l,this.latestValues),l}removeTransform(o){const a=H();at(a,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Ut(u.latestValues))continue;Un(u.latestValues)&&u.updateSnapshot();const c=H(),d=u.measurePageBox();at(c,d),Yi(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return Ut(this.latestValues)&&Yi(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==J.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:d}=this.options;if(!(!this.layout||!(c||d))){if(this.resolvedRelativeTargetAt=J.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=H(),this.relativeTargetOrigin=H(),Te(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),at(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=H(),this.targetWithTransforms=H()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),nd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):at(this.target,this.layout.layoutBox),wr(this.target,this.targetDelta)):at(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=H(),this.relativeTargetOrigin=H(),Te(this.relativeTargetOrigin,this.target,f.target),at(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Un(this.parent.latestValues)||br(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const o=this.getLead(),a=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===J.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||c))return;at(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;gu(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=H());const{target:g}=o;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Ki(this.prevProjectionDelta.x,this.projectionDelta.x),Ki(this.prevProjectionDelta.y,this.projectionDelta.y)),we(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Qi(this.projectionDelta.x,this.prevProjectionDelta.x)||!Qi(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ee(),this.projectionDelta=ee(),this.projectionDeltaWithTransform=ee()}setAnimationOrigin(o,a=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},d=ee();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=H(),g=l?l.source:void 0,y=this.layout?this.layout.source:void 0,v=g!==y,w=this.getStack(),x=!w||w.members.length<=1,S=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(Xd));this.animationProgress=0;let b;this.mixTargetDelta=k=>{const A=k/1e3;so(d.x,o.x,A),so(d.y,o.y,A),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Te(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Hd(this.relativeTarget,this.relativeTargetOrigin,f,A),b&&Ed(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=H()),at(b,this.relativeTarget)),v&&(this.animationValues=c,Ad(c,u,this.latestValues,A,S,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=A},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Dt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=F.update(()=>{Xe.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=ie(0)),this.currentAnimation=bd(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Nd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:c}=o;if(!(!a||!l||!u)){if(this!==o&&this.layout&&u&&Hr(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||H();const d=nt(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=nt(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}at(a,l),te(a,c),we(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new kd),this.sharedNodes.get(o).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&Cn("z",o,u,this.animationValues);for(let c=0;c<Sn.length;c++)Cn(`rotate${Sn[c]}`,o,u,this.animationValues),Cn(`skew${Sn[c]}`,o,u,this.animationValues);o.render();for(const c in u)o.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Ke(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Ke(a?.pointerEvents)||""),this.hasProjected&&!Ut(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=Rd(this.projectionDeltaWithTransform,this.treeScale,c);l&&(d=l(c,d)),o.transform=d;const{x:f,y:g}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?o.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:o.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const y in Me){if(c[y]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:x}=Me[y],S=d==="none"?c[y]:v(c[y],u);if(w){const b=w.length;for(let k=0;k<b;k++)o[w[k]]=S}else x?this.options.visualElement.renderState.vars[y]=S:o[y]=S}this.options.layoutId&&(o.pointerEvents=u===this?Ke(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(to),this.root.sharedNodes.clear()}}}function Ld(t){t.updateLayout()}function Od(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,r=e.source!==t.layout.source;i==="size"?lt(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=nt(d);d.min=n[c].min,d.max=d.min+f}):Hr(i,e.layoutBox,n)&<(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=nt(n[c]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[c].max=t.relativeTarget[c].min+f)});const o=ee();we(o,n,e.layoutBox);const a=ee();r?we(a,t.applyTransform(s,!0),e.measuredBox):we(a,n,e.layoutBox);const l=!Ur(o);let u=!1;if(!t.resumeFrom){const c=t.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:d,layout:f}=c;if(d&&f){const g=H();Te(g,e.layoutBox,d.layoutBox);const y=H();Te(y,n,f.layoutBox),_r(g,y)||(u=!0),c.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=g,t.relativeParent=c)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Fd(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function Bd(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function $d(t){t.clearSnapshot()}function to(t){t.clearMeasurements()}function eo(t){t.isLayoutDirty=!1}function zd(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function no(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Ud(t){t.resolveTargetDelta()}function _d(t){t.calcProjection()}function Wd(t){t.resetSkewAndRotation()}function Kd(t){t.removeLeadSnapshot()}function so(t,e,n){t.translate=z(e.translate,0,n),t.scale=z(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function io(t,e,n,s){t.min=z(e.min,n.min,s),t.max=z(e.max,n.max,s)}function Hd(t,e,n,s){io(t.x,e.x,n.x,s),io(t.y,e.y,n.y,s)}function Xd(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Yd={duration:.45,ease:[.4,0,.1,1]},oo=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),ro=oo("applewebkit/")&&!oo("chrome/")?Math.round:ut;function ao(t){t.min=ro(t.min),t.max=ro(t.max)}function Gd(t){ao(t.x),ao(t.y)}function Hr(t,e,n){return t==="position"||t==="preserve-aspect"&&!ed(Ji(e),Ji(n),.2)}function qd(t){return t!==t.root&&t.scroll?.wasRoot}const Zd=Kr({attachResizeListener:(t,e)=>je(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),An={current:void 0},Xr=Kr({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!An.current){const t=new Zd({});t.mount(window),t.setOptions({layoutScroll:!0}),An.current=t}return An.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Jd={pan:{Feature:gd},drag:{Feature:pd,ProjectionNode:Xr,MeasureLayout:Br}};function lo(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&F.postRender(()=>r(e,ke(e)))}class Qd extends Et{mount(){const{current:e}=this.node;e&&(this.unmount=wc(e,(n,s)=>(lo(this.node,s,"Start"),i=>lo(this.node,i,"End"))))}unmount(){}}class th extends Et{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=De(je(this.node.current,"focus",()=>this.onFocus()),je(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function co(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),r=s[i];r&&F.postRender(()=>r(e,ke(e)))}class eh extends Et{mount(){const{current:e}=this.node;e&&(this.unmount=Ac(e,(n,s)=>(co(this.node,s,"Start"),(i,{success:r})=>co(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Gn=new WeakMap,Pn=new WeakMap,nh=t=>{const e=Gn.get(t.target);e&&e(t)},sh=t=>{t.forEach(nh)};function ih({root:t,...e}){const n=t||document;Pn.has(n)||Pn.set(n,{});const s=Pn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(sh,{root:t,...e})),s[i]}function oh(t,e,n){const s=ih(e);return Gn.set(t,n),s.observe(t),()=>{Gn.delete(t),s.unobserve(t)}}const rh={some:0,all:1};class ah extends Et{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:r}=e,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:rh[i]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,r&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=u?c:d;f&&f(l)};return oh(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(lh(e,n))&&this.startObserver()}unmount(){}}function lh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Yr={inView:{Feature:ah},tap:{Feature:eh},focus:{Feature:th},hover:{Feature:Qd}},ch={layout:{ProjectionNode:Xr,MeasureLayout:Br}},uh={...Rr,...Yr,...Jd,...ch},dh=fu(uh,Mr),hh={renderer:Mr,...Rr,...Yr};function Gr(t,e){return He(t,e)}const Ue=Gr("div"),fh=Gr("p");function qr(t,e){if(!e)throw new Error(`❌ toolMetadata is required!
|
|
9
|
+
`),()=>{w.contains(v)&&w.removeChild(v)}},[t]),h.jsx(kc,{isPresent:t,childRef:r,sizeRef:o,children:fe.cloneElement(e,{ref:l})})}const Nc=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const u=es(Ic),c=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:c,initial:t,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const y of u.values())if(!y)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return r&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,y)=>u.set(y,!1))},[n]),fe.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),o==="popLayout"&&(e=h.jsx(Rc,{isPresent:n,anchorX:a,root:l,children:e})),h.jsx(nn.Provider,{value:f,children:e})};function Ic(){return new Map}function ar(e=!0){const t=m.useContext(nn);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=t,r=m.useId();m.useEffect(()=>{if(e)return i(r)},[e]);const o=m.useCallback(()=>e&&s&&s(r),[r,s,e]);return!n&&s?[!1,o]:[!0]}const zt=e=>e.key||"";function xi(e){const t=[];return m.Children.forEach(e,n=>{m.isValidElement(n)&&t.push(n)}),t}const Lc=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[u,c]=ar(o),d=m.useMemo(()=>xi(e),[e]),f=o&&!u?[]:d.map(zt),g=m.useRef(!0),y=m.useRef(d),v=es(()=>new Map),[w,x]=m.useState(d),[S,b]=m.useState(d);go(()=>{g.current=!1,y.current=d;for(let D=0;D<S.length;D++){const R=zt(S[D]);f.includes(R)?v.delete(R):v.get(R)!==!0&&v.set(R,!1)}},[S,f.length,f.join("-")]);const k=[];if(d!==w){let D=[...d];for(let R=0;R<S.length;R++){const P=S[R],N=zt(P);f.includes(N)||(D.splice(R,0,P),k.push(P))}return r==="wait"&&k.length&&(D=k),b(xi(D)),x(d),null}process.env.NODE_ENV!=="production"&&r==="wait"&&S.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:A}=m.useContext(Qn);return h.jsx(h.Fragment,{children:S.map(D=>{const R=zt(D),P=o&&!u?!1:d===S||f.includes(R),N=()=>{if(v.has(R))v.set(R,!0);else return;let W=!0;v.forEach(U=>{U||(W=!1)}),W&&(A?.(),b(y.current),o&&c?.(),s&&s())};return h.jsx(Nc,{isPresent:P,initial:!g.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:P?void 0:N,anchorX:a,children:D},R)})})},Cs=m.createContext({strict:!1}),vi={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},ot={};for(const e in vi)ot[e]={isEnabled:t=>vi[e].some(n=>!!t[n])};function Un(e){for(const t in e)ot[t]={...ot[t],...e[t]}}function Oc({children:e,features:t,strict:n=!1}){const[,s]=m.useState(!vn(t)),i=m.useRef(void 0);if(!vn(t)){const{renderer:r,...o}=t;i.current=r,Un(o)}return m.useEffect(()=>{vn(t)&&t().then(({renderer:r,...o})=>{Un(o),i.current=r,s(!0)})},[]),h.jsx(Cs.Provider,{value:{renderer:i.current,strict:n},children:e})}function vn(e){return typeof e=="function"}const Fc=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function en(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Fc.has(e)}let lr=e=>!en(e);function Bc(e){typeof e=="function"&&(lr=t=>t.startsWith("on")?!en(t):e(t))}try{Bc(require("@emotion/is-prop-valid").default)}catch{}function $c(e,t,n){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||(lr(i)||n===!0&&en(i)||!t&&!en(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const sn=m.createContext({});function on(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Pt(e){return typeof e=="string"||Array.isArray(e)}const As=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Ps=["initial",...As];function rn(e){return on(e.animate)||Ps.some(t=>Pt(e[t]))}function cr(e){return!!(rn(e)||e.variants)}function zc(e,t){if(rn(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Pt(n)?n:void 0,animate:Pt(s)?s:void 0}}return e.inherit!==!1?t:{}}function Uc(e){const{initial:t,animate:n}=zc(e,m.useContext(sn));return m.useMemo(()=>({initial:t,animate:n}),[bi(t),bi(n)])}function bi(e){return Array.isArray(e)?e.join(" "):e}const Mt={};function _c(e){for(const t in e)Mt[t]=e[t],cs(t)&&(Mt[t].isCSSVariable=!0)}function ur(e,{layout:t,layoutId:n}){return ct.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Mt[e]||e==="opacity")}const Wc={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Kc=lt.length;function Hc(e,t,n){let s="",i=!0;for(let r=0;r<Kc;r++){const o=lt[r],a=e[o];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(o.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=tr(a,bs[o]);if(!l){i=!1;const c=Wc[o]||o;s+=`${c}(${u}) `}n&&(t[o]=u)}}return s=s.trim(),n?s=n(t,i?"":s):i&&(s="none"),s}function Ms(e,t,n){const{style:s,vars:i,transformOrigin:r}=e;let o=!1,a=!1;for(const l in t){const u=t[l];if(ct.has(l)){o=!0;continue}else if(cs(l)){i[l]=u;continue}else{const c=tr(u,bs[l]);l.startsWith("origin")?(a=!0,r[l]=c):s[l]=c}}if(t.transform||(o||n?s.transform=Hc(t,e.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:c=0}=r;s.transformOrigin=`${l} ${u} ${c}`}}const js=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function dr(e,t,n){for(const s in t)!te(t[s])&&!ur(s,n)&&(e[s]=t[s])}function Xc({transformTemplate:e},t){return m.useMemo(()=>{const n=js();return Ms(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Gc(e,t){const n=e.style||{},s={};return dr(s,n,e),Object.assign(s,Xc(e,t)),s}function Yc(e,t){const n={},s=Gc(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const qc={offset:"stroke-dashoffset",array:"stroke-dasharray"},Zc={offset:"strokeDashoffset",array:"strokeDasharray"};function Jc(e,t,n=1,s=0,i=!0){e.pathLength=1;const r=i?qc:Zc;e[r.offset]=E.transform(-s);const o=E.transform(t),a=E.transform(n);e[r.array]=`${o} ${a}`}function hr(e,{attrX:t,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,u,c){if(Ms(e,a,u),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=c?.transformBox??"fill-box",delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&Jc(d,i,r,o,!1)}const fr=()=>({...js(),attrs:{}}),mr=e=>typeof e=="string"&&e.toLowerCase()==="svg";function Qc(e,t,n,s){const i=m.useMemo(()=>{const r=fr();return hr(r,t,mr(s),e.transformTemplate,e.style),{...r.attrs,style:{...r.style}}},[t]);if(e.style){const r={};dr(r,e.style,e),i.style={...r,...i.style}}return i}const eu=["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 Es(e){return typeof e!="string"||e.includes("-")?!1:!!(eu.indexOf(e)>-1||/[A-Z]/u.test(e))}function tu(e,t,n,{latestValues:s},i,r=!1){const a=(Es(e)?Qc:Yc)(t,s,i,e),l=$c(t,typeof e=="string",r),u=e!==m.Fragment?{...l,...a,ref:n}:{},{children:c}=t,d=m.useMemo(()=>te(c)?c.get():c,[c]);return m.createElement(e,{...u,children:d})}function wi(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Ds(e,t,n,s){if(typeof t=="function"){const[i,r]=wi(s);t=t(n!==void 0?n:e.custom,i,r)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,r]=wi(s);t=t(n!==void 0?n:e.custom,i,r)}return t}function Ht(e){return te(e)?e.get():e}function nu({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,i){return{latestValues:su(n,s,i,e),renderState:t()}}function su(e,t,n,s){const i={},r=s(e,{});for(const f in r)i[f]=Ht(r[f]);let{initial:o,animate:a}=e;const l=rn(e),u=cr(e);t&&u&&!l&&e.inherit!==!1&&(o===void 0&&(o=t.initial),a===void 0&&(a=t.animate));let c=n?n.initial===!1:!1;c=c||o===!1;const d=c?a:o;if(d&&typeof d!="boolean"&&!on(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=Ds(e,f[g]);if(y){const{transitionEnd:v,transition:w,...x}=y;for(const S in x){let b=x[S];if(Array.isArray(b)){const k=c?b.length-1:0;b=b[k]}b!==null&&(i[S]=b)}for(const S in v)i[S]=v[S]}}}return i}const pr=e=>(t,n)=>{const s=m.useContext(sn),i=m.useContext(nn),r=()=>nu(e,t,s,i);return n?r():es(r)};function Vs(e,t,n){const{style:s}=e,i={};for(const r in s)(te(s[r])||t.style&&te(t.style[r])||ur(r,e)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const iu=pr({scrapeMotionValuesFromProps:Vs,createRenderState:js});function gr(e,t,n){const s=Vs(e,t,n);for(const i in e)if(te(e[i])||te(t[i])){const r=lt.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=e[i]}return s}const ou=pr({scrapeMotionValuesFromProps:gr,createRenderState:fr}),ru=Symbol.for("motionComponentSymbol");function Je(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function au(e,t,n){return m.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):Je(n)&&(n.current=s))},[t])}const ks=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),lu="framerAppearId",yr="data-"+ks(lu),xr=m.createContext({});function cu(e,t,n,s,i){const{visualElement:r}=m.useContext(sn),o=m.useContext(Cs),a=m.useContext(nn),l=m.useContext(Ss).reducedMotion,u=m.useRef(null);s=s||o.renderer,!u.current&&s&&(u.current=s(e,{visualState:t,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const c=u.current,d=m.useContext(xr);c&&!c.projection&&i&&(c.type==="html"||c.type==="svg")&&uu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{c&&f.current&&c.update(n,a)});const g=n[yr],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return go(()=>{c&&(f.current=!0,window.MotionIsMounted=!0,c.updateFeatures(),c.scheduleRenderMicrotask(),y.current&&c.animationState&&c.animationState.animateChanges())}),m.useEffect(()=>{c&&(!y.current&&c.animationState&&c.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),c.enteringChildren=void 0)}),c}function uu(e,t,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:vr(e.parent)),e.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&Je(a),visualElement:e,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u})}function vr(e){if(e)return e.options.allowProjection!==!1?e.projection:vr(e.parent)}function Xt(e,{forwardMotionProps:t=!1}={},n,s){n&&Un(n);const i=Es(e)?ou:iu;function r(a,l){let u;const c={...m.useContext(Ss),...a,layoutId:du(a)},{isStatic:d}=c,f=Uc(a),g=i(a,d);if(!d&&ts){hu(c,n);const y=fu(c);u=y.MeasureLayout,f.visualElement=cu(e,g,c,s,y.ProjectionNode)}return h.jsxs(sn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...c}):null,tu(e,a,au(g,f.visualElement,l),g,d,t)]})}r.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const o=m.forwardRef(r);return o[ru]=e,o}function du({layoutId:e}){const t=m.useContext(Qn).id;return t&&e!==void 0?t+"-"+e:e}function hu(e,t){const n=m.useContext(Cs).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?rt(!1,s,"lazy-strict-mode"):Se(!1,s,"lazy-strict-mode")}}function fu(e){const{drag:t,layout:n}=ot;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function mu(e,t){if(typeof Proxy>"u")return Xt;const n=new Map,s=(r,o)=>Xt(r,o,e,t),i=(r,o)=>(process.env.NODE_ENV!=="production"&&rs(!1,"motion() is deprecated. Use motion.create() instead."),s(r,o));return new Proxy(i,{get:(r,o)=>o==="create"?s:(n.has(o)||n.set(o,Xt(o,void 0,e,t)),n.get(o))})}function br({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function pu({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function gu(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function bn(e){return e===void 0||e===1}function _n({scale:e,scaleX:t,scaleY:n}){return!bn(e)||!bn(t)||!bn(n)}function Ue(e){return _n(e)||wr(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function wr(e){return Ti(e.x)||Ti(e.y)}function Ti(e){return e&&e!=="0%"}function tn(e,t,n){const s=e-n,i=t*s;return n+i}function Si(e,t,n,s,i){return i!==void 0&&(e=tn(e,i,s)),tn(e,n,s)+t}function Wn(e,t=0,n=1,s,i){e.min=Si(e.min,t,n,s,i),e.max=Si(e.max,t,n,s,i)}function Tr(e,{x:t,y:n}){Wn(e.x,t.translate,t.scale,t.originPoint),Wn(e.y,n.translate,n.scale,n.originPoint)}const Ci=.999999999999,Ai=1.0000000000001;function yu(e,t,n,s=!1){const i=n.length;if(!i)return;t.x=t.y=1;let r,o;for(let a=0;a<i;a++){r=n[a],o=r.projectionDelta;const{visualElement:l}=r.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&et(e,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Tr(e,o)),s&&Ue(r.latestValues)&&et(e,r.latestValues))}t.x<Ai&&t.x>Ci&&(t.x=1),t.y<Ai&&t.y>Ci&&(t.y=1)}function Qe(e,t){e.min=e.min+t,e.max=e.max+t}function Pi(e,t,n,s,i=.5){const r=z(e.min,e.max,i);Wn(e,t,n,r,s)}function et(e,t){Pi(e.x,t.x,t.scaleX,t.scale,t.originX),Pi(e.y,t.y,t.scaleY,t.scale,t.originY)}function Sr(e,t){return br(gu(e.getBoundingClientRect(),t))}function xu(e,t,n){const s=Sr(e,n),{scroll:i}=t;return i&&(Qe(s.x,i.offset.x),Qe(s.y,i.offset.y)),s}const Mi=()=>({translate:0,scale:1,origin:0,originPoint:0}),tt=()=>({x:Mi(),y:Mi()}),ji=()=>({min:0,max:0}),H=()=>({x:ji(),y:ji()}),Kn={current:null},Cr={current:!1};function vu(){if(Cr.current=!0,!!ts)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Kn.current=e.matches;e.addEventListener("change",t),t()}else Kn.current=!1}const bu=new WeakMap;function wu(e,t,n){for(const s in t){const i=t[s],r=n[s];if(te(i))e.addValue(s,i);else if(te(r))e.addValue(s,it(i,{owner:e}));else if(r!==i)if(e.hasValue(s)){const o=e.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=e.getStaticValue(s);e.addValue(s,it(o!==void 0?o:i,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Ei=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Tu{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:r,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=xs,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=ie.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,F.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!r,this.isControllingVariants=rn(n),this.isVariantNode=cr(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];l[f]!==void 0&&te(g)&&g.set(l[f])}}mount(t){this.current=t,bu.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Cr.current||vu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Kn.current,process.env.NODE_ENV!=="production"&&rs(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Ee(this.notifyUpdate),Ee(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=ct.has(t);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[t]=o,this.props.onUpdate&&F.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),r&&r(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in ot){const n=ot[t];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[t]&&i&&s(this.props)&&(this.features[t]=new i(this)),this.features[t]){const r=this.features[t];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):H()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Ei.length;s++){const i=Ei[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=t[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=wu(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=it(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(yo(s)||vo(s))?s=parseFloat(s):!Ec(s)&&De.test(n)&&(s=er(t,n)),this.setBaseTarget(t,te(s)?s.get():s)),te(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const r=Ds(this.props,n,this.presenceContext?.custom);r&&(s=r[t])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!te(i)?i:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new os),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){ws.render(this.render)}}class Ar extends Tu{constructor(){super(...arguments),this.KeyframeResolver=yc}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;te(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Pr(e,{style:t,vars:n},s,i){const r=e.style;let o;for(o in t)r[o]=t[o];i?.applyProjectionStyles(r,s);for(o in n)r.setProperty(o,n[o])}function Su(e){return window.getComputedStyle(e)}class Cu extends Ar{constructor(){super(...arguments),this.type="html",this.renderInstance=Pr}readValueFromInstance(t,n){if(ct.has(n))return this.projection?.isProjecting?In(n):Il(t,n);{const s=Su(t),i=(cs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Sr(t,n)}build(t,n,s){Ms(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return Vs(t,n,s)}}const Mr=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Au(e,t,n,s){Pr(e,t,void 0,s);for(const i in t.attrs)e.setAttribute(Mr.has(i)?i:ks(i),t.attrs[i])}class Pu extends Ar{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=H}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(ct.has(n)){const s=Qo(n);return s&&s.default||0}return n=Mr.has(n)?n:ks(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return gr(t,n,s)}build(t,n,s){hr(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,i){Au(t,n,s,i)}mount(t){this.isSVGTag=mr(t.tagName),super.mount(t)}}const jr=(e,t)=>Es(e)?new Pu(t):new Cu(t,{allowProjection:e!==m.Fragment});function st(e,t,n){const s=e.getProps();return Ds(s,t,n!==void 0?n:s.custom,e)}const Hn=e=>Array.isArray(e);function Mu(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,it(n))}function ju(e){return Hn(e)?e[e.length-1]||0:e}function Eu(e,t){const n=st(e,t);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=ju(r[o]);Mu(e,o,a)}}function Du(e){return!!(te(e)&&e.add)}function Xn(e,t){const n=e.getValue("willChange");if(Du(n))return n.add(t);if(!n&&Ce.WillChange){const s=new Ce.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function Er(e){return e.props[yr]}const Vu=e=>e!==null;function ku(e,{repeat:t,repeatType:n="loop"},s){const i=e.filter(Vu),r=t&&n!=="loop"&&t%2===1?0:i.length-1;return i[r]}const Ru={type:"spring",stiffness:500,damping:25,restSpeed:10},Nu=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Iu={type:"keyframes",duration:.8},Lu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Ou=(e,{keyframes:t})=>t.length>2?Iu:ct.has(e)?e.startsWith("scale")?Nu(t[1]):Ru:Lu;function Fu({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const Rs=(e,t,n,s={},i,r)=>o=>{const a=vs(s,e)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-me(l);const c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-u,onUpdate:f=>{t.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:r?void 0:i};Fu(a)||Object.assign(c,Ou(e,c)),c.duration&&(c.duration=me(c.duration)),c.repeatDelay&&(c.repeatDelay=me(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&($n(c),c.delay===0&&(d=!0)),(Ce.instantAnimations||Ce.skipAnimations)&&(d=!0,$n(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,d&&!r&&t.get()!==void 0){const f=ku(c.keyframes,a);if(f!==void 0){F.update(()=>{c.onUpdate(f),c.onComplete()});return}}return a.isSync?new ys(c):new ic(c)};function Bu({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function Dr(e,t,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=e.getDefaultTransition(),transitionEnd:o,...a}=t;s&&(r=s);const l=[],u=i&&e.animationState&&e.animationState.getState()[i];for(const c in a){const d=e.getValue(c,e.latestValues[c]??null),f=a[c];if(f===void 0||u&&Bu(u,c))continue;const g={delay:n,...vs(r||{},c)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=Er(e);if(x){const S=window.MotionHandoffAnimation(x,c,F);S!==null&&(g.startTime=S,v=!0)}}Xn(e,c),d.start(Rs(c,d,f,e.shouldReduceMotion&&qo.has(c)?{type:!1}:g,e,v));const w=d.animation;w&&l.push(w)}return o&&Promise.all(l).then(()=>{F.update(()=>{o&&Eu(e,o)})}),l}function Vr(e,t,n,s=0,i=1){const r=Array.from(e).sort((u,c)=>u.sortNodePosition(c)).indexOf(t),o=e.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Gn(e,t,n={}){const s=st(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const r=s?()=>Promise.all(Dr(e,s,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=i;return $u(e,t,l,u,c,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,u]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>u())}else return Promise.all([r(),o(n.delay)])}function $u(e,t,n=0,s=0,i=0,r=1,o){const a=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),a.push(Gn(l,t,{...o,delay:n+(typeof s=="function"?0:s)+Vr(e.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function zu(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const i=t.map(r=>Gn(e,r,n));s=Promise.all(i)}else if(typeof t=="string")s=Gn(e,t,n);else{const i=typeof t=="function"?st(e,t,n.custom):t;s=Promise.all(Dr(e,i,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function kr(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}const Uu=Ps.length;function Rr(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Rr(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<Uu;n++){const s=Ps[n],i=e.props[s];(Pt(i)||i===!1)&&(t[s]=i)}return t}const _u=[...As].reverse(),Wu=As.length;function Ku(e){return t=>Promise.all(t.map(({animation:n,options:s})=>zu(e,n,s)))}function Hu(e){let t=Ku(e),n=Di(),s=!0;const i=l=>(u,c)=>{const d=st(e,c,l==="exit"?e.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;u={...u,...y,...g}}return u};function r(l){t=l(e)}function o(l){const{props:u}=e,c=Rr(e.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let w=0;w<Wu;w++){const x=_u[w],S=n[x],b=u[x]!==void 0?u[x]:c[x],k=Pt(b),A=x===l?S.isActive:null;A===!1&&(y=w);let D=b===c[x]&&b!==u[x]&&k;if(D&&s&&e.manuallyAnimateOnMount&&(D=!1),S.protectedKeys={...g},!S.isActive&&A===null||!b&&!S.prevProp||on(b)||typeof b=="boolean")continue;const R=Xu(S.prevProp,b);let P=R||x===l&&S.isActive&&!D&&k||w>y&&k,N=!1;const W=Array.isArray(b)?b:[b];let U=W.reduce(i(x),{});A===!1&&(U={});const{prevResolvedValues:we={}}=S,Ae={...we,...U},de=V=>{P=!0,f.has(V)&&(N=!0,f.delete(V)),S.needsAnimating[V]=!0;const Y=e.getValue(V);Y&&(Y.liveStyle=!1)};for(const V in Ae){const Y=U[V],X=we[V];if(g.hasOwnProperty(V))continue;let oe=!1;Hn(Y)&&Hn(X)?oe=!kr(Y,X):oe=Y!==X,oe?Y!=null?de(V):f.add(V):Y!==void 0&&f.has(V)?de(V):S.protectedKeys[V]=!0}S.prevProp=b,S.prevResolvedValues=U,S.isActive&&(g={...g,...U}),s&&e.blockInitialAnimation&&(P=!1);const se=D&&R;P&&(!se||N)&&d.push(...W.map(V=>{const Y={type:x};if(typeof V=="string"&&s&&!se&&e.manuallyAnimateOnMount&&e.parent){const{parent:X}=e,oe=st(X,V);if(X.enteringChildren&&oe){const{delayChildren:_}=oe.transition||{};Y.delay=Vr(X.enteringChildren,e,_)}}return{animation:V,options:Y}}))}if(f.size){const w={};if(typeof u.initial!="boolean"){const x=st(e,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(w.transition=x.transition)}f.forEach(x=>{const S=e.getBaseTarget(x),b=e.getValue(x);b&&(b.liveStyle=!0),w[x]=S??null}),d.push({animation:w})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(v=!1),s=!1,v?t(d):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();e.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;const c=o(l);for(const d in n)n[d].protectedKeys={};return c}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Di()}}}function Xu(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!kr(t,e):!1}function $e(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Di(){return{animate:$e(!0),whileInView:$e(),whileHover:$e(),whileTap:$e(),whileDrag:$e(),whileFocus:$e(),exit:$e()}}class Ve{constructor(t){this.isMounted=!1,this.node=t}update(){}}class Gu extends Ve{constructor(t){super(t),t.animationState||(t.animationState=Hu(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();on(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Yu=0;class qu extends Ve{constructor(){super(...arguments),this.id=Yu++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Nr={animation:{Feature:Gu},exit:{Feature:qu}};function jt(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function Rt(e){return{point:{x:e.pageX,y:e.pageY}}}const Zu=e=>t=>Ts(t)&&e(t,Rt(t));function bt(e,t,n,s){return jt(e,t,Zu(n),s)}const Ir=1e-4,Ju=1-Ir,Qu=1+Ir,Lr=.01,ed=0-Lr,td=0+Lr;function ne(e){return e.max-e.min}function nd(e,t,n){return Math.abs(e-t)<=n}function Vi(e,t,n,s=.5){e.origin=s,e.originPoint=z(t.min,t.max,e.origin),e.scale=ne(n)/ne(t),e.translate=z(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Ju&&e.scale<=Qu||isNaN(e.scale))&&(e.scale=1),(e.translate>=ed&&e.translate<=td||isNaN(e.translate))&&(e.translate=0)}function wt(e,t,n,s){Vi(e.x,t.x,n.x,s?s.originX:void 0),Vi(e.y,t.y,n.y,s?s.originY:void 0)}function ki(e,t,n){e.min=n.min+t.min,e.max=e.min+ne(t)}function sd(e,t,n){ki(e.x,t.x,n.x),ki(e.y,t.y,n.y)}function Ri(e,t,n){e.min=t.min-n.min,e.max=e.min+ne(t)}function Tt(e,t,n){Ri(e.x,t.x,n.x),Ri(e.y,t.y,n.y)}function le(e){return[e("x"),e("y")]}const Or=({current:e})=>e?e.ownerDocument.defaultView:null,Ni=(e,t)=>Math.abs(e-t);function id(e,t){const n=Ni(e.x,t.x),s=Ni(e.y,t.y);return Math.sqrt(n**2+s**2)}class Fr{constructor(t,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:r=!1,distanceThreshold:o=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=Tn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=id(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:v}=f,{timestamp:w}=J;this.history.push({...v,timestamp:w});const{onStart:x,onMove:S}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=wn(g,this.transformPagePoint),F.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:v,resumeAnimation:w}=this.handlers;if(this.dragSnapToOrigin&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=Tn(f.type==="pointercancel"?this.lastMoveEventInfo:wn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!Ts(t))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=Rt(t),l=wn(a,this.transformPagePoint),{point:u}=l,{timestamp:c}=J;this.history=[{...u,timestamp:c}];const{onSessionStart:d}=n;d&&d(t,Tn(l,this.history)),this.removeListeners=Dt(bt(this.contextWindow,"pointermove",this.handlePointerMove),bt(this.contextWindow,"pointerup",this.handlePointerUp),bt(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Ee(this.updatePoint)}}function wn(e,t){return t?{point:t(e.point)}:e}function Ii(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Tn({point:e},t){return{point:e,delta:Ii(e,Br(t)),offset:Ii(e,od(t)),velocity:rd(t,.1)}}function od(e){return e[0]}function Br(e){return e[e.length-1]}function rd(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const i=Br(e);for(;n>=0&&(s=e[n],!(i.timestamp-s.timestamp>me(t)));)n--;if(!s)return{x:0,y:0};const r=ce(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function ad(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?z(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?z(n,e,s.max):Math.min(e,n)),e}function Li(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function ld(e,{top:t,left:n,bottom:s,right:i}){return{x:Li(e.x,n,i),y:Li(e.y,t,s)}}function Oi(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function cd(e,t){return{x:Oi(e.x,t.x),y:Oi(e.y,t.y)}}function ud(e,t){let n=.5;const s=ne(e),i=ne(t);return i>s?n=St(t.min,t.max-s,e.min):s>i&&(n=St(e.min,e.max-i,t.min)),Te(0,1,n)}function dd(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const Yn=.35;function hd(e=Yn){return e===!1?e=0:e===!0&&(e=Yn),{x:Fi(e,"left","right"),y:Fi(e,"top","bottom")}}function Fi(e,t,n){return{min:Bi(e,t),max:Bi(e,n)}}function Bi(e,t){return typeof e=="number"?e:e[t]||0}const fd=new WeakMap;class md{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=H(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const r=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Rt(d).point)},o=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=wc(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),le(x=>{let S=this.getAxisMotionValue(x).get()||0;if(be.test(S)){const{projection:b}=this.visualElement;if(b&&b.layout){const k=b.layout.layoutBox[x];k&&(S=ne(k)*(parseFloat(S)/100))}}this.originPoint[x]=S}),v&&F.postRender(()=>v(d,f)),Xn(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:v,onDrag:w}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:x}=f;if(y&&this.currentDirection===null){this.currentDirection=pd(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),w&&w(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>le(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new Fr(t,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:s,contextWindow:Or(this.visualElement)})}stop(t,n){const s=t||this.latestPointerEvent,i=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!i||!s)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&F.postRender(()=>a(s,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:i}=this.getProps();if(!s||!Ut(t,i,this.currentDirection))return;const r=this.getAxisMotionValue(t);let o=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(o=ad(o,this.constraints[t],this.elastic[t])),r.set(o)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;t&&Je(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=ld(s.layoutBox,t):this.constraints=!1,this.elastic=hd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&le(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=dd(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Je(t))return!1;const s=t.current;Se(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const r=xu(s,i.root,this.visualElement.getTransformPagePoint());let o=cd(i.layout.layoutBox,r);if(n){const a=n(pu(o));this.hasMutatedConstraints=!!a,a&&(o=br(a))}return o}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=le(c=>{if(!Ut(c,n,this.currentDirection))return;let d=l&&l[c]||{};o&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?t[c]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(c,y)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return Xn(this.visualElement,t),s.start(Rs(t,s,0,n,this.visualElement,!1))}stopAnimation(){le(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){le(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){le(n=>{const{drag:s}=this.getProps();if(!Ut(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n];r.set(t[n]-z(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Je(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};le(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=ud({min:l,max:l},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),le(o=>{if(!Ut(o,t,null))return;const a=this.getAxisMotionValue(o),{min:l,max:u}=this.constraints[o];a.set(z(l,u,i[o]))})}addListeners(){if(!this.visualElement.current)return;fd.set(this.visualElement,this);const t=this.visualElement.current,n=bt(t,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Je(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,r=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),F.read(s);const o=jt(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(le(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())});return()=>{o(),n(),r(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=Yn,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function Ut(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function pd(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class gd extends Ve{constructor(t){super(t),this.removeGroupControls=ue,this.removeListeners=ue,this.controls=new md(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ue}unmount(){this.removeGroupControls(),this.removeListeners()}}const $i=e=>(t,n)=>{e&&F.postRender(()=>e(t,n))};class yd extends Ve{constructor(){super(...arguments),this.removePointerDownListener=ue}onPointerDown(t){this.session=new Fr(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Or(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:$i(t),onStart:$i(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&F.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=bt(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Gt={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function zi(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const yt={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(E.test(e))e=parseFloat(e);else return e;const n=zi(e,t.target.x),s=zi(e,t.target.y);return`${n}% ${s}%`}},xd={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,i=De.parse(e);if(i.length>5)return s;const r=De.createTransformer(e),o=typeof i[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;i[0+o]/=a,i[1+o]/=l;const u=z(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=u),typeof i[3+o]=="number"&&(i[3+o]/=u),r(i)}};let Sn=!1;class vd extends m.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=t;_c(bd),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),Sn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),Gt.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,Sn=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==r?o.willUpdate():this.safeToRemove(),t.isPresent!==r&&(r?o.promote():o.relegate()||F.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),ws.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=t;Sn=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function $r(e){const[t,n]=ar(),s=m.useContext(Qn);return h.jsx(vd,{...e,layoutGroup:s,switchLayoutGroup:m.useContext(xr),isPresent:t,safeToRemove:n})}const bd={borderRadius:{...yt,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:yt,borderTopRightRadius:yt,borderBottomLeftRadius:yt,borderBottomRightRadius:yt,boxShadow:xd};function wd(e,t,n){const s=te(e)?e:it(e);return s.start(Rs("",s,t,n)),s.animation}const Td=(e,t)=>e.depth-t.depth;class Sd{constructor(){this.children=[],this.isDirty=!1}add(t){ns(this.children,t),this.isDirty=!0}remove(t){ss(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Td),this.isDirty=!1,this.children.forEach(t)}}function Cd(e,t){const n=ie.now(),s=({timestamp:i})=>{const r=i-n;r>=t&&(Ee(s),e(r-t))};return F.setup(s,!0),()=>Ee(s)}const zr=["TopLeft","TopRight","BottomLeft","BottomRight"],Ad=zr.length,Ui=e=>typeof e=="string"?parseFloat(e):e,_i=e=>typeof e=="number"||E.test(e);function Pd(e,t,n,s,i,r){i?(e.opacity=z(0,n.opacity??1,Md(s)),e.opacityExit=z(t.opacity??1,0,jd(s))):r&&(e.opacity=z(t.opacity??1,n.opacity??1,s));for(let o=0;o<Ad;o++){const a=`border${zr[o]}Radius`;let l=Wi(t,a),u=Wi(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||_i(l)===_i(u)?(e[a]=Math.max(z(Ui(l),Ui(u),s),0),(be.test(u)||be.test(l))&&(e[a]+="%")):e[a]=u}(t.rotate||n.rotate)&&(e.rotate=z(t.rotate||0,n.rotate||0,s))}function Wi(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const Md=Ur(0,.5,Mo),jd=Ur(.5,.95,ue);function Ur(e,t,n){return s=>s<e?0:s>t?1:n(St(e,t,s))}function Ki(e,t){e.min=t.min,e.max=t.max}function ae(e,t){Ki(e.x,t.x),Ki(e.y,t.y)}function Hi(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function Xi(e,t,n,s,i){return e-=t,e=tn(e,1/n,s),i!==void 0&&(e=tn(e,1/i,s)),e}function Ed(e,t=0,n=1,s=.5,i,r=e,o=e){if(be.test(t)&&(t=parseFloat(t),t=z(o.min,o.max,t/100)-o.min),typeof t!="number")return;let a=z(r.min,r.max,s);e===r&&(a-=t),e.min=Xi(e.min,t,n,a,i),e.max=Xi(e.max,t,n,a,i)}function Gi(e,t,[n,s,i],r,o){Ed(e,t[n],t[s],t[i],t.scale,r,o)}const Dd=["x","scaleX","originX"],Vd=["y","scaleY","originY"];function Yi(e,t,n,s){Gi(e.x,t,Dd,n?n.x:void 0,s?s.x:void 0),Gi(e.y,t,Vd,n?n.y:void 0,s?s.y:void 0)}function qi(e){return e.translate===0&&e.scale===1}function _r(e){return qi(e.x)&&qi(e.y)}function Zi(e,t){return e.min===t.min&&e.max===t.max}function kd(e,t){return Zi(e.x,t.x)&&Zi(e.y,t.y)}function Ji(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Wr(e,t){return Ji(e.x,t.x)&&Ji(e.y,t.y)}function Qi(e){return ne(e.x)/ne(e.y)}function eo(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Rd{constructor(){this.members=[]}add(t){ns(this.members,t),t.scheduleRender()}remove(t){if(ss(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(i=>t===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const r=this.members[i];if(r.isPresent!==!1){s=r;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender(),t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:i}=t.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Nd(e,t,n){let s="";const i=e.x.translate/t.x,r=e.y.translate/t.y,o=n?.z||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),c&&(s+=`rotate(${c}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),y&&(s+=`skewY(${y}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const Cn=["","X","Y","Z"],Id=1e3;let Ld=0;function An(e,t,n,s){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),s&&(s[e]=0))}function Kr(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Er(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",F,!(i||r))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&Kr(s)}function Hr({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=t?.()){this.id=Ld++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Bd),this.nodes.forEach(_d),this.nodes.forEach(Wd),this.nodes.forEach($d)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Sd)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new os),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=rr(o)&&!Mc(o),this.instance=o;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let c,d=0;const f=()=>this.root.updateBlockedByResize=!1;F.read(()=>{d=window.innerWidth}),e(o,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,c&&c(),c=Cd(f,250),Gt.hasAnimatedSinceResize&&(Gt.hasAnimatedSinceResize=!1,this.nodes.forEach(so)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||Yd,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=u.getProps(),x=!this.targetLayout||!Wr(this.targetLayout,g),S=!d&&f;if(this.options.layoutRoot||this.resumeFrom||S||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...vs(y,"layout"),onPlay:v,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(c,S)}else d||so(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Ee(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Kd),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Kr(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const d=this.path[c];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(to);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(no);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Ud),this.nodes.forEach(Od),this.nodes.forEach(Fd)):this.nodes.forEach(no),this.clearAllSnapshots();const a=ie.now();J.delta=Te(0,1e3/60,a-J.timestamp),J.timestamp=a,J.isProcessing=!0,fn.update.process(J),fn.preRender.process(J),fn.render.process(J),J.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,ws.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(zd),this.sharedNodes.forEach(Hd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,F.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){F.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ne(this.snapshot.measuredBox.x)&&!ne(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=H(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!_r(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;o&&this.instance&&(a||Ue(this.latestValues)||c)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),qd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return H();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Zd))){const{scroll:u}=this.root;u&&(Qe(a.x,u.offset.x),Qe(a.y,u.offset.y))}return a}removeElementScroll(o){const a=H();if(ae(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:d}=u;u!==this.root&&c&&d.layoutScroll&&(c.wasRoot&&ae(a,o),Qe(a.x,c.offset.x),Qe(a.y,c.offset.y))}return a}applyTransform(o,a=!1){const l=H();ae(l,o);for(let u=0;u<this.path.length;u++){const c=this.path[u];!a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&et(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),Ue(c.latestValues)&&et(l,c.latestValues)}return Ue(this.latestValues)&&et(l,this.latestValues),l}removeTransform(o){const a=H();ae(a,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Ue(u.latestValues))continue;_n(u.latestValues)&&u.updateSnapshot();const c=H(),d=u.measurePageBox();ae(c,d),Yi(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return Ue(this.latestValues)&&Yi(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==J.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:d}=this.options;if(!(!this.layout||!(c||d))){if(this.resolvedRelativeTargetAt=J.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=H(),this.relativeTargetOrigin=H(),Tt(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),ae(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=H(),this.targetWithTransforms=H()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),sd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):ae(this.target,this.layout.layoutBox),Tr(this.target,this.targetDelta)):ae(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=H(),this.relativeTargetOrigin=H(),Tt(this.relativeTargetOrigin,this.target,f.target),ae(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||_n(this.parent.latestValues)||wr(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const o=this.getLead(),a=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===J.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||c))return;ae(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;yu(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=H());const{target:g}=o;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Hi(this.prevProjectionDelta.x,this.projectionDelta.x),Hi(this.prevProjectionDelta.y,this.projectionDelta.y)),wt(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!eo(this.projectionDelta.x,this.prevProjectionDelta.x)||!eo(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=tt(),this.projectionDelta=tt(),this.projectionDeltaWithTransform=tt()}setAnimationOrigin(o,a=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},d=tt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=H(),g=l?l.source:void 0,y=this.layout?this.layout.source:void 0,v=g!==y,w=this.getStack(),x=!w||w.members.length<=1,S=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(Gd));this.animationProgress=0;let b;this.mixTargetDelta=k=>{const A=k/1e3;io(d.x,o.x,A),io(d.y,o.y,A),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Tt(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Xd(this.relativeTarget,this.relativeTargetOrigin,f,A),b&&kd(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=H()),ae(b,this.relativeTarget)),v&&(this.animationValues=c,Pd(c,u,this.latestValues,A,S,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=A},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Ee(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=F.update(()=>{Gt.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=it(0)),this.currentAnimation=wd(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Id),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:c}=o;if(!(!a||!l||!u)){if(this!==o&&this.layout&&u&&Xr(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||H();const d=ne(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=ne(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}ae(a,l),et(a,c),wt(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Rd),this.sharedNodes.get(o).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&An("z",o,u,this.animationValues);for(let c=0;c<Cn.length;c++)An(`rotate${Cn[c]}`,o,u,this.animationValues),An(`skew${Cn[c]}`,o,u,this.animationValues);o.render();for(const c in u)o.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Ht(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Ht(a?.pointerEvents)||""),this.hasProjected&&!Ue(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=Nd(this.projectionDeltaWithTransform,this.treeScale,c);l&&(d=l(c,d)),o.transform=d;const{x:f,y:g}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?o.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:o.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const y in Mt){if(c[y]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:x}=Mt[y],S=d==="none"?c[y]:v(c[y],u);if(w){const b=w.length;for(let k=0;k<b;k++)o[w[k]]=S}else x?this.options.visualElement.renderState.vars[y]=S:o[y]=S}this.options.layoutId&&(o.pointerEvents=u===this?Ht(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(to),this.root.sharedNodes.clear()}}}function Od(e){e.updateLayout()}function Fd(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=e.layout,{animationType:i}=e.options,r=t.source!==e.layout.source;i==="size"?le(c=>{const d=r?t.measuredBox[c]:t.layoutBox[c],f=ne(d);d.min=n[c].min,d.max=d.min+f}):Xr(i,t.layoutBox,n)&&le(c=>{const d=r?t.measuredBox[c]:t.layoutBox[c],f=ne(n[c]);d.max=d.min+f,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[c].max=e.relativeTarget[c].min+f)});const o=tt();wt(o,n,t.layoutBox);const a=tt();r?wt(a,e.applyTransform(s,!0),t.measuredBox):wt(a,n,t.layoutBox);const l=!_r(o);let u=!1;if(!e.resumeFrom){const c=e.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:d,layout:f}=c;if(d&&f){const g=H();Tt(g,t.layoutBox,d.layoutBox);const y=H();Tt(y,n,f.layoutBox),Wr(g,y)||(u=!0),c.options.layoutRoot&&(e.relativeTarget=y,e.relativeTargetOrigin=g,e.relativeParent=c)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function Bd(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function $d(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function zd(e){e.clearSnapshot()}function to(e){e.clearMeasurements()}function no(e){e.isLayoutDirty=!1}function Ud(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function so(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function _d(e){e.resolveTargetDelta()}function Wd(e){e.calcProjection()}function Kd(e){e.resetSkewAndRotation()}function Hd(e){e.removeLeadSnapshot()}function io(e,t,n){e.translate=z(t.translate,0,n),e.scale=z(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function oo(e,t,n,s){e.min=z(t.min,n.min,s),e.max=z(t.max,n.max,s)}function Xd(e,t,n,s){oo(e.x,t.x,n.x,s),oo(e.y,t.y,n.y,s)}function Gd(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const Yd={duration:.45,ease:[.4,0,.1,1]},ro=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),ao=ro("applewebkit/")&&!ro("chrome/")?Math.round:ue;function lo(e){e.min=ao(e.min),e.max=ao(e.max)}function qd(e){lo(e.x),lo(e.y)}function Xr(e,t,n){return e==="position"||e==="preserve-aspect"&&!nd(Qi(t),Qi(n),.2)}function Zd(e){return e!==e.root&&e.scroll?.wasRoot}const Jd=Hr({attachResizeListener:(e,t)=>jt(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Pn={current:void 0},Gr=Hr({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Pn.current){const e=new Jd({});e.mount(window),e.setOptions({layoutScroll:!0}),Pn.current=e}return Pn.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Qd={pan:{Feature:yd},drag:{Feature:gd,ProjectionNode:Gr,MeasureLayout:$r}};function co(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&F.postRender(()=>r(t,Rt(t)))}class eh extends Ve{mount(){const{current:t}=this.node;t&&(this.unmount=Tc(t,(n,s)=>(co(this.node,s,"Start"),i=>co(this.node,i,"End"))))}unmount(){}}class th extends Ve{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Dt(jt(this.node.current,"focus",()=>this.onFocus()),jt(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function uo(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),r=s[i];r&&F.postRender(()=>r(t,Rt(t)))}class nh extends Ve{mount(){const{current:t}=this.node;t&&(this.unmount=Pc(t,(n,s)=>(uo(this.node,s,"Start"),(i,{success:r})=>uo(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const qn=new WeakMap,Mn=new WeakMap,sh=e=>{const t=qn.get(e.target);t&&t(e)},ih=e=>{e.forEach(sh)};function oh({root:e,...t}){const n=e||document;Mn.has(n)||Mn.set(n,{});const s=Mn.get(n),i=JSON.stringify(t);return s[i]||(s[i]=new IntersectionObserver(ih,{root:e,...t})),s[i]}function rh(e,t,n){const s=oh(t);return qn.set(e,n),s.observe(e),()=>{qn.delete(e),s.unobserve(e)}}const ah={some:0,all:1};class lh extends Ve{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:r}=t,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:ah[i]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,r&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=u?c:d;f&&f(l)};return rh(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(ch(t,n))&&this.startObserver()}unmount(){}}function ch({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Yr={inView:{Feature:lh},tap:{Feature:nh},focus:{Feature:th},hover:{Feature:eh}},uh={layout:{ProjectionNode:Gr,MeasureLayout:$r}},dh={...Nr,...Yr,...Qd,...uh},hh=mu(dh,jr),fh={renderer:jr,...Nr,...Yr};function qr(e,t){return Xt(e,t)}const _t=qr("div"),mh=qr("p"),Et=Symbol.for("@arcteninc/core:originalName");function ph(e,t){return e[Et]=t,e}function gh(e,t){const n=new Set,s=Object.values(t);e.forEach(i=>{if(typeof i!="function"||i[Et])return;const r=i.name;let o;r&&(o=t[r],o&&!n.has(o.name)?n.add(o.name):o=void 0),o||(o=s.find(a=>!n.has(a.name)),o&&n.add(o.name)),o&&(i[Et]=o.name)})}function Zr(e,t){if(!t)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)
|
|
@@ -14,10 +14,10 @@ Please:
|
|
|
14
14
|
import { toolMetadata } from './.arcten/tool-metadata';
|
|
15
15
|
3. Pass it to useAgent/ArctenAgent:
|
|
16
16
|
useAgent({ tools: [...], toolMetadata: toolMetadata.functions })
|
|
17
|
-
`);const n=new Set,s=Object.values(
|
|
18
|
-
To fix: Run "arcten-extract-types ." and ensure "${r}" is used in ArctenAgent/useAgent.`),null)}).filter(i=>i!==null)}function mh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const r=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),r&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([o,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[o,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},o))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(Ge,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(q.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(Ge,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(q.X,{className:"h-3 w-3"})})]})]})})}function ph({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,r]=m.useState(!1);if(t==="fetchDocContent")return null;const o=["k","maxResults","_organizationId"];t==="searchDocs"&&o.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!o.includes(u))),l=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>l&&r(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${l?"cursor-pointer hover:bg-opacity-80":""}`,children:[l&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(q.ChevronDown,{className:"h-3 w-3"}):h.jsx(q.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(q.X,{className:"h-3 w-3"}):s?h.jsx(q.Zap,{className:"h-3 w-3"}):h.jsx(q.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&l&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,c])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof c=="string"?c:JSON.stringify(c)})]},u))})})]})}function gh({...t}){return h.jsx(Zn.Root,{"data-slot":"collapsible",...t})}function yh({...t}){return h.jsx(Zn.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function xh({...t}){return h.jsx(Zn.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const vh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),Rs=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(vh,{className:Q("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);Rs.displayName="Response";const bh=Object.freeze(Object.defineProperty({__proto__:null,Response:Rs},Symbol.toStringTag,{value:"Module"})),wh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const r=dh.create(e),o=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(r,{animate:{backgroundPosition:"0% center"},className: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":`${o}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},Th=m.memo(wh),Zr=m.createContext(null),Sh=()=>{const t=m.useContext(Zr);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Ch=1e3,Ah=1e3,Jr=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:r,children:o,...a})=>{const[l,u]=Xs.useControllableState({prop:n,defaultProp:s,onChange:i}),[c,d]=Xs.useControllableState({prop:r,defaultProp:0}),[f,g]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{e?y===null&&v(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/Ah)),v(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&l&&!f){const x=setTimeout(()=>{u(!1),g(!0)},Ch);return()=>clearTimeout(x)}},[e,l,s,u,f]);const w=x=>{u(x)};return h.jsx(Zr.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:u,duration:c},children:h.jsx(gh,{className:Q("not-prose mb-4",t),onOpenChange:w,open:l,...a,children:o})})}),Ph=(t,e)=>t||e===0?h.jsx(Th,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Qr=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:r}=Sh();return h.jsx(yh,{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(q.BrainIcon,{className:"size-4"}),Ph(s,r),h.jsx(q.ChevronDownIcon,{className:Q("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),ta=m.memo(({className:t,children:e,...n})=>h.jsx(xh,{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(Rs,{className:"grid gap-2",children:e})}));Jr.displayName="Reasoning";Qr.displayName="ReasoningTrigger";ta.displayName="ReasoningContent";function Mh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:r=void 0,defaultWidth:o=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:c=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:y="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:w}){const[x,S]=m.useState(null),b=m.useRef(null),[k,A]=m.useState(null),[V,R]=m.useState(null),P=m.useRef(null),[N,W]=m.useState(u),[U,wt]=m.useState(o),[At,dt]=m.useState(600),[st,pt]=m.useState(!1),[E,G]=m.useState(!1),[X,ot]=m.useState(!1),[_,ue]=m.useState({x:100,y:100}),[Xt,kt]=m.useState(!1),[de,Rt]=m.useState({x:0,y:0}),[he,rn]=m.useState(!1),fe=m.useRef(null),Yt=m.useRef(null),[Nt,me]=m.useState(""),[j,M]=m.useState(null),[L,Z]=m.useState("Thinking..."),[K,rt]=m.useState(new Set),[ea,na]=m.useState(""),[It,sa]=m.useState([]),[an,Ns]=m.useState(!1),[ln,Is]=m.useState([]),[Ls,cn]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Gt,Re]=m.useState(!1),[Dh,Ne]=m.useState(!1),[Vh,Ie]=m.useState([]),gt=m.useMemo(()=>[...c,...d],[c,d]),Os=m.useMemo(()=>qr(gt,f),[gt,f]),Fs=m.useMemo(()=>new Set(gt.map(p=>p.name)),[gt]),un=m.useMemo(()=>Os.filter(p=>Fs.has(p.name)),[Os,Fs]),Bs=m.useMemo(()=>{const p=new Map;return gt.forEach(T=>p.set(T.name,T)),p},[gt]),$s=m.useMemo(()=>new Set(d.map(p=>p.name)),[d]),zs=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&W(JSON.parse(p));const T=localStorage.getItem("arcten-sidebar-width");T&&wt(parseInt(T));const I=localStorage.getItem("arcten-sidebar-height");I&&dt(parseInt(I));const C=localStorage.getItem("arcten-sidebar-detached");C&&G(JSON.parse(C));const B=localStorage.getItem("arcten-sidebar-position");if(B){const Pt=JSON.parse(B),xt=50,Mt=Math.max(xt-o,Math.min(Pt.x,window.innerWidth-xt)),tt=Math.max(0,Math.min(Pt.y,window.innerHeight-xt));ue({x:Mt,y:tt})}const O=localStorage.getItem("arcten-sidebar-minimized");O&&ot(JSON.parse(O)),rn(!0)}},[]),m.useEffect(()=>((async()=>{try{const T=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!T.ok)throw new Error("Failed to fetch token");const I=await T.json();S(I.clientToken),b.current=I.clientToken,R(I.expiresAt),A(null)}catch(T){A(T instanceof Error?T.message:"Failed to fetch token")}})(),()=>{P.current&&clearTimeout(P.current)}),[y,w]),m.useEffect(()=>{if(!V)return;P.current&&clearTimeout(P.current);const p=Math.floor(Date.now()/1e3),T=V-p,C=Math.max(0,T-5);return console.log(`Token expires at ${new Date(V*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${C} seconds`),P.current=setTimeout(async()=>{console.log("Refreshing token...");try{const B=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!B.ok)throw new Error("Failed to refresh token");const O=await B.json();S(O.clientToken),b.current=O.clientToken,R(O.expiresAt),A(null),console.log("Token refreshed successfully")}catch(B){console.error("Token refresh failed:",B),A(B instanceof Error?B.message:"Failed to refresh token")}},C*1e3),()=>{P.current&&clearTimeout(P.current)}},[V,y,w]),m.useEffect(()=>{(async()=>{if(gt.length!==0)try{const T=gt.map(C=>({name:C.name,code:C.toString()})),I=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:T})});if(I.ok){const C=await I.json();sa(C.tools)}}catch(T){console.error("Failed to fetch tool descriptions:",T)}})()},[gt]),m.useEffect(()=>{Promise.resolve().then(()=>bh).then(p=>{M(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{na(window.location.pathname)};p(),window.addEventListener("popstate",p);const T=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(T)}},[]);async function Us(){if(!(!w?.id||!x)){Ne(!0);try{const T=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${x}`}})).json();Is(T.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{Ne(!1)}}}m.useEffect(()=>{w?.id&&x&&Us()},[w,x]);function ia(p){const T=Math.floor((Date.now()-p)/1e3);return T<60?"now":T<3600?`${Math.floor(T/60)}m`:T<86400?`${Math.floor(T/3600)}h`:`${Math.floor(T/86400)}d`}function oa(){const p=crypto.randomUUID();cn(p),Oe([]),Ie([]),Re(!1)}async function ra(p){if(x)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${x}`}}),Is(ln.filter(T=>T._id!==p)),p===Ls&&oa()}catch(T){console.error("Failed to delete conversation:",T)}}async function aa(p){cn(p.chatId),Re(!1),Ne(!0);try{const T=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${b.current}`}});if(!T.ok)throw new Error(`Failed to fetch messages: ${T.statusText}`);const C=(await T.json()).messages||[];Oe(C),Ie(C)}catch(T){console.error("Failed to load conversation messages:",T);const I=p.messages||[];Oe(I),Ie(I)}finally{Ne(!1)}}const la=async(p,T={})=>{const I=T.headers?new Headers(T.headers):new Headers;return I.delete("user-agent"),I.delete("User-Agent"),fetch(p,{...T,headers:I})},{messages:pe,sendMessage:ca,status:yt,error:_s,stop:Le,addToolResult:ge,setMessages:Oe}=uo.useChat({id:Ls||void 0,transport:new Ye.DefaultChatTransport({api:`${v}/chat`,fetch:la,headers:()=>{const p={};return b.current&&(p.Authorization=`Bearer ${b.current}`),p},body:()=>{const p=un.map(T=>({name:T.name,description:T.description,inputSchema:T.jsonSchema}));return process.env.NODE_ENV==="development"&&console.log("[ArctenAgent] Sending tools to API:",{totalTools:p.length,toolNames:p.map(T=>T.name),allToolNames:gt.map(T=>T.name),filteredToolNames:un.map(T=>T.name)}),{tools:p,systemPrompt:g,currentRoute:ea}}}),sendAutomaticallyWhen:Ye.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{N&&Yt.current&&Yt.current.focus()},[N,pe]);function ua(){W(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function da(){W(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[N]),m.useEffect(()=>{fe.current&&fe.current.scrollIntoView({behavior:"smooth"})},[pe]),m.useEffect(()=>{function p(T){T.key==="Escape"&&(yt==="streaming"||yt==="submitted")&&(T.preventDefault(),Le())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[yt,Le]);function ha(){const p=crypto.randomUUID();cn(p),Oe([]),Ie([]),Re(!1)}function Ws(p){if(p.preventDefault(),!Nt.trim())return;(yt==="streaming"||yt==="submitted")&&Le();const T=zs[Math.floor(Math.random()*zs.length)]||"Thinking...";Z(T),ca({text:Nt}),me("")}function fa(p){const T=p.target.value;me(T)}m.useEffect(()=>{if(!st)return;function p(I){if(E){const C=I.clientX-_.x,B=I.clientY-_.y;C>=a&&C<=l&&wt(C),B>=400&&B<=1e3&&dt(B)}else{const C=window.innerWidth-I.clientX;C>=a&&C<=l&&wt(C)}}function T(){pt(!1),localStorage.setItem("arcten-sidebar-width",U.toString()),localStorage.setItem("arcten-sidebar-height",At.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[st,U,At,E,_,a,l]);function ma(p){p.preventDefault(),pt(!0)}function pa(){G(!0),ot(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function ga(){G(!1),ot(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ks(){ot(!X),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!X))}function ya(p){E&&(kt(!0),Rt({x:p.clientX-_.x,y:p.clientY-_.y}))}return m.useEffect(()=>{if(!E)return;function p(){ue(T=>{const C=window.innerWidth-50,B=window.innerHeight-50,O=50-U,Pt=0,xt=Math.max(O,Math.min(T.x,C)),Mt=Math.max(Pt,Math.min(T.y,B));if(xt!==T.x||Mt!==T.y){const tt={x:xt,y:Mt};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(tt)),tt}return T})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[E,U]),m.useEffect(()=>{if(!Xt)return;function p(I){const C=I.clientX-de.x,B=I.clientY-de.y,O=50,Pt=window.innerWidth-O,xt=window.innerHeight-O,Mt=O-U,tt=0,vt=Math.max(Mt,Math.min(C,Pt)),Lt=Math.max(tt,Math.min(B,xt));ue({x:vt,y:Lt})}function T(){kt(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(_))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[Xt,de,_,U]),he?k?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: ",k]})}):x?h.jsx(Lc,{features:hh,children:h.jsx(Ue,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:E?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:E?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
19
|
-
${
|
|
17
|
+
`);gh(e,t);const n=new Set,s=Object.values(t);return e.map(i=>{if(typeof i!="function")return null;const r=i[Et],o=i.name;if((!o||o.trim()==="")&&!r)return null;let a;if(r&&(a=t[r],a&&!n.has(a.name)?n.add(a.name):a=void 0),!a&&o&&(a=t[o],a&&!n.has(a.name)?n.add(a.name):a=void 0),a||(a=s.find(l=>!n.has(l.name)),a&&n.add(a.name)),!a){if(typeof process<"u"&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production")&&typeof console<"u"&&console.warn){const u=r||o||"unnamed";console.warn(`⚠️ [@arcteninc/core] No metadata found for tool "${u}". This tool will be excluded.
|
|
18
|
+
To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`)}return null}return{name:a.name,description:a.description,jsonSchema:a.parameters}}).filter(i=>i!==null)}function yh({toolName:e,description:t,args:n,onApprove:s,onDeny:i}){const r=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:e})}),r&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([o,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[o,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},o))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(qt,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(q.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(qt,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(q.X,{className:"h-3 w-3"})})]})]})})}function xh({toolName:e,args:t,isDenied:n,isSafe:s}){const[i,r]=m.useState(!1);if(e==="fetchDocContent")return null;const o=["k","maxResults","_organizationId"];e==="searchDocs"&&o.push("filters");const a=Object.fromEntries(Object.entries(t).filter(([u])=>!o.includes(u))),l=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>l&&r(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${l?"cursor-pointer hover:bg-opacity-80":""}`,children:[l&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(q.ChevronDown,{className:"h-3 w-3"}):h.jsx(q.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(q.X,{className:"h-3 w-3"}):s?h.jsx(q.Zap,{className:"h-3 w-3"}):h.jsx(q.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",e]})]}),i&&l&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,c])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof c=="string"?c:JSON.stringify(c)})]},u))})})]})}function vh({...e}){return h.jsx(Jn.Root,{"data-slot":"collapsible",...e})}function bh({...e}){return h.jsx(Jn.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function wh({...e}){return h.jsx(Jn.CollapsibleContent,{"data-slot":"collapsible-content",...e})}const Th=m.lazy(()=>import("streamdown").then(e=>({default:e.Streamdown}))),Ns=m.memo(({className:e,...t})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Th,{className:Q("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t})}),(e,t)=>e.children===t.children);Ns.displayName="Response";const Sh=Object.freeze(Object.defineProperty({__proto__:null,Response:Ns},Symbol.toStringTag,{value:"Module"})),Ch=({children:e,as:t="p",className:n,duration:s=2,spread:i=2})=>{const r=hh.create(t),o=m.useMemo(()=>(e?.length??0)*i,[e,i]);return h.jsx(r,{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":`${o}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:e})},Ah=m.memo(Ch),Jr=m.createContext(null),Ph=()=>{const e=m.useContext(Jr);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Mh=1e3,jh=1e3,Qr=m.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:r,children:o,...a})=>{const[l,u]=Gs.useControllableState({prop:n,defaultProp:s,onChange:i}),[c,d]=Gs.useControllableState({prop:r,defaultProp:0}),[f,g]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{t?y===null&&v(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/jh)),v(null))},[t,y,d]),m.useEffect(()=>{if(s&&!t&&l&&!f){const x=setTimeout(()=>{u(!1),g(!0)},Mh);return()=>clearTimeout(x)}},[t,l,s,u,f]);const w=x=>{u(x)};return h.jsx(Jr.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:c},children:h.jsx(vh,{className:Q("not-prose mb-4",e),onOpenChange:w,open:l,...a,children:o})})}),Eh=(e,t)=>e||t===0?h.jsx(Ah,{duration:1,children:"Thinking..."}):t===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",t," seconds"]}),ea=m.memo(({className:e,children:t,...n})=>{const{isStreaming:s,isOpen:i,duration:r}=Ph();return h.jsx(bh,{className:Q("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??h.jsxs(h.Fragment,{children:[h.jsx(q.BrainIcon,{className:"size-4"}),Eh(s,r),h.jsx(q.ChevronDownIcon,{className:Q("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),ta=m.memo(({className:e,children:t,...n})=>h.jsx(wh,{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",e),...n,children:h.jsx(Ns,{className:"grid gap-2",children:t})}));Qr.displayName="Reasoning";ea.displayName="ReasoningTrigger";ta.displayName="ReasoningContent";function Dh({theme:e="auto",layout:t="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:r=void 0,defaultWidth:o=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:c=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:y="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:w}){const[x,S]=m.useState(null),b=m.useRef(null),[k,A]=m.useState(null),[D,R]=m.useState(null),P=m.useRef(null),[N,W]=m.useState(u),[U,we]=m.useState(o),[Ae,de]=m.useState(600),[se,pe]=m.useState(!1),[V,Y]=m.useState(!1),[X,oe]=m.useState(!1),[_,ut]=m.useState({x:100,y:100}),[Xe,ke]=m.useState(!1),[dt,Re]=m.useState({x:0,y:0}),[ht,an]=m.useState(!1),ft=m.useRef(null),Ge=m.useRef(null),[Ne,mt]=m.useState(""),[j,M]=m.useState(null),[L,Z]=m.useState("Thinking..."),[K,re]=m.useState(new Set),[na,sa]=m.useState(""),[Ie,ia]=m.useState([]),[ln,Is]=m.useState(!1),[cn,Ls]=m.useState([]),[Os,un]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Ye,Nt]=m.useState(!1),[kh,It]=m.useState(!1),[Rh,Lt]=m.useState([]),ge=m.useMemo(()=>[...c,...d],[c,d]),Fs=m.useMemo(()=>Zr(ge,f),[ge,f]),Bs=m.useMemo(()=>new Set(ge.map(p=>p.name)),[ge]),dn=m.useMemo(()=>Fs.filter(p=>Bs.has(p.name)),[Fs,Bs]),$s=m.useMemo(()=>{const p=new Map;return ge.forEach(T=>p.set(T.name,T)),p},[ge]),zs=m.useMemo(()=>new Set(d.map(p=>p.name)),[d]),Us=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&W(JSON.parse(p));const T=localStorage.getItem("arcten-sidebar-width");T&&we(parseInt(T));const I=localStorage.getItem("arcten-sidebar-height");I&&de(parseInt(I));const C=localStorage.getItem("arcten-sidebar-detached");C&&Y(JSON.parse(C));const B=localStorage.getItem("arcten-sidebar-position");if(B){const Pe=JSON.parse(B),xe=50,Me=Math.max(xe-o,Math.min(Pe.x,window.innerWidth-xe)),ee=Math.max(0,Math.min(Pe.y,window.innerHeight-xe));ut({x:Me,y:ee})}const O=localStorage.getItem("arcten-sidebar-minimized");O&&oe(JSON.parse(O)),an(!0)}},[]),m.useEffect(()=>((async()=>{try{const T=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!T.ok)throw new Error("Failed to fetch token");const I=await T.json();S(I.clientToken),b.current=I.clientToken,R(I.expiresAt),A(null)}catch(T){A(T instanceof Error?T.message:"Failed to fetch token")}})(),()=>{P.current&&clearTimeout(P.current)}),[y,w]),m.useEffect(()=>{if(!D)return;P.current&&clearTimeout(P.current);const p=Math.floor(Date.now()/1e3),T=D-p,C=Math.max(0,T-5);return console.log(`Token expires at ${new Date(D*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${C} seconds`),P.current=setTimeout(async()=>{console.log("Refreshing token...");try{const B=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!B.ok)throw new Error("Failed to refresh token");const O=await B.json();S(O.clientToken),b.current=O.clientToken,R(O.expiresAt),A(null),console.log("Token refreshed successfully")}catch(B){console.error("Token refresh failed:",B),A(B instanceof Error?B.message:"Failed to refresh token")}},C*1e3),()=>{P.current&&clearTimeout(P.current)}},[D,y,w]),m.useEffect(()=>{(async()=>{if(ge.length!==0)try{const T=ge.map(C=>({name:C.name,code:C.toString()})),I=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:T})});if(I.ok){const C=await I.json();ia(C.tools)}}catch(T){console.error("Failed to fetch tool descriptions:",T)}})()},[ge]),m.useEffect(()=>{Promise.resolve().then(()=>Sh).then(p=>{M(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{sa(window.location.pathname)};p(),window.addEventListener("popstate",p);const T=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(T)}},[]);async function _s(){if(!(!w?.id||!x)){It(!0);try{const T=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${x}`}})).json();Ls(T.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{It(!1)}}}m.useEffect(()=>{w?.id&&x&&_s()},[w,x]);function oa(p){const T=Math.floor((Date.now()-p)/1e3);return T<60?"now":T<3600?`${Math.floor(T/60)}m`:T<86400?`${Math.floor(T/3600)}h`:`${Math.floor(T/86400)}d`}function ra(){const p=crypto.randomUUID();un(p),Ft([]),Lt([]),Nt(!1)}async function aa(p){if(x)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${x}`}}),Ls(cn.filter(T=>T._id!==p)),p===Os&&ra()}catch(T){console.error("Failed to delete conversation:",T)}}async function la(p){un(p.chatId),Nt(!1),It(!0);try{const T=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${b.current}`}});if(!T.ok)throw new Error(`Failed to fetch messages: ${T.statusText}`);const C=(await T.json()).messages||[];Ft(C),Lt(C)}catch(T){console.error("Failed to load conversation messages:",T);const I=p.messages||[];Ft(I),Lt(I)}finally{It(!1)}}const ca=async(p,T={})=>{const I=T.headers?new Headers(T.headers):new Headers;return I.delete("user-agent"),I.delete("User-Agent"),fetch(p,{...T,headers:I})},{messages:pt,sendMessage:ua,status:ye,error:Ws,stop:Ot,addToolResult:gt,setMessages:Ft}=ho.useChat({id:Os||void 0,transport:new Yt.DefaultChatTransport({api:`${v}/chat`,fetch:ca,headers:()=>{const p={};return b.current&&(p.Authorization=`Bearer ${b.current}`),p},body:()=>{const p=dn.map(T=>({name:T.name,description:T.description,inputSchema:T.jsonSchema}));return process.env.NODE_ENV==="development"&&console.log("[ArctenAgent] Sending tools to API:",{totalTools:p.length,toolNames:p.map(T=>T.name),allToolNames:ge.map(T=>T.name),filteredToolNames:dn.map(T=>T.name)}),{tools:p,systemPrompt:g,currentRoute:na}}}),sendAutomaticallyWhen:Yt.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{N&&Ge.current&&Ge.current.focus()},[N,pt]);function da(){W(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function ha(){W(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[N]),m.useEffect(()=>{ft.current&&ft.current.scrollIntoView({behavior:"smooth"})},[pt]),m.useEffect(()=>{function p(T){T.key==="Escape"&&(ye==="streaming"||ye==="submitted")&&(T.preventDefault(),Ot())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[ye,Ot]);function fa(){const p=crypto.randomUUID();un(p),Ft([]),Lt([]),Nt(!1)}function Ks(p){if(p.preventDefault(),!Ne.trim())return;(ye==="streaming"||ye==="submitted")&&Ot();const T=Us[Math.floor(Math.random()*Us.length)]||"Thinking...";Z(T),ua({text:Ne}),mt("")}function ma(p){const T=p.target.value;mt(T)}m.useEffect(()=>{if(!se)return;function p(I){if(V){const C=I.clientX-_.x,B=I.clientY-_.y;C>=a&&C<=l&&we(C),B>=400&&B<=1e3&&de(B)}else{const C=window.innerWidth-I.clientX;C>=a&&C<=l&&we(C)}}function T(){pe(!1),localStorage.setItem("arcten-sidebar-width",U.toString()),localStorage.setItem("arcten-sidebar-height",Ae.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[se,U,Ae,V,_,a,l]);function pa(p){p.preventDefault(),pe(!0)}function ga(){Y(!0),oe(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function ya(){Y(!1),oe(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Hs(){oe(!X),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!X))}function xa(p){V&&(ke(!0),Re({x:p.clientX-_.x,y:p.clientY-_.y}))}return m.useEffect(()=>{if(!V)return;function p(){ut(T=>{const C=window.innerWidth-50,B=window.innerHeight-50,O=50-U,Pe=0,xe=Math.max(O,Math.min(T.x,C)),Me=Math.max(Pe,Math.min(T.y,B));if(xe!==T.x||Me!==T.y){const ee={x:xe,y:Me};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(ee)),ee}return T})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[V,U]),m.useEffect(()=>{if(!Xe)return;function p(I){const C=I.clientX-dt.x,B=I.clientY-dt.y,O=50,Pe=window.innerWidth-O,xe=window.innerHeight-O,Me=O-U,ee=0,ve=Math.max(Me,Math.min(C,Pe)),Le=Math.max(ee,Math.min(B,xe));ut({x:ve,y:Le})}function T(){ke(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(_))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[Xe,dt,_,U]),ht?k?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: ",k]})}):x?h.jsx(Oc,{features:fh,children:h.jsx(_t,{id:"arcten-sidebar","data-theme":e,"data-layout":t,"data-model":n,initial:V?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:V?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
19
|
+
${V?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
|
|
20
20
|
${N?"bg-stone-50 dark:bg-stone-900":"bg-stone-100 dark:bg-stone-800 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors duration-200"}
|
|
21
|
-
${
|
|
21
|
+
${V?"border border-border":"border-l border-border"}
|
|
22
22
|
${N?"":"w-[30px]"}
|
|
23
|
-
`,style:N?E?{width:`${U}px`,height:X?"auto":`${At}px`,left:`${_.x}px`,top:`${_.y}px`}:{width:`${U}px`}:void 0,onClick:N?void 0:ua,children:N?h.jsxs(h.Fragment,{children:[!E&&h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:ma,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),E&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),pt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),kt(!0),Rt({x:p.clientX-_.x,y:p.clientY-_.y})},children:h.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),pt(!0)}})]}),h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${E?"cursor-move":""}`,onMouseDown:E?ya:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${E&&X?"cursor-pointer":""}`,onClick:E&&X?p=>{p.stopPropagation(),Ks()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(zt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:ha,"aria-label":"New chat",children:h.jsx(q.Plus,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:"Start a new conversation"})]}),h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(zt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:E?ga:pa,"aria-label":E?"Dock sidebar":"Float sidebar",children:E?h.jsx(q.Dock,{className:"h-4 w-4"}):h.jsx(q.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:E?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(zt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:E?Ks:da,"aria-label":E?X?"Maximize":"Minimize":"Close sidebar",children:E?X?h.jsx(q.Maximize2,{className:"h-4 w-4"}):h.jsx(q.Minimize2,{className:"h-4 w-4"}):h.jsx(q.X,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:E?X?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!X&&h.jsxs(h.Fragment,{children:[w&&ln.length>0&&h.jsxs("div",{className:`border-b border-border ${Gt?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(Ge,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Gt||Us(),Re(!Gt)},children:Gt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Gt?"flex-1 overflow-y-auto":""}`,children:ln.slice(0,Gt?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:Q(zt({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>aa(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:ia(p.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:T=>{T.stopPropagation(),ra(p._id)},"aria-label":"Delete conversation",children:h.jsx(q.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:pe.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r&&h.jsx("div",{className:"mb-6",children:r}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),It.length>0&&h.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:h.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(an?It:It.slice(0,10)).map(p=>h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(dn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{me(p.sampleUsage),Yt.current?.focus()},children:p.friendlyName})}),h.jsx(Bt,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),It.length>10&&!an&&h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsxs(dn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Ns(!0),children:["+",It.length-10," more"]})}),h.jsx(Bt,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),h.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:It.slice(10).map(p=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[p.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:p.description})]},p.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),an&&It.length>10&&h.jsx(dn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Ns(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[pe.map(p=>{const I=p.parts.filter(C=>C.type==="text").map(C=>C.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(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:I}):h.jsx("div",{className:"space-y-2",children:p.parts.map((C,B)=>{if(C.type?.startsWith("tool-")){const O=C.type?.replace("tool-","")||"",Pt=un.find(tt=>tt.name===O),xt=C.state==="input-available",Mt=C.state==="output-available";if(xt)return $s.has(O)?((async()=>{if(K.has(C.toolCallId))return;rt(Lt=>new Set(Lt).add(C.toolCallId));const vt=Bs.get(O);if(vt)try{console.log("Auto-executing safe tool:",O);const Lt=await vt(...Object.values(C.input||{}));ge({toolCallId:C.toolCallId,tool:O,output:Lt}),console.log("Safe tool result added:",C.toolCallId)}catch(Lt){ge({toolCallId:C.toolCallId,tool:O,output:`Error: ${Lt}`}),console.log("Safe tool error result added:",C.toolCallId)}})(),null):h.jsx(Ue,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(mh,{toolName:O,description:Pt?.description||"",args:C.input||{},onApprove:async()=>{if(K.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}rt(vt=>new Set(vt).add(C.toolCallId));const tt=Bs.get(O);if(tt)try{const vt=await tt(...Object.values(C.input||{}));ge({toolCallId:C.toolCallId,tool:O,output:vt}),console.log("Tool result added:",C.toolCallId)}catch(vt){ge({toolCallId:C.toolCallId,tool:O,output:`Error: ${vt}`}),console.log("Tool error result added:",C.toolCallId)}},onDeny:async()=>{if(K.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}rt(tt=>new Set(tt).add(C.toolCallId)),ge({toolCallId:C.toolCallId,tool:O,output:"User denied tool execution"}),console.log("Tool denied:",C.toolCallId)}})},`${C.toolCallId}-${B}`);if(Mt){const tt=C.output==="User denied tool execution";return h.jsx(ph,{toolName:O,args:C.input||{},isDenied:tt,isSafe:$s.has(O)},`${C.toolCallId}-${B}`)}return null}return C.type==="text"&&C.text&&j?h.jsx(j,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:C.text},`${p.id}-${B}`):C.type==="reasoning"&&C.text?h.jsxs(Jr,{className:"w-full",isStreaming:yt==="streaming"&&B===p.parts.length-1&&p.id===pe.at(-1)?.id,children:[h.jsx(Qr,{}),h.jsx(ta,{children:C.text})]},`${p.id}-${B}`):null})})})},p.id)}),h.jsx("div",{ref:fe})]})}),_s&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",_s.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Ic,{mode:"wait",children:(yt==="streaming"||yt==="submitted")&&h.jsxs(Ue,{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(Ue,{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:L})]})}),h.jsxs("form",{onSubmit:Ws,className:"relative",children:[h.jsx(mo,{ref:Yt,value:Nt,onChange:fa,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),Ws(p))}}),yt==="streaming"||yt==="submitted"?h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(zt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Le,children:h.jsx(q.Square,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Ys,{children:"Escape"})," to stop"]})]}):h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"submit",className:Q(zt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!Nt.trim(),children:h.jsx(q.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Ys,{children:"Enter"})," to send"]})]})]})]})]}),h.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all overflow-hidden",children:[h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(q.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),h.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function jh({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:r=[],safeTools:o=[],toolMetadata:a,systemPrompt:l="",initialMessages:u=[],conversationId:c,onToolCall:d,onFinish:f,ragFilters:g}={}){console.log("[useAgent] Hook initialized",{apiBaseUrl:t,tokenEndpoint:e,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[y,v]=m.useState(n||null),w=m.useRef(n||null),[x,S]=m.useState(null),[b,k]=m.useState(null),A=m.useRef(null),[V,R]=m.useState([]),[P,N]=m.useState(c||(typeof window<"u"?crypto.randomUUID():null)),[W,U]=m.useState(!1),[wt,At]=m.useState(new Set),dt=m.useMemo(()=>[...r,...o],[r,o]),st=m.useMemo(()=>qr(dt,a),[dt,a]),pt=m.useMemo(()=>{const j=new Map;let M=0;return dt.forEach(L=>{const Z=st.find(K=>K.name===L.name);if(Z)j.set(Z.name,L),M++;else if(M<st.length){const K=st[M];j.set(K.name,L),M++}}),j},[dt,st]),E=m.useMemo(()=>new Set(st.map(j=>j.name)),[st]),G=m.useMemo(()=>st.filter(j=>E.has(j.name)),[st,E]),X=m.useMemo(()=>{const j=new Set;return o.forEach(M=>{for(const[L,Z]of pt.entries())if(Z===M){j.add(L);break}}),j},[o,pt]);m.useEffect(()=>{if(console.log("[useAgent] Token fetch effect running",{skipTokenFetch:s,hasProvidedToken:!!n,user:i?.id,tokenEndpoint:e}),s||n){console.log("[useAgent] Skipping token fetch",{reason:s?"skipTokenFetch=true":"token provided"});return}return(async()=>{console.log("[useAgent] Fetching initial token from",e);try{const M=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!M.ok)throw new Error("Failed to fetch token");const L=await M.json();console.log("[useAgent] Token fetched successfully",{expiresAt:L.expiresAt,expiresIn:L.expiresAt?`${L.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),v(L.clientToken),w.current=L.clientToken,k(L.expiresAt),S(null)}catch(M){console.error("[useAgent] Token fetch failed:",M),S(M instanceof Error?M.message:"Failed to fetch token")}})(),()=>{console.log("[useAgent] Cleaning up token fetch effect"),A.current&&clearTimeout(A.current)}},[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(console.log("[useAgent] Token refresh effect running",{hasTokenExpiresAt:!!b,tokenExpiresAt:b,skipTokenFetch:s,hasProvidedToken:!!n}),!b||s||n){console.log("[useAgent] Skipping token refresh setup",{reason:b?s?"skipTokenFetch=true":"token provided":"no expiry"});return}A.current&&(console.log("[useAgent] Clearing existing token refresh timeout"),clearTimeout(A.current));const j=Math.floor(Date.now()/1e3),M=b-j,Z=Math.max(0,M-5);return console.log("[useAgent] Scheduling token refresh",{expiresAt:b,now:j,timeUntilExpiry:`${M}s`,timeUntilRefresh:`${Z}s`,refreshAt:new Date((j+Z)*1e3).toISOString()}),A.current=setTimeout(async()=>{console.log("[useAgent] Refreshing token...");try{const K=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!K.ok)throw new Error("Failed to refresh token");const rt=await K.json();console.log("[useAgent] Token refreshed successfully",{newExpiresAt:rt.expiresAt,expiresIn:`${rt.expiresAt-Math.floor(Date.now()/1e3)}s`}),v(rt.clientToken),w.current=rt.clientToken,k(rt.expiresAt),S(null)}catch(K){console.error("[useAgent] Token refresh failed:",K),S(K instanceof Error?K.message:"Failed to refresh token")}},Z*1e3),()=>{console.log("[useAgent] Cleaning up token refresh effect"),A.current&&clearTimeout(A.current)}},[b,e,JSON.stringify(i),s,n]);const ot=async(j,M={})=>{const L=M.headers?new Headers(M.headers):new Headers;return L.delete("user-agent"),L.delete("User-Agent"),fetch(j,{...M,headers:L})},{messages:_,sendMessage:ue,status:Xt,error:kt,stop:de,addToolResult:Rt,setMessages:he}=uo.useChat({id:P||void 0,messages:u,transport:new Ye.DefaultChatTransport({api:`${t}/chat`,fetch:ot,headers:()=>{const j={};return w.current&&(j.Authorization=`Bearer ${w.current}`),j},body:()=>{const j=G.map(M=>({name:M.name,description:M.description,inputSchema:M.jsonSchema}));return process.env.NODE_ENV==="development"&&console.log("[useAgent] Sending tools to API:",{totalTools:j.length,toolNames:j.map(M=>M.name),allToolNames:dt.map(M=>M.name),filteredToolNames:G.map(M=>M.name)}),{tools:j,systemPrompt:l,...g&&{ragFilters:g}}}}),sendAutomaticallyWhen:Ye.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{_.forEach(j=>{j.role==="assistant"&&j.parts.forEach(M=>{if(!M.type?.startsWith("tool-")||M.state!=="input-available")return;const L=M.type.replace("tool-",""),Z=M.toolCallId;if(!wt.has(Z)){if(At(K=>new Set(K).add(Z)),X.has(L)){const K=pt.get(L);K&&(async()=>{try{const rt=await K(...Object.values(M.input||{}));Rt({toolCallId:Z,tool:L,output:rt})}catch(rt){Rt({toolCallId:Z,tool:L,output:`Error: ${rt}`})}})()}else if(d){const K={toolCallId:Z,toolName:L,args:M.input||{}};d({toolCall:K})}}})})},[_,X,pt,d,Rt,wt]),m.useEffect(()=>{if(Xt==="ready"&&_.length>0&&f){const j=_[_.length-1];j&&j.role==="assistant"&&f({message:j,messages:_,isAbort:!1,isDisconnect:!1,isError:!!kt})}},[Xt,_,kt,f]);async function rn(){if(!(!i?.id||!y)){console.log("[useAgent] Fetching conversations for user:",i?.id),U(!0);try{const M=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${y}`}})).json();R(M.conversations||[])}catch(j){console.error("Failed to fetch conversations:",j)}finally{U(!1)}}}m.useEffect(()=>{i?.id&&y&&rn()},[JSON.stringify(i),y,t]);async function fe(j){N(j),U(!0);try{const M=await fetch(`${t}/conversations/${j}/messages`,{headers:{Authorization:`Bearer ${w.current}`}});if(!M.ok)throw new Error(`Failed to fetch messages: ${M.statusText}`);const Z=(await M.json()).messages||[];he(Z)}catch(M){console.error("Failed to load conversation messages:",M)}finally{U(!1)}}async function Yt(j){if(y)try{await fetch(`${t}/conversations/${j}`,{method:"DELETE",headers:{Authorization:`Bearer ${y}`}}),R(V.filter(M=>M._id!==j)),j===P&&Nt()}catch(M){console.error("Failed to delete conversation:",M)}}function Nt(){const j=crypto.randomUUID();N(j),he([]),At(new Set)}function me(j){Rt(j)}return{id:P,messages:_,status:Xt,error:kt,sendMessage:ue,stop:de,addToolOutput:me,setMessages:he,conversations:V,loadConversation:fe,deleteConversation:Yt,startNewConversation:Nt,isLoadingConversations:W,clientToken:y,tokenError:x}}exports.verifyToken=Da.verifyToken;exports.ArctenAgent=Mh;exports.useAgent=jh;
|
|
23
|
+
`,style:N?V?{width:`${U}px`,height:X?"auto":`${Ae}px`,left:`${_.x}px`,top:`${_.y}px`}:{width:`${U}px`}:void 0,onClick:N?void 0:da,children:N?h.jsxs(h.Fragment,{children:[!V&&h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:pa,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),V&&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(),pe(!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(),ke(!0),Re({x:p.clientX-_.x,y:p.clientY-_.y})},children:h.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),pe(!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 ${V?"cursor-move":""}`,onMouseDown:V?xa:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${V&&X?"cursor-pointer":""}`,onClick:V&&X?p=>{p.stopPropagation(),Hs()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(ze({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:fa,"aria-label":"New chat",children:h.jsx(q.Plus,{className:"h-4 w-4"})})}),h.jsx(Be,{children:"Start a new conversation"})]}),h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(ze({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:V?ya:ga,"aria-label":V?"Dock sidebar":"Float sidebar",children:V?h.jsx(q.Dock,{className:"h-4 w-4"}):h.jsx(q.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Be,{children:V?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(ze({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:V?Hs:ha,"aria-label":V?X?"Maximize":"Minimize":"Close sidebar",children:V?X?h.jsx(q.Maximize2,{className:"h-4 w-4"}):h.jsx(q.Minimize2,{className:"h-4 w-4"}):h.jsx(q.X,{className:"h-4 w-4"})})}),h.jsx(Be,{children:V?X?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!X&&h.jsxs(h.Fragment,{children:[w&&cn.length>0&&h.jsxs("div",{className:`border-b border-border ${Ye?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(qt,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Ye||_s(),Nt(!Ye)},children:Ye?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Ye?"flex-1 overflow-y-auto":""}`,children:cn.slice(0,Ye?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:Q(ze({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>la(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:oa(p.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:T=>{T.stopPropagation(),aa(p._id)},"aria-label":"Delete conversation",children:h.jsx(q.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:pt.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r&&h.jsx("div",{className:"mb-6",children:r}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),Ie.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:[(ln?Ie:Ie.slice(0,10)).map(p=>h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx(hn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{mt(p.sampleUsage),Ge.current?.focus()},children:p.friendlyName})}),h.jsx(Be,{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)),Ie.length>10&&!ln&&h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsxs(hn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Is(!0),children:["+",Ie.length-10," more"]})}),h.jsx(Be,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),h.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:Ie.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"})]})})]}),ln&&Ie.length>10&&h.jsx(hn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Is(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[pt.map(p=>{const I=p.parts.filter(C=>C.type==="text").map(C=>C.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(mh,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:I}):h.jsx("div",{className:"space-y-2",children:p.parts.map((C,B)=>{if(C.type?.startsWith("tool-")){const O=C.type?.replace("tool-","")||"",Pe=dn.find(ee=>ee.name===O),xe=C.state==="input-available",Me=C.state==="output-available";if(xe)return zs.has(O)?((async()=>{if(K.has(C.toolCallId))return;re(Le=>new Set(Le).add(C.toolCallId));const ve=$s.get(O);if(ve)try{console.log("Auto-executing safe tool:",O);const Le=await ve(...Object.values(C.input||{}));gt({toolCallId:C.toolCallId,tool:O,output:Le}),console.log("Safe tool result added:",C.toolCallId)}catch(Le){gt({toolCallId:C.toolCallId,tool:O,output:`Error: ${Le}`}),console.log("Safe tool error result added:",C.toolCallId)}})(),null):h.jsx(_t,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(yh,{toolName:O,description:Pe?.description||"",args:C.input||{},onApprove:async()=>{if(K.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}re(ve=>new Set(ve).add(C.toolCallId));const ee=$s.get(O);if(ee)try{const ve=await ee(...Object.values(C.input||{}));gt({toolCallId:C.toolCallId,tool:O,output:ve}),console.log("Tool result added:",C.toolCallId)}catch(ve){gt({toolCallId:C.toolCallId,tool:O,output:`Error: ${ve}`}),console.log("Tool error result added:",C.toolCallId)}},onDeny:async()=>{if(K.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}re(ee=>new Set(ee).add(C.toolCallId)),gt({toolCallId:C.toolCallId,tool:O,output:"User denied tool execution"}),console.log("Tool denied:",C.toolCallId)}})},`${C.toolCallId}-${B}`);if(Me){const ee=C.output==="User denied tool execution";return h.jsx(xh,{toolName:O,args:C.input||{},isDenied:ee,isSafe:zs.has(O)},`${C.toolCallId}-${B}`)}return null}return C.type==="text"&&C.text&&j?h.jsx(j,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:C.text},`${p.id}-${B}`):C.type==="reasoning"&&C.text?h.jsxs(Qr,{className:"w-full",isStreaming:ye==="streaming"&&B===p.parts.length-1&&p.id===pt.at(-1)?.id,children:[h.jsx(ea,{}),h.jsx(ta,{children:C.text})]},`${p.id}-${B}`):null})})})},p.id)}),h.jsx("div",{ref:ft})]})}),Ws&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",Ws.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Lc,{mode:"wait",children:(ye==="streaming"||ye==="submitted")&&h.jsxs(_t,{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(_t,{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:L})]})}),h.jsxs("form",{onSubmit:Ks,className:"relative",children:[h.jsx(po,{ref:Ge,value:Ne,onChange:ma,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),Ks(p))}}),ye==="streaming"||ye==="submitted"?h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(ze({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Ot,children:h.jsx(q.Square,{className:"h-4 w-4"})})}),h.jsxs(Be,{children:[h.jsx(Ys,{children:"Escape"})," to stop"]})]}):h.jsxs(Oe,{children:[h.jsx(Fe,{asChild:!0,children:h.jsx("button",{type:"submit",className:Q(ze({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!Ne.trim(),children:h.jsx(q.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Be,{children:[h.jsx(Ys,{children:"Enter"})," to send"]})]})]})]})]}),h.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all overflow-hidden",children:[h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(q.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),h.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function Vh({apiBaseUrl:e="https://api.arcten.com",tokenEndpoint:t="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:r=[],safeTools:o=[],toolMetadata:a,systemPrompt:l="",initialMessages:u=[],conversationId:c,onToolCall:d,onFinish:f,ragFilters:g}={}){console.log("[useAgent] Hook initialized",{apiBaseUrl:e,tokenEndpoint:t,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[y,v]=m.useState(n||null),w=m.useRef(n||null),[x,S]=m.useState(null),[b,k]=m.useState(null),A=m.useRef(null),[D,R]=m.useState([]),[P,N]=m.useState(c||(typeof window<"u"?crypto.randomUUID():null)),[W,U]=m.useState(!1),[we,Ae]=m.useState(new Set),de=m.useMemo(()=>[...r,...o],[r,o]),se=m.useMemo(()=>Zr(de,a),[de,a]),pe=m.useMemo(()=>{const j=new Map;let M=0;return de.forEach(L=>{const Z=se.find(K=>K.name===L.name);if(Z)j.set(Z.name,L),M++;else if(M<se.length){const K=se[M];j.set(K.name,L),M++}}),j},[de,se]),V=m.useMemo(()=>new Set(se.map(j=>j.name)),[se]),Y=m.useMemo(()=>se.filter(j=>V.has(j.name)),[se,V]),X=m.useMemo(()=>{const j=new Set;return o.forEach(M=>{for(const[L,Z]of pe.entries())if(Z===M){j.add(L);break}}),j},[o,pe]);m.useEffect(()=>{if(console.log("[useAgent] Token fetch effect running",{skipTokenFetch:s,hasProvidedToken:!!n,user:i?.id,tokenEndpoint:t}),s||n){console.log("[useAgent] Skipping token fetch",{reason:s?"skipTokenFetch=true":"token provided"});return}return(async()=>{console.log("[useAgent] Fetching initial token from",t);try{const M=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!M.ok)throw new Error("Failed to fetch token");const L=await M.json();console.log("[useAgent] Token fetched successfully",{expiresAt:L.expiresAt,expiresIn:L.expiresAt?`${L.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),v(L.clientToken),w.current=L.clientToken,k(L.expiresAt),S(null)}catch(M){console.error("[useAgent] Token fetch failed:",M),S(M instanceof Error?M.message:"Failed to fetch token")}})(),()=>{console.log("[useAgent] Cleaning up token fetch effect"),A.current&&clearTimeout(A.current)}},[t,JSON.stringify(i),s,n]),m.useEffect(()=>{if(console.log("[useAgent] Token refresh effect running",{hasTokenExpiresAt:!!b,tokenExpiresAt:b,skipTokenFetch:s,hasProvidedToken:!!n}),!b||s||n){console.log("[useAgent] Skipping token refresh setup",{reason:b?s?"skipTokenFetch=true":"token provided":"no expiry"});return}A.current&&(console.log("[useAgent] Clearing existing token refresh timeout"),clearTimeout(A.current));const j=Math.floor(Date.now()/1e3),M=b-j,Z=Math.max(0,M-5);return console.log("[useAgent] Scheduling token refresh",{expiresAt:b,now:j,timeUntilExpiry:`${M}s`,timeUntilRefresh:`${Z}s`,refreshAt:new Date((j+Z)*1e3).toISOString()}),A.current=setTimeout(async()=>{console.log("[useAgent] Refreshing token...");try{const K=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!K.ok)throw new Error("Failed to refresh token");const re=await K.json();console.log("[useAgent] Token refreshed successfully",{newExpiresAt:re.expiresAt,expiresIn:`${re.expiresAt-Math.floor(Date.now()/1e3)}s`}),v(re.clientToken),w.current=re.clientToken,k(re.expiresAt),S(null)}catch(K){console.error("[useAgent] Token refresh failed:",K),S(K instanceof Error?K.message:"Failed to refresh token")}},Z*1e3),()=>{console.log("[useAgent] Cleaning up token refresh effect"),A.current&&clearTimeout(A.current)}},[b,t,JSON.stringify(i),s,n]);const oe=async(j,M={})=>{const L=M.headers?new Headers(M.headers):new Headers;return L.delete("user-agent"),L.delete("User-Agent"),fetch(j,{...M,headers:L})},{messages:_,sendMessage:ut,status:Xe,error:ke,stop:dt,addToolResult:Re,setMessages:ht}=ho.useChat({id:P||void 0,messages:u,transport:new Yt.DefaultChatTransport({api:`${e}/chat`,fetch:oe,headers:()=>{const j={};return w.current&&(j.Authorization=`Bearer ${w.current}`),j},body:()=>{const j=Y.map(M=>({name:M.name,description:M.description,inputSchema:M.jsonSchema}));return process.env.NODE_ENV==="development"&&console.log("[useAgent] Sending tools to API:",{totalTools:j.length,toolNames:j.map(M=>M.name),allToolNames:de.map(M=>M.name),filteredToolNames:Y.map(M=>M.name)}),{tools:j,systemPrompt:l,...g&&{ragFilters:g}}}}),sendAutomaticallyWhen:Yt.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{_.forEach(j=>{j.role==="assistant"&&j.parts.forEach(M=>{if(!M.type?.startsWith("tool-")||M.state!=="input-available")return;const L=M.type.replace("tool-",""),Z=M.toolCallId;if(!we.has(Z)){if(Ae(K=>new Set(K).add(Z)),X.has(L)){const K=pe.get(L);K&&(async()=>{try{const re=await K(...Object.values(M.input||{}));Re({toolCallId:Z,tool:L,output:re})}catch(re){Re({toolCallId:Z,tool:L,output:`Error: ${re}`})}})()}else if(d){const K={toolCallId:Z,toolName:L,args:M.input||{}};d({toolCall:K})}}})})},[_,X,pe,d,Re,we]),m.useEffect(()=>{if(Xe==="ready"&&_.length>0&&f){const j=_[_.length-1];j&&j.role==="assistant"&&f({message:j,messages:_,isAbort:!1,isDisconnect:!1,isError:!!ke})}},[Xe,_,ke,f]);async function an(){if(!(!i?.id||!y)){console.log("[useAgent] Fetching conversations for user:",i?.id),U(!0);try{const M=await(await fetch(`${e}/conversations`,{headers:{Authorization:`Bearer ${y}`}})).json();R(M.conversations||[])}catch(j){console.error("Failed to fetch conversations:",j)}finally{U(!1)}}}m.useEffect(()=>{i?.id&&y&&an()},[JSON.stringify(i),y,e]);async function ft(j){N(j),U(!0);try{const M=await fetch(`${e}/conversations/${j}/messages`,{headers:{Authorization:`Bearer ${w.current}`}});if(!M.ok)throw new Error(`Failed to fetch messages: ${M.statusText}`);const Z=(await M.json()).messages||[];ht(Z)}catch(M){console.error("Failed to load conversation messages:",M)}finally{U(!1)}}async function Ge(j){if(y)try{await fetch(`${e}/conversations/${j}`,{method:"DELETE",headers:{Authorization:`Bearer ${y}`}}),R(D.filter(M=>M._id!==j)),j===P&&Ne()}catch(M){console.error("Failed to delete conversation:",M)}}function Ne(){const j=crypto.randomUUID();N(j),ht([]),Ae(new Set)}function mt(j){Re(j)}return{id:P,messages:_,status:Xe,error:ke,sendMessage:ut,stop:dt,addToolOutput:mt,setMessages:ht,conversations:D,loadConversation:ft,deleteConversation:Ge,startNewConversation:Ne,isLoadingConversations:W,clientToken:y,tokenError:x}}exports.verifyToken=Da.verifyToken;exports.ARCTEN_ORIGINAL_NAME=Et;exports.ArctenAgent=Dh;exports.preserveToolName=ph;exports.useAgent=Vh;
|