@arcteninc/core 0.0.165 → 0.0.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";var yl=Object.create;var Qr=Object.defineProperty;var xl=Object.getOwnPropertyDescriptor;var bl=Object.getOwnPropertyNames;var vl=Object.getPrototypeOf,wl=Object.prototype.hasOwnProperty;var Sl=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of bl(t))!wl.call(e,r)&&r!==n&&Qr(e,r,{get:()=>t[r],enumerable:!(s=xl(t,r))||s.enumerable});return e};var Tl=(e,t,n)=>(n=e!=null?yl(vl(e)):{},Sl(t||!e||!e.__esModule?Qr(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),h=require("react"),te=require("lucide-react"),jl=require("@ai-sdk/react"),ei=require("ai"),wo=require("@radix-ui/react-slot"),So=require("class-variance-authority"),Cl=require("clsx"),Pl=require("tailwind-merge"),Al=require("@radix-ui/react-tooltip"),ti=require("@radix-ui/react-use-controllable-state"),El=require("@radix-ui/react-collapsible"),Ml=require("react-dom"),kl=require("@radix-ui/react-dialog"),Nl=require("./server.cjs");function ms(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 _e=ms(h),Ht=ms(Al),hr=ms(El),Vt=ms(kl),Oe=Symbol.for("@arcteninc/core:originalName");function Dl(e,t){return e[Oe]=t,e}function Rl(e,t,n,s){if(typeof e!="function")return null;const r=e[Oe];if(r){const a=t[r];if(a&&!n.has(a.name))return{fn:e,meta:a}}const o=e.name;let i;if(o&&(i=t[o],i&&!n.has(i.name)))return e[Oe]=i.name,{fn:e,meta:i};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(i=t[a],i))return e[Oe]=i.name,{fn:e,meta:i}}else if(i=Object.values(t).find(l=>!n.has(l.name)),i)return e[Oe]=i.name,{fn:e,meta:i};return null}function mr(e,t){if(!t)return[];let n,s;if("functions"in t&&typeof t.functions=="object"){const o=t;n=o.functions,s=o.toolOrder}else n=t,s=void 0;const r=new Set;return e.map(o=>{const i=Rl(o,n,r,s);if(!i){const a=o.name,c=o[Oe]||a||"unnamed";return typeof process<"u"&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production")&&typeof console<"u"&&console.warn&&console.warn(`⚠️ [@arcteninc/core] No metadata found for tool "${c}". This tool will be excluded.
|
|
2
|
-
To fix: Run "arcten-extract-types ." and ensure "${c}" is used in ArctenAgent/useAgent.`),null}return r.add(i.meta.name),{name:i.meta.name,description:i.meta.description,jsonSchema:i.meta.parameters}}).filter(o=>o!==null)}const Vl={password:[/^password$/i,/^pwd$/i,/^pass$/i,/^newPassword$/i,/^oldPassword$/i,/^currentPassword$/i,/^confirmPassword$/i,/.*password.*/i],email:[/^email$/i,/^emailAddress$/i,/^mail$/i,/.*email.*/i],phone:[/^phone$/i,/^phoneNumber$/i,/^mobile$/i,/^cell$/i,/^cellPhone$/i,/^telephone$/i,/.*phone.*/i,/.*mobile.*/i],pin:[/^pin$/i,/^pinCode$/i,/^securityPin$/i,/^accessPin$/i,/.*pin$/i],ssn:[/^ssn$/i,/^socialSecurityNumber$/i,/^social$/i,/.*ssn.*/i,/.*social.*/i],creditCard:[/^creditCard$/i,/^cardNumber$/i,/^card$/i,/^ccNumber$/i,/^creditCardNumber$/i,/.*card.*/i,/^cvv$/i,/^cvc$/i,/^cvn$/i,/^securityCode$/i],text:[]};function Sn(e){for(const[t,n]of Object.entries(Vl))if(t!=="text"){for(const s of n)if(s.test(e))return t}return null}function Il(e,t){return{password:{title:"Password Required",description:"Please enter your password to continue",placeholder:"Enter password..."},email:{title:"Email Required",description:"Please enter your email address",placeholder:"Enter email address..."},phone:{title:"Phone Number Required",description:"Please enter your phone number",placeholder:"Enter phone number..."},pin:{title:"PIN Required",description:"Please enter your PIN",placeholder:"Enter PIN..."},ssn:{title:"Social Security Number Required",description:"Please enter your Social Security Number",placeholder:"XXX-XX-XXXX"},creditCard:{title:"Credit Card Required",description:"Please enter your credit card information",placeholder:"XXXX XXXX XXXX XXXX"},text:{title:"Secure Input Required",description:`Please enter your ${t}`,placeholder:`Enter ${t}...`}}[e]}function Ol(e,t,n){return t.length>0}function $l(e,t,n,s={}){const r=[];return Object.keys(s).forEach(i=>{const a=i in n,l=n[i];if(!a){const f=s[i];if(f!=null&&f!=="")return}const c=Ll(s[i]),d={name:i,type:Fl(l||Sn(i)||"text"),label:To(i),placeholder:Bl(i,l),required:!0,value:c};d.type==="password"&&(d.validation=f=>f.length<8?"Password must be at least 8 characters":null),r.push(d)}),r.sort((i,a)=>{const l=i.name in n,c=a.name in n;return l===c?0:l?1:-1}),{shouldUseForm:Ol(e,t),fields:r,title:Ul(e),description:zl(e,r.length)}}function Ll(e){if(e!=null){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}}function Fl(e){switch(e){case"password":return"password";case"email":return"email";case"phone":return"phone";case"pin":return"pin";case"ssn":return"ssn";case"creditCard":return"creditCard";default:return"text"}}function To(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Bl(e,t){return t?Il(t,e).placeholder:`Enter ${To(e).toLowerCase()}...`}function Ul(e){return e.replace(/([A-Z])/g," $1").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function zl(e,t){const n=e.toLowerCase();return t<=2?`Please provide the required information to ${n}.`:`Please fill out the form below to ${n}. Required fields are marked with *.`}function jn(e){if(typeof e=="string")try{const t=JSON.parse(e);return jn(t)}catch{return e}if(Array.isArray(e))return e.map(jn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=jn(s);return t}return e}function _l(e,t){if(!t||Object.keys(t).length===0)return e;const n={...e};return Object.keys(t).forEach(s=>{s in n&&delete n[s]}),n}function Xl(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return jn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?jn(e):{}}const ns="__secureOutput",ss="[hidden for privacy]";function Wl(e,t){if(!e||e.length===0)return t;const n=new Map;t.forEach(o=>{const i=o[Oe]||o.name;i&&n.set(i,o)});const s=new Map(e.map(o=>[o.name,o])),r=[];return e.forEach(o=>{const i=n.get(o.name);if(!i){console.log(`[useAgent] Skipping server-only tool: ${o.name}`);return}if(!o.isEnabled&&!o.isOverridable){console.log(`[useAgent] Blocking non-overridable disabled tool: ${o.name}`);return}if(!o.isEnabled&&o.isOverridable&&i){console.log(`[useAgent] Allowing overridable disabled tool with local implementation: ${o.name}`),r.push(i);return}o.isEnabled&&i&&r.push(i)}),t.forEach(o=>{const i=o[Oe]||o.name;i&&!s.has(i)&&(console.log(`[useAgent] Allowing client-only tool (forward compatible): ${i}`),r.push(o))}),r}function ql(e){if(typeof globalThis.structuredClone=="function")return globalThis.structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch(t){return console.warn("[useAgent] Failed to clone value for redaction:",t),e}}function Kl(e){return e.replace(/\[(\w+)\]/g,".$1").split(".").map(t=>t.trim()).filter(Boolean)}function Gl(e,t){if(t.length===0)return e;if(!e||typeof e!="object")return;let n=e;for(const s of t){if(!n||typeof n!="object")return;n=n[s]}return n}function Hl(e,t,n){if(!e||typeof e!="object"||t.length===0)return!1;let s=e;for(let o=0;o<t.length-1;o++){if(!s||typeof s!="object")return!1;const i=s,a=t[o];if(a===void 0)return!1;const l=i[a];if(l==null||typeof l!="object")return!1;s=l}if(!s)return!1;const r=t[t.length-1];return!r||!(r in s)?!1:(s[r]=n,!0)}function _s(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0}function jo(e,t=""){const n={};return e&&typeof e=="object"?Object.entries(e).forEach(([s,r])=>{const o=t?`${t}.${s}`:s;n[o]=_s(r),r&&typeof r=="object"&&Object.assign(n,jo(r,o))}):t&&(n[t]=_s(e)),n}function Yl(e){if(e===void 0||e===!1)return;if(e===!0)return{strategy:"full",fields:[],placeholder:ss,includeFieldStatus:!1,preserve:[]};if(Array.isArray(e))return{strategy:"fields",fields:e,placeholder:ss,includeFieldStatus:!1,preserve:[]};const t=e.strategy??(e.fields&&e.fields.length>0?"fields":"full");return{strategy:t,fields:t==="fields"?e.fields??[]:[],placeholder:e.placeholder??ss,includeFieldStatus:e.includeFieldStatus??!1,preserve:e.preserve??[]}}function Jl(e){if(!e)return{};const t={};for(const[n,s]of Object.entries(e)){const r=Yl(s);r&&(t[n]=r)}return t}function Co(e,t,n){const s=n.placeholder,r={tool:e,redacted:!0,strategy:n.strategy,placeholder:s};if(n.strategy==="full"){n.includeFieldStatus&&typeof t=="object"&&t!==null&&(r.fieldStatus=jo(t)),r.redactedFields=["*"];let l={};return n.preserve.length>0&&t&&typeof t=="object"&&n.preserve.forEach(c=>{c in t&&(l[c]=t[c])}),l[ns]=r,l}if(n.fields.includes("*"))return Co(e,t,{...n,strategy:"full",fields:[]});if(typeof t!="object"||t===null)return{value:s,[ns]:{...r,redactedFields:n.fields}};const o=ql(t),i=[],a={};return n.fields.forEach(l=>{const c=Kl(l);if(c.length===0)return;const d=Gl(o,c),f=_s(d);a[l]=f,Hl(o,c,s)&&i.push(l)}),r.redactedFields=i,n.includeFieldStatus&&(r.fieldStatus=a),o[ns]=r,o}function Po({apiBaseUrl:e="https://api.arcten.com",tokenEndpoint:t="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:r,tools:o=[],safeTools:i=[],safeToolNames:a,toolMetadata:l,sensitiveParams:c,sensitiveOutputs:d,autoDetectSensitive:f=!1,autoFormGeneration:m=!1,formMode:p="auto",systemPrompt:x="",agentId:b,agentName:S,projectId:v,enableRemoteConfig:M,remoteConfigUrl:E,initialMessages:L=[],conversationId:D,state:O,onStateChange:k,allowStateEdits:P=!0,onToolCall:V,onFinish:A,sources:N,ragConfig:F,ragFilters:$,secureInputHandler:B}={}){const X=e.replace(/\/+$/,""),[G,K]=h.useState(null),[oe,ye]=h.useState(!1),[We,wt]=h.useState(null),tt=h.useMemo(()=>{const g=N||[],y=G?.config?.sources||[];return[...new Set([...g,...y])]},[N,G]),H=h.useMemo(()=>F!==void 0?F:$?{enabled:!0,filters:$}:tt&&tt.length>0?{enabled:!0,organizationId:tt[0],autoExecute:!0,filters:void 0}:{enabled:!1},[tt,F,$]),It=h.useMemo(()=>M===!1?!1:!!v,[v,M]);h.useEffect(()=>{if(!It||!ae.current)return;(async()=>{ye(!0),wt(null);try{const w=`${E||X.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,j=await fetch(w,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae.current}`},body:JSON.stringify({path:"agents:getConfigForClient",args:{projectId:v,agentName:S,agentId:b},format:"json"})});if(!j.ok){if(j.status===404){console.warn("[useAgent] Remote config endpoint not found (404), using local tools only"),K(null);return}const R=await j.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch remote config: ${j.status} ${R}`)}const C=await j.json();K(C?.value||null),console.log("[useAgent] Remote config loaded successfully:",C?.value)}catch(y){console.error("[useAgent] Failed to fetch remote config:",y);const w=y instanceof Error?y:new Error(String(y));wt(w),K(null)}finally{ye(!1)}})()},[It,v,S,b,X,E]);const Ee=h.useMemo(()=>{const g={};if(c)for(const[y,w]of Object.entries(c))if(g[y]={},Array.isArray(w))for(const j of w){const C=Sn(j);g[y][j]=C||"text"}else for(const[j,C]of Object.entries(w))g[y][j]=C;if(l){for(const[y,w]of Object.entries(l))if(w&&typeof w=="object"&&"sensitiveParams"in w){g[y]||(g[y]={});const j=w.sensitiveParams;if(Array.isArray(j))for(const C of j){const R=Sn(C);g[y][C]=R||"text"}else if(j&&typeof j=="object")for(const[C,R]of Object.entries(j))g[y][C]=R}}return g},[c,l,f]),St=h.useMemo(()=>Jl(d),[d]),Ce=h.useCallback((g,y)=>{const w=St[g];if(!w)return y;try{return Co(g,y,w)}catch(j){return console.error(`[useAgent] Failed to redact output for ${g}:`,j),{value:ss,[ns]:{tool:g,redacted:!0,error:String(j)}}}},[St]),[Fe,Ot]=h.useState(n||null),ae=h.useRef(n||null),[dn,ct]=h.useState(null),[ut,fn]=h.useState(null),Be=h.useRef(null),[Tt,jt]=h.useState([]),[ke,hn]=h.useState(D||(typeof window<"u"?crypto.randomUUID():null)),[bs,$t]=h.useState(!1),mn=h.useRef(new Set),[Lt,nt]=h.useState(new Map),[vs,Bn]=h.useState(new Map),[st,Un]=h.useState(new Map),[zn,Ft]=h.useState(new Map),ce=O!==void 0,[Bt,dt]=h.useState({}),xe=h.useRef({}),pn=ce?O||{}:Bt;ce&&O?xe.current=O:ce||(xe.current=Bt);const[qe,Re]=h.useState(!1),[gn,Ke]=h.useState(null),Ct=h.useRef(!1),_n=h.useCallback(async(g,y=3)=>{if(!ke||!ae.current)return;const w=async()=>{const C=`${X.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,R=await fetch(C,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:ke,updates:g},format:"json"})});if(!R.ok){if(R.status===404){console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const I=await R.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${R.status} ${I}`)}};for(let j=0;j<y;j++)try{await w(),Ke(null);return}catch(C){if(j===y-1){const I=C instanceof Error?C:new Error(String(C));throw Ke(I),console.error("Failed to sync state to Convex after retries:",C),I}await new Promise(I=>setTimeout(I,Math.pow(2,j)*100))}},[ke,X,ae]),Pe=h.useMemo(()=>function(){return xe.current},[]),ft=h.useMemo(()=>async function(y){const w={...xe.current,...y};xe.current=w,ce||dt(w),k&&k(w);try{await _n(y)}catch(j){throw j}},[_n,k,ce]);h.useEffect(()=>{ce&&O&&(xe.current=O)},[ce,O]);const Ne=h.useCallback(g=>B?B.showSecureModal(g):new Promise(y=>{nt(w=>new Map(w).set(g.id,g)),Bn(w=>new Map(w).set(g.id,y))}),[B]),Xn=h.useCallback((g,y)=>{if(B)return;const w=vs.get(g);w&&(w(y),nt(j=>{const C=new Map(j);return C.delete(g),C}),Bn(j=>{const C=new Map(j);return C.delete(g),C}))},[vs,B]),Ut=h.useCallback(g=>B?B.showSecureForm(g):new Promise(y=>{Un(w=>new Map(w).set(g.id,g)),Ft(w=>new Map(w).set(g.id,y))}),[B]),rt=h.useCallback((g,y)=>{if(B)return;const w=zn.get(g);w&&(w(y),Un(j=>{const C=new Map(j);return C.delete(g),C}),Ft(j=>{const C=new Map(j);return C.delete(g),C}))},[zn,B]),Wn=h.useCallback((g,y)=>{const w=Ee[g]||{},j=Object.keys(w).length>0;if(f){const C=Object.keys(y).filter(R=>Sn(R)!==null);return j||C.length>0}return j},[Ee,f]),qn=h.useCallback((g,y)=>{const j={...Ee[g]||{}};if(f){for(const R of Object.keys(y))if(!(R in j)){const I=Sn(R);I&&(j[R]=I)}}const C=Object.entries(j).filter(([R])=>Object.prototype.hasOwnProperty.call(y,R));return C.length>0?Object.fromEntries(C):j},[Ee,f]),Ge=h.useMemo(()=>H?.enabled?async function(y,w=20,j){const C={...H.filters,...j};if(N&&N.length>1){const I=N.map(q=>fetch(`${X}/search`,{method:"POST",headers:{"Content-Type":"application/json",...ae.current?{Authorization:`Bearer ${ae.current}`}:{}},body:JSON.stringify({q:y,k:Math.min(w,100),organizationId:q,...Object.keys(C).length>0?{filters:C}:{}})}).then(ie=>ie.ok?ie.json():null)),ee=await Promise.all(I),Q=[];for(const q of ee)q?.candidates&&Q.push(...q.candidates);Q.sort((q,ie)=>{const Qe=q.scores?.rerank||q.scores?.dense||0;return(ie.scores?.rerank||ie.scores?.dense||0)-Qe});const be=Q.slice(0,w).map((q,ie)=>{const Qe=q.citation||q.url;return{rank:ie+1,doc_id:q.doc_id,block_id:q.block_id,url:q.url,citation:Qe,title:q.title||"Untitled",snippet:q.snippet,score:q.scores?.rerank||q.scores?.dense||0,metadata:{site:q.metadata?.site,lang:q.metadata?.lang,contentType:q.metadata?.content_type}}});return{success:!0,query:y,total:Q.length,results:be,summary:`Found ${Q.length} relevant results across ${N.length} source(s) for "${y}". Top result: ${be[0]?.title||"N/A"}`}}const R=H.organizationId&&H.organizationId!=="default"?H.organizationId:N&&N.length>0?N[0]:void 0;try{const I={q:y,k:Math.min(w,100)};R&&(I.organizationId=R),Object.keys(C).length>0&&(I.filters=C);const ee={"Content-Type":"application/json"};ae.current&&(ee.Authorization=`Bearer ${ae.current}`);const Q=await fetch(`${X}/search`,{method:"POST",headers:ee,body:JSON.stringify(I)});if(!Q.ok){const ie=await Q.text();return{success:!1,error:`Search failed: ${Q.status} ${ie}`}}const be=await Q.json(),q=be.candidates.map((ie,Qe)=>{const vn=ie.citation||ie.url;return{rank:Qe+1,doc_id:ie.doc_id,block_id:ie.block_id,url:ie.url,citation:vn,title:ie.title||"Untitled",snippet:ie.snippet,score:ie.scores?.rerank||ie.scores?.dense||0,metadata:{site:ie.metadata?.site,lang:ie.metadata?.lang,contentType:ie.metadata?.content_type}}});return{success:!0,query:be.query,total:be.total,results:q,summary:`Found ${be.total} relevant results for "${y}". Top result: ${q[0]?.title||"N/A"}`}}catch(I){return{success:!1,error:I instanceof Error?I.message:"Unknown error occurred"}}}:null,[H,X,ae]),He=h.useMemo(()=>H?.enabled?async function(y,w){const j=H.organizationId&&H.organizationId!=="default"?H.organizationId:N&&N.length>0?N[0]:void 0;try{const C={"Content-Type":"application/json"};ae.current&&(C.Authorization=`Bearer ${ae.current}`);const R=await fetch(`${X}/fetch`,{method:"POST",headers:C,body:JSON.stringify({doc_id:y,block_ids:w,...j?{organizationId:j}:{}})});if(!R.ok){const ee=await R.text();return{success:!1,error:`Fetch failed: ${R.status} ${ee}`}}const I=await R.json();return{success:!0,blocks:I.blocks||[],fullContent:I.fullContent||"",pageUrl:I.pageUrl||"",pageTitle:I.pageTitle||"",summary:`Fetched ${I.blocks?.length||0} blocks from ${I.pageTitle||y}`}}catch(C){return{success:!1,error:C instanceof Error?C.message:"Unknown error occurred"}}}:null,[H,X,ae]),yn=h.useMemo(()=>{if(G&&G.config?.tools){const g=Wl(G.config.tools,o);return console.log("[useAgent] Merged remote config:",{remoteToolCount:G.config.tools.length,localToolCount:o.length,mergedToolCount:g.length}),g}return o},[G,o]),Ue=G?.enableStateTools??!0,Ye=G?.enableRagTools??H?.enabled??!1,Kn=h.useMemo(()=>{const g=[...yn,...i];return Ue&&(g.push(Pe),(!ce||P)&&g.push(ft)),Ye&&(Ge&&g.push(Ge),He&&g.push(He)),g},[yn,i,Pe,ft,Ge,He,Ue,Ye,ce,P]),Gn=h.useMemo(()=>[...yn,...i],[yn,i]),it=h.useMemo(()=>mr(Gn,l),[Gn,l]),Pt=h.useMemo(()=>{const g=new Map,y=new Map(it.map(w=>[w.name,w]));return g.set("getState",Pe),(!ce||P)&&g.set("setState",ft),H?.enabled&&(Ge&&g.set("searchDocs",Ge),He&&g.set("fetchDocContent",He)),Kn.forEach(w=>{if(w===Pe||w===ft||w===Ge||w===He)return;const j=w[Oe];if(j){const R=y.get(j);if(R){g.set(R.name,w);return}}const C=it.find(R=>R.name===w.name);C&&g.set(C.name,w)}),g},[Kn,it,Pe,ft,Ge,He,H,ce,P]),Hn=h.useMemo(()=>new Set(it.map(g=>g.name)),[it]),xn=h.useMemo(()=>{const g=[];Ue&&(g.push({name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}),(!ce||P)&&g.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}));const y=[];Ye&&y.push({name:"searchDocs",description:"Search documentation using semantic search. Returns relevant results with snippets and scores. Use this first to find relevant documentation. Default returns 20 results - use higher k values (30-50) when you need to find many sources.",jsonSchema:{type:"object",properties:{query:{type:"string",description:"The search query (user's question or keywords)"},k:{type:"number",description:"Number of results to return (default: 20, max: 100). Use 20-30 for comprehensive searches, or higher (50-100) when you need to find all relevant sources.",default:20},filters:{type:"object",description:"Optional filters to scope the search",properties:{site:{type:"string"},lang:{type:"string"},tags:{type:"array",items:{type:"string"}},docIds:{type:"array",items:{type:"string"}},pageIds:{type:"array",items:{type:"string"}}}}},required:["query"]}},{name:"fetchDocContent",description:"Fetch full content of documentation blocks after searching. Use this AFTER searchDocs when you find relevant results (scores > 0.3) to get complete text. Automatically fetches nearby blocks (5 chunks before/after each requested block) for context. You can pass multiple block_ids to fetch comprehensive content from multiple blocks/pages.",jsonSchema:{type:"object",properties:{doc_id:{type:"string",description:"The doc_id from searchDocs results"},block_ids:{type:"array",items:{type:"string"},description:"Array of block_ids from searchDocs results. You can pass multiple block_ids to fetch comprehensive content."}},required:["doc_id","block_ids"]}});const w=[];return G?.config?.workflows&&G.config.workflows.forEach(j=>{const C={},R=[];j.parameters&&j.parameters.forEach(I=>{C[I.name]={type:I.type||"string",description:I.description},I.required&&R.push(I.name)}),w.push({name:`workflow_${j.name.replace(/\s+/g,"_").toLowerCase()}`,description:j.description||`Execute the "${j.name}" workflow. ${j.contentPlaintext?.slice(0,200)||""}`,jsonSchema:{type:"object",properties:C,required:R},_workflow:j})}),[...it,...g,...y,...w]},[it,Ue,Ye,ce,P,G]),ht=h.useMemo(()=>xn.filter(g=>g.name==="getState"?Ue:g.name==="setState"?Ue&&(!ce||P):g.name==="searchDocs"||g.name==="fetchDocContent"?Ye:g.name.startsWith("workflow_")?!0:Hn.has(g.name)),[xn,Hn,Ue,Ye,ce,P]),zt=h.useMemo(()=>{const g=new Set;return Ue&&(g.add("getState"),g.add("setState")),Ye&&H?.autoExecute!==!1&&(g.add("searchDocs"),g.add("fetchDocContent")),G?.config?.tools?G.config.tools.forEach(y=>{y.isEnabled&&!y.requiresApproval&&g.add(y.name)}):(i.forEach(y=>{for(const[w,j]of Pt.entries())if(j===y){g.add(w);break}}),a&&Array.isArray(a)&&a.forEach(y=>{typeof y=="string"&&g.add(y)})),G?.config?.workflows&&G.config.workflows.forEach(y=>{const w=`workflow_${y.name.replace(/\s+/g,"_").toLowerCase()}`;y.requiresApproval||g.add(w)}),g},[G,i,a,Pt,Ue,Ye,H]);h.useEffect(()=>{if(s||n)return;let g=!1,y=null;const w=async(j=1,C=3)=>{if(!g)try{const R=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!R.ok)throw new Error("Failed to fetch token");const I=await R.json();g||(Ot(I.clientToken),ae.current=I.clientToken,fn(I.expiresAt),ct(null))}catch(R){if(console.error(`[useAgent] Token fetch failed (attempt ${j}/${C}):`,R),j<C&&!g){const I=Math.pow(2,j-1)*1e3;y=setTimeout(()=>w(j+1,C),I)}else g||ct(R instanceof Error?R.message:"Failed to fetch token")}};return w(),()=>{g=!0,y&&clearTimeout(y),Be.current&&clearTimeout(Be.current)}},[t,JSON.stringify(r),s,n]),h.useEffect(()=>{if(!ut||s||n)return;Be.current&&clearTimeout(Be.current);const g=async(R=1,I=3)=>{try{const ee=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!ee.ok)throw new Error("Failed to refresh token");const Q=await ee.json();Ot(Q.clientToken),ae.current=Q.clientToken,fn(Q.expiresAt),ct(null)}catch(ee){if(console.error(`[useAgent] Token refresh failed (attempt ${R}/${I}):`,ee),R<I){const Q=Math.pow(2,R-1)*1e3;setTimeout(()=>g(R+1,I),Q)}else ct(ee instanceof Error?ee.message:"Failed to refresh token")}},y=Math.floor(Date.now()/1e3),w=ut-y,C=Math.max(0,w-5);return Be.current=setTimeout(()=>g(),C*1e3),()=>{Be.current&&clearTimeout(Be.current)}},[ut,t,JSON.stringify(r),s,n]),h.useEffect(()=>{if(s||n)return;const g=async()=>{if(document.visibilityState!=="visible")return;const y=Math.floor(Date.now()/1e3);if(!ut||ut<=y+5){console.log("[useAgent] Tab visible, token expired - refreshing");try{const j=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(j.ok){const C=await j.json();Ot(C.clientToken),ae.current=C.clientToken,fn(C.expiresAt),ct(null)}}catch(j){console.error("[useAgent] Token refresh on visibility change failed:",j)}}};return document.addEventListener("visibilitychange",g),()=>document.removeEventListener("visibilitychange",g)},[t,JSON.stringify(r),ut,s,n]);const ws=async(g,y={})=>{const w=y.headers?new Headers(y.headers):new Headers;return w.delete("user-agent"),w.delete("User-Agent"),fetch(g,{...y,headers:w})},bn=h.useRef(null),Yn=`${X}/chat`,{messages:Je,sendMessage:T,status:_,error:z,stop:Z,addToolResult:Y,setMessages:J}=jl.useChat({id:ke||void 0,messages:L,transport:new ei.DefaultChatTransport({api:Yn,fetch:ws,headers:()=>{const g={};return ae.current&&(g.Authorization=`Bearer ${ae.current}`),g},body:()=>({tools:ht.map(y=>({name:y.name,description:y.description,inputSchema:y.jsonSchema})),...b&&{agentId:b},...S&&{agentName:S},state:xe.current,...$&&{ragFilters:$}})}),sendAutomaticallyWhen:g=>{const y=g.messages;if(y[y.length-1]?.role!=="assistant")return!1;const C=[...y].reverse().find(I=>I.role==="user")?.id;if(C&&bn.current===C)return!1;const R=ei.lastAssistantMessageIsCompleteWithToolCalls(g);return R&&C&&(bn.current=C),R}}),De=T,re=h.useCallback(g=>(bn.current=null,De(g)),[De]),ue=h.useCallback((g,y,w)=>{const j=Ce(g,w);Y({toolCallId:y,tool:g,output:j})},[Y,Ce]);h.useEffect(()=>{Je.forEach(g=>{g.role==="assistant"&&g.parts.forEach(y=>{if(!y.type?.startsWith("tool-")||y.state!=="input-available")return;const w=y.type.replace("tool-",""),j=y.toolCallId;if(mn.current.has(j))return;mn.current.add(j);const C=Xl(y.input);if(Wn(w,C)){const R=qn(w,C),I=Object.entries(R).filter(([q])=>C[q]!==void 0),ee=I.length>0?Object.fromEntries(I):R,Q=Object.keys(C),be=_l(C,ee);(async()=>{try{const q=$l(w,Q,ee,C),ie={id:`${j}-form`,toolName:w,toolCallId:j,title:q.title,description:q.description,fields:q.fields},Qe=await Ut(ie);if(Qe===null){ue(w,j,"User cancelled secure input");return}const vn={...be,...Qe},Ss=Pt.get(w);if(!Ss)throw new Error(`Tool ${w} not found`);let Ts;const js=ht.find(Zr=>Zr.name===w);if(js&&js.jsonSchema?.properties){const pl=Object.keys(js.jsonSchema.properties).map(gl=>vn[gl]);Ts=await Ss(...pl)}else Ts=await Ss(...Object.values(vn));ue(w,j,Ts)}catch(q){console.error(`[useAgent] Error executing tool with secure input ${w}:`,q),ue(w,j,`Error: ${q}`)}})();return}if(w.startsWith("workflow_")&&zt.has(w)){(async()=>{try{const I=ht.find(Q=>Q.name===w)?._workflow;if(!I)throw new Error(`Workflow metadata not found for ${w}`);let ee;if(I.webhook?.url){let Q=C;if(I.webhook.bodyTemplate){let q=I.webhook.bodyTemplate;Object.entries(C).forEach(([ie,Qe])=>{q=q.replace(new RegExp(`\\{\\{${ie}\\}\\}`,"g"),String(Qe))}),Q=JSON.parse(q)}const be=await fetch(I.webhook.url,{method:I.webhook.method||"POST",headers:{"Content-Type":"application/json",...I.webhook.headers||{}},body:JSON.stringify(Q)});if(be.ok)ee={success:!0,data:await be.json().catch(()=>({success:!0}))};else{const q=await be.text();ee={success:!1,error:`Webhook failed: ${be.status} ${q}`}}}else ee={success:!0,message:`Workflow "${I.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:I.contentPlaintext};ue(w,j,ee)}catch(R){console.error(`[useAgent] Error executing workflow ${w}:`,R),ue(w,j,`Error: ${R}`)}})();return}if(zt.has(w)&&!Wn(w,C)){const R=Pt.get(w);R?(async()=>{try{const I=ht.find(Q=>Q.name===w);let ee;if(I&&I.jsonSchema?.properties){const be=Object.keys(I.jsonSchema.properties).map(q=>C[q]);ee=await R(...be)}else if(w==="getState")ee=R();else if(w==="setState"){const Q=C.updates||C;ee=await R(Q)}else ee=await R(...Object.values(C));ue(w,j,ee)}catch(I){console.error(`[useAgent] Error executing tool ${w}:`,I),ue(w,j,`Error: ${I}`)}})():console.warn(`[useAgent] Tool ${w} not found in toolsMap`)}else w.startsWith("workflow_")&&V?V({toolCall:{toolCallId:j,toolName:w,args:C}}):V&&V({toolCall:{toolCallId:j,toolName:w,args:C}})})})},[Je,zt,Pt,V,ue,ft,ht,Wn,qn,Ne]),h.useEffect(()=>{if(_==="ready"&&Je.length>0&&A){const g=Je[Je.length-1];g&&g.role==="assistant"&&A({message:g,messages:Je,isAbort:!1,isDisconnect:!1,isError:!!z})}},[_,Je,z,A]);async function W(){if(!(!r?.id||!Fe)){$t(!0);try{const y=await(await fetch(`${X}/conversations`,{headers:{Authorization:`Bearer ${Fe}`}})).json();jt(y.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{$t(!1)}}}h.useEffect(()=>{r?.id&&Fe&&W()},[JSON.stringify(r),Fe,X]),h.useEffect(()=>{if(!ke||!ae.current)return;(async()=>{Re(!0),Ke(null);try{const y=await fetch(`${X.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:ke},format:"json"})});if(!y.ok){const C=await y.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${y.status} ${C}`)}const j=(await y.json())?.value||{};xe.current=j,ce||dt(j),k&&k(j),Ct.current=!0}catch(y){console.error("Failed to fetch state:",y);const w=y instanceof Error?y:new Error(String(y));Ke(w),Ct.current||(xe.current={},ce?k&&k({}):(dt({}),k&&k({})),Ct.current=!0)}finally{Re(!1)}})()},[ke,X,ce,k]);async function me(g){hn(g),$t(!0);try{const y=await fetch(`${X}/conversations/${g}/messages`,{headers:{Authorization:`Bearer ${ae.current}`}});if(!y.ok)throw new Error(`Failed to fetch messages: ${y.statusText}`);const j=(await y.json()).messages||[];J(j)}catch(y){console.error("Failed to load conversation messages:",y)}finally{$t(!1)}}async function ne(g){if(Fe)try{await fetch(`${X}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${Fe}`}}),jt(Tt.filter(y=>y._id!==g)),g===ke&&Se()}catch(y){console.error("Failed to delete conversation:",y)}}function Se(){const g=crypto.randomUUID();hn(g),J([]),mn.current=new Set,xe.current={},ce?k&&k({}):(dt({}),k&&k({})),Ct.current=!1}function de(g){const y=g.tool||"unknown-tool",w=Ce(y,g.output);Y({toolCallId:g.toolCallId,tool:y,output:w})}async function Ze(g,y,w){if(!y.startsWith("workflow_"))throw new Error(`${y} is not a workflow tool`);try{const C=ht.find(I=>I.name===y)?._workflow;if(!C)throw new Error(`Workflow metadata not found for ${y}`);let R;if(C.webhook?.url){let I=w;if(C.webhook.bodyTemplate){let Q=C.webhook.bodyTemplate;Object.entries(w).forEach(([be,q])=>{Q=Q.replace(new RegExp(`\\{\\{${be}\\}\\}`,"g"),String(q))}),I=JSON.parse(Q)}const ee=await fetch(C.webhook.url,{method:C.webhook.method||"POST",headers:{"Content-Type":"application/json",...C.webhook.headers||{}},body:JSON.stringify(I)});if(ee.ok)R={success:!0,data:await ee.json().catch(()=>({success:!0}))};else{const Q=await ee.text();R={success:!1,error:`Webhook failed: ${ee.status} ${Q}`}}}else R={success:!0,message:`Workflow "${C.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:C.contentPlaintext};return de({toolCallId:g,tool:y,output:R}),R}catch(j){const C={success:!1,error:String(j)};throw de({toolCallId:g,tool:y,output:C}),j}}async function ve(g){const y={...xe.current,...g};xe.current=y,ce||dt(y),k&&k(y);try{await _n(g)}catch(w){throw w}}return{id:ke,messages:Je,status:_,error:z,sendMessage:re,stop:Z,addToolOutput:de,executeWorkflowTool:Ze,setMessages:J,conversations:Tt,loadConversation:me,deleteConversation:ne,startNewConversation:Se,isLoadingConversations:bs,clientToken:Fe,tokenError:dn,state:pn,setState:ve,isStateLoading:qe,stateError:gn,pendingSecureInputs:Array.from(Lt.values()),completeSecureInput:Xn,pendingSecureForms:Array.from(st.values()),completeSecureForm:rt,safeToolNames:zt}}function se(...e){return Pl.twMerge(Cl.clsx(e))}const Et=So.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),je=_e.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...r},o)=>{const i=s?wo.Slot:"button";return u.jsx(i,{ref:o,"data-slot":"button",className:se(Et({variant:t,size:n,className:e})),...r})});je.displayName="Button";const Zl=So.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 Cs({className:e,variant:t,asChild:n=!1,...s}){const r=n?wo.Slot:"span";return u.jsx(r,{"data-slot":"badge",className:se(Zl({variant:t}),e),...s})}const Ql=({textAreaRef:e,triggerAutoSize:t,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[r,o]=_e.useState(!0);_e.useEffect(()=>{const a=e.current;if(a){r&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[e.current,t])},Ao=_e.forwardRef(({maxHeight:e=Number.MAX_SAFE_INTEGER,minHeight:t=52,className:n,onChange:s,value:r,...o},i)=>{const a=_e.useRef(null),[l,c]=_e.useState("");return Ql({textAreaRef:a,triggerAutoSize:l,maxHeight:e,minHeight:t}),h.useImperativeHandle(i,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:e,minHeight:t})),_e.useEffect(()=>{c(r)},[o?.defaultValue,r]),u.jsx("textarea",{...o,value:r,ref:a,className:se("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:d=>{c(d.target.value),s?.(d)}})});Ao.displayName="AutosizeTextarea";function ec({delayDuration:e=0,...t}){return u.jsx(Ht.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function mt({...e}){return u.jsx(ec,{children:u.jsx(Ht.Root,{"data-slot":"tooltip",...e})})}function pt({...e}){return u.jsx(Ht.Trigger,{"data-slot":"tooltip-trigger",...e})}function gt({className:e,sideOffset:t=0,children:n,...s}){return u.jsx(Ht.Portal,{children:u.jsxs(Ht.Content,{"data-slot":"tooltip-content",sideOffset:t,className:se("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,u.jsx(Ht.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function ni({className:e,...t}){return u.jsx("kbd",{"data-slot":"kbd",className:se("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 pr=h.createContext({});function gr(e){const t=h.useRef(null);return t.current===null&&(t.current=e()),t.current}const yr=typeof window<"u",Eo=yr?h.useLayoutEffect:h.useEffect,ps=h.createContext(null);function xr(e,t){e.indexOf(t)===-1&&e.push(t)}function br(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const ot=(e,t,n)=>n>t?t:n<e?e:n;function Xs(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let Qt=()=>{},at=()=>{};process.env.NODE_ENV!=="production"&&(Qt=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Xs(t,n))},at=(e,t,n)=>{if(!e)throw new Error(Xs(t,n))});const lt={},Mo=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function ko(e){return typeof e=="object"&&e!==null}const No=e=>/^0[^.\s]+$/u.test(e);function vr(e){let t;return()=>(t===void 0&&(t=e()),t)}const Le=e=>e,tc=(e,t)=>n=>t(e(n)),On=(...e)=>e.reduce(tc),kn=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class wr{constructor(){this.subscriptions=[]}add(t){return xr(this.subscriptions,t),()=>br(this.subscriptions,t)}notify(t,n,s){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](t,n,s);else for(let o=0;o<r;o++){const i=this.subscriptions[o];i&&i(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Xe=e=>e*1e3,$e=e=>e/1e3;function Do(e,t){return t?e*(1e3/t):0}const si=new Set;function Sr(e,t,n){e||si.has(t)||(console.warn(Xs(t,n)),si.add(t))}const Ro=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,nc=1e-7,sc=12;function rc(e,t,n,s,r){let o,i,a=0;do i=t+(n-t)/2,o=Ro(i,s,r)-e,o>0?n=i:t=i;while(Math.abs(o)>nc&&++a<sc);return i}function $n(e,t,n,s){if(e===t&&n===s)return Le;const r=o=>rc(o,0,1,e,n);return o=>o===0||o===1?o:Ro(r(o),t,s)}const Vo=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Io=e=>t=>1-e(1-t),Oo=$n(.33,1.53,.69,.99),Tr=Io(Oo),$o=Vo(Tr),Lo=e=>(e*=2)<1?.5*Tr(e):.5*(2-Math.pow(2,-10*(e-1))),jr=e=>1-Math.sin(Math.acos(e)),Fo=Io(jr),Bo=Vo(jr),ic=$n(.42,0,1,1),oc=$n(0,0,.58,1),Uo=$n(.42,0,.58,1),ac=e=>Array.isArray(e)&&typeof e[0]!="number",zo=e=>Array.isArray(e)&&typeof e[0]=="number",ri={linear:Le,easeIn:ic,easeInOut:Uo,easeOut:oc,circIn:jr,circInOut:Bo,circOut:Fo,backIn:Tr,backInOut:$o,backOut:Oo,anticipate:Lo},lc=e=>typeof e=="string",ii=e=>{if(zo(e)){at(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,r]=e;return $n(t,n,s,r)}else if(lc(e))return at(ri[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),ri[e];return e},Jn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function cc(e,t){let n=new Set,s=new Set,r=!1,o=!1;const i=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(d){i.has(d)&&(c.schedule(d),e()),d(a)}const c={schedule:(d,f=!1,m=!1)=>{const x=m&&r?n:s;return f&&i.add(d),x.has(d)||x.add(d),d},cancel:d=>{s.delete(d),i.delete(d)},process:d=>{if(a=d,r){o=!0;return}r=!0,[n,s]=[s,n],n.forEach(l),n.clear(),r=!1,o&&(o=!1,c.process(d))}};return c}const uc=40;function _o(e,t){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,i=Jn.reduce((E,L)=>(E[L]=cc(o),E),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:d,update:f,preRender:m,render:p,postRender:x}=i,b=()=>{const E=lt.useManualTiming?r.timestamp:performance.now();n=!1,lt.useManualTiming||(r.delta=s?1e3/60:Math.max(Math.min(E-r.timestamp,uc),1)),r.timestamp=E,r.isProcessing=!0,a.process(r),l.process(r),c.process(r),d.process(r),f.process(r),m.process(r),p.process(r),x.process(r),r.isProcessing=!1,n&&t&&(s=!1,e(b))},S=()=>{n=!0,s=!0,r.isProcessing||e(b)};return{schedule:Jn.reduce((E,L)=>{const D=i[L];return E[L]=(O,k=!1,P=!1)=>(n||S(),D.schedule(O,k,P)),E},{}),cancel:E=>{for(let L=0;L<Jn.length;L++)i[Jn[L]].cancel(E)},state:r,steps:i}}const{schedule:le,cancel:xt,state:we,steps:Ps}=_o(typeof requestAnimationFrame<"u"?requestAnimationFrame:Le,!0);let rs;function dc(){rs=void 0}const Me={now:()=>(rs===void 0&&Me.set(we.isProcessing||lt.useManualTiming?we.timestamp:performance.now()),rs),set:e=>{rs=e,queueMicrotask(dc)}},Xo=e=>t=>typeof t=="string"&&t.startsWith(e),Cr=Xo("--"),fc=Xo("var(--"),Pr=e=>fc(e)?hc.test(e.split("/*")[0].trim()):!1,hc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,en={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Nn={...en,transform:e=>ot(0,1,e)},Zn={...en,default:1},Cn=e=>Math.round(e*1e5)/1e5,Ar=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function mc(e){return e==null}const pc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Er=(e,t)=>n=>!!(typeof n=="string"&&pc.test(n)&&n.startsWith(e)||t&&!mc(n)&&Object.prototype.hasOwnProperty.call(n,t)),Wo=(e,t,n)=>s=>{if(typeof s!="string")return s;const[r,o,i,a]=s.match(Ar);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(i),alpha:a!==void 0?parseFloat(a):1}},gc=e=>ot(0,255,e),As={...en,transform:e=>Math.round(gc(e))},kt={test:Er("rgb","red"),parse:Wo("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+As.transform(e)+", "+As.transform(t)+", "+As.transform(n)+", "+Cn(Nn.transform(s))+")"};function yc(e){let t="",n="",s="",r="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),r=e.substring(4,5),t+=t,n+=n,s+=s,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:r?parseInt(r,16)/255:1}}const Ws={test:Er("#"),parse:yc,transform:kt.transform},Ln=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),yt=Ln("deg"),et=Ln("%"),U=Ln("px"),xc=Ln("vh"),bc=Ln("vw"),oi={...et,parse:e=>et.parse(e)/100,transform:e=>et.transform(e*100)},_t={test:Er("hsl","hue"),parse:Wo("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+et.transform(Cn(t))+", "+et.transform(Cn(n))+", "+Cn(Nn.transform(s))+")"},ge={test:e=>kt.test(e)||Ws.test(e)||_t.test(e),parse:e=>kt.test(e)?kt.parse(e):_t.test(e)?_t.parse(e):Ws.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?kt.transform(e):_t.transform(e),getAnimatableNone:e=>{const t=ge.parse(e);return t.alpha=0,ge.transform(t)}},vc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function wc(e){return isNaN(e)&&typeof e=="string"&&(e.match(Ar)?.length||0)+(e.match(vc)?.length||0)>0}const qo="number",Ko="color",Sc="var",Tc="var(",ai="${}",jc=/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 Dn(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},r=[];let o=0;const a=t.replace(jc,l=>(ge.test(l)?(s.color.push(o),r.push(Ko),n.push(ge.parse(l))):l.startsWith(Tc)?(s.var.push(o),r.push(Sc),n.push(l)):(s.number.push(o),r.push(qo),n.push(parseFloat(l))),++o,ai)).split(ai);return{values:n,split:a,indexes:s,types:r}}function Go(e){return Dn(e).values}function Ho(e){const{split:t,types:n}=Dn(e),s=t.length;return r=>{let o="";for(let i=0;i<s;i++)if(o+=t[i],r[i]!==void 0){const a=n[i];a===qo?o+=Cn(r[i]):a===Ko?o+=ge.transform(r[i]):o+=r[i]}return o}}const Cc=e=>typeof e=="number"?0:ge.test(e)?ge.getAnimatableNone(e):e;function Pc(e){const t=Go(e);return Ho(e)(t.map(Cc))}const bt={test:wc,parse:Go,createTransformer:Ho,getAnimatableNone:Pc};function Es(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 Ac({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let r=0,o=0,i=0;if(!t)r=o=i=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;r=Es(l,a,e+1/3),o=Es(l,a,e),i=Es(l,a,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(i*255),alpha:s}}function cs(e,t){return n=>n>0?t:e}const he=(e,t,n)=>e+(t-e)*n,Ms=(e,t,n)=>{const s=e*e,r=n*(t*t-s)+s;return r<0?0:Math.sqrt(r)},Ec=[Ws,kt,_t],Mc=e=>Ec.find(t=>t.test(e));function li(e){const t=Mc(e);if(Qt(!!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===_t&&(n=Ac(n)),n}const ci=(e,t)=>{const n=li(e),s=li(t);if(!n||!s)return cs(e,t);const r={...n};return o=>(r.red=Ms(n.red,s.red,o),r.green=Ms(n.green,s.green,o),r.blue=Ms(n.blue,s.blue,o),r.alpha=he(n.alpha,s.alpha,o),kt.transform(r))},qs=new Set(["none","hidden"]);function kc(e,t){return qs.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Nc(e,t){return n=>he(e,t,n)}function Mr(e){return typeof e=="number"?Nc:typeof e=="string"?Pr(e)?cs:ge.test(e)?ci:Vc:Array.isArray(e)?Yo:typeof e=="object"?ge.test(e)?ci:Dc:cs}function Yo(e,t){const n=[...e],s=n.length,r=e.map((o,i)=>Mr(o)(o,t[i]));return o=>{for(let i=0;i<s;i++)n[i]=r[i](o);return n}}function Dc(e,t){const n={...e,...t},s={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(s[r]=Mr(e[r])(e[r],t[r]));return r=>{for(const o in s)n[o]=s[o](r);return n}}function Rc(e,t){const n=[],s={color:0,var:0,number:0};for(let r=0;r<t.values.length;r++){const o=t.types[r],i=e.indexes[o][s[o]],a=e.values[i]??0;n[r]=a,s[o]++}return n}const Vc=(e,t)=>{const n=bt.createTransformer(t),s=Dn(e),r=Dn(t);return s.indexes.var.length===r.indexes.var.length&&s.indexes.color.length===r.indexes.color.length&&s.indexes.number.length>=r.indexes.number.length?qs.has(e)&&!r.values.length||qs.has(t)&&!s.values.length?kc(e,t):On(Yo(Rc(s,r),r.values),n):(Qt(!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"),cs(e,t))};function Jo(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?he(e,t,n):Mr(e)(e,t)}const Ic=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>le.update(t,n),stop:()=>xt(t),now:()=>we.isProcessing?we.timestamp:Me.now()}},Zo=(e,t,n=10)=>{let s="";const r=Math.max(Math.round(t/n),2);for(let o=0;o<r;o++)s+=Math.round(e(o/(r-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},us=2e4;function kr(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<us;)t+=n,s=e.next(t);return t>=us?1/0:t}function Oc(e,t=100,n){const s=n({...e,keyframes:[0,t]}),r=Math.min(kr(s),us);return{type:"keyframes",ease:o=>s.next(r*o).value/t,duration:$e(r)}}const $c=5;function Qo(e,t,n){const s=Math.max(t-$c,0);return Do(n-e(s),t-s)}const fe={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},ks=.001;function Lc({duration:e=fe.duration,bounce:t=fe.bounce,velocity:n=fe.velocity,mass:s=fe.mass}){let r,o;Qt(e<=Xe(fe.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=ot(fe.minDamping,fe.maxDamping,i),e=ot(fe.minDuration,fe.maxDuration,$e(e)),i<1?(r=c=>{const d=c*i,f=d*e,m=d-n,p=Ks(c,i),x=Math.exp(-f);return ks-m/p*x},o=c=>{const f=c*i*e,m=f*n+n,p=Math.pow(i,2)*Math.pow(c,2)*e,x=Math.exp(-f),b=Ks(Math.pow(c,2),i);return(-r(c)+ks>0?-1:1)*((m-p)*x)/b}):(r=c=>{const d=Math.exp(-c*e),f=(c-n)*e+1;return-ks+d*f},o=c=>{const d=Math.exp(-c*e),f=(n-c)*(e*e);return d*f});const a=5/e,l=Bc(r,o,a);if(e=Xe(e),isNaN(l))return{stiffness:fe.stiffness,damping:fe.damping,duration:e};{const c=Math.pow(l,2)*s;return{stiffness:c,damping:i*2*Math.sqrt(s*c),duration:e}}}const Fc=12;function Bc(e,t,n){let s=n;for(let r=1;r<Fc;r++)s=s-e(s)/t(s);return s}function Ks(e,t){return e*Math.sqrt(1-t*t)}const Uc=["duration","bounce"],zc=["stiffness","damping","mass"];function ui(e,t){return t.some(n=>e[n]!==void 0)}function _c(e){let t={velocity:fe.velocity,stiffness:fe.stiffness,damping:fe.damping,mass:fe.mass,isResolvedFromDuration:!1,...e};if(!ui(e,zc)&&ui(e,Uc))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,o=2*ot(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:fe.mass,stiffness:r,damping:o}}else{const n=Lc(e);t={...t,...n,mass:fe.mass},t.isResolvedFromDuration=!0}return t}function ds(e=fe.visualDuration,t=fe.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:r}=n;const o=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:l,damping:c,mass:d,duration:f,velocity:m,isResolvedFromDuration:p}=_c({...n,velocity:-$e(n.velocity||0)}),x=m||0,b=c/(2*Math.sqrt(l*d)),S=i-o,v=$e(Math.sqrt(l/d)),M=Math.abs(S)<5;s||(s=M?fe.restSpeed.granular:fe.restSpeed.default),r||(r=M?fe.restDelta.granular:fe.restDelta.default);let E;if(b<1){const D=Ks(v,b);E=O=>{const k=Math.exp(-b*v*O);return i-k*((x+b*v*S)/D*Math.sin(D*O)+S*Math.cos(D*O))}}else if(b===1)E=D=>i-Math.exp(-v*D)*(S+(x+v*S)*D);else{const D=v*Math.sqrt(b*b-1);E=O=>{const k=Math.exp(-b*v*O),P=Math.min(D*O,300);return i-k*((x+b*v*S)*Math.sinh(P)+D*S*Math.cosh(P))/D}}const L={calculatedDuration:p&&f||null,next:D=>{const O=E(D);if(p)a.done=D>=f;else{let k=D===0?x:0;b<1&&(k=D===0?Xe(x):Qo(E,D,O));const P=Math.abs(k)<=s,V=Math.abs(i-O)<=r;a.done=P&&V}return a.value=a.done?i:O,a},toString:()=>{const D=Math.min(kr(L),us),O=Zo(k=>L.next(D*k).value,D,30);return D+"ms "+O},toTransition:()=>{}};return L}ds.applyToOptions=e=>{const t=Oc(e,100,ds);return e.ease=t.ease,e.duration=Xe(t.duration),e.type="keyframes",e};function Gs({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:r=10,bounceStiffness:o=500,modifyTarget:i,min:a,max:l,restDelta:c=.5,restSpeed:d}){const f=e[0],m={done:!1,value:f},p=P=>a!==void 0&&P<a||l!==void 0&&P>l,x=P=>a===void 0?l:l===void 0||Math.abs(a-P)<Math.abs(l-P)?a:l;let b=n*t;const S=f+b,v=i===void 0?S:i(S);v!==S&&(b=v-f);const M=P=>-b*Math.exp(-P/s),E=P=>v+M(P),L=P=>{const V=M(P),A=E(P);m.done=Math.abs(V)<=c,m.value=m.done?v:A};let D,O;const k=P=>{p(m.value)&&(D=P,O=ds({keyframes:[m.value,x(m.value)],velocity:Qo(E,P,m.value),damping:r,stiffness:o,restDelta:c,restSpeed:d}))};return k(0),{calculatedDuration:null,next:P=>{let V=!1;return!O&&D===void 0&&(V=!0,L(P),k(P)),D!==void 0&&P>=D?O.next(P-D):(!V&&L(P),m)}}}function Xc(e,t,n){const s=[],r=n||lt.mix||Jo,o=e.length-1;for(let i=0;i<o;i++){let a=r(e[i],e[i+1]);if(t){const l=Array.isArray(t)?t[i]||Le:t;a=On(l,a)}s.push(a)}return s}function Wc(e,t,{clamp:n=!0,ease:s,mixer:r}={}){const o=e.length;if(at(o===t.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const i=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=Xc(t,s,r),l=a.length,c=d=>{if(i&&d<e[0])return t[0];let f=0;if(l>1)for(;f<e.length-2&&!(d<e[f+1]);f++);const m=kn(e[f],e[f+1],d);return a[f](m)};return n?d=>c(ot(e[0],e[o-1],d)):c}function qc(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=kn(0,t,s);e.push(he(n,1,r))}}function Kc(e){const t=[0];return qc(t,e.length-1),t}function Gc(e,t){return e.map(n=>n*t)}function Hc(e,t){return e.map(()=>t||Uo).splice(0,e.length-1)}function Xt({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const r=ac(s)?s.map(ii):ii(s),o={done:!1,value:t[0]},i=Gc(n&&n.length===t.length?n:Kc(t),e),a=Wc(i,t,{ease:Array.isArray(r)?r:Hc(t,r)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Yc=e=>e!==null;function Nr(e,{repeat:t,repeatType:n="loop"},s,r=1){const o=e.filter(Yc),a=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Jc={decay:Gs,inertia:Gs,tween:Xt,keyframes:Xt,spring:ds};function ea(e){typeof e.type=="string"&&(e.type=Jc[e.type])}class Dr{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 Zc=e=>e/100;class Rr extends Dr{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!==Me.now()&&this.tick(Me.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;ea(t);const{type:n=Xt,repeat:s=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=t;let{keyframes:a}=t;const l=n||Xt;process.env.NODE_ENV!=="production"&&l!==Xt&&at(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Xt&&typeof a[0]!="number"&&(this.mixKeyframes=On(Zc,Jo(a[0],a[1])),a=[0,100]);const c=l({...t,keyframes:a});o==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-i})),c.calculatedDuration===null&&(c.calculatedDuration=kr(c));const{calculatedDuration:d}=c;this.calculatedDuration=d,this.resolvedDuration=d+r,this.totalDuration=this.resolvedDuration*(s+1)-r,this.generator=c}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:r,mixKeyframes:o,mirroredGenerator:i,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:c=0,keyframes:d,repeat:f,repeatType:m,repeatDelay:p,type:x,onUpdate:b,finalKeyframe:S}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-r/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const v=this.currentTime-c*(this.playbackSpeed>=0?1:-1),M=this.playbackSpeed>=0?v<0:v>r;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let E=this.currentTime,L=s;if(f){const P=Math.min(this.currentTime,r)/a;let V=Math.floor(P),A=P%1;!A&&P>=1&&(A=1),A===1&&V--,V=Math.min(V,f+1),!!(V%2)&&(m==="reverse"?(A=1-A,p&&(A-=p/a)):m==="mirror"&&(L=i)),E=ot(0,1,A)*a}const D=M?{done:!1,value:d[0]}:L.next(E);o&&(D.value=o(D.value));let{done:O}=D;!M&&l!==null&&(O=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const k=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return k&&x!==Gs&&(D.value=Nr(d,this.options,S,this.speed)),b&&b(D.value),k&&this.finish(),D}then(t,n){return this.finished.then(t,n)}get duration(){return $e(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+$e(t)}get time(){return $e(this.currentTime)}set time(t){t=Xe(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(Me.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=$e(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Ic,startTime:n}=this.options;this.driver||(this.driver=t(r=>this.tick(r))),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(Me.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 Qc(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Nt=e=>e*180/Math.PI,Hs=e=>{const t=Nt(Math.atan2(e[1],e[0]));return Ys(t)},eu={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Hs,rotateZ:Hs,skewX:e=>Nt(Math.atan(e[1])),skewY:e=>Nt(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Ys=e=>(e=e%360,e<0&&(e+=360),e),di=Hs,fi=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),hi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),tu={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:fi,scaleY:hi,scale:e=>(fi(e)+hi(e))/2,rotateX:e=>Ys(Nt(Math.atan2(e[6],e[5]))),rotateY:e=>Ys(Nt(Math.atan2(-e[2],e[0]))),rotateZ:di,rotate:di,skewX:e=>Nt(Math.atan(e[4])),skewY:e=>Nt(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Js(e){return e.includes("scale")?1:0}function Zs(e,t){if(!e||e==="none")return Js(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=tu,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=eu,r=a}if(!r)return Js(t);const o=s[t],i=r[1].split(",").map(su);return typeof o=="function"?o(i):i[o]}const nu=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Zs(n,t)};function su(e){return parseFloat(e.trim())}const tn=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],nn=new Set(tn),mi=e=>e===en||e===U,ru=new Set(["x","y","z"]),iu=tn.filter(e=>!ru.has(e));function ou(e){const t=[];return iu.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Dt={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})=>Zs(t,"x"),y:(e,{transform:t})=>Zs(t,"y")};Dt.translateX=Dt.x;Dt.translateY=Dt.y;const Rt=new Set;let Qs=!1,er=!1,tr=!1;function ta(){if(er){const e=Array.from(Rt).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const r=ou(s);r.length&&(n.set(s,r),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const r=n.get(s);r&&r.forEach(([o,i])=>{s.getValue(o)?.set(i)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}er=!1,Qs=!1,Rt.forEach(e=>e.complete(tr)),Rt.clear()}function na(){Rt.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(er=!0)})}function au(){tr=!0,na(),ta(),tr=!1}class Vr{constructor(t,n,s,r,o,i=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=r,this.element=o,this.isAsync=i}scheduleResolve(){this.state="scheduled",this.isAsync?(Rt.add(this),Qs||(Qs=!0,le.read(na),le.resolveKeyframes(ta))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:r}=this;if(t[0]===null){const o=r?.get(),i=t[t.length-1];if(o!==void 0)t[0]=o;else if(s&&n){const a=s.readValue(n,i);a!=null&&(t[0]=a)}t[0]===void 0&&(t[0]=i),r&&o===void 0&&r.set(t[0])}Qc(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Rt.delete(this)}cancel(){this.state==="scheduled"&&(Rt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const lu=e=>e.startsWith("--");function cu(e,t,n){lu(t)?e.style.setProperty(t,n):e.style[t]=n}const uu=vr(()=>window.ScrollTimeline!==void 0),du={};function fu(e,t){const n=vr(e);return()=>du[t]??n()}const sa=fu(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Tn=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,pi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Tn([0,.65,.55,1]),circOut:Tn([.55,0,1,.45]),backIn:Tn([.31,.01,.66,-.59]),backOut:Tn([.33,1.53,.69,.99])};function ra(e,t){if(e)return typeof e=="function"?sa()?Zo(e,t):"ease-out":zo(e)?Tn(e):Array.isArray(e)?e.map(n=>ra(n,t)||pi.easeOut):pi[e]}function hu(e,t,n,{delay:s=0,duration:r=300,repeat:o=0,repeatType:i="loop",ease:a="easeOut",times:l}={},c=void 0){const d={[t]:n};l&&(d.offset=l);const f=ra(a,r);Array.isArray(f)&&(d.easing=f);const m={delay:s,duration:r,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:o+1,direction:i==="reverse"?"alternate":"normal"};return c&&(m.pseudoElement=c),e.animate(d,m)}function ia(e){return typeof e=="function"&&"applyToOptions"in e}function mu({type:e,...t}){return ia(e)&&sa()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class pu extends Dr{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:s,keyframes:r,pseudoElement:o,allowFlatten:i=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!o,this.allowFlatten=i,this.options=t,at(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const c=mu(t);this.animation=hu(n,s,r,c,o),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Nr(r,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):cu(n,s,d),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 $e(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+$e(t)}get time(){return $e(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=Xe(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&&uu()?(this.animation.timeline=t,Le):n(this)}}const oa={anticipate:Lo,backInOut:$o,circInOut:Bo};function gu(e){return e in oa}function yu(e){typeof e.ease=="string"&&gu(e.ease)&&(e.ease=oa[e.ease])}const gi=10;class xu extends pu{constructor(t){yu(t),ea(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:s,onComplete:r,element:o,...i}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const a=new Rr({...i,autoplay:!1}),l=Xe(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-gi).value,a.sample(l).value,gi),a.stop()}}const yi=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(bt.test(e)||e==="0")&&!e.startsWith("url("));function bu(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 vu(e,t,n,s){const r=e[0];if(r===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],i=yi(r,t),a=yi(o,t);return Qt(i===a,`You are trying to animate ${t} from "${r}" to "${o}". "${i?o:r}" is not an animatable value.`,"value-not-animatable"),!i||!a?!1:bu(e)||(n==="spring"||ia(n))&&s}function nr(e){e.duration=0,e.type="keyframes"}const wu=new Set(["opacity","clipPath","filter","transform"]),Su=vr(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Tu(e){const{motionValue:t,name:n,repeatDelay:s,repeatType:r,damping:o,type:i}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:c}=t.owner.getProps();return Su()&&n&&wu.has(n)&&(n!=="transform"||!c)&&!l&&!s&&r!=="mirror"&&o!==0&&i!=="inertia"}const ju=40;class Cu extends Dr{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:i="loop",keyframes:a,name:l,motionValue:c,element:d,...f}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Me.now();const m={autoplay:t,delay:n,type:s,repeat:r,repeatDelay:o,repeatType:i,name:l,motionValue:c,element:d,...f},p=d?.KeyframeResolver||Vr;this.keyframeResolver=new p(a,(x,b,S)=>this.onKeyframesResolved(x,b,m,!S),l,c,d),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,s,r){this.keyframeResolver=void 0;const{name:o,type:i,velocity:a,delay:l,isHandoff:c,onUpdate:d}=s;this.resolvedAt=Me.now(),vu(t,o,i,a)||((lt.instantAnimations||!l)&&d?.(Nr(t,s,n)),t[0]=t[t.length-1],nr(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>ju?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!c&&Tu(m)?new xu({...m,element:m.motionValue.owner.current}):new Rr(m);p.finished.then(()=>this.notifyFinished()).catch(Le),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),au()),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 Pu=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Au(e){const t=Pu.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}const Eu=4;function aa(e,t,n=1){at(n<=Eu,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=Au(e);if(!s)return;const o=window.getComputedStyle(t).getPropertyValue(s);if(o){const i=o.trim();return Mo(i)?parseFloat(i):i}return Pr(r)?aa(r,t,n+1):r}function Ir(e,t){return e?.[t]??e?.default??e}const la=new Set(["width","height","top","left","right","bottom",...tn]),Mu={test:e=>e==="auto",parse:e=>e},ca=e=>t=>t.test(e),ua=[en,U,et,yt,bc,xc,Mu],xi=e=>ua.find(ca(e));function ku(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||No(e):!0}const Nu=new Set(["brightness","contrast","saturate","opacity"]);function Du(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(Ar)||[];if(!s)return e;const r=n.replace(s,"");let o=Nu.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+r+")"}const Ru=/\b([a-z-]*)\(.*?\)/gu,sr={...bt,getAnimatableNone:e=>{const t=e.match(Ru);return t?t.map(Du).join(" "):e}},bi={...en,transform:Math.round},Vu={rotate:yt,rotateX:yt,rotateY:yt,rotateZ:yt,scale:Zn,scaleX:Zn,scaleY:Zn,scaleZ:Zn,skew:yt,skewX:yt,skewY:yt,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:Nn,originX:oi,originY:oi,originZ:U},Or={borderWidth:U,borderTopWidth:U,borderRightWidth:U,borderBottomWidth:U,borderLeftWidth:U,borderRadius:U,radius:U,borderTopLeftRadius:U,borderTopRightRadius:U,borderBottomRightRadius:U,borderBottomLeftRadius:U,width:U,maxWidth:U,height:U,maxHeight:U,top:U,right:U,bottom:U,left:U,padding:U,paddingTop:U,paddingRight:U,paddingBottom:U,paddingLeft:U,margin:U,marginTop:U,marginRight:U,marginBottom:U,marginLeft:U,backgroundPositionX:U,backgroundPositionY:U,...Vu,zIndex:bi,fillOpacity:Nn,strokeOpacity:Nn,numOctaves:bi},Iu={...Or,color:ge,backgroundColor:ge,outlineColor:ge,fill:ge,stroke:ge,borderColor:ge,borderTopColor:ge,borderRightColor:ge,borderBottomColor:ge,borderLeftColor:ge,filter:sr,WebkitFilter:sr},da=e=>Iu[e];function fa(e,t){let n=da(e);return n!==sr&&(n=bt),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Ou=new Set(["auto","none","0"]);function $u(e,t,n){let s=0,r;for(;s<e.length&&!r;){const o=e[s];typeof o=="string"&&!Ou.has(o)&&Dn(o).values.length&&(r=e[s]),s++}if(r&&n)for(const o of t)e[o]=fa(n,r)}class Lu extends Vr{constructor(t,n,s,r,o){super(t,n,s,r,o,!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 c=t[l];if(typeof c=="string"&&(c=c.trim(),Pr(c))){const d=aa(c,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!la.has(s)||t.length!==2)return;const[r,o]=t,i=xi(r),a=xi(o);if(i!==a)if(mi(i)&&mi(a))for(let l=0;l<t.length;l++){const c=t[l];typeof c=="string"&&(t[l]=parseFloat(c))}else Dt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||ku(t[r]))&&s.push(r);s.length&&$u(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=Dt[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&t.getValue(s,r).jump(r,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const r=t.getValue(n);r&&r.jump(this.measuredOrigin,!1);const o=s.length-1,i=s[o];s[o]=Dt[n](t.measureViewportBox(),window.getComputedStyle(t.current)),i!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=i),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{t.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function Fu(e,t,n){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let s=document;const r=n?.[e]??s.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e)}const ha=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function ma(e){return ko(e)&&"offsetHeight"in e}const vi=30,Bu=e=>!isNaN(parseFloat(e));class Uu{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const r=Me.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Me.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Bu(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Sr(!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 wr);const s=this.events[t].add(n);return t==="change"?()=>{s(),le.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=Me.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>vi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,vi);return Do(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 Jt(e,t){return new Uu(e,t)}const{schedule:$r}=_o(queueMicrotask,!1),ze={x:!1,y:!1};function pa(){return ze.x||ze.y}function zu(e){return e==="x"||e==="y"?ze[e]?null:(ze[e]=!0,()=>{ze[e]=!1}):ze.x||ze.y?null:(ze.x=ze.y=!0,()=>{ze.x=ze.y=!1})}function ga(e,t){const n=Fu(e),s=new AbortController,r={passive:!0,...t,signal:s.signal};return[n,r,()=>s.abort()]}function wi(e){return!(e.pointerType==="touch"||pa())}function _u(e,t,n={}){const[s,r,o]=ga(e,n),i=a=>{if(!wi(a))return;const{target:l}=a,c=t(l,a);if(typeof c!="function"||!l)return;const d=f=>{wi(f)&&(c(f),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return s.forEach(a=>{a.addEventListener("pointerenter",i,r)}),o}const ya=(e,t)=>t?e===t?!0:ya(e,t.parentElement):!1,Lr=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Xu=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Wu(e){return Xu.has(e.tagName)||e.tabIndex!==-1}const is=new WeakSet;function Si(e){return t=>{t.key==="Enter"&&e(t)}}function Ns(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const qu=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Si(()=>{if(is.has(n))return;Ns(n,"down");const r=Si(()=>{Ns(n,"up")}),o=()=>Ns(n,"cancel");n.addEventListener("keyup",r,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function Ti(e){return Lr(e)&&!pa()}function Ku(e,t,n={}){const[s,r,o]=ga(e,n),i=a=>{const l=a.currentTarget;if(!Ti(a))return;is.add(l);const c=t(l,a),d=(p,x)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",m),is.has(l)&&is.delete(l),Ti(p)&&typeof c=="function"&&c(p,{success:x})},f=p=>{d(p,l===window||l===document||n.useGlobalTarget||ya(l,p.target))},m=p=>{d(p,!1)};window.addEventListener("pointerup",f,r),window.addEventListener("pointercancel",m,r)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",i,r),ma(a)&&(a.addEventListener("focus",c=>qu(c,r)),!Wu(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function xa(e){return ko(e)&&"ownerSVGElement"in e}function Gu(e){return xa(e)&&e.tagName==="svg"}const Te=e=>!!(e&&e.getVelocity),Hu=[...ua,ge,bt],Yu=e=>Hu.find(ca(e)),Fr=h.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function ji(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ju(...e){return t=>{let n=!1;const s=e.map(r=>{const o=ji(r,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let r=0;r<s.length;r++){const o=s[r];typeof o=="function"?o():ji(e[r],null)}}}}function Zu(...e){return _e.useCallback(Ju(...e),e)}class Qu extends _e.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,r=ma(s)&&s.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=r-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function ed({children:e,isPresent:t,anchorX:n,root:s}){const r=h.useId(),o=h.useRef(null),i=h.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=h.useContext(Fr),l=Zu(o,e?.ref);return h.useInsertionEffect(()=>{const{width:c,height:d,top:f,left:m,right:p}=i.current;if(t||!o.current||!c||!d)return;const x=n==="left"?`left: ${m}`:`right: ${p}`;o.current.dataset.motionPopId=r;const b=document.createElement("style");a&&(b.nonce=a);const S=s??document.head;return S.appendChild(b),b.sheet&&b.sheet.insertRule(`
|
|
2
|
+
To fix: Run "arcten-extract-types ." and ensure "${c}" is used in ArctenAgent/useAgent.`),null}return r.add(i.meta.name),{name:i.meta.name,description:i.meta.description,jsonSchema:i.meta.parameters}}).filter(o=>o!==null)}const Vl={password:[/^password$/i,/^pwd$/i,/^pass$/i,/^newPassword$/i,/^oldPassword$/i,/^currentPassword$/i,/^confirmPassword$/i,/.*password.*/i],email:[/^email$/i,/^emailAddress$/i,/^mail$/i,/.*email.*/i],phone:[/^phone$/i,/^phoneNumber$/i,/^mobile$/i,/^cell$/i,/^cellPhone$/i,/^telephone$/i,/.*phone.*/i,/.*mobile.*/i],pin:[/^pin$/i,/^pinCode$/i,/^securityPin$/i,/^accessPin$/i,/.*pin$/i],ssn:[/^ssn$/i,/^socialSecurityNumber$/i,/^social$/i,/.*ssn.*/i,/.*social.*/i],creditCard:[/^creditCard$/i,/^cardNumber$/i,/^card$/i,/^ccNumber$/i,/^creditCardNumber$/i,/.*card.*/i,/^cvv$/i,/^cvc$/i,/^cvn$/i,/^securityCode$/i],text:[]};function Sn(e){for(const[t,n]of Object.entries(Vl))if(t!=="text"){for(const s of n)if(s.test(e))return t}return null}function Il(e,t){return{password:{title:"Password Required",description:"Please enter your password to continue",placeholder:"Enter password..."},email:{title:"Email Required",description:"Please enter your email address",placeholder:"Enter email address..."},phone:{title:"Phone Number Required",description:"Please enter your phone number",placeholder:"Enter phone number..."},pin:{title:"PIN Required",description:"Please enter your PIN",placeholder:"Enter PIN..."},ssn:{title:"Social Security Number Required",description:"Please enter your Social Security Number",placeholder:"XXX-XX-XXXX"},creditCard:{title:"Credit Card Required",description:"Please enter your credit card information",placeholder:"XXXX XXXX XXXX XXXX"},text:{title:"Secure Input Required",description:`Please enter your ${t}`,placeholder:`Enter ${t}...`}}[e]}function Ol(e,t,n){return t.length>0}function $l(e,t,n,s={}){const r=[];return Object.keys(s).forEach(i=>{const a=i in n,l=n[i];if(!a){const f=s[i];if(f!=null&&f!=="")return}const c=Ll(s[i]),d={name:i,type:Fl(l||Sn(i)||"text"),label:To(i),placeholder:Bl(i,l),required:!0,value:c};d.type==="password"&&(d.validation=f=>f.length<8?"Password must be at least 8 characters":null),r.push(d)}),r.sort((i,a)=>{const l=i.name in n,c=a.name in n;return l===c?0:l?1:-1}),{shouldUseForm:Ol(e,t),fields:r,title:Ul(e),description:zl(e,r.length)}}function Ll(e){if(e!=null){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}}function Fl(e){switch(e){case"password":return"password";case"email":return"email";case"phone":return"phone";case"pin":return"pin";case"ssn":return"ssn";case"creditCard":return"creditCard";default:return"text"}}function To(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Bl(e,t){return t?Il(t,e).placeholder:`Enter ${To(e).toLowerCase()}...`}function Ul(e){return e.replace(/([A-Z])/g," $1").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function zl(e,t){const n=e.toLowerCase();return t<=2?`Please provide the required information to ${n}.`:`Please fill out the form below to ${n}. Required fields are marked with *.`}function jn(e){if(typeof e=="string")try{const t=JSON.parse(e);return jn(t)}catch{return e}if(Array.isArray(e))return e.map(jn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=jn(s);return t}return e}function _l(e,t){if(!t||Object.keys(t).length===0)return e;const n={...e};return Object.keys(t).forEach(s=>{s in n&&delete n[s]}),n}function Xl(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return jn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?jn(e):{}}const ns="__secureOutput",ss="[hidden for privacy]";function Wl(e,t){if(!e||e.length===0)return t;const n=new Map;t.forEach(o=>{const i=o[Oe]||o.name;i&&n.set(i,o)});const s=new Map(e.map(o=>[o.name,o])),r=[];return e.forEach(o=>{const i=n.get(o.name);if(!i){console.log(`[useAgent] Skipping server-only tool: ${o.name}`);return}if(!o.isEnabled&&!o.isOverridable){console.log(`[useAgent] Blocking non-overridable disabled tool: ${o.name}`);return}if(!o.isEnabled&&o.isOverridable&&i){console.log(`[useAgent] Allowing overridable disabled tool with local implementation: ${o.name}`),r.push(i);return}o.isEnabled&&i&&r.push(i)}),t.forEach(o=>{const i=o[Oe]||o.name;i&&!s.has(i)&&(console.log(`[useAgent] Allowing client-only tool (forward compatible): ${i}`),r.push(o))}),r}function ql(e){if(typeof globalThis.structuredClone=="function")return globalThis.structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch(t){return console.warn("[useAgent] Failed to clone value for redaction:",t),e}}function Kl(e){return e.replace(/\[(\w+)\]/g,".$1").split(".").map(t=>t.trim()).filter(Boolean)}function Gl(e,t){if(t.length===0)return e;if(!e||typeof e!="object")return;let n=e;for(const s of t){if(!n||typeof n!="object")return;n=n[s]}return n}function Hl(e,t,n){if(!e||typeof e!="object"||t.length===0)return!1;let s=e;for(let o=0;o<t.length-1;o++){if(!s||typeof s!="object")return!1;const i=s,a=t[o];if(a===void 0)return!1;const l=i[a];if(l==null||typeof l!="object")return!1;s=l}if(!s)return!1;const r=t[t.length-1];return!r||!(r in s)?!1:(s[r]=n,!0)}function _s(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0}function jo(e,t=""){const n={};return e&&typeof e=="object"?Object.entries(e).forEach(([s,r])=>{const o=t?`${t}.${s}`:s;n[o]=_s(r),r&&typeof r=="object"&&Object.assign(n,jo(r,o))}):t&&(n[t]=_s(e)),n}function Yl(e){if(e===void 0||e===!1)return;if(e===!0)return{strategy:"full",fields:[],placeholder:ss,includeFieldStatus:!1,preserve:[]};if(Array.isArray(e))return{strategy:"fields",fields:e,placeholder:ss,includeFieldStatus:!1,preserve:[]};const t=e.strategy??(e.fields&&e.fields.length>0?"fields":"full");return{strategy:t,fields:t==="fields"?e.fields??[]:[],placeholder:e.placeholder??ss,includeFieldStatus:e.includeFieldStatus??!1,preserve:e.preserve??[]}}function Jl(e){if(!e)return{};const t={};for(const[n,s]of Object.entries(e)){const r=Yl(s);r&&(t[n]=r)}return t}function Co(e,t,n){const s=n.placeholder,r={tool:e,redacted:!0,strategy:n.strategy,placeholder:s};if(n.strategy==="full"){n.includeFieldStatus&&typeof t=="object"&&t!==null&&(r.fieldStatus=jo(t)),r.redactedFields=["*"];let l={};return n.preserve.length>0&&t&&typeof t=="object"&&n.preserve.forEach(c=>{c in t&&(l[c]=t[c])}),l[ns]=r,l}if(n.fields.includes("*"))return Co(e,t,{...n,strategy:"full",fields:[]});if(typeof t!="object"||t===null)return{value:s,[ns]:{...r,redactedFields:n.fields}};const o=ql(t),i=[],a={};return n.fields.forEach(l=>{const c=Kl(l);if(c.length===0)return;const d=Gl(o,c),f=_s(d);a[l]=f,Hl(o,c,s)&&i.push(l)}),r.redactedFields=i,n.includeFieldStatus&&(r.fieldStatus=a),o[ns]=r,o}function Po({apiBaseUrl:e="https://api.arcten.com",tokenEndpoint:t="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:r,tools:o=[],safeTools:i=[],safeToolNames:a,toolMetadata:l,sensitiveParams:c,sensitiveOutputs:d,autoDetectSensitive:f=!1,autoFormGeneration:m=!1,formMode:p="auto",systemPrompt:x="",agentId:b,agentName:S,projectId:v,enableRemoteConfig:M,remoteConfigUrl:E,initialMessages:L=[],conversationId:D,state:O,onStateChange:k,allowStateEdits:P=!0,onToolCall:V,onFinish:A,sources:N,ragConfig:F,ragFilters:$,secureInputHandler:B}={}){const X=e.replace(/\/+$/,""),[G,K]=h.useState(null),[oe,ye]=h.useState(!1),[We,wt]=h.useState(null),tt=h.useMemo(()=>{const g=N||[],y=G?.config?.sources||[];return[...new Set([...g,...y])]},[N,G]),H=h.useMemo(()=>F!==void 0?F:$?{enabled:!0,filters:$}:tt&&tt.length>0?{enabled:!0,organizationId:tt[0],autoExecute:!0,filters:void 0}:{enabled:!1},[tt,F,$]),It=h.useMemo(()=>M===!1?!1:!!v,[v,M]);h.useEffect(()=>{if(!It||!ae.current)return;(async()=>{ye(!0),wt(null);try{const w=`${E||X.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,j=await fetch(w,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae.current}`},body:JSON.stringify({path:"agents:getConfigForClient",args:{projectId:v,agentName:S,agentId:b},format:"json"})});if(!j.ok){if(j.status===404){console.warn("[useAgent] Remote config endpoint not found (404), using local tools only"),K(null);return}const R=await j.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch remote config: ${j.status} ${R}`)}const C=await j.json();K(C?.value||null),console.log("[useAgent] Remote config loaded successfully:",C?.value)}catch(y){console.error("[useAgent] Failed to fetch remote config:",y);const w=y instanceof Error?y:new Error(String(y));wt(w),K(null)}finally{ye(!1)}})()},[It,v,S,b,X,E]);const Ee=h.useMemo(()=>{const g={};if(c)for(const[y,w]of Object.entries(c))if(g[y]={},Array.isArray(w))for(const j of w){const C=Sn(j);g[y][j]=C||"text"}else for(const[j,C]of Object.entries(w))g[y][j]=C;if(l){for(const[y,w]of Object.entries(l))if(w&&typeof w=="object"&&"sensitiveParams"in w){g[y]||(g[y]={});const j=w.sensitiveParams;if(Array.isArray(j))for(const C of j){const R=Sn(C);g[y][C]=R||"text"}else if(j&&typeof j=="object")for(const[C,R]of Object.entries(j))g[y][C]=R}}return g},[c,l,f]),St=h.useMemo(()=>Jl(d),[d]),Ce=h.useCallback((g,y)=>{const w=St[g];if(!w)return y;try{return Co(g,y,w)}catch(j){return console.error(`[useAgent] Failed to redact output for ${g}:`,j),{value:ss,[ns]:{tool:g,redacted:!0,error:String(j)}}}},[St]),[Fe,Ot]=h.useState(n||null),ae=h.useRef(n||null),[dn,ct]=h.useState(null),[ut,fn]=h.useState(null),Be=h.useRef(null),[Tt,jt]=h.useState([]),[ke,hn]=h.useState(D||(typeof window<"u"?crypto.randomUUID():null)),[bs,$t]=h.useState(!1),mn=h.useRef(new Set),[Lt,nt]=h.useState(new Map),[vs,Bn]=h.useState(new Map),[st,Un]=h.useState(new Map),[zn,Ft]=h.useState(new Map),ce=O!==void 0,[Bt,dt]=h.useState({}),xe=h.useRef({}),pn=ce?O||{}:Bt;ce&&O?xe.current=O:ce||(xe.current=Bt);const[qe,Re]=h.useState(!1),[gn,Ke]=h.useState(null),Ct=h.useRef(!1),_n=h.useCallback(async(g,y=3)=>{if(!ke||!ae.current)return;const w=async()=>{const C=`${X.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,R=await fetch(C,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:ke,updates:g},format:"json"})});if(!R.ok){if(R.status===404)return;const I=await R.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${R.status} ${I}`)}};for(let j=0;j<y;j++)try{await w(),Ke(null);return}catch(C){if(j===y-1){const I=C instanceof Error?C:new Error(String(C));throw Ke(I),console.error("Failed to sync state to Convex after retries:",C),I}await new Promise(I=>setTimeout(I,Math.pow(2,j)*100))}},[ke,X,ae]),Pe=h.useMemo(()=>function(){return xe.current},[]),ft=h.useMemo(()=>async function(y){const w={...xe.current,...y};xe.current=w,ce||dt(w),k&&k(w);try{await _n(y)}catch(j){throw j}},[_n,k,ce]);h.useEffect(()=>{ce&&O&&(xe.current=O)},[ce,O]);const Ne=h.useCallback(g=>B?B.showSecureModal(g):new Promise(y=>{nt(w=>new Map(w).set(g.id,g)),Bn(w=>new Map(w).set(g.id,y))}),[B]),Xn=h.useCallback((g,y)=>{if(B)return;const w=vs.get(g);w&&(w(y),nt(j=>{const C=new Map(j);return C.delete(g),C}),Bn(j=>{const C=new Map(j);return C.delete(g),C}))},[vs,B]),Ut=h.useCallback(g=>B?B.showSecureForm(g):new Promise(y=>{Un(w=>new Map(w).set(g.id,g)),Ft(w=>new Map(w).set(g.id,y))}),[B]),rt=h.useCallback((g,y)=>{if(B)return;const w=zn.get(g);w&&(w(y),Un(j=>{const C=new Map(j);return C.delete(g),C}),Ft(j=>{const C=new Map(j);return C.delete(g),C}))},[zn,B]),Wn=h.useCallback((g,y)=>{const w=Ee[g]||{},j=Object.keys(w).length>0;if(f){const C=Object.keys(y).filter(R=>Sn(R)!==null);return j||C.length>0}return j},[Ee,f]),qn=h.useCallback((g,y)=>{const j={...Ee[g]||{}};if(f){for(const R of Object.keys(y))if(!(R in j)){const I=Sn(R);I&&(j[R]=I)}}const C=Object.entries(j).filter(([R])=>Object.prototype.hasOwnProperty.call(y,R));return C.length>0?Object.fromEntries(C):j},[Ee,f]),Ge=h.useMemo(()=>H?.enabled?async function(y,w=20,j){const C={...H.filters,...j};if(N&&N.length>1){const I=N.map(q=>fetch(`${X}/search`,{method:"POST",headers:{"Content-Type":"application/json",...ae.current?{Authorization:`Bearer ${ae.current}`}:{}},body:JSON.stringify({q:y,k:Math.min(w,100),organizationId:q,...Object.keys(C).length>0?{filters:C}:{}})}).then(ie=>ie.ok?ie.json():null)),ee=await Promise.all(I),Q=[];for(const q of ee)q?.candidates&&Q.push(...q.candidates);Q.sort((q,ie)=>{const Qe=q.scores?.rerank||q.scores?.dense||0;return(ie.scores?.rerank||ie.scores?.dense||0)-Qe});const be=Q.slice(0,w).map((q,ie)=>{const Qe=q.citation||q.url;return{rank:ie+1,doc_id:q.doc_id,block_id:q.block_id,url:q.url,citation:Qe,title:q.title||"Untitled",snippet:q.snippet,score:q.scores?.rerank||q.scores?.dense||0,metadata:{site:q.metadata?.site,lang:q.metadata?.lang,contentType:q.metadata?.content_type}}});return{success:!0,query:y,total:Q.length,results:be,summary:`Found ${Q.length} relevant results across ${N.length} source(s) for "${y}". Top result: ${be[0]?.title||"N/A"}`}}const R=H.organizationId&&H.organizationId!=="default"?H.organizationId:N&&N.length>0?N[0]:void 0;try{const I={q:y,k:Math.min(w,100)};R&&(I.organizationId=R),Object.keys(C).length>0&&(I.filters=C);const ee={"Content-Type":"application/json"};ae.current&&(ee.Authorization=`Bearer ${ae.current}`);const Q=await fetch(`${X}/search`,{method:"POST",headers:ee,body:JSON.stringify(I)});if(!Q.ok){const ie=await Q.text();return{success:!1,error:`Search failed: ${Q.status} ${ie}`}}const be=await Q.json(),q=be.candidates.map((ie,Qe)=>{const vn=ie.citation||ie.url;return{rank:Qe+1,doc_id:ie.doc_id,block_id:ie.block_id,url:ie.url,citation:vn,title:ie.title||"Untitled",snippet:ie.snippet,score:ie.scores?.rerank||ie.scores?.dense||0,metadata:{site:ie.metadata?.site,lang:ie.metadata?.lang,contentType:ie.metadata?.content_type}}});return{success:!0,query:be.query,total:be.total,results:q,summary:`Found ${be.total} relevant results for "${y}". Top result: ${q[0]?.title||"N/A"}`}}catch(I){return{success:!1,error:I instanceof Error?I.message:"Unknown error occurred"}}}:null,[H,X,ae]),He=h.useMemo(()=>H?.enabled?async function(y,w){const j=H.organizationId&&H.organizationId!=="default"?H.organizationId:N&&N.length>0?N[0]:void 0;try{const C={"Content-Type":"application/json"};ae.current&&(C.Authorization=`Bearer ${ae.current}`);const R=await fetch(`${X}/fetch`,{method:"POST",headers:C,body:JSON.stringify({doc_id:y,block_ids:w,...j?{organizationId:j}:{}})});if(!R.ok){const ee=await R.text();return{success:!1,error:`Fetch failed: ${R.status} ${ee}`}}const I=await R.json();return{success:!0,blocks:I.blocks||[],fullContent:I.fullContent||"",pageUrl:I.pageUrl||"",pageTitle:I.pageTitle||"",summary:`Fetched ${I.blocks?.length||0} blocks from ${I.pageTitle||y}`}}catch(C){return{success:!1,error:C instanceof Error?C.message:"Unknown error occurred"}}}:null,[H,X,ae]),yn=h.useMemo(()=>{if(G&&G.config?.tools){const g=Wl(G.config.tools,o);return console.log("[useAgent] Merged remote config:",{remoteToolCount:G.config.tools.length,localToolCount:o.length,mergedToolCount:g.length}),g}return o},[G,o]),Ue=G?.enableStateTools??!0,Ye=G?.enableRagTools??H?.enabled??!1,Kn=h.useMemo(()=>{const g=[...yn,...i];return Ue&&(g.push(Pe),(!ce||P)&&g.push(ft)),Ye&&(Ge&&g.push(Ge),He&&g.push(He)),g},[yn,i,Pe,ft,Ge,He,Ue,Ye,ce,P]),Gn=h.useMemo(()=>[...yn,...i],[yn,i]),it=h.useMemo(()=>mr(Gn,l),[Gn,l]),Pt=h.useMemo(()=>{const g=new Map,y=new Map(it.map(w=>[w.name,w]));return g.set("getState",Pe),(!ce||P)&&g.set("setState",ft),H?.enabled&&(Ge&&g.set("searchDocs",Ge),He&&g.set("fetchDocContent",He)),Kn.forEach(w=>{if(w===Pe||w===ft||w===Ge||w===He)return;const j=w[Oe];if(j){const R=y.get(j);if(R){g.set(R.name,w);return}}const C=it.find(R=>R.name===w.name);C&&g.set(C.name,w)}),g},[Kn,it,Pe,ft,Ge,He,H,ce,P]),Hn=h.useMemo(()=>new Set(it.map(g=>g.name)),[it]),xn=h.useMemo(()=>{const g=[];Ue&&(g.push({name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}),(!ce||P)&&g.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}));const y=[];Ye&&y.push({name:"searchDocs",description:"Search documentation using semantic search. Returns relevant results with snippets and scores. Use this first to find relevant documentation. Default returns 20 results - use higher k values (30-50) when you need to find many sources.",jsonSchema:{type:"object",properties:{query:{type:"string",description:"The search query (user's question or keywords)"},k:{type:"number",description:"Number of results to return (default: 20, max: 100). Use 20-30 for comprehensive searches, or higher (50-100) when you need to find all relevant sources.",default:20},filters:{type:"object",description:"Optional filters to scope the search",properties:{site:{type:"string"},lang:{type:"string"},tags:{type:"array",items:{type:"string"}},docIds:{type:"array",items:{type:"string"}},pageIds:{type:"array",items:{type:"string"}}}}},required:["query"]}},{name:"fetchDocContent",description:"Fetch full content of documentation blocks after searching. Use this AFTER searchDocs when you find relevant results (scores > 0.3) to get complete text. Automatically fetches nearby blocks (5 chunks before/after each requested block) for context. You can pass multiple block_ids to fetch comprehensive content from multiple blocks/pages.",jsonSchema:{type:"object",properties:{doc_id:{type:"string",description:"The doc_id from searchDocs results"},block_ids:{type:"array",items:{type:"string"},description:"Array of block_ids from searchDocs results. You can pass multiple block_ids to fetch comprehensive content."}},required:["doc_id","block_ids"]}});const w=[];return G?.config?.workflows&&G.config.workflows.forEach(j=>{const C={},R=[];j.parameters&&j.parameters.forEach(I=>{C[I.name]={type:I.type||"string",description:I.description},I.required&&R.push(I.name)}),w.push({name:`workflow_${j.name.replace(/\s+/g,"_").toLowerCase()}`,description:j.description||`Execute the "${j.name}" workflow. ${j.contentPlaintext?.slice(0,200)||""}`,jsonSchema:{type:"object",properties:C,required:R},_workflow:j})}),[...it,...g,...y,...w]},[it,Ue,Ye,ce,P,G]),ht=h.useMemo(()=>xn.filter(g=>g.name==="getState"?Ue:g.name==="setState"?Ue&&(!ce||P):g.name==="searchDocs"||g.name==="fetchDocContent"?Ye:g.name.startsWith("workflow_")?!0:Hn.has(g.name)),[xn,Hn,Ue,Ye,ce,P]),zt=h.useMemo(()=>{const g=new Set;return Ue&&(g.add("getState"),g.add("setState")),Ye&&H?.autoExecute!==!1&&(g.add("searchDocs"),g.add("fetchDocContent")),G?.config?.tools?G.config.tools.forEach(y=>{y.isEnabled&&!y.requiresApproval&&g.add(y.name)}):(i.forEach(y=>{for(const[w,j]of Pt.entries())if(j===y){g.add(w);break}}),a&&Array.isArray(a)&&a.forEach(y=>{typeof y=="string"&&g.add(y)})),G?.config?.workflows&&G.config.workflows.forEach(y=>{const w=`workflow_${y.name.replace(/\s+/g,"_").toLowerCase()}`;y.requiresApproval||g.add(w)}),g},[G,i,a,Pt,Ue,Ye,H]);h.useEffect(()=>{if(s||n)return;let g=!1,y=null;const w=async(j=1,C=3)=>{if(!g)try{const R=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!R.ok)throw new Error("Failed to fetch token");const I=await R.json();g||(Ot(I.clientToken),ae.current=I.clientToken,fn(I.expiresAt),ct(null))}catch(R){if(console.error(`[useAgent] Token fetch failed (attempt ${j}/${C}):`,R),j<C&&!g){const I=Math.pow(2,j-1)*1e3;y=setTimeout(()=>w(j+1,C),I)}else g||ct(R instanceof Error?R.message:"Failed to fetch token")}};return w(),()=>{g=!0,y&&clearTimeout(y),Be.current&&clearTimeout(Be.current)}},[t,JSON.stringify(r),s,n]),h.useEffect(()=>{if(!ut||s||n)return;Be.current&&clearTimeout(Be.current);const g=async(R=1,I=3)=>{try{const ee=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!ee.ok)throw new Error("Failed to refresh token");const Q=await ee.json();Ot(Q.clientToken),ae.current=Q.clientToken,fn(Q.expiresAt),ct(null)}catch(ee){if(console.error(`[useAgent] Token refresh failed (attempt ${R}/${I}):`,ee),R<I){const Q=Math.pow(2,R-1)*1e3;setTimeout(()=>g(R+1,I),Q)}else ct(ee instanceof Error?ee.message:"Failed to refresh token")}},y=Math.floor(Date.now()/1e3),w=ut-y,C=Math.max(0,w-5);return Be.current=setTimeout(()=>g(),C*1e3),()=>{Be.current&&clearTimeout(Be.current)}},[ut,t,JSON.stringify(r),s,n]),h.useEffect(()=>{if(s||n)return;const g=async()=>{if(document.visibilityState!=="visible")return;const y=Math.floor(Date.now()/1e3);if(!ut||ut<=y+5){console.log("[useAgent] Tab visible, token expired - refreshing");try{const j=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(j.ok){const C=await j.json();Ot(C.clientToken),ae.current=C.clientToken,fn(C.expiresAt),ct(null)}}catch(j){console.error("[useAgent] Token refresh on visibility change failed:",j)}}};return document.addEventListener("visibilitychange",g),()=>document.removeEventListener("visibilitychange",g)},[t,JSON.stringify(r),ut,s,n]);const ws=async(g,y={})=>{const w=y.headers?new Headers(y.headers):new Headers;return w.delete("user-agent"),w.delete("User-Agent"),fetch(g,{...y,headers:w})},bn=h.useRef(null),Yn=`${X}/chat`,{messages:Je,sendMessage:T,status:_,error:z,stop:Z,addToolResult:Y,setMessages:J}=jl.useChat({id:ke||void 0,messages:L,transport:new ei.DefaultChatTransport({api:Yn,fetch:ws,headers:()=>{const g={};return ae.current&&(g.Authorization=`Bearer ${ae.current}`),g},body:()=>({tools:ht.map(y=>({name:y.name,description:y.description,inputSchema:y.jsonSchema})),...b&&{agentId:b},...S&&{agentName:S},state:xe.current,...$&&{ragFilters:$}})}),sendAutomaticallyWhen:g=>{const y=g.messages;if(y[y.length-1]?.role!=="assistant")return!1;const C=[...y].reverse().find(I=>I.role==="user")?.id;if(C&&bn.current===C)return!1;const R=ei.lastAssistantMessageIsCompleteWithToolCalls(g);return R&&C&&(bn.current=C),R}}),De=T,re=h.useCallback(g=>(bn.current=null,De(g)),[De]),ue=h.useCallback((g,y,w)=>{const j=Ce(g,w);Y({toolCallId:y,tool:g,output:j})},[Y,Ce]);h.useEffect(()=>{Je.forEach(g=>{g.role==="assistant"&&g.parts.forEach(y=>{if(!y.type?.startsWith("tool-")||y.state!=="input-available")return;const w=y.type.replace("tool-",""),j=y.toolCallId;if(mn.current.has(j))return;mn.current.add(j);const C=Xl(y.input);if(Wn(w,C)){const R=qn(w,C),I=Object.entries(R).filter(([q])=>C[q]!==void 0),ee=I.length>0?Object.fromEntries(I):R,Q=Object.keys(C),be=_l(C,ee);(async()=>{try{const q=$l(w,Q,ee,C),ie={id:`${j}-form`,toolName:w,toolCallId:j,title:q.title,description:q.description,fields:q.fields},Qe=await Ut(ie);if(Qe===null){ue(w,j,"User cancelled secure input");return}const vn={...be,...Qe},Ss=Pt.get(w);if(!Ss)throw new Error(`Tool ${w} not found`);let Ts;const js=ht.find(Zr=>Zr.name===w);if(js&&js.jsonSchema?.properties){const pl=Object.keys(js.jsonSchema.properties).map(gl=>vn[gl]);Ts=await Ss(...pl)}else Ts=await Ss(...Object.values(vn));ue(w,j,Ts)}catch(q){console.error(`[useAgent] Error executing tool with secure input ${w}:`,q),ue(w,j,`Error: ${q}`)}})();return}if(w.startsWith("workflow_")&&zt.has(w)){(async()=>{try{const I=ht.find(Q=>Q.name===w)?._workflow;if(!I)throw new Error(`Workflow metadata not found for ${w}`);let ee;if(I.webhook?.url){let Q=C;if(I.webhook.bodyTemplate){let q=I.webhook.bodyTemplate;Object.entries(C).forEach(([ie,Qe])=>{q=q.replace(new RegExp(`\\{\\{${ie}\\}\\}`,"g"),String(Qe))}),Q=JSON.parse(q)}const be=await fetch(I.webhook.url,{method:I.webhook.method||"POST",headers:{"Content-Type":"application/json",...I.webhook.headers||{}},body:JSON.stringify(Q)});if(be.ok)ee={success:!0,data:await be.json().catch(()=>({success:!0}))};else{const q=await be.text();ee={success:!1,error:`Webhook failed: ${be.status} ${q}`}}}else ee={success:!0,message:`Workflow "${I.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:I.contentPlaintext};ue(w,j,ee)}catch(R){console.error(`[useAgent] Error executing workflow ${w}:`,R),ue(w,j,`Error: ${R}`)}})();return}if(zt.has(w)&&!Wn(w,C)){const R=Pt.get(w);R?(async()=>{try{const I=ht.find(Q=>Q.name===w);let ee;if(I&&I.jsonSchema?.properties){const be=Object.keys(I.jsonSchema.properties).map(q=>C[q]);ee=await R(...be)}else if(w==="getState")ee=R();else if(w==="setState"){const Q=C.updates||C;ee=await R(Q)}else ee=await R(...Object.values(C));ue(w,j,ee)}catch(I){console.error(`[useAgent] Error executing tool ${w}:`,I),ue(w,j,`Error: ${I}`)}})():console.warn(`[useAgent] Tool ${w} not found in toolsMap`)}else w.startsWith("workflow_")&&V?V({toolCall:{toolCallId:j,toolName:w,args:C}}):V&&V({toolCall:{toolCallId:j,toolName:w,args:C}})})})},[Je,zt,Pt,V,ue,ft,ht,Wn,qn,Ne]),h.useEffect(()=>{if(_==="ready"&&Je.length>0&&A){const g=Je[Je.length-1];g&&g.role==="assistant"&&A({message:g,messages:Je,isAbort:!1,isDisconnect:!1,isError:!!z})}},[_,Je,z,A]);async function W(){if(!(!r?.id||!Fe)){$t(!0);try{const y=await(await fetch(`${X}/conversations`,{headers:{Authorization:`Bearer ${Fe}`}})).json();jt(y.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{$t(!1)}}}h.useEffect(()=>{r?.id&&Fe&&W()},[JSON.stringify(r),Fe,X]),h.useEffect(()=>{if(!ke||!ae.current)return;(async()=>{Re(!0),Ke(null);try{const y=await fetch(`${X.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:ke},format:"json"})});if(!y.ok){const C=await y.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${y.status} ${C}`)}const j=(await y.json())?.value||{};xe.current=j,ce||dt(j),k&&k(j),Ct.current=!0}catch(y){console.error("Failed to fetch state:",y);const w=y instanceof Error?y:new Error(String(y));Ke(w),Ct.current||(xe.current={},ce?k&&k({}):(dt({}),k&&k({})),Ct.current=!0)}finally{Re(!1)}})()},[ke,X,ce,k]);async function me(g){hn(g),$t(!0);try{const y=await fetch(`${X}/conversations/${g}/messages`,{headers:{Authorization:`Bearer ${ae.current}`}});if(!y.ok)throw new Error(`Failed to fetch messages: ${y.statusText}`);const j=(await y.json()).messages||[];J(j)}catch(y){console.error("Failed to load conversation messages:",y)}finally{$t(!1)}}async function ne(g){if(Fe)try{await fetch(`${X}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${Fe}`}}),jt(Tt.filter(y=>y._id!==g)),g===ke&&Se()}catch(y){console.error("Failed to delete conversation:",y)}}function Se(){const g=crypto.randomUUID();hn(g),J([]),mn.current=new Set,xe.current={},ce?k&&k({}):(dt({}),k&&k({})),Ct.current=!1}function de(g){const y=g.tool||"unknown-tool",w=Ce(y,g.output);Y({toolCallId:g.toolCallId,tool:y,output:w})}async function Ze(g,y,w){if(!y.startsWith("workflow_"))throw new Error(`${y} is not a workflow tool`);try{const C=ht.find(I=>I.name===y)?._workflow;if(!C)throw new Error(`Workflow metadata not found for ${y}`);let R;if(C.webhook?.url){let I=w;if(C.webhook.bodyTemplate){let Q=C.webhook.bodyTemplate;Object.entries(w).forEach(([be,q])=>{Q=Q.replace(new RegExp(`\\{\\{${be}\\}\\}`,"g"),String(q))}),I=JSON.parse(Q)}const ee=await fetch(C.webhook.url,{method:C.webhook.method||"POST",headers:{"Content-Type":"application/json",...C.webhook.headers||{}},body:JSON.stringify(I)});if(ee.ok)R={success:!0,data:await ee.json().catch(()=>({success:!0}))};else{const Q=await ee.text();R={success:!1,error:`Webhook failed: ${ee.status} ${Q}`}}}else R={success:!0,message:`Workflow "${C.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:C.contentPlaintext};return de({toolCallId:g,tool:y,output:R}),R}catch(j){const C={success:!1,error:String(j)};throw de({toolCallId:g,tool:y,output:C}),j}}async function ve(g){const y={...xe.current,...g};xe.current=y,ce||dt(y),k&&k(y);try{await _n(g)}catch(w){throw w}}return{id:ke,messages:Je,status:_,error:z,sendMessage:re,stop:Z,addToolOutput:de,executeWorkflowTool:Ze,setMessages:J,conversations:Tt,loadConversation:me,deleteConversation:ne,startNewConversation:Se,isLoadingConversations:bs,clientToken:Fe,tokenError:dn,state:pn,setState:ve,isStateLoading:qe,stateError:gn,pendingSecureInputs:Array.from(Lt.values()),completeSecureInput:Xn,pendingSecureForms:Array.from(st.values()),completeSecureForm:rt,safeToolNames:zt}}function se(...e){return Pl.twMerge(Cl.clsx(e))}const Et=So.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),je=_e.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...r},o)=>{const i=s?wo.Slot:"button";return u.jsx(i,{ref:o,"data-slot":"button",className:se(Et({variant:t,size:n,className:e})),...r})});je.displayName="Button";const Zl=So.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 Cs({className:e,variant:t,asChild:n=!1,...s}){const r=n?wo.Slot:"span";return u.jsx(r,{"data-slot":"badge",className:se(Zl({variant:t}),e),...s})}const Ql=({textAreaRef:e,triggerAutoSize:t,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[r,o]=_e.useState(!0);_e.useEffect(()=>{const a=e.current;if(a){r&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[e.current,t])},Ao=_e.forwardRef(({maxHeight:e=Number.MAX_SAFE_INTEGER,minHeight:t=52,className:n,onChange:s,value:r,...o},i)=>{const a=_e.useRef(null),[l,c]=_e.useState("");return Ql({textAreaRef:a,triggerAutoSize:l,maxHeight:e,minHeight:t}),h.useImperativeHandle(i,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:e,minHeight:t})),_e.useEffect(()=>{c(r)},[o?.defaultValue,r]),u.jsx("textarea",{...o,value:r,ref:a,className:se("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:d=>{c(d.target.value),s?.(d)}})});Ao.displayName="AutosizeTextarea";function ec({delayDuration:e=0,...t}){return u.jsx(Ht.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function mt({...e}){return u.jsx(ec,{children:u.jsx(Ht.Root,{"data-slot":"tooltip",...e})})}function pt({...e}){return u.jsx(Ht.Trigger,{"data-slot":"tooltip-trigger",...e})}function gt({className:e,sideOffset:t=0,children:n,...s}){return u.jsx(Ht.Portal,{children:u.jsxs(Ht.Content,{"data-slot":"tooltip-content",sideOffset:t,className:se("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,u.jsx(Ht.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function ni({className:e,...t}){return u.jsx("kbd",{"data-slot":"kbd",className:se("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 pr=h.createContext({});function gr(e){const t=h.useRef(null);return t.current===null&&(t.current=e()),t.current}const yr=typeof window<"u",Eo=yr?h.useLayoutEffect:h.useEffect,ps=h.createContext(null);function xr(e,t){e.indexOf(t)===-1&&e.push(t)}function br(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const ot=(e,t,n)=>n>t?t:n<e?e:n;function Xs(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let Qt=()=>{},at=()=>{};process.env.NODE_ENV!=="production"&&(Qt=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Xs(t,n))},at=(e,t,n)=>{if(!e)throw new Error(Xs(t,n))});const lt={},Mo=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function ko(e){return typeof e=="object"&&e!==null}const No=e=>/^0[^.\s]+$/u.test(e);function vr(e){let t;return()=>(t===void 0&&(t=e()),t)}const Le=e=>e,tc=(e,t)=>n=>t(e(n)),On=(...e)=>e.reduce(tc),kn=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class wr{constructor(){this.subscriptions=[]}add(t){return xr(this.subscriptions,t),()=>br(this.subscriptions,t)}notify(t,n,s){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](t,n,s);else for(let o=0;o<r;o++){const i=this.subscriptions[o];i&&i(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Xe=e=>e*1e3,$e=e=>e/1e3;function Do(e,t){return t?e*(1e3/t):0}const si=new Set;function Sr(e,t,n){e||si.has(t)||(console.warn(Xs(t,n)),si.add(t))}const Ro=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,nc=1e-7,sc=12;function rc(e,t,n,s,r){let o,i,a=0;do i=t+(n-t)/2,o=Ro(i,s,r)-e,o>0?n=i:t=i;while(Math.abs(o)>nc&&++a<sc);return i}function $n(e,t,n,s){if(e===t&&n===s)return Le;const r=o=>rc(o,0,1,e,n);return o=>o===0||o===1?o:Ro(r(o),t,s)}const Vo=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Io=e=>t=>1-e(1-t),Oo=$n(.33,1.53,.69,.99),Tr=Io(Oo),$o=Vo(Tr),Lo=e=>(e*=2)<1?.5*Tr(e):.5*(2-Math.pow(2,-10*(e-1))),jr=e=>1-Math.sin(Math.acos(e)),Fo=Io(jr),Bo=Vo(jr),ic=$n(.42,0,1,1),oc=$n(0,0,.58,1),Uo=$n(.42,0,.58,1),ac=e=>Array.isArray(e)&&typeof e[0]!="number",zo=e=>Array.isArray(e)&&typeof e[0]=="number",ri={linear:Le,easeIn:ic,easeInOut:Uo,easeOut:oc,circIn:jr,circInOut:Bo,circOut:Fo,backIn:Tr,backInOut:$o,backOut:Oo,anticipate:Lo},lc=e=>typeof e=="string",ii=e=>{if(zo(e)){at(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,r]=e;return $n(t,n,s,r)}else if(lc(e))return at(ri[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),ri[e];return e},Jn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function cc(e,t){let n=new Set,s=new Set,r=!1,o=!1;const i=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(d){i.has(d)&&(c.schedule(d),e()),d(a)}const c={schedule:(d,f=!1,m=!1)=>{const x=m&&r?n:s;return f&&i.add(d),x.has(d)||x.add(d),d},cancel:d=>{s.delete(d),i.delete(d)},process:d=>{if(a=d,r){o=!0;return}r=!0,[n,s]=[s,n],n.forEach(l),n.clear(),r=!1,o&&(o=!1,c.process(d))}};return c}const uc=40;function _o(e,t){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,i=Jn.reduce((E,L)=>(E[L]=cc(o),E),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:d,update:f,preRender:m,render:p,postRender:x}=i,b=()=>{const E=lt.useManualTiming?r.timestamp:performance.now();n=!1,lt.useManualTiming||(r.delta=s?1e3/60:Math.max(Math.min(E-r.timestamp,uc),1)),r.timestamp=E,r.isProcessing=!0,a.process(r),l.process(r),c.process(r),d.process(r),f.process(r),m.process(r),p.process(r),x.process(r),r.isProcessing=!1,n&&t&&(s=!1,e(b))},S=()=>{n=!0,s=!0,r.isProcessing||e(b)};return{schedule:Jn.reduce((E,L)=>{const D=i[L];return E[L]=(O,k=!1,P=!1)=>(n||S(),D.schedule(O,k,P)),E},{}),cancel:E=>{for(let L=0;L<Jn.length;L++)i[Jn[L]].cancel(E)},state:r,steps:i}}const{schedule:le,cancel:xt,state:we,steps:Ps}=_o(typeof requestAnimationFrame<"u"?requestAnimationFrame:Le,!0);let rs;function dc(){rs=void 0}const Me={now:()=>(rs===void 0&&Me.set(we.isProcessing||lt.useManualTiming?we.timestamp:performance.now()),rs),set:e=>{rs=e,queueMicrotask(dc)}},Xo=e=>t=>typeof t=="string"&&t.startsWith(e),Cr=Xo("--"),fc=Xo("var(--"),Pr=e=>fc(e)?hc.test(e.split("/*")[0].trim()):!1,hc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,en={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Nn={...en,transform:e=>ot(0,1,e)},Zn={...en,default:1},Cn=e=>Math.round(e*1e5)/1e5,Ar=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function mc(e){return e==null}const pc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Er=(e,t)=>n=>!!(typeof n=="string"&&pc.test(n)&&n.startsWith(e)||t&&!mc(n)&&Object.prototype.hasOwnProperty.call(n,t)),Wo=(e,t,n)=>s=>{if(typeof s!="string")return s;const[r,o,i,a]=s.match(Ar);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(i),alpha:a!==void 0?parseFloat(a):1}},gc=e=>ot(0,255,e),As={...en,transform:e=>Math.round(gc(e))},kt={test:Er("rgb","red"),parse:Wo("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+As.transform(e)+", "+As.transform(t)+", "+As.transform(n)+", "+Cn(Nn.transform(s))+")"};function yc(e){let t="",n="",s="",r="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),r=e.substring(4,5),t+=t,n+=n,s+=s,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:r?parseInt(r,16)/255:1}}const Ws={test:Er("#"),parse:yc,transform:kt.transform},Ln=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),yt=Ln("deg"),et=Ln("%"),U=Ln("px"),xc=Ln("vh"),bc=Ln("vw"),oi={...et,parse:e=>et.parse(e)/100,transform:e=>et.transform(e*100)},_t={test:Er("hsl","hue"),parse:Wo("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+et.transform(Cn(t))+", "+et.transform(Cn(n))+", "+Cn(Nn.transform(s))+")"},ge={test:e=>kt.test(e)||Ws.test(e)||_t.test(e),parse:e=>kt.test(e)?kt.parse(e):_t.test(e)?_t.parse(e):Ws.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?kt.transform(e):_t.transform(e),getAnimatableNone:e=>{const t=ge.parse(e);return t.alpha=0,ge.transform(t)}},vc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function wc(e){return isNaN(e)&&typeof e=="string"&&(e.match(Ar)?.length||0)+(e.match(vc)?.length||0)>0}const qo="number",Ko="color",Sc="var",Tc="var(",ai="${}",jc=/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 Dn(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},r=[];let o=0;const a=t.replace(jc,l=>(ge.test(l)?(s.color.push(o),r.push(Ko),n.push(ge.parse(l))):l.startsWith(Tc)?(s.var.push(o),r.push(Sc),n.push(l)):(s.number.push(o),r.push(qo),n.push(parseFloat(l))),++o,ai)).split(ai);return{values:n,split:a,indexes:s,types:r}}function Go(e){return Dn(e).values}function Ho(e){const{split:t,types:n}=Dn(e),s=t.length;return r=>{let o="";for(let i=0;i<s;i++)if(o+=t[i],r[i]!==void 0){const a=n[i];a===qo?o+=Cn(r[i]):a===Ko?o+=ge.transform(r[i]):o+=r[i]}return o}}const Cc=e=>typeof e=="number"?0:ge.test(e)?ge.getAnimatableNone(e):e;function Pc(e){const t=Go(e);return Ho(e)(t.map(Cc))}const bt={test:wc,parse:Go,createTransformer:Ho,getAnimatableNone:Pc};function Es(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 Ac({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let r=0,o=0,i=0;if(!t)r=o=i=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;r=Es(l,a,e+1/3),o=Es(l,a,e),i=Es(l,a,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(i*255),alpha:s}}function cs(e,t){return n=>n>0?t:e}const he=(e,t,n)=>e+(t-e)*n,Ms=(e,t,n)=>{const s=e*e,r=n*(t*t-s)+s;return r<0?0:Math.sqrt(r)},Ec=[Ws,kt,_t],Mc=e=>Ec.find(t=>t.test(e));function li(e){const t=Mc(e);if(Qt(!!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===_t&&(n=Ac(n)),n}const ci=(e,t)=>{const n=li(e),s=li(t);if(!n||!s)return cs(e,t);const r={...n};return o=>(r.red=Ms(n.red,s.red,o),r.green=Ms(n.green,s.green,o),r.blue=Ms(n.blue,s.blue,o),r.alpha=he(n.alpha,s.alpha,o),kt.transform(r))},qs=new Set(["none","hidden"]);function kc(e,t){return qs.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Nc(e,t){return n=>he(e,t,n)}function Mr(e){return typeof e=="number"?Nc:typeof e=="string"?Pr(e)?cs:ge.test(e)?ci:Vc:Array.isArray(e)?Yo:typeof e=="object"?ge.test(e)?ci:Dc:cs}function Yo(e,t){const n=[...e],s=n.length,r=e.map((o,i)=>Mr(o)(o,t[i]));return o=>{for(let i=0;i<s;i++)n[i]=r[i](o);return n}}function Dc(e,t){const n={...e,...t},s={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(s[r]=Mr(e[r])(e[r],t[r]));return r=>{for(const o in s)n[o]=s[o](r);return n}}function Rc(e,t){const n=[],s={color:0,var:0,number:0};for(let r=0;r<t.values.length;r++){const o=t.types[r],i=e.indexes[o][s[o]],a=e.values[i]??0;n[r]=a,s[o]++}return n}const Vc=(e,t)=>{const n=bt.createTransformer(t),s=Dn(e),r=Dn(t);return s.indexes.var.length===r.indexes.var.length&&s.indexes.color.length===r.indexes.color.length&&s.indexes.number.length>=r.indexes.number.length?qs.has(e)&&!r.values.length||qs.has(t)&&!s.values.length?kc(e,t):On(Yo(Rc(s,r),r.values),n):(Qt(!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"),cs(e,t))};function Jo(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?he(e,t,n):Mr(e)(e,t)}const Ic=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>le.update(t,n),stop:()=>xt(t),now:()=>we.isProcessing?we.timestamp:Me.now()}},Zo=(e,t,n=10)=>{let s="";const r=Math.max(Math.round(t/n),2);for(let o=0;o<r;o++)s+=Math.round(e(o/(r-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},us=2e4;function kr(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<us;)t+=n,s=e.next(t);return t>=us?1/0:t}function Oc(e,t=100,n){const s=n({...e,keyframes:[0,t]}),r=Math.min(kr(s),us);return{type:"keyframes",ease:o=>s.next(r*o).value/t,duration:$e(r)}}const $c=5;function Qo(e,t,n){const s=Math.max(t-$c,0);return Do(n-e(s),t-s)}const fe={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},ks=.001;function Lc({duration:e=fe.duration,bounce:t=fe.bounce,velocity:n=fe.velocity,mass:s=fe.mass}){let r,o;Qt(e<=Xe(fe.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=ot(fe.minDamping,fe.maxDamping,i),e=ot(fe.minDuration,fe.maxDuration,$e(e)),i<1?(r=c=>{const d=c*i,f=d*e,m=d-n,p=Ks(c,i),x=Math.exp(-f);return ks-m/p*x},o=c=>{const f=c*i*e,m=f*n+n,p=Math.pow(i,2)*Math.pow(c,2)*e,x=Math.exp(-f),b=Ks(Math.pow(c,2),i);return(-r(c)+ks>0?-1:1)*((m-p)*x)/b}):(r=c=>{const d=Math.exp(-c*e),f=(c-n)*e+1;return-ks+d*f},o=c=>{const d=Math.exp(-c*e),f=(n-c)*(e*e);return d*f});const a=5/e,l=Bc(r,o,a);if(e=Xe(e),isNaN(l))return{stiffness:fe.stiffness,damping:fe.damping,duration:e};{const c=Math.pow(l,2)*s;return{stiffness:c,damping:i*2*Math.sqrt(s*c),duration:e}}}const Fc=12;function Bc(e,t,n){let s=n;for(let r=1;r<Fc;r++)s=s-e(s)/t(s);return s}function Ks(e,t){return e*Math.sqrt(1-t*t)}const Uc=["duration","bounce"],zc=["stiffness","damping","mass"];function ui(e,t){return t.some(n=>e[n]!==void 0)}function _c(e){let t={velocity:fe.velocity,stiffness:fe.stiffness,damping:fe.damping,mass:fe.mass,isResolvedFromDuration:!1,...e};if(!ui(e,zc)&&ui(e,Uc))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,o=2*ot(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:fe.mass,stiffness:r,damping:o}}else{const n=Lc(e);t={...t,...n,mass:fe.mass},t.isResolvedFromDuration=!0}return t}function ds(e=fe.visualDuration,t=fe.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:r}=n;const o=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:l,damping:c,mass:d,duration:f,velocity:m,isResolvedFromDuration:p}=_c({...n,velocity:-$e(n.velocity||0)}),x=m||0,b=c/(2*Math.sqrt(l*d)),S=i-o,v=$e(Math.sqrt(l/d)),M=Math.abs(S)<5;s||(s=M?fe.restSpeed.granular:fe.restSpeed.default),r||(r=M?fe.restDelta.granular:fe.restDelta.default);let E;if(b<1){const D=Ks(v,b);E=O=>{const k=Math.exp(-b*v*O);return i-k*((x+b*v*S)/D*Math.sin(D*O)+S*Math.cos(D*O))}}else if(b===1)E=D=>i-Math.exp(-v*D)*(S+(x+v*S)*D);else{const D=v*Math.sqrt(b*b-1);E=O=>{const k=Math.exp(-b*v*O),P=Math.min(D*O,300);return i-k*((x+b*v*S)*Math.sinh(P)+D*S*Math.cosh(P))/D}}const L={calculatedDuration:p&&f||null,next:D=>{const O=E(D);if(p)a.done=D>=f;else{let k=D===0?x:0;b<1&&(k=D===0?Xe(x):Qo(E,D,O));const P=Math.abs(k)<=s,V=Math.abs(i-O)<=r;a.done=P&&V}return a.value=a.done?i:O,a},toString:()=>{const D=Math.min(kr(L),us),O=Zo(k=>L.next(D*k).value,D,30);return D+"ms "+O},toTransition:()=>{}};return L}ds.applyToOptions=e=>{const t=Oc(e,100,ds);return e.ease=t.ease,e.duration=Xe(t.duration),e.type="keyframes",e};function Gs({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:r=10,bounceStiffness:o=500,modifyTarget:i,min:a,max:l,restDelta:c=.5,restSpeed:d}){const f=e[0],m={done:!1,value:f},p=P=>a!==void 0&&P<a||l!==void 0&&P>l,x=P=>a===void 0?l:l===void 0||Math.abs(a-P)<Math.abs(l-P)?a:l;let b=n*t;const S=f+b,v=i===void 0?S:i(S);v!==S&&(b=v-f);const M=P=>-b*Math.exp(-P/s),E=P=>v+M(P),L=P=>{const V=M(P),A=E(P);m.done=Math.abs(V)<=c,m.value=m.done?v:A};let D,O;const k=P=>{p(m.value)&&(D=P,O=ds({keyframes:[m.value,x(m.value)],velocity:Qo(E,P,m.value),damping:r,stiffness:o,restDelta:c,restSpeed:d}))};return k(0),{calculatedDuration:null,next:P=>{let V=!1;return!O&&D===void 0&&(V=!0,L(P),k(P)),D!==void 0&&P>=D?O.next(P-D):(!V&&L(P),m)}}}function Xc(e,t,n){const s=[],r=n||lt.mix||Jo,o=e.length-1;for(let i=0;i<o;i++){let a=r(e[i],e[i+1]);if(t){const l=Array.isArray(t)?t[i]||Le:t;a=On(l,a)}s.push(a)}return s}function Wc(e,t,{clamp:n=!0,ease:s,mixer:r}={}){const o=e.length;if(at(o===t.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const i=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=Xc(t,s,r),l=a.length,c=d=>{if(i&&d<e[0])return t[0];let f=0;if(l>1)for(;f<e.length-2&&!(d<e[f+1]);f++);const m=kn(e[f],e[f+1],d);return a[f](m)};return n?d=>c(ot(e[0],e[o-1],d)):c}function qc(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=kn(0,t,s);e.push(he(n,1,r))}}function Kc(e){const t=[0];return qc(t,e.length-1),t}function Gc(e,t){return e.map(n=>n*t)}function Hc(e,t){return e.map(()=>t||Uo).splice(0,e.length-1)}function Xt({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const r=ac(s)?s.map(ii):ii(s),o={done:!1,value:t[0]},i=Gc(n&&n.length===t.length?n:Kc(t),e),a=Wc(i,t,{ease:Array.isArray(r)?r:Hc(t,r)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Yc=e=>e!==null;function Nr(e,{repeat:t,repeatType:n="loop"},s,r=1){const o=e.filter(Yc),a=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Jc={decay:Gs,inertia:Gs,tween:Xt,keyframes:Xt,spring:ds};function ea(e){typeof e.type=="string"&&(e.type=Jc[e.type])}class Dr{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 Zc=e=>e/100;class Rr extends Dr{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!==Me.now()&&this.tick(Me.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;ea(t);const{type:n=Xt,repeat:s=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=t;let{keyframes:a}=t;const l=n||Xt;process.env.NODE_ENV!=="production"&&l!==Xt&&at(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Xt&&typeof a[0]!="number"&&(this.mixKeyframes=On(Zc,Jo(a[0],a[1])),a=[0,100]);const c=l({...t,keyframes:a});o==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-i})),c.calculatedDuration===null&&(c.calculatedDuration=kr(c));const{calculatedDuration:d}=c;this.calculatedDuration=d,this.resolvedDuration=d+r,this.totalDuration=this.resolvedDuration*(s+1)-r,this.generator=c}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:r,mixKeyframes:o,mirroredGenerator:i,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:c=0,keyframes:d,repeat:f,repeatType:m,repeatDelay:p,type:x,onUpdate:b,finalKeyframe:S}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-r/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const v=this.currentTime-c*(this.playbackSpeed>=0?1:-1),M=this.playbackSpeed>=0?v<0:v>r;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let E=this.currentTime,L=s;if(f){const P=Math.min(this.currentTime,r)/a;let V=Math.floor(P),A=P%1;!A&&P>=1&&(A=1),A===1&&V--,V=Math.min(V,f+1),!!(V%2)&&(m==="reverse"?(A=1-A,p&&(A-=p/a)):m==="mirror"&&(L=i)),E=ot(0,1,A)*a}const D=M?{done:!1,value:d[0]}:L.next(E);o&&(D.value=o(D.value));let{done:O}=D;!M&&l!==null&&(O=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const k=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return k&&x!==Gs&&(D.value=Nr(d,this.options,S,this.speed)),b&&b(D.value),k&&this.finish(),D}then(t,n){return this.finished.then(t,n)}get duration(){return $e(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+$e(t)}get time(){return $e(this.currentTime)}set time(t){t=Xe(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(Me.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=$e(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Ic,startTime:n}=this.options;this.driver||(this.driver=t(r=>this.tick(r))),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(Me.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 Qc(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Nt=e=>e*180/Math.PI,Hs=e=>{const t=Nt(Math.atan2(e[1],e[0]));return Ys(t)},eu={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Hs,rotateZ:Hs,skewX:e=>Nt(Math.atan(e[1])),skewY:e=>Nt(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Ys=e=>(e=e%360,e<0&&(e+=360),e),di=Hs,fi=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),hi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),tu={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:fi,scaleY:hi,scale:e=>(fi(e)+hi(e))/2,rotateX:e=>Ys(Nt(Math.atan2(e[6],e[5]))),rotateY:e=>Ys(Nt(Math.atan2(-e[2],e[0]))),rotateZ:di,rotate:di,skewX:e=>Nt(Math.atan(e[4])),skewY:e=>Nt(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Js(e){return e.includes("scale")?1:0}function Zs(e,t){if(!e||e==="none")return Js(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=tu,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=eu,r=a}if(!r)return Js(t);const o=s[t],i=r[1].split(",").map(su);return typeof o=="function"?o(i):i[o]}const nu=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Zs(n,t)};function su(e){return parseFloat(e.trim())}const tn=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],nn=new Set(tn),mi=e=>e===en||e===U,ru=new Set(["x","y","z"]),iu=tn.filter(e=>!ru.has(e));function ou(e){const t=[];return iu.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Dt={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})=>Zs(t,"x"),y:(e,{transform:t})=>Zs(t,"y")};Dt.translateX=Dt.x;Dt.translateY=Dt.y;const Rt=new Set;let Qs=!1,er=!1,tr=!1;function ta(){if(er){const e=Array.from(Rt).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const r=ou(s);r.length&&(n.set(s,r),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const r=n.get(s);r&&r.forEach(([o,i])=>{s.getValue(o)?.set(i)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}er=!1,Qs=!1,Rt.forEach(e=>e.complete(tr)),Rt.clear()}function na(){Rt.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(er=!0)})}function au(){tr=!0,na(),ta(),tr=!1}class Vr{constructor(t,n,s,r,o,i=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=r,this.element=o,this.isAsync=i}scheduleResolve(){this.state="scheduled",this.isAsync?(Rt.add(this),Qs||(Qs=!0,le.read(na),le.resolveKeyframes(ta))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:r}=this;if(t[0]===null){const o=r?.get(),i=t[t.length-1];if(o!==void 0)t[0]=o;else if(s&&n){const a=s.readValue(n,i);a!=null&&(t[0]=a)}t[0]===void 0&&(t[0]=i),r&&o===void 0&&r.set(t[0])}Qc(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Rt.delete(this)}cancel(){this.state==="scheduled"&&(Rt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const lu=e=>e.startsWith("--");function cu(e,t,n){lu(t)?e.style.setProperty(t,n):e.style[t]=n}const uu=vr(()=>window.ScrollTimeline!==void 0),du={};function fu(e,t){const n=vr(e);return()=>du[t]??n()}const sa=fu(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Tn=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,pi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Tn([0,.65,.55,1]),circOut:Tn([.55,0,1,.45]),backIn:Tn([.31,.01,.66,-.59]),backOut:Tn([.33,1.53,.69,.99])};function ra(e,t){if(e)return typeof e=="function"?sa()?Zo(e,t):"ease-out":zo(e)?Tn(e):Array.isArray(e)?e.map(n=>ra(n,t)||pi.easeOut):pi[e]}function hu(e,t,n,{delay:s=0,duration:r=300,repeat:o=0,repeatType:i="loop",ease:a="easeOut",times:l}={},c=void 0){const d={[t]:n};l&&(d.offset=l);const f=ra(a,r);Array.isArray(f)&&(d.easing=f);const m={delay:s,duration:r,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:o+1,direction:i==="reverse"?"alternate":"normal"};return c&&(m.pseudoElement=c),e.animate(d,m)}function ia(e){return typeof e=="function"&&"applyToOptions"in e}function mu({type:e,...t}){return ia(e)&&sa()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class pu extends Dr{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:s,keyframes:r,pseudoElement:o,allowFlatten:i=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!o,this.allowFlatten=i,this.options=t,at(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const c=mu(t);this.animation=hu(n,s,r,c,o),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Nr(r,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):cu(n,s,d),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 $e(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+$e(t)}get time(){return $e(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=Xe(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&&uu()?(this.animation.timeline=t,Le):n(this)}}const oa={anticipate:Lo,backInOut:$o,circInOut:Bo};function gu(e){return e in oa}function yu(e){typeof e.ease=="string"&&gu(e.ease)&&(e.ease=oa[e.ease])}const gi=10;class xu extends pu{constructor(t){yu(t),ea(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:s,onComplete:r,element:o,...i}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const a=new Rr({...i,autoplay:!1}),l=Xe(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-gi).value,a.sample(l).value,gi),a.stop()}}const yi=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(bt.test(e)||e==="0")&&!e.startsWith("url("));function bu(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 vu(e,t,n,s){const r=e[0];if(r===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],i=yi(r,t),a=yi(o,t);return Qt(i===a,`You are trying to animate ${t} from "${r}" to "${o}". "${i?o:r}" is not an animatable value.`,"value-not-animatable"),!i||!a?!1:bu(e)||(n==="spring"||ia(n))&&s}function nr(e){e.duration=0,e.type="keyframes"}const wu=new Set(["opacity","clipPath","filter","transform"]),Su=vr(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Tu(e){const{motionValue:t,name:n,repeatDelay:s,repeatType:r,damping:o,type:i}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:c}=t.owner.getProps();return Su()&&n&&wu.has(n)&&(n!=="transform"||!c)&&!l&&!s&&r!=="mirror"&&o!==0&&i!=="inertia"}const ju=40;class Cu extends Dr{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:i="loop",keyframes:a,name:l,motionValue:c,element:d,...f}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Me.now();const m={autoplay:t,delay:n,type:s,repeat:r,repeatDelay:o,repeatType:i,name:l,motionValue:c,element:d,...f},p=d?.KeyframeResolver||Vr;this.keyframeResolver=new p(a,(x,b,S)=>this.onKeyframesResolved(x,b,m,!S),l,c,d),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,s,r){this.keyframeResolver=void 0;const{name:o,type:i,velocity:a,delay:l,isHandoff:c,onUpdate:d}=s;this.resolvedAt=Me.now(),vu(t,o,i,a)||((lt.instantAnimations||!l)&&d?.(Nr(t,s,n)),t[0]=t[t.length-1],nr(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>ju?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!c&&Tu(m)?new xu({...m,element:m.motionValue.owner.current}):new Rr(m);p.finished.then(()=>this.notifyFinished()).catch(Le),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),au()),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 Pu=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Au(e){const t=Pu.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}const Eu=4;function aa(e,t,n=1){at(n<=Eu,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=Au(e);if(!s)return;const o=window.getComputedStyle(t).getPropertyValue(s);if(o){const i=o.trim();return Mo(i)?parseFloat(i):i}return Pr(r)?aa(r,t,n+1):r}function Ir(e,t){return e?.[t]??e?.default??e}const la=new Set(["width","height","top","left","right","bottom",...tn]),Mu={test:e=>e==="auto",parse:e=>e},ca=e=>t=>t.test(e),ua=[en,U,et,yt,bc,xc,Mu],xi=e=>ua.find(ca(e));function ku(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||No(e):!0}const Nu=new Set(["brightness","contrast","saturate","opacity"]);function Du(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(Ar)||[];if(!s)return e;const r=n.replace(s,"");let o=Nu.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+r+")"}const Ru=/\b([a-z-]*)\(.*?\)/gu,sr={...bt,getAnimatableNone:e=>{const t=e.match(Ru);return t?t.map(Du).join(" "):e}},bi={...en,transform:Math.round},Vu={rotate:yt,rotateX:yt,rotateY:yt,rotateZ:yt,scale:Zn,scaleX:Zn,scaleY:Zn,scaleZ:Zn,skew:yt,skewX:yt,skewY:yt,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:Nn,originX:oi,originY:oi,originZ:U},Or={borderWidth:U,borderTopWidth:U,borderRightWidth:U,borderBottomWidth:U,borderLeftWidth:U,borderRadius:U,radius:U,borderTopLeftRadius:U,borderTopRightRadius:U,borderBottomRightRadius:U,borderBottomLeftRadius:U,width:U,maxWidth:U,height:U,maxHeight:U,top:U,right:U,bottom:U,left:U,padding:U,paddingTop:U,paddingRight:U,paddingBottom:U,paddingLeft:U,margin:U,marginTop:U,marginRight:U,marginBottom:U,marginLeft:U,backgroundPositionX:U,backgroundPositionY:U,...Vu,zIndex:bi,fillOpacity:Nn,strokeOpacity:Nn,numOctaves:bi},Iu={...Or,color:ge,backgroundColor:ge,outlineColor:ge,fill:ge,stroke:ge,borderColor:ge,borderTopColor:ge,borderRightColor:ge,borderBottomColor:ge,borderLeftColor:ge,filter:sr,WebkitFilter:sr},da=e=>Iu[e];function fa(e,t){let n=da(e);return n!==sr&&(n=bt),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Ou=new Set(["auto","none","0"]);function $u(e,t,n){let s=0,r;for(;s<e.length&&!r;){const o=e[s];typeof o=="string"&&!Ou.has(o)&&Dn(o).values.length&&(r=e[s]),s++}if(r&&n)for(const o of t)e[o]=fa(n,r)}class Lu extends Vr{constructor(t,n,s,r,o){super(t,n,s,r,o,!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 c=t[l];if(typeof c=="string"&&(c=c.trim(),Pr(c))){const d=aa(c,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!la.has(s)||t.length!==2)return;const[r,o]=t,i=xi(r),a=xi(o);if(i!==a)if(mi(i)&&mi(a))for(let l=0;l<t.length;l++){const c=t[l];typeof c=="string"&&(t[l]=parseFloat(c))}else Dt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||ku(t[r]))&&s.push(r);s.length&&$u(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=Dt[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&t.getValue(s,r).jump(r,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const r=t.getValue(n);r&&r.jump(this.measuredOrigin,!1);const o=s.length-1,i=s[o];s[o]=Dt[n](t.measureViewportBox(),window.getComputedStyle(t.current)),i!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=i),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{t.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function Fu(e,t,n){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let s=document;const r=n?.[e]??s.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e)}const ha=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function ma(e){return ko(e)&&"offsetHeight"in e}const vi=30,Bu=e=>!isNaN(parseFloat(e));class Uu{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const r=Me.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Me.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Bu(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Sr(!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 wr);const s=this.events[t].add(n);return t==="change"?()=>{s(),le.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=Me.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>vi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,vi);return Do(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 Jt(e,t){return new Uu(e,t)}const{schedule:$r}=_o(queueMicrotask,!1),ze={x:!1,y:!1};function pa(){return ze.x||ze.y}function zu(e){return e==="x"||e==="y"?ze[e]?null:(ze[e]=!0,()=>{ze[e]=!1}):ze.x||ze.y?null:(ze.x=ze.y=!0,()=>{ze.x=ze.y=!1})}function ga(e,t){const n=Fu(e),s=new AbortController,r={passive:!0,...t,signal:s.signal};return[n,r,()=>s.abort()]}function wi(e){return!(e.pointerType==="touch"||pa())}function _u(e,t,n={}){const[s,r,o]=ga(e,n),i=a=>{if(!wi(a))return;const{target:l}=a,c=t(l,a);if(typeof c!="function"||!l)return;const d=f=>{wi(f)&&(c(f),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return s.forEach(a=>{a.addEventListener("pointerenter",i,r)}),o}const ya=(e,t)=>t?e===t?!0:ya(e,t.parentElement):!1,Lr=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Xu=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Wu(e){return Xu.has(e.tagName)||e.tabIndex!==-1}const is=new WeakSet;function Si(e){return t=>{t.key==="Enter"&&e(t)}}function Ns(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const qu=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Si(()=>{if(is.has(n))return;Ns(n,"down");const r=Si(()=>{Ns(n,"up")}),o=()=>Ns(n,"cancel");n.addEventListener("keyup",r,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function Ti(e){return Lr(e)&&!pa()}function Ku(e,t,n={}){const[s,r,o]=ga(e,n),i=a=>{const l=a.currentTarget;if(!Ti(a))return;is.add(l);const c=t(l,a),d=(p,x)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",m),is.has(l)&&is.delete(l),Ti(p)&&typeof c=="function"&&c(p,{success:x})},f=p=>{d(p,l===window||l===document||n.useGlobalTarget||ya(l,p.target))},m=p=>{d(p,!1)};window.addEventListener("pointerup",f,r),window.addEventListener("pointercancel",m,r)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",i,r),ma(a)&&(a.addEventListener("focus",c=>qu(c,r)),!Wu(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function xa(e){return ko(e)&&"ownerSVGElement"in e}function Gu(e){return xa(e)&&e.tagName==="svg"}const Te=e=>!!(e&&e.getVelocity),Hu=[...ua,ge,bt],Yu=e=>Hu.find(ca(e)),Fr=h.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function ji(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ju(...e){return t=>{let n=!1;const s=e.map(r=>{const o=ji(r,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let r=0;r<s.length;r++){const o=s[r];typeof o=="function"?o():ji(e[r],null)}}}}function Zu(...e){return _e.useCallback(Ju(...e),e)}class Qu extends _e.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,r=ma(s)&&s.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=r-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function ed({children:e,isPresent:t,anchorX:n,root:s}){const r=h.useId(),o=h.useRef(null),i=h.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=h.useContext(Fr),l=Zu(o,e?.ref);return h.useInsertionEffect(()=>{const{width:c,height:d,top:f,left:m,right:p}=i.current;if(t||!o.current||!c||!d)return;const x=n==="left"?`left: ${m}`:`right: ${p}`;o.current.dataset.motionPopId=r;const b=document.createElement("style");a&&(b.nonce=a);const S=s??document.head;return S.appendChild(b),b.sheet&&b.sheet.insertRule(`
|
|
3
3
|
[data-motion-pop-id="${r}"] {
|
|
4
4
|
position: absolute !important;
|
|
5
5
|
width: ${c}px !important;
|
package/dist/index.mjs
CHANGED
|
@@ -584,10 +584,8 @@ function Cc({
|
|
|
584
584
|
})
|
|
585
585
|
});
|
|
586
586
|
if (!V.ok) {
|
|
587
|
-
if (V.status === 404)
|
|
588
|
-
console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");
|
|
587
|
+
if (V.status === 404)
|
|
589
588
|
return;
|
|
590
|
-
}
|
|
591
589
|
const O = await V.text().catch(() => "Unknown error");
|
|
592
590
|
throw new Error(`Failed to sync conversation state: ${V.status} ${O}`);
|
|
593
591
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAgent.d.ts","sourceRoot":"","sources":["../../src/lib/useAgent.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAKf,MAAM,oBAAoB,CAAC;AA8X5B,wBAAgB,QAAQ,CAAC,EACvB,UAAU,EAAE,aAAwC,EACpD,aAAmC,EACnC,WAAW,EAAE,aAAa,EAC1B,cAAsB,EACtB,IAAI,EACJ,KAAU,EACV,SAAc,EACd,aAAa,EAAE,iBAAiB,EAChC,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,mBAA2B,EAC3B,kBAA0B,EAC1B,QAAiB,EAEjB,YAAiB,EACjB,OAAO,EACP,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAoB,EACpB,cAAc,EAAE,qBAAqB,EACrC,KAAK,EAAE,eAAe,EACtB,aAAa,EACb,eAAsB,EACtB,UAAU,EACV,QAAQ,EACR,OAAO,EACP,SAAS,EACT,UAAU,EAAE,+CAA+C;AAC3D,kBAAkB,GACnB,GAAE,eAAoB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"useAgent.d.ts","sourceRoot":"","sources":["../../src/lib/useAgent.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAKf,MAAM,oBAAoB,CAAC;AA8X5B,wBAAgB,QAAQ,CAAC,EACvB,UAAU,EAAE,aAAwC,EACpD,aAAmC,EACnC,WAAW,EAAE,aAAa,EAC1B,cAAsB,EACtB,IAAI,EACJ,KAAU,EACV,SAAc,EACd,aAAa,EAAE,iBAAiB,EAChC,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,mBAA2B,EAC3B,kBAA0B,EAC1B,QAAiB,EAEjB,YAAiB,EACjB,OAAO,EACP,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAoB,EACpB,cAAc,EAAE,qBAAqB,EACrC,KAAK,EAAE,eAAe,EACtB,aAAa,EACb,eAAsB,EACtB,UAAU,EACV,QAAQ,EACR,OAAO,EACP,SAAS,EACT,UAAU,EAAE,+CAA+C;AAC3D,kBAAkB,GACnB,GAAE,eAAoB,GAAG,cAAc,CA6vDvC"}
|
|
@@ -31,6 +31,8 @@ interface BuildTimeFunctionMetadata {
|
|
|
31
31
|
interface BuildTimeMetadata {
|
|
32
32
|
functions: Record<string, BuildTimeFunctionMetadata>;
|
|
33
33
|
toolOrder?: string[];
|
|
34
|
+
generated?: string;
|
|
35
|
+
discoveredFrom?: string[];
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* Extract tool metadata from functions using build-time generated metadata
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-tool-metadata.d.ts","sourceRoot":"","sources":["../../src/utils/extract-tool-metadata.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,oBAAoB,eAA6C,CAAC;AAE/E;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC,CAGnF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,GAAG,CAAC;CACjB;AAGD,UAAU,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,GAAG,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAGD,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IACrD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"extract-tool-metadata.d.ts","sourceRoot":"","sources":["../../src/utils/extract-tool-metadata.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,oBAAoB,eAA6C,CAAC;AAE/E;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC,CAGnF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,GAAG,CAAC;CACjB;AAGD,UAAU,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,GAAG,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAGD,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IACrD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AA+DD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,QAAQ,EAAE,EACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,GAAG,iBAAiB,GAAG,IAAI,GACnF,YAAY,EAAE,CA8DhB"}
|