@arcteninc/core 0.0.138 → 0.0.139
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 +8 -8
- package/dist/index.mjs +3123 -3126
- package/dist/lib/useAgent.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var hl=Object.create;var Gr=Object.defineProperty;var fl=Object.getOwnPropertyDescriptor;var ml=Object.getOwnPropertyNames;var pl=Object.getPrototypeOf,gl=Object.prototype.hasOwnProperty;var yl=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ml(t))!gl.call(e,r)&&r!==n&&Gr(e,r,{get:()=>t[r],enumerable:!(s=fl(t,r))||s.enumerable});return e};var xl=(e,t,n)=>(n=e!=null?hl(pl(e)):{},yl(t||!e||!e.__esModule?Gr(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),f=require("react"),Z=require("lucide-react"),bl=require("@ai-sdk/react"),Yr=require("ai"),go=require("@radix-ui/react-slot"),yo=require("class-variance-authority"),vl=require("clsx"),wl=require("tailwind-merge"),Sl=require("@radix-ui/react-tooltip"),Hr=require("@radix-ui/react-use-controllable-state"),Tl=require("@radix-ui/react-collapsible"),Cl=require("react-dom"),jl=require("@radix-ui/react-dialog"),Pl=require("./server.cjs");function as(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=as(f),Ut=as(Sl),ar=as(Tl),Mt=as(jl),Re=Symbol.for("@arcteninc/core:originalName");function Al(e,t){return e[Re]=t,e}function Ml(e,t,n,s){if(typeof e!="function")return null;const r=e[Re];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[Re]=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[Re]=i.name,{fn:e,meta:i}}else if(i=Object.values(t).find(l=>!n.has(l.name)),i)return e[Re]=i.name,{fn:e,meta:i};return null}function lr(e,t){if(e.length===0&&!t)return[];let n,s;if(!t)throw new Error(`❌ toolMetadata is required when providing local tools!
|
|
2
2
|
|
|
3
3
|
Please:
|
|
4
4
|
1. Run "arcten-extract-types ." before build (add to package.json scripts)
|
|
@@ -7,18 +7,18 @@ Please:
|
|
|
7
7
|
3. Pass it to useAgent/ArctenAgent:
|
|
8
8
|
useAgent({ tools: [...], toolMetadata: toolMetadata })
|
|
9
9
|
(Pass the full object for better minification support, or toolMetadata.functions for backward compatibility)
|
|
10
|
-
`);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=
|
|
11
|
-
To fix: Run "arcten-extract-types ." and ensure "${u}" 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 Pl={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 fn(e){for(const[t,n]of Object.entries(Pl))if(t!=="text"){for(const s of n)if(s.test(e))return t}return null}function Al(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 Ml(e,t,n){return t.length>0}function El(e,t,n,s={}){const r=[];return Object.keys(s).forEach(i=>{const a=i in n,l=n[i];if(!a){const h=s[i];if(h!=null&&h!=="")return}const u=kl(s[i]),d={name:i,type:Nl(l||fn(i)||"text"),label:po(i),placeholder:Dl(i,l),required:!0,value:u};d.type==="password"&&(d.validation=h=>h.length<8?"Password must be at least 8 characters":null),r.push(d)}),r.sort((i,a)=>{const l=i.name in n,u=a.name in n;return l===u?0:l?1:-1}),{shouldUseForm:Ml(e,t),fields:r,title:Rl(e),description:Vl(e,r.length)}}function kl(e){if(e!=null){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}}function Nl(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 po(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Dl(e,t){return t?Al(t,e).placeholder:`Enter ${po(e).toLowerCase()}...`}function Rl(e){return e.replace(/([A-Z])/g," $1").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Vl(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 pn(e){if(typeof e=="string")try{const t=JSON.parse(e);return pn(t)}catch{return e}if(Array.isArray(e))return e.map(pn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=pn(s);return t}return e}function Il(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 Ol(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return pn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?pn(e):{}}const Wn="__secureOutput",Kn="[hidden for privacy]";function Ll(e,t){if(!e||e.length===0)return t;const n=new Map;t.forEach(o=>{const i=o[ke]||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[ke]||o.name;i&&!s.has(i)&&(console.log(`[useAgent] Allowing client-only tool (forward compatible): ${i}`),r.push(o))}),r}function Fl(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 $l(e){return e.replace(/\[(\w+)\]/g,".$1").split(".").map(t=>t.trim()).filter(Boolean)}function Bl(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 zl(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 Vs(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 go(e,t=""){const n={};return e&&typeof e=="object"?Object.entries(e).forEach(([s,r])=>{const o=t?`${t}.${s}`:s;n[o]=Vs(r),r&&typeof r=="object"&&Object.assign(n,go(r,o))}):t&&(n[t]=Vs(e)),n}function Ul(e){if(e===void 0||e===!1)return;if(e===!0)return{strategy:"full",fields:[],placeholder:Kn,includeFieldStatus:!1,preserve:[]};if(Array.isArray(e))return{strategy:"fields",fields:e,placeholder:Kn,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??Kn,includeFieldStatus:e.includeFieldStatus??!1,preserve:e.preserve??[]}}function _l(e){if(!e)return{};const t={};for(const[n,s]of Object.entries(e)){const r=Ul(s);r&&(t[n]=r)}return t}function yo(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=go(t)),r.redactedFields=["*"];let l={};return n.preserve.length>0&&t&&typeof t=="object"&&n.preserve.forEach(u=>{u in t&&(l[u]=t[u])}),l[Wn]=r,l}if(n.fields.includes("*"))return yo(e,t,{...n,strategy:"full",fields:[]});if(typeof t!="object"||t===null)return{value:s,[Wn]:{...r,redactedFields:n.fields}};const o=Fl(t),i=[],a={};return n.fields.forEach(l=>{const u=$l(l);if(u.length===0)return;const d=Bl(o,u),h=Vs(d);a[l]=h,zl(o,u,s)&&i.push(l)}),r.redactedFields=i,n.includeFieldStatus&&(r.fieldStatus=a),o[Wn]=r,o}function xo({apiBaseUrl:e="https://api.arcten.com",tokenEndpoint:t="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:r,tools:o=[],safeTools:i=[],toolMetadata:a,sensitiveParams:l,sensitiveOutputs:u,autoDetectSensitive:d=!1,autoFormGeneration:h=!1,formMode:m="auto",systemPrompt:p="",agentId:S,agentName:w,projectId:T,enableRemoteConfig:x,remoteConfigUrl:P,initialMessages:E=[],conversationId:L,state:N,onStateChange:k,allowStateEdits:I=!0,onToolCall:A,onFinish:O,sources:j,ragConfig:R,ragFilters:F,secureInputHandler:D}={}){const[$,J]=f.useState(null),[ne,G]=f.useState(!1),[se,fe]=f.useState(null),ge=f.useMemo(()=>{const g=j||[],y=$?.config?.sources||[];return[...new Set([...g,...y])]},[j,$]),B=f.useMemo(()=>R!==void 0?R:F?{enabled:!0,filters:F}:ge&&ge.length>0?{enabled:!0,organizationId:ge[0],autoExecute:!0,filters:void 0}:{enabled:!1},[ge,R,F]),Ct=f.useMemo(()=>x===!1?!1:!!T,[T,x]);f.useEffect(()=>{if(!Ct||!te.current)return;(async()=>{G(!0),fe(null);try{const b=`${P||e.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,v=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${te.current}`},body:JSON.stringify({path:"agents:getConfigForClient",args:{projectId:T,agentName:w,agentId:S},format:"json"})});if(!v.ok){if(v.status===404){console.warn("[useAgent] Remote config endpoint not found (404), using local tools only"),J(null);return}const V=await v.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch remote config: ${v.status} ${V}`)}const M=await v.json();J(M?.value||null),console.log("[useAgent] Remote config loaded successfully:",M?.value)}catch(y){console.error("[useAgent] Failed to fetch remote config:",y);const b=y instanceof Error?y:new Error(String(y));fe(b),J(null)}finally{G(!1)}})()},[Ct,T,w,S,e,P]);const Te=f.useMemo(()=>{const g={};if(l)for(const[y,b]of Object.entries(l))if(g[y]={},Array.isArray(b))for(const v of b){const M=fn(v);g[y][v]=M||"text"}else for(const[v,M]of Object.entries(b))g[y][v]=M;if(a){for(const[y,b]of Object.entries(a))if(b&&typeof b=="object"&&"sensitiveParams"in b){g[y]||(g[y]={});const v=b.sensitiveParams;if(Array.isArray(v))for(const M of v){const V=fn(M);g[y][M]=V||"text"}else if(v&&typeof v=="object")for(const[M,V]of Object.entries(v))g[y][M]=V}}return g},[l,a,d]),at=f.useMemo(()=>_l(u),[u]),we=f.useCallback((g,y)=>{const b=at[g];if(!b)return y;try{return yo(g,y,b)}catch(v){return console.error(`[useAgent] Failed to redact output for ${g}:`,v),{value:Kn,[Wn]:{tool:g,redacted:!0,error:String(v)}}}},[at]),[Re,Qt]=f.useState(n||null),te=f.useRef(n||null),[en,lt]=f.useState(null),[tn,Nn]=f.useState(null),Ve=f.useRef(null),[ct,ut]=f.useState([]),[je,nn]=f.useState(L||(typeof window<"u"?crypto.randomUUID():null)),[ls,jt]=f.useState(!1),[Dn,dt]=f.useState(new Set),[Je,cs]=f.useState(new Map),[Rn,ze]=f.useState(new Map),[us,Vn]=f.useState(new Map),[Pt,sn]=f.useState(new Map),re=N!==void 0,[rn,Ie]=f.useState({}),ye=f.useRef({}),Ue=re?N||{}:rn;re&&N?ye.current=N:re||(ye.current=rn);const[Oe,At]=f.useState(!1),[ht,ft]=f.useState(null),on=f.useRef(!1),Pe=f.useCallback(async(g,y=3)=>{if(!je||!te.current)return;const b=async()=>{const M=`${e.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,V=await fetch(M,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${te.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:je,updates:g},format:"json"})});if(!V.ok){if(V.status===404){console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const z=await V.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${V.status} ${z}`)}};for(let v=0;v<y;v++)try{await b(),ft(null);return}catch(M){if(v===y-1){const z=M instanceof Error?M:new Error(String(M));throw ft(z),console.error("Failed to sync state to Convex after retries:",M),z}await new Promise(z=>setTimeout(z,Math.pow(2,v)*100))}},[je,e,te]),mt=f.useMemo(()=>function(){return ye.current},[]),he=f.useMemo(()=>async function(y){const b={...ye.current,...y};ye.current=b,re||Ie(b),k&&k(b);try{await Pe(y)}catch(v){throw v}},[Pe,k,re]);f.useEffect(()=>{re&&N&&(ye.current=N)},[re,N]);const In=f.useCallback(g=>D?D.showSecureModal(g):new Promise(y=>{cs(b=>new Map(b).set(g.id,g)),ze(b=>new Map(b).set(g.id,y))}),[D]),Mt=f.useCallback((g,y)=>{if(D)return;const b=Rn.get(g);b&&(b(y),cs(v=>{const M=new Map(v);return M.delete(g),M}),ze(v=>{const M=new Map(v);return M.delete(g),M}))},[Rn,D]),Ke=f.useCallback(g=>D?D.showSecureForm(g):new Promise(y=>{Vn(b=>new Map(b).set(g.id,g)),sn(b=>new Map(b).set(g.id,y))}),[D]),_r=f.useCallback((g,y)=>{if(D)return;const b=Pt.get(g);b&&(b(y),Vn(v=>{const M=new Map(v);return M.delete(g),M}),sn(v=>{const M=new Map(v);return M.delete(g),M}))},[Pt,D]),an=f.useCallback((g,y)=>{const b=Te[g]||{},v=Object.keys(b).length>0;if(d){const M=Object.keys(y).filter(V=>fn(V)!==null);return v||M.length>0}return v},[Te,d]),ln=f.useCallback((g,y)=>{const v={...Te[g]||{}};if(d){for(const V of Object.keys(y))if(!(V in v)){const z=fn(V);z&&(v[V]=z)}}const M=Object.entries(v).filter(([V])=>Object.prototype.hasOwnProperty.call(y,V));return M.length>0?Object.fromEntries(M):v},[Te,d]),_e=f.useMemo(()=>B?.enabled?async function(y,b=20,v){const M={...B.filters,...v};if(j&&j.length>1){const z=j.map(H=>fetch(`${e}/search`,{method:"POST",headers:{"Content-Type":"application/json",...te.current?{Authorization:`Bearer ${te.current}`}:{}},body:JSON.stringify({q:y,k:Math.min(b,100),organizationId:H,...Object.keys(M).length>0?{filters:M}:{}})}).then(oe=>oe.ok?oe.json():null)),ie=await Promise.all(z),me=[];for(const H of ie)H?.candidates&&me.push(...H.candidates);me.sort((H,oe)=>{const Qe=H.scores?.rerank||H.scores?.dense||0;return(oe.scores?.rerank||oe.scores?.dense||0)-Qe});const Le=me.slice(0,b).map((H,oe)=>{const Qe=H.citation||H.url;return{rank:oe+1,doc_id:H.doc_id,block_id:H.block_id,url:H.url,citation:Qe,title:H.title||"Untitled",snippet:H.snippet,score:H.scores?.rerank||H.scores?.dense||0,metadata:{site:H.metadata?.site,lang:H.metadata?.lang,contentType:H.metadata?.content_type}}});return{success:!0,query:y,total:me.length,results:Le,summary:`Found ${me.length} relevant results across ${j.length} source(s) for "${y}". Top result: ${Le[0]?.title||"N/A"}`}}const V=B.organizationId&&B.organizationId!=="default"?B.organizationId:j&&j.length>0?j[0]:void 0;try{const z={q:y,k:Math.min(b,100)};V&&(z.organizationId=V),Object.keys(M).length>0&&(z.filters=M);const ie={"Content-Type":"application/json"};te.current&&(ie.Authorization=`Bearer ${te.current}`);const me=await fetch(`${e}/search`,{method:"POST",headers:ie,body:JSON.stringify(z)});if(!me.ok){const oe=await me.text();return{success:!1,error:`Search failed: ${me.status} ${oe}`}}const Le=await me.json(),H=Le.candidates.map((oe,Qe)=>{const dn=oe.citation||oe.url;return{rank:Qe+1,doc_id:oe.doc_id,block_id:oe.block_id,url:oe.url,citation:dn,title:oe.title||"Untitled",snippet:oe.snippet,score:oe.scores?.rerank||oe.scores?.dense||0,metadata:{site:oe.metadata?.site,lang:oe.metadata?.lang,contentType:oe.metadata?.content_type}}});return{success:!0,query:Le.query,total:Le.total,results:H,summary:`Found ${Le.total} relevant results for "${y}". Top result: ${H[0]?.title||"N/A"}`}}catch(z){return{success:!1,error:z instanceof Error?z.message:"Unknown error occurred"}}}:null,[B,e,te]),Ze=f.useMemo(()=>B?.enabled?async function(y,b){const v=B.organizationId&&B.organizationId!=="default"?B.organizationId:j&&j.length>0?j[0]:void 0;try{const M={"Content-Type":"application/json"};te.current&&(M.Authorization=`Bearer ${te.current}`);const V=await fetch(`${e}/fetch`,{method:"POST",headers:M,body:JSON.stringify({doc_id:y,block_ids:b,...v?{organizationId:v}:{}})});if(!V.ok){const ie=await V.text();return{success:!1,error:`Fetch failed: ${V.status} ${ie}`}}const z=await V.json();return{success:!0,blocks:z.blocks||[],fullContent:z.fullContent||"",pageUrl:z.pageUrl||"",pageTitle:z.pageTitle||"",summary:`Fetched ${z.blocks?.length||0} blocks from ${z.pageTitle||y}`}}catch(M){return{success:!1,error:M instanceof Error?M.message:"Unknown error occurred"}}}:null,[B,e,te]),On=f.useMemo(()=>{if($&&$.config?.tools){const g=Ll($.config.tools,o);return console.log("[useAgent] Merged remote config:",{remoteToolCount:$.config.tools.length,localToolCount:o.length,mergedToolCount:g.length}),g}return o},[$,o]),Et=f.useMemo(()=>{const g=[...On,...i,mt];return(!re||I)&&g.push(he),B?.enabled&&(_e&&g.push(_e),Ze&&g.push(Ze)),g},[On,i,mt,he,_e,Ze,B,re,I]),qe=f.useMemo(()=>ir(Et,a),[Et,a]),pt=f.useMemo(()=>{const g=new Map,y=new Map(qe.map(b=>[b.name,b]));return g.set("getState",mt),(!re||I)&&g.set("setState",he),B?.enabled&&(_e&&g.set("searchDocs",_e),Ze&&g.set("fetchDocContent",Ze)),Et.forEach(b=>{if(b===mt||b===he||b===_e||b===Ze)return;const v=b[ke];if(v){const V=y.get(v);if(V){g.set(V.name,b);return}}const M=qe.find(V=>V.name===b.name);M&&g.set(M.name,b)}),g},[Et,qe,mt,he,_e,Ze,B,re,I]),Ln=f.useMemo(()=>new Set(qe.map(g=>g.name)),[qe]),Fn=f.useMemo(()=>{const g=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}];(!re||I)&&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=[];return B?.enabled&&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"]}}),[...qe,...g,...y]},[qe,B,re,I]),kt=f.useMemo(()=>Fn.filter(g=>g.name==="getState"?!0:g.name==="setState"?!re||I:B?.enabled&&(g.name==="searchDocs"||g.name==="fetchDocContent")?!0:Ln.has(g.name)),[Fn,Ln,re,I,B]),cn=f.useMemo(()=>{const g=new Set;return g.add("getState"),g.add("setState"),B?.enabled&&B.autoExecute!==!1&&(g.add("searchDocs"),g.add("fetchDocContent")),i.forEach(y=>{for(const[b,v]of pt.entries())if(v===y){g.add(b);break}}),g},[i,pt,B]);f.useEffect(()=>s||n?void 0:((async()=>{try{const y=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!y.ok)throw new Error("Failed to fetch token");const b=await y.json();Qt(b.clientToken),te.current=b.clientToken,Nn(b.expiresAt),lt(null)}catch(y){console.error("[useAgent] Token fetch failed:",y),lt(y instanceof Error?y.message:"Failed to fetch token")}})(),()=>{Ve.current&&clearTimeout(Ve.current)}),[t,JSON.stringify(r),s,n]),f.useEffect(()=>{if(!tn||s||n)return;Ve.current&&clearTimeout(Ve.current);const g=Math.floor(Date.now()/1e3),y=tn-g,v=Math.max(0,y-5);return Ve.current=setTimeout(async()=>{try{const M=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!M.ok)throw new Error("Failed to refresh token");const V=await M.json();Qt(V.clientToken),te.current=V.clientToken,Nn(V.expiresAt),lt(null)}catch(M){console.error("[useAgent] Token refresh failed:",M),lt(M instanceof Error?M.message:"Failed to refresh token")}},v*1e3),()=>{Ve.current&&clearTimeout(Ve.current)}},[tn,t,JSON.stringify(r),s,n]);const ds=async(g,y={})=>{const b=y.headers?new Headers(y.headers):new Headers;b.delete("user-agent"),b.delete("User-Agent"),console.log("[useAgent] Making request to:",g),console.log("[useAgent] Method:",y.method||"GET"),console.log("[useAgent] Has Authorization header:",b.has("Authorization")),console.log("[useAgent] Client token available:",!!te.current);try{const v=await fetch(g,{...y,headers:b});if(!v.ok){console.error("[useAgent] Request failed:",v.status,v.statusText);const M=await v.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",M)}return v}catch(v){throw console.error("[useAgent] Fetch error:",v),v}},$n=`${e}/chat`;console.log("[useAgent] Chat API URL:",$n);const{messages:Xe,sendMessage:hs,status:Nt,error:un,stop:C,addToolResult:_,setMessages:W}=gl.useChat({id:je||void 0,messages:E,transport:new Kr.DefaultChatTransport({api:$n,fetch:ds,headers:()=>{const g={};return te.current?(g.Authorization=`Bearer ${te.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),g},body:()=>{console.log("[ArctenAgent] body() agentName =",w);const g=kt.map(v=>({name:v.name,description:v.description,inputSchema:v.jsonSchema})),y=g.filter(v=>v.name==="getState"||v.name==="setState").map(v=>v.name),b=g.filter(v=>v.name==="searchDocs"||v.name==="fetchDocContent").map(v=>v.name);return y.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",y),b.length>0?console.log("[useAgent] RAG tools included in tools list sent to AI SDK:",b):B?.enabled&&console.warn("[useAgent] RAG is enabled but no RAG tools found in tools list!"),{tools:g,...S&&{agentId:S},...w&&{agentName:w},state:ye.current,...F&&{ragFilters:F}}}}),sendAutomaticallyWhen:Kr.lastAssistantMessageIsCompleteWithToolCalls}),K=f.useCallback((g,y,b)=>{const v=we(g,b);_({toolCallId:y,tool:g,output:v})},[_,we]);f.useEffect(()=>{Xe.forEach(g=>{g.role==="assistant"&&g.parts.forEach(y=>{if(!y.type?.startsWith("tool-")||y.state!=="input-available")return;const b=y.type.replace("tool-",""),v=y.toolCallId;if(Dn.has(v))return;dt(V=>new Set(V).add(v));const M=Ol(y.input);if(an(b,M)){const V=ln(b,M),z=Object.entries(V).filter(([H])=>M[H]!==void 0),ie=z.length>0?Object.fromEntries(z):V,me=Object.keys(M),Le=Il(M,ie);(async()=>{try{const H=El(b,me,ie,M),oe={id:`${v}-form`,toolName:b,toolCallId:v,title:H.title,description:H.description,fields:H.fields},Qe=await Ke(oe);if(Qe===null){K(b,v,"User cancelled secure input");return}const dn={...Le,...Qe},fs=pt.get(b);if(!fs)throw new Error(`Tool ${b} not found`);let ms;const ps=kt.find(Xr=>Xr.name===b);if(ps&&ps.jsonSchema?.properties){const al=Object.keys(ps.jsonSchema.properties).map(ll=>dn[ll]);ms=await fs(...al)}else ms=await fs(...Object.values(dn));K(b,v,ms)}catch(H){console.error(`[useAgent] Error executing tool with secure input ${b}:`,H),K(b,v,`Error: ${H}`)}})();return}if(cn.has(b)&&!an(b,M)){const V=pt.get(b);V?(async()=>{try{const z=kt.find(me=>me.name===b);let ie;if(z&&z.jsonSchema?.properties){const Le=Object.keys(z.jsonSchema.properties).map(H=>M[H]);ie=await V(...Le)}else if(b==="getState")ie=V();else if(b==="setState"){const me=M.updates||M;ie=await V(me)}else ie=await V(...Object.values(M));K(b,v,ie)}catch(z){console.error(`[useAgent] Error executing tool ${b}:`,z),K(b,v,`Error: ${z}`)}})():console.warn(`[useAgent] Tool ${b} not found in toolsMap`)}else A&&A({toolCall:{toolCallId:v,toolName:b,args:M}})})})},[Xe,cn,pt,A,K,Dn,he,kt,an,ln,In]),f.useEffect(()=>{if(Nt==="ready"&&Xe.length>0&&O){const g=Xe[Xe.length-1];g&&g.role==="assistant"&&O({message:g,messages:Xe,isAbort:!1,isDisconnect:!1,isError:!!un})}},[Nt,Xe,un,O]);async function q(){if(!(!r?.id||!Re)){jt(!0);try{const y=await(await fetch(`${e}/conversations`,{headers:{Authorization:`Bearer ${Re}`}})).json();ut(y.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{jt(!1)}}}f.useEffect(()=>{r?.id&&Re&&q()},[JSON.stringify(r),Re,e]),f.useEffect(()=>{if(!je||!te.current)return;(async()=>{At(!0),ft(null);try{const y=await fetch(`${e.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${te.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:je},format:"json"})});if(!y.ok){const M=await y.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${y.status} ${M}`)}const v=(await y.json())?.value||{};ye.current=v,re||Ie(v),k&&k(v),on.current=!0}catch(y){console.error("Failed to fetch state:",y);const b=y instanceof Error?y:new Error(String(y));ft(b),on.current||(ye.current={},re?k&&k({}):(Ie({}),k&&k({})),on.current=!0)}finally{At(!1)}})()},[je,e,re,k]);async function Y(g){nn(g),jt(!0);try{const y=await fetch(`${e}/conversations/${g}/messages`,{headers:{Authorization:`Bearer ${te.current}`}});if(!y.ok)throw new Error(`Failed to fetch messages: ${y.statusText}`);const v=(await y.json()).messages||[];W(v)}catch(y){console.error("Failed to load conversation messages:",y)}finally{jt(!1)}}async function Ae(g){if(Re)try{await fetch(`${e}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${Re}`}}),ut(ct.filter(y=>y._id!==g)),g===je&&ee()}catch(y){console.error("Failed to delete conversation:",y)}}function ee(){const g=crypto.randomUUID();nn(g),W([]),dt(new Set),ye.current={},re?k&&k({}):(Ie({}),k&&k({})),on.current=!1}function xe(g){const y=g.tool||"unknown-tool",b=we(y,g.output);_({toolCallId:g.toolCallId,tool:y,output:b})}async function X(g){const y={...ye.current,...g};ye.current=y,re||Ie(y),k&&k(y);try{await Pe(g)}catch(b){throw b}}return{id:je,messages:Xe,status:Nt,error:un,sendMessage:hs,stop:C,addToolOutput:xe,setMessages:W,conversations:ct,loadConversation:Y,deleteConversation:Ae,startNewConversation:ee,isLoadingConversations:ls,clientToken:Re,tokenError:en,state:Ue,setState:X,isStateLoading:Oe,stateError:ht,pendingSecureInputs:Array.from(Je.values()),completeSecureInput:Mt,pendingSecureForms:Array.from(us.values()),completeSecureForm:_r}}function Q(...e){return xl.twMerge(yl.clsx(e))}const yt=mo.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive 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"}}),ve=$e.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...r},o)=>{const i=s?fo.Slot:"button";return c.jsx(i,{ref:o,"data-slot":"button",className:Q(yt({variant:t,size:n,className:e})),...r})});ve.displayName="Button";const Xl=mo.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function gs({className:e,variant:t,asChild:n=!1,...s}){const r=n?fo.Slot:"span";return c.jsx(r,{"data-slot":"badge",className:Q(Xl({variant:t}),e),...s})}const Wl=({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])},bo=$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,u]=$e.useState("");return Wl({textAreaRef:a,triggerAutoSize:l,maxHeight:e,minHeight:t}),f.useImperativeHandle(i,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:e,minHeight:t})),$e.useEffect(()=>{u(r)},[o?.defaultValue,r]),c.jsx("textarea",{...o,value:r,ref:a,className:Q("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:d=>{u(d.target.value),s?.(d)}})});bo.displayName="AutosizeTextarea";function Kl({delayDuration:e=0,...t}){return c.jsx(Ft.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function et({...e}){return c.jsx(Kl,{children:c.jsx(Ft.Root,{"data-slot":"tooltip",...e})})}function tt({...e}){return c.jsx(Ft.Trigger,{"data-slot":"tooltip-trigger",...e})}function nt({className:e,sideOffset:t=0,children:n,...s}){return c.jsx(Ft.Portal,{children:c.jsxs(Ft.Content,{"data-slot":"tooltip-content",sideOffset:t,className:Q("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...s,children:[n,c.jsx(Ft.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Gr({className:e,...t}){return c.jsx("kbd",{"data-slot":"kbd",className:Q("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e),...t})}const or=f.createContext({});function ar(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const lr=typeof window<"u",vo=lr?f.useLayoutEffect:f.useEffect,rs=f.createContext(null);function cr(e,t){e.indexOf(t)===-1&&e.push(t)}function ur(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const Ge=(e,t,n)=>n>t?t:n<e?e:n;function Is(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let Ut=()=>{},Ye=()=>{};process.env.NODE_ENV!=="production"&&(Ut=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Is(t,n))},Ye=(e,t,n)=>{if(!e)throw new Error(Is(t,n))});const He={},wo=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function So(e){return typeof e=="object"&&e!==null}const To=e=>/^0[^.\s]+$/u.test(e);function dr(e){let t;return()=>(t===void 0&&(t=e()),t)}const De=e=>e,ql=(e,t)=>n=>t(e(n)),An=(...e)=>e.reduce(ql),wn=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class hr{constructor(){this.subscriptions=[]}add(t){return cr(this.subscriptions,t),()=>ur(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 Be=e=>e*1e3,Ne=e=>e/1e3;function Co(e,t){return t?e*(1e3/t):0}const Yr=new Set;function fr(e,t,n){e||Yr.has(t)||(console.warn(Is(t,n)),Yr.add(t))}const jo=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Gl=1e-7,Yl=12;function Hl(e,t,n,s,r){let o,i,a=0;do i=t+(n-t)/2,o=jo(i,s,r)-e,o>0?n=i:t=i;while(Math.abs(o)>Gl&&++a<Yl);return i}function Mn(e,t,n,s){if(e===t&&n===s)return De;const r=o=>Hl(o,0,1,e,n);return o=>o===0||o===1?o:jo(r(o),t,s)}const Po=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Ao=e=>t=>1-e(1-t),Mo=Mn(.33,1.53,.69,.99),mr=Ao(Mo),Eo=Po(mr),ko=e=>(e*=2)<1?.5*mr(e):.5*(2-Math.pow(2,-10*(e-1))),pr=e=>1-Math.sin(Math.acos(e)),No=Ao(pr),Do=Po(pr),Jl=Mn(.42,0,1,1),Zl=Mn(0,0,.58,1),Ro=Mn(.42,0,.58,1),Ql=e=>Array.isArray(e)&&typeof e[0]!="number",Vo=e=>Array.isArray(e)&&typeof e[0]=="number",Hr={linear:De,easeIn:Jl,easeInOut:Ro,easeOut:Zl,circIn:pr,circInOut:Do,circOut:No,backIn:mr,backInOut:Eo,backOut:Mo,anticipate:ko},ec=e=>typeof e=="string",Jr=e=>{if(Vo(e)){Ye(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,r]=e;return Mn(t,n,s,r)}else if(ec(e))return Ye(Hr[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),Hr[e];return e},Bn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function tc(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)&&(u.schedule(d),e()),d(a)}const u={schedule:(d,h=!1,m=!1)=>{const S=m&&r?n:s;return h&&i.add(d),S.has(d)||S.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,u.process(d))}};return u}const nc=40;function Io(e,t){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,i=Bn.reduce((E,L)=>(E[L]=tc(o),E),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:d,update:h,preRender:m,render:p,postRender:S}=i,w=()=>{const E=He.useManualTiming?r.timestamp:performance.now();n=!1,He.useManualTiming||(r.delta=s?1e3/60:Math.max(Math.min(E-r.timestamp,nc),1)),r.timestamp=E,r.isProcessing=!0,a.process(r),l.process(r),u.process(r),d.process(r),h.process(r),m.process(r),p.process(r),S.process(r),r.isProcessing=!1,n&&t&&(s=!1,e(w))},T=()=>{n=!0,s=!0,r.isProcessing||e(w)};return{schedule:Bn.reduce((E,L)=>{const N=i[L];return E[L]=(k,I=!1,A=!1)=>(n||T(),N.schedule(k,I,A)),E},{}),cancel:E=>{for(let L=0;L<Bn.length;L++)i[Bn[L]].cancel(E)},state:r,steps:i}}const{schedule:ae,cancel:rt,state:pe,steps:ys}=Io(typeof requestAnimationFrame<"u"?requestAnimationFrame:De,!0);let qn;function sc(){qn=void 0}const Ce={now:()=>(qn===void 0&&Ce.set(pe.isProcessing||He.useManualTiming?pe.timestamp:performance.now()),qn),set:e=>{qn=e,queueMicrotask(sc)}},Oo=e=>t=>typeof t=="string"&&t.startsWith(e),gr=Oo("--"),rc=Oo("var(--"),yr=e=>rc(e)?ic.test(e.split("/*")[0].trim()):!1,ic=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,_t={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Sn={..._t,transform:e=>Ge(0,1,e)},zn={..._t,default:1},gn=e=>Math.round(e*1e5)/1e5,xr=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function oc(e){return e==null}const ac=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,br=(e,t)=>n=>!!(typeof n=="string"&&ac.test(n)&&n.startsWith(e)||t&&!oc(n)&&Object.prototype.hasOwnProperty.call(n,t)),Lo=(e,t,n)=>s=>{if(typeof s!="string")return s;const[r,o,i,a]=s.match(xr);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(i),alpha:a!==void 0?parseFloat(a):1}},lc=e=>Ge(0,255,e),xs={..._t,transform:e=>Math.round(lc(e))},bt={test:br("rgb","red"),parse:Lo("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+xs.transform(e)+", "+xs.transform(t)+", "+xs.transform(n)+", "+gn(Sn.transform(s))+")"};function cc(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 Os={test:br("#"),parse:cc,transform:bt.transform},En=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),st=En("deg"),We=En("%"),U=En("px"),uc=En("vh"),dc=En("vw"),Zr={...We,parse:e=>We.parse(e)/100,transform:e=>We.transform(e*100)},Dt={test:br("hsl","hue"),parse:Lo("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+We.transform(gn(t))+", "+We.transform(gn(n))+", "+gn(Sn.transform(s))+")"},de={test:e=>bt.test(e)||Os.test(e)||Dt.test(e),parse:e=>bt.test(e)?bt.parse(e):Dt.test(e)?Dt.parse(e):Os.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?bt.transform(e):Dt.transform(e),getAnimatableNone:e=>{const t=de.parse(e);return t.alpha=0,de.transform(t)}},hc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function fc(e){return isNaN(e)&&typeof e=="string"&&(e.match(xr)?.length||0)+(e.match(hc)?.length||0)>0}const Fo="number",$o="color",mc="var",pc="var(",Qr="${}",gc=/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 Tn(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},r=[];let o=0;const a=t.replace(gc,l=>(de.test(l)?(s.color.push(o),r.push($o),n.push(de.parse(l))):l.startsWith(pc)?(s.var.push(o),r.push(mc),n.push(l)):(s.number.push(o),r.push(Fo),n.push(parseFloat(l))),++o,Qr)).split(Qr);return{values:n,split:a,indexes:s,types:r}}function Bo(e){return Tn(e).values}function zo(e){const{split:t,types:n}=Tn(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===Fo?o+=gn(r[i]):a===$o?o+=de.transform(r[i]):o+=r[i]}return o}}const yc=e=>typeof e=="number"?0:de.test(e)?de.getAnimatableNone(e):e;function xc(e){const t=Bo(e);return zo(e)(t.map(yc))}const it={test:fc,parse:Bo,createTransformer:zo,getAnimatableNone:xc};function bs(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 bc({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=bs(l,a,e+1/3),o=bs(l,a,e),i=bs(l,a,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(i*255),alpha:s}}function Zn(e,t){return n=>n>0?t:e}const ce=(e,t,n)=>e+(t-e)*n,vs=(e,t,n)=>{const s=e*e,r=n*(t*t-s)+s;return r<0?0:Math.sqrt(r)},vc=[Os,bt,Dt],wc=e=>vc.find(t=>t.test(e));function ei(e){const t=wc(e);if(Ut(!!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===Dt&&(n=bc(n)),n}const ti=(e,t)=>{const n=ei(e),s=ei(t);if(!n||!s)return Zn(e,t);const r={...n};return o=>(r.red=vs(n.red,s.red,o),r.green=vs(n.green,s.green,o),r.blue=vs(n.blue,s.blue,o),r.alpha=ce(n.alpha,s.alpha,o),bt.transform(r))},Ls=new Set(["none","hidden"]);function Sc(e,t){return Ls.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Tc(e,t){return n=>ce(e,t,n)}function vr(e){return typeof e=="number"?Tc:typeof e=="string"?yr(e)?Zn:de.test(e)?ti:Pc:Array.isArray(e)?Uo:typeof e=="object"?de.test(e)?ti:Cc:Zn}function Uo(e,t){const n=[...e],s=n.length,r=e.map((o,i)=>vr(o)(o,t[i]));return o=>{for(let i=0;i<s;i++)n[i]=r[i](o);return n}}function Cc(e,t){const n={...e,...t},s={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(s[r]=vr(e[r])(e[r],t[r]));return r=>{for(const o in s)n[o]=s[o](r);return n}}function jc(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 Pc=(e,t)=>{const n=it.createTransformer(t),s=Tn(e),r=Tn(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?Ls.has(e)&&!r.values.length||Ls.has(t)&&!s.values.length?Sc(e,t):An(Uo(jc(s,r),r.values),n):(Ut(!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"),Zn(e,t))};function _o(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?ce(e,t,n):vr(e)(e,t)}const Ac=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ae.update(t,n),stop:()=>rt(t),now:()=>pe.isProcessing?pe.timestamp:Ce.now()}},Xo=(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)})`},Qn=2e4;function wr(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<Qn;)t+=n,s=e.next(t);return t>=Qn?1/0:t}function Mc(e,t=100,n){const s=n({...e,keyframes:[0,t]}),r=Math.min(wr(s),Qn);return{type:"keyframes",ease:o=>s.next(r*o).value/t,duration:Ne(r)}}const Ec=5;function Wo(e,t,n){const s=Math.max(t-Ec,0);return Co(n-e(s),t-s)}const le={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},ws=.001;function kc({duration:e=le.duration,bounce:t=le.bounce,velocity:n=le.velocity,mass:s=le.mass}){let r,o;Ut(e<=Be(le.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=Ge(le.minDamping,le.maxDamping,i),e=Ge(le.minDuration,le.maxDuration,Ne(e)),i<1?(r=u=>{const d=u*i,h=d*e,m=d-n,p=Fs(u,i),S=Math.exp(-h);return ws-m/p*S},o=u=>{const h=u*i*e,m=h*n+n,p=Math.pow(i,2)*Math.pow(u,2)*e,S=Math.exp(-h),w=Fs(Math.pow(u,2),i);return(-r(u)+ws>0?-1:1)*((m-p)*S)/w}):(r=u=>{const d=Math.exp(-u*e),h=(u-n)*e+1;return-ws+d*h},o=u=>{const d=Math.exp(-u*e),h=(n-u)*(e*e);return d*h});const a=5/e,l=Dc(r,o,a);if(e=Be(e),isNaN(l))return{stiffness:le.stiffness,damping:le.damping,duration:e};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:i*2*Math.sqrt(s*u),duration:e}}}const Nc=12;function Dc(e,t,n){let s=n;for(let r=1;r<Nc;r++)s=s-e(s)/t(s);return s}function Fs(e,t){return e*Math.sqrt(1-t*t)}const Rc=["duration","bounce"],Vc=["stiffness","damping","mass"];function ni(e,t){return t.some(n=>e[n]!==void 0)}function Ic(e){let t={velocity:le.velocity,stiffness:le.stiffness,damping:le.damping,mass:le.mass,isResolvedFromDuration:!1,...e};if(!ni(e,Vc)&&ni(e,Rc))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,o=2*Ge(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:le.mass,stiffness:r,damping:o}}else{const n=kc(e);t={...t,...n,mass:le.mass},t.isResolvedFromDuration=!0}return t}function es(e=le.visualDuration,t=le.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:u,mass:d,duration:h,velocity:m,isResolvedFromDuration:p}=Ic({...n,velocity:-Ne(n.velocity||0)}),S=m||0,w=u/(2*Math.sqrt(l*d)),T=i-o,x=Ne(Math.sqrt(l/d)),P=Math.abs(T)<5;s||(s=P?le.restSpeed.granular:le.restSpeed.default),r||(r=P?le.restDelta.granular:le.restDelta.default);let E;if(w<1){const N=Fs(x,w);E=k=>{const I=Math.exp(-w*x*k);return i-I*((S+w*x*T)/N*Math.sin(N*k)+T*Math.cos(N*k))}}else if(w===1)E=N=>i-Math.exp(-x*N)*(T+(S+x*T)*N);else{const N=x*Math.sqrt(w*w-1);E=k=>{const I=Math.exp(-w*x*k),A=Math.min(N*k,300);return i-I*((S+w*x*T)*Math.sinh(A)+N*T*Math.cosh(A))/N}}const L={calculatedDuration:p&&h||null,next:N=>{const k=E(N);if(p)a.done=N>=h;else{let I=N===0?S:0;w<1&&(I=N===0?Be(S):Wo(E,N,k));const A=Math.abs(I)<=s,O=Math.abs(i-k)<=r;a.done=A&&O}return a.value=a.done?i:k,a},toString:()=>{const N=Math.min(wr(L),Qn),k=Xo(I=>L.next(N*I).value,N,30);return N+"ms "+k},toTransition:()=>{}};return L}es.applyToOptions=e=>{const t=Mc(e,100,es);return e.ease=t.ease,e.duration=Be(t.duration),e.type="keyframes",e};function $s({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:r=10,bounceStiffness:o=500,modifyTarget:i,min:a,max:l,restDelta:u=.5,restSpeed:d}){const h=e[0],m={done:!1,value:h},p=A=>a!==void 0&&A<a||l!==void 0&&A>l,S=A=>a===void 0?l:l===void 0||Math.abs(a-A)<Math.abs(l-A)?a:l;let w=n*t;const T=h+w,x=i===void 0?T:i(T);x!==T&&(w=x-h);const P=A=>-w*Math.exp(-A/s),E=A=>x+P(A),L=A=>{const O=P(A),j=E(A);m.done=Math.abs(O)<=u,m.value=m.done?x:j};let N,k;const I=A=>{p(m.value)&&(N=A,k=es({keyframes:[m.value,S(m.value)],velocity:Wo(E,A,m.value),damping:r,stiffness:o,restDelta:u,restSpeed:d}))};return I(0),{calculatedDuration:null,next:A=>{let O=!1;return!k&&N===void 0&&(O=!0,L(A),I(A)),N!==void 0&&A>=N?k.next(A-N):(!O&&L(A),m)}}}function Oc(e,t,n){const s=[],r=n||He.mix||_o,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]||De:t;a=An(l,a)}s.push(a)}return s}function Lc(e,t,{clamp:n=!0,ease:s,mixer:r}={}){const o=e.length;if(Ye(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=Oc(t,s,r),l=a.length,u=d=>{if(i&&d<e[0])return t[0];let h=0;if(l>1)for(;h<e.length-2&&!(d<e[h+1]);h++);const m=wn(e[h],e[h+1],d);return a[h](m)};return n?d=>u(Ge(e[0],e[o-1],d)):u}function Fc(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=wn(0,t,s);e.push(ce(n,1,r))}}function $c(e){const t=[0];return Fc(t,e.length-1),t}function Bc(e,t){return e.map(n=>n*t)}function zc(e,t){return e.map(()=>t||Ro).splice(0,e.length-1)}function Rt({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const r=Ql(s)?s.map(Jr):Jr(s),o={done:!1,value:t[0]},i=Bc(n&&n.length===t.length?n:$c(t),e),a=Lc(i,t,{ease:Array.isArray(r)?r:zc(t,r)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Uc=e=>e!==null;function Sr(e,{repeat:t,repeatType:n="loop"},s,r=1){const o=e.filter(Uc),a=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const _c={decay:$s,inertia:$s,tween:Rt,keyframes:Rt,spring:es};function Ko(e){typeof e.type=="string"&&(e.type=_c[e.type])}class Tr{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 Xc=e=>e/100;class Cr extends Tr{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!==Ce.now()&&this.tick(Ce.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;Ko(t);const{type:n=Rt,repeat:s=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=t;let{keyframes:a}=t;const l=n||Rt;process.env.NODE_ENV!=="production"&&l!==Rt&&Ye(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Rt&&typeof a[0]!="number"&&(this.mixKeyframes=An(Xc,_o(a[0],a[1])),a=[0,100]);const u=l({...t,keyframes:a});o==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-i})),u.calculatedDuration===null&&(u.calculatedDuration=wr(u));const{calculatedDuration:d}=u;this.calculatedDuration=d,this.resolvedDuration=d+r,this.totalDuration=this.resolvedDuration*(s+1)-r,this.generator=u}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:s,totalDuration:r,mixKeyframes:o,mirroredGenerator:i,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:d,repeat:h,repeatType:m,repeatDelay:p,type:S,onUpdate:w,finalKeyframe:T}=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 x=this.currentTime-u*(this.playbackSpeed>=0?1:-1),P=this.playbackSpeed>=0?x<0:x>r;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let E=this.currentTime,L=s;if(h){const A=Math.min(this.currentTime,r)/a;let O=Math.floor(A),j=A%1;!j&&A>=1&&(j=1),j===1&&O--,O=Math.min(O,h+1),!!(O%2)&&(m==="reverse"?(j=1-j,p&&(j-=p/a)):m==="mirror"&&(L=i)),E=Ge(0,1,j)*a}const N=P?{done:!1,value:d[0]}:L.next(E);o&&(N.value=o(N.value));let{done:k}=N;!P&&l!==null&&(k=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const I=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&k);return I&&S!==$s&&(N.value=Sr(d,this.options,T,this.speed)),w&&w(N.value),I&&this.finish(),N}then(t,n){return this.finished.then(t,n)}get duration(){return Ne(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ne(t)}get time(){return Ne(this.currentTime)}set time(t){t=Be(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(Ce.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Ne(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Ac,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(Ce.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 Wc(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const vt=e=>e*180/Math.PI,Bs=e=>{const t=vt(Math.atan2(e[1],e[0]));return zs(t)},Kc={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Bs,rotateZ:Bs,skewX:e=>vt(Math.atan(e[1])),skewY:e=>vt(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},zs=e=>(e=e%360,e<0&&(e+=360),e),si=Bs,ri=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),ii=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),qc={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ri,scaleY:ii,scale:e=>(ri(e)+ii(e))/2,rotateX:e=>zs(vt(Math.atan2(e[6],e[5]))),rotateY:e=>zs(vt(Math.atan2(-e[2],e[0]))),rotateZ:si,rotate:si,skewX:e=>vt(Math.atan(e[4])),skewY:e=>vt(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Us(e){return e.includes("scale")?1:0}function _s(e,t){if(!e||e==="none")return Us(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=qc,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Kc,r=a}if(!r)return Us(t);const o=s[t],i=r[1].split(",").map(Yc);return typeof o=="function"?o(i):i[o]}const Gc=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return _s(n,t)};function Yc(e){return parseFloat(e.trim())}const Xt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Wt=new Set(Xt),oi=e=>e===_t||e===U,Hc=new Set(["x","y","z"]),Jc=Xt.filter(e=>!Hc.has(e));function Zc(e){const t=[];return Jc.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const wt={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})=>_s(t,"x"),y:(e,{transform:t})=>_s(t,"y")};wt.translateX=wt.x;wt.translateY=wt.y;const St=new Set;let Xs=!1,Ws=!1,Ks=!1;function qo(){if(Ws){const e=Array.from(St).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const r=Zc(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)})}Ws=!1,Xs=!1,St.forEach(e=>e.complete(Ks)),St.clear()}function Go(){St.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Ws=!0)})}function Qc(){Ks=!0,Go(),qo(),Ks=!1}class jr{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?(St.add(this),Xs||(Xs=!0,ae.read(Go),ae.resolveKeyframes(qo))):(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])}Wc(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),St.delete(this)}cancel(){this.state==="scheduled"&&(St.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const eu=e=>e.startsWith("--");function tu(e,t,n){eu(t)?e.style.setProperty(t,n):e.style[t]=n}const nu=dr(()=>window.ScrollTimeline!==void 0),su={};function ru(e,t){const n=dr(e);return()=>su[t]??n()}const Yo=ru(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),mn=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,ai={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:mn([0,.65,.55,1]),circOut:mn([.55,0,1,.45]),backIn:mn([.31,.01,.66,-.59]),backOut:mn([.33,1.53,.69,.99])};function Ho(e,t){if(e)return typeof e=="function"?Yo()?Xo(e,t):"ease-out":Vo(e)?mn(e):Array.isArray(e)?e.map(n=>Ho(n,t)||ai.easeOut):ai[e]}function iu(e,t,n,{delay:s=0,duration:r=300,repeat:o=0,repeatType:i="loop",ease:a="easeOut",times:l}={},u=void 0){const d={[t]:n};l&&(d.offset=l);const h=Ho(a,r);Array.isArray(h)&&(d.easing=h);const m={delay:s,duration:r,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:o+1,direction:i==="reverse"?"alternate":"normal"};return u&&(m.pseudoElement=u),e.animate(d,m)}function Jo(e){return typeof e=="function"&&"applyToOptions"in e}function ou({type:e,...t}){return Jo(e)&&Yo()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class au extends Tr{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,Ye(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=ou(t);this.animation=iu(n,s,r,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Sr(r,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):tu(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 Ne(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ne(t)}get time(){return Ne(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=Be(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&&nu()?(this.animation.timeline=t,De):n(this)}}const Zo={anticipate:ko,backInOut:Eo,circInOut:Do};function lu(e){return e in Zo}function cu(e){typeof e.ease=="string"&&lu(e.ease)&&(e.ease=Zo[e.ease])}const li=10;class uu extends au{constructor(t){cu(t),Ko(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 Cr({...i,autoplay:!1}),l=Be(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-li).value,a.sample(l).value,li),a.stop()}}const ci=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(it.test(e)||e==="0")&&!e.startsWith("url("));function du(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 hu(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=ci(r,t),a=ci(o,t);return Ut(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:du(e)||(n==="spring"||Jo(n))&&s}function qs(e){e.duration=0,e.type="keyframes"}const fu=new Set(["opacity","clipPath","filter","transform"]),mu=dr(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function pu(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:u}=t.owner.getProps();return mu()&&n&&fu.has(n)&&(n!=="transform"||!u)&&!l&&!s&&r!=="mirror"&&o!==0&&i!=="inertia"}const gu=40;class yu extends Tr{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:i="loop",keyframes:a,name:l,motionValue:u,element:d,...h}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ce.now();const m={autoplay:t,delay:n,type:s,repeat:r,repeatDelay:o,repeatType:i,name:l,motionValue:u,element:d,...h},p=d?.KeyframeResolver||jr;this.keyframeResolver=new p(a,(S,w,T)=>this.onKeyframesResolved(S,w,m,!T),l,u,d),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,s,r){this.keyframeResolver=void 0;const{name:o,type:i,velocity:a,delay:l,isHandoff:u,onUpdate:d}=s;this.resolvedAt=Ce.now(),hu(t,o,i,a)||((He.instantAnimations||!l)&&d?.(Sr(t,s,n)),t[0]=t[t.length-1],qs(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>gu?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!u&&pu(m)?new uu({...m,element:m.motionValue.owner.current}):new Cr(m);p.finished.then(()=>this.notifyFinished()).catch(De),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(),Qc()),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 xu=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function bu(e){const t=xu.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}const vu=4;function Qo(e,t,n=1){Ye(n<=vu,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=bu(e);if(!s)return;const o=window.getComputedStyle(t).getPropertyValue(s);if(o){const i=o.trim();return wo(i)?parseFloat(i):i}return yr(r)?Qo(r,t,n+1):r}function Pr(e,t){return e?.[t]??e?.default??e}const ea=new Set(["width","height","top","left","right","bottom",...Xt]),wu={test:e=>e==="auto",parse:e=>e},ta=e=>t=>t.test(e),na=[_t,U,We,st,dc,uc,wu],ui=e=>na.find(ta(e));function Su(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||To(e):!0}const Tu=new Set(["brightness","contrast","saturate","opacity"]);function Cu(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(xr)||[];if(!s)return e;const r=n.replace(s,"");let o=Tu.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+r+")"}const ju=/\b([a-z-]*)\(.*?\)/gu,Gs={...it,getAnimatableNone:e=>{const t=e.match(ju);return t?t.map(Cu).join(" "):e}},di={..._t,transform:Math.round},Pu={rotate:st,rotateX:st,rotateY:st,rotateZ:st,scale:zn,scaleX:zn,scaleY:zn,scaleZ:zn,skew:st,skewX:st,skewY:st,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:Sn,originX:Zr,originY:Zr,originZ:U},Ar={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,...Pu,zIndex:di,fillOpacity:Sn,strokeOpacity:Sn,numOctaves:di},Au={...Ar,color:de,backgroundColor:de,outlineColor:de,fill:de,stroke:de,borderColor:de,borderTopColor:de,borderRightColor:de,borderBottomColor:de,borderLeftColor:de,filter:Gs,WebkitFilter:Gs},sa=e=>Au[e];function ra(e,t){let n=sa(e);return n!==Gs&&(n=it),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Mu=new Set(["auto","none","0"]);function Eu(e,t,n){let s=0,r;for(;s<e.length&&!r;){const o=e[s];typeof o=="string"&&!Mu.has(o)&&Tn(o).values.length&&(r=e[s]),s++}if(r&&n)for(const o of t)e[o]=ra(n,r)}class ku extends jr{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 u=t[l];if(typeof u=="string"&&(u=u.trim(),yr(u))){const d=Qo(u,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!ea.has(s)||t.length!==2)return;const[r,o]=t,i=ui(r),a=ui(o);if(i!==a)if(oi(i)&&oi(a))for(let l=0;l<t.length;l++){const u=t[l];typeof u=="string"&&(t[l]=parseFloat(u))}else wt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||Su(t[r]))&&s.push(r);s.length&&Eu(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=wt[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]=wt[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 Nu(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 ia=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function oa(e){return So(e)&&"offsetHeight"in e}const hi=30,Du=e=>!isNaN(parseFloat(e));class Ru{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const r=Ce.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=Ce.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Du(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&fr(!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 hr);const s=this.events[t].add(n);return t==="change"?()=>{s(),ae.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=Ce.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>hi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,hi);return Co(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 Bt(e,t){return new Ru(e,t)}const{schedule:Mr}=Io(queueMicrotask,!1),Fe={x:!1,y:!1};function aa(){return Fe.x||Fe.y}function Vu(e){return e==="x"||e==="y"?Fe[e]?null:(Fe[e]=!0,()=>{Fe[e]=!1}):Fe.x||Fe.y?null:(Fe.x=Fe.y=!0,()=>{Fe.x=Fe.y=!1})}function la(e,t){const n=Nu(e),s=new AbortController,r={passive:!0,...t,signal:s.signal};return[n,r,()=>s.abort()]}function fi(e){return!(e.pointerType==="touch"||aa())}function Iu(e,t,n={}){const[s,r,o]=la(e,n),i=a=>{if(!fi(a))return;const{target:l}=a,u=t(l,a);if(typeof u!="function"||!l)return;const d=h=>{fi(h)&&(u(h),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return s.forEach(a=>{a.addEventListener("pointerenter",i,r)}),o}const ca=(e,t)=>t?e===t?!0:ca(e,t.parentElement):!1,Er=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Ou=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Lu(e){return Ou.has(e.tagName)||e.tabIndex!==-1}const Gn=new WeakSet;function mi(e){return t=>{t.key==="Enter"&&e(t)}}function Ss(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Fu=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=mi(()=>{if(Gn.has(n))return;Ss(n,"down");const r=mi(()=>{Ss(n,"up")}),o=()=>Ss(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 pi(e){return Er(e)&&!aa()}function $u(e,t,n={}){const[s,r,o]=la(e,n),i=a=>{const l=a.currentTarget;if(!pi(a))return;Gn.add(l);const u=t(l,a),d=(p,S)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",m),Gn.has(l)&&Gn.delete(l),pi(p)&&typeof u=="function"&&u(p,{success:S})},h=p=>{d(p,l===window||l===document||n.useGlobalTarget||ca(l,p.target))},m=p=>{d(p,!1)};window.addEventListener("pointerup",h,r),window.addEventListener("pointercancel",m,r)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",i,r),oa(a)&&(a.addEventListener("focus",u=>Fu(u,r)),!Lu(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function ua(e){return So(e)&&"ownerSVGElement"in e}function Bu(e){return ua(e)&&e.tagName==="svg"}const be=e=>!!(e&&e.getVelocity),zu=[...na,de,it],Uu=e=>zu.find(ta(e)),kr=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function gi(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function _u(...e){return t=>{let n=!1;const s=e.map(r=>{const o=gi(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():gi(e[r],null)}}}}function Xu(...e){return $e.useCallback(_u(...e),e)}class Wu extends $e.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,r=oa(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 Ku({children:e,isPresent:t,anchorX:n,root:s}){const r=f.useId(),o=f.useRef(null),i=f.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=f.useContext(kr),l=Xu(o,e?.ref);return f.useInsertionEffect(()=>{const{width:u,height:d,top:h,left:m,right:p}=i.current;if(t||!o.current||!u||!d)return;const S=n==="left"?`left: ${m}`:`right: ${p}`;o.current.dataset.motionPopId=r;const w=document.createElement("style");a&&(w.nonce=a);const T=s??document.head;return T.appendChild(w),w.sheet&&w.sheet.insertRule(`
|
|
10
|
+
`);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=Ml(o,n,r,s);if(!i){const a=o.name,u=o[Re]||a||"unnamed";return typeof process<"u"&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production")&&typeof console<"u"&&console.warn&&console.warn(`⚠️ [@arcteninc/core] No metadata found for tool "${u}". This tool will be excluded.
|
|
11
|
+
To fix: Run "arcten-extract-types ." and ensure "${u}" 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 El={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 yn(e){for(const[t,n]of Object.entries(El))if(t!=="text"){for(const s of n)if(s.test(e))return t}return null}function kl(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 Nl(e,t,n){return t.length>0}function Dl(e,t,n,s={}){const r=[];return Object.keys(s).forEach(i=>{const a=i in n,l=n[i];if(!a){const h=s[i];if(h!=null&&h!=="")return}const u=Rl(s[i]),d={name:i,type:Vl(l||yn(i)||"text"),label:xo(i),placeholder:Il(i,l),required:!0,value:u};d.type==="password"&&(d.validation=h=>h.length<8?"Password must be at least 8 characters":null),r.push(d)}),r.sort((i,a)=>{const l=i.name in n,u=a.name in n;return l===u?0:l?1:-1}),{shouldUseForm:Nl(e,t),fields:r,title:Ol(e),description:Ll(e,r.length)}}function Rl(e){if(e!=null){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}}function Vl(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 xo(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Il(e,t){return t?kl(t,e).placeholder:`Enter ${xo(e).toLowerCase()}...`}function Ol(e){return e.replace(/([A-Z])/g," $1").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Ll(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 bn(e){if(typeof e=="string")try{const t=JSON.parse(e);return bn(t)}catch{return e}if(Array.isArray(e))return e.map(bn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=bn(s);return t}return e}function Fl(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 $l(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return bn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?bn(e):{}}const Yn="__secureOutput",Hn="[hidden for privacy]";function Bl(e,t){if(!e||e.length===0)return t;const n=new Map;t.forEach(o=>{const i=o[Re]||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[Re]||o.name;i&&!s.has(i)&&(console.log(`[useAgent] Allowing client-only tool (forward compatible): ${i}`),r.push(o))}),r}function zl(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 Ul(e){return e.replace(/\[(\w+)\]/g,".$1").split(".").map(t=>t.trim()).filter(Boolean)}function _l(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 Xl(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 Ls(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 bo(e,t=""){const n={};return e&&typeof e=="object"?Object.entries(e).forEach(([s,r])=>{const o=t?`${t}.${s}`:s;n[o]=Ls(r),r&&typeof r=="object"&&Object.assign(n,bo(r,o))}):t&&(n[t]=Ls(e)),n}function Wl(e){if(e===void 0||e===!1)return;if(e===!0)return{strategy:"full",fields:[],placeholder:Hn,includeFieldStatus:!1,preserve:[]};if(Array.isArray(e))return{strategy:"fields",fields:e,placeholder:Hn,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??Hn,includeFieldStatus:e.includeFieldStatus??!1,preserve:e.preserve??[]}}function Kl(e){if(!e)return{};const t={};for(const[n,s]of Object.entries(e)){const r=Wl(s);r&&(t[n]=r)}return t}function vo(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=bo(t)),r.redactedFields=["*"];let l={};return n.preserve.length>0&&t&&typeof t=="object"&&n.preserve.forEach(u=>{u in t&&(l[u]=t[u])}),l[Yn]=r,l}if(n.fields.includes("*"))return vo(e,t,{...n,strategy:"full",fields:[]});if(typeof t!="object"||t===null)return{value:s,[Yn]:{...r,redactedFields:n.fields}};const o=zl(t),i=[],a={};return n.fields.forEach(l=>{const u=Ul(l);if(u.length===0)return;const d=_l(o,u),h=Ls(d);a[l]=h,Xl(o,u,s)&&i.push(l)}),r.redactedFields=i,n.includeFieldStatus&&(r.fieldStatus=a),o[Yn]=r,o}function wo({apiBaseUrl:e="https://api.arcten.com",tokenEndpoint:t="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:r,tools:o=[],safeTools:i=[],toolMetadata:a,sensitiveParams:l,sensitiveOutputs:u,autoDetectSensitive:d=!1,autoFormGeneration:h=!1,formMode:m="auto",systemPrompt:p="",agentId:w,agentName:v,projectId:T,enableRemoteConfig:x,remoteConfigUrl:P,initialMessages:E=[],conversationId:O,state:N,onStateChange:k,allowStateEdits:V=!0,onToolCall:A,onFinish:I,sources:j,ragConfig:R,ragFilters:F,secureInputHandler:D}={}){const[L,J]=f.useState(null),[se,q]=f.useState(!1),[re,me]=f.useState(null),xe=f.useMemo(()=>{const g=j||[],b=L?.config?.sources||[];return[...new Set([...g,...b])]},[j,L]),_=f.useMemo(()=>R!==void 0?R:F?{enabled:!0,filters:F}:xe&&xe.length>0?{enabled:!0,organizationId:xe[0],autoExecute:!0,filters:void 0}:{enabled:!1},[xe,R,F]),Et=f.useMemo(()=>x===!1?!1:!!T,[T,x]);f.useEffect(()=>{if(!Et||!ne.current)return;(async()=>{q(!0),me(null);try{const y=`${P||e.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,S=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ne.current}`},body:JSON.stringify({path:"agents:getConfigForClient",args:{projectId:T,agentName:v,agentId:w},format:"json"})});if(!S.ok){if(S.status===404){console.warn("[useAgent] Remote config endpoint not found (404), using local tools only"),J(null);return}const $=await S.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch remote config: ${S.status} ${$}`)}const M=await S.json();J(M?.value||null),console.log("[useAgent] Remote config loaded successfully:",M?.value)}catch(b){console.error("[useAgent] Failed to fetch remote config:",b);const y=b instanceof Error?b:new Error(String(b));me(y),J(null)}finally{q(!1)}})()},[Et,T,v,w,e,P]);const Ae=f.useMemo(()=>{const g={};if(l)for(const[b,y]of Object.entries(l))if(g[b]={},Array.isArray(y))for(const S of y){const M=yn(S);g[b][S]=M||"text"}else for(const[S,M]of Object.entries(y))g[b][S]=M;if(a){for(const[b,y]of Object.entries(a))if(y&&typeof y=="object"&&"sensitiveParams"in y){g[b]||(g[b]={});const S=y.sensitiveParams;if(Array.isArray(S))for(const M of S){const $=yn(M);g[b][M]=$||"text"}else if(S&&typeof S=="object")for(const[M,$]of Object.entries(S))g[b][M]=$}}return g},[l,a,d]),ht=f.useMemo(()=>Kl(u),[u]),Te=f.useCallback((g,b)=>{const y=ht[g];if(!y)return b;try{return vo(g,b,y)}catch(S){return console.error(`[useAgent] Failed to redact output for ${g}:`,S),{value:Hn,[Yn]:{tool:g,redacted:!0,error:String(S)}}}},[ht]),[Oe,sn]=f.useState(n||null),ne=f.useRef(n||null),[rn,ft]=f.useState(null),[on,In]=f.useState(null),Le=f.useRef(null),[mt,pt]=f.useState([]),[Ee,an]=f.useState(O||(typeof window<"u"?crypto.randomUUID():null)),[hs,kt]=f.useState(!1),[On,gt]=f.useState(new Set),[nt,fs]=f.useState(new Map),[Ln,We]=f.useState(new Map),[ms,Fn]=f.useState(new Map),[Nt,ln]=f.useState(new Map),ie=N!==void 0,[cn,Fe]=f.useState({}),be=f.useRef({}),Ke=ie?N||{}:cn;ie&&N?be.current=N:ie||(be.current=cn);const[$e,Dt]=f.useState(!1),[yt,xt]=f.useState(null),un=f.useRef(!1),ke=f.useCallback(async(g,b=3)=>{if(!Ee||!ne.current)return;const y=async()=>{const M=`${e.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,$=await fetch(M,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ne.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:Ee,updates:g},format:"json"})});if(!$.ok){if($.status===404){console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const Y=await $.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${$.status} ${Y}`)}};for(let S=0;S<b;S++)try{await y(),xt(null);return}catch(M){if(S===b-1){const Y=M instanceof Error?M:new Error(String(M));throw xt(Y),console.error("Failed to sync state to Convex after retries:",M),Y}await new Promise(Y=>setTimeout(Y,Math.pow(2,S)*100))}},[Ee,e,ne]),bt=f.useMemo(()=>function(){return be.current},[]),fe=f.useMemo(()=>async function(b){const y={...be.current,...b};be.current=y,ie||Fe(y),k&&k(y);try{await ke(b)}catch(S){throw S}},[ke,k,ie]);f.useEffect(()=>{ie&&N&&(be.current=N)},[ie,N]);const $n=f.useCallback(g=>D?D.showSecureModal(g):new Promise(b=>{fs(y=>new Map(y).set(g.id,g)),We(y=>new Map(y).set(g.id,b))}),[D]),Rt=f.useCallback((g,b)=>{if(D)return;const y=Ln.get(g);y&&(y(b),fs(S=>{const M=new Map(S);return M.delete(g),M}),We(S=>{const M=new Map(S);return M.delete(g),M}))},[Ln,D]),Je=f.useCallback(g=>D?D.showSecureForm(g):new Promise(b=>{Fn(y=>new Map(y).set(g.id,g)),ln(y=>new Map(y).set(g.id,b))}),[D]),Kr=f.useCallback((g,b)=>{if(D)return;const y=Nt.get(g);y&&(y(b),Fn(S=>{const M=new Map(S);return M.delete(g),M}),ln(S=>{const M=new Map(S);return M.delete(g),M}))},[Nt,D]),dn=f.useCallback((g,b)=>{const y=Ae[g]||{},S=Object.keys(y).length>0;if(d){const M=Object.keys(b).filter($=>yn($)!==null);return S||M.length>0}return S},[Ae,d]),hn=f.useCallback((g,b)=>{const S={...Ae[g]||{}};if(d){for(const $ of Object.keys(b))if(!($ in S)){const Y=yn($);Y&&(S[$]=Y)}}const M=Object.entries(S).filter(([$])=>Object.prototype.hasOwnProperty.call(b,$));return M.length>0?Object.fromEntries(M):S},[Ae,d]),qe=f.useMemo(()=>_?.enabled?async function(b,y=20,S){const M={..._.filters,...S};if(j&&j.length>1){const Y=j.map(H=>fetch(`${e}/search`,{method:"POST",headers:{"Content-Type":"application/json",...ne.current?{Authorization:`Bearer ${ne.current}`}:{}},body:JSON.stringify({q:b,k:Math.min(y,100),organizationId:H,...Object.keys(M).length>0?{filters:M}:{}})}).then(oe=>oe.ok?oe.json():null)),je=await Promise.all(Y),ge=[];for(const H of je)H?.candidates&&ge.push(...H.candidates);ge.sort((H,oe)=>{const rt=H.scores?.rerank||H.scores?.dense||0;return(oe.scores?.rerank||oe.scores?.dense||0)-rt});const ze=ge.slice(0,y).map((H,oe)=>{const rt=H.citation||H.url;return{rank:oe+1,doc_id:H.doc_id,block_id:H.block_id,url:H.url,citation:rt,title:H.title||"Untitled",snippet:H.snippet,score:H.scores?.rerank||H.scores?.dense||0,metadata:{site:H.metadata?.site,lang:H.metadata?.lang,contentType:H.metadata?.content_type}}});return{success:!0,query:b,total:ge.length,results:ze,summary:`Found ${ge.length} relevant results across ${j.length} source(s) for "${b}". Top result: ${ze[0]?.title||"N/A"}`}}const $=_.organizationId&&_.organizationId!=="default"?_.organizationId:j&&j.length>0?j[0]:void 0;try{const Y={q:b,k:Math.min(y,100)};$&&(Y.organizationId=$),Object.keys(M).length>0&&(Y.filters=M);const je={"Content-Type":"application/json"};ne.current&&(je.Authorization=`Bearer ${ne.current}`);const ge=await fetch(`${e}/search`,{method:"POST",headers:je,body:JSON.stringify(Y)});if(!ge.ok){const oe=await ge.text();return{success:!1,error:`Search failed: ${ge.status} ${oe}`}}const ze=await ge.json(),H=ze.candidates.map((oe,rt)=>{const pn=oe.citation||oe.url;return{rank:rt+1,doc_id:oe.doc_id,block_id:oe.block_id,url:oe.url,citation:pn,title:oe.title||"Untitled",snippet:oe.snippet,score:oe.scores?.rerank||oe.scores?.dense||0,metadata:{site:oe.metadata?.site,lang:oe.metadata?.lang,contentType:oe.metadata?.content_type}}});return{success:!0,query:ze.query,total:ze.total,results:H,summary:`Found ${ze.total} relevant results for "${b}". Top result: ${H[0]?.title||"N/A"}`}}catch(Y){return{success:!1,error:Y instanceof Error?Y.message:"Unknown error occurred"}}}:null,[_,e,ne]),st=f.useMemo(()=>_?.enabled?async function(b,y){const S=_.organizationId&&_.organizationId!=="default"?_.organizationId:j&&j.length>0?j[0]:void 0;try{const M={"Content-Type":"application/json"};ne.current&&(M.Authorization=`Bearer ${ne.current}`);const $=await fetch(`${e}/fetch`,{method:"POST",headers:M,body:JSON.stringify({doc_id:b,block_ids:y,...S?{organizationId:S}:{}})});if(!$.ok){const je=await $.text();return{success:!1,error:`Fetch failed: ${$.status} ${je}`}}const Y=await $.json();return{success:!0,blocks:Y.blocks||[],fullContent:Y.fullContent||"",pageUrl:Y.pageUrl||"",pageTitle:Y.pageTitle||"",summary:`Fetched ${Y.blocks?.length||0} blocks from ${Y.pageTitle||b}`}}catch(M){return{success:!1,error:M instanceof Error?M.message:"Unknown error occurred"}}}:null,[_,e,ne]),Vt=f.useMemo(()=>{if(L&&L.config?.tools){const g=Bl(L.config.tools,o);return console.log("[useAgent] Merged remote config:",{remoteToolCount:L.config.tools.length,localToolCount:o.length,mergedToolCount:g.length}),g}return o},[L,o]),Be=L?.enableStateTools??!0,Ge=L?.enableRagTools??_?.enabled??!1,Bn=f.useMemo(()=>{const g=[...Vt,...i];return Be&&(g.push(bt),(!ie||V)&&g.push(fe)),Ge&&(qe&&g.push(qe),st&&g.push(st)),g},[Vt,i,bt,fe,qe,st,Be,Ge,ie,V]),zn=f.useMemo(()=>[...Vt,...i],[Vt,i]),Ze=f.useMemo(()=>lr(zn,a),[zn,a]),vt=f.useMemo(()=>{const g=new Map,b=new Map(Ze.map(y=>[y.name,y]));return g.set("getState",bt),(!ie||V)&&g.set("setState",fe),_?.enabled&&(qe&&g.set("searchDocs",qe),st&&g.set("fetchDocContent",st)),Bn.forEach(y=>{if(y===bt||y===fe||y===qe||y===st)return;const S=y[Re];if(S){const $=b.get(S);if($){g.set($.name,y);return}}const M=Ze.find($=>$.name===y.name);M&&g.set(M.name,y)}),g},[Bn,Ze,bt,fe,qe,st,_,ie,V]),fn=f.useMemo(()=>new Set(Ze.map(g=>g.name)),[Ze]),Un=f.useMemo(()=>{const g=[];Be&&(g.push({name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}),(!ie||V)&&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 b=[];return Ge&&b.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"]}}),[...Ze,...g,...b]},[Ze,Be,Ge,ie,V]),It=f.useMemo(()=>Un.filter(g=>g.name==="getState"?Be:g.name==="setState"?Be&&(!ie||V):g.name==="searchDocs"||g.name==="fetchDocContent"?Ge:fn.has(g.name)),[Un,fn,Be,Ge,ie,V]),_n=f.useMemo(()=>{const g=new Set;return Be&&(g.add("getState"),g.add("setState")),Ge&&_?.autoExecute!==!1&&(g.add("searchDocs"),g.add("fetchDocContent")),i.forEach(b=>{for(const[y,S]of vt.entries())if(S===b){g.add(y);break}}),g},[i,vt,Be,Ge,_]);f.useEffect(()=>s||n?void 0:((async()=>{try{const b=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!b.ok)throw new Error("Failed to fetch token");const y=await b.json();sn(y.clientToken),ne.current=y.clientToken,In(y.expiresAt),ft(null)}catch(b){console.error("[useAgent] Token fetch failed:",b),ft(b instanceof Error?b.message:"Failed to fetch token")}})(),()=>{Le.current&&clearTimeout(Le.current)}),[t,JSON.stringify(r),s,n]),f.useEffect(()=>{if(!on||s||n)return;Le.current&&clearTimeout(Le.current);const g=Math.floor(Date.now()/1e3),b=on-g,S=Math.max(0,b-5);return Le.current=setTimeout(async()=>{try{const M=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!M.ok)throw new Error("Failed to refresh token");const $=await M.json();sn($.clientToken),ne.current=$.clientToken,In($.expiresAt),ft(null)}catch(M){console.error("[useAgent] Token refresh failed:",M),ft(M instanceof Error?M.message:"Failed to refresh token")}},S*1e3),()=>{Le.current&&clearTimeout(Le.current)}},[on,t,JSON.stringify(r),s,n]);const ps=async(g,b={})=>{const y=b.headers?new Headers(b.headers):new Headers;y.delete("user-agent"),y.delete("User-Agent"),console.log("[useAgent] Making request to:",g),console.log("[useAgent] Method:",b.method||"GET"),console.log("[useAgent] Has Authorization header:",y.has("Authorization")),console.log("[useAgent] Client token available:",!!ne.current);try{const S=await fetch(g,{...b,headers:y});if(!S.ok){console.error("[useAgent] Request failed:",S.status,S.statusText);const M=await S.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",M)}return S}catch(S){throw console.error("[useAgent] Fetch error:",S),S}},mn=`${e}/chat`;console.log("[useAgent] Chat API URL:",mn);const{messages:Ye,sendMessage:C,status:z,error:X,stop:G,addToolResult:W,setMessages:K}=bl.useChat({id:Ee||void 0,messages:E,transport:new Yr.DefaultChatTransport({api:mn,fetch:ps,headers:()=>{const g={};return ne.current?(g.Authorization=`Bearer ${ne.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),g},body:()=>{console.log("[ArctenAgent] body() agentName =",v);const g=It.map(S=>({name:S.name,description:S.description,inputSchema:S.jsonSchema})),b=g.filter(S=>S.name==="getState"||S.name==="setState").map(S=>S.name),y=g.filter(S=>S.name==="searchDocs"||S.name==="fetchDocContent").map(S=>S.name);return b.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",b),y.length>0?console.log("[useAgent] RAG tools included in tools list sent to AI SDK:",y):_?.enabled&&console.warn("[useAgent] RAG is enabled but no RAG tools found in tools list!"),{tools:g,...w&&{agentId:w},...v&&{agentName:v},state:be.current,...F&&{ragFilters:F}}}}),sendAutomaticallyWhen:Yr.lastAssistantMessageIsCompleteWithToolCalls}),pe=f.useCallback((g,b,y)=>{const S=Te(g,y);W({toolCallId:b,tool:g,output:S})},[W,Te]);f.useEffect(()=>{Ye.forEach(g=>{g.role==="assistant"&&g.parts.forEach(b=>{if(!b.type?.startsWith("tool-")||b.state!=="input-available")return;const y=b.type.replace("tool-",""),S=b.toolCallId;if(On.has(S))return;gt($=>new Set($).add(S));const M=$l(b.input);if(dn(y,M)){const $=hn(y,M),Y=Object.entries($).filter(([H])=>M[H]!==void 0),je=Y.length>0?Object.fromEntries(Y):$,ge=Object.keys(M),ze=Fl(M,je);(async()=>{try{const H=Dl(y,ge,je,M),oe={id:`${S}-form`,toolName:y,toolCallId:S,title:H.title,description:H.description,fields:H.fields},rt=await Je(oe);if(rt===null){pe(y,S,"User cancelled secure input");return}const pn={...ze,...rt},gs=vt.get(y);if(!gs)throw new Error(`Tool ${y} not found`);let ys;const xs=It.find(qr=>qr.name===y);if(xs&&xs.jsonSchema?.properties){const ul=Object.keys(xs.jsonSchema.properties).map(dl=>pn[dl]);ys=await gs(...ul)}else ys=await gs(...Object.values(pn));pe(y,S,ys)}catch(H){console.error(`[useAgent] Error executing tool with secure input ${y}:`,H),pe(y,S,`Error: ${H}`)}})();return}if(_n.has(y)&&!dn(y,M)){const $=vt.get(y);$?(async()=>{try{const Y=It.find(ge=>ge.name===y);let je;if(Y&&Y.jsonSchema?.properties){const ze=Object.keys(Y.jsonSchema.properties).map(H=>M[H]);je=await $(...ze)}else if(y==="getState")je=$();else if(y==="setState"){const ge=M.updates||M;je=await $(ge)}else je=await $(...Object.values(M));pe(y,S,je)}catch(Y){console.error(`[useAgent] Error executing tool ${y}:`,Y),pe(y,S,`Error: ${Y}`)}})():console.warn(`[useAgent] Tool ${y} not found in toolsMap`)}else A&&A({toolCall:{toolCallId:S,toolName:y,args:M}})})})},[Ye,_n,vt,A,pe,On,fe,It,dn,hn,$n]),f.useEffect(()=>{if(z==="ready"&&Ye.length>0&&I){const g=Ye[Ye.length-1];g&&g.role==="assistant"&&I({message:g,messages:Ye,isAbort:!1,isDisconnect:!1,isError:!!X})}},[z,Ye,X,I]);async function te(){if(!(!r?.id||!Oe)){kt(!0);try{const b=await(await fetch(`${e}/conversations`,{headers:{Authorization:`Bearer ${Oe}`}})).json();pt(b.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{kt(!1)}}}f.useEffect(()=>{r?.id&&Oe&&te()},[JSON.stringify(r),Oe,e]),f.useEffect(()=>{if(!Ee||!ne.current)return;(async()=>{Dt(!0),xt(null);try{const b=await fetch(`${e.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ne.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:Ee},format:"json"})});if(!b.ok){const M=await b.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${b.status} ${M}`)}const S=(await b.json())?.value||{};be.current=S,ie||Fe(S),k&&k(S),un.current=!0}catch(b){console.error("Failed to fetch state:",b);const y=b instanceof Error?b:new Error(String(b));xt(y),un.current||(be.current={},ie?k&&k({}):(Fe({}),k&&k({})),un.current=!0)}finally{Dt(!1)}})()},[Ee,e,ie,k]);async function ve(g){an(g),kt(!0);try{const b=await fetch(`${e}/conversations/${g}/messages`,{headers:{Authorization:`Bearer ${ne.current}`}});if(!b.ok)throw new Error(`Failed to fetch messages: ${b.statusText}`);const S=(await b.json()).messages||[];K(S)}catch(b){console.error("Failed to load conversation messages:",b)}finally{kt(!1)}}async function U(g){if(Oe)try{await fetch(`${e}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${Oe}`}}),pt(mt.filter(b=>b._id!==g)),g===Ee&&ue()}catch(b){console.error("Failed to delete conversation:",b)}}function ue(){const g=crypto.randomUUID();an(g),K([]),gt(new Set),be.current={},ie?k&&k({}):(Fe({}),k&&k({})),un.current=!1}function Q(g){const b=g.tool||"unknown-tool",y=Te(b,g.output);W({toolCallId:g.toolCallId,tool:b,output:y})}async function Ce(g){const b={...be.current,...g};be.current=b,ie||Fe(b),k&&k(b);try{await ke(g)}catch(y){throw y}}return{id:Ee,messages:Ye,status:z,error:X,sendMessage:C,stop:G,addToolOutput:Q,setMessages:K,conversations:mt,loadConversation:ve,deleteConversation:U,startNewConversation:ue,isLoadingConversations:hs,clientToken:Oe,tokenError:rn,state:Ke,setState:Ce,isStateLoading:$e,stateError:yt,pendingSecureInputs:Array.from(nt.values()),completeSecureInput:Rt,pendingSecureForms:Array.from(ms.values()),completeSecureForm:Kr}}function ee(...e){return wl.twMerge(vl.clsx(e))}const St=yo.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"}}),Se=_e.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...r},o)=>{const i=s?go.Slot:"button";return c.jsx(i,{ref:o,"data-slot":"button",className:ee(St({variant:t,size:n,className:e})),...r})});Se.displayName="Button";const ql=yo.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 bs({className:e,variant:t,asChild:n=!1,...s}){const r=n?go.Slot:"span";return c.jsx(r,{"data-slot":"badge",className:ee(ql({variant:t}),e),...s})}const Gl=({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])},So=_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,u]=_e.useState("");return Gl({textAreaRef:a,triggerAutoSize:l,maxHeight:e,minHeight:t}),f.useImperativeHandle(i,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:e,minHeight:t})),_e.useEffect(()=>{u(r)},[o?.defaultValue,r]),c.jsx("textarea",{...o,value:r,ref:a,className:ee("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=>{u(d.target.value),s?.(d)}})});So.displayName="AutosizeTextarea";function Yl({delayDuration:e=0,...t}){return c.jsx(Ut.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function it({...e}){return c.jsx(Yl,{children:c.jsx(Ut.Root,{"data-slot":"tooltip",...e})})}function ot({...e}){return c.jsx(Ut.Trigger,{"data-slot":"tooltip-trigger",...e})}function at({className:e,sideOffset:t=0,children:n,...s}){return c.jsx(Ut.Portal,{children:c.jsxs(Ut.Content,{"data-slot":"tooltip-content",sideOffset:t,className:ee("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,c.jsx(Ut.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Jr({className:e,...t}){return c.jsx("kbd",{"data-slot":"kbd",className:ee("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 cr=f.createContext({});function ur(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const dr=typeof window<"u",To=dr?f.useLayoutEffect:f.useEffect,ls=f.createContext(null);function hr(e,t){e.indexOf(t)===-1&&e.push(t)}function fr(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const Qe=(e,t,n)=>n>t?t:n<e?e:n;function Fs(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let Kt=()=>{},et=()=>{};process.env.NODE_ENV!=="production"&&(Kt=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Fs(t,n))},et=(e,t,n)=>{if(!e)throw new Error(Fs(t,n))});const tt={},Co=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function jo(e){return typeof e=="object"&&e!==null}const Po=e=>/^0[^.\s]+$/u.test(e);function mr(e){let t;return()=>(t===void 0&&(t=e()),t)}const Ie=e=>e,Hl=(e,t)=>n=>t(e(n)),Nn=(...e)=>e.reduce(Hl),jn=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class pr{constructor(){this.subscriptions=[]}add(t){return hr(this.subscriptions,t),()=>fr(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,Ve=e=>e/1e3;function Ao(e,t){return t?e*(1e3/t):0}const Zr=new Set;function gr(e,t,n){e||Zr.has(t)||(console.warn(Fs(t,n)),Zr.add(t))}const Mo=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Jl=1e-7,Zl=12;function Ql(e,t,n,s,r){let o,i,a=0;do i=t+(n-t)/2,o=Mo(i,s,r)-e,o>0?n=i:t=i;while(Math.abs(o)>Jl&&++a<Zl);return i}function Dn(e,t,n,s){if(e===t&&n===s)return Ie;const r=o=>Ql(o,0,1,e,n);return o=>o===0||o===1?o:Mo(r(o),t,s)}const Eo=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ko=e=>t=>1-e(1-t),No=Dn(.33,1.53,.69,.99),yr=ko(No),Do=Eo(yr),Ro=e=>(e*=2)<1?.5*yr(e):.5*(2-Math.pow(2,-10*(e-1))),xr=e=>1-Math.sin(Math.acos(e)),Vo=ko(xr),Io=Eo(xr),ec=Dn(.42,0,1,1),tc=Dn(0,0,.58,1),Oo=Dn(.42,0,.58,1),nc=e=>Array.isArray(e)&&typeof e[0]!="number",Lo=e=>Array.isArray(e)&&typeof e[0]=="number",Qr={linear:Ie,easeIn:ec,easeInOut:Oo,easeOut:tc,circIn:xr,circInOut:Io,circOut:Vo,backIn:yr,backInOut:Do,backOut:No,anticipate:Ro},sc=e=>typeof e=="string",ei=e=>{if(Lo(e)){et(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,r]=e;return Dn(t,n,s,r)}else if(sc(e))return et(Qr[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),Qr[e];return e},Xn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function rc(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)&&(u.schedule(d),e()),d(a)}const u={schedule:(d,h=!1,m=!1)=>{const w=m&&r?n:s;return h&&i.add(d),w.has(d)||w.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,u.process(d))}};return u}const ic=40;function Fo(e,t){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,i=Xn.reduce((E,O)=>(E[O]=rc(o),E),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:d,update:h,preRender:m,render:p,postRender:w}=i,v=()=>{const E=tt.useManualTiming?r.timestamp:performance.now();n=!1,tt.useManualTiming||(r.delta=s?1e3/60:Math.max(Math.min(E-r.timestamp,ic),1)),r.timestamp=E,r.isProcessing=!0,a.process(r),l.process(r),u.process(r),d.process(r),h.process(r),m.process(r),p.process(r),w.process(r),r.isProcessing=!1,n&&t&&(s=!1,e(v))},T=()=>{n=!0,s=!0,r.isProcessing||e(v)};return{schedule:Xn.reduce((E,O)=>{const N=i[O];return E[O]=(k,V=!1,A=!1)=>(n||T(),N.schedule(k,V,A)),E},{}),cancel:E=>{for(let O=0;O<Xn.length;O++)i[Xn[O]].cancel(E)},state:r,steps:i}}const{schedule:ae,cancel:ct,state:ye,steps:vs}=Fo(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ie,!0);let Jn;function oc(){Jn=void 0}const Me={now:()=>(Jn===void 0&&Me.set(ye.isProcessing||tt.useManualTiming?ye.timestamp:performance.now()),Jn),set:e=>{Jn=e,queueMicrotask(oc)}},$o=e=>t=>typeof t=="string"&&t.startsWith(e),br=$o("--"),ac=$o("var(--"),vr=e=>ac(e)?lc.test(e.split("/*")[0].trim()):!1,lc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,qt={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Pn={...qt,transform:e=>Qe(0,1,e)},Wn={...qt,default:1},vn=e=>Math.round(e*1e5)/1e5,wr=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function cc(e){return e==null}const uc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Sr=(e,t)=>n=>!!(typeof n=="string"&&uc.test(n)&&n.startsWith(e)||t&&!cc(n)&&Object.prototype.hasOwnProperty.call(n,t)),Bo=(e,t,n)=>s=>{if(typeof s!="string")return s;const[r,o,i,a]=s.match(wr);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(i),alpha:a!==void 0?parseFloat(a):1}},dc=e=>Qe(0,255,e),ws={...qt,transform:e=>Math.round(dc(e))},Ct={test:Sr("rgb","red"),parse:Bo("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+ws.transform(e)+", "+ws.transform(t)+", "+ws.transform(n)+", "+vn(Pn.transform(s))+")"};function hc(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 $s={test:Sr("#"),parse:hc,transform:Ct.transform},Rn=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),lt=Rn("deg"),He=Rn("%"),B=Rn("px"),fc=Rn("vh"),mc=Rn("vw"),ti={...He,parse:e=>He.parse(e)/100,transform:e=>He.transform(e*100)},Ot={test:Sr("hsl","hue"),parse:Bo("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+He.transform(vn(t))+", "+He.transform(vn(n))+", "+vn(Pn.transform(s))+")"},he={test:e=>Ct.test(e)||$s.test(e)||Ot.test(e),parse:e=>Ct.test(e)?Ct.parse(e):Ot.test(e)?Ot.parse(e):$s.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Ct.transform(e):Ot.transform(e),getAnimatableNone:e=>{const t=he.parse(e);return t.alpha=0,he.transform(t)}},pc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function gc(e){return isNaN(e)&&typeof e=="string"&&(e.match(wr)?.length||0)+(e.match(pc)?.length||0)>0}const zo="number",Uo="color",yc="var",xc="var(",ni="${}",bc=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function An(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},r=[];let o=0;const a=t.replace(bc,l=>(he.test(l)?(s.color.push(o),r.push(Uo),n.push(he.parse(l))):l.startsWith(xc)?(s.var.push(o),r.push(yc),n.push(l)):(s.number.push(o),r.push(zo),n.push(parseFloat(l))),++o,ni)).split(ni);return{values:n,split:a,indexes:s,types:r}}function _o(e){return An(e).values}function Xo(e){const{split:t,types:n}=An(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===zo?o+=vn(r[i]):a===Uo?o+=he.transform(r[i]):o+=r[i]}return o}}const vc=e=>typeof e=="number"?0:he.test(e)?he.getAnimatableNone(e):e;function wc(e){const t=_o(e);return Xo(e)(t.map(vc))}const ut={test:gc,parse:_o,createTransformer:Xo,getAnimatableNone:wc};function Ss(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 Sc({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=Ss(l,a,e+1/3),o=Ss(l,a,e),i=Ss(l,a,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(i*255),alpha:s}}function ns(e,t){return n=>n>0?t:e}const ce=(e,t,n)=>e+(t-e)*n,Ts=(e,t,n)=>{const s=e*e,r=n*(t*t-s)+s;return r<0?0:Math.sqrt(r)},Tc=[$s,Ct,Ot],Cc=e=>Tc.find(t=>t.test(e));function si(e){const t=Cc(e);if(Kt(!!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===Ot&&(n=Sc(n)),n}const ri=(e,t)=>{const n=si(e),s=si(t);if(!n||!s)return ns(e,t);const r={...n};return o=>(r.red=Ts(n.red,s.red,o),r.green=Ts(n.green,s.green,o),r.blue=Ts(n.blue,s.blue,o),r.alpha=ce(n.alpha,s.alpha,o),Ct.transform(r))},Bs=new Set(["none","hidden"]);function jc(e,t){return Bs.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Pc(e,t){return n=>ce(e,t,n)}function Tr(e){return typeof e=="number"?Pc:typeof e=="string"?vr(e)?ns:he.test(e)?ri:Ec:Array.isArray(e)?Wo:typeof e=="object"?he.test(e)?ri:Ac:ns}function Wo(e,t){const n=[...e],s=n.length,r=e.map((o,i)=>Tr(o)(o,t[i]));return o=>{for(let i=0;i<s;i++)n[i]=r[i](o);return n}}function Ac(e,t){const n={...e,...t},s={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(s[r]=Tr(e[r])(e[r],t[r]));return r=>{for(const o in s)n[o]=s[o](r);return n}}function Mc(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 Ec=(e,t)=>{const n=ut.createTransformer(t),s=An(e),r=An(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?Bs.has(e)&&!r.values.length||Bs.has(t)&&!s.values.length?jc(e,t):Nn(Wo(Mc(s,r),r.values),n):(Kt(!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"),ns(e,t))};function Ko(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?ce(e,t,n):Tr(e)(e,t)}const kc=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ae.update(t,n),stop:()=>ct(t),now:()=>ye.isProcessing?ye.timestamp:Me.now()}},qo=(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)})`},ss=2e4;function Cr(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<ss;)t+=n,s=e.next(t);return t>=ss?1/0:t}function Nc(e,t=100,n){const s=n({...e,keyframes:[0,t]}),r=Math.min(Cr(s),ss);return{type:"keyframes",ease:o=>s.next(r*o).value/t,duration:Ve(r)}}const Dc=5;function Go(e,t,n){const s=Math.max(t-Dc,0);return Ao(n-e(s),t-s)}const le={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},Cs=.001;function Rc({duration:e=le.duration,bounce:t=le.bounce,velocity:n=le.velocity,mass:s=le.mass}){let r,o;Kt(e<=Xe(le.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=Qe(le.minDamping,le.maxDamping,i),e=Qe(le.minDuration,le.maxDuration,Ve(e)),i<1?(r=u=>{const d=u*i,h=d*e,m=d-n,p=zs(u,i),w=Math.exp(-h);return Cs-m/p*w},o=u=>{const h=u*i*e,m=h*n+n,p=Math.pow(i,2)*Math.pow(u,2)*e,w=Math.exp(-h),v=zs(Math.pow(u,2),i);return(-r(u)+Cs>0?-1:1)*((m-p)*w)/v}):(r=u=>{const d=Math.exp(-u*e),h=(u-n)*e+1;return-Cs+d*h},o=u=>{const d=Math.exp(-u*e),h=(n-u)*(e*e);return d*h});const a=5/e,l=Ic(r,o,a);if(e=Xe(e),isNaN(l))return{stiffness:le.stiffness,damping:le.damping,duration:e};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:i*2*Math.sqrt(s*u),duration:e}}}const Vc=12;function Ic(e,t,n){let s=n;for(let r=1;r<Vc;r++)s=s-e(s)/t(s);return s}function zs(e,t){return e*Math.sqrt(1-t*t)}const Oc=["duration","bounce"],Lc=["stiffness","damping","mass"];function ii(e,t){return t.some(n=>e[n]!==void 0)}function Fc(e){let t={velocity:le.velocity,stiffness:le.stiffness,damping:le.damping,mass:le.mass,isResolvedFromDuration:!1,...e};if(!ii(e,Lc)&&ii(e,Oc))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,o=2*Qe(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:le.mass,stiffness:r,damping:o}}else{const n=Rc(e);t={...t,...n,mass:le.mass},t.isResolvedFromDuration=!0}return t}function rs(e=le.visualDuration,t=le.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:u,mass:d,duration:h,velocity:m,isResolvedFromDuration:p}=Fc({...n,velocity:-Ve(n.velocity||0)}),w=m||0,v=u/(2*Math.sqrt(l*d)),T=i-o,x=Ve(Math.sqrt(l/d)),P=Math.abs(T)<5;s||(s=P?le.restSpeed.granular:le.restSpeed.default),r||(r=P?le.restDelta.granular:le.restDelta.default);let E;if(v<1){const N=zs(x,v);E=k=>{const V=Math.exp(-v*x*k);return i-V*((w+v*x*T)/N*Math.sin(N*k)+T*Math.cos(N*k))}}else if(v===1)E=N=>i-Math.exp(-x*N)*(T+(w+x*T)*N);else{const N=x*Math.sqrt(v*v-1);E=k=>{const V=Math.exp(-v*x*k),A=Math.min(N*k,300);return i-V*((w+v*x*T)*Math.sinh(A)+N*T*Math.cosh(A))/N}}const O={calculatedDuration:p&&h||null,next:N=>{const k=E(N);if(p)a.done=N>=h;else{let V=N===0?w:0;v<1&&(V=N===0?Xe(w):Go(E,N,k));const A=Math.abs(V)<=s,I=Math.abs(i-k)<=r;a.done=A&&I}return a.value=a.done?i:k,a},toString:()=>{const N=Math.min(Cr(O),ss),k=qo(V=>O.next(N*V).value,N,30);return N+"ms "+k},toTransition:()=>{}};return O}rs.applyToOptions=e=>{const t=Nc(e,100,rs);return e.ease=t.ease,e.duration=Xe(t.duration),e.type="keyframes",e};function Us({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:r=10,bounceStiffness:o=500,modifyTarget:i,min:a,max:l,restDelta:u=.5,restSpeed:d}){const h=e[0],m={done:!1,value:h},p=A=>a!==void 0&&A<a||l!==void 0&&A>l,w=A=>a===void 0?l:l===void 0||Math.abs(a-A)<Math.abs(l-A)?a:l;let v=n*t;const T=h+v,x=i===void 0?T:i(T);x!==T&&(v=x-h);const P=A=>-v*Math.exp(-A/s),E=A=>x+P(A),O=A=>{const I=P(A),j=E(A);m.done=Math.abs(I)<=u,m.value=m.done?x:j};let N,k;const V=A=>{p(m.value)&&(N=A,k=rs({keyframes:[m.value,w(m.value)],velocity:Go(E,A,m.value),damping:r,stiffness:o,restDelta:u,restSpeed:d}))};return V(0),{calculatedDuration:null,next:A=>{let I=!1;return!k&&N===void 0&&(I=!0,O(A),V(A)),N!==void 0&&A>=N?k.next(A-N):(!I&&O(A),m)}}}function $c(e,t,n){const s=[],r=n||tt.mix||Ko,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]||Ie:t;a=Nn(l,a)}s.push(a)}return s}function Bc(e,t,{clamp:n=!0,ease:s,mixer:r}={}){const o=e.length;if(et(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=$c(t,s,r),l=a.length,u=d=>{if(i&&d<e[0])return t[0];let h=0;if(l>1)for(;h<e.length-2&&!(d<e[h+1]);h++);const m=jn(e[h],e[h+1],d);return a[h](m)};return n?d=>u(Qe(e[0],e[o-1],d)):u}function zc(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=jn(0,t,s);e.push(ce(n,1,r))}}function Uc(e){const t=[0];return zc(t,e.length-1),t}function _c(e,t){return e.map(n=>n*t)}function Xc(e,t){return e.map(()=>t||Oo).splice(0,e.length-1)}function Lt({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const r=nc(s)?s.map(ei):ei(s),o={done:!1,value:t[0]},i=_c(n&&n.length===t.length?n:Uc(t),e),a=Bc(i,t,{ease:Array.isArray(r)?r:Xc(t,r)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Wc=e=>e!==null;function jr(e,{repeat:t,repeatType:n="loop"},s,r=1){const o=e.filter(Wc),a=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Kc={decay:Us,inertia:Us,tween:Lt,keyframes:Lt,spring:rs};function Yo(e){typeof e.type=="string"&&(e.type=Kc[e.type])}class Pr{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 qc=e=>e/100;class Ar extends Pr{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;Yo(t);const{type:n=Lt,repeat:s=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=t;let{keyframes:a}=t;const l=n||Lt;process.env.NODE_ENV!=="production"&&l!==Lt&&et(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Lt&&typeof a[0]!="number"&&(this.mixKeyframes=Nn(qc,Ko(a[0],a[1])),a=[0,100]);const u=l({...t,keyframes:a});o==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-i})),u.calculatedDuration===null&&(u.calculatedDuration=Cr(u));const{calculatedDuration:d}=u;this.calculatedDuration=d,this.resolvedDuration=d+r,this.totalDuration=this.resolvedDuration*(s+1)-r,this.generator=u}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:s,totalDuration:r,mixKeyframes:o,mirroredGenerator:i,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:d,repeat:h,repeatType:m,repeatDelay:p,type:w,onUpdate:v,finalKeyframe:T}=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 x=this.currentTime-u*(this.playbackSpeed>=0?1:-1),P=this.playbackSpeed>=0?x<0:x>r;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let E=this.currentTime,O=s;if(h){const A=Math.min(this.currentTime,r)/a;let I=Math.floor(A),j=A%1;!j&&A>=1&&(j=1),j===1&&I--,I=Math.min(I,h+1),!!(I%2)&&(m==="reverse"?(j=1-j,p&&(j-=p/a)):m==="mirror"&&(O=i)),E=Qe(0,1,j)*a}const N=P?{done:!1,value:d[0]}:O.next(E);o&&(N.value=o(N.value));let{done:k}=N;!P&&l!==null&&(k=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const V=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&k);return V&&w!==Us&&(N.value=jr(d,this.options,T,this.speed)),v&&v(N.value),V&&this.finish(),N}then(t,n){return this.finished.then(t,n)}get duration(){return Ve(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ve(t)}get time(){return Ve(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=Ve(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=kc,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 Gc(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const jt=e=>e*180/Math.PI,_s=e=>{const t=jt(Math.atan2(e[1],e[0]));return Xs(t)},Yc={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:_s,rotateZ:_s,skewX:e=>jt(Math.atan(e[1])),skewY:e=>jt(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Xs=e=>(e=e%360,e<0&&(e+=360),e),oi=_s,ai=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),li=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Hc={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ai,scaleY:li,scale:e=>(ai(e)+li(e))/2,rotateX:e=>Xs(jt(Math.atan2(e[6],e[5]))),rotateY:e=>Xs(jt(Math.atan2(-e[2],e[0]))),rotateZ:oi,rotate:oi,skewX:e=>jt(Math.atan(e[4])),skewY:e=>jt(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Ws(e){return e.includes("scale")?1:0}function Ks(e,t){if(!e||e==="none")return Ws(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=Hc,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Yc,r=a}if(!r)return Ws(t);const o=s[t],i=r[1].split(",").map(Zc);return typeof o=="function"?o(i):i[o]}const Jc=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Ks(n,t)};function Zc(e){return parseFloat(e.trim())}const Gt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Yt=new Set(Gt),ci=e=>e===qt||e===B,Qc=new Set(["x","y","z"]),eu=Gt.filter(e=>!Qc.has(e));function tu(e){const t=[];return eu.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Pt={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})=>Ks(t,"x"),y:(e,{transform:t})=>Ks(t,"y")};Pt.translateX=Pt.x;Pt.translateY=Pt.y;const At=new Set;let qs=!1,Gs=!1,Ys=!1;function Ho(){if(Gs){const e=Array.from(At).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const r=tu(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)})}Gs=!1,qs=!1,At.forEach(e=>e.complete(Ys)),At.clear()}function Jo(){At.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Gs=!0)})}function nu(){Ys=!0,Jo(),Ho(),Ys=!1}class Mr{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?(At.add(this),qs||(qs=!0,ae.read(Jo),ae.resolveKeyframes(Ho))):(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])}Gc(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),At.delete(this)}cancel(){this.state==="scheduled"&&(At.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const su=e=>e.startsWith("--");function ru(e,t,n){su(t)?e.style.setProperty(t,n):e.style[t]=n}const iu=mr(()=>window.ScrollTimeline!==void 0),ou={};function au(e,t){const n=mr(e);return()=>ou[t]??n()}const Zo=au(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),xn=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,ui={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:xn([0,.65,.55,1]),circOut:xn([.55,0,1,.45]),backIn:xn([.31,.01,.66,-.59]),backOut:xn([.33,1.53,.69,.99])};function Qo(e,t){if(e)return typeof e=="function"?Zo()?qo(e,t):"ease-out":Lo(e)?xn(e):Array.isArray(e)?e.map(n=>Qo(n,t)||ui.easeOut):ui[e]}function lu(e,t,n,{delay:s=0,duration:r=300,repeat:o=0,repeatType:i="loop",ease:a="easeOut",times:l}={},u=void 0){const d={[t]:n};l&&(d.offset=l);const h=Qo(a,r);Array.isArray(h)&&(d.easing=h);const m={delay:s,duration:r,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:o+1,direction:i==="reverse"?"alternate":"normal"};return u&&(m.pseudoElement=u),e.animate(d,m)}function ea(e){return typeof e=="function"&&"applyToOptions"in e}function cu({type:e,...t}){return ea(e)&&Zo()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class uu extends Pr{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,et(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=cu(t);this.animation=lu(n,s,r,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=jr(r,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):ru(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 Ve(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ve(t)}get time(){return Ve(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&&iu()?(this.animation.timeline=t,Ie):n(this)}}const ta={anticipate:Ro,backInOut:Do,circInOut:Io};function du(e){return e in ta}function hu(e){typeof e.ease=="string"&&du(e.ease)&&(e.ease=ta[e.ease])}const di=10;class fu extends uu{constructor(t){hu(t),Yo(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 Ar({...i,autoplay:!1}),l=Xe(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-di).value,a.sample(l).value,di),a.stop()}}const hi=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(ut.test(e)||e==="0")&&!e.startsWith("url("));function mu(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 pu(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=hi(r,t),a=hi(o,t);return Kt(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:mu(e)||(n==="spring"||ea(n))&&s}function Hs(e){e.duration=0,e.type="keyframes"}const gu=new Set(["opacity","clipPath","filter","transform"]),yu=mr(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function xu(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:u}=t.owner.getProps();return yu()&&n&&gu.has(n)&&(n!=="transform"||!u)&&!l&&!s&&r!=="mirror"&&o!==0&&i!=="inertia"}const bu=40;class vu extends Pr{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:i="loop",keyframes:a,name:l,motionValue:u,element:d,...h}){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:u,element:d,...h},p=d?.KeyframeResolver||Mr;this.keyframeResolver=new p(a,(w,v,T)=>this.onKeyframesResolved(w,v,m,!T),l,u,d),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,s,r){this.keyframeResolver=void 0;const{name:o,type:i,velocity:a,delay:l,isHandoff:u,onUpdate:d}=s;this.resolvedAt=Me.now(),pu(t,o,i,a)||((tt.instantAnimations||!l)&&d?.(jr(t,s,n)),t[0]=t[t.length-1],Hs(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>bu?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!u&&xu(m)?new fu({...m,element:m.motionValue.owner.current}):new Ar(m);p.finished.then(()=>this.notifyFinished()).catch(Ie),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(),nu()),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 wu=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Su(e){const t=wu.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}const Tu=4;function na(e,t,n=1){et(n<=Tu,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=Su(e);if(!s)return;const o=window.getComputedStyle(t).getPropertyValue(s);if(o){const i=o.trim();return Co(i)?parseFloat(i):i}return vr(r)?na(r,t,n+1):r}function Er(e,t){return e?.[t]??e?.default??e}const sa=new Set(["width","height","top","left","right","bottom",...Gt]),Cu={test:e=>e==="auto",parse:e=>e},ra=e=>t=>t.test(e),ia=[qt,B,He,lt,mc,fc,Cu],fi=e=>ia.find(ra(e));function ju(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Po(e):!0}const Pu=new Set(["brightness","contrast","saturate","opacity"]);function Au(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(wr)||[];if(!s)return e;const r=n.replace(s,"");let o=Pu.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+r+")"}const Mu=/\b([a-z-]*)\(.*?\)/gu,Js={...ut,getAnimatableNone:e=>{const t=e.match(Mu);return t?t.map(Au).join(" "):e}},mi={...qt,transform:Math.round},Eu={rotate:lt,rotateX:lt,rotateY:lt,rotateZ:lt,scale:Wn,scaleX:Wn,scaleY:Wn,scaleZ:Wn,skew:lt,skewX:lt,skewY:lt,distance:B,translateX:B,translateY:B,translateZ:B,x:B,y:B,z:B,perspective:B,transformPerspective:B,opacity:Pn,originX:ti,originY:ti,originZ:B},kr={borderWidth:B,borderTopWidth:B,borderRightWidth:B,borderBottomWidth:B,borderLeftWidth:B,borderRadius:B,radius:B,borderTopLeftRadius:B,borderTopRightRadius:B,borderBottomRightRadius:B,borderBottomLeftRadius:B,width:B,maxWidth:B,height:B,maxHeight:B,top:B,right:B,bottom:B,left:B,padding:B,paddingTop:B,paddingRight:B,paddingBottom:B,paddingLeft:B,margin:B,marginTop:B,marginRight:B,marginBottom:B,marginLeft:B,backgroundPositionX:B,backgroundPositionY:B,...Eu,zIndex:mi,fillOpacity:Pn,strokeOpacity:Pn,numOctaves:mi},ku={...kr,color:he,backgroundColor:he,outlineColor:he,fill:he,stroke:he,borderColor:he,borderTopColor:he,borderRightColor:he,borderBottomColor:he,borderLeftColor:he,filter:Js,WebkitFilter:Js},oa=e=>ku[e];function aa(e,t){let n=oa(e);return n!==Js&&(n=ut),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Nu=new Set(["auto","none","0"]);function Du(e,t,n){let s=0,r;for(;s<e.length&&!r;){const o=e[s];typeof o=="string"&&!Nu.has(o)&&An(o).values.length&&(r=e[s]),s++}if(r&&n)for(const o of t)e[o]=aa(n,r)}class Ru extends Mr{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 u=t[l];if(typeof u=="string"&&(u=u.trim(),vr(u))){const d=na(u,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!sa.has(s)||t.length!==2)return;const[r,o]=t,i=fi(r),a=fi(o);if(i!==a)if(ci(i)&&ci(a))for(let l=0;l<t.length;l++){const u=t[l];typeof u=="string"&&(t[l]=parseFloat(u))}else Pt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||ju(t[r]))&&s.push(r);s.length&&Du(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=Pt[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]=Pt[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 Vu(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 la=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function ca(e){return jo(e)&&"offsetHeight"in e}const pi=30,Iu=e=>!isNaN(parseFloat(e));class Ou{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=Iu(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&gr(!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 pr);const s=this.events[t].add(n);return t==="change"?()=>{s(),ae.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>pi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,pi);return Ao(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 Xt(e,t){return new Ou(e,t)}const{schedule:Nr}=Fo(queueMicrotask,!1),Ue={x:!1,y:!1};function ua(){return Ue.x||Ue.y}function Lu(e){return e==="x"||e==="y"?Ue[e]?null:(Ue[e]=!0,()=>{Ue[e]=!1}):Ue.x||Ue.y?null:(Ue.x=Ue.y=!0,()=>{Ue.x=Ue.y=!1})}function da(e,t){const n=Vu(e),s=new AbortController,r={passive:!0,...t,signal:s.signal};return[n,r,()=>s.abort()]}function gi(e){return!(e.pointerType==="touch"||ua())}function Fu(e,t,n={}){const[s,r,o]=da(e,n),i=a=>{if(!gi(a))return;const{target:l}=a,u=t(l,a);if(typeof u!="function"||!l)return;const d=h=>{gi(h)&&(u(h),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return s.forEach(a=>{a.addEventListener("pointerenter",i,r)}),o}const ha=(e,t)=>t?e===t?!0:ha(e,t.parentElement):!1,Dr=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,$u=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Bu(e){return $u.has(e.tagName)||e.tabIndex!==-1}const Zn=new WeakSet;function yi(e){return t=>{t.key==="Enter"&&e(t)}}function js(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const zu=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=yi(()=>{if(Zn.has(n))return;js(n,"down");const r=yi(()=>{js(n,"up")}),o=()=>js(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 xi(e){return Dr(e)&&!ua()}function Uu(e,t,n={}){const[s,r,o]=da(e,n),i=a=>{const l=a.currentTarget;if(!xi(a))return;Zn.add(l);const u=t(l,a),d=(p,w)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",m),Zn.has(l)&&Zn.delete(l),xi(p)&&typeof u=="function"&&u(p,{success:w})},h=p=>{d(p,l===window||l===document||n.useGlobalTarget||ha(l,p.target))},m=p=>{d(p,!1)};window.addEventListener("pointerup",h,r),window.addEventListener("pointercancel",m,r)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",i,r),ca(a)&&(a.addEventListener("focus",u=>zu(u,r)),!Bu(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function fa(e){return jo(e)&&"ownerSVGElement"in e}function _u(e){return fa(e)&&e.tagName==="svg"}const we=e=>!!(e&&e.getVelocity),Xu=[...ia,he,ut],Wu=e=>Xu.find(ra(e)),Rr=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function bi(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ku(...e){return t=>{let n=!1;const s=e.map(r=>{const o=bi(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():bi(e[r],null)}}}}function qu(...e){return _e.useCallback(Ku(...e),e)}class Gu extends _e.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,r=ca(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 Yu({children:e,isPresent:t,anchorX:n,root:s}){const r=f.useId(),o=f.useRef(null),i=f.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=f.useContext(Rr),l=qu(o,e?.ref);return f.useInsertionEffect(()=>{const{width:u,height:d,top:h,left:m,right:p}=i.current;if(t||!o.current||!u||!d)return;const w=n==="left"?`left: ${m}`:`right: ${p}`;o.current.dataset.motionPopId=r;const v=document.createElement("style");a&&(v.nonce=a);const T=s??document.head;return T.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
12
12
|
[data-motion-pop-id="${r}"] {
|
|
13
13
|
position: absolute !important;
|
|
14
14
|
width: ${u}px !important;
|
|
15
15
|
height: ${d}px !important;
|
|
16
|
-
${
|
|
16
|
+
${w}px !important;
|
|
17
17
|
top: ${h}px !important;
|
|
18
18
|
}
|
|
19
|
-
`),()=>{T.contains(w)&&T.removeChild(w)}},[t]),c.jsx(Wu,{isPresent:t,childRef:o,sizeRef:i,children:$e.cloneElement(e,{ref:l})})}const qu=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:o,mode:i,anchorX:a,root:l})=>{const u=ar(Gu),d=f.useId();let h=!0,m=f.useMemo(()=>(h=!1,{id:d,initial:t,isPresent:n,custom:r,onExitComplete:p=>{u.set(p,!0);for(const S of u.values())if(!S)return;s&&s()},register:p=>(u.set(p,!1),()=>u.delete(p))}),[n,u,s]);return o&&h&&(m={...m}),f.useMemo(()=>{u.forEach((p,S)=>u.set(S,!1))},[n]),$e.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),i==="popLayout"&&(e=c.jsx(Ku,{isPresent:n,anchorX:a,root:l,children:e})),c.jsx(rs.Provider,{value:m,children:e})};function Gu(){return new Map}function da(e=!0){const t=f.useContext(rs);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:r}=t,o=f.useId();f.useEffect(()=>{if(e)return r(o)},[e]);const i=f.useCallback(()=>e&&s&&s(o),[o,s,e]);return!n&&s?[!1,i]:[!0]}const Un=e=>e.key||"";function yi(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const Yu=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:o="sync",propagate:i=!1,anchorX:a="left",root:l})=>{const[u,d]=da(i),h=f.useMemo(()=>yi(e),[e]),m=i&&!u?[]:h.map(Un),p=f.useRef(!0),S=f.useRef(h),w=ar(()=>new Map),[T,x]=f.useState(h),[P,E]=f.useState(h);vo(()=>{p.current=!1,S.current=h;for(let k=0;k<P.length;k++){const I=Un(P[k]);m.includes(I)?w.delete(I):w.get(I)!==!0&&w.set(I,!1)}},[P,m.length,m.join("-")]);const L=[];if(h!==T){let k=[...h];for(let I=0;I<P.length;I++){const A=P[I],O=Un(A);m.includes(O)||(k.splice(I,0,A),L.push(A))}return o==="wait"&&L.length&&(k=L),E(yi(k)),x(h),null}process.env.NODE_ENV!=="production"&&o==="wait"&&P.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:N}=f.useContext(or);return c.jsx(c.Fragment,{children:P.map(k=>{const I=Un(k),A=i&&!u?!1:h===P||m.includes(I),O=()=>{if(w.has(I))w.set(I,!0);else return;let j=!0;w.forEach(R=>{R||(j=!1)}),j&&(N?.(),E(S.current),i&&d?.(),s&&s())};return c.jsx(qu,{isPresent:A,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:o,root:l,onExitComplete:A?void 0:O,anchorX:a,children:k},I)})})},Nr=f.createContext({strict:!1}),xi={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},zt={};for(const e in xi)zt[e]={isEnabled:t=>xi[e].some(n=>!!t[n])};function Ys(e){for(const t in e)zt[t]={...zt[t],...e[t]}}function Hu({children:e,features:t,strict:n=!1}){const[,s]=f.useState(!Ts(t)),r=f.useRef(void 0);if(!Ts(t)){const{renderer:o,...i}=t;r.current=o,Ys(i)}return f.useEffect(()=>{Ts(t)&&t().then(({renderer:o,...i})=>{Ys(i),r.current=o,s(!0)})},[]),c.jsx(Nr.Provider,{value:{renderer:r.current,strict:n},children:e})}function Ts(e){return typeof e=="function"}const Ju=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function ts(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Ju.has(e)}let ha=e=>!ts(e);function Zu(e){typeof e=="function"&&(ha=t=>t.startsWith("on")?!ts(t):e(t))}try{Zu(require("@emotion/is-prop-valid").default)}catch{}function Qu(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||(ha(r)||n===!0&&ts(r)||!t&&!ts(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const is=f.createContext({});function os(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Cn(e){return typeof e=="string"||Array.isArray(e)}const Dr=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Rr=["initial",...Dr];function as(e){return os(e.animate)||Rr.some(t=>Cn(e[t]))}function fa(e){return!!(as(e)||e.variants)}function ed(e,t){if(as(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Cn(n)?n:void 0,animate:Cn(s)?s:void 0}}return e.inherit!==!1?t:{}}function td(e){const{initial:t,animate:n}=ed(e,f.useContext(is));return f.useMemo(()=>({initial:t,animate:n}),[bi(t),bi(n)])}function bi(e){return Array.isArray(e)?e.join(" "):e}const jn={};function nd(e){for(const t in e)jn[t]=e[t],gr(t)&&(jn[t].isCSSVariable=!0)}function ma(e,{layout:t,layoutId:n}){return Wt.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!jn[e]||e==="opacity")}const sd={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},rd=Xt.length;function id(e,t,n){let s="",r=!0;for(let o=0;o<rd;o++){const i=Xt[o],a=e[i];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(i.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=ia(a,Ar[i]);if(!l){r=!1;const d=sd[i]||i;s+=`${d}(${u}) `}n&&(t[i]=u)}}return s=s.trim(),n?s=n(t,r?"":s):r&&(s="none"),s}function Vr(e,t,n){const{style:s,vars:r,transformOrigin:o}=e;let i=!1,a=!1;for(const l in t){const u=t[l];if(Wt.has(l)){i=!0;continue}else if(gr(l)){r[l]=u;continue}else{const d=ia(u,Ar[l]);l.startsWith("origin")?(a=!0,o[l]=d):s[l]=d}}if(t.transform||(i||n?s.transform=id(t,e.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:d=0}=o;s.transformOrigin=`${l} ${u} ${d}`}}const Ir=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function pa(e,t,n){for(const s in t)!be(t[s])&&!ma(s,n)&&(e[s]=t[s])}function od({transformTemplate:e},t){return f.useMemo(()=>{const n=Ir();return Vr(n,t,e),Object.assign({},n.vars,n.style)},[t])}function ad(e,t){const n=e.style||{},s={};return pa(s,n,e),Object.assign(s,od(e,t)),s}function ld(e,t){const n={},s=ad(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const cd={offset:"stroke-dashoffset",array:"stroke-dasharray"},ud={offset:"strokeDashoffset",array:"strokeDasharray"};function dd(e,t,n=1,s=0,r=!0){e.pathLength=1;const o=r?cd:ud;e[o.offset]=U.transform(-s);const i=U.transform(t),a=U.transform(n);e[o.array]=`${i} ${a}`}function ga(e,{attrX:t,attrY:n,attrScale:s,pathLength:r,pathSpacing:o=1,pathOffset:i=0,...a},l,u,d){if(Vr(e,a,u),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:h,style:m}=e;h.transform&&(m.transform=h.transform,delete h.transform),(m.transform||h.transformOrigin)&&(m.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),m.transform&&(m.transformBox=d?.transformBox??"fill-box",delete h.transformBox),t!==void 0&&(h.x=t),n!==void 0&&(h.y=n),s!==void 0&&(h.scale=s),r!==void 0&&dd(h,r,o,i,!1)}const ya=()=>({...Ir(),attrs:{}}),xa=e=>typeof e=="string"&&e.toLowerCase()==="svg";function hd(e,t,n,s){const r=f.useMemo(()=>{const o=ya();return ga(o,t,xa(s),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};pa(o,e.style,e),r.style={...o,...r.style}}return r}const fd=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Or(e){return typeof e!="string"||e.includes("-")?!1:!!(fd.indexOf(e)>-1||/[A-Z]/u.test(e))}function md(e,t,n,{latestValues:s},r,o=!1){const a=(Or(e)?hd:ld)(t,s,r,e),l=Qu(t,typeof e=="string",o),u=e!==f.Fragment?{...l,...a,ref:n}:{},{children:d}=t,h=f.useMemo(()=>be(d)?d.get():d,[d]);return f.createElement(e,{...u,children:h})}function vi(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Lr(e,t,n,s){if(typeof t=="function"){const[r,o]=vi(s);t=t(n!==void 0?n:e.custom,r,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[r,o]=vi(s);t=t(n!==void 0?n:e.custom,r,o)}return t}function Yn(e){return be(e)?e.get():e}function pd({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:gd(n,s,r,e),renderState:t()}}function gd(e,t,n,s){const r={},o=s(e,{});for(const m in o)r[m]=Yn(o[m]);let{initial:i,animate:a}=e;const l=as(e),u=fa(e);t&&u&&!l&&e.inherit!==!1&&(i===void 0&&(i=t.initial),a===void 0&&(a=t.animate));let d=n?n.initial===!1:!1;d=d||i===!1;const h=d?a:i;if(h&&typeof h!="boolean"&&!os(h)){const m=Array.isArray(h)?h:[h];for(let p=0;p<m.length;p++){const S=Lr(e,m[p]);if(S){const{transitionEnd:w,transition:T,...x}=S;for(const P in x){let E=x[P];if(Array.isArray(E)){const L=d?E.length-1:0;E=E[L]}E!==null&&(r[P]=E)}for(const P in w)r[P]=w[P]}}}return r}const ba=e=>(t,n)=>{const s=f.useContext(is),r=f.useContext(rs),o=()=>pd(e,t,s,r);return n?o():ar(o)};function Fr(e,t,n){const{style:s}=e,r={};for(const o in s)(be(s[o])||t.style&&be(t.style[o])||ma(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(r[o]=s[o]);return r}const yd=ba({scrapeMotionValuesFromProps:Fr,createRenderState:Ir});function va(e,t,n){const s=Fr(e,t,n);for(const r in e)if(be(e[r])||be(t[r])){const o=Xt.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;s[o]=e[r]}return s}const xd=ba({scrapeMotionValuesFromProps:va,createRenderState:ya}),bd=Symbol.for("motionComponentSymbol");function Vt(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function vd(e,t,n){return f.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):Vt(n)&&(n.current=s))},[t])}const $r=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),wd="framerAppearId",wa="data-"+$r(wd),Sa=f.createContext({});function Sd(e,t,n,s,r){const{visualElement:o}=f.useContext(is),i=f.useContext(Nr),a=f.useContext(rs),l=f.useContext(kr).reducedMotion,u=f.useRef(null);s=s||i.renderer,!u.current&&s&&(u.current=s(e,{visualState:t,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const d=u.current,h=f.useContext(Sa);d&&!d.projection&&r&&(d.type==="html"||d.type==="svg")&&Td(u.current,n,r,h);const m=f.useRef(!1);f.useInsertionEffect(()=>{d&&m.current&&d.update(n,a)});const p=n[wa],S=f.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return vo(()=>{d&&(m.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),d.scheduleRenderMicrotask(),S.current&&d.animationState&&d.animationState.animateChanges())}),f.useEffect(()=>{d&&(!S.current&&d.animationState&&d.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(p)}),S.current=!1),d.enteringChildren=void 0)}),d}function Td(e,t,n,s){const{layoutId:r,layout:o,drag:i,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Ta(e.parent)),e.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!i||a&&Vt(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:d,layoutScroll:l,layoutRoot:u})}function Ta(e){if(e)return e.options.allowProjection!==!1?e.projection:Ta(e.parent)}function Hn(e,{forwardMotionProps:t=!1}={},n,s){n&&Ys(n);const r=Or(e)?xd:yd;function o(a,l){let u;const d={...f.useContext(kr),...a,layoutId:Cd(a)},{isStatic:h}=d,m=td(a),p=r(a,h);if(!h&&lr){jd(d,n);const S=Pd(d);u=S.MeasureLayout,m.visualElement=Sd(e,p,d,s,S.ProjectionNode)}return c.jsxs(is.Provider,{value:m,children:[u&&m.visualElement?c.jsx(u,{visualElement:m.visualElement,...d}):null,md(e,a,vd(p,m.visualElement,l),p,h,t)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const i=f.forwardRef(o);return i[bd]=e,i}function Cd({layoutId:e}){const t=f.useContext(or).id;return t&&e!==void 0?t+"-"+e:e}function jd(e,t){const n=f.useContext(Nr).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Ut(!1,s,"lazy-strict-mode"):Ye(!1,s,"lazy-strict-mode")}}function Pd(e){const{drag:t,layout:n}=zt;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Ad(e,t){if(typeof Proxy>"u")return Hn;const n=new Map,s=(o,i)=>Hn(o,i,e,t),r=(o,i)=>(process.env.NODE_ENV!=="production"&&fr(!1,"motion() is deprecated. Use motion.create() instead."),s(o,i));return new Proxy(r,{get:(o,i)=>i==="create"?s:(n.has(i)||n.set(i,Hn(i,void 0,e,t)),n.get(i))})}function Ca({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Md({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Ed(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Cs(e){return e===void 0||e===1}function Hs({scale:e,scaleX:t,scaleY:n}){return!Cs(e)||!Cs(t)||!Cs(n)}function xt(e){return Hs(e)||ja(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function ja(e){return wi(e.x)||wi(e.y)}function wi(e){return e&&e!=="0%"}function ns(e,t,n){const s=e-n,r=t*s;return n+r}function Si(e,t,n,s,r){return r!==void 0&&(e=ns(e,r,s)),ns(e,n,s)+t}function Js(e,t=0,n=1,s,r){e.min=Si(e.min,t,n,s,r),e.max=Si(e.max,t,n,s,r)}function Pa(e,{x:t,y:n}){Js(e.x,t.translate,t.scale,t.originPoint),Js(e.y,n.translate,n.scale,n.originPoint)}const Ti=.999999999999,Ci=1.0000000000001;function kd(e,t,n,s=!1){const r=n.length;if(!r)return;t.x=t.y=1;let o,i;for(let a=0;a<r;a++){o=n[a],i=o.projectionDelta;const{visualElement:l}=o.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&Ot(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Pa(e,i)),s&&xt(o.latestValues)&&Ot(e,o.latestValues))}t.x<Ci&&t.x>Ti&&(t.x=1),t.y<Ci&&t.y>Ti&&(t.y=1)}function It(e,t){e.min=e.min+t,e.max=e.max+t}function ji(e,t,n,s,r=.5){const o=ce(e.min,e.max,r);Js(e,t,n,o,s)}function Ot(e,t){ji(e.x,t.x,t.scaleX,t.scale,t.originX),ji(e.y,t.y,t.scaleY,t.scale,t.originY)}function Aa(e,t){return Ca(Ed(e.getBoundingClientRect(),t))}function Nd(e,t,n){const s=Aa(e,n),{scroll:r}=t;return r&&(It(s.x,r.offset.x),It(s.y,r.offset.y)),s}const Pi=()=>({translate:0,scale:1,origin:0,originPoint:0}),Lt=()=>({x:Pi(),y:Pi()}),Ai=()=>({min:0,max:0}),ue=()=>({x:Ai(),y:Ai()}),Zs={current:null},Ma={current:!1};function Dd(){if(Ma.current=!0,!!lr)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Zs.current=e.matches;e.addEventListener("change",t),t()}else Zs.current=!1}const Rd=new WeakMap;function Vd(e,t,n){for(const s in t){const r=t[s],o=n[s];if(be(r))e.addValue(s,r);else if(be(o))e.addValue(s,Bt(r,{owner:e}));else if(o!==r)if(e.hasValue(s)){const i=e.getValue(s);i.liveStyle===!0?i.jump(r):i.hasAnimated||i.set(r)}else{const i=e.getStaticValue(s);e.addValue(s,Bt(i!==void 0?i:r,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Mi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Id{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:r,blockInitialAnimation:o,visualState:i},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=jr,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=Ce.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,ae.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=i;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=as(n),this.isVariantNode=fa(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:d,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in h){const p=h[m];l[m]!==void 0&&be(p)&&p.set(l[m])}}mount(t){this.current=t,Rd.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Ma.current||Dd(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Zs.current,process.env.NODE_ENV!=="production"&&fr(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),rt(this.notifyUpdate),rt(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=Wt.has(t);s&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",i=>{this.latestValues[t]=i,this.props.onUpdate&&ae.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{r(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in zt){const n=zt[t];if(!n)continue;const{isEnabled:s,Feature:r}=n;if(!this.features[t]&&r&&s(this.props)&&(this.features[t]=new r(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):ue()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Mi.length;s++){const r=Mi[s];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const o="on"+r,i=t[o];i&&(this.propEventSubscriptions[r]=this.on(r,i))}this.prevMotionValues=Vd(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=Bt(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(wo(s)||To(s))?s=parseFloat(s):!Uu(s)&&it.test(n)&&(s=ra(t,n)),this.setBaseTarget(t,be(s)?s.get():s)),be(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=Lr(this.props,n,this.presenceContext?.custom);o&&(s=o[t])}if(n&&s!==void 0)return s;const r=this.getBaseTargetFromProps(this.props,t);return r!==void 0&&!be(r)?r:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new hr),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Mr.render(this.render)}}class Ea extends Id{constructor(){super(...arguments),this.KeyframeResolver=ku}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;be(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function ka(e,{style:t,vars:n},s,r){const o=e.style;let i;for(i in t)o[i]=t[i];r?.applyProjectionStyles(o,s);for(i in n)o.setProperty(i,n[i])}function Od(e){return window.getComputedStyle(e)}class Ld extends Ea{constructor(){super(...arguments),this.type="html",this.renderInstance=ka}readValueFromInstance(t,n){if(Wt.has(n))return this.projection?.isProjecting?Us(n):Gc(t,n);{const s=Od(t),r=(gr(n)?s.getPropertyValue(n):s[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Aa(t,n)}build(t,n,s){Vr(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return Fr(t,n,s)}}const Na=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Fd(e,t,n,s){ka(e,t,void 0,s);for(const r in t.attrs)e.setAttribute(Na.has(r)?r:$r(r),t.attrs[r])}class $d extends Ea{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=ue}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Wt.has(n)){const s=sa(n);return s&&s.default||0}return n=Na.has(n)?n:$r(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return va(t,n,s)}build(t,n,s){ga(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,r){Fd(t,n,s,r)}mount(t){this.isSVGTag=xa(t.tagName),super.mount(t)}}const Da=(e,t)=>Or(e)?new $d(t):new Ld(t,{allowProjection:e!==f.Fragment});function $t(e,t,n){const s=e.getProps();return Lr(s,t,n!==void 0?n:s.custom,e)}const Qs=e=>Array.isArray(e);function Bd(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Bt(n))}function zd(e){return Qs(e)?e[e.length-1]||0:e}function Ud(e,t){const n=$t(e,t);let{transitionEnd:s={},transition:r={},...o}=n||{};o={...o,...s};for(const i in o){const a=zd(o[i]);Bd(e,i,a)}}function _d(e){return!!(be(e)&&e.add)}function er(e,t){const n=e.getValue("willChange");if(_d(n))return n.add(t);if(!n&&He.WillChange){const s=new He.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function Ra(e){return e.props[wa]}const Xd=e=>e!==null;function Wd(e,{repeat:t,repeatType:n="loop"},s){const r=e.filter(Xd),o=t&&n!=="loop"&&t%2===1?0:r.length-1;return r[o]}const Kd={type:"spring",stiffness:500,damping:25,restSpeed:10},qd=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Gd={type:"keyframes",duration:.8},Yd={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Hd=(e,{keyframes:t})=>t.length>2?Gd:Wt.has(e)?e.startsWith("scale")?qd(t[1]):Kd:Yd;function Jd({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:r,repeat:o,repeatType:i,repeatDelay:a,from:l,elapsed:u,...d}){return!!Object.keys(d).length}const Br=(e,t,n,s={},r,o)=>i=>{const a=Pr(s,e)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-Be(l);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-u,onUpdate:m=>{t.set(m),a.onUpdate&&a.onUpdate(m)},onComplete:()=>{i(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:o?void 0:r};Jd(a)||Object.assign(d,Hd(e,d)),d.duration&&(d.duration=Be(d.duration)),d.repeatDelay&&(d.repeatDelay=Be(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let h=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(qs(d),d.delay===0&&(h=!0)),(He.instantAnimations||He.skipAnimations)&&(h=!0,qs(d),d.delay=0),d.allowFlatten=!a.type&&!a.ease,h&&!o&&t.get()!==void 0){const m=Wd(d.keyframes,a);if(m!==void 0){ae.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new Cr(d):new yu(d)};function Zd({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function Va(e,t,{delay:n=0,transitionOverride:s,type:r}={}){let{transition:o=e.getDefaultTransition(),transitionEnd:i,...a}=t;s&&(o=s);const l=[],u=r&&e.animationState&&e.animationState.getState()[r];for(const d in a){const h=e.getValue(d,e.latestValues[d]??null),m=a[d];if(m===void 0||u&&Zd(u,d))continue;const p={delay:n,...Pr(o||{},d)},S=h.get();if(S!==void 0&&!h.isAnimating&&!Array.isArray(m)&&m===S&&!p.velocity)continue;let w=!1;if(window.MotionHandoffAnimation){const x=Ra(e);if(x){const P=window.MotionHandoffAnimation(x,d,ae);P!==null&&(p.startTime=P,w=!0)}}er(e,d),h.start(Br(d,h,m,e.shouldReduceMotion&&ea.has(d)?{type:!1}:p,e,w));const T=h.animation;T&&l.push(T)}return i&&Promise.all(l).then(()=>{ae.update(()=>{i&&Ud(e,i)})}),l}function Ia(e,t,n,s=0,r=1){const o=Array.from(e).sort((u,d)=>u.sortNodePosition(d)).indexOf(t),i=e.size,a=(i-1)*s;return typeof n=="function"?n(o,i):r===1?o*s:a-o*s}function tr(e,t,n={}){const s=$t(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:r=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(r=n.transitionOverride);const o=s?()=>Promise.all(Va(e,s,n)):()=>Promise.resolve(),i=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:d,staggerDirection:h}=r;return Qd(e,t,l,u,d,h,n)}:()=>Promise.resolve(),{when:a}=r;if(a){const[l,u]=a==="beforeChildren"?[o,i]:[i,o];return l().then(()=>u())}else return Promise.all([o(),i(n.delay)])}function Qd(e,t,n=0,s=0,r=0,o=1,i){const a=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),a.push(tr(l,t,{...i,delay:n+(typeof s=="function"?0:s)+Ia(e.variantChildren,l,s,r,o)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function eh(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const r=t.map(o=>tr(e,o,n));s=Promise.all(r)}else if(typeof t=="string")s=tr(e,t,n);else{const r=typeof t=="function"?$t(e,t,n.custom):t;s=Promise.all(Va(e,r,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function Oa(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}const th=Rr.length;function La(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?La(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<th;n++){const s=Rr[n],r=e.props[s];(Cn(r)||r===!1)&&(t[s]=r)}return t}const nh=[...Dr].reverse(),sh=Dr.length;function rh(e){return t=>Promise.all(t.map(({animation:n,options:s})=>eh(e,n,s)))}function ih(e){let t=rh(e),n=Ei(),s=!0;const r=l=>(u,d)=>{const h=$t(e,d,l==="exit"?e.presenceContext?.custom:void 0);if(h){const{transition:m,transitionEnd:p,...S}=h;u={...u,...S,...p}}return u};function o(l){t=l(e)}function i(l){const{props:u}=e,d=La(e.parent)||{},h=[],m=new Set;let p={},S=1/0;for(let T=0;T<sh;T++){const x=nh[T],P=n[x],E=u[x]!==void 0?u[x]:d[x],L=Cn(E),N=x===l?P.isActive:null;N===!1&&(S=T);let k=E===d[x]&&E!==u[x]&&L;if(k&&s&&e.manuallyAnimateOnMount&&(k=!1),P.protectedKeys={...p},!P.isActive&&N===null||!E&&!P.prevProp||os(E)||typeof E=="boolean")continue;const I=oh(P.prevProp,E);let A=I||x===l&&P.isActive&&!k&&L||T>S&&L,O=!1;const j=Array.isArray(E)?E:[E];let R=j.reduce(r(x),{});N===!1&&(R={});const{prevResolvedValues:F={}}=P,D={...F,...R},$=G=>{A=!0,m.has(G)&&(O=!0,m.delete(G)),P.needsAnimating[G]=!0;const se=e.getValue(G);se&&(se.liveStyle=!1)};for(const G in D){const se=R[G],fe=F[G];if(p.hasOwnProperty(G))continue;let ge=!1;Qs(se)&&Qs(fe)?ge=!Oa(se,fe):ge=se!==fe,ge?se!=null?$(G):m.add(G):se!==void 0&&m.has(G)?$(G):P.protectedKeys[G]=!0}P.prevProp=E,P.prevResolvedValues=R,P.isActive&&(p={...p,...R}),s&&e.blockInitialAnimation&&(A=!1);const J=k&&I;A&&(!J||O)&&h.push(...j.map(G=>{const se={type:x};if(typeof G=="string"&&s&&!J&&e.manuallyAnimateOnMount&&e.parent){const{parent:fe}=e,ge=$t(fe,G);if(fe.enteringChildren&&ge){const{delayChildren:B}=ge.transition||{};se.delay=Ia(fe.enteringChildren,e,B)}}return{animation:G,options:se}}))}if(m.size){const T={};if(typeof u.initial!="boolean"){const x=$t(e,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(T.transition=x.transition)}m.forEach(x=>{const P=e.getBaseTarget(x),E=e.getValue(x);E&&(E.liveStyle=!0),T[x]=P??null}),h.push({animation:T})}let w=!!h.length;return s&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(w=!1),s=!1,w?t(h):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();e.variantChildren?.forEach(h=>h.animationState?.setActive(l,u)),n[l].isActive=u;const d=i(l);for(const h in n)n[h].protectedKeys={};return d}return{animateChanges:i,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Ei()}}}function oh(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Oa(t,e):!1}function gt(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Ei(){return{animate:gt(!0),whileInView:gt(),whileHover:gt(),whileTap:gt(),whileDrag:gt(),whileFocus:gt(),exit:gt()}}class ot{constructor(t){this.isMounted=!1,this.node=t}update(){}}class ah extends ot{constructor(t){super(t),t.animationState||(t.animationState=ih(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();os(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let lh=0;class ch extends ot{constructor(){super(...arguments),this.id=lh++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Fa={animation:{Feature:ah},exit:{Feature:ch}};function Pn(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function kn(e){return{point:{x:e.pageX,y:e.pageY}}}const uh=e=>t=>Er(t)&&e(t,kn(t));function yn(e,t,n,s){return Pn(e,t,uh(n),s)}const $a=1e-4,dh=1-$a,hh=1+$a,Ba=.01,fh=0-Ba,mh=0+Ba;function Se(e){return e.max-e.min}function ph(e,t,n){return Math.abs(e-t)<=n}function ki(e,t,n,s=.5){e.origin=s,e.originPoint=ce(t.min,t.max,e.origin),e.scale=Se(n)/Se(t),e.translate=ce(n.min,n.max,e.origin)-e.originPoint,(e.scale>=dh&&e.scale<=hh||isNaN(e.scale))&&(e.scale=1),(e.translate>=fh&&e.translate<=mh||isNaN(e.translate))&&(e.translate=0)}function xn(e,t,n,s){ki(e.x,t.x,n.x,s?s.originX:void 0),ki(e.y,t.y,n.y,s?s.originY:void 0)}function Ni(e,t,n){e.min=n.min+t.min,e.max=e.min+Se(t)}function gh(e,t,n){Ni(e.x,t.x,n.x),Ni(e.y,t.y,n.y)}function Di(e,t,n){e.min=t.min-n.min,e.max=e.min+Se(t)}function bn(e,t,n){Di(e.x,t.x,n.x),Di(e.y,t.y,n.y)}function Ee(e){return[e("x"),e("y")]}const za=({current:e})=>e?e.ownerDocument.defaultView:null,Ri=(e,t)=>Math.abs(e-t);function yh(e,t){const n=Ri(e.x,t.x),s=Ri(e.y,t.y);return Math.sqrt(n**2+s**2)}class Ua{constructor(t,n,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:o=!1,distanceThreshold:i=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const m=Ps(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,S=yh(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!S)return;const{point:w}=m,{timestamp:T}=pe;this.history.push({...w,timestamp:T});const{onStart:x,onMove:P}=this.handlers;p||(x&&x(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),P&&P(this.lastMoveEvent,m)},this.handlePointerMove=(m,p)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=js(p,this.transformPagePoint),ae.update(this.updatePoint,!0)},this.handlePointerUp=(m,p)=>{this.end();const{onEnd:S,onSessionEnd:w,resumeAnimation:T}=this.handlers;if(this.dragSnapToOrigin&&T&&T(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=Ps(m.type==="pointercancel"?this.lastMoveEventInfo:js(p,this.transformPagePoint),this.history);this.startEvent&&S&&S(m,x),w&&w(m,x)},!Er(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=i,this.contextWindow=r||window;const a=kn(t),l=js(a,this.transformPagePoint),{point:u}=l,{timestamp:d}=pe;this.history=[{...u,timestamp:d}];const{onSessionStart:h}=n;h&&h(t,Ps(l,this.history)),this.removeListeners=An(yn(this.contextWindow,"pointermove",this.handlePointerMove),yn(this.contextWindow,"pointerup",this.handlePointerUp),yn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),rt(this.updatePoint)}}function js(e,t){return t?{point:t(e.point)}:e}function Vi(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ps({point:e},t){return{point:e,delta:Vi(e,_a(t)),offset:Vi(e,xh(t)),velocity:bh(t,.1)}}function xh(e){return e[0]}function _a(e){return e[e.length-1]}function bh(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=_a(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>Be(t)));)n--;if(!s)return{x:0,y:0};const o=Ne(r.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const i={x:(r.x-s.x)/o,y:(r.y-s.y)/o};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function vh(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?ce(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?ce(n,e,s.max):Math.min(e,n)),e}function Ii(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function wh(e,{top:t,left:n,bottom:s,right:r}){return{x:Ii(e.x,n,r),y:Ii(e.y,t,s)}}function Oi(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function Sh(e,t){return{x:Oi(e.x,t.x),y:Oi(e.y,t.y)}}function Th(e,t){let n=.5;const s=Se(e),r=Se(t);return r>s?n=wn(t.min,t.max-s,e.min):s>r&&(n=wn(e.min,e.max-r,t.min)),Ge(0,1,n)}function Ch(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const nr=.35;function jh(e=nr){return e===!1?e=0:e===!0&&(e=nr),{x:Li(e,"left","right"),y:Li(e,"top","bottom")}}function Li(e,t,n){return{min:Fi(e,t),max:Fi(e,n)}}function Fi(e,t){return typeof e=="number"?e:e[t]||0}const Ph=new WeakMap;class Ah{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ue(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const o=h=>{const{dragSnapToOrigin:m}=this.getProps();m?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(kn(h).point)},i=(h,m)=>{const{drag:p,dragPropagation:S,onDragStart:w}=this.getProps();if(p&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Vu(p),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ee(x=>{let P=this.getAxisMotionValue(x).get()||0;if(We.test(P)){const{projection:E}=this.visualElement;if(E&&E.layout){const L=E.layout.layoutBox[x];L&&(P=Se(L)*(parseFloat(P)/100))}}this.originPoint[x]=P}),w&&ae.postRender(()=>w(h,m)),er(this.visualElement,"transform");const{animationState:T}=this.visualElement;T&&T.setActive("whileDrag",!0)},a=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m;const{dragPropagation:p,dragDirectionLock:S,onDirectionLock:w,onDrag:T}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:x}=m;if(S&&this.currentDirection===null){this.currentDirection=Mh(x),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",m.point,x),this.updateAxis("y",m.point,x),this.visualElement.render(),T&&T(h,m)},l=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m,this.stop(h,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>Ee(h=>this.getAnimationState(h)==="paused"&&this.getAxisMotionValue(h).animation?.play()),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Ua(t,{onSessionStart:o,onStart:i,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:za(this.visualElement)})}stop(t,n){const s=t||this.latestPointerEvent,r=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!r||!s)return;const{velocity:i}=r;this.startAnimation(i);const{onDragEnd:a}=this.getProps();a&&ae.postRender(()=>a(s,r))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:r}=this.getProps();if(!s||!_n(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(i=vh(i,this.constraints[t],this.elastic[t])),o.set(i)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;t&&Vt(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=wh(s.layoutBox,t):this.constraints=!1,this.elastic=jh(n),r!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&Ee(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Ch(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Vt(t))return!1;const s=t.current;Ye(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=Nd(s,r.root,this.visualElement.getTransformPagePoint());let i=Sh(r.layout.layoutBox,o);if(n){const a=n(Md(i));this.hasMutatedConstraints=!!a,a&&(i=Ca(a))}return i}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=Ee(d=>{if(!_n(d,n,this.currentDirection))return;let h=l&&l[d]||{};i&&(h={min:0,max:0});const m=r?200:1e6,p=r?40:1e7,S={type:"inertia",velocity:s?t[d]:0,bounceStiffness:m,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...o,...h};return this.startAxisValueAnimation(d,S)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return er(this.visualElement,t),s.start(Br(t,s,0,n,this.visualElement,!1))}stopAnimation(){Ee(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Ee(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),r=s[n];return r||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){Ee(n=>{const{drag:s}=this.getProps();if(!_n(n,s,this.currentDirection))return;const{projection:r}=this.visualElement,o=this.getAxisMotionValue(n);if(r&&r.layout){const{min:i,max:a}=r.layout.layoutBox[n];o.set(t[n]-ce(i,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Vt(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Ee(i=>{const a=this.getAxisMotionValue(i);if(a&&this.constraints!==!1){const l=a.get();r[i]=Th({min:l,max:l},this.constraints[i])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),Ee(i=>{if(!_n(i,t,null))return;const a=this.getAxisMotionValue(i),{min:l,max:u}=this.constraints[i];a.set(ce(l,u,r[i]))})}addListeners(){if(!this.visualElement.current)return;Ph.set(this.visualElement,this);const t=this.visualElement.current,n=yn(t,"pointerdown",l=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Vt(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,o=r.addEventListener("measure",s);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),ae.read(s);const i=Pn(window,"resize",()=>this.scalePositionWithinConstraints()),a=r.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(Ee(d=>{const h=this.getAxisMotionValue(d);h&&(this.originPoint[d]+=l[d].translate,h.set(h.get()+l[d].translate))}),this.visualElement.render())});return()=>{i(),n(),o(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:o=!1,dragElastic:i=nr,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:o,dragElastic:i,dragMomentum:a}}}function _n(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Mh(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Eh extends ot{constructor(t){super(t),this.removeGroupControls=De,this.removeListeners=De,this.controls=new Ah(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||De}unmount(){this.removeGroupControls(),this.removeListeners()}}const $i=e=>(t,n)=>{e&&ae.postRender(()=>e(t,n))};class kh extends ot{constructor(){super(...arguments),this.removePointerDownListener=De}onPointerDown(t){this.session=new Ua(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:za(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:$i(t),onStart:$i(n),onMove:s,onEnd:(o,i)=>{delete this.session,r&&ae.postRender(()=>r(o,i))}}}mount(){this.removePointerDownListener=yn(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Jn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Bi(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const hn={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(U.test(e))e=parseFloat(e);else return e;const n=Bi(e,t.target.x),s=Bi(e,t.target.y);return`${n}% ${s}%`}},Nh={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,r=it.parse(e);if(r.length>5)return s;const o=it.createTransformer(e),i=typeof r[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;r[0+i]/=a,r[1+i]/=l;const u=ce(a,l,.5);return typeof r[2+i]=="number"&&(r[2+i]/=u),typeof r[3+i]=="number"&&(r[3+i]/=u),o(r)}};let As=!1;class Dh extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:o}=t;nd(Rh),o&&(n.group&&n.group.add(o),s&&s.register&&r&&s.register(o),As&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),Jn.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:r,isPresent:o}=this.props,{projection:i}=s;return i&&(i.isPresent=o,As=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==o?i.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?i.promote():i.relegate()||ae.postRender(()=>{const a=i.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Mr.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;As=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Xa(e){const[t,n]=da(),s=f.useContext(or);return c.jsx(Dh,{...e,layoutGroup:s,switchLayoutGroup:f.useContext(Sa),isPresent:t,safeToRemove:n})}const Rh={borderRadius:{...hn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:hn,borderTopRightRadius:hn,borderBottomLeftRadius:hn,borderBottomRightRadius:hn,boxShadow:Nh};function Vh(e,t,n){const s=be(e)?e:Bt(e);return s.start(Br("",s,t,n)),s.animation}const Ih=(e,t)=>e.depth-t.depth;class Oh{constructor(){this.children=[],this.isDirty=!1}add(t){cr(this.children,t),this.isDirty=!0}remove(t){ur(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Ih),this.isDirty=!1,this.children.forEach(t)}}function Lh(e,t){const n=Ce.now(),s=({timestamp:r})=>{const o=r-n;o>=t&&(rt(s),e(o-t))};return ae.setup(s,!0),()=>rt(s)}const Wa=["TopLeft","TopRight","BottomLeft","BottomRight"],Fh=Wa.length,zi=e=>typeof e=="string"?parseFloat(e):e,Ui=e=>typeof e=="number"||U.test(e);function $h(e,t,n,s,r,o){r?(e.opacity=ce(0,n.opacity??1,Bh(s)),e.opacityExit=ce(t.opacity??1,0,zh(s))):o&&(e.opacity=ce(t.opacity??1,n.opacity??1,s));for(let i=0;i<Fh;i++){const a=`border${Wa[i]}Radius`;let l=_i(t,a),u=_i(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Ui(l)===Ui(u)?(e[a]=Math.max(ce(zi(l),zi(u),s),0),(We.test(u)||We.test(l))&&(e[a]+="%")):e[a]=u}(t.rotate||n.rotate)&&(e.rotate=ce(t.rotate||0,n.rotate||0,s))}function _i(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const Bh=Ka(0,.5,No),zh=Ka(.5,.95,De);function Ka(e,t,n){return s=>s<e?0:s>t?1:n(wn(e,t,s))}function Xi(e,t){e.min=t.min,e.max=t.max}function Me(e,t){Xi(e.x,t.x),Xi(e.y,t.y)}function Wi(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function Ki(e,t,n,s,r){return e-=t,e=ns(e,1/n,s),r!==void 0&&(e=ns(e,1/r,s)),e}function Uh(e,t=0,n=1,s=.5,r,o=e,i=e){if(We.test(t)&&(t=parseFloat(t),t=ce(i.min,i.max,t/100)-i.min),typeof t!="number")return;let a=ce(o.min,o.max,s);e===o&&(a-=t),e.min=Ki(e.min,t,n,a,r),e.max=Ki(e.max,t,n,a,r)}function qi(e,t,[n,s,r],o,i){Uh(e,t[n],t[s],t[r],t.scale,o,i)}const _h=["x","scaleX","originX"],Xh=["y","scaleY","originY"];function Gi(e,t,n,s){qi(e.x,t,_h,n?n.x:void 0,s?s.x:void 0),qi(e.y,t,Xh,n?n.y:void 0,s?s.y:void 0)}function Yi(e){return e.translate===0&&e.scale===1}function qa(e){return Yi(e.x)&&Yi(e.y)}function Hi(e,t){return e.min===t.min&&e.max===t.max}function Wh(e,t){return Hi(e.x,t.x)&&Hi(e.y,t.y)}function Ji(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Ga(e,t){return Ji(e.x,t.x)&&Ji(e.y,t.y)}function Zi(e){return Se(e.x)/Se(e.y)}function Qi(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Kh{constructor(){this.members=[]}add(t){cr(this.members,t),t.scheduleRender()}remove(t){if(ur(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(r=>t===r);if(n===0)return!1;let s;for(let r=n;r>=0;r--){const o=this.members[r];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender(),t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:r}=t.options;r===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function qh(e,t,n){let s="";const r=e.x.translate/t.x,o=e.y.translate/t.y,i=n?.z||0;if((r||o||i)&&(s=`translate3d(${r}px, ${o}px, ${i}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:u,rotate:d,rotateX:h,rotateY:m,skewX:p,skewY:S}=n;u&&(s=`perspective(${u}px) ${s}`),d&&(s+=`rotate(${d}deg) `),h&&(s+=`rotateX(${h}deg) `),m&&(s+=`rotateY(${m}deg) `),p&&(s+=`skewX(${p}deg) `),S&&(s+=`skewY(${S}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const Ms=["","X","Y","Z"],Gh=1e3;let Yh=0;function Es(e,t,n,s){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),s&&(s[e]=0))}function Ya(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Ra(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ae,!(r||o))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&Ya(s)}function Ha({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:r}){return class{constructor(i={},a=t?.()){this.id=Yh++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Zh),this.nodes.forEach(nf),this.nodes.forEach(sf),this.nodes.forEach(Qh)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=i,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Oh)}addEventListener(i,a){return this.eventHandlers.has(i)||this.eventHandlers.set(i,new hr),this.eventHandlers.get(i).add(a)}notifyListeners(i,...a){const l=this.eventHandlers.get(i);l&&l.notify(...a)}hasListeners(i){return this.eventHandlers.has(i)}mount(i){if(this.instance)return;this.isSVG=ua(i)&&!Bu(i),this.instance=i;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(i),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let d,h=0;const m=()=>this.root.updateBlockedByResize=!1;ae.read(()=>{h=window.innerWidth}),e(i,()=>{const p=window.innerWidth;p!==h&&(h=p,this.root.updateBlockedByResize=!0,d&&d(),d=Lh(m,250),Jn.hasAnimatedSinceResize&&(Jn.hasAnimatedSinceResize=!1,this.nodes.forEach(no)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:h,hasRelativeLayoutChanged:m,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const S=this.options.transition||u.getDefaultTransition()||cf,{onLayoutAnimationStart:w,onLayoutAnimationComplete:T}=u.getProps(),x=!this.targetLayout||!Ga(this.targetLayout,p),P=!h&&m;if(this.options.layoutRoot||this.resumeFrom||P||h&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const E={...Pr(S,"layout"),onPlay:w,onComplete:T};(u.shouldReduceMotion||this.options.layoutRoot)&&(E.delay=0,E.type=!1),this.startAnimation(E),this.setAnimationOrigin(d,P)}else h||no(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const i=this.getStack();i&&i.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),rt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(rf),this.animationId++)}getTransformTemplate(){const{visualElement:i}=this.options;return i&&i.getProps().transformTemplate}willUpdate(i=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Ya(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const h=this.path[d];h.shouldResetTransform=!0,h.updateScroll("snapshot"),h.options.layoutRoot&&h.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),i&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(eo);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(to);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(tf),this.nodes.forEach(Hh),this.nodes.forEach(Jh)):this.nodes.forEach(to),this.clearAllSnapshots();const a=Ce.now();pe.delta=Ge(0,1e3/60,a-pe.timestamp),pe.timestamp=a,pe.isProcessing=!0,ys.update.process(pe),ys.preRender.process(pe),ys.render.process(pe),pe.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Mr.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(ef),this.sharedNodes.forEach(of)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ae.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ae.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Se(this.snapshot.measuredBox.x)&&!Se(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const i=this.layout;this.layout=this.measure(!1),this.layoutCorrected=ue(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,i?i.layoutBox:void 0)}updateScroll(i="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===i&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:i,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!r)return;const i=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!qa(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;i&&this.instance&&(a||xt(this.latestValues)||d)&&(r(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(i=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return i&&(l=this.removeTransform(l)),uf(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:i}=this.options;if(!i)return ue();const a=i.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(df))){const{scroll:u}=this.root;u&&(It(a.x,u.offset.x),It(a.y,u.offset.y))}return a}removeElementScroll(i){const a=ue();if(Me(a,i),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:d,options:h}=u;u!==this.root&&d&&h.layoutScroll&&(d.wasRoot&&Me(a,i),It(a.x,d.offset.x),It(a.y,d.offset.y))}return a}applyTransform(i,a=!1){const l=ue();Me(l,i);for(let u=0;u<this.path.length;u++){const d=this.path[u];!a&&d.options.layoutScroll&&d.scroll&&d!==d.root&&Ot(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),xt(d.latestValues)&&Ot(l,d.latestValues)}return xt(this.latestValues)&&Ot(l,this.latestValues),l}removeTransform(i){const a=ue();Me(a,i);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!xt(u.latestValues))continue;Hs(u.latestValues)&&u.updateSnapshot();const d=ue(),h=u.measurePageBox();Me(d,h),Gi(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return xt(this.latestValues)&&Gi(a,this.latestValues),a}setTargetDelta(i){this.targetDelta=i,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(i){this.options={...this.options,...i,crossfade:i.crossfade!==void 0?i.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==pe.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(i=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(i||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:d,layoutId:h}=this.options;if(!(!this.layout||!(d||h))){if(this.resolvedRelativeTargetAt=pe.timestamp,!this.targetDelta&&!this.relativeTarget){const m=this.getClosestProjectingParent();m&&m.layout&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=ue(),this.relativeTargetOrigin=ue(),bn(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),Me(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=ue(),this.targetWithTransforms=ue()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),gh(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Me(this.target,this.layout.layoutBox),Pa(this.target,this.targetDelta)):Me(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const m=this.getClosestProjectingParent();m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=ue(),this.relativeTargetOrigin=ue(),bn(this.relativeTargetOrigin,this.target,m.target),Me(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Hs(this.parent.latestValues)||ja(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const i=this.getLead(),a=!!this.resumingFrom||this!==i;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===pe.timestamp&&(l=!1),l)return;const{layout:u,layoutId:d}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||d))return;Me(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,m=this.treeScale.y;kd(this.layoutCorrected,this.treeScale,this.path,a),i.layout&&!i.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(i.target=i.layout.layoutBox,i.targetWithTransforms=ue());const{target:p}=i;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Wi(this.prevProjectionDelta.x,this.projectionDelta.x),Wi(this.prevProjectionDelta.y,this.projectionDelta.y)),xn(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==m||!Qi(this.projectionDelta.x,this.prevProjectionDelta.x)||!Qi(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(i=!0){if(this.options.visualElement?.scheduleRender(),i){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Lt(),this.projectionDelta=Lt(),this.projectionDeltaWithTransform=Lt()}setAnimationOrigin(i,a=!1){const l=this.snapshot,u=l?l.latestValues:{},d={...this.latestValues},h=Lt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=ue(),p=l?l.source:void 0,S=this.layout?this.layout.source:void 0,w=p!==S,T=this.getStack(),x=!T||T.members.length<=1,P=!!(w&&!x&&this.options.crossfade===!0&&!this.path.some(lf));this.animationProgress=0;let E;this.mixTargetDelta=L=>{const N=L/1e3;so(h.x,i.x,N),so(h.y,i.y,N),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(bn(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),af(this.relativeTarget,this.relativeTargetOrigin,m,N),E&&Wh(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=ue()),Me(E,this.relativeTarget)),w&&(this.animationValues=d,$h(d,u,this.latestValues,N,P,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=N},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(i){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(rt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ae.update(()=>{Jn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Bt(0)),this.currentAnimation=Vh(this.motionValue,[0,1e3],{...i,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),i.onUpdate&&i.onUpdate(a)},onStop:()=>{},onComplete:()=>{i.onComplete&&i.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const i=this.getStack();i&&i.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Gh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const i=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:d}=i;if(!(!a||!l||!u)){if(this!==i&&this.layout&&u&&Ja(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||ue();const h=Se(this.layout.layoutBox.x);l.x.min=i.target.x.min,l.x.max=l.x.min+h;const m=Se(this.layout.layoutBox.y);l.y.min=i.target.y.min,l.y.max=l.y.min+m}Me(a,l),Ot(a,d),xn(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(i,a){this.sharedNodes.has(i)||this.sharedNodes.set(i,new Kh),this.sharedNodes.get(i).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const i=this.getStack();return i?i.lead===this:!0}getLead(){const{layoutId:i}=this.options;return i?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:i}=this.options;return i?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:i}=this.options;if(i)return this.root.sharedNodes.get(i)}promote({needsReset:i,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),i&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const i=this.getStack();return i?i.relegate(this):!1}resetSkewAndRotation(){const{visualElement:i}=this.options;if(!i)return;let a=!1;const{latestValues:l}=i;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&Es("z",i,u,this.animationValues);for(let d=0;d<Ms.length;d++)Es(`rotate${Ms[d]}`,i,u,this.animationValues),Es(`skew${Ms[d]}`,i,u,this.animationValues);i.render();for(const d in u)i.setStaticValue(d,u[d]),this.animationValues&&(this.animationValues[d]=u[d]);i.scheduleRender()}applyProjectionStyles(i,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){i.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,i.visibility="",i.opacity="",i.pointerEvents=Yn(a?.pointerEvents)||"",i.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(i.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,i.pointerEvents=Yn(a?.pointerEvents)||""),this.hasProjected&&!xt(this.latestValues)&&(i.transform=l?l({},""):"none",this.hasProjected=!1);return}i.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let h=qh(this.projectionDeltaWithTransform,this.treeScale,d);l&&(h=l(d,h)),i.transform=h;const{x:m,y:p}=this.projectionDelta;i.transformOrigin=`${m.origin*100}% ${p.origin*100}% 0`,u.animationValues?i.opacity=u===this?d.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:d.opacityExit:i.opacity=u===this?d.opacity!==void 0?d.opacity:"":d.opacityExit!==void 0?d.opacityExit:0;for(const S in jn){if(d[S]===void 0)continue;const{correct:w,applyTo:T,isCSSVariable:x}=jn[S],P=h==="none"?d[S]:w(d[S],u);if(T){const E=T.length;for(let L=0;L<E;L++)i[T[L]]=P}else x?this.options.visualElement.renderState.vars[S]=P:i[S]=P}this.options.layoutId&&(i.pointerEvents=u===this?Yn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(i=>i.currentAnimation?.stop()),this.root.nodes.forEach(eo),this.root.sharedNodes.clear()}}}function Hh(e){e.updateLayout()}function Jh(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=e.layout,{animationType:r}=e.options,o=t.source!==e.layout.source;r==="size"?Ee(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Se(h);h.min=n[d].min,h.max=h.min+m}):Ja(r,t.layoutBox,n)&&Ee(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Se(n[d]);h.max=h.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[d].max=e.relativeTarget[d].min+m)});const i=Lt();xn(i,n,t.layoutBox);const a=Lt();o?xn(a,e.applyTransform(s,!0),t.measuredBox):xn(a,n,t.layoutBox);const l=!qa(i);let u=!1;if(!e.resumeFrom){const d=e.getClosestProjectingParent();if(d&&!d.resumeFrom){const{snapshot:h,layout:m}=d;if(h&&m){const p=ue();bn(p,t.layoutBox,h.layoutBox);const S=ue();bn(S,n,m.layoutBox),Ga(p,S)||(u=!0),d.options.layoutRoot&&(e.relativeTarget=S,e.relativeTargetOrigin=p,e.relativeParent=d)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:a,layoutDelta:i,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function Zh(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function Qh(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function ef(e){e.clearSnapshot()}function eo(e){e.clearMeasurements()}function to(e){e.isLayoutDirty=!1}function tf(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function no(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function nf(e){e.resolveTargetDelta()}function sf(e){e.calcProjection()}function rf(e){e.resetSkewAndRotation()}function of(e){e.removeLeadSnapshot()}function so(e,t,n){e.translate=ce(t.translate,0,n),e.scale=ce(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ro(e,t,n,s){e.min=ce(t.min,n.min,s),e.max=ce(t.max,n.max,s)}function af(e,t,n,s){ro(e.x,t.x,n.x,s),ro(e.y,t.y,n.y,s)}function lf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const cf={duration:.45,ease:[.4,0,.1,1]},io=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),oo=io("applewebkit/")&&!io("chrome/")?Math.round:De;function ao(e){e.min=oo(e.min),e.max=oo(e.max)}function uf(e){ao(e.x),ao(e.y)}function Ja(e,t,n){return e==="position"||e==="preserve-aspect"&&!ph(Zi(t),Zi(n),.2)}function df(e){return e!==e.root&&e.scroll?.wasRoot}const hf=Ha({attachResizeListener:(e,t)=>Pn(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),ks={current:void 0},Za=Ha({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!ks.current){const e=new hf({});e.mount(window),e.setOptions({layoutScroll:!0}),ks.current=e}return ks.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),ff={pan:{Feature:kh},drag:{Feature:Eh,ProjectionNode:Za,MeasureLayout:Xa}};function lo(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,o=s[r];o&&ae.postRender(()=>o(t,kn(t)))}class mf extends ot{mount(){const{current:t}=this.node;t&&(this.unmount=Iu(t,(n,s)=>(lo(this.node,s,"Start"),r=>lo(this.node,r,"End"))))}unmount(){}}class pf extends ot{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=An(Pn(this.node.current,"focus",()=>this.onFocus()),Pn(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function co(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),o=s[r];o&&ae.postRender(()=>o(t,kn(t)))}class gf extends ot{mount(){const{current:t}=this.node;t&&(this.unmount=$u(t,(n,s)=>(co(this.node,s,"Start"),(r,{success:o})=>co(this.node,r,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const sr=new WeakMap,Ns=new WeakMap,yf=e=>{const t=sr.get(e.target);t&&t(e)},xf=e=>{e.forEach(yf)};function bf({root:e,...t}){const n=e||document;Ns.has(n)||Ns.set(n,{});const s=Ns.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(xf,{root:e,...t})),s[r]}function vf(e,t,n){const s=bf(t);return sr.set(e,n),s.observe(e),()=>{sr.delete(e),s.unobserve(e)}}const wf={some:0,all:1};class Sf extends ot{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:r="some",once:o}=t,i={root:n?n.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:wf[r]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:h}=this.node.getProps(),m=u?d:h;m&&m(l)};return vf(this.node.current,i,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Tf(t,n))&&this.startObserver()}unmount(){}}function Tf({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Qa={inView:{Feature:Sf},tap:{Feature:gf},focus:{Feature:pf},hover:{Feature:mf}},Cf={layout:{ProjectionNode:Za,MeasureLayout:Xa}},jf={...Fa,...Qa,...ff,...Cf},Pf=Ad(jf,Da),Af={renderer:Da,...Fa,...Qa};function zr(e,t){return Hn(e,t)}const Mf=zr("button"),Xn=zr("div"),Ef=zr("p");function kf({toolName:e,description:t,args:n,onApprove:s,onDeny:r}){const o=Object.keys(n).length>0;return c.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:c.jsx("span",{className:"text-sm font-medium text-foreground",children:e})}),o&&c.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([i,a])=>c.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[c.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[i,":"]}),c.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},i))})]}),c.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[c.jsxs(ve,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[c.jsx(Z.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),c.jsx(ve,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:r,children:c.jsx(Z.X,{className:"h-3 w-3"})})]})]})})}function Nf({toolName:e,args:t,isDenied:n,isSafe:s}){const[r,o]=f.useState(!1);if(e==="fetchDocContent")return null;const i=["k","maxResults","_organizationId"];e==="searchDocs"&&i.push("filters");const a=Object.fromEntries(Object.entries(t).filter(([u])=>!i.includes(u))),l=Object.keys(a).length>0;return c.jsxs("div",{className:"my-1",children:[c.jsxs("button",{onClick:()=>l&&o(!r),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors bg-muted text-muted-foreground ${l?"cursor-pointer hover:bg-muted/80":""}`,children:[l&&c.jsx("span",{className:"transition-transform duration-200",children:r?c.jsx(Z.ChevronDown,{className:"h-3 w-3"}):c.jsx(Z.ChevronRight,{className:"h-3 w-3"})}),n?c.jsx(Z.X,{className:"h-3 w-3"}):s?c.jsx(Z.Zap,{className:"h-3 w-3"}):c.jsx(Z.Check,{className:"h-3 w-3"}),c.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",e]})]}),r&&l&&c.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:c.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,d])=>c.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[c.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),c.jsx("span",{className:"font-mono text-foreground",children:typeof d=="string"?d:JSON.stringify(d)})]},u))})})]})}function Df({...e}){return c.jsx(rr.Root,{"data-slot":"collapsible",...e})}function Rf({...e}){return c.jsx(rr.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function Vf({...e}){return c.jsx(rr.CollapsibleContent,{"data-slot":"collapsible-content",...e})}const If=f.lazy(()=>import("streamdown").then(e=>({default:e.Streamdown}))),Ur=f.memo(({className:e,...t})=>typeof window>"u"?null:c.jsx(f.Suspense,{fallback:null,children:c.jsx(If,{className:Q("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t})}),(e,t)=>e.children===t.children);Ur.displayName="Response";const Of=Object.freeze(Object.defineProperty({__proto__:null,Response:Ur},Symbol.toStringTag,{value:"Module"})),Lf=({children:e,as:t="p",className:n,duration:s=2,spread:r=2})=>{const o=Pf.create(t),i=f.useMemo(()=>(e?.length??0)*r,[e,r]);return c.jsx(o,{animate:{backgroundPosition:"0% center"},className:Q("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${i}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:e})},Ff=f.memo(Lf),el=f.createContext(null),$f=()=>{const e=f.useContext(el);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Bf=1e3,zf=1e3,tl=f.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:s=!0,onOpenChange:r,duration:o,children:i,...a})=>{const[l,u]=qr.useControllableState({prop:n,defaultProp:s,onChange:r}),[d,h]=qr.useControllableState({prop:o,defaultProp:0}),[m,p]=f.useState(!1),[S,w]=f.useState(null);f.useEffect(()=>{t?S===null&&w(Date.now()):S!==null&&(h(Math.ceil((Date.now()-S)/zf)),w(null))},[t,S,h]),f.useEffect(()=>{if(s&&!t&&l&&!m){const x=setTimeout(()=>{u(!1),p(!0)},Bf);return()=>clearTimeout(x)}},[t,l,s,u,m]);const T=x=>{u(x)};return c.jsx(el.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:c.jsx(Df,{className:Q("not-prose mb-4",e),onOpenChange:T,open:l,...a,children:i})})}),Uf=(e,t)=>e||t===0?c.jsx(Ff,{duration:1,children:"Thinking..."}):t===void 0?c.jsx("p",{children:"Thought for a few seconds"}):c.jsxs("p",{children:["Thought for ",t," seconds"]}),nl=f.memo(({className:e,children:t,...n})=>{const{isStreaming:s,isOpen:r,duration:o}=$f();return c.jsx(Rf,{className:Q("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??c.jsxs(c.Fragment,{children:[c.jsx(Z.BrainIcon,{className:"size-4"}),Uf(s,o),c.jsx(Z.ChevronDownIcon,{className:Q("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),sl=f.memo(({className:e,children:t,...n})=>c.jsx(Vf,{className:Q("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:c.jsx(Ur,{className:"grid gap-2",children:t})}));tl.displayName="Reasoning";nl.displayName="ReasoningTrigger";sl.displayName="ReasoningContent";function uo(e){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=16`}function _f({sources:e,citationNumber:t,className:n}){const s=e.find(o=>o.number===t);if(!s)return null;const r=uo(s.domain);return c.jsxs(et,{children:[c.jsx(tt,{asChild:!0,children:c.jsxs("button",{className:Q("inline-flex items-center gap-1 px-1 py-0.5 rounded text-[10px] font-medium","bg-stone-200/60 dark:bg-stone-700/60 text-stone-800 dark:text-stone-200","hover:bg-stone-300/80 dark:hover:bg-stone-600/80","transition-all duration-200","border border-stone-300/60 dark:border-stone-600/60","cursor-pointer hover:scale-105 active:scale-95","leading-tight",n),onClick:o=>{o.preventDefault(),o.stopPropagation(),window.open(s.url,"_blank","noopener,noreferrer")},children:[c.jsx("img",{src:r,alt:"",className:"w-3 h-3 leading-none",onError:o=>{const i=o.target;i.style.display="none"}}),c.jsx("span",{className:"leading-none",children:s.domain})]})}),c.jsx(nt,{side:"top",className:"bg-stone-800 dark:bg-stone-900 border border-stone-700 dark:border-stone-600 p-3 max-w-sm z-50 rounded-lg shadow-lg",children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"text-xs font-semibold text-stone-300 dark:text-stone-200 mb-2 pb-2 border-b border-stone-700 dark:border-stone-600",children:["Sources • ",e.length]}),e.map(o=>{const i=o.title||o.domain;return c.jsxs("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:Q("flex items-center gap-2 p-2 rounded-md hover:bg-stone-700/50 dark:hover:bg-stone-700/50 transition-colors","text-stone-300 dark:text-stone-300 hover:text-white dark:hover:text-white"),onClick:a=>a.stopPropagation(),children:[c.jsx("img",{src:uo(o.domain),alt:"",className:"w-4 h-4 flex-shrink-0",onError:a=>{const l=a.target;l.style.display="none"}}),c.jsx("span",{className:"text-xs flex-1 truncate",children:i})]},o.number)})]})})]})}function Xf({text:e,citations:t,citationMap:n,groupedCitations:s,referencesText:r,ResponseComponent:o,className:i,showCitations:a=!0,showReferences:l=!0}){const u=f.useRef(null),[d,h]=f.useState([]);f.useEffect(()=>{if(!a||!u.current||t.length===0||n.size===0){(n.size===0||!a)&&h([]);return}const T=u.current;let x,P=!1;const E=new WeakSet,L=()=>{if(!u.current||P)return;P=!0;const k=u.current,I=/\[(\d+)\]/g,A=document.createTreeWalker(k,NodeFilter.SHOW_TEXT,null),O=[];let j;for(;j=A.nextNode();)if(j.nodeType===Node.TEXT_NODE&&!E.has(j)){const F=j,D=F.textContent||"";let $=F.parentElement,J=!1;for(;$&&$!==k;){if($.tagName==="A"||$.tagName==="CODE"||$.tagName==="PRE"){J=!0;break}$=$.parentElement}if(!J){const G=Array.from(D.matchAll(I)).filter(se=>{if(!se[1])return!1;const fe=parseInt(se[1],10);return n.has(fe)});G.length>0&&O.push({node:F,matches:G})}}if(O.length===0){P=!1;return}const R=[];O.forEach(({node:F,matches:D})=>{E.add(F);const $=F.textContent||"",J=document.createDocumentFragment();let ne=0;D.forEach(G=>{if(!G[1])return;G.index!==void 0&&G.index>ne&&J.appendChild(document.createTextNode($.slice(ne,G.index)));const se=document.createElement("span");se.className="inline-flex items-center citation-button-container";const fe=parseInt(G[1],10);se.setAttribute("data-citation",G[1]),J.appendChild(se),R.push({element:se,citationNum:fe}),ne=(G.index||0)+G[0].length}),ne<$.length&&J.appendChild(document.createTextNode($.slice(ne))),F.parentNode&&F.parentNode.replaceChild(J,F)}),R.length>0&&h(F=>{const D=new Set(F.map(ne=>ne.element)),$=F.filter(ne=>ne.element.isConnected),J=R.filter(ne=>!D.has(ne.element));return[...$,...J]}),P=!1},N=new MutationObserver(()=>{clearTimeout(x),x=setTimeout(L,100)});return N.observe(T,{childList:!0,subtree:!0,characterData:!0}),x=setTimeout(L,200),()=>{N.disconnect(),clearTimeout(x)}},[e,t,n,a]);const m=s&&s.length>0||n&&n.size>0||r;function p(T){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(T)}&sz=16`}function S(T){try{return new URL(T).hostname.replace(/^www\./,"")}catch{return T}}const w=a&&l&&m?c.jsxs("div",{className:"mt-4 pt-4 border-t border-stone-200 dark:border-stone-700",children:[c.jsx("div",{className:"text-xs font-semibold text-stone-600 dark:text-stone-400 mb-3",children:"References"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:s&&s.length>0?s.map((T,x)=>{const P=T.title||T.baseUrl,E=S(T.url),L=p(E);return c.jsxs("a",{href:T.url,target:"_blank",rel:"noopener noreferrer",className:Q("inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium","bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300","hover:bg-stone-200 dark:hover:bg-stone-700","transition-all duration-200","border border-stone-200 dark:border-stone-700","cursor-pointer hover:scale-105 active:scale-95","no-underline"),children:[c.jsx("img",{src:L,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:N=>{const k=N.target;k.style.display="none"}}),c.jsx("span",{className:"leading-none",children:P})]},`group-${x}`)}):Array.from(n.entries()).sort(([T],[x])=>T-x).map(([T,x])=>{const P=S(x),E=p(P);return c.jsxs("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:Q("inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium","bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300","hover:bg-stone-200 dark:hover:bg-stone-700","transition-all duration-200","border border-stone-200 dark:border-stone-700","cursor-pointer hover:scale-105 active:scale-95","no-underline"),children:[c.jsx("img",{src:E,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:L=>{const N=L.target;N.style.display="none"}}),c.jsx("span",{className:"leading-none",children:x})]},T)})})]}):null;return c.jsxs("div",{className:i,children:[c.jsx("div",{ref:u,children:c.jsx(o,{children:e})}),a&&d.filter(({element:T})=>T.isConnected).map(({element:T,citationNum:x},P)=>{if(!t.find(N=>N.number===x))return null;const L=Array.from(new Map(t.map(N=>{const k=N.url.replace(/\/+$/,""),I=s?.find(A=>A.url.replace(/\/+$/,"")===k);return[k,{number:N.number,url:N.url,domain:S(N.url),title:I?.title}]})).values());return wl.createPortal(c.jsx(_f,{sources:L,citationNumber:x},`citation-${x}-${T}`),T,`citation-${x}-${P}`)}),w]})}function Kt({...e}){return c.jsx(Tt.Root,{"data-slot":"dialog",...e})}function Wf({...e}){return c.jsx(Tt.Portal,{"data-slot":"dialog-portal",...e})}function Kf({className:e,...t}){return c.jsx(Tt.Overlay,{"data-slot":"dialog-overlay",className:Q("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function qt({className:e,children:t,showCloseButton:n=!0,...s}){return c.jsxs(Wf,{"data-slot":"dialog-portal",children:[c.jsx(Kf,{}),c.jsxs(Tt.Content,{"data-slot":"dialog-content",className:Q("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...s,children:[t,n&&c.jsxs(Tt.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[c.jsx(Z.XIcon,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Gt({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-header",className:Q("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Yt({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-footer",className:Q("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Ht({className:e,...t}){return c.jsx(Tt.Title,{"data-slot":"dialog-title",className:Q("text-lg leading-none font-semibold",e),...t})}function Jt({className:e,...t}){return c.jsx(Tt.Description,{"data-slot":"dialog-description",className:Q("text-muted-foreground text-sm",e),...t})}function Zt({className:e,type:t,...n}){return c.jsx("input",{type:t,"data-slot":"input",className:Q("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-white px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}function qf({isOpen:e,title:t="Password Required",description:n="Please enter your password to continue",placeholder:s="Enter password...",onComplete:r}){const[o,i]=f.useState(""),[a,l]=f.useState(!1),[u,d]=f.useState(!1),h=async p=>{if(p.preventDefault(),!!o.trim()){d(!0);try{r(o)}finally{d(!1)}}},m=()=>{i(""),r(null)};return c.jsx(Kt,{open:e,children:c.jsx(qt,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(Gt,{children:[c.jsx(Ht,{children:t}),c.jsx(Jt,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsxs("div",{className:"relative",children:[c.jsx(Zt,{type:a?"text":"password",value:o,onChange:p=>i(p.target.value),placeholder:s,className:"pr-10",autoFocus:!0,disabled:u}),c.jsx("button",{type:"button",onClick:()=>l(!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:u,children:a?c.jsx(Z.EyeOff,{className:"h-4 w-4"}):c.jsx(Z.Eye,{className:"h-4 w-4"})})]})}),c.jsxs(Yt,{children:[c.jsx(ve,{type:"button",variant:"ghost",onClick:m,disabled:u,children:"Cancel"}),c.jsx(ve,{type:"submit",disabled:!o.trim()||u,children:u?"Submitting...":"Submit"})]})]})})})}function Gf({isOpen:e,title:t="Email Required",description:n="Please enter your email address",placeholder:s="Enter email address...",onComplete:r}){const[o,i]=f.useState(""),[a,l]=f.useState(!0),[u,d]=f.useState(!1),h=w=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w),m=w=>{i(w),w.trim()?l(h(w)):l(!0)},p=async w=>{if(w.preventDefault(),!o.trim()||!h(o)){l(!1);return}d(!0);try{r(o)}finally{d(!1)}},S=()=>{i(""),l(!0),r(null)};return c.jsx(Kt,{open:e,children:c.jsx(qt,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:p,children:[c.jsxs(Gt,{children:[c.jsxs(Ht,{className:"flex items-center gap-2",children:[c.jsx(Z.Mail,{className:"h-5 w-5"}),t]}),c.jsx(Jt,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(Zt,{type:"email",value:o,onChange:w=>m(w.target.value),placeholder:s,className:a?"":"border-red-500",autoFocus:!0,disabled:u}),!a&&c.jsx("p",{className:"text-sm text-red-500 mt-1",children:"Please enter a valid email address"})]}),c.jsxs(Yt,{children:[c.jsx(ve,{type:"button",variant:"ghost",onClick:S,disabled:u,children:"Cancel"}),c.jsx(ve,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function Yf({isOpen:e,title:t="Phone Number Required",description:n="Please enter your phone number",placeholder:s="Enter phone number...",onComplete:r}){const[o,i]=f.useState(""),[a,l]=f.useState(!0),[u,d]=f.useState(!1),h=T=>{const x=T.replace(/\D/g,"");return x.length<=3?x:x.length<=6?`(${x.slice(0,3)}) ${x.slice(3)}`:`(${x.slice(0,3)}) ${x.slice(3,6)}-${x.slice(6,10)}`},m=T=>T.replace(/\D/g,"").length===10,p=T=>{const x=h(T);i(x),x.trim()?l(m(x)):l(!0)},S=async T=>{if(T.preventDefault(),!o.trim()||!m(o)){l(!1);return}d(!0);try{const x=o.replace(/\D/g,"");r(x)}finally{d(!1)}},w=()=>{i(""),l(!0),r(null)};return c.jsx(Kt,{open:e,children:c.jsx(qt,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:S,children:[c.jsxs(Gt,{children:[c.jsxs(Ht,{className:"flex items-center gap-2",children:[c.jsx(Z.Phone,{className:"h-5 w-5"}),t]}),c.jsx(Jt,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(Zt,{type:"tel",value:o,onChange:T=>p(T.target.value),placeholder:s,className:a?"":"border-red-500",maxLength:14,autoFocus:!0,disabled:u}),!a&&c.jsx("p",{className:"text-sm text-red-500 mt-1",children:"Please enter a valid 10-digit phone number"})]}),c.jsxs(Yt,{children:[c.jsx(ve,{type:"button",variant:"ghost",onClick:w,disabled:u,children:"Cancel"}),c.jsx(ve,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function Hf({isOpen:e,title:t="PIN Required",description:n="Please enter your PIN",placeholder:s="Enter PIN...",length:r=4,onComplete:o}){const[i,a]=f.useState(""),[l,u]=f.useState(!1),d=p=>{const S=p.replace(/\D/g,"");a(S.slice(0,r))},h=async p=>{if(p.preventDefault(),i.length===r){u(!0);try{o(i)}finally{u(!1)}}},m=()=>{a(""),o(null)};return c.jsx(Kt,{open:e,children:c.jsx(qt,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(Gt,{children:[c.jsxs(Ht,{className:"flex items-center gap-2",children:[c.jsx(Z.Shield,{className:"h-5 w-5"}),t]}),c.jsx(Jt,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(Zt,{type:"password",value:i,onChange:p=>d(p.target.value),placeholder:s,className:"text-center text-lg tracking-widest",maxLength:r,autoFocus:!0,disabled:l}),c.jsxs("p",{className:"text-sm text-gray-500 mt-1 text-center",children:["Enter ",r,"-digit PIN"]})]}),c.jsxs(Yt,{children:[c.jsx(ve,{type:"button",variant:"ghost",onClick:m,disabled:l,children:"Cancel"}),c.jsx(ve,{type:"submit",disabled:i.length!==r||l,children:l?"Submitting...":"Submit"})]})]})})})}function Ds({isOpen:e,title:t="Secure Input Required",description:n="Please enter the requested information",placeholder:s="Enter value...",type:r="password",onComplete:o}){const[i,a]=f.useState(""),[l,u]=f.useState(!1),d=async m=>{if(m.preventDefault(),!!i.trim()){u(!0);try{o(i)}finally{u(!1)}}},h=()=>{a(""),o(null)};return c.jsx(Kt,{open:e,children:c.jsx(qt,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:d,children:[c.jsxs(Gt,{children:[c.jsxs(Ht,{className:"flex items-center gap-2",children:[c.jsx(Z.Lock,{className:"h-5 w-5"}),t]}),c.jsx(Jt,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsx(Zt,{type:r,value:i,onChange:m=>a(m.target.value),placeholder:s,autoFocus:!0,disabled:l})}),c.jsxs(Yt,{children:[c.jsx(ve,{type:"button",variant:"ghost",onClick:h,disabled:l,children:"Cancel"}),c.jsx(ve,{type:"submit",disabled:!i.trim()||l,children:l?"Submitting...":"Submit"})]})]})})})}function Jf({isOpen:e,title:t,description:n,fields:s,onComplete:r,submitText:o="Submit",cancelText:i="Cancel"}){const[a,l]=f.useState(()=>{const j={};return s.forEach(R=>{j[R.name]=R.value||""}),j}),[u,d]=f.useState({}),[h,m]=f.useState({}),[p,S]=f.useState(!1),w=j=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j)?null:"Please enter a valid email address",T=j=>j.replace(/\D/g,"").length===10?null:"Please enter a valid 10-digit phone number",x=(j,R=4)=>j.length===R?null:`PIN must be ${R} digits`,P=j=>{const R=j.replace(/\D/g,"");return R.length<=3?R:R.length<=6?`(${R.slice(0,3)}) ${R.slice(3)}`:`(${R.slice(0,3)}) ${R.slice(3,6)}-${R.slice(6,10)}`},E=(j,R,F)=>{let D=R,$=null;switch(F.type){case"phone":D=P(R),D.trim()&&($=T(D));break;case"email":R.trim()&&($=w(R));break;case"pin":D=R.replace(/\D/g,"").slice(0,6),D.trim()&&($=x(D));break}!$&&F.validation&&D.trim()&&($=F.validation(D)),l(J=>({...J,[j]:D})),d(J=>({...J,[j]:$||""}))},L=()=>{const j={};let R=!0;return s.forEach(F=>{const D=a[F.name]||"";let $=null;if(F.required&&!D.trim())$=`${F.label} is required`;else if(D.trim()){switch(F.type){case"email":$=w(D);break;case"phone":$=T(D);break;case"pin":$=x(D);break}!$&&F.validation&&($=F.validation(D))}$&&(j[F.name]=$,R=!1)}),d(j),R},N=async j=>{if(j.preventDefault(),!!L()){S(!0);try{const R={};s.forEach(F=>{const D=a[F.name]?.trim();D&&(F.type==="phone"?R[F.name]=D.replace(/\D/g,""):R[F.name]=D)}),r(R)}finally{S(!1)}}},k=()=>{l({}),d({}),m({}),r(null)},I=j=>{m(R=>({...R,[j]:!R[j]}))},A=j=>{switch(j.type){case"password":return h[j.name]?"text":"password";case"email":return"email";case"phone":return"tel";case"pin":case"ssn":return"password";default:return"text"}},O=j=>{if(j.placeholder)return j.placeholder;switch(j.type){case"email":return"Enter email address...";case"phone":return"Enter phone number...";case"password":return"Enter password...";case"pin":return"Enter PIN...";case"ssn":return"XXX-XX-XXXX";case"creditCard":return"XXXX XXXX XXXX XXXX";default:return`Enter ${j.label.toLowerCase()}...`}};return c.jsx(Kt,{open:e,children:c.jsx(qt,{showCloseButton:!1,className:"max-w-md",children:c.jsxs("form",{onSubmit:N,children:[c.jsxs(Gt,{children:[c.jsx(Ht,{children:t}),n&&c.jsx(Jt,{children:n})]}),c.jsx("div",{className:"py-4 space-y-4",children:s.map(j=>c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm font-medium mb-1",children:[j.label,j.required&&c.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),c.jsxs("div",{className:"relative",children:[c.jsx(Zt,{type:A(j),value:a[j.name]||"",onChange:R=>E(j.name,R.target.value,j),placeholder:O(j),className:u[j.name]?"border-red-500":"",disabled:p,autoFocus:j===s[0],maxLength:j.type==="pin"?6:j.type==="phone"?14:void 0}),j.type==="password"&&c.jsx("button",{type:"button",onClick:()=>I(j.name),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:p,children:h[j.name]?c.jsx(Z.EyeOff,{className:"h-4 w-4"}):c.jsx(Z.Eye,{className:"h-4 w-4"})})]}),u[j.name]&&c.jsxs("div",{className:"flex items-center gap-1 mt-1 text-sm text-red-500",children:[c.jsx(Z.AlertCircle,{className:"h-3 w-3"}),u[j.name]]})]},j.name))}),c.jsxs(Yt,{children:[c.jsx(ve,{type:"button",variant:"ghost",onClick:k,disabled:p,children:i}),c.jsx(ve,{type:"submit",disabled:p,children:p?"Submitting...":o})]})]})})})}const rl=f.createContext(void 0);function il(){const e=f.useContext(rl);if(!e)throw new Error("useSecureModal must be used within a SecureModalProvider");return e}function ol({children:e}){const[t,n]=f.useState(null),[s,r]=f.useState(null),o=f.useRef(null),i=f.useRef(null),a=f.useCallback(p=>new Promise(S=>{n(p),o.current=S}),[]),l=f.useCallback(p=>new Promise(S=>{r(p),i.current=S}),[]),u=f.useCallback(p=>{o.current&&(o.current(p),o.current=null),n(null)},[]),d=f.useCallback(p=>{i.current&&(i.current(p),i.current=null),r(null)},[]),h=()=>{if(s){const S=s.fields.map(w=>({name:w.name,type:w.type==="text"?"text":w.type==="password"?"password":w.type==="email"?"email":w.type==="phone"?"phone":w.type==="pin"?"pin":w.type==="ssn"?"ssn":w.type==="creditCard"?"creditCard":"text",label:w.label,placeholder:w.placeholder,required:w.required!==!1,value:w.value}));return c.jsx(Jf,{isOpen:!0,title:s.title,description:s.description,fields:S,onComplete:d})}if(!t)return null;const p={isOpen:!0,title:t.title,description:t.description,placeholder:t.placeholder,onComplete:u};switch(t.type){case"password":return c.jsx(qf,{...p});case"email":return c.jsx(Gf,{...p});case"phone":return c.jsx(Yf,{...p});case"pin":return c.jsx(Hf,{...p});case"ssn":return c.jsx(Ds,{...p,title:t.title||"SSN Required",placeholder:t.placeholder||"XXX-XX-XXXX"});case"creditCard":return c.jsx(Ds,{...p,title:t.title||"Credit Card Required",placeholder:t.placeholder||"XXXX XXXX XXXX XXXX",type:"text"});case"text":default:return c.jsx(Ds,{...p})}},m=f.useMemo(()=>({showSecureModal:a,showSecureForm:l}),[a,l]);return c.jsxs(rl.Provider,{value:m,children:[e,h()]})}function Zf(e){try{const t=new URL(e),n=`${t.protocol}//${t.host}${t.pathname}`,s=t.hash?t.hash.substring(1):void 0;return{baseUrl:n,anchor:s}}catch{const t=e.indexOf("#");return t!==-1?{baseUrl:e.substring(0,t),anchor:e.substring(t+1)}:{baseUrl:e}}}function Qf(e){try{const t=new URL(e),s=t.pathname.split("/").filter(a=>a.length>0);if(s.length===0)return t.hostname;const r=s[s.length-1];return r&&r.replace(/\.(md|mdx|html|htm)$/i,"").replace(/[-_]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" ")||t.hostname}catch{const t=e.indexOf("#"),n=t!==-1?e.substring(0,t):e,s=n.split("/").filter(r=>r.length>0);if(s.length>0){const r=s[s.length-1];return r&&r.replace(/\.(md|mdx|html|htm)$/i,"").replace(/[-_]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" ")||n}return n}}function ho(e){let t=e.replace(/_+$/gm,"");const n=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,s=t.match(n),r=new Map,o=[],i=new Map,a=new Map,l=new Map,u=new Map;if(s&&s[1]){const A=s[1],O=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let j;for(;(j=O.exec(A))!==null;)if(j[1]&&j[2]){const R=parseInt(j[1],10),F=j[2].replace(/[.,;:!?]+$/,""),D=F.replace(/\/+$/,"");if(a.has(D)||a.set(D,F),i.has(D)||i.set(D,[]),i.get(D).push(R),!l.has(D))l.set(D,R);else{const $=l.get(D);R<$&&l.set(D,R)}}for(const[R,F]of i.entries()){const D=l.get(R);for(const $ of F)$!==D&&u.set($,D)}for(const[R,F]of l.entries()){const D=a.get(R)||R;r.set(F,D),o.push({number:F,url:D})}}let d,h=t;s&&s[0]&&(d=s[0],h=t.replace(n,""));const m=[];let p=0;const S=/```[\s\S]*?```|`[^`]+`/g;let w;for(;(w=S.exec(h))!==null;)w.index>p&&m.push({type:"text",content:h.slice(p,w.index),start:p,end:w.index}),m.push({type:"code",content:w[0],start:w.index,end:w.index+w[0].length}),p=w.index+w[0].length;p<h.length&&m.push({type:"text",content:h.slice(p),start:p,end:h.length});const T=m.map(A=>{if(A.type==="code")return A.content;let O=A.content;return O=O.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(R,F,D)=>{const $=parseInt(F,10),J=D.replace(/\/+$/,""),ne=u.get($)||$;return l.has(J)||(l.set(J,ne),r.has(ne)||(r.set(ne,D),o.push({number:ne,url:D}))),`[${ne}]`}),O=O.replace(/\[(\d+)\]/g,(R,F)=>{const D=parseInt(F,10);return`[${u.get(D)||D}]`}),O}),x=[];for(const[A,O]of l.entries()){const j=a.get(A)||A,{baseUrl:R,anchor:F}=Zf(j),D=Qf(j);x.push({url:j,baseUrl:R,numbers:[O],anchor:F,title:D})}x.sort((A,O)=>(A.numbers[0]||0)-(O.numbers[0]||0));const P=new Map;let E=1;for(const A of x){const O=A.numbers[0];P.set(O,E),A.numbers=[E],E++}const L=new Map;for(const[A,O]of r.entries()){const j=P.get(A);j&&L.set(j,O)}const N=o.map(A=>{const O=P.get(A.number);return O?{number:O,url:A.url}:A}).filter(A=>P.has(A.number)),k=Array.from(P.entries()).sort((A,O)=>O[0]-A[0]);let I=T.join("");for(const[A,O]of k){const j=new RegExp(`\\[${A}\\](?!\\d)`,"g");I=I.replace(j,`[${O}]`)}return{processedText:I,citations:N.sort((A,O)=>A.number-O.number),citationMap:L,groupedCitations:x,referencesText:d}}function vn(e){if(typeof e=="string")try{const t=JSON.parse(e);return vn(t)}catch{return e}if(Array.isArray(e))return e.map(vn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=vn(s);return t}return e}function Rs(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return vn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?vn(e):{}}function em({theme:e="auto",layout:t="sidebar",model:n="auto",animated:s=!0,title:r="Chat",logo:o=void 0,defaultWidth:i=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:d=[],safeTools:h=[],toolMetadata:m,systemPrompt:p="",agentId:S,agentName:w,tokenEndpoint:T="/api/arcten/token",apiBaseUrl:x="https://api.arcten.com",user:P,state:E,onStateChange:L,allowStateEdits:N=!0,sources:k,ragConfig:I,showCitations:A=!0,sensitiveParams:O,autoDetectSensitive:j=!1}){const{showSecureModal:R}=il(),F=xo({apiBaseUrl:x,tokenEndpoint:T,user:P,tools:d,safeTools:h,toolMetadata:m,sensitiveParams:O,autoDetectSensitive:j,agentId:S,agentName:w,state:E,onStateChange:L,allowStateEdits:N,sources:k,ragConfig:I});f.useMemo(()=>I!==void 0?I:k&&k.length>0?{enabled:!0,organizationId:k[0],autoExecute:!0,filters:void 0}:{enabled:!1},[k,I]);const[D,$]=f.useState(u),[J,ne]=f.useState(i),[G,se]=f.useState(600),[fe,ge]=f.useState(!1),[B,Ct]=f.useState(!1),[Te,at]=f.useState(!1),[we,Re]=f.useState({x:100,y:100}),[Qt,te]=f.useState(!1),[en,lt]=f.useState({x:0,y:0}),[tn,Nn]=f.useState(!1),Ve=f.useRef(null),ct=f.useRef(null),[ut,je]=f.useState(""),[nn,ls]=f.useState(null),[jt,Dn]=f.useState("Thinking..."),[dt,Je]=f.useState(new Set),[cs,Rn]=f.useState(""),[ze,us]=f.useState([]),Vn=f.useRef(new Map),Pt=f.useRef(!1),sn=f.useRef(""),[re,rn]=f.useState(!1),[Ie,ye]=f.useState(!1),Ue=f.useMemo(()=>[...d,...h],[d,h]),Oe=f.useMemo(()=>ir(Ue,m),[Ue,m]),At=f.useMemo(()=>{const C=new Map,_=new Map(Oe.map(W=>[W.name,W]));return Ue.forEach(W=>{const K=W[ke];if(K){const Y=_.get(K);if(Y){C.set(Y.name,W);return}}const q=Oe.find(Y=>Y.name===W.name);q&&C.set(q.name,W)}),C},[Ue,Oe]),ht=f.useMemo(()=>{const C=new Set,_=new Map(Oe.map(W=>[W.name,W]));return h.forEach(W=>{const K=W[ke];if(K&&_.has(K))C.add(K);else{const q=Oe.find(Y=>Y.name===W.name);q&&C.add(q.name)}}),C},[h,Oe]),ft=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];f.useEffect(()=>{if(typeof window<"u"){const C=localStorage.getItem("arcten-sidebar-expanded");C&&$(JSON.parse(C));const _=localStorage.getItem("arcten-sidebar-width");_&&ne(parseInt(_));const W=localStorage.getItem("arcten-sidebar-height");W&&se(parseInt(W));const K=localStorage.getItem("arcten-sidebar-detached");K&&Ct(JSON.parse(K));const q=localStorage.getItem("arcten-sidebar-position");if(q){const Ae=JSON.parse(q),ee=50,xe=Math.max(ee-i,Math.min(Ae.x,window.innerWidth-ee)),X=Math.max(0,Math.min(Ae.y,window.innerHeight-ee));Re({x:xe,y:X})}const Y=localStorage.getItem("arcten-sidebar-minimized");Y&&at(JSON.parse(Y)),Nn(!0)}},[]),f.useMemo(()=>P,[P?.id]),f.useEffect(()=>{(async()=>{if(Ue.length===0)return;const _=Ue.map(W=>`${W.name}:${W.toString()}`).join("|");if(_!==sn.current&&!Pt.current){Pt.current=!0,sn.current=_;try{const W=Ue.map(q=>({name:q.name,code:q.toString()})),K=await fetch(`${x}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:W})});if(K.ok){const q=await K.json();q.tools&&q.tools.forEach(Y=>{Vn.current.set(Y.name,Y)}),us(q.tools)}}catch(W){console.error("Failed to fetch tool descriptions:",W)}finally{Pt.current=!1}}})()},[Ue,x]),f.useEffect(()=>{Promise.resolve().then(()=>Of).then(C=>{ls(()=>C.Response)})},[]),f.useEffect(()=>{const C=()=>{Rn(window.location.pathname)};C(),window.addEventListener("popstate",C);const _=setInterval(C,500);return()=>{window.removeEventListener("popstate",C),clearInterval(_)}},[]);const{id:on,messages:Pe,sendMessage:mt,status:he,error:In,stop:Mt,addToolOutput:Ke,setMessages:_r,clientToken:an,tokenError:ln,conversations:_e,isLoadingConversations:Ze,loadConversation:On,deleteConversation:Et,startNewConversation:qe}=F;f.useEffect(()=>{D&&ct.current&&ct.current.focus()},[D,Pe]),f.useEffect(()=>{const C=Pe[Pe.length-1];if(!C||C.role!=="assistant")return;const _=C.parts?.filter(W=>W.type?.startsWith("tool-")&&W.state==="input-available"&&typeof W.toolCallId=="string"&&W.input!==void 0)||[];for(const W of _){const K=W,q=K.type?.replace("tool-","")||"",Y=K.toolCallId;if(ht.has(q)){if(dt.has(Y))continue;Je(ee=>ee.has(Y)?ee:new Set(ee).add(Y)),(async()=>{try{const ee=At.get(q);if(!ee){console.warn(`[ArctenAgent] Tool ${q} not found in toolsMap`),Ke({toolCallId:Y,tool:q,output:`Error: Tool ${q} not found`}),Je(y=>{const b=new Set(y);return b.delete(Y),b});return}const xe=Rs(K.input),X=Oe.find(y=>y.name===q);let g;if(X&&X.jsonSchema?.properties){const b=Object.keys(X.jsonSchema.properties).map(v=>xe[v]);g=await ee(...b)}else g=await ee(...Object.values(xe));Ke({toolCallId:Y,tool:q,output:g}),Je(y=>{const b=new Set(y);return b.delete(Y),b})}catch(ee){console.error(`[ArctenAgent] Error executing safe tool ${q}:`,ee),Ke({toolCallId:Y,tool:q,output:`Error: ${ee instanceof Error?ee.message:String(ee)}`}),Je(xe=>{const X=new Set(xe);return X.delete(Y),X})}})()}}},[Pe,ht,At,Oe,Ke,dt]);function pt(){$(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Ln(){$(!1),localStorage.setItem("arcten-sidebar-expanded","false")}f.useEffect(()=>{},[D]),f.useEffect(()=>{Ve.current&&Ve.current.scrollIntoView({behavior:"smooth"})},[Pe]),f.useEffect(()=>{function C(_){_.key==="Escape"&&(he==="streaming"||he==="submitted")&&(_.preventDefault(),Mt())}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[he,Mt]);function Fn(C){const _=Math.floor((Date.now()-C)/1e3);return _<60?"now":_<3600?`${Math.floor(_/60)}m`:_<86400?`${Math.floor(_/3600)}h`:`${Math.floor(_/86400)}d`}function kt(){qe(),ye(!1)}function cn(C){if(C.preventDefault(),!ut.trim())return;(he==="streaming"||he==="submitted")&&Mt();const _=ft[Math.floor(Math.random()*ft.length)]||"Thinking...";Dn(_),mt({text:ut}),je("")}function ds(C){const _=C.target.value;je(_)}f.useEffect(()=>{if(!fe)return;function C(W){if(B){const K=W.clientX-we.x,q=W.clientY-we.y;K>=a&&K<=l&&ne(K),q>=400&&q<=1e3&&se(q)}else{const K=window.innerWidth-W.clientX;K>=a&&K<=l&&ne(K)}}function _(){ge(!1),localStorage.setItem("arcten-sidebar-width",J.toString()),localStorage.setItem("arcten-sidebar-height",G.toString())}return window.addEventListener("mousemove",C),window.addEventListener("mouseup",_),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",_)}},[fe,J,G,B,we,a,l]);function $n(C){C.preventDefault(),ge(!0)}function Xe(){Ct(!0),at(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function hs(){Ct(!1),at(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Nt(){at(!Te),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!Te))}function un(C){B&&(te(!0),lt({x:C.clientX-we.x,y:C.clientY-we.y}))}return f.useEffect(()=>{if(!B)return;function C(){Re(_=>{const K=window.innerWidth-50,q=window.innerHeight-50,Y=50-J,Ae=0,ee=Math.max(Y,Math.min(_.x,K)),xe=Math.max(Ae,Math.min(_.y,q));if(ee!==_.x||xe!==_.y){const X={x:ee,y:xe};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(X)),X}return _})}return window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[B,J]),f.useEffect(()=>{if(!Qt)return;function C(W){const K=W.clientX-en.x,q=W.clientY-en.y,Y=50,Ae=window.innerWidth-Y,ee=window.innerHeight-Y,xe=Y-J,X=0,g=Math.max(xe,Math.min(K,Ae)),y=Math.max(X,Math.min(q,ee));Re({x:g,y})}function _(){te(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(we))}return window.addEventListener("mousemove",C),window.addEventListener("mouseup",_),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",_)}},[Qt,en,we,J]),tn?ln?c.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:c.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",ln]})}):an?c.jsx(Hu,{features:Af,children:c.jsx(Xn,{id:"arcten-sidebar","data-theme":e,"data-layout":t,"data-model":n,initial:B?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:B?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
20
|
-
${
|
|
19
|
+
`),()=>{T.contains(v)&&T.removeChild(v)}},[t]),c.jsx(Gu,{isPresent:t,childRef:o,sizeRef:i,children:_e.cloneElement(e,{ref:l})})}const Hu=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:o,mode:i,anchorX:a,root:l})=>{const u=ur(Ju),d=f.useId();let h=!0,m=f.useMemo(()=>(h=!1,{id:d,initial:t,isPresent:n,custom:r,onExitComplete:p=>{u.set(p,!0);for(const w of u.values())if(!w)return;s&&s()},register:p=>(u.set(p,!1),()=>u.delete(p))}),[n,u,s]);return o&&h&&(m={...m}),f.useMemo(()=>{u.forEach((p,w)=>u.set(w,!1))},[n]),_e.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),i==="popLayout"&&(e=c.jsx(Yu,{isPresent:n,anchorX:a,root:l,children:e})),c.jsx(ls.Provider,{value:m,children:e})};function Ju(){return new Map}function ma(e=!0){const t=f.useContext(ls);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:r}=t,o=f.useId();f.useEffect(()=>{if(e)return r(o)},[e]);const i=f.useCallback(()=>e&&s&&s(o),[o,s,e]);return!n&&s?[!1,i]:[!0]}const Kn=e=>e.key||"";function vi(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const Zu=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:o="sync",propagate:i=!1,anchorX:a="left",root:l})=>{const[u,d]=ma(i),h=f.useMemo(()=>vi(e),[e]),m=i&&!u?[]:h.map(Kn),p=f.useRef(!0),w=f.useRef(h),v=ur(()=>new Map),[T,x]=f.useState(h),[P,E]=f.useState(h);To(()=>{p.current=!1,w.current=h;for(let k=0;k<P.length;k++){const V=Kn(P[k]);m.includes(V)?v.delete(V):v.get(V)!==!0&&v.set(V,!1)}},[P,m.length,m.join("-")]);const O=[];if(h!==T){let k=[...h];for(let V=0;V<P.length;V++){const A=P[V],I=Kn(A);m.includes(I)||(k.splice(V,0,A),O.push(A))}return o==="wait"&&O.length&&(k=O),E(vi(k)),x(h),null}process.env.NODE_ENV!=="production"&&o==="wait"&&P.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:N}=f.useContext(cr);return c.jsx(c.Fragment,{children:P.map(k=>{const V=Kn(k),A=i&&!u?!1:h===P||m.includes(V),I=()=>{if(v.has(V))v.set(V,!0);else return;let j=!0;v.forEach(R=>{R||(j=!1)}),j&&(N?.(),E(w.current),i&&d?.(),s&&s())};return c.jsx(Hu,{isPresent:A,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:o,root:l,onExitComplete:A?void 0:I,anchorX:a,children:k},V)})})},Vr=f.createContext({strict:!1}),wi={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Wt={};for(const e in wi)Wt[e]={isEnabled:t=>wi[e].some(n=>!!t[n])};function Zs(e){for(const t in e)Wt[t]={...Wt[t],...e[t]}}function Qu({children:e,features:t,strict:n=!1}){const[,s]=f.useState(!Ps(t)),r=f.useRef(void 0);if(!Ps(t)){const{renderer:o,...i}=t;r.current=o,Zs(i)}return f.useEffect(()=>{Ps(t)&&t().then(({renderer:o,...i})=>{Zs(i),r.current=o,s(!0)})},[]),c.jsx(Vr.Provider,{value:{renderer:r.current,strict:n},children:e})}function Ps(e){return typeof e=="function"}const ed=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function is(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||ed.has(e)}let pa=e=>!is(e);function td(e){typeof e=="function"&&(pa=t=>t.startsWith("on")?!is(t):e(t))}try{td(require("@emotion/is-prop-valid").default)}catch{}function nd(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||(pa(r)||n===!0&&is(r)||!t&&!is(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const cs=f.createContext({});function us(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Mn(e){return typeof e=="string"||Array.isArray(e)}const Ir=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Or=["initial",...Ir];function ds(e){return us(e.animate)||Or.some(t=>Mn(e[t]))}function ga(e){return!!(ds(e)||e.variants)}function sd(e,t){if(ds(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Mn(n)?n:void 0,animate:Mn(s)?s:void 0}}return e.inherit!==!1?t:{}}function rd(e){const{initial:t,animate:n}=sd(e,f.useContext(cs));return f.useMemo(()=>({initial:t,animate:n}),[Si(t),Si(n)])}function Si(e){return Array.isArray(e)?e.join(" "):e}const En={};function id(e){for(const t in e)En[t]=e[t],br(t)&&(En[t].isCSSVariable=!0)}function ya(e,{layout:t,layoutId:n}){return Yt.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!En[e]||e==="opacity")}const od={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},ad=Gt.length;function ld(e,t,n){let s="",r=!0;for(let o=0;o<ad;o++){const i=Gt[o],a=e[i];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(i.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=la(a,kr[i]);if(!l){r=!1;const d=od[i]||i;s+=`${d}(${u}) `}n&&(t[i]=u)}}return s=s.trim(),n?s=n(t,r?"":s):r&&(s="none"),s}function Lr(e,t,n){const{style:s,vars:r,transformOrigin:o}=e;let i=!1,a=!1;for(const l in t){const u=t[l];if(Yt.has(l)){i=!0;continue}else if(br(l)){r[l]=u;continue}else{const d=la(u,kr[l]);l.startsWith("origin")?(a=!0,o[l]=d):s[l]=d}}if(t.transform||(i||n?s.transform=ld(t,e.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:d=0}=o;s.transformOrigin=`${l} ${u} ${d}`}}const Fr=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function xa(e,t,n){for(const s in t)!we(t[s])&&!ya(s,n)&&(e[s]=t[s])}function cd({transformTemplate:e},t){return f.useMemo(()=>{const n=Fr();return Lr(n,t,e),Object.assign({},n.vars,n.style)},[t])}function ud(e,t){const n=e.style||{},s={};return xa(s,n,e),Object.assign(s,cd(e,t)),s}function dd(e,t){const n={},s=ud(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const hd={offset:"stroke-dashoffset",array:"stroke-dasharray"},fd={offset:"strokeDashoffset",array:"strokeDasharray"};function md(e,t,n=1,s=0,r=!0){e.pathLength=1;const o=r?hd:fd;e[o.offset]=B.transform(-s);const i=B.transform(t),a=B.transform(n);e[o.array]=`${i} ${a}`}function ba(e,{attrX:t,attrY:n,attrScale:s,pathLength:r,pathSpacing:o=1,pathOffset:i=0,...a},l,u,d){if(Lr(e,a,u),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:h,style:m}=e;h.transform&&(m.transform=h.transform,delete h.transform),(m.transform||h.transformOrigin)&&(m.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),m.transform&&(m.transformBox=d?.transformBox??"fill-box",delete h.transformBox),t!==void 0&&(h.x=t),n!==void 0&&(h.y=n),s!==void 0&&(h.scale=s),r!==void 0&&md(h,r,o,i,!1)}const va=()=>({...Fr(),attrs:{}}),wa=e=>typeof e=="string"&&e.toLowerCase()==="svg";function pd(e,t,n,s){const r=f.useMemo(()=>{const o=va();return ba(o,t,wa(s),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};xa(o,e.style,e),r.style={...o,...r.style}}return r}const gd=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function $r(e){return typeof e!="string"||e.includes("-")?!1:!!(gd.indexOf(e)>-1||/[A-Z]/u.test(e))}function yd(e,t,n,{latestValues:s},r,o=!1){const a=($r(e)?pd:dd)(t,s,r,e),l=nd(t,typeof e=="string",o),u=e!==f.Fragment?{...l,...a,ref:n}:{},{children:d}=t,h=f.useMemo(()=>we(d)?d.get():d,[d]);return f.createElement(e,{...u,children:h})}function Ti(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Br(e,t,n,s){if(typeof t=="function"){const[r,o]=Ti(s);t=t(n!==void 0?n:e.custom,r,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[r,o]=Ti(s);t=t(n!==void 0?n:e.custom,r,o)}return t}function Qn(e){return we(e)?e.get():e}function xd({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:bd(n,s,r,e),renderState:t()}}function bd(e,t,n,s){const r={},o=s(e,{});for(const m in o)r[m]=Qn(o[m]);let{initial:i,animate:a}=e;const l=ds(e),u=ga(e);t&&u&&!l&&e.inherit!==!1&&(i===void 0&&(i=t.initial),a===void 0&&(a=t.animate));let d=n?n.initial===!1:!1;d=d||i===!1;const h=d?a:i;if(h&&typeof h!="boolean"&&!us(h)){const m=Array.isArray(h)?h:[h];for(let p=0;p<m.length;p++){const w=Br(e,m[p]);if(w){const{transitionEnd:v,transition:T,...x}=w;for(const P in x){let E=x[P];if(Array.isArray(E)){const O=d?E.length-1:0;E=E[O]}E!==null&&(r[P]=E)}for(const P in v)r[P]=v[P]}}}return r}const Sa=e=>(t,n)=>{const s=f.useContext(cs),r=f.useContext(ls),o=()=>xd(e,t,s,r);return n?o():ur(o)};function zr(e,t,n){const{style:s}=e,r={};for(const o in s)(we(s[o])||t.style&&we(t.style[o])||ya(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(r[o]=s[o]);return r}const vd=Sa({scrapeMotionValuesFromProps:zr,createRenderState:Fr});function Ta(e,t,n){const s=zr(e,t,n);for(const r in e)if(we(e[r])||we(t[r])){const o=Gt.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;s[o]=e[r]}return s}const wd=Sa({scrapeMotionValuesFromProps:Ta,createRenderState:va}),Sd=Symbol.for("motionComponentSymbol");function Ft(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Td(e,t,n){return f.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):Ft(n)&&(n.current=s))},[t])}const Ur=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Cd="framerAppearId",Ca="data-"+Ur(Cd),ja=f.createContext({});function jd(e,t,n,s,r){const{visualElement:o}=f.useContext(cs),i=f.useContext(Vr),a=f.useContext(ls),l=f.useContext(Rr).reducedMotion,u=f.useRef(null);s=s||i.renderer,!u.current&&s&&(u.current=s(e,{visualState:t,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const d=u.current,h=f.useContext(ja);d&&!d.projection&&r&&(d.type==="html"||d.type==="svg")&&Pd(u.current,n,r,h);const m=f.useRef(!1);f.useInsertionEffect(()=>{d&&m.current&&d.update(n,a)});const p=n[Ca],w=f.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return To(()=>{d&&(m.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),d.scheduleRenderMicrotask(),w.current&&d.animationState&&d.animationState.animateChanges())}),f.useEffect(()=>{d&&(!w.current&&d.animationState&&d.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(p)}),w.current=!1),d.enteringChildren=void 0)}),d}function Pd(e,t,n,s){const{layoutId:r,layout:o,drag:i,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Pa(e.parent)),e.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!i||a&&Ft(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:d,layoutScroll:l,layoutRoot:u})}function Pa(e){if(e)return e.options.allowProjection!==!1?e.projection:Pa(e.parent)}function es(e,{forwardMotionProps:t=!1}={},n,s){n&&Zs(n);const r=$r(e)?wd:vd;function o(a,l){let u;const d={...f.useContext(Rr),...a,layoutId:Ad(a)},{isStatic:h}=d,m=rd(a),p=r(a,h);if(!h&&dr){Md(d,n);const w=Ed(d);u=w.MeasureLayout,m.visualElement=jd(e,p,d,s,w.ProjectionNode)}return c.jsxs(cs.Provider,{value:m,children:[u&&m.visualElement?c.jsx(u,{visualElement:m.visualElement,...d}):null,yd(e,a,Td(p,m.visualElement,l),p,h,t)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const i=f.forwardRef(o);return i[Sd]=e,i}function Ad({layoutId:e}){const t=f.useContext(cr).id;return t&&e!==void 0?t+"-"+e:e}function Md(e,t){const n=f.useContext(Vr).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Kt(!1,s,"lazy-strict-mode"):et(!1,s,"lazy-strict-mode")}}function Ed(e){const{drag:t,layout:n}=Wt;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function kd(e,t){if(typeof Proxy>"u")return es;const n=new Map,s=(o,i)=>es(o,i,e,t),r=(o,i)=>(process.env.NODE_ENV!=="production"&&gr(!1,"motion() is deprecated. Use motion.create() instead."),s(o,i));return new Proxy(r,{get:(o,i)=>i==="create"?s:(n.has(i)||n.set(i,es(i,void 0,e,t)),n.get(i))})}function Aa({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Nd({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Dd(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function As(e){return e===void 0||e===1}function Qs({scale:e,scaleX:t,scaleY:n}){return!As(e)||!As(t)||!As(n)}function Tt(e){return Qs(e)||Ma(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ma(e){return Ci(e.x)||Ci(e.y)}function Ci(e){return e&&e!=="0%"}function os(e,t,n){const s=e-n,r=t*s;return n+r}function ji(e,t,n,s,r){return r!==void 0&&(e=os(e,r,s)),os(e,n,s)+t}function er(e,t=0,n=1,s,r){e.min=ji(e.min,t,n,s,r),e.max=ji(e.max,t,n,s,r)}function Ea(e,{x:t,y:n}){er(e.x,t.translate,t.scale,t.originPoint),er(e.y,n.translate,n.scale,n.originPoint)}const Pi=.999999999999,Ai=1.0000000000001;function Rd(e,t,n,s=!1){const r=n.length;if(!r)return;t.x=t.y=1;let o,i;for(let a=0;a<r;a++){o=n[a],i=o.projectionDelta;const{visualElement:l}=o.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&Bt(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Ea(e,i)),s&&Tt(o.latestValues)&&Bt(e,o.latestValues))}t.x<Ai&&t.x>Pi&&(t.x=1),t.y<Ai&&t.y>Pi&&(t.y=1)}function $t(e,t){e.min=e.min+t,e.max=e.max+t}function Mi(e,t,n,s,r=.5){const o=ce(e.min,e.max,r);er(e,t,n,o,s)}function Bt(e,t){Mi(e.x,t.x,t.scaleX,t.scale,t.originX),Mi(e.y,t.y,t.scaleY,t.scale,t.originY)}function ka(e,t){return Aa(Dd(e.getBoundingClientRect(),t))}function Vd(e,t,n){const s=ka(e,n),{scroll:r}=t;return r&&($t(s.x,r.offset.x),$t(s.y,r.offset.y)),s}const Ei=()=>({translate:0,scale:1,origin:0,originPoint:0}),zt=()=>({x:Ei(),y:Ei()}),ki=()=>({min:0,max:0}),de=()=>({x:ki(),y:ki()}),tr={current:null},Na={current:!1};function Id(){if(Na.current=!0,!!dr)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>tr.current=e.matches;e.addEventListener("change",t),t()}else tr.current=!1}const Od=new WeakMap;function Ld(e,t,n){for(const s in t){const r=t[s],o=n[s];if(we(r))e.addValue(s,r);else if(we(o))e.addValue(s,Xt(r,{owner:e}));else if(o!==r)if(e.hasValue(s)){const i=e.getValue(s);i.liveStyle===!0?i.jump(r):i.hasAnimated||i.set(r)}else{const i=e.getStaticValue(s);e.addValue(s,Xt(i!==void 0?i:r,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Ni=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Fd{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:r,blockInitialAnimation:o,visualState:i},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Mr,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=Me.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,ae.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=i;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=ds(n),this.isVariantNode=ga(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:d,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in h){const p=h[m];l[m]!==void 0&&we(p)&&p.set(l[m])}}mount(t){this.current=t,Od.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Na.current||Id(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:tr.current,process.env.NODE_ENV!=="production"&&gr(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),ct(this.notifyUpdate),ct(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=Yt.has(t);s&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",i=>{this.latestValues[t]=i,this.props.onUpdate&&ae.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{r(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Wt){const n=Wt[t];if(!n)continue;const{isEnabled:s,Feature:r}=n;if(!this.features[t]&&r&&s(this.props)&&(this.features[t]=new r(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):de()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Ni.length;s++){const r=Ni[s];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const o="on"+r,i=t[o];i&&(this.propEventSubscriptions[r]=this.on(r,i))}this.prevMotionValues=Ld(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=Xt(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(Co(s)||Po(s))?s=parseFloat(s):!Wu(s)&&ut.test(n)&&(s=aa(t,n)),this.setBaseTarget(t,we(s)?s.get():s)),we(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=Br(this.props,n,this.presenceContext?.custom);o&&(s=o[t])}if(n&&s!==void 0)return s;const r=this.getBaseTargetFromProps(this.props,t);return r!==void 0&&!we(r)?r:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new pr),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Nr.render(this.render)}}class Da extends Fd{constructor(){super(...arguments),this.KeyframeResolver=Ru}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;we(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Ra(e,{style:t,vars:n},s,r){const o=e.style;let i;for(i in t)o[i]=t[i];r?.applyProjectionStyles(o,s);for(i in n)o.setProperty(i,n[i])}function $d(e){return window.getComputedStyle(e)}class Bd extends Da{constructor(){super(...arguments),this.type="html",this.renderInstance=Ra}readValueFromInstance(t,n){if(Yt.has(n))return this.projection?.isProjecting?Ws(n):Jc(t,n);{const s=$d(t),r=(br(n)?s.getPropertyValue(n):s[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return ka(t,n)}build(t,n,s){Lr(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return zr(t,n,s)}}const Va=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function zd(e,t,n,s){Ra(e,t,void 0,s);for(const r in t.attrs)e.setAttribute(Va.has(r)?r:Ur(r),t.attrs[r])}class Ud extends Da{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=de}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Yt.has(n)){const s=oa(n);return s&&s.default||0}return n=Va.has(n)?n:Ur(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return Ta(t,n,s)}build(t,n,s){ba(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,r){zd(t,n,s,r)}mount(t){this.isSVGTag=wa(t.tagName),super.mount(t)}}const Ia=(e,t)=>$r(e)?new Ud(t):new Bd(t,{allowProjection:e!==f.Fragment});function _t(e,t,n){const s=e.getProps();return Br(s,t,n!==void 0?n:s.custom,e)}const nr=e=>Array.isArray(e);function _d(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Xt(n))}function Xd(e){return nr(e)?e[e.length-1]||0:e}function Wd(e,t){const n=_t(e,t);let{transitionEnd:s={},transition:r={},...o}=n||{};o={...o,...s};for(const i in o){const a=Xd(o[i]);_d(e,i,a)}}function Kd(e){return!!(we(e)&&e.add)}function sr(e,t){const n=e.getValue("willChange");if(Kd(n))return n.add(t);if(!n&&tt.WillChange){const s=new tt.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function Oa(e){return e.props[Ca]}const qd=e=>e!==null;function Gd(e,{repeat:t,repeatType:n="loop"},s){const r=e.filter(qd),o=t&&n!=="loop"&&t%2===1?0:r.length-1;return r[o]}const Yd={type:"spring",stiffness:500,damping:25,restSpeed:10},Hd=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Jd={type:"keyframes",duration:.8},Zd={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Qd=(e,{keyframes:t})=>t.length>2?Jd:Yt.has(e)?e.startsWith("scale")?Hd(t[1]):Yd:Zd;function eh({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:r,repeat:o,repeatType:i,repeatDelay:a,from:l,elapsed:u,...d}){return!!Object.keys(d).length}const _r=(e,t,n,s={},r,o)=>i=>{const a=Er(s,e)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-Xe(l);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-u,onUpdate:m=>{t.set(m),a.onUpdate&&a.onUpdate(m)},onComplete:()=>{i(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:o?void 0:r};eh(a)||Object.assign(d,Qd(e,d)),d.duration&&(d.duration=Xe(d.duration)),d.repeatDelay&&(d.repeatDelay=Xe(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let h=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(Hs(d),d.delay===0&&(h=!0)),(tt.instantAnimations||tt.skipAnimations)&&(h=!0,Hs(d),d.delay=0),d.allowFlatten=!a.type&&!a.ease,h&&!o&&t.get()!==void 0){const m=Gd(d.keyframes,a);if(m!==void 0){ae.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new Ar(d):new vu(d)};function th({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function La(e,t,{delay:n=0,transitionOverride:s,type:r}={}){let{transition:o=e.getDefaultTransition(),transitionEnd:i,...a}=t;s&&(o=s);const l=[],u=r&&e.animationState&&e.animationState.getState()[r];for(const d in a){const h=e.getValue(d,e.latestValues[d]??null),m=a[d];if(m===void 0||u&&th(u,d))continue;const p={delay:n,...Er(o||{},d)},w=h.get();if(w!==void 0&&!h.isAnimating&&!Array.isArray(m)&&m===w&&!p.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=Oa(e);if(x){const P=window.MotionHandoffAnimation(x,d,ae);P!==null&&(p.startTime=P,v=!0)}}sr(e,d),h.start(_r(d,h,m,e.shouldReduceMotion&&sa.has(d)?{type:!1}:p,e,v));const T=h.animation;T&&l.push(T)}return i&&Promise.all(l).then(()=>{ae.update(()=>{i&&Wd(e,i)})}),l}function Fa(e,t,n,s=0,r=1){const o=Array.from(e).sort((u,d)=>u.sortNodePosition(d)).indexOf(t),i=e.size,a=(i-1)*s;return typeof n=="function"?n(o,i):r===1?o*s:a-o*s}function rr(e,t,n={}){const s=_t(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:r=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(r=n.transitionOverride);const o=s?()=>Promise.all(La(e,s,n)):()=>Promise.resolve(),i=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:d,staggerDirection:h}=r;return nh(e,t,l,u,d,h,n)}:()=>Promise.resolve(),{when:a}=r;if(a){const[l,u]=a==="beforeChildren"?[o,i]:[i,o];return l().then(()=>u())}else return Promise.all([o(),i(n.delay)])}function nh(e,t,n=0,s=0,r=0,o=1,i){const a=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),a.push(rr(l,t,{...i,delay:n+(typeof s=="function"?0:s)+Fa(e.variantChildren,l,s,r,o)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function sh(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const r=t.map(o=>rr(e,o,n));s=Promise.all(r)}else if(typeof t=="string")s=rr(e,t,n);else{const r=typeof t=="function"?_t(e,t,n.custom):t;s=Promise.all(La(e,r,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function $a(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}const rh=Or.length;function Ba(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Ba(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<rh;n++){const s=Or[n],r=e.props[s];(Mn(r)||r===!1)&&(t[s]=r)}return t}const ih=[...Ir].reverse(),oh=Ir.length;function ah(e){return t=>Promise.all(t.map(({animation:n,options:s})=>sh(e,n,s)))}function lh(e){let t=ah(e),n=Di(),s=!0;const r=l=>(u,d)=>{const h=_t(e,d,l==="exit"?e.presenceContext?.custom:void 0);if(h){const{transition:m,transitionEnd:p,...w}=h;u={...u,...w,...p}}return u};function o(l){t=l(e)}function i(l){const{props:u}=e,d=Ba(e.parent)||{},h=[],m=new Set;let p={},w=1/0;for(let T=0;T<oh;T++){const x=ih[T],P=n[x],E=u[x]!==void 0?u[x]:d[x],O=Mn(E),N=x===l?P.isActive:null;N===!1&&(w=T);let k=E===d[x]&&E!==u[x]&&O;if(k&&s&&e.manuallyAnimateOnMount&&(k=!1),P.protectedKeys={...p},!P.isActive&&N===null||!E&&!P.prevProp||us(E)||typeof E=="boolean")continue;const V=ch(P.prevProp,E);let A=V||x===l&&P.isActive&&!k&&O||T>w&&O,I=!1;const j=Array.isArray(E)?E:[E];let R=j.reduce(r(x),{});N===!1&&(R={});const{prevResolvedValues:F={}}=P,D={...F,...R},L=q=>{A=!0,m.has(q)&&(I=!0,m.delete(q)),P.needsAnimating[q]=!0;const re=e.getValue(q);re&&(re.liveStyle=!1)};for(const q in D){const re=R[q],me=F[q];if(p.hasOwnProperty(q))continue;let xe=!1;nr(re)&&nr(me)?xe=!$a(re,me):xe=re!==me,xe?re!=null?L(q):m.add(q):re!==void 0&&m.has(q)?L(q):P.protectedKeys[q]=!0}P.prevProp=E,P.prevResolvedValues=R,P.isActive&&(p={...p,...R}),s&&e.blockInitialAnimation&&(A=!1);const J=k&&V;A&&(!J||I)&&h.push(...j.map(q=>{const re={type:x};if(typeof q=="string"&&s&&!J&&e.manuallyAnimateOnMount&&e.parent){const{parent:me}=e,xe=_t(me,q);if(me.enteringChildren&&xe){const{delayChildren:_}=xe.transition||{};re.delay=Fa(me.enteringChildren,e,_)}}return{animation:q,options:re}}))}if(m.size){const T={};if(typeof u.initial!="boolean"){const x=_t(e,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(T.transition=x.transition)}m.forEach(x=>{const P=e.getBaseTarget(x),E=e.getValue(x);E&&(E.liveStyle=!0),T[x]=P??null}),h.push({animation:T})}let v=!!h.length;return s&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(v=!1),s=!1,v?t(h):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();e.variantChildren?.forEach(h=>h.animationState?.setActive(l,u)),n[l].isActive=u;const d=i(l);for(const h in n)n[h].protectedKeys={};return d}return{animateChanges:i,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Di()}}}function ch(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!$a(t,e):!1}function wt(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Di(){return{animate:wt(!0),whileInView:wt(),whileHover:wt(),whileTap:wt(),whileDrag:wt(),whileFocus:wt(),exit:wt()}}class dt{constructor(t){this.isMounted=!1,this.node=t}update(){}}class uh extends dt{constructor(t){super(t),t.animationState||(t.animationState=lh(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();us(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let dh=0;class hh extends dt{constructor(){super(...arguments),this.id=dh++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const za={animation:{Feature:uh},exit:{Feature:hh}};function kn(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function Vn(e){return{point:{x:e.pageX,y:e.pageY}}}const fh=e=>t=>Dr(t)&&e(t,Vn(t));function wn(e,t,n,s){return kn(e,t,fh(n),s)}const Ua=1e-4,mh=1-Ua,ph=1+Ua,_a=.01,gh=0-_a,yh=0+_a;function Pe(e){return e.max-e.min}function xh(e,t,n){return Math.abs(e-t)<=n}function Ri(e,t,n,s=.5){e.origin=s,e.originPoint=ce(t.min,t.max,e.origin),e.scale=Pe(n)/Pe(t),e.translate=ce(n.min,n.max,e.origin)-e.originPoint,(e.scale>=mh&&e.scale<=ph||isNaN(e.scale))&&(e.scale=1),(e.translate>=gh&&e.translate<=yh||isNaN(e.translate))&&(e.translate=0)}function Sn(e,t,n,s){Ri(e.x,t.x,n.x,s?s.originX:void 0),Ri(e.y,t.y,n.y,s?s.originY:void 0)}function Vi(e,t,n){e.min=n.min+t.min,e.max=e.min+Pe(t)}function bh(e,t,n){Vi(e.x,t.x,n.x),Vi(e.y,t.y,n.y)}function Ii(e,t,n){e.min=t.min-n.min,e.max=e.min+Pe(t)}function Tn(e,t,n){Ii(e.x,t.x,n.x),Ii(e.y,t.y,n.y)}function De(e){return[e("x"),e("y")]}const Xa=({current:e})=>e?e.ownerDocument.defaultView:null,Oi=(e,t)=>Math.abs(e-t);function vh(e,t){const n=Oi(e.x,t.x),s=Oi(e.y,t.y);return Math.sqrt(n**2+s**2)}class Wa{constructor(t,n,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:o=!1,distanceThreshold:i=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const m=Es(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,w=vh(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!w)return;const{point:v}=m,{timestamp:T}=ye;this.history.push({...v,timestamp:T});const{onStart:x,onMove:P}=this.handlers;p||(x&&x(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),P&&P(this.lastMoveEvent,m)},this.handlePointerMove=(m,p)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=Ms(p,this.transformPagePoint),ae.update(this.updatePoint,!0)},this.handlePointerUp=(m,p)=>{this.end();const{onEnd:w,onSessionEnd:v,resumeAnimation:T}=this.handlers;if(this.dragSnapToOrigin&&T&&T(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=Es(m.type==="pointercancel"?this.lastMoveEventInfo:Ms(p,this.transformPagePoint),this.history);this.startEvent&&w&&w(m,x),v&&v(m,x)},!Dr(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=i,this.contextWindow=r||window;const a=Vn(t),l=Ms(a,this.transformPagePoint),{point:u}=l,{timestamp:d}=ye;this.history=[{...u,timestamp:d}];const{onSessionStart:h}=n;h&&h(t,Es(l,this.history)),this.removeListeners=Nn(wn(this.contextWindow,"pointermove",this.handlePointerMove),wn(this.contextWindow,"pointerup",this.handlePointerUp),wn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),ct(this.updatePoint)}}function Ms(e,t){return t?{point:t(e.point)}:e}function Li(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Es({point:e},t){return{point:e,delta:Li(e,Ka(t)),offset:Li(e,wh(t)),velocity:Sh(t,.1)}}function wh(e){return e[0]}function Ka(e){return e[e.length-1]}function Sh(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Ka(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>Xe(t)));)n--;if(!s)return{x:0,y:0};const o=Ve(r.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const i={x:(r.x-s.x)/o,y:(r.y-s.y)/o};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function Th(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?ce(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?ce(n,e,s.max):Math.min(e,n)),e}function Fi(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function Ch(e,{top:t,left:n,bottom:s,right:r}){return{x:Fi(e.x,n,r),y:Fi(e.y,t,s)}}function $i(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function jh(e,t){return{x:$i(e.x,t.x),y:$i(e.y,t.y)}}function Ph(e,t){let n=.5;const s=Pe(e),r=Pe(t);return r>s?n=jn(t.min,t.max-s,e.min):s>r&&(n=jn(e.min,e.max-r,t.min)),Qe(0,1,n)}function Ah(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const ir=.35;function Mh(e=ir){return e===!1?e=0:e===!0&&(e=ir),{x:Bi(e,"left","right"),y:Bi(e,"top","bottom")}}function Bi(e,t,n){return{min:zi(e,t),max:zi(e,n)}}function zi(e,t){return typeof e=="number"?e:e[t]||0}const Eh=new WeakMap;class kh{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=de(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const o=h=>{const{dragSnapToOrigin:m}=this.getProps();m?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Vn(h).point)},i=(h,m)=>{const{drag:p,dragPropagation:w,onDragStart:v}=this.getProps();if(p&&!w&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Lu(p),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),De(x=>{let P=this.getAxisMotionValue(x).get()||0;if(He.test(P)){const{projection:E}=this.visualElement;if(E&&E.layout){const O=E.layout.layoutBox[x];O&&(P=Pe(O)*(parseFloat(P)/100))}}this.originPoint[x]=P}),v&&ae.postRender(()=>v(h,m)),sr(this.visualElement,"transform");const{animationState:T}=this.visualElement;T&&T.setActive("whileDrag",!0)},a=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m;const{dragPropagation:p,dragDirectionLock:w,onDirectionLock:v,onDrag:T}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:x}=m;if(w&&this.currentDirection===null){this.currentDirection=Nh(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",m.point,x),this.updateAxis("y",m.point,x),this.visualElement.render(),T&&T(h,m)},l=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m,this.stop(h,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>De(h=>this.getAnimationState(h)==="paused"&&this.getAxisMotionValue(h).animation?.play()),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Wa(t,{onSessionStart:o,onStart:i,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:Xa(this.visualElement)})}stop(t,n){const s=t||this.latestPointerEvent,r=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!r||!s)return;const{velocity:i}=r;this.startAnimation(i);const{onDragEnd:a}=this.getProps();a&&ae.postRender(()=>a(s,r))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:r}=this.getProps();if(!s||!qn(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(i=Th(i,this.constraints[t],this.elastic[t])),o.set(i)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;t&&Ft(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=Ch(s.layoutBox,t):this.constraints=!1,this.elastic=Mh(n),r!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&De(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Ah(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Ft(t))return!1;const s=t.current;et(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=Vd(s,r.root,this.visualElement.getTransformPagePoint());let i=jh(r.layout.layoutBox,o);if(n){const a=n(Nd(i));this.hasMutatedConstraints=!!a,a&&(i=Aa(a))}return i}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=De(d=>{if(!qn(d,n,this.currentDirection))return;let h=l&&l[d]||{};i&&(h={min:0,max:0});const m=r?200:1e6,p=r?40:1e7,w={type:"inertia",velocity:s?t[d]:0,bounceStiffness:m,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...o,...h};return this.startAxisValueAnimation(d,w)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return sr(this.visualElement,t),s.start(_r(t,s,0,n,this.visualElement,!1))}stopAnimation(){De(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){De(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),r=s[n];return r||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){De(n=>{const{drag:s}=this.getProps();if(!qn(n,s,this.currentDirection))return;const{projection:r}=this.visualElement,o=this.getAxisMotionValue(n);if(r&&r.layout){const{min:i,max:a}=r.layout.layoutBox[n];o.set(t[n]-ce(i,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Ft(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};De(i=>{const a=this.getAxisMotionValue(i);if(a&&this.constraints!==!1){const l=a.get();r[i]=Ph({min:l,max:l},this.constraints[i])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),De(i=>{if(!qn(i,t,null))return;const a=this.getAxisMotionValue(i),{min:l,max:u}=this.constraints[i];a.set(ce(l,u,r[i]))})}addListeners(){if(!this.visualElement.current)return;Eh.set(this.visualElement,this);const t=this.visualElement.current,n=wn(t,"pointerdown",l=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Ft(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,o=r.addEventListener("measure",s);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),ae.read(s);const i=kn(window,"resize",()=>this.scalePositionWithinConstraints()),a=r.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(De(d=>{const h=this.getAxisMotionValue(d);h&&(this.originPoint[d]+=l[d].translate,h.set(h.get()+l[d].translate))}),this.visualElement.render())});return()=>{i(),n(),o(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:o=!1,dragElastic:i=ir,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:o,dragElastic:i,dragMomentum:a}}}function qn(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Nh(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Dh extends dt{constructor(t){super(t),this.removeGroupControls=Ie,this.removeListeners=Ie,this.controls=new kh(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ie}unmount(){this.removeGroupControls(),this.removeListeners()}}const Ui=e=>(t,n)=>{e&&ae.postRender(()=>e(t,n))};class Rh extends dt{constructor(){super(...arguments),this.removePointerDownListener=Ie}onPointerDown(t){this.session=new Wa(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Xa(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:Ui(t),onStart:Ui(n),onMove:s,onEnd:(o,i)=>{delete this.session,r&&ae.postRender(()=>r(o,i))}}}mount(){this.removePointerDownListener=wn(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const ts={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function _i(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const gn={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(B.test(e))e=parseFloat(e);else return e;const n=_i(e,t.target.x),s=_i(e,t.target.y);return`${n}% ${s}%`}},Vh={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,r=ut.parse(e);if(r.length>5)return s;const o=ut.createTransformer(e),i=typeof r[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;r[0+i]/=a,r[1+i]/=l;const u=ce(a,l,.5);return typeof r[2+i]=="number"&&(r[2+i]/=u),typeof r[3+i]=="number"&&(r[3+i]/=u),o(r)}};let ks=!1;class Ih extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:o}=t;id(Oh),o&&(n.group&&n.group.add(o),s&&s.register&&r&&s.register(o),ks&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),ts.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:r,isPresent:o}=this.props,{projection:i}=s;return i&&(i.isPresent=o,ks=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==o?i.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?i.promote():i.relegate()||ae.postRender(()=>{const a=i.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Nr.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;ks=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function qa(e){const[t,n]=ma(),s=f.useContext(cr);return c.jsx(Ih,{...e,layoutGroup:s,switchLayoutGroup:f.useContext(ja),isPresent:t,safeToRemove:n})}const Oh={borderRadius:{...gn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:gn,borderTopRightRadius:gn,borderBottomLeftRadius:gn,borderBottomRightRadius:gn,boxShadow:Vh};function Lh(e,t,n){const s=we(e)?e:Xt(e);return s.start(_r("",s,t,n)),s.animation}const Fh=(e,t)=>e.depth-t.depth;class $h{constructor(){this.children=[],this.isDirty=!1}add(t){hr(this.children,t),this.isDirty=!0}remove(t){fr(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Fh),this.isDirty=!1,this.children.forEach(t)}}function Bh(e,t){const n=Me.now(),s=({timestamp:r})=>{const o=r-n;o>=t&&(ct(s),e(o-t))};return ae.setup(s,!0),()=>ct(s)}const Ga=["TopLeft","TopRight","BottomLeft","BottomRight"],zh=Ga.length,Xi=e=>typeof e=="string"?parseFloat(e):e,Wi=e=>typeof e=="number"||B.test(e);function Uh(e,t,n,s,r,o){r?(e.opacity=ce(0,n.opacity??1,_h(s)),e.opacityExit=ce(t.opacity??1,0,Xh(s))):o&&(e.opacity=ce(t.opacity??1,n.opacity??1,s));for(let i=0;i<zh;i++){const a=`border${Ga[i]}Radius`;let l=Ki(t,a),u=Ki(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Wi(l)===Wi(u)?(e[a]=Math.max(ce(Xi(l),Xi(u),s),0),(He.test(u)||He.test(l))&&(e[a]+="%")):e[a]=u}(t.rotate||n.rotate)&&(e.rotate=ce(t.rotate||0,n.rotate||0,s))}function Ki(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const _h=Ya(0,.5,Vo),Xh=Ya(.5,.95,Ie);function Ya(e,t,n){return s=>s<e?0:s>t?1:n(jn(e,t,s))}function qi(e,t){e.min=t.min,e.max=t.max}function Ne(e,t){qi(e.x,t.x),qi(e.y,t.y)}function Gi(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function Yi(e,t,n,s,r){return e-=t,e=os(e,1/n,s),r!==void 0&&(e=os(e,1/r,s)),e}function Wh(e,t=0,n=1,s=.5,r,o=e,i=e){if(He.test(t)&&(t=parseFloat(t),t=ce(i.min,i.max,t/100)-i.min),typeof t!="number")return;let a=ce(o.min,o.max,s);e===o&&(a-=t),e.min=Yi(e.min,t,n,a,r),e.max=Yi(e.max,t,n,a,r)}function Hi(e,t,[n,s,r],o,i){Wh(e,t[n],t[s],t[r],t.scale,o,i)}const Kh=["x","scaleX","originX"],qh=["y","scaleY","originY"];function Ji(e,t,n,s){Hi(e.x,t,Kh,n?n.x:void 0,s?s.x:void 0),Hi(e.y,t,qh,n?n.y:void 0,s?s.y:void 0)}function Zi(e){return e.translate===0&&e.scale===1}function Ha(e){return Zi(e.x)&&Zi(e.y)}function Qi(e,t){return e.min===t.min&&e.max===t.max}function Gh(e,t){return Qi(e.x,t.x)&&Qi(e.y,t.y)}function eo(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Ja(e,t){return eo(e.x,t.x)&&eo(e.y,t.y)}function to(e){return Pe(e.x)/Pe(e.y)}function no(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Yh{constructor(){this.members=[]}add(t){hr(this.members,t),t.scheduleRender()}remove(t){if(fr(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(r=>t===r);if(n===0)return!1;let s;for(let r=n;r>=0;r--){const o=this.members[r];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender(),t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:r}=t.options;r===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Hh(e,t,n){let s="";const r=e.x.translate/t.x,o=e.y.translate/t.y,i=n?.z||0;if((r||o||i)&&(s=`translate3d(${r}px, ${o}px, ${i}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:u,rotate:d,rotateX:h,rotateY:m,skewX:p,skewY:w}=n;u&&(s=`perspective(${u}px) ${s}`),d&&(s+=`rotate(${d}deg) `),h&&(s+=`rotateX(${h}deg) `),m&&(s+=`rotateY(${m}deg) `),p&&(s+=`skewX(${p}deg) `),w&&(s+=`skewY(${w}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const Ns=["","X","Y","Z"],Jh=1e3;let Zh=0;function Ds(e,t,n,s){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),s&&(s[e]=0))}function Za(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Oa(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ae,!(r||o))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&Za(s)}function Qa({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:r}){return class{constructor(i={},a=t?.()){this.id=Zh++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(tf),this.nodes.forEach(of),this.nodes.forEach(af),this.nodes.forEach(nf)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=i,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new $h)}addEventListener(i,a){return this.eventHandlers.has(i)||this.eventHandlers.set(i,new pr),this.eventHandlers.get(i).add(a)}notifyListeners(i,...a){const l=this.eventHandlers.get(i);l&&l.notify(...a)}hasListeners(i){return this.eventHandlers.has(i)}mount(i){if(this.instance)return;this.isSVG=fa(i)&&!_u(i),this.instance=i;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(i),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let d,h=0;const m=()=>this.root.updateBlockedByResize=!1;ae.read(()=>{h=window.innerWidth}),e(i,()=>{const p=window.innerWidth;p!==h&&(h=p,this.root.updateBlockedByResize=!0,d&&d(),d=Bh(m,250),ts.hasAnimatedSinceResize&&(ts.hasAnimatedSinceResize=!1,this.nodes.forEach(io)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:h,hasRelativeLayoutChanged:m,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const w=this.options.transition||u.getDefaultTransition()||hf,{onLayoutAnimationStart:v,onLayoutAnimationComplete:T}=u.getProps(),x=!this.targetLayout||!Ja(this.targetLayout,p),P=!h&&m;if(this.options.layoutRoot||this.resumeFrom||P||h&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const E={...Er(w,"layout"),onPlay:v,onComplete:T};(u.shouldReduceMotion||this.options.layoutRoot)&&(E.delay=0,E.type=!1),this.startAnimation(E),this.setAnimationOrigin(d,P)}else h||io(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const i=this.getStack();i&&i.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),ct(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(lf),this.animationId++)}getTransformTemplate(){const{visualElement:i}=this.options;return i&&i.getProps().transformTemplate}willUpdate(i=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Za(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const h=this.path[d];h.shouldResetTransform=!0,h.updateScroll("snapshot"),h.options.layoutRoot&&h.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),i&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(so);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(ro);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(rf),this.nodes.forEach(Qh),this.nodes.forEach(ef)):this.nodes.forEach(ro),this.clearAllSnapshots();const a=Me.now();ye.delta=Qe(0,1e3/60,a-ye.timestamp),ye.timestamp=a,ye.isProcessing=!0,vs.update.process(ye),vs.preRender.process(ye),vs.render.process(ye),ye.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Nr.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(sf),this.sharedNodes.forEach(cf)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ae.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ae.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Pe(this.snapshot.measuredBox.x)&&!Pe(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const i=this.layout;this.layout=this.measure(!1),this.layoutCorrected=de(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,i?i.layoutBox:void 0)}updateScroll(i="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===i&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:i,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!r)return;const i=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Ha(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;i&&this.instance&&(a||Tt(this.latestValues)||d)&&(r(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(i=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return i&&(l=this.removeTransform(l)),ff(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:i}=this.options;if(!i)return de();const a=i.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(mf))){const{scroll:u}=this.root;u&&($t(a.x,u.offset.x),$t(a.y,u.offset.y))}return a}removeElementScroll(i){const a=de();if(Ne(a,i),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:d,options:h}=u;u!==this.root&&d&&h.layoutScroll&&(d.wasRoot&&Ne(a,i),$t(a.x,d.offset.x),$t(a.y,d.offset.y))}return a}applyTransform(i,a=!1){const l=de();Ne(l,i);for(let u=0;u<this.path.length;u++){const d=this.path[u];!a&&d.options.layoutScroll&&d.scroll&&d!==d.root&&Bt(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),Tt(d.latestValues)&&Bt(l,d.latestValues)}return Tt(this.latestValues)&&Bt(l,this.latestValues),l}removeTransform(i){const a=de();Ne(a,i);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Tt(u.latestValues))continue;Qs(u.latestValues)&&u.updateSnapshot();const d=de(),h=u.measurePageBox();Ne(d,h),Ji(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return Tt(this.latestValues)&&Ji(a,this.latestValues),a}setTargetDelta(i){this.targetDelta=i,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(i){this.options={...this.options,...i,crossfade:i.crossfade!==void 0?i.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==ye.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(i=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(i||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:d,layoutId:h}=this.options;if(!(!this.layout||!(d||h))){if(this.resolvedRelativeTargetAt=ye.timestamp,!this.targetDelta&&!this.relativeTarget){const m=this.getClosestProjectingParent();m&&m.layout&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=de(),this.relativeTargetOrigin=de(),Tn(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),Ne(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=de(),this.targetWithTransforms=de()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),bh(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ne(this.target,this.layout.layoutBox),Ea(this.target,this.targetDelta)):Ne(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const m=this.getClosestProjectingParent();m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=de(),this.relativeTargetOrigin=de(),Tn(this.relativeTargetOrigin,this.target,m.target),Ne(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Qs(this.parent.latestValues)||Ma(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const i=this.getLead(),a=!!this.resumingFrom||this!==i;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===ye.timestamp&&(l=!1),l)return;const{layout:u,layoutId:d}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||d))return;Ne(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,m=this.treeScale.y;Rd(this.layoutCorrected,this.treeScale,this.path,a),i.layout&&!i.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(i.target=i.layout.layoutBox,i.targetWithTransforms=de());const{target:p}=i;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Gi(this.prevProjectionDelta.x,this.projectionDelta.x),Gi(this.prevProjectionDelta.y,this.projectionDelta.y)),Sn(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==m||!no(this.projectionDelta.x,this.prevProjectionDelta.x)||!no(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(i=!0){if(this.options.visualElement?.scheduleRender(),i){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=zt(),this.projectionDelta=zt(),this.projectionDeltaWithTransform=zt()}setAnimationOrigin(i,a=!1){const l=this.snapshot,u=l?l.latestValues:{},d={...this.latestValues},h=zt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=de(),p=l?l.source:void 0,w=this.layout?this.layout.source:void 0,v=p!==w,T=this.getStack(),x=!T||T.members.length<=1,P=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(df));this.animationProgress=0;let E;this.mixTargetDelta=O=>{const N=O/1e3;oo(h.x,i.x,N),oo(h.y,i.y,N),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Tn(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),uf(this.relativeTarget,this.relativeTargetOrigin,m,N),E&&Gh(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=de()),Ne(E,this.relativeTarget)),v&&(this.animationValues=d,Uh(d,u,this.latestValues,N,P,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=N},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(i){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(ct(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ae.update(()=>{ts.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Xt(0)),this.currentAnimation=Lh(this.motionValue,[0,1e3],{...i,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),i.onUpdate&&i.onUpdate(a)},onStop:()=>{},onComplete:()=>{i.onComplete&&i.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const i=this.getStack();i&&i.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Jh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const i=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:d}=i;if(!(!a||!l||!u)){if(this!==i&&this.layout&&u&&el(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||de();const h=Pe(this.layout.layoutBox.x);l.x.min=i.target.x.min,l.x.max=l.x.min+h;const m=Pe(this.layout.layoutBox.y);l.y.min=i.target.y.min,l.y.max=l.y.min+m}Ne(a,l),Bt(a,d),Sn(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(i,a){this.sharedNodes.has(i)||this.sharedNodes.set(i,new Yh),this.sharedNodes.get(i).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const i=this.getStack();return i?i.lead===this:!0}getLead(){const{layoutId:i}=this.options;return i?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:i}=this.options;return i?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:i}=this.options;if(i)return this.root.sharedNodes.get(i)}promote({needsReset:i,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),i&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const i=this.getStack();return i?i.relegate(this):!1}resetSkewAndRotation(){const{visualElement:i}=this.options;if(!i)return;let a=!1;const{latestValues:l}=i;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&Ds("z",i,u,this.animationValues);for(let d=0;d<Ns.length;d++)Ds(`rotate${Ns[d]}`,i,u,this.animationValues),Ds(`skew${Ns[d]}`,i,u,this.animationValues);i.render();for(const d in u)i.setStaticValue(d,u[d]),this.animationValues&&(this.animationValues[d]=u[d]);i.scheduleRender()}applyProjectionStyles(i,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){i.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,i.visibility="",i.opacity="",i.pointerEvents=Qn(a?.pointerEvents)||"",i.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(i.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,i.pointerEvents=Qn(a?.pointerEvents)||""),this.hasProjected&&!Tt(this.latestValues)&&(i.transform=l?l({},""):"none",this.hasProjected=!1);return}i.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let h=Hh(this.projectionDeltaWithTransform,this.treeScale,d);l&&(h=l(d,h)),i.transform=h;const{x:m,y:p}=this.projectionDelta;i.transformOrigin=`${m.origin*100}% ${p.origin*100}% 0`,u.animationValues?i.opacity=u===this?d.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:d.opacityExit:i.opacity=u===this?d.opacity!==void 0?d.opacity:"":d.opacityExit!==void 0?d.opacityExit:0;for(const w in En){if(d[w]===void 0)continue;const{correct:v,applyTo:T,isCSSVariable:x}=En[w],P=h==="none"?d[w]:v(d[w],u);if(T){const E=T.length;for(let O=0;O<E;O++)i[T[O]]=P}else x?this.options.visualElement.renderState.vars[w]=P:i[w]=P}this.options.layoutId&&(i.pointerEvents=u===this?Qn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(i=>i.currentAnimation?.stop()),this.root.nodes.forEach(so),this.root.sharedNodes.clear()}}}function Qh(e){e.updateLayout()}function ef(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=e.layout,{animationType:r}=e.options,o=t.source!==e.layout.source;r==="size"?De(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Pe(h);h.min=n[d].min,h.max=h.min+m}):el(r,t.layoutBox,n)&&De(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Pe(n[d]);h.max=h.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[d].max=e.relativeTarget[d].min+m)});const i=zt();Sn(i,n,t.layoutBox);const a=zt();o?Sn(a,e.applyTransform(s,!0),t.measuredBox):Sn(a,n,t.layoutBox);const l=!Ha(i);let u=!1;if(!e.resumeFrom){const d=e.getClosestProjectingParent();if(d&&!d.resumeFrom){const{snapshot:h,layout:m}=d;if(h&&m){const p=de();Tn(p,t.layoutBox,h.layoutBox);const w=de();Tn(w,n,m.layoutBox),Ja(p,w)||(u=!0),d.options.layoutRoot&&(e.relativeTarget=w,e.relativeTargetOrigin=p,e.relativeParent=d)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:a,layoutDelta:i,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function tf(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function nf(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function sf(e){e.clearSnapshot()}function so(e){e.clearMeasurements()}function ro(e){e.isLayoutDirty=!1}function rf(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function io(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function of(e){e.resolveTargetDelta()}function af(e){e.calcProjection()}function lf(e){e.resetSkewAndRotation()}function cf(e){e.removeLeadSnapshot()}function oo(e,t,n){e.translate=ce(t.translate,0,n),e.scale=ce(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ao(e,t,n,s){e.min=ce(t.min,n.min,s),e.max=ce(t.max,n.max,s)}function uf(e,t,n,s){ao(e.x,t.x,n.x,s),ao(e.y,t.y,n.y,s)}function df(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const hf={duration:.45,ease:[.4,0,.1,1]},lo=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),co=lo("applewebkit/")&&!lo("chrome/")?Math.round:Ie;function uo(e){e.min=co(e.min),e.max=co(e.max)}function ff(e){uo(e.x),uo(e.y)}function el(e,t,n){return e==="position"||e==="preserve-aspect"&&!xh(to(t),to(n),.2)}function mf(e){return e!==e.root&&e.scroll?.wasRoot}const pf=Qa({attachResizeListener:(e,t)=>kn(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Rs={current:void 0},tl=Qa({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Rs.current){const e=new pf({});e.mount(window),e.setOptions({layoutScroll:!0}),Rs.current=e}return Rs.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),gf={pan:{Feature:Rh},drag:{Feature:Dh,ProjectionNode:tl,MeasureLayout:qa}};function ho(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,o=s[r];o&&ae.postRender(()=>o(t,Vn(t)))}class yf extends dt{mount(){const{current:t}=this.node;t&&(this.unmount=Fu(t,(n,s)=>(ho(this.node,s,"Start"),r=>ho(this.node,r,"End"))))}unmount(){}}class xf extends dt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Nn(kn(this.node.current,"focus",()=>this.onFocus()),kn(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function fo(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),o=s[r];o&&ae.postRender(()=>o(t,Vn(t)))}class bf extends dt{mount(){const{current:t}=this.node;t&&(this.unmount=Uu(t,(n,s)=>(fo(this.node,s,"Start"),(r,{success:o})=>fo(this.node,r,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const or=new WeakMap,Vs=new WeakMap,vf=e=>{const t=or.get(e.target);t&&t(e)},wf=e=>{e.forEach(vf)};function Sf({root:e,...t}){const n=e||document;Vs.has(n)||Vs.set(n,{});const s=Vs.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(wf,{root:e,...t})),s[r]}function Tf(e,t,n){const s=Sf(t);return or.set(e,n),s.observe(e),()=>{or.delete(e),s.unobserve(e)}}const Cf={some:0,all:1};class jf extends dt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:r="some",once:o}=t,i={root:n?n.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:Cf[r]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:h}=this.node.getProps(),m=u?d:h;m&&m(l)};return Tf(this.node.current,i,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Pf(t,n))&&this.startObserver()}unmount(){}}function Pf({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const nl={inView:{Feature:jf},tap:{Feature:bf},focus:{Feature:xf},hover:{Feature:yf}},Af={layout:{ProjectionNode:tl,MeasureLayout:qa}},Mf={...za,...nl,...gf,...Af},Ef=kd(Mf,Ia),kf={renderer:Ia,...za,...nl};function Xr(e,t){return es(e,t)}const Nf=Xr("button"),Gn=Xr("div"),Df=Xr("p");function Rf({toolName:e,description:t,args:n,onApprove:s,onDeny:r}){const o=Object.keys(n).length>0;return c.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:c.jsx("span",{className:"text-sm font-medium text-foreground",children:e})}),o&&c.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([i,a])=>c.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[c.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[i,":"]}),c.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},i))})]}),c.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[c.jsxs(Se,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[c.jsx(Z.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),c.jsx(Se,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:r,children:c.jsx(Z.X,{className:"h-3 w-3"})})]})]})})}function Vf({toolName:e,args:t,isDenied:n,isSafe:s}){const[r,o]=f.useState(!1);if(e==="fetchDocContent")return null;const i=["k","maxResults","_organizationId"];e==="searchDocs"&&i.push("filters");const a=Object.fromEntries(Object.entries(t).filter(([u])=>!i.includes(u))),l=Object.keys(a).length>0;return c.jsxs("div",{className:"my-1",children:[c.jsxs("button",{onClick:()=>l&&o(!r),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors bg-muted text-muted-foreground ${l?"cursor-pointer hover:bg-muted/80":""}`,children:[l&&c.jsx("span",{className:"transition-transform duration-200",children:r?c.jsx(Z.ChevronDown,{className:"h-3 w-3"}):c.jsx(Z.ChevronRight,{className:"h-3 w-3"})}),n?c.jsx(Z.X,{className:"h-3 w-3"}):s?c.jsx(Z.Zap,{className:"h-3 w-3"}):c.jsx(Z.Check,{className:"h-3 w-3"}),c.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",e]})]}),r&&l&&c.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:c.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,d])=>c.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[c.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),c.jsx("span",{className:"font-mono text-foreground",children:typeof d=="string"?d:JSON.stringify(d)})]},u))})})]})}function If({...e}){return c.jsx(ar.Root,{"data-slot":"collapsible",...e})}function Of({...e}){return c.jsx(ar.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function Lf({...e}){return c.jsx(ar.CollapsibleContent,{"data-slot":"collapsible-content",...e})}const Ff=f.lazy(()=>import("streamdown").then(e=>({default:e.Streamdown}))),Wr=f.memo(({className:e,...t})=>typeof window>"u"?null:c.jsx(f.Suspense,{fallback:null,children:c.jsx(Ff,{className:ee("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t})}),(e,t)=>e.children===t.children);Wr.displayName="Response";const $f=Object.freeze(Object.defineProperty({__proto__:null,Response:Wr},Symbol.toStringTag,{value:"Module"})),Bf=({children:e,as:t="p",className:n,duration:s=2,spread:r=2})=>{const o=Ef.create(t),i=f.useMemo(()=>(e?.length??0)*r,[e,r]);return c.jsx(o,{animate:{backgroundPosition:"0% center"},className:ee("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${i}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:e})},zf=f.memo(Bf),sl=f.createContext(null),Uf=()=>{const e=f.useContext(sl);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},_f=1e3,Xf=1e3,rl=f.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:s=!0,onOpenChange:r,duration:o,children:i,...a})=>{const[l,u]=Hr.useControllableState({prop:n,defaultProp:s,onChange:r}),[d,h]=Hr.useControllableState({prop:o,defaultProp:0}),[m,p]=f.useState(!1),[w,v]=f.useState(null);f.useEffect(()=>{t?w===null&&v(Date.now()):w!==null&&(h(Math.ceil((Date.now()-w)/Xf)),v(null))},[t,w,h]),f.useEffect(()=>{if(s&&!t&&l&&!m){const x=setTimeout(()=>{u(!1),p(!0)},_f);return()=>clearTimeout(x)}},[t,l,s,u,m]);const T=x=>{u(x)};return c.jsx(sl.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:c.jsx(If,{className:ee("not-prose mb-4",e),onOpenChange:T,open:l,...a,children:i})})}),Wf=(e,t)=>e||t===0?c.jsx(zf,{duration:1,children:"Thinking..."}):t===void 0?c.jsx("p",{children:"Thought for a few seconds"}):c.jsxs("p",{children:["Thought for ",t," seconds"]}),il=f.memo(({className:e,children:t,...n})=>{const{isStreaming:s,isOpen:r,duration:o}=Uf();return c.jsx(Of,{className:ee("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??c.jsxs(c.Fragment,{children:[c.jsx(Z.BrainIcon,{className:"size-4"}),Wf(s,o),c.jsx(Z.ChevronDownIcon,{className:ee("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),ol=f.memo(({className:e,children:t,...n})=>c.jsx(Lf,{className:ee("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:c.jsx(Wr,{className:"grid gap-2",children:t})}));rl.displayName="Reasoning";il.displayName="ReasoningTrigger";ol.displayName="ReasoningContent";function mo(e){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=16`}function Kf({sources:e,citationNumber:t,className:n}){const s=e.find(o=>o.number===t);if(!s)return null;const r=mo(s.domain);return c.jsxs(it,{children:[c.jsx(ot,{asChild:!0,children:c.jsxs("button",{className:ee("inline-flex items-center gap-1 px-1 py-0.5 rounded text-[10px] font-medium","bg-stone-200/60 dark:bg-stone-700/60 text-stone-800 dark:text-stone-200","hover:bg-stone-300/80 dark:hover:bg-stone-600/80","transition-all duration-200","border border-stone-300/60 dark:border-stone-600/60","cursor-pointer hover:scale-105 active:scale-95","leading-tight",n),onClick:o=>{o.preventDefault(),o.stopPropagation(),window.open(s.url,"_blank","noopener,noreferrer")},children:[c.jsx("img",{src:r,alt:"",className:"w-3 h-3 leading-none",onError:o=>{const i=o.target;i.style.display="none"}}),c.jsx("span",{className:"leading-none",children:s.domain})]})}),c.jsx(at,{side:"top",className:"bg-stone-800 dark:bg-stone-900 border border-stone-700 dark:border-stone-600 p-3 max-w-sm z-50 rounded-lg shadow-lg",children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"text-xs font-semibold text-stone-300 dark:text-stone-200 mb-2 pb-2 border-b border-stone-700 dark:border-stone-600",children:["Sources • ",e.length]}),e.map(o=>{const i=o.title||o.domain;return c.jsxs("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:ee("flex items-center gap-2 p-2 rounded-md hover:bg-stone-700/50 dark:hover:bg-stone-700/50 transition-colors","text-stone-300 dark:text-stone-300 hover:text-white dark:hover:text-white"),onClick:a=>a.stopPropagation(),children:[c.jsx("img",{src:mo(o.domain),alt:"",className:"w-4 h-4 flex-shrink-0",onError:a=>{const l=a.target;l.style.display="none"}}),c.jsx("span",{className:"text-xs flex-1 truncate",children:i})]},o.number)})]})})]})}function qf({text:e,citations:t,citationMap:n,groupedCitations:s,referencesText:r,ResponseComponent:o,className:i,showCitations:a=!0,showReferences:l=!0}){const u=f.useRef(null),[d,h]=f.useState([]);f.useEffect(()=>{if(!a||!u.current||t.length===0||n.size===0){(n.size===0||!a)&&h([]);return}const T=u.current;let x,P=!1;const E=new WeakSet,O=()=>{if(!u.current||P)return;P=!0;const k=u.current,V=/\[(\d+)\]/g,A=document.createTreeWalker(k,NodeFilter.SHOW_TEXT,null),I=[];let j;for(;j=A.nextNode();)if(j.nodeType===Node.TEXT_NODE&&!E.has(j)){const F=j,D=F.textContent||"";let L=F.parentElement,J=!1;for(;L&&L!==k;){if(L.tagName==="A"||L.tagName==="CODE"||L.tagName==="PRE"){J=!0;break}L=L.parentElement}if(!J){const q=Array.from(D.matchAll(V)).filter(re=>{if(!re[1])return!1;const me=parseInt(re[1],10);return n.has(me)});q.length>0&&I.push({node:F,matches:q})}}if(I.length===0){P=!1;return}const R=[];I.forEach(({node:F,matches:D})=>{E.add(F);const L=F.textContent||"",J=document.createDocumentFragment();let se=0;D.forEach(q=>{if(!q[1])return;q.index!==void 0&&q.index>se&&J.appendChild(document.createTextNode(L.slice(se,q.index)));const re=document.createElement("span");re.className="inline-flex items-center citation-button-container";const me=parseInt(q[1],10);re.setAttribute("data-citation",q[1]),J.appendChild(re),R.push({element:re,citationNum:me}),se=(q.index||0)+q[0].length}),se<L.length&&J.appendChild(document.createTextNode(L.slice(se))),F.parentNode&&F.parentNode.replaceChild(J,F)}),R.length>0&&h(F=>{const D=new Set(F.map(se=>se.element)),L=F.filter(se=>se.element.isConnected),J=R.filter(se=>!D.has(se.element));return[...L,...J]}),P=!1},N=new MutationObserver(()=>{clearTimeout(x),x=setTimeout(O,100)});return N.observe(T,{childList:!0,subtree:!0,characterData:!0}),x=setTimeout(O,200),()=>{N.disconnect(),clearTimeout(x)}},[e,t,n,a]);const m=s&&s.length>0||n&&n.size>0||r;function p(T){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(T)}&sz=16`}function w(T){try{return new URL(T).hostname.replace(/^www\./,"")}catch{return T}}const v=a&&l&&m?c.jsxs("div",{className:"mt-4 pt-4 border-t border-stone-200 dark:border-stone-700",children:[c.jsx("div",{className:"text-xs font-semibold text-stone-600 dark:text-stone-400 mb-3",children:"References"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:s&&s.length>0?s.map((T,x)=>{const P=T.title||T.baseUrl,E=w(T.url),O=p(E);return c.jsxs("a",{href:T.url,target:"_blank",rel:"noopener noreferrer",className:ee("inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium","bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300","hover:bg-stone-200 dark:hover:bg-stone-700","transition-all duration-200","border border-stone-200 dark:border-stone-700","cursor-pointer hover:scale-105 active:scale-95","no-underline"),children:[c.jsx("img",{src:O,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:N=>{const k=N.target;k.style.display="none"}}),c.jsx("span",{className:"leading-none",children:P})]},`group-${x}`)}):Array.from(n.entries()).sort(([T],[x])=>T-x).map(([T,x])=>{const P=w(x),E=p(P);return c.jsxs("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:ee("inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium","bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300","hover:bg-stone-200 dark:hover:bg-stone-700","transition-all duration-200","border border-stone-200 dark:border-stone-700","cursor-pointer hover:scale-105 active:scale-95","no-underline"),children:[c.jsx("img",{src:E,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:O=>{const N=O.target;N.style.display="none"}}),c.jsx("span",{className:"leading-none",children:x})]},T)})})]}):null;return c.jsxs("div",{className:i,children:[c.jsx("div",{ref:u,children:c.jsx(o,{children:e})}),a&&d.filter(({element:T})=>T.isConnected).map(({element:T,citationNum:x},P)=>{if(!t.find(N=>N.number===x))return null;const O=Array.from(new Map(t.map(N=>{const k=N.url.replace(/\/+$/,""),V=s?.find(A=>A.url.replace(/\/+$/,"")===k);return[k,{number:N.number,url:N.url,domain:w(N.url),title:V?.title}]})).values());return Cl.createPortal(c.jsx(Kf,{sources:O,citationNumber:x},`citation-${x}-${T}`),T,`citation-${x}-${P}`)}),v]})}function Ht({...e}){return c.jsx(Mt.Root,{"data-slot":"dialog",...e})}function Gf({...e}){return c.jsx(Mt.Portal,{"data-slot":"dialog-portal",...e})}function Yf({className:e,...t}){return c.jsx(Mt.Overlay,{"data-slot":"dialog-overlay",className:ee("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Jt({className:e,children:t,showCloseButton:n=!0,...s}){return c.jsxs(Gf,{"data-slot":"dialog-portal",children:[c.jsx(Yf,{}),c.jsxs(Mt.Content,{"data-slot":"dialog-content",className:ee("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...s,children:[t,n&&c.jsxs(Mt.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[c.jsx(Z.XIcon,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Zt({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-header",className:ee("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Qt({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-footer",className:ee("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function en({className:e,...t}){return c.jsx(Mt.Title,{"data-slot":"dialog-title",className:ee("text-lg leading-none font-semibold",e),...t})}function tn({className:e,...t}){return c.jsx(Mt.Description,{"data-slot":"dialog-description",className:ee("text-muted-foreground text-sm",e),...t})}function nn({className:e,type:t,...n}){return c.jsx("input",{type:t,"data-slot":"input",className:ee("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-white px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}function Hf({isOpen:e,title:t="Password Required",description:n="Please enter your password to continue",placeholder:s="Enter password...",onComplete:r}){const[o,i]=f.useState(""),[a,l]=f.useState(!1),[u,d]=f.useState(!1),h=async p=>{if(p.preventDefault(),!!o.trim()){d(!0);try{r(o)}finally{d(!1)}}},m=()=>{i(""),r(null)};return c.jsx(Ht,{open:e,children:c.jsx(Jt,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(Zt,{children:[c.jsx(en,{children:t}),c.jsx(tn,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsxs("div",{className:"relative",children:[c.jsx(nn,{type:a?"text":"password",value:o,onChange:p=>i(p.target.value),placeholder:s,className:"pr-10",autoFocus:!0,disabled:u}),c.jsx("button",{type:"button",onClick:()=>l(!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:u,children:a?c.jsx(Z.EyeOff,{className:"h-4 w-4"}):c.jsx(Z.Eye,{className:"h-4 w-4"})})]})}),c.jsxs(Qt,{children:[c.jsx(Se,{type:"button",variant:"ghost",onClick:m,disabled:u,children:"Cancel"}),c.jsx(Se,{type:"submit",disabled:!o.trim()||u,children:u?"Submitting...":"Submit"})]})]})})})}function Jf({isOpen:e,title:t="Email Required",description:n="Please enter your email address",placeholder:s="Enter email address...",onComplete:r}){const[o,i]=f.useState(""),[a,l]=f.useState(!0),[u,d]=f.useState(!1),h=v=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v),m=v=>{i(v),v.trim()?l(h(v)):l(!0)},p=async v=>{if(v.preventDefault(),!o.trim()||!h(o)){l(!1);return}d(!0);try{r(o)}finally{d(!1)}},w=()=>{i(""),l(!0),r(null)};return c.jsx(Ht,{open:e,children:c.jsx(Jt,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:p,children:[c.jsxs(Zt,{children:[c.jsxs(en,{className:"flex items-center gap-2",children:[c.jsx(Z.Mail,{className:"h-5 w-5"}),t]}),c.jsx(tn,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(nn,{type:"email",value:o,onChange:v=>m(v.target.value),placeholder:s,className:a?"":"border-red-500",autoFocus:!0,disabled:u}),!a&&c.jsx("p",{className:"text-sm text-red-500 mt-1",children:"Please enter a valid email address"})]}),c.jsxs(Qt,{children:[c.jsx(Se,{type:"button",variant:"ghost",onClick:w,disabled:u,children:"Cancel"}),c.jsx(Se,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function Zf({isOpen:e,title:t="Phone Number Required",description:n="Please enter your phone number",placeholder:s="Enter phone number...",onComplete:r}){const[o,i]=f.useState(""),[a,l]=f.useState(!0),[u,d]=f.useState(!1),h=T=>{const x=T.replace(/\D/g,"");return x.length<=3?x:x.length<=6?`(${x.slice(0,3)}) ${x.slice(3)}`:`(${x.slice(0,3)}) ${x.slice(3,6)}-${x.slice(6,10)}`},m=T=>T.replace(/\D/g,"").length===10,p=T=>{const x=h(T);i(x),x.trim()?l(m(x)):l(!0)},w=async T=>{if(T.preventDefault(),!o.trim()||!m(o)){l(!1);return}d(!0);try{const x=o.replace(/\D/g,"");r(x)}finally{d(!1)}},v=()=>{i(""),l(!0),r(null)};return c.jsx(Ht,{open:e,children:c.jsx(Jt,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:w,children:[c.jsxs(Zt,{children:[c.jsxs(en,{className:"flex items-center gap-2",children:[c.jsx(Z.Phone,{className:"h-5 w-5"}),t]}),c.jsx(tn,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(nn,{type:"tel",value:o,onChange:T=>p(T.target.value),placeholder:s,className:a?"":"border-red-500",maxLength:14,autoFocus:!0,disabled:u}),!a&&c.jsx("p",{className:"text-sm text-red-500 mt-1",children:"Please enter a valid 10-digit phone number"})]}),c.jsxs(Qt,{children:[c.jsx(Se,{type:"button",variant:"ghost",onClick:v,disabled:u,children:"Cancel"}),c.jsx(Se,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function Qf({isOpen:e,title:t="PIN Required",description:n="Please enter your PIN",placeholder:s="Enter PIN...",length:r=4,onComplete:o}){const[i,a]=f.useState(""),[l,u]=f.useState(!1),d=p=>{const w=p.replace(/\D/g,"");a(w.slice(0,r))},h=async p=>{if(p.preventDefault(),i.length===r){u(!0);try{o(i)}finally{u(!1)}}},m=()=>{a(""),o(null)};return c.jsx(Ht,{open:e,children:c.jsx(Jt,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(Zt,{children:[c.jsxs(en,{className:"flex items-center gap-2",children:[c.jsx(Z.Shield,{className:"h-5 w-5"}),t]}),c.jsx(tn,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(nn,{type:"password",value:i,onChange:p=>d(p.target.value),placeholder:s,className:"text-center text-lg tracking-widest",maxLength:r,autoFocus:!0,disabled:l}),c.jsxs("p",{className:"text-sm text-gray-500 mt-1 text-center",children:["Enter ",r,"-digit PIN"]})]}),c.jsxs(Qt,{children:[c.jsx(Se,{type:"button",variant:"ghost",onClick:m,disabled:l,children:"Cancel"}),c.jsx(Se,{type:"submit",disabled:i.length!==r||l,children:l?"Submitting...":"Submit"})]})]})})})}function Is({isOpen:e,title:t="Secure Input Required",description:n="Please enter the requested information",placeholder:s="Enter value...",type:r="password",onComplete:o}){const[i,a]=f.useState(""),[l,u]=f.useState(!1),d=async m=>{if(m.preventDefault(),!!i.trim()){u(!0);try{o(i)}finally{u(!1)}}},h=()=>{a(""),o(null)};return c.jsx(Ht,{open:e,children:c.jsx(Jt,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:d,children:[c.jsxs(Zt,{children:[c.jsxs(en,{className:"flex items-center gap-2",children:[c.jsx(Z.Lock,{className:"h-5 w-5"}),t]}),c.jsx(tn,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsx(nn,{type:r,value:i,onChange:m=>a(m.target.value),placeholder:s,autoFocus:!0,disabled:l})}),c.jsxs(Qt,{children:[c.jsx(Se,{type:"button",variant:"ghost",onClick:h,disabled:l,children:"Cancel"}),c.jsx(Se,{type:"submit",disabled:!i.trim()||l,children:l?"Submitting...":"Submit"})]})]})})})}function em({isOpen:e,title:t,description:n,fields:s,onComplete:r,submitText:o="Submit",cancelText:i="Cancel"}){const[a,l]=f.useState(()=>{const j={};return s.forEach(R=>{j[R.name]=R.value||""}),j}),[u,d]=f.useState({}),[h,m]=f.useState({}),[p,w]=f.useState(!1),v=j=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j)?null:"Please enter a valid email address",T=j=>j.replace(/\D/g,"").length===10?null:"Please enter a valid 10-digit phone number",x=(j,R=4)=>j.length===R?null:`PIN must be ${R} digits`,P=j=>{const R=j.replace(/\D/g,"");return R.length<=3?R:R.length<=6?`(${R.slice(0,3)}) ${R.slice(3)}`:`(${R.slice(0,3)}) ${R.slice(3,6)}-${R.slice(6,10)}`},E=(j,R,F)=>{let D=R,L=null;switch(F.type){case"phone":D=P(R),D.trim()&&(L=T(D));break;case"email":R.trim()&&(L=v(R));break;case"pin":D=R.replace(/\D/g,"").slice(0,6),D.trim()&&(L=x(D));break}!L&&F.validation&&D.trim()&&(L=F.validation(D)),l(J=>({...J,[j]:D})),d(J=>({...J,[j]:L||""}))},O=()=>{const j={};let R=!0;return s.forEach(F=>{const D=a[F.name]||"";let L=null;if(F.required&&!D.trim())L=`${F.label} is required`;else if(D.trim()){switch(F.type){case"email":L=v(D);break;case"phone":L=T(D);break;case"pin":L=x(D);break}!L&&F.validation&&(L=F.validation(D))}L&&(j[F.name]=L,R=!1)}),d(j),R},N=async j=>{if(j.preventDefault(),!!O()){w(!0);try{const R={};s.forEach(F=>{const D=a[F.name]?.trim();D&&(F.type==="phone"?R[F.name]=D.replace(/\D/g,""):R[F.name]=D)}),r(R)}finally{w(!1)}}},k=()=>{l({}),d({}),m({}),r(null)},V=j=>{m(R=>({...R,[j]:!R[j]}))},A=j=>{switch(j.type){case"password":return h[j.name]?"text":"password";case"email":return"email";case"phone":return"tel";case"pin":case"ssn":return"password";default:return"text"}},I=j=>{if(j.placeholder)return j.placeholder;switch(j.type){case"email":return"Enter email address...";case"phone":return"Enter phone number...";case"password":return"Enter password...";case"pin":return"Enter PIN...";case"ssn":return"XXX-XX-XXXX";case"creditCard":return"XXXX XXXX XXXX XXXX";default:return`Enter ${j.label.toLowerCase()}...`}};return c.jsx(Ht,{open:e,children:c.jsx(Jt,{showCloseButton:!1,className:"max-w-md",children:c.jsxs("form",{onSubmit:N,children:[c.jsxs(Zt,{children:[c.jsx(en,{children:t}),n&&c.jsx(tn,{children:n})]}),c.jsx("div",{className:"py-4 space-y-4",children:s.map(j=>c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm font-medium mb-1",children:[j.label,j.required&&c.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),c.jsxs("div",{className:"relative",children:[c.jsx(nn,{type:A(j),value:a[j.name]||"",onChange:R=>E(j.name,R.target.value,j),placeholder:I(j),className:u[j.name]?"border-red-500":"",disabled:p,autoFocus:j===s[0],maxLength:j.type==="pin"?6:j.type==="phone"?14:void 0}),j.type==="password"&&c.jsx("button",{type:"button",onClick:()=>V(j.name),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:p,children:h[j.name]?c.jsx(Z.EyeOff,{className:"h-4 w-4"}):c.jsx(Z.Eye,{className:"h-4 w-4"})})]}),u[j.name]&&c.jsxs("div",{className:"flex items-center gap-1 mt-1 text-sm text-red-500",children:[c.jsx(Z.AlertCircle,{className:"h-3 w-3"}),u[j.name]]})]},j.name))}),c.jsxs(Qt,{children:[c.jsx(Se,{type:"button",variant:"ghost",onClick:k,disabled:p,children:i}),c.jsx(Se,{type:"submit",disabled:p,children:p?"Submitting...":o})]})]})})})}const al=f.createContext(void 0);function ll(){const e=f.useContext(al);if(!e)throw new Error("useSecureModal must be used within a SecureModalProvider");return e}function cl({children:e}){const[t,n]=f.useState(null),[s,r]=f.useState(null),o=f.useRef(null),i=f.useRef(null),a=f.useCallback(p=>new Promise(w=>{n(p),o.current=w}),[]),l=f.useCallback(p=>new Promise(w=>{r(p),i.current=w}),[]),u=f.useCallback(p=>{o.current&&(o.current(p),o.current=null),n(null)},[]),d=f.useCallback(p=>{i.current&&(i.current(p),i.current=null),r(null)},[]),h=()=>{if(s){const w=s.fields.map(v=>({name:v.name,type:v.type==="text"?"text":v.type==="password"?"password":v.type==="email"?"email":v.type==="phone"?"phone":v.type==="pin"?"pin":v.type==="ssn"?"ssn":v.type==="creditCard"?"creditCard":"text",label:v.label,placeholder:v.placeholder,required:v.required!==!1,value:v.value}));return c.jsx(em,{isOpen:!0,title:s.title,description:s.description,fields:w,onComplete:d})}if(!t)return null;const p={isOpen:!0,title:t.title,description:t.description,placeholder:t.placeholder,onComplete:u};switch(t.type){case"password":return c.jsx(Hf,{...p});case"email":return c.jsx(Jf,{...p});case"phone":return c.jsx(Zf,{...p});case"pin":return c.jsx(Qf,{...p});case"ssn":return c.jsx(Is,{...p,title:t.title||"SSN Required",placeholder:t.placeholder||"XXX-XX-XXXX"});case"creditCard":return c.jsx(Is,{...p,title:t.title||"Credit Card Required",placeholder:t.placeholder||"XXXX XXXX XXXX XXXX",type:"text"});case"text":default:return c.jsx(Is,{...p})}},m=f.useMemo(()=>({showSecureModal:a,showSecureForm:l}),[a,l]);return c.jsxs(al.Provider,{value:m,children:[e,h()]})}function tm(e){try{const t=new URL(e),n=`${t.protocol}//${t.host}${t.pathname}`,s=t.hash?t.hash.substring(1):void 0;return{baseUrl:n,anchor:s}}catch{const t=e.indexOf("#");return t!==-1?{baseUrl:e.substring(0,t),anchor:e.substring(t+1)}:{baseUrl:e}}}function nm(e){try{const t=new URL(e),s=t.pathname.split("/").filter(a=>a.length>0);if(s.length===0)return t.hostname;const r=s[s.length-1];return r&&r.replace(/\.(md|mdx|html|htm)$/i,"").replace(/[-_]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" ")||t.hostname}catch{const t=e.indexOf("#"),n=t!==-1?e.substring(0,t):e,s=n.split("/").filter(r=>r.length>0);if(s.length>0){const r=s[s.length-1];return r&&r.replace(/\.(md|mdx|html|htm)$/i,"").replace(/[-_]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" ")||n}return n}}function po(e){let t=e.replace(/_+$/gm,"");const n=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,s=t.match(n),r=new Map,o=[],i=new Map,a=new Map,l=new Map,u=new Map;if(s&&s[1]){const A=s[1],I=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let j;for(;(j=I.exec(A))!==null;)if(j[1]&&j[2]){const R=parseInt(j[1],10),F=j[2].replace(/[.,;:!?]+$/,""),D=F.replace(/\/+$/,"");if(a.has(D)||a.set(D,F),i.has(D)||i.set(D,[]),i.get(D).push(R),!l.has(D))l.set(D,R);else{const L=l.get(D);R<L&&l.set(D,R)}}for(const[R,F]of i.entries()){const D=l.get(R);for(const L of F)L!==D&&u.set(L,D)}for(const[R,F]of l.entries()){const D=a.get(R)||R;r.set(F,D),o.push({number:F,url:D})}}let d,h=t;s&&s[0]&&(d=s[0],h=t.replace(n,""));const m=[];let p=0;const w=/```[\s\S]*?```|`[^`]+`/g;let v;for(;(v=w.exec(h))!==null;)v.index>p&&m.push({type:"text",content:h.slice(p,v.index),start:p,end:v.index}),m.push({type:"code",content:v[0],start:v.index,end:v.index+v[0].length}),p=v.index+v[0].length;p<h.length&&m.push({type:"text",content:h.slice(p),start:p,end:h.length});const T=m.map(A=>{if(A.type==="code")return A.content;let I=A.content;return I=I.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(R,F,D)=>{const L=parseInt(F,10),J=D.replace(/\/+$/,""),se=u.get(L)||L;return l.has(J)||(l.set(J,se),r.has(se)||(r.set(se,D),o.push({number:se,url:D}))),`[${se}]`}),I=I.replace(/\[(\d+)\]/g,(R,F)=>{const D=parseInt(F,10);return`[${u.get(D)||D}]`}),I}),x=[];for(const[A,I]of l.entries()){const j=a.get(A)||A,{baseUrl:R,anchor:F}=tm(j),D=nm(j);x.push({url:j,baseUrl:R,numbers:[I],anchor:F,title:D})}x.sort((A,I)=>(A.numbers[0]||0)-(I.numbers[0]||0));const P=new Map;let E=1;for(const A of x){const I=A.numbers[0];P.set(I,E),A.numbers=[E],E++}const O=new Map;for(const[A,I]of r.entries()){const j=P.get(A);j&&O.set(j,I)}const N=o.map(A=>{const I=P.get(A.number);return I?{number:I,url:A.url}:A}).filter(A=>P.has(A.number)),k=Array.from(P.entries()).sort((A,I)=>I[0]-A[0]);let V=T.join("");for(const[A,I]of k){const j=new RegExp(`\\[${A}\\](?!\\d)`,"g");V=V.replace(j,`[${I}]`)}return{processedText:V,citations:N.sort((A,I)=>A.number-I.number),citationMap:O,groupedCitations:x,referencesText:d}}function Cn(e){if(typeof e=="string")try{const t=JSON.parse(e);return Cn(t)}catch{return e}if(Array.isArray(e))return e.map(Cn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=Cn(s);return t}return e}function Os(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return Cn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?Cn(e):{}}function sm({theme:e="auto",layout:t="sidebar",model:n="auto",animated:s=!0,title:r="Chat",logo:o=void 0,defaultWidth:i=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:d=[],safeTools:h=[],toolMetadata:m,systemPrompt:p="",agentId:w,agentName:v,tokenEndpoint:T="/api/arcten/token",apiBaseUrl:x="https://api.arcten.com",user:P,state:E,onStateChange:O,allowStateEdits:N=!0,sources:k,ragConfig:V,showCitations:A=!0,sensitiveParams:I,autoDetectSensitive:j=!1}){const{showSecureModal:R}=ll(),F=wo({apiBaseUrl:x,tokenEndpoint:T,user:P,tools:d,safeTools:h,toolMetadata:m,sensitiveParams:I,autoDetectSensitive:j,agentId:w,agentName:v,state:E,onStateChange:O,allowStateEdits:N,sources:k,ragConfig:V});f.useMemo(()=>V!==void 0?V:k&&k.length>0?{enabled:!0,organizationId:k[0],autoExecute:!0,filters:void 0}:{enabled:!1},[k,V]);const[D,L]=f.useState(u),[J,se]=f.useState(i),[q,re]=f.useState(600),[me,xe]=f.useState(!1),[_,Et]=f.useState(!1),[Ae,ht]=f.useState(!1),[Te,Oe]=f.useState({x:100,y:100}),[sn,ne]=f.useState(!1),[rn,ft]=f.useState({x:0,y:0}),[on,In]=f.useState(!1),Le=f.useRef(null),mt=f.useRef(null),[pt,Ee]=f.useState(""),[an,hs]=f.useState(null),[kt,On]=f.useState("Thinking..."),[gt,nt]=f.useState(new Set),[fs,Ln]=f.useState(""),[We,ms]=f.useState([]),Fn=f.useRef(new Map),Nt=f.useRef(!1),ln=f.useRef(""),[ie,cn]=f.useState(!1),[Fe,be]=f.useState(!1),Ke=f.useMemo(()=>[...d,...h],[d,h]),$e=f.useMemo(()=>lr(Ke,m),[Ke,m]),Dt=f.useMemo(()=>{const C=new Map,z=new Map($e.map(X=>[X.name,X]));return Ke.forEach(X=>{const G=X[Re];if(G){const K=z.get(G);if(K){C.set(K.name,X);return}}const W=$e.find(K=>K.name===X.name);W&&C.set(W.name,X)}),C},[Ke,$e]),yt=f.useMemo(()=>{const C=new Set,z=new Map($e.map(X=>[X.name,X]));return h.forEach(X=>{const G=X[Re];if(G&&z.has(G))C.add(G);else{const W=$e.find(K=>K.name===X.name);W&&C.add(W.name)}}),C},[h,$e]),xt=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];f.useEffect(()=>{if(typeof window<"u"){const C=localStorage.getItem("arcten-sidebar-expanded");C&&L(JSON.parse(C));const z=localStorage.getItem("arcten-sidebar-width");z&&se(parseInt(z));const X=localStorage.getItem("arcten-sidebar-height");X&&re(parseInt(X));const G=localStorage.getItem("arcten-sidebar-detached");G&&Et(JSON.parse(G));const W=localStorage.getItem("arcten-sidebar-position");if(W){const pe=JSON.parse(W),te=50,ve=Math.max(te-i,Math.min(pe.x,window.innerWidth-te)),U=Math.max(0,Math.min(pe.y,window.innerHeight-te));Oe({x:ve,y:U})}const K=localStorage.getItem("arcten-sidebar-minimized");K&&ht(JSON.parse(K)),In(!0)}},[]),f.useMemo(()=>P,[P?.id]),f.useEffect(()=>{(async()=>{if(Ke.length===0)return;const z=Ke.map(X=>`${X.name}:${X.toString()}`).join("|");if(z!==ln.current&&!Nt.current){Nt.current=!0,ln.current=z;try{const X=Ke.map(W=>({name:W.name,code:W.toString()})),G=await fetch(`${x}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:X})});if(G.ok){const W=await G.json();W.tools&&W.tools.forEach(K=>{Fn.current.set(K.name,K)}),ms(W.tools)}}catch(X){console.error("Failed to fetch tool descriptions:",X)}finally{Nt.current=!1}}})()},[Ke,x]),f.useEffect(()=>{Promise.resolve().then(()=>$f).then(C=>{hs(()=>C.Response)})},[]),f.useEffect(()=>{const C=()=>{Ln(window.location.pathname)};C(),window.addEventListener("popstate",C);const z=setInterval(C,500);return()=>{window.removeEventListener("popstate",C),clearInterval(z)}},[]);const{id:un,messages:ke,sendMessage:bt,status:fe,error:$n,stop:Rt,addToolOutput:Je,setMessages:Kr,clientToken:dn,tokenError:hn,conversations:qe,isLoadingConversations:st,loadConversation:Vt,deleteConversation:Be,startNewConversation:Ge}=F;f.useEffect(()=>{D&&mt.current&&mt.current.focus()},[D,ke]),f.useEffect(()=>{const C=ke[ke.length-1];if(!C||C.role!=="assistant")return;const z=C.parts?.filter(X=>X.type?.startsWith("tool-")&&X.state==="input-available"&&typeof X.toolCallId=="string"&&X.input!==void 0)||[];for(const X of z){const G=X,W=G.type?.replace("tool-","")||"",K=G.toolCallId;if(yt.has(W)){if(gt.has(K))continue;nt(te=>te.has(K)?te:new Set(te).add(K)),(async()=>{try{const te=Dt.get(W);if(!te){console.warn(`[ArctenAgent] Tool ${W} not found in toolsMap`),Je({toolCallId:K,tool:W,output:`Error: Tool ${W} not found`}),nt(Q=>{const Ce=new Set(Q);return Ce.delete(K),Ce});return}const ve=Os(G.input),U=$e.find(Q=>Q.name===W);let ue;if(U&&U.jsonSchema?.properties){const Ce=Object.keys(U.jsonSchema.properties).map(g=>ve[g]);ue=await te(...Ce)}else ue=await te(...Object.values(ve));Je({toolCallId:K,tool:W,output:ue}),nt(Q=>{const Ce=new Set(Q);return Ce.delete(K),Ce})}catch(te){console.error(`[ArctenAgent] Error executing safe tool ${W}:`,te),Je({toolCallId:K,tool:W,output:`Error: ${te instanceof Error?te.message:String(te)}`}),nt(ve=>{const U=new Set(ve);return U.delete(K),U})}})()}}},[ke,yt,Dt,$e,Je,gt]);function Bn(){L(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function zn(){L(!1),localStorage.setItem("arcten-sidebar-expanded","false")}f.useEffect(()=>{},[D]),f.useEffect(()=>{Le.current&&Le.current.scrollIntoView({behavior:"smooth"})},[ke]),f.useEffect(()=>{function C(z){z.key==="Escape"&&(fe==="streaming"||fe==="submitted")&&(z.preventDefault(),Rt())}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[fe,Rt]);function Ze(C){const z=Math.floor((Date.now()-C)/1e3);return z<60?"now":z<3600?`${Math.floor(z/60)}m`:z<86400?`${Math.floor(z/3600)}h`:`${Math.floor(z/86400)}d`}function vt(){Ge(),be(!1)}function fn(C){if(C.preventDefault(),!pt.trim())return;(fe==="streaming"||fe==="submitted")&&Rt();const z=xt[Math.floor(Math.random()*xt.length)]||"Thinking...";On(z),bt({text:pt}),Ee("")}function Un(C){const z=C.target.value;Ee(z)}f.useEffect(()=>{if(!me)return;function C(X){if(_){const G=X.clientX-Te.x,W=X.clientY-Te.y;G>=a&&G<=l&&se(G),W>=400&&W<=1e3&&re(W)}else{const G=window.innerWidth-X.clientX;G>=a&&G<=l&&se(G)}}function z(){xe(!1),localStorage.setItem("arcten-sidebar-width",J.toString()),localStorage.setItem("arcten-sidebar-height",q.toString())}return window.addEventListener("mousemove",C),window.addEventListener("mouseup",z),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",z)}},[me,J,q,_,Te,a,l]);function It(C){C.preventDefault(),xe(!0)}function _n(){Et(!0),ht(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function ps(){Et(!1),ht(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function mn(){ht(!Ae),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!Ae))}function Ye(C){_&&(ne(!0),ft({x:C.clientX-Te.x,y:C.clientY-Te.y}))}return f.useEffect(()=>{if(!_)return;function C(){Oe(z=>{const G=window.innerWidth-50,W=window.innerHeight-50,K=50-J,pe=0,te=Math.max(K,Math.min(z.x,G)),ve=Math.max(pe,Math.min(z.y,W));if(te!==z.x||ve!==z.y){const U={x:te,y:ve};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(U)),U}return z})}return window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[_,J]),f.useEffect(()=>{if(!sn)return;function C(X){const G=X.clientX-rn.x,W=X.clientY-rn.y,K=50,pe=window.innerWidth-K,te=window.innerHeight-K,ve=K-J,U=0,ue=Math.max(ve,Math.min(G,pe)),Q=Math.max(U,Math.min(W,te));Oe({x:ue,y:Q})}function z(){ne(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(Te))}return window.addEventListener("mousemove",C),window.addEventListener("mouseup",z),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",z)}},[sn,rn,Te,J]),on?hn?c.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:c.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",hn]})}):dn?c.jsx(Qu,{features:kf,children:c.jsx(Gn,{id:"arcten-sidebar","data-theme":e,"data-layout":t,"data-model":n,initial:_?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:_?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
20
|
+
${_?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
|
|
21
21
|
${D?"bg-stone-50 dark:bg-stone-900":"bg-stone-100 dark:bg-stone-800 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors duration-200"}
|
|
22
|
-
${
|
|
22
|
+
${_?"border border-border":"border-l border-border"}
|
|
23
23
|
${D?"":"w-[30px]"}
|
|
24
|
-
`,style:D?B?{width:`${J}px`,height:Te?"auto":`${G}px`,left:`${we.x}px`,top:`${we.y}px`}:{width:`${J}px`}:void 0,onClick:D?void 0:pt,children:D?c.jsxs(c.Fragment,{children:[!B&&c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:$n,children:c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),B&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:C=>{C.preventDefault(),ge(!0)}}),c.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:C=>{C.preventDefault(),C.stopPropagation(),te(!0),lt({x:C.clientX-we.x,y:C.clientY-we.y})},children:c.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),c.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:C=>{C.preventDefault(),ge(!0)}})]}),c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${B?"cursor-move":""}`,onMouseDown:B?un:void 0,children:[c.jsx("h2",{className:`text-base font-semibold ${B&&Te?"cursor-pointer":""}`,onClick:B&&Te?C=>{C.stopPropagation(),Nt()}:void 0,children:r}),c.jsxs("div",{className:"flex items-center gap-1",onClick:C=>C.stopPropagation(),children:[c.jsxs(et,{children:[c.jsx(tt,{asChild:!0,children:c.jsx("button",{type:"button",className:Q(yt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:kt,"aria-label":"New chat",children:c.jsx(Z.Plus,{className:"h-4 w-4"})})}),c.jsx(nt,{children:"Start a new conversation"})]}),c.jsxs(et,{children:[c.jsx(tt,{asChild:!0,children:c.jsx("button",{type:"button",className:Q(yt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:B?hs:Xe,"aria-label":B?"Dock sidebar":"Float sidebar",children:B?c.jsx(Z.Dock,{className:"h-4 w-4"}):c.jsx(Z.PictureInPicture2,{className:"h-4 w-4"})})}),c.jsx(nt,{children:B?"Dock to sidebar":"Undock to floating window"})]}),c.jsxs(et,{children:[c.jsx(tt,{asChild:!0,children:c.jsx("button",{type:"button",className:Q(yt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:B?Nt:Ln,"aria-label":B?Te?"Maximize":"Minimize":"Close sidebar",children:B?Te?c.jsx(Z.Maximize2,{className:"h-4 w-4"}):c.jsx(Z.Minimize2,{className:"h-4 w-4"}):c.jsx(Z.X,{className:"h-4 w-4"})})}),c.jsx(nt,{children:B?Te?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!Te&&c.jsxs(c.Fragment,{children:[P&&_e.length>0&&c.jsxs("div",{className:`border-b border-border ${Ie?"flex flex-col flex-1":""}`,children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[c.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),c.jsx(ve,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{ye(!Ie)},children:Ie?"Show less":"View all"})]}),c.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Ie?"flex-1 overflow-y-auto":""}`,children:_e.slice(0,Ie?void 0:3).map(C=>c.jsxs("div",{className:"group relative",children:[c.jsxs(Mf,{type:"button",className:Q(yt({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal active:scale-[0.99]"),onClick:()=>{On(C.chatId||C._id),ye(!1)},children:[c.jsx("span",{className:"text-xs truncate",children:C.title}),c.jsx("div",{className:"ml-2 flex items-center",children:c.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:Fn(C.updatedAt)})})]}),c.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:_=>{_.stopPropagation(),Et(C._id)},"aria-label":"Delete conversation",children:c.jsx(Z.X,{className:"h-3 w-3"})})]},C._id))})]}),c.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[c.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:Pe.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&c.jsx("div",{className:"mb-6",children:o}),c.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),ze.length>0&&c.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:c.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(re?ze:ze.slice(0,10)).map(C=>c.jsxs(et,{children:[c.jsx(tt,{asChild:!0,children:c.jsx(gs,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{je(C.sampleUsage),ct.current?.focus()},children:C.friendlyName})}),c.jsx(nt,{children:c.jsxs("div",{className:"max-w-xs",children:[c.jsx("p",{className:"font-medium",children:C.description}),c.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[c.jsx("span",{className:"font-medium",children:"Example:"}),' "',C.sampleUsage,'"']}),C.paramCount>0&&c.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[c.jsx("span",{className:"font-medium",children:"Parameters:"})," ",C.params.join(", ")]})]})})]},C.name)),ze.length>10&&!re&&c.jsxs(et,{children:[c.jsx(tt,{asChild:!0,children:c.jsxs(gs,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>rn(!0),children:["+",ze.length-10," more"]})}),c.jsx(nt,{children:c.jsxs("div",{className:"max-w-xs",children:[c.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),c.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:ze.slice(10).map(C=>c.jsxs("div",{children:[c.jsxs("span",{className:"font-medium text-xs",children:[C.friendlyName,":"]}),c.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:C.description})]},C.name))}),c.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),re&&ze.length>10&&c.jsx(gs,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>rn(!1),children:"Show less"})]})})]}):c.jsxs(c.Fragment,{children:[Pe.map(C=>{const W=C.parts.filter(X=>X.type==="text").map(X=>X.text).join("");let K=C.parts;C.role==="assistant"&&C.parts.some(g=>g.timestamp)&&(K=[...C.parts].sort((g,y)=>{const b=g.timestamp||0,v=y.timestamp||0;return b-v}));let q=[],Y=new Map,Ae=[],ee,xe=!0;if(C.role==="assistant"){const X=K.filter(v=>v.type==="text"&&v.text),g=[],y=[];X.forEach(v=>{const{citations:M,citationMap:V,groupedCitations:z,referencesText:ie}=ho(v.text);q.push(...M),g.push(V),z&&y.push(...z),ie&&(ee=ie)}),g.forEach(v=>{v.forEach((M,V)=>{Y.has(V)||Y.set(V,M)})}),Ae=Array.from(new Map(y.map(v=>[v.url,v])).values()).sort((v,M)=>(v.numbers[0]||0)-(M.numbers[0]||0)),xe=!(he==="streaming"&&C.id===Pe.at(-1)?.id)}return c.jsx("div",{className:`${C.role==="user"?"flex justify-end":"w-full"}`,children:c.jsx("div",{className:`${C.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:C.role==="user"?c.jsx(Ef,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:W}):c.jsx("div",{className:"space-y-2",children:K.map((X,g)=>{if(X.type?.startsWith("tool-")){const y=X.type?.replace("tool-","")||"",b=Oe.find(V=>V.name===y),v=X.state==="input-available",M=X.state==="output-available";if(v&&ht.has(y),v){if(ht.has(y))return null;const V=Rs(X.input);return c.jsx(Xn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:c.jsx(kf,{toolName:y,description:b?.description||"",args:V,onApprove:async()=>{if(dt.has(X.toolCallId))return;Je(ie=>new Set(ie).add(X.toolCallId));const z=At.get(y);if(z)try{const ie=await z(...Object.values(V));Ke({toolCallId:X.toolCallId,tool:y,output:ie})}catch(ie){Ke({toolCallId:X.toolCallId,tool:y,output:`Error: ${ie}`})}},onDeny:async()=>{dt.has(X.toolCallId)||(Je(z=>new Set(z).add(X.toolCallId)),Ke({toolCallId:X.toolCallId,tool:y,output:"User denied tool execution"}))}})},`${X.toolCallId}-${g}`)}else if(M){const V=X.output==="User denied tool execution",z=Rs(X.input);return c.jsx(Nf,{toolName:y,args:z,isDenied:V,isSafe:ht.has(y)},`${X.toolCallId}-${g}`)}return null}if(X.type==="text"&&X.text&&nn){const{processedText:y}=ho(X.text),V=!K.slice(g+1).some(z=>z.type==="text"&&z.text)&&xe&&Y.size>0;return c.jsx(Xf,{text:y,citations:q,citationMap:Y,groupedCitations:V?Ae:void 0,referencesText:V?ee:void 0,ResponseComponent:nn,className:"text-sm prose prose-sm dark:prose-invert max-w-none",showCitations:A,showReferences:V},`${C.id}-${g}`)}return X.type==="reasoning"&&X.text?c.jsxs(tl,{className:"w-full",isStreaming:he==="streaming"&&g===C.parts.length-1&&C.id===Pe.at(-1)?.id,children:[c.jsx(nl,{}),c.jsx(sl,{children:X.text})]},`${C.id}-${g}`):null})})})},C.id)}),c.jsx("div",{ref:Ve})]})}),In&&c.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",In.message]}),c.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[c.jsx(Yu,{mode:"wait",children:(he==="streaming"||he==="submitted")&&c.jsxs(Xn,{initial:{opacity:0,filter:"blur(4px)",y:5},animate:{opacity:1,filter:"blur(0px)",y:0},exit:{opacity:0,filter:"blur(4px)",y:5},transition:{duration:.2,ease:"easeOut"},className:"absolute left-1/2 -translate-x-1/2 -top-6 flex items-center gap-1.5 bg-stone-100 dark:bg-stone-800 px-3 py-1.5 rounded-full shadow-lg border border-border z-50",children:[c.jsx(Xn,{className:"w-2 h-2 bg-stone-400 dark:bg-stone-600",animate:{rotate:[0,0,90,90],borderRadius:["50%","30%","30%","50%"],scale:[.75,1,1,.75]},transition:{duration:2,repeat:1/0,ease:"easeInOut",times:[0,.4,.6,1]}}),c.jsx("p",{className:"text-xs text-muted-foreground",children:jt})]})}),c.jsxs("form",{onSubmit:cn,className:"relative",children:[c.jsx(bo,{ref:ct,value:ut,onChange:ds,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),cn(C))}}),he==="streaming"||he==="submitted"?c.jsxs(et,{children:[c.jsx(tt,{asChild:!0,children:c.jsx("button",{type:"button",className:Q(yt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Mt,children:c.jsx(Z.Square,{className:"h-4 w-4"})})}),c.jsxs(nt,{children:[c.jsx(Gr,{children:"Escape"})," to stop"]})]}):c.jsxs(et,{children:[c.jsx(tt,{asChild:!0,children:c.jsx("button",{type:"submit",className:Q(yt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!ut.trim(),children:c.jsx(Z.ArrowRight,{className:"h-4 w-4"})})}),c.jsxs(nt,{children:[c.jsx(Gr,{children:"Enter"})," to send"]})]})]})]})]}),c.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[c.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),c.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),c.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):c.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[c.jsx(Z.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),c.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):c.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:c.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function tm(e){return c.jsx(ol,{children:c.jsx(em,{...e})})}exports.verifyToken=Tl.verifyToken;exports.ARCTEN_ORIGINAL_NAME=ke;exports.ArctenAgent=tm;exports.SecureModalProvider=ol;exports.extractToolsMetadata=ir;exports.preserveToolName=Cl;exports.useAgent=xo;exports.useSecureModal=il;
|
|
24
|
+
`,style:D?_?{width:`${J}px`,height:Ae?"auto":`${q}px`,left:`${Te.x}px`,top:`${Te.y}px`}:{width:`${J}px`}:void 0,onClick:D?void 0:Bn,children:D?c.jsxs(c.Fragment,{children:[!_&&c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:It,children:c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),_&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:C=>{C.preventDefault(),xe(!0)}}),c.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:C=>{C.preventDefault(),C.stopPropagation(),ne(!0),ft({x:C.clientX-Te.x,y:C.clientY-Te.y})},children:c.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),c.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:C=>{C.preventDefault(),xe(!0)}})]}),c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${_?"cursor-move":""}`,onMouseDown:_?Ye:void 0,children:[c.jsx("h2",{className:`text-base font-semibold ${_&&Ae?"cursor-pointer":""}`,onClick:_&&Ae?C=>{C.stopPropagation(),mn()}:void 0,children:r}),c.jsxs("div",{className:"flex items-center gap-1",onClick:C=>C.stopPropagation(),children:[c.jsxs(it,{children:[c.jsx(ot,{asChild:!0,children:c.jsx("button",{type:"button",className:ee(St({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:vt,"aria-label":"New chat",children:c.jsx(Z.Plus,{className:"h-4 w-4"})})}),c.jsx(at,{children:"Start a new conversation"})]}),c.jsxs(it,{children:[c.jsx(ot,{asChild:!0,children:c.jsx("button",{type:"button",className:ee(St({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:_?ps:_n,"aria-label":_?"Dock sidebar":"Float sidebar",children:_?c.jsx(Z.Dock,{className:"h-4 w-4"}):c.jsx(Z.PictureInPicture2,{className:"h-4 w-4"})})}),c.jsx(at,{children:_?"Dock to sidebar":"Undock to floating window"})]}),c.jsxs(it,{children:[c.jsx(ot,{asChild:!0,children:c.jsx("button",{type:"button",className:ee(St({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:_?mn:zn,"aria-label":_?Ae?"Maximize":"Minimize":"Close sidebar",children:_?Ae?c.jsx(Z.Maximize2,{className:"h-4 w-4"}):c.jsx(Z.Minimize2,{className:"h-4 w-4"}):c.jsx(Z.X,{className:"h-4 w-4"})})}),c.jsx(at,{children:_?Ae?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!Ae&&c.jsxs(c.Fragment,{children:[P&&qe.length>0&&c.jsxs("div",{className:`border-b border-border ${Fe?"flex flex-col flex-1":""}`,children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[c.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),c.jsx(Se,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{be(!Fe)},children:Fe?"Show less":"View all"})]}),c.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Fe?"flex-1 overflow-y-auto":""}`,children:qe.slice(0,Fe?void 0:3).map(C=>c.jsxs("div",{className:"group relative",children:[c.jsxs(Nf,{type:"button",className:ee(St({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal active:scale-[0.99]"),onClick:()=>{Vt(C.chatId||C._id),be(!1)},children:[c.jsx("span",{className:"text-xs truncate",children:C.title}),c.jsx("div",{className:"ml-2 flex items-center",children:c.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:Ze(C.updatedAt)})})]}),c.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:z=>{z.stopPropagation(),Be(C._id)},"aria-label":"Delete conversation",children:c.jsx(Z.X,{className:"h-3 w-3"})})]},C._id))})]}),c.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[c.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:ke.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&c.jsx("div",{className:"mb-6",children:o}),c.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),We.length>0&&c.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:c.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(ie?We:We.slice(0,10)).map(C=>c.jsxs(it,{children:[c.jsx(ot,{asChild:!0,children:c.jsx(bs,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Ee(C.sampleUsage),mt.current?.focus()},children:C.friendlyName})}),c.jsx(at,{children:c.jsxs("div",{className:"max-w-xs",children:[c.jsx("p",{className:"font-medium",children:C.description}),c.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[c.jsx("span",{className:"font-medium",children:"Example:"}),' "',C.sampleUsage,'"']}),C.paramCount>0&&c.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[c.jsx("span",{className:"font-medium",children:"Parameters:"})," ",C.params.join(", ")]})]})})]},C.name)),We.length>10&&!ie&&c.jsxs(it,{children:[c.jsx(ot,{asChild:!0,children:c.jsxs(bs,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>cn(!0),children:["+",We.length-10," more"]})}),c.jsx(at,{children:c.jsxs("div",{className:"max-w-xs",children:[c.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),c.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:We.slice(10).map(C=>c.jsxs("div",{children:[c.jsxs("span",{className:"font-medium text-xs",children:[C.friendlyName,":"]}),c.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:C.description})]},C.name))}),c.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),ie&&We.length>10&&c.jsx(bs,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>cn(!1),children:"Show less"})]})})]}):c.jsxs(c.Fragment,{children:[ke.map(C=>{const X=C.parts.filter(U=>U.type==="text").map(U=>U.text).join("");let G=C.parts;C.role==="assistant"&&C.parts.some(ue=>ue.timestamp)&&(G=[...C.parts].sort((ue,Q)=>{const Ce=ue.timestamp||0,g=Q.timestamp||0;return Ce-g}));let W=[],K=new Map,pe=[],te,ve=!0;if(C.role==="assistant"){const U=G.filter(g=>g.type==="text"&&g.text),ue=[],Q=[];U.forEach(g=>{const{citations:b,citationMap:y,groupedCitations:S,referencesText:M}=po(g.text);W.push(...b),ue.push(y),S&&Q.push(...S),M&&(te=M)}),ue.forEach(g=>{g.forEach((b,y)=>{K.has(y)||K.set(y,b)})}),pe=Array.from(new Map(Q.map(g=>[g.url,g])).values()).sort((g,b)=>(g.numbers[0]||0)-(b.numbers[0]||0)),ve=!(fe==="streaming"&&C.id===ke.at(-1)?.id)}return c.jsx("div",{className:`${C.role==="user"?"flex justify-end":"w-full"}`,children:c.jsx("div",{className:`${C.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:C.role==="user"?c.jsx(Df,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:X}):c.jsx("div",{className:"space-y-2",children:G.map((U,ue)=>{if(U.type?.startsWith("tool-")){const Q=U.type?.replace("tool-","")||"",Ce=$e.find(y=>y.name===Q),g=U.state==="input-available",b=U.state==="output-available";if(g&&yt.has(Q),g){if(yt.has(Q))return null;const y=Os(U.input);return c.jsx(Gn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:c.jsx(Rf,{toolName:Q,description:Ce?.description||"",args:y,onApprove:async()=>{if(gt.has(U.toolCallId))return;nt(M=>new Set(M).add(U.toolCallId));const S=Dt.get(Q);if(S)try{const M=await S(...Object.values(y));Je({toolCallId:U.toolCallId,tool:Q,output:M})}catch(M){Je({toolCallId:U.toolCallId,tool:Q,output:`Error: ${M}`})}},onDeny:async()=>{gt.has(U.toolCallId)||(nt(S=>new Set(S).add(U.toolCallId)),Je({toolCallId:U.toolCallId,tool:Q,output:"User denied tool execution"}))}})},`${U.toolCallId}-${ue}`)}else if(b){const y=U.output==="User denied tool execution",S=Os(U.input);return c.jsx(Vf,{toolName:Q,args:S,isDenied:y,isSafe:yt.has(Q)},`${U.toolCallId}-${ue}`)}return null}if(U.type==="text"&&U.text&&an){const{processedText:Q}=po(U.text),y=!G.slice(ue+1).some(S=>S.type==="text"&&S.text)&&ve&&K.size>0;return c.jsx(qf,{text:Q,citations:W,citationMap:K,groupedCitations:y?pe:void 0,referencesText:y?te:void 0,ResponseComponent:an,className:"text-sm prose prose-sm dark:prose-invert max-w-none",showCitations:A,showReferences:y},`${C.id}-${ue}`)}return U.type==="reasoning"&&U.text?c.jsxs(rl,{className:"w-full",isStreaming:fe==="streaming"&&ue===C.parts.length-1&&C.id===ke.at(-1)?.id,children:[c.jsx(il,{}),c.jsx(ol,{children:U.text})]},`${C.id}-${ue}`):null})})})},C.id)}),c.jsx("div",{ref:Le})]})}),$n&&c.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",$n.message]}),c.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[c.jsx(Zu,{mode:"wait",children:(fe==="streaming"||fe==="submitted")&&c.jsxs(Gn,{initial:{opacity:0,filter:"blur(4px)",y:5},animate:{opacity:1,filter:"blur(0px)",y:0},exit:{opacity:0,filter:"blur(4px)",y:5},transition:{duration:.2,ease:"easeOut"},className:"absolute left-1/2 -translate-x-1/2 -top-6 flex items-center gap-1.5 bg-stone-100 dark:bg-stone-800 px-3 py-1.5 rounded-full shadow-lg border border-border z-50",children:[c.jsx(Gn,{className:"w-2 h-2 bg-stone-400 dark:bg-stone-600",animate:{rotate:[0,0,90,90],borderRadius:["50%","30%","30%","50%"],scale:[.75,1,1,.75]},transition:{duration:2,repeat:1/0,ease:"easeInOut",times:[0,.4,.6,1]}}),c.jsx("p",{className:"text-xs text-muted-foreground",children:kt})]})}),c.jsxs("form",{onSubmit:fn,className:"relative",children:[c.jsx(So,{ref:mt,value:pt,onChange:Un,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),fn(C))}}),fe==="streaming"||fe==="submitted"?c.jsxs(it,{children:[c.jsx(ot,{asChild:!0,children:c.jsx("button",{type:"button",className:ee(St({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Rt,children:c.jsx(Z.Square,{className:"h-4 w-4"})})}),c.jsxs(at,{children:[c.jsx(Jr,{children:"Escape"})," to stop"]})]}):c.jsxs(it,{children:[c.jsx(ot,{asChild:!0,children:c.jsx("button",{type:"submit",className:ee(St({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!pt.trim(),children:c.jsx(Z.ArrowRight,{className:"h-4 w-4"})})}),c.jsxs(at,{children:[c.jsx(Jr,{children:"Enter"})," to send"]})]})]})]})]}),c.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[c.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),c.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),c.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):c.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[c.jsx(Z.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),c.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):c.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:c.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function rm(e){return c.jsx(cl,{children:c.jsx(sm,{...e})})}exports.verifyToken=Pl.verifyToken;exports.ARCTEN_ORIGINAL_NAME=Re;exports.ArctenAgent=rm;exports.SecureModalProvider=cl;exports.extractToolsMetadata=lr;exports.preserveToolName=Al;exports.useAgent=wo;exports.useSecureModal=ll;
|