@arcteninc/core 0.0.139 → 0.0.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ArctenAgent.d.ts +1 -0
- package/dist/components/ArctenAgent.d.ts.map +1 -1
- package/dist/core.css +1 -1
- package/dist/index.cjs +9 -18
- package/dist/index.mjs +3597 -3487
- package/dist/lib/useAgent.d.ts +1 -1
- package/dist/lib/useAgent.d.ts.map +1 -1
- package/dist/types/use-agent.d.ts +3 -0
- package/dist/types/use-agent.d.ts.map +1 -1
- package/dist/utils/extract-tool-metadata.d.ts +2 -3
- package/dist/utils/extract-tool-metadata.d.ts.map +1 -1
- package/package.json +14 -5
- package/scripts/arcten-cli.cjs +80 -43
- package/scripts/cli-create-project.ts +608 -0
- package/scripts/cli-create-wrapper.cjs +60 -0
- package/scripts/cli-extract-types-auto.ts +153 -1
- package/scripts/cli-init-wizard-wrapper.cjs +4 -3
- package/scripts/cli-init-wizard.ts +607 -802
- package/scripts/cli-sync-wrapper.cjs +69 -0
- package/scripts/cli-sync.ts +896 -0
- package/scripts/config-parser.ts +432 -0
- package/scripts/dashboard-sync.ts +454 -0
- package/scripts/tree-sitter-discover.ts +542 -0
- package/scripts/wasm/tree-sitter-tsx.wasm +0 -0
- package/scripts/wasm/tree-sitter-typescript.wasm +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
|
|
3
|
-
Please:
|
|
4
|
-
1. Run "arcten-extract-types ." before build (add to package.json scripts)
|
|
5
|
-
2. Import the generated metadata:
|
|
6
|
-
import { toolMetadata } from './.arcten/tool-metadata';
|
|
7
|
-
3. Pass it to useAgent/ArctenAgent:
|
|
8
|
-
useAgent({ tools: [...], toolMetadata: toolMetadata })
|
|
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=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(`
|
|
1
|
+
"use strict";var ml=Object.create;var Hr=Object.defineProperty;var pl=Object.getOwnPropertyDescriptor;var gl=Object.getOwnPropertyNames;var yl=Object.getPrototypeOf,xl=Object.prototype.hasOwnProperty;var bl=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of gl(t))!xl.call(e,r)&&r!==n&&Hr(e,r,{get:()=>t[r],enumerable:!(s=pl(t,r))||s.enumerable});return e};var vl=(e,t,n)=>(n=e!=null?ml(yl(e)):{},bl(t||!e||!e.__esModule?Hr(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),f=require("react"),te=require("lucide-react"),wl=require("@ai-sdk/react"),Jr=require("ai"),xo=require("@radix-ui/react-slot"),bo=require("class-variance-authority"),Sl=require("clsx"),Tl=require("tailwind-merge"),Cl=require("@radix-ui/react-tooltip"),Zr=require("@radix-ui/react-use-controllable-state"),jl=require("@radix-ui/react-collapsible"),Pl=require("react-dom"),Al=require("@radix-ui/react-dialog"),El=require("./server.cjs");function cs(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 We=cs(f),Wt=cs(Cl),cr=cs(jl),Nt=cs(Al),Ie=Symbol.for("@arcteninc/core:originalName");function Ml(e,t){return e[Ie]=t,e}function kl(e,t,n,s){if(typeof e!="function")return null;const r=e[Ie];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[Ie]=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[Ie]=i.name,{fn:e,meta:i}}else if(i=Object.values(t).find(l=>!n.has(l.name)),i)return e[Ie]=i.name,{fn:e,meta:i};return null}function ur(e,t){if(!t)return[];let n,s;if("functions"in t&&typeof t.functions=="object"){const o=t;n=o.functions,s=o.toolOrder}else n=t,s=void 0;const r=new Set;return e.map(o=>{const i=kl(o,n,r,s);if(!i){const a=o.name,u=o[Ie]||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.
|
|
2
|
+
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 Nl={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 vn(e){for(const[t,n]of Object.entries(Nl))if(t!=="text"){for(const s of n)if(s.test(e))return t}return null}function Dl(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 Rl(e,t,n){return t.length>0}function Vl(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=Il(s[i]),d={name:i,type:Ol(l||vn(i)||"text"),label:vo(i),placeholder:Ll(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:Rl(e,t),fields:r,title:$l(e),description:Fl(e,r.length)}}function Il(e){if(e!=null){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}}function Ol(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 vo(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Ll(e,t){return t?Dl(t,e).placeholder:`Enter ${vo(e).toLowerCase()}...`}function $l(e){return e.replace(/([A-Z])/g," $1").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Fl(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 Sn(e){if(typeof e=="string")try{const t=JSON.parse(e);return Sn(t)}catch{return e}if(Array.isArray(e))return e.map(Sn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=Sn(s);return t}return e}function Bl(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 zl(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return Sn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?Sn(e):{}}const Jn="__secureOutput",Zn="[hidden for privacy]";function Ul(e,t){if(!e||e.length===0)return t;const n=new Map;t.forEach(o=>{const i=o[Ie]||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[Ie]||o.name;i&&!s.has(i)&&(console.log(`[useAgent] Allowing client-only tool (forward compatible): ${i}`),r.push(o))}),r}function _l(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 Xl(e){return e.replace(/\[(\w+)\]/g,".$1").split(".").map(t=>t.trim()).filter(Boolean)}function Wl(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 ql(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 Fs(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 wo(e,t=""){const n={};return e&&typeof e=="object"?Object.entries(e).forEach(([s,r])=>{const o=t?`${t}.${s}`:s;n[o]=Fs(r),r&&typeof r=="object"&&Object.assign(n,wo(r,o))}):t&&(n[t]=Fs(e)),n}function Kl(e){if(e===void 0||e===!1)return;if(e===!0)return{strategy:"full",fields:[],placeholder:Zn,includeFieldStatus:!1,preserve:[]};if(Array.isArray(e))return{strategy:"fields",fields:e,placeholder:Zn,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??Zn,includeFieldStatus:e.includeFieldStatus??!1,preserve:e.preserve??[]}}function Gl(e){if(!e)return{};const t={};for(const[n,s]of Object.entries(e)){const r=Kl(s);r&&(t[n]=r)}return t}function So(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=wo(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[Jn]=r,l}if(n.fields.includes("*"))return So(e,t,{...n,strategy:"full",fields:[]});if(typeof t!="object"||t===null)return{value:s,[Jn]:{...r,redactedFields:n.fields}};const o=_l(t),i=[],a={};return n.fields.forEach(l=>{const u=Xl(l);if(u.length===0)return;const d=Wl(o,u),h=Fs(d);a[l]=h,ql(o,u,s)&&i.push(l)}),r.redactedFields=i,n.includeFieldStatus&&(r.fieldStatus=a),o[Jn]=r,o}function To({apiBaseUrl:e="https://api.arcten.com",tokenEndpoint:t="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:r,tools:o=[],safeTools:i=[],safeToolNames:a,toolMetadata:l,sensitiveParams:u,sensitiveOutputs:d,autoDetectSensitive:h=!1,autoFormGeneration:m=!1,formMode:p="auto",systemPrompt:S="",agentId:w,agentName:T,projectId:v,enableRemoteConfig:E,remoteConfigUrl:M,initialMessages:F=[],conversationId:D,state:O,onStateChange:N,allowStateEdits:j=!0,onToolCall:L,onFinish:A,sources:k,ragConfig:B,ragFilters:V,secureInputHandler:I}={}){const[K,Z]=f.useState(null),[J,se]=f.useState(!1),[Ce,De]=f.useState(null),$e=f.useMemo(()=>{const y=k||[],g=K?.config?.sources||[];return[...new Set([...y,...g])]},[k,K]),q=f.useMemo(()=>B!==void 0?B:V?{enabled:!0,filters:V}:$e&&$e.length>0?{enabled:!0,organizationId:$e[0],autoExecute:!0,filters:void 0}:{enabled:!1},[$e,B,V]),Dt=f.useMemo(()=>E===!1?!1:!!v,[v,E]);f.useEffect(()=>{if(!Dt||!oe.current)return;(async()=>{se(!0),De(null);try{const x=`${M||e.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"agents:getConfigForClient",args:{projectId:v,agentName:T,agentId:w},format:"json"})});if(!b.ok){if(b.status===404){console.warn("[useAgent] Remote config endpoint not found (404), using local tools only"),Z(null);return}const R=await b.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch remote config: ${b.status} ${R}`)}const P=await b.json();Z(P?.value||null),console.log("[useAgent] Remote config loaded successfully:",P?.value)}catch(g){console.error("[useAgent] Failed to fetch remote config:",g);const x=g instanceof Error?g:new Error(String(g));De(x),Z(null)}finally{se(!1)}})()},[Dt,v,T,w,e,M]);const Ee=f.useMemo(()=>{const y={};if(u)for(const[g,x]of Object.entries(u))if(y[g]={},Array.isArray(x))for(const b of x){const P=vn(b);y[g][b]=P||"text"}else for(const[b,P]of Object.entries(x))y[g][b]=P;if(l){for(const[g,x]of Object.entries(l))if(x&&typeof x=="object"&&"sensitiveParams"in x){y[g]||(y[g]={});const b=x.sensitiveParams;if(Array.isArray(b))for(const P of b){const R=vn(P);y[g][P]=R||"text"}else if(b&&typeof b=="object")for(const[P,R]of Object.entries(b))y[g][P]=R}}return y},[u,l,h]),pt=f.useMemo(()=>Gl(d),[d]),je=f.useCallback((y,g)=>{const x=pt[y];if(!x)return g;try{return So(y,g,x)}catch(b){return console.error(`[useAgent] Failed to redact output for ${y}:`,b),{value:Zn,[Jn]:{tool:y,redacted:!0,error:String(b)}}}},[pt]),[Fe,an]=f.useState(n||null),oe=f.useRef(n||null),[ln,gt]=f.useState(null),[cn,$n]=f.useState(null),Be=f.useRef(null),[yt,xt]=f.useState([]),[ke,un]=f.useState(D||(typeof window<"u"?crypto.randomUUID():null)),[ms,Rt]=f.useState(!1),[Fn,bt]=f.useState(new Set),[it,ps]=f.useState(new Map),[Bn,Ke]=f.useState(new Map),[gs,zn]=f.useState(new Map),[Vt,dn]=f.useState(new Map),le=O!==void 0,[hn,ze]=f.useState({}),ve=f.useRef({}),Ge=le?O||{}:hn;le&&O?ve.current=O:le||(ve.current=hn);const[Ue,It]=f.useState(!1),[vt,wt]=f.useState(null),fn=f.useRef(!1),Ne=f.useCallback(async(y,g=3)=>{if(!ke||!oe.current)return;const x=async()=>{const P=`${e.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,R=await fetch(P,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:ke,updates:y},format:"json"})});if(!R.ok){if(R.status===404){console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const $=await R.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${R.status} ${$}`)}};for(let b=0;b<g;b++)try{await x(),wt(null);return}catch(P){if(b===g-1){const $=P instanceof Error?P:new Error(String(P));throw wt($),console.error("Failed to sync state to Convex after retries:",P),$}await new Promise($=>setTimeout($,Math.pow(2,b)*100))}},[ke,e,oe]),St=f.useMemo(()=>function(){return ve.current},[]),ye=f.useMemo(()=>async function(g){const x={...ve.current,...g};ve.current=x,le||ze(x),N&&N(x);try{await Ne(g)}catch(b){throw b}},[Ne,N,le]);f.useEffect(()=>{le&&O&&(ve.current=O)},[le,O]);const Un=f.useCallback(y=>I?I.showSecureModal(y):new Promise(g=>{ps(x=>new Map(x).set(y.id,y)),Ke(x=>new Map(x).set(y.id,g))}),[I]),Ot=f.useCallback((y,g)=>{if(I)return;const x=Bn.get(y);x&&(x(g),ps(b=>{const P=new Map(b);return P.delete(y),P}),Ke(b=>{const P=new Map(b);return P.delete(y),P}))},[Bn,I]),et=f.useCallback(y=>I?I.showSecureForm(y):new Promise(g=>{zn(x=>new Map(x).set(y.id,y)),dn(x=>new Map(x).set(y.id,g))}),[I]),Gr=f.useCallback((y,g)=>{if(I)return;const x=Vt.get(y);x&&(x(g),zn(b=>{const P=new Map(b);return P.delete(y),P}),dn(b=>{const P=new Map(b);return P.delete(y),P}))},[Vt,I]),mn=f.useCallback((y,g)=>{const x=Ee[y]||{},b=Object.keys(x).length>0;if(h){const P=Object.keys(g).filter(R=>vn(R)!==null);return b||P.length>0}return b},[Ee,h]),pn=f.useCallback((y,g)=>{const b={...Ee[y]||{}};if(h){for(const R of Object.keys(g))if(!(R in b)){const $=vn(R);$&&(b[R]=$)}}const P=Object.entries(b).filter(([R])=>Object.prototype.hasOwnProperty.call(g,R));return P.length>0?Object.fromEntries(P):b},[Ee,h]),Ye=f.useMemo(()=>q?.enabled?async function(g,x=20,b){const P={...q.filters,...b};if(k&&k.length>1){const $=k.map(W=>fetch(`${e}/search`,{method:"POST",headers:{"Content-Type":"application/json",...oe.current?{Authorization:`Bearer ${oe.current}`}:{}},body:JSON.stringify({q:g,k:Math.min(x,100),organizationId:W,...Object.keys(P).length>0?{filters:P}:{}})}).then(ie=>ie.ok?ie.json():null)),ae=await Promise.all($),ee=[];for(const W of ae)W?.candidates&&ee.push(...W.candidates);ee.sort((W,ie)=>{const Ze=W.scores?.rerank||W.scores?.dense||0;return(ie.scores?.rerank||ie.scores?.dense||0)-Ze});const xe=ee.slice(0,x).map((W,ie)=>{const Ze=W.citation||W.url;return{rank:ie+1,doc_id:W.doc_id,block_id:W.block_id,url:W.url,citation:Ze,title:W.title||"Untitled",snippet:W.snippet,score:W.scores?.rerank||W.scores?.dense||0,metadata:{site:W.metadata?.site,lang:W.metadata?.lang,contentType:W.metadata?.content_type}}});return{success:!0,query:g,total:ee.length,results:xe,summary:`Found ${ee.length} relevant results across ${k.length} source(s) for "${g}". Top result: ${xe[0]?.title||"N/A"}`}}const R=q.organizationId&&q.organizationId!=="default"?q.organizationId:k&&k.length>0?k[0]:void 0;try{const $={q:g,k:Math.min(x,100)};R&&($.organizationId=R),Object.keys(P).length>0&&($.filters=P);const ae={"Content-Type":"application/json"};oe.current&&(ae.Authorization=`Bearer ${oe.current}`);const ee=await fetch(`${e}/search`,{method:"POST",headers:ae,body:JSON.stringify($)});if(!ee.ok){const ie=await ee.text();return{success:!1,error:`Search failed: ${ee.status} ${ie}`}}const xe=await ee.json(),W=xe.candidates.map((ie,Ze)=>{const xn=ie.citation||ie.url;return{rank:Ze+1,doc_id:ie.doc_id,block_id:ie.block_id,url:ie.url,citation:xn,title:ie.title||"Untitled",snippet:ie.snippet,score:ie.scores?.rerank||ie.scores?.dense||0,metadata:{site:ie.metadata?.site,lang:ie.metadata?.lang,contentType:ie.metadata?.content_type}}});return{success:!0,query:xe.query,total:xe.total,results:W,summary:`Found ${xe.total} relevant results for "${g}". Top result: ${W[0]?.title||"N/A"}`}}catch($){return{success:!1,error:$ instanceof Error?$.message:"Unknown error occurred"}}}:null,[q,e,oe]),ot=f.useMemo(()=>q?.enabled?async function(g,x){const b=q.organizationId&&q.organizationId!=="default"?q.organizationId:k&&k.length>0?k[0]:void 0;try{const P={"Content-Type":"application/json"};oe.current&&(P.Authorization=`Bearer ${oe.current}`);const R=await fetch(`${e}/fetch`,{method:"POST",headers:P,body:JSON.stringify({doc_id:g,block_ids:x,...b?{organizationId:b}:{}})});if(!R.ok){const ae=await R.text();return{success:!1,error:`Fetch failed: ${R.status} ${ae}`}}const $=await R.json();return{success:!0,blocks:$.blocks||[],fullContent:$.fullContent||"",pageUrl:$.pageUrl||"",pageTitle:$.pageTitle||"",summary:`Fetched ${$.blocks?.length||0} blocks from ${$.pageTitle||g}`}}catch(P){return{success:!1,error:P instanceof Error?P.message:"Unknown error occurred"}}}:null,[q,e,oe]),Lt=f.useMemo(()=>{if(K&&K.config?.tools){const y=Ul(K.config.tools,o);return console.log("[useAgent] Merged remote config:",{remoteToolCount:K.config.tools.length,localToolCount:o.length,mergedToolCount:y.length}),y}return o},[K,o]),_e=K?.enableStateTools??!0,He=K?.enableRagTools??q?.enabled??!1,_n=f.useMemo(()=>{const y=[...Lt,...i];return _e&&(y.push(St),(!le||j)&&y.push(ye)),He&&(Ye&&y.push(Ye),ot&&y.push(ot)),y},[Lt,i,St,ye,Ye,ot,_e,He,le,j]),Xn=f.useMemo(()=>[...Lt,...i],[Lt,i]),tt=f.useMemo(()=>ur(Xn,l),[Xn,l]),Tt=f.useMemo(()=>{const y=new Map,g=new Map(tt.map(x=>[x.name,x]));return y.set("getState",St),(!le||j)&&y.set("setState",ye),q?.enabled&&(Ye&&y.set("searchDocs",Ye),ot&&y.set("fetchDocContent",ot)),_n.forEach(x=>{if(x===St||x===ye||x===Ye||x===ot)return;const b=x[Ie];if(b){const R=g.get(b);if(R){y.set(R.name,x);return}}const P=tt.find(R=>R.name===x.name);P&&y.set(P.name,x)}),y},[_n,tt,St,ye,Ye,ot,q,le,j]),gn=f.useMemo(()=>new Set(tt.map(y=>y.name)),[tt]),Wn=f.useMemo(()=>{const y=[];_e&&(y.push({name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}),(!le||j)&&y.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 g=[];He&&g.push({name:"searchDocs",description:"Search documentation using semantic search. Returns relevant results with snippets and scores. Use this first to find relevant documentation. Default returns 20 results - use higher k values (30-50) when you need to find many sources.",jsonSchema:{type:"object",properties:{query:{type:"string",description:"The search query (user's question or keywords)"},k:{type:"number",description:"Number of results to return (default: 20, max: 100). Use 20-30 for comprehensive searches, or higher (50-100) when you need to find all relevant sources.",default:20},filters:{type:"object",description:"Optional filters to scope the search",properties:{site:{type:"string"},lang:{type:"string"},tags:{type:"array",items:{type:"string"}},docIds:{type:"array",items:{type:"string"}},pageIds:{type:"array",items:{type:"string"}}}}},required:["query"]}},{name:"fetchDocContent",description:"Fetch full content of documentation blocks after searching. Use this AFTER searchDocs when you find relevant results (scores > 0.3) to get complete text. Automatically fetches nearby blocks (5 chunks before/after each requested block) for context. You can pass multiple block_ids to fetch comprehensive content from multiple blocks/pages.",jsonSchema:{type:"object",properties:{doc_id:{type:"string",description:"The doc_id from searchDocs results"},block_ids:{type:"array",items:{type:"string"},description:"Array of block_ids from searchDocs results. You can pass multiple block_ids to fetch comprehensive content."}},required:["doc_id","block_ids"]}});const x=[];return K?.config?.workflows&&K.config.workflows.forEach(b=>{const P={},R=[];b.parameters&&b.parameters.forEach($=>{P[$.name]={type:$.type||"string",description:$.description},$.required&&R.push($.name)}),x.push({name:`workflow_${b.name.replace(/\s+/g,"_").toLowerCase()}`,description:b.description||`Execute the "${b.name}" workflow. ${b.contentPlaintext?.slice(0,200)||""}`,jsonSchema:{type:"object",properties:P,required:R},_workflow:b})}),[...tt,...y,...g,...x]},[tt,_e,He,le,j,K]),at=f.useMemo(()=>Wn.filter(y=>y.name==="getState"?_e:y.name==="setState"?_e&&(!le||j):y.name==="searchDocs"||y.name==="fetchDocContent"?He:y.name.startsWith("workflow_")?!0:gn.has(y.name)),[Wn,gn,_e,He,le,j]),$t=f.useMemo(()=>{const y=new Set;return _e&&(y.add("getState"),y.add("setState")),He&&q?.autoExecute!==!1&&(y.add("searchDocs"),y.add("fetchDocContent")),K?.config?.tools?K.config.tools.forEach(g=>{g.isEnabled&&!g.requiresApproval&&y.add(g.name)}):(i.forEach(g=>{for(const[x,b]of Tt.entries())if(b===g){y.add(x);break}}),a&&Array.isArray(a)&&a.forEach(g=>{typeof g=="string"&&y.add(g)})),K?.config?.workflows&&K.config.workflows.forEach(g=>{const x=`workflow_${g.name.replace(/\s+/g,"_").toLowerCase()}`;g.requiresApproval||y.add(x)}),y},[K,i,a,Tt,_e,He,q]);f.useEffect(()=>s||n?void 0:((async()=>{try{const g=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!g.ok)throw new Error("Failed to fetch token");const x=await g.json();an(x.clientToken),oe.current=x.clientToken,$n(x.expiresAt),gt(null)}catch(g){console.error("[useAgent] Token fetch failed:",g),gt(g instanceof Error?g.message:"Failed to fetch token")}})(),()=>{Be.current&&clearTimeout(Be.current)}),[t,JSON.stringify(r),s,n]),f.useEffect(()=>{if(!cn||s||n)return;Be.current&&clearTimeout(Be.current);const y=Math.floor(Date.now()/1e3),g=cn-y,b=Math.max(0,g-5);return Be.current=setTimeout(async()=>{try{const P=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!P.ok)throw new Error("Failed to refresh token");const R=await P.json();an(R.clientToken),oe.current=R.clientToken,$n(R.expiresAt),gt(null)}catch(P){console.error("[useAgent] Token refresh failed:",P),gt(P instanceof Error?P.message:"Failed to refresh token")}},b*1e3),()=>{Be.current&&clearTimeout(Be.current)}},[cn,t,JSON.stringify(r),s,n]);const ys=async(y,g={})=>{const x=g.headers?new Headers(g.headers):new Headers;x.delete("user-agent"),x.delete("User-Agent"),console.log("[useAgent] Making request to:",y),console.log("[useAgent] Method:",g.method||"GET"),console.log("[useAgent] Has Authorization header:",x.has("Authorization")),console.log("[useAgent] Client token available:",!!oe.current);try{const b=await fetch(y,{...g,headers:x});if(!b.ok){console.error("[useAgent] Request failed:",b.status,b.statusText);const P=await b.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",P)}return b}catch(b){throw console.error("[useAgent] Fetch error:",b),b}},yn=`${e}/chat`;console.log("[useAgent] Chat API URL:",yn);const{messages:Je,sendMessage:C,status:_,error:U,stop:H,addToolResult:G,setMessages:Y}=wl.useChat({id:ke||void 0,messages:F,transport:new Jr.DefaultChatTransport({api:yn,fetch:ys,headers:()=>{const y={};return oe.current?(y.Authorization=`Bearer ${oe.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),y},body:()=>{console.log("[ArctenAgent] body() agentName =",T);const y=at.map(b=>({name:b.name,description:b.description,inputSchema:b.jsonSchema})),g=y.filter(b=>b.name==="getState"||b.name==="setState").map(b=>b.name),x=y.filter(b=>b.name==="searchDocs"||b.name==="fetchDocContent").map(b=>b.name);return g.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",g),x.length>0?console.log("[useAgent] RAG tools included in tools list sent to AI SDK:",x):q?.enabled&&console.warn("[useAgent] RAG is enabled but no RAG tools found in tools list!"),{tools:y,...w&&{agentId:w},...T&&{agentName:T},state:ve.current,...V&&{ragFilters:V}}}}),sendAutomaticallyWhen:Jr.lastAssistantMessageIsCompleteWithToolCalls}),ge=f.useCallback((y,g,x)=>{const b=je(y,x);G({toolCallId:g,tool:y,output:b})},[G,je]);f.useEffect(()=>{Je.forEach(y=>{y.role==="assistant"&&y.parts.forEach(g=>{if(!g.type?.startsWith("tool-")||g.state!=="input-available")return;const x=g.type.replace("tool-",""),b=g.toolCallId;if(Fn.has(b))return;bt(R=>new Set(R).add(b));const P=zl(g.input);if(mn(x,P)){const R=pn(x,P),$=Object.entries(R).filter(([W])=>P[W]!==void 0),ae=$.length>0?Object.fromEntries($):R,ee=Object.keys(P),xe=Bl(P,ae);(async()=>{try{const W=Vl(x,ee,ae,P),ie={id:`${b}-form`,toolName:x,toolCallId:b,title:W.title,description:W.description,fields:W.fields},Ze=await et(ie);if(Ze===null){ge(x,b,"User cancelled secure input");return}const xn={...xe,...Ze},xs=Tt.get(x);if(!xs)throw new Error(`Tool ${x} not found`);let bs;const vs=at.find(Yr=>Yr.name===x);if(vs&&vs.jsonSchema?.properties){const hl=Object.keys(vs.jsonSchema.properties).map(fl=>xn[fl]);bs=await xs(...hl)}else bs=await xs(...Object.values(xn));ge(x,b,bs)}catch(W){console.error(`[useAgent] Error executing tool with secure input ${x}:`,W),ge(x,b,`Error: ${W}`)}})();return}if(x.startsWith("workflow_")&&$t.has(x)){(async()=>{try{const $=at.find(ee=>ee.name===x)?._workflow;if(!$)throw new Error(`Workflow metadata not found for ${x}`);let ae;if($.webhook?.url){let ee=P;if($.webhook.bodyTemplate){let W=$.webhook.bodyTemplate;Object.entries(P).forEach(([ie,Ze])=>{W=W.replace(new RegExp(`\\{\\{${ie}\\}\\}`,"g"),String(Ze))}),ee=JSON.parse(W)}const xe=await fetch($.webhook.url,{method:$.webhook.method||"POST",headers:{"Content-Type":"application/json",...$.webhook.headers||{}},body:JSON.stringify(ee)});if(xe.ok)ae={success:!0,data:await xe.json().catch(()=>({success:!0}))};else{const W=await xe.text();ae={success:!1,error:`Webhook failed: ${xe.status} ${W}`}}}else ae={success:!0,message:`Workflow "${$.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:$.contentPlaintext};ge(x,b,ae)}catch(R){console.error(`[useAgent] Error executing workflow ${x}:`,R),ge(x,b,`Error: ${R}`)}})();return}if($t.has(x)&&!mn(x,P)){const R=Tt.get(x);R?(async()=>{try{const $=at.find(ee=>ee.name===x);let ae;if($&&$.jsonSchema?.properties){const xe=Object.keys($.jsonSchema.properties).map(W=>P[W]);ae=await R(...xe)}else if(x==="getState")ae=R();else if(x==="setState"){const ee=P.updates||P;ae=await R(ee)}else ae=await R(...Object.values(P));ge(x,b,ae)}catch($){console.error(`[useAgent] Error executing tool ${x}:`,$),ge(x,b,`Error: ${$}`)}})():console.warn(`[useAgent] Tool ${x} not found in toolsMap`)}else x.startsWith("workflow_")&&L?L({toolCall:{toolCallId:b,toolName:x,args:P}}):L&&L({toolCall:{toolCallId:b,toolName:x,args:P}})})})},[Je,$t,Tt,L,ge,Fn,ye,at,mn,pn,Un]),f.useEffect(()=>{if(_==="ready"&&Je.length>0&&A){const y=Je[Je.length-1];y&&y.role==="assistant"&&A({message:y,messages:Je,isAbort:!1,isDisconnect:!1,isError:!!U})}},[_,Je,U,A]);async function re(){if(!(!r?.id||!Fe)){Rt(!0);try{const g=await(await fetch(`${e}/conversations`,{headers:{Authorization:`Bearer ${Fe}`}})).json();xt(g.conversations||[])}catch(y){console.error("Failed to fetch conversations:",y)}finally{Rt(!1)}}}f.useEffect(()=>{r?.id&&Fe&&re()},[JSON.stringify(r),Fe,e]),f.useEffect(()=>{if(!ke||!oe.current)return;(async()=>{It(!0),wt(null);try{const g=await fetch(`${e.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:ke},format:"json"})});if(!g.ok){const P=await g.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${g.status} ${P}`)}const b=(await g.json())?.value||{};ve.current=b,le||ze(b),N&&N(b),fn.current=!0}catch(g){console.error("Failed to fetch state:",g);const x=g instanceof Error?g:new Error(String(g));wt(x),fn.current||(ve.current={},le?N&&N({}):(ze({}),N&&N({})),fn.current=!0)}finally{It(!1)}})()},[ke,e,le,N]);async function we(y){un(y),Rt(!0);try{const g=await fetch(`${e}/conversations/${y}/messages`,{headers:{Authorization:`Bearer ${oe.current}`}});if(!g.ok)throw new Error(`Failed to fetch messages: ${g.statusText}`);const b=(await g.json()).messages||[];Y(b)}catch(g){console.error("Failed to load conversation messages:",g)}finally{Rt(!1)}}async function X(y){if(Fe)try{await fetch(`${e}/conversations/${y}`,{method:"DELETE",headers:{Authorization:`Bearer ${Fe}`}}),xt(yt.filter(g=>g._id!==y)),y===ke&&he()}catch(g){console.error("Failed to delete conversation:",g)}}function he(){const y=crypto.randomUUID();un(y),Y([]),bt(new Set),ve.current={},le?N&&N({}):(ze({}),N&&N({})),fn.current=!1}function Q(y){const g=y.tool||"unknown-tool",x=je(g,y.output);G({toolCallId:y.toolCallId,tool:g,output:x})}async function Pe(y,g,x){if(!g.startsWith("workflow_"))throw new Error(`${g} is not a workflow tool`);try{const P=at.find($=>$.name===g)?._workflow;if(!P)throw new Error(`Workflow metadata not found for ${g}`);let R;if(P.webhook?.url){let $=x;if(P.webhook.bodyTemplate){let ee=P.webhook.bodyTemplate;Object.entries(x).forEach(([xe,W])=>{ee=ee.replace(new RegExp(`\\{\\{${xe}\\}\\}`,"g"),String(W))}),$=JSON.parse(ee)}const ae=await fetch(P.webhook.url,{method:P.webhook.method||"POST",headers:{"Content-Type":"application/json",...P.webhook.headers||{}},body:JSON.stringify($)});if(ae.ok)R={success:!0,data:await ae.json().catch(()=>({success:!0}))};else{const ee=await ae.text();R={success:!1,error:`Webhook failed: ${ae.status} ${ee}`}}}else R={success:!0,message:`Workflow "${P.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:P.contentPlaintext};return Q({toolCallId:y,tool:g,output:R}),R}catch(b){const P={success:!1,error:String(b)};throw Q({toolCallId:y,tool:g,output:P}),b}}async function fe(y){const g={...ve.current,...y};ve.current=g,le||ze(g),N&&N(g);try{await Ne(y)}catch(x){throw x}}return{id:ke,messages:Je,status:_,error:U,sendMessage:C,stop:H,addToolOutput:Q,executeWorkflowTool:Pe,setMessages:Y,conversations:yt,loadConversation:we,deleteConversation:X,startNewConversation:he,isLoadingConversations:ms,clientToken:Fe,tokenError:ln,state:Ge,setState:fe,isStateLoading:Ue,stateError:vt,pendingSecureInputs:Array.from(it.values()),completeSecureInput:Ot,pendingSecureForms:Array.from(gs.values()),completeSecureForm:Gr,safeToolNames:$t}}function ne(...e){return Tl.twMerge(Sl.clsx(e))}const jt=bo.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"}}),Te=We.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...r},o)=>{const i=s?xo.Slot:"button";return c.jsx(i,{ref:o,"data-slot":"button",className:ne(jt({variant:t,size:n,className:e})),...r})});Te.displayName="Button";const Yl=bo.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 ws({className:e,variant:t,asChild:n=!1,...s}){const r=n?xo.Slot:"span";return c.jsx(r,{"data-slot":"badge",className:ne(Yl({variant:t}),e),...s})}const Hl=({textAreaRef:e,triggerAutoSize:t,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[r,o]=We.useState(!0);We.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])},Co=We.forwardRef(({maxHeight:e=Number.MAX_SAFE_INTEGER,minHeight:t=52,className:n,onChange:s,value:r,...o},i)=>{const a=We.useRef(null),[l,u]=We.useState("");return Hl({textAreaRef:a,triggerAutoSize:l,maxHeight:e,minHeight:t}),f.useImperativeHandle(i,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:e,minHeight:t})),We.useEffect(()=>{u(r)},[o?.defaultValue,r]),c.jsx("textarea",{...o,value:r,ref:a,className:ne("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)}})});Co.displayName="AutosizeTextarea";function Jl({delayDuration:e=0,...t}){return c.jsx(Wt.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function lt({...e}){return c.jsx(Jl,{children:c.jsx(Wt.Root,{"data-slot":"tooltip",...e})})}function ct({...e}){return c.jsx(Wt.Trigger,{"data-slot":"tooltip-trigger",...e})}function ut({className:e,sideOffset:t=0,children:n,...s}){return c.jsx(Wt.Portal,{children:c.jsxs(Wt.Content,{"data-slot":"tooltip-content",sideOffset:t,className:ne("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(Wt.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Qr({className:e,...t}){return c.jsx("kbd",{"data-slot":"kbd",className:ne("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 dr=f.createContext({});function hr(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const fr=typeof window<"u",jo=fr?f.useLayoutEffect:f.useEffect,us=f.createContext(null);function mr(e,t){e.indexOf(t)===-1&&e.push(t)}function pr(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const nt=(e,t,n)=>n>t?t:n<e?e:n;function Bs(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let Yt=()=>{},st=()=>{};process.env.NODE_ENV!=="production"&&(Yt=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Bs(t,n))},st=(e,t,n)=>{if(!e)throw new Error(Bs(t,n))});const rt={},Po=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Ao(e){return typeof e=="object"&&e!==null}const Eo=e=>/^0[^.\s]+$/u.test(e);function gr(e){let t;return()=>(t===void 0&&(t=e()),t)}const Le=e=>e,Zl=(e,t)=>n=>t(e(n)),Vn=(...e)=>e.reduce(Zl),En=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class yr{constructor(){this.subscriptions=[]}add(t){return mr(this.subscriptions,t),()=>pr(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 qe=e=>e*1e3,Oe=e=>e/1e3;function Mo(e,t){return t?e*(1e3/t):0}const ei=new Set;function xr(e,t,n){e||ei.has(t)||(console.warn(Bs(t,n)),ei.add(t))}const ko=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Ql=1e-7,ec=12;function tc(e,t,n,s,r){let o,i,a=0;do i=t+(n-t)/2,o=ko(i,s,r)-e,o>0?n=i:t=i;while(Math.abs(o)>Ql&&++a<ec);return i}function In(e,t,n,s){if(e===t&&n===s)return Le;const r=o=>tc(o,0,1,e,n);return o=>o===0||o===1?o:ko(r(o),t,s)}const No=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Do=e=>t=>1-e(1-t),Ro=In(.33,1.53,.69,.99),br=Do(Ro),Vo=No(br),Io=e=>(e*=2)<1?.5*br(e):.5*(2-Math.pow(2,-10*(e-1))),vr=e=>1-Math.sin(Math.acos(e)),Oo=Do(vr),Lo=No(vr),nc=In(.42,0,1,1),sc=In(0,0,.58,1),$o=In(.42,0,.58,1),rc=e=>Array.isArray(e)&&typeof e[0]!="number",Fo=e=>Array.isArray(e)&&typeof e[0]=="number",ti={linear:Le,easeIn:nc,easeInOut:$o,easeOut:sc,circIn:vr,circInOut:Lo,circOut:Oo,backIn:br,backInOut:Vo,backOut:Ro,anticipate:Io},ic=e=>typeof e=="string",ni=e=>{if(Fo(e)){st(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,r]=e;return In(t,n,s,r)}else if(ic(e))return st(ti[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),ti[e];return e},qn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function oc(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 ac=40;function Bo(e,t){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,i=qn.reduce((M,F)=>(M[F]=oc(o),M),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:d,update:h,preRender:m,render:p,postRender:S}=i,w=()=>{const M=rt.useManualTiming?r.timestamp:performance.now();n=!1,rt.useManualTiming||(r.delta=s?1e3/60:Math.max(Math.min(M-r.timestamp,ac),1)),r.timestamp=M,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:qn.reduce((M,F)=>{const D=i[F];return M[F]=(O,N=!1,j=!1)=>(n||T(),D.schedule(O,N,j)),M},{}),cancel:M=>{for(let F=0;F<qn.length;F++)i[qn[F]].cancel(M)},state:r,steps:i}}const{schedule:ce,cancel:ht,state:be,steps:Ss}=Bo(typeof requestAnimationFrame<"u"?requestAnimationFrame:Le,!0);let Qn;function lc(){Qn=void 0}const Me={now:()=>(Qn===void 0&&Me.set(be.isProcessing||rt.useManualTiming?be.timestamp:performance.now()),Qn),set:e=>{Qn=e,queueMicrotask(lc)}},zo=e=>t=>typeof t=="string"&&t.startsWith(e),wr=zo("--"),cc=zo("var(--"),Sr=e=>cc(e)?uc.test(e.split("/*")[0].trim()):!1,uc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Ht={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Mn={...Ht,transform:e=>nt(0,1,e)},Kn={...Ht,default:1},Tn=e=>Math.round(e*1e5)/1e5,Tr=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function dc(e){return e==null}const hc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Cr=(e,t)=>n=>!!(typeof n=="string"&&hc.test(n)&&n.startsWith(e)||t&&!dc(n)&&Object.prototype.hasOwnProperty.call(n,t)),Uo=(e,t,n)=>s=>{if(typeof s!="string")return s;const[r,o,i,a]=s.match(Tr);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(i),alpha:a!==void 0?parseFloat(a):1}},fc=e=>nt(0,255,e),Ts={...Ht,transform:e=>Math.round(fc(e))},At={test:Cr("rgb","red"),parse:Uo("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+Ts.transform(e)+", "+Ts.transform(t)+", "+Ts.transform(n)+", "+Tn(Mn.transform(s))+")"};function mc(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 zs={test:Cr("#"),parse:mc,transform:At.transform},On=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),dt=On("deg"),Qe=On("%"),z=On("px"),pc=On("vh"),gc=On("vw"),si={...Qe,parse:e=>Qe.parse(e)/100,transform:e=>Qe.transform(e*100)},Ft={test:Cr("hsl","hue"),parse:Uo("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+Qe.transform(Tn(t))+", "+Qe.transform(Tn(n))+", "+Tn(Mn.transform(s))+")"},pe={test:e=>At.test(e)||zs.test(e)||Ft.test(e),parse:e=>At.test(e)?At.parse(e):Ft.test(e)?Ft.parse(e):zs.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?At.transform(e):Ft.transform(e),getAnimatableNone:e=>{const t=pe.parse(e);return t.alpha=0,pe.transform(t)}},yc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function xc(e){return isNaN(e)&&typeof e=="string"&&(e.match(Tr)?.length||0)+(e.match(yc)?.length||0)>0}const _o="number",Xo="color",bc="var",vc="var(",ri="${}",wc=/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 kn(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},r=[];let o=0;const a=t.replace(wc,l=>(pe.test(l)?(s.color.push(o),r.push(Xo),n.push(pe.parse(l))):l.startsWith(vc)?(s.var.push(o),r.push(bc),n.push(l)):(s.number.push(o),r.push(_o),n.push(parseFloat(l))),++o,ri)).split(ri);return{values:n,split:a,indexes:s,types:r}}function Wo(e){return kn(e).values}function qo(e){const{split:t,types:n}=kn(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===_o?o+=Tn(r[i]):a===Xo?o+=pe.transform(r[i]):o+=r[i]}return o}}const Sc=e=>typeof e=="number"?0:pe.test(e)?pe.getAnimatableNone(e):e;function Tc(e){const t=Wo(e);return qo(e)(t.map(Sc))}const ft={test:xc,parse:Wo,createTransformer:qo,getAnimatableNone:Tc};function Cs(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 Cc({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=Cs(l,a,e+1/3),o=Cs(l,a,e),i=Cs(l,a,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(i*255),alpha:s}}function rs(e,t){return n=>n>0?t:e}const de=(e,t,n)=>e+(t-e)*n,js=(e,t,n)=>{const s=e*e,r=n*(t*t-s)+s;return r<0?0:Math.sqrt(r)},jc=[zs,At,Ft],Pc=e=>jc.find(t=>t.test(e));function ii(e){const t=Pc(e);if(Yt(!!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===Ft&&(n=Cc(n)),n}const oi=(e,t)=>{const n=ii(e),s=ii(t);if(!n||!s)return rs(e,t);const r={...n};return o=>(r.red=js(n.red,s.red,o),r.green=js(n.green,s.green,o),r.blue=js(n.blue,s.blue,o),r.alpha=de(n.alpha,s.alpha,o),At.transform(r))},Us=new Set(["none","hidden"]);function Ac(e,t){return Us.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Ec(e,t){return n=>de(e,t,n)}function jr(e){return typeof e=="number"?Ec:typeof e=="string"?Sr(e)?rs:pe.test(e)?oi:Nc:Array.isArray(e)?Ko:typeof e=="object"?pe.test(e)?oi:Mc:rs}function Ko(e,t){const n=[...e],s=n.length,r=e.map((o,i)=>jr(o)(o,t[i]));return o=>{for(let i=0;i<s;i++)n[i]=r[i](o);return n}}function Mc(e,t){const n={...e,...t},s={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(s[r]=jr(e[r])(e[r],t[r]));return r=>{for(const o in s)n[o]=s[o](r);return n}}function kc(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 Nc=(e,t)=>{const n=ft.createTransformer(t),s=kn(e),r=kn(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?Us.has(e)&&!r.values.length||Us.has(t)&&!s.values.length?Ac(e,t):Vn(Ko(kc(s,r),r.values),n):(Yt(!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"),rs(e,t))};function Go(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?de(e,t,n):jr(e)(e,t)}const Dc=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ce.update(t,n),stop:()=>ht(t),now:()=>be.isProcessing?be.timestamp:Me.now()}},Yo=(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)})`},is=2e4;function Pr(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<is;)t+=n,s=e.next(t);return t>=is?1/0:t}function Rc(e,t=100,n){const s=n({...e,keyframes:[0,t]}),r=Math.min(Pr(s),is);return{type:"keyframes",ease:o=>s.next(r*o).value/t,duration:Oe(r)}}const Vc=5;function Ho(e,t,n){const s=Math.max(t-Vc,0);return Mo(n-e(s),t-s)}const ue={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},Ps=.001;function Ic({duration:e=ue.duration,bounce:t=ue.bounce,velocity:n=ue.velocity,mass:s=ue.mass}){let r,o;Yt(e<=qe(ue.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=nt(ue.minDamping,ue.maxDamping,i),e=nt(ue.minDuration,ue.maxDuration,Oe(e)),i<1?(r=u=>{const d=u*i,h=d*e,m=d-n,p=_s(u,i),S=Math.exp(-h);return Ps-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=_s(Math.pow(u,2),i);return(-r(u)+Ps>0?-1:1)*((m-p)*S)/w}):(r=u=>{const d=Math.exp(-u*e),h=(u-n)*e+1;return-Ps+d*h},o=u=>{const d=Math.exp(-u*e),h=(n-u)*(e*e);return d*h});const a=5/e,l=Lc(r,o,a);if(e=qe(e),isNaN(l))return{stiffness:ue.stiffness,damping:ue.damping,duration:e};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:i*2*Math.sqrt(s*u),duration:e}}}const Oc=12;function Lc(e,t,n){let s=n;for(let r=1;r<Oc;r++)s=s-e(s)/t(s);return s}function _s(e,t){return e*Math.sqrt(1-t*t)}const $c=["duration","bounce"],Fc=["stiffness","damping","mass"];function ai(e,t){return t.some(n=>e[n]!==void 0)}function Bc(e){let t={velocity:ue.velocity,stiffness:ue.stiffness,damping:ue.damping,mass:ue.mass,isResolvedFromDuration:!1,...e};if(!ai(e,Fc)&&ai(e,$c))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,o=2*nt(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:ue.mass,stiffness:r,damping:o}}else{const n=Ic(e);t={...t,...n,mass:ue.mass},t.isResolvedFromDuration=!0}return t}function os(e=ue.visualDuration,t=ue.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}=Bc({...n,velocity:-Oe(n.velocity||0)}),S=m||0,w=u/(2*Math.sqrt(l*d)),T=i-o,v=Oe(Math.sqrt(l/d)),E=Math.abs(T)<5;s||(s=E?ue.restSpeed.granular:ue.restSpeed.default),r||(r=E?ue.restDelta.granular:ue.restDelta.default);let M;if(w<1){const D=_s(v,w);M=O=>{const N=Math.exp(-w*v*O);return i-N*((S+w*v*T)/D*Math.sin(D*O)+T*Math.cos(D*O))}}else if(w===1)M=D=>i-Math.exp(-v*D)*(T+(S+v*T)*D);else{const D=v*Math.sqrt(w*w-1);M=O=>{const N=Math.exp(-w*v*O),j=Math.min(D*O,300);return i-N*((S+w*v*T)*Math.sinh(j)+D*T*Math.cosh(j))/D}}const F={calculatedDuration:p&&h||null,next:D=>{const O=M(D);if(p)a.done=D>=h;else{let N=D===0?S:0;w<1&&(N=D===0?qe(S):Ho(M,D,O));const j=Math.abs(N)<=s,L=Math.abs(i-O)<=r;a.done=j&&L}return a.value=a.done?i:O,a},toString:()=>{const D=Math.min(Pr(F),is),O=Yo(N=>F.next(D*N).value,D,30);return D+"ms "+O},toTransition:()=>{}};return F}os.applyToOptions=e=>{const t=Rc(e,100,os);return e.ease=t.ease,e.duration=qe(t.duration),e.type="keyframes",e};function Xs({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=j=>a!==void 0&&j<a||l!==void 0&&j>l,S=j=>a===void 0?l:l===void 0||Math.abs(a-j)<Math.abs(l-j)?a:l;let w=n*t;const T=h+w,v=i===void 0?T:i(T);v!==T&&(w=v-h);const E=j=>-w*Math.exp(-j/s),M=j=>v+E(j),F=j=>{const L=E(j),A=M(j);m.done=Math.abs(L)<=u,m.value=m.done?v:A};let D,O;const N=j=>{p(m.value)&&(D=j,O=os({keyframes:[m.value,S(m.value)],velocity:Ho(M,j,m.value),damping:r,stiffness:o,restDelta:u,restSpeed:d}))};return N(0),{calculatedDuration:null,next:j=>{let L=!1;return!O&&D===void 0&&(L=!0,F(j),N(j)),D!==void 0&&j>=D?O.next(j-D):(!L&&F(j),m)}}}function zc(e,t,n){const s=[],r=n||rt.mix||Go,o=e.length-1;for(let i=0;i<o;i++){let a=r(e[i],e[i+1]);if(t){const l=Array.isArray(t)?t[i]||Le:t;a=Vn(l,a)}s.push(a)}return s}function Uc(e,t,{clamp:n=!0,ease:s,mixer:r}={}){const o=e.length;if(st(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=zc(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=En(e[h],e[h+1],d);return a[h](m)};return n?d=>u(nt(e[0],e[o-1],d)):u}function _c(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=En(0,t,s);e.push(de(n,1,r))}}function Xc(e){const t=[0];return _c(t,e.length-1),t}function Wc(e,t){return e.map(n=>n*t)}function qc(e,t){return e.map(()=>t||$o).splice(0,e.length-1)}function Bt({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const r=rc(s)?s.map(ni):ni(s),o={done:!1,value:t[0]},i=Wc(n&&n.length===t.length?n:Xc(t),e),a=Uc(i,t,{ease:Array.isArray(r)?r:qc(t,r)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Kc=e=>e!==null;function Ar(e,{repeat:t,repeatType:n="loop"},s,r=1){const o=e.filter(Kc),a=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Gc={decay:Xs,inertia:Xs,tween:Bt,keyframes:Bt,spring:os};function Jo(e){typeof e.type=="string"&&(e.type=Gc[e.type])}class Er{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 Yc=e=>e/100;class Mr extends Er{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;Jo(t);const{type:n=Bt,repeat:s=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=t;let{keyframes:a}=t;const l=n||Bt;process.env.NODE_ENV!=="production"&&l!==Bt&&st(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Bt&&typeof a[0]!="number"&&(this.mixKeyframes=Vn(Yc,Go(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=Pr(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 v=this.currentTime-u*(this.playbackSpeed>=0?1:-1),E=this.playbackSpeed>=0?v<0:v>r;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let M=this.currentTime,F=s;if(h){const j=Math.min(this.currentTime,r)/a;let L=Math.floor(j),A=j%1;!A&&j>=1&&(A=1),A===1&&L--,L=Math.min(L,h+1),!!(L%2)&&(m==="reverse"?(A=1-A,p&&(A-=p/a)):m==="mirror"&&(F=i)),M=nt(0,1,A)*a}const D=E?{done:!1,value:d[0]}:F.next(M);o&&(D.value=o(D.value));let{done:O}=D;!E&&l!==null&&(O=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const N=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return N&&S!==Xs&&(D.value=Ar(d,this.options,T,this.speed)),w&&w(D.value),N&&this.finish(),D}then(t,n){return this.finished.then(t,n)}get duration(){return Oe(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Oe(t)}get time(){return Oe(this.currentTime)}set time(t){t=qe(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=Oe(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Dc,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 Hc(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Et=e=>e*180/Math.PI,Ws=e=>{const t=Et(Math.atan2(e[1],e[0]));return qs(t)},Jc={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Ws,rotateZ:Ws,skewX:e=>Et(Math.atan(e[1])),skewY:e=>Et(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},qs=e=>(e=e%360,e<0&&(e+=360),e),li=Ws,ci=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),ui=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Zc={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ci,scaleY:ui,scale:e=>(ci(e)+ui(e))/2,rotateX:e=>qs(Et(Math.atan2(e[6],e[5]))),rotateY:e=>qs(Et(Math.atan2(-e[2],e[0]))),rotateZ:li,rotate:li,skewX:e=>Et(Math.atan(e[4])),skewY:e=>Et(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Ks(e){return e.includes("scale")?1:0}function Gs(e,t){if(!e||e==="none")return Ks(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=Zc,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Jc,r=a}if(!r)return Ks(t);const o=s[t],i=r[1].split(",").map(eu);return typeof o=="function"?o(i):i[o]}const Qc=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Gs(n,t)};function eu(e){return parseFloat(e.trim())}const Jt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Zt=new Set(Jt),di=e=>e===Ht||e===z,tu=new Set(["x","y","z"]),nu=Jt.filter(e=>!tu.has(e));function su(e){const t=[];return nu.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Mt={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})=>Gs(t,"x"),y:(e,{transform:t})=>Gs(t,"y")};Mt.translateX=Mt.x;Mt.translateY=Mt.y;const kt=new Set;let Ys=!1,Hs=!1,Js=!1;function Zo(){if(Hs){const e=Array.from(kt).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const r=su(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)})}Hs=!1,Ys=!1,kt.forEach(e=>e.complete(Js)),kt.clear()}function Qo(){kt.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Hs=!0)})}function ru(){Js=!0,Qo(),Zo(),Js=!1}class kr{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?(kt.add(this),Ys||(Ys=!0,ce.read(Qo),ce.resolveKeyframes(Zo))):(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])}Hc(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),kt.delete(this)}cancel(){this.state==="scheduled"&&(kt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const iu=e=>e.startsWith("--");function ou(e,t,n){iu(t)?e.style.setProperty(t,n):e.style[t]=n}const au=gr(()=>window.ScrollTimeline!==void 0),lu={};function cu(e,t){const n=gr(e);return()=>lu[t]??n()}const ea=cu(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),wn=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,hi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:wn([0,.65,.55,1]),circOut:wn([.55,0,1,.45]),backIn:wn([.31,.01,.66,-.59]),backOut:wn([.33,1.53,.69,.99])};function ta(e,t){if(e)return typeof e=="function"?ea()?Yo(e,t):"ease-out":Fo(e)?wn(e):Array.isArray(e)?e.map(n=>ta(n,t)||hi.easeOut):hi[e]}function uu(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=ta(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 na(e){return typeof e=="function"&&"applyToOptions"in e}function du({type:e,...t}){return na(e)&&ea()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class hu extends Er{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,st(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=du(t);this.animation=uu(n,s,r,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Ar(r,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):ou(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 Oe(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Oe(t)}get time(){return Oe(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=qe(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&&au()?(this.animation.timeline=t,Le):n(this)}}const sa={anticipate:Io,backInOut:Vo,circInOut:Lo};function fu(e){return e in sa}function mu(e){typeof e.ease=="string"&&fu(e.ease)&&(e.ease=sa[e.ease])}const fi=10;class pu extends hu{constructor(t){mu(t),Jo(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 Mr({...i,autoplay:!1}),l=qe(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-fi).value,a.sample(l).value,fi),a.stop()}}const mi=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(ft.test(e)||e==="0")&&!e.startsWith("url("));function gu(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 yu(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=mi(r,t),a=mi(o,t);return Yt(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:gu(e)||(n==="spring"||na(n))&&s}function Zs(e){e.duration=0,e.type="keyframes"}const xu=new Set(["opacity","clipPath","filter","transform"]),bu=gr(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function vu(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 bu()&&n&&xu.has(n)&&(n!=="transform"||!u)&&!l&&!s&&r!=="mirror"&&o!==0&&i!=="inertia"}const wu=40;class Su extends Er{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||kr;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=Me.now(),yu(t,o,i,a)||((rt.instantAnimations||!l)&&d?.(Ar(t,s,n)),t[0]=t[t.length-1],Zs(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>wu?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!u&&vu(m)?new pu({...m,element:m.motionValue.owner.current}):new Mr(m);p.finished.then(()=>this.notifyFinished()).catch(Le),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),ru()),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 Tu=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Cu(e){const t=Tu.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}const ju=4;function ra(e,t,n=1){st(n<=ju,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=Cu(e);if(!s)return;const o=window.getComputedStyle(t).getPropertyValue(s);if(o){const i=o.trim();return Po(i)?parseFloat(i):i}return Sr(r)?ra(r,t,n+1):r}function Nr(e,t){return e?.[t]??e?.default??e}const ia=new Set(["width","height","top","left","right","bottom",...Jt]),Pu={test:e=>e==="auto",parse:e=>e},oa=e=>t=>t.test(e),aa=[Ht,z,Qe,dt,gc,pc,Pu],pi=e=>aa.find(oa(e));function Au(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Eo(e):!0}const Eu=new Set(["brightness","contrast","saturate","opacity"]);function Mu(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(Tr)||[];if(!s)return e;const r=n.replace(s,"");let o=Eu.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+r+")"}const ku=/\b([a-z-]*)\(.*?\)/gu,Qs={...ft,getAnimatableNone:e=>{const t=e.match(ku);return t?t.map(Mu).join(" "):e}},gi={...Ht,transform:Math.round},Nu={rotate:dt,rotateX:dt,rotateY:dt,rotateZ:dt,scale:Kn,scaleX:Kn,scaleY:Kn,scaleZ:Kn,skew:dt,skewX:dt,skewY:dt,distance:z,translateX:z,translateY:z,translateZ:z,x:z,y:z,z,perspective:z,transformPerspective:z,opacity:Mn,originX:si,originY:si,originZ:z},Dr={borderWidth:z,borderTopWidth:z,borderRightWidth:z,borderBottomWidth:z,borderLeftWidth:z,borderRadius:z,radius:z,borderTopLeftRadius:z,borderTopRightRadius:z,borderBottomRightRadius:z,borderBottomLeftRadius:z,width:z,maxWidth:z,height:z,maxHeight:z,top:z,right:z,bottom:z,left:z,padding:z,paddingTop:z,paddingRight:z,paddingBottom:z,paddingLeft:z,margin:z,marginTop:z,marginRight:z,marginBottom:z,marginLeft:z,backgroundPositionX:z,backgroundPositionY:z,...Nu,zIndex:gi,fillOpacity:Mn,strokeOpacity:Mn,numOctaves:gi},Du={...Dr,color:pe,backgroundColor:pe,outlineColor:pe,fill:pe,stroke:pe,borderColor:pe,borderTopColor:pe,borderRightColor:pe,borderBottomColor:pe,borderLeftColor:pe,filter:Qs,WebkitFilter:Qs},la=e=>Du[e];function ca(e,t){let n=la(e);return n!==Qs&&(n=ft),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Ru=new Set(["auto","none","0"]);function Vu(e,t,n){let s=0,r;for(;s<e.length&&!r;){const o=e[s];typeof o=="string"&&!Ru.has(o)&&kn(o).values.length&&(r=e[s]),s++}if(r&&n)for(const o of t)e[o]=ca(n,r)}class Iu extends kr{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(),Sr(u))){const d=ra(u,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!ia.has(s)||t.length!==2)return;const[r,o]=t,i=pi(r),a=pi(o);if(i!==a)if(di(i)&&di(a))for(let l=0;l<t.length;l++){const u=t[l];typeof u=="string"&&(t[l]=parseFloat(u))}else Mt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||Au(t[r]))&&s.push(r);s.length&&Vu(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=Mt[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]=Mt[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 Ou(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 ua=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function da(e){return Ao(e)&&"offsetHeight"in e}const yi=30,Lu=e=>!isNaN(parseFloat(e));class $u{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=Lu(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&xr(!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 yr);const s=this.events[t].add(n);return t==="change"?()=>{s(),ce.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>yi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,yi);return Mo(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 Kt(e,t){return new $u(e,t)}const{schedule:Rr}=Bo(queueMicrotask,!1),Xe={x:!1,y:!1};function ha(){return Xe.x||Xe.y}function Fu(e){return e==="x"||e==="y"?Xe[e]?null:(Xe[e]=!0,()=>{Xe[e]=!1}):Xe.x||Xe.y?null:(Xe.x=Xe.y=!0,()=>{Xe.x=Xe.y=!1})}function fa(e,t){const n=Ou(e),s=new AbortController,r={passive:!0,...t,signal:s.signal};return[n,r,()=>s.abort()]}function xi(e){return!(e.pointerType==="touch"||ha())}function Bu(e,t,n={}){const[s,r,o]=fa(e,n),i=a=>{if(!xi(a))return;const{target:l}=a,u=t(l,a);if(typeof u!="function"||!l)return;const d=h=>{xi(h)&&(u(h),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return s.forEach(a=>{a.addEventListener("pointerenter",i,r)}),o}const ma=(e,t)=>t?e===t?!0:ma(e,t.parentElement):!1,Vr=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,zu=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Uu(e){return zu.has(e.tagName)||e.tabIndex!==-1}const es=new WeakSet;function bi(e){return t=>{t.key==="Enter"&&e(t)}}function As(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const _u=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=bi(()=>{if(es.has(n))return;As(n,"down");const r=bi(()=>{As(n,"up")}),o=()=>As(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 vi(e){return Vr(e)&&!ha()}function Xu(e,t,n={}){const[s,r,o]=fa(e,n),i=a=>{const l=a.currentTarget;if(!vi(a))return;es.add(l);const u=t(l,a),d=(p,S)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",m),es.has(l)&&es.delete(l),vi(p)&&typeof u=="function"&&u(p,{success:S})},h=p=>{d(p,l===window||l===document||n.useGlobalTarget||ma(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),da(a)&&(a.addEventListener("focus",u=>_u(u,r)),!Uu(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function pa(e){return Ao(e)&&"ownerSVGElement"in e}function Wu(e){return pa(e)&&e.tagName==="svg"}const Se=e=>!!(e&&e.getVelocity),qu=[...aa,pe,ft],Ku=e=>qu.find(oa(e)),Ir=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function wi(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Gu(...e){return t=>{let n=!1;const s=e.map(r=>{const o=wi(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():wi(e[r],null)}}}}function Yu(...e){return We.useCallback(Gu(...e),e)}class Hu extends We.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,r=da(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 Ju({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(Ir),l=Yu(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(`
|
|
12
3
|
[data-motion-pop-id="${r}"] {
|
|
13
4
|
position: absolute !important;
|
|
14
5
|
width: ${u}px !important;
|
|
15
6
|
height: ${d}px !important;
|
|
16
|
-
${
|
|
7
|
+
${S}px !important;
|
|
17
8
|
top: ${h}px !important;
|
|
18
9
|
}
|
|
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
|
-
${
|
|
21
|
-
${
|
|
22
|
-
${
|
|
23
|
-
${
|
|
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;
|
|
10
|
+
`),()=>{T.contains(w)&&T.removeChild(w)}},[t]),c.jsx(Hu,{isPresent:t,childRef:o,sizeRef:i,children:We.cloneElement(e,{ref:l})})}const Zu=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:o,mode:i,anchorX:a,root:l})=>{const u=hr(Qu),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]),We.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),i==="popLayout"&&(e=c.jsx(Ju,{isPresent:n,anchorX:a,root:l,children:e})),c.jsx(us.Provider,{value:m,children:e})};function Qu(){return new Map}function ga(e=!0){const t=f.useContext(us);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 Gn=e=>e.key||"";function Si(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const ed=({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]=ga(i),h=f.useMemo(()=>Si(e),[e]),m=i&&!u?[]:h.map(Gn),p=f.useRef(!0),S=f.useRef(h),w=hr(()=>new Map),[T,v]=f.useState(h),[E,M]=f.useState(h);jo(()=>{p.current=!1,S.current=h;for(let O=0;O<E.length;O++){const N=Gn(E[O]);m.includes(N)?w.delete(N):w.get(N)!==!0&&w.set(N,!1)}},[E,m.length,m.join("-")]);const F=[];if(h!==T){let O=[...h];for(let N=0;N<E.length;N++){const j=E[N],L=Gn(j);m.includes(L)||(O.splice(N,0,j),F.push(j))}return o==="wait"&&F.length&&(O=F),M(Si(O)),v(h),null}process.env.NODE_ENV!=="production"&&o==="wait"&&E.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:D}=f.useContext(dr);return c.jsx(c.Fragment,{children:E.map(O=>{const N=Gn(O),j=i&&!u?!1:h===E||m.includes(N),L=()=>{if(w.has(N))w.set(N,!0);else return;let A=!0;w.forEach(k=>{k||(A=!1)}),A&&(D?.(),M(S.current),i&&d?.(),s&&s())};return c.jsx(Zu,{isPresent:j,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:o,root:l,onExitComplete:j?void 0:L,anchorX:a,children:O},N)})})},Or=f.createContext({strict:!1}),Ti={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"]},Gt={};for(const e in Ti)Gt[e]={isEnabled:t=>Ti[e].some(n=>!!t[n])};function er(e){for(const t in e)Gt[t]={...Gt[t],...e[t]}}function td({children:e,features:t,strict:n=!1}){const[,s]=f.useState(!Es(t)),r=f.useRef(void 0);if(!Es(t)){const{renderer:o,...i}=t;r.current=o,er(i)}return f.useEffect(()=>{Es(t)&&t().then(({renderer:o,...i})=>{er(i),r.current=o,s(!0)})},[]),c.jsx(Or.Provider,{value:{renderer:r.current,strict:n},children:e})}function Es(e){return typeof e=="function"}const nd=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 as(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||nd.has(e)}let ya=e=>!as(e);function sd(e){typeof e=="function"&&(ya=t=>t.startsWith("on")?!as(t):e(t))}try{sd(require("@emotion/is-prop-valid").default)}catch{}function rd(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||(ya(r)||n===!0&&as(r)||!t&&!as(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const ds=f.createContext({});function hs(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Nn(e){return typeof e=="string"||Array.isArray(e)}const Lr=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],$r=["initial",...Lr];function fs(e){return hs(e.animate)||$r.some(t=>Nn(e[t]))}function xa(e){return!!(fs(e)||e.variants)}function id(e,t){if(fs(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Nn(n)?n:void 0,animate:Nn(s)?s:void 0}}return e.inherit!==!1?t:{}}function od(e){const{initial:t,animate:n}=id(e,f.useContext(ds));return f.useMemo(()=>({initial:t,animate:n}),[Ci(t),Ci(n)])}function Ci(e){return Array.isArray(e)?e.join(" "):e}const Dn={};function ad(e){for(const t in e)Dn[t]=e[t],wr(t)&&(Dn[t].isCSSVariable=!0)}function ba(e,{layout:t,layoutId:n}){return Zt.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Dn[e]||e==="opacity")}const ld={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},cd=Jt.length;function ud(e,t,n){let s="",r=!0;for(let o=0;o<cd;o++){const i=Jt[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=ua(a,Dr[i]);if(!l){r=!1;const d=ld[i]||i;s+=`${d}(${u}) `}n&&(t[i]=u)}}return s=s.trim(),n?s=n(t,r?"":s):r&&(s="none"),s}function Fr(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(Zt.has(l)){i=!0;continue}else if(wr(l)){r[l]=u;continue}else{const d=ua(u,Dr[l]);l.startsWith("origin")?(a=!0,o[l]=d):s[l]=d}}if(t.transform||(i||n?s.transform=ud(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 Br=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function va(e,t,n){for(const s in t)!Se(t[s])&&!ba(s,n)&&(e[s]=t[s])}function dd({transformTemplate:e},t){return f.useMemo(()=>{const n=Br();return Fr(n,t,e),Object.assign({},n.vars,n.style)},[t])}function hd(e,t){const n=e.style||{},s={};return va(s,n,e),Object.assign(s,dd(e,t)),s}function fd(e,t){const n={},s=hd(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 md={offset:"stroke-dashoffset",array:"stroke-dasharray"},pd={offset:"strokeDashoffset",array:"strokeDasharray"};function gd(e,t,n=1,s=0,r=!0){e.pathLength=1;const o=r?md:pd;e[o.offset]=z.transform(-s);const i=z.transform(t),a=z.transform(n);e[o.array]=`${i} ${a}`}function wa(e,{attrX:t,attrY:n,attrScale:s,pathLength:r,pathSpacing:o=1,pathOffset:i=0,...a},l,u,d){if(Fr(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&&gd(h,r,o,i,!1)}const Sa=()=>({...Br(),attrs:{}}),Ta=e=>typeof e=="string"&&e.toLowerCase()==="svg";function yd(e,t,n,s){const r=f.useMemo(()=>{const o=Sa();return wa(o,t,Ta(s),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};va(o,e.style,e),r.style={...o,...r.style}}return r}const xd=["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 zr(e){return typeof e!="string"||e.includes("-")?!1:!!(xd.indexOf(e)>-1||/[A-Z]/u.test(e))}function bd(e,t,n,{latestValues:s},r,o=!1){const a=(zr(e)?yd:fd)(t,s,r,e),l=rd(t,typeof e=="string",o),u=e!==f.Fragment?{...l,...a,ref:n}:{},{children:d}=t,h=f.useMemo(()=>Se(d)?d.get():d,[d]);return f.createElement(e,{...u,children:h})}function ji(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Ur(e,t,n,s){if(typeof t=="function"){const[r,o]=ji(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]=ji(s);t=t(n!==void 0?n:e.custom,r,o)}return t}function ts(e){return Se(e)?e.get():e}function vd({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:wd(n,s,r,e),renderState:t()}}function wd(e,t,n,s){const r={},o=s(e,{});for(const m in o)r[m]=ts(o[m]);let{initial:i,animate:a}=e;const l=fs(e),u=xa(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"&&!hs(h)){const m=Array.isArray(h)?h:[h];for(let p=0;p<m.length;p++){const S=Ur(e,m[p]);if(S){const{transitionEnd:w,transition:T,...v}=S;for(const E in v){let M=v[E];if(Array.isArray(M)){const F=d?M.length-1:0;M=M[F]}M!==null&&(r[E]=M)}for(const E in w)r[E]=w[E]}}}return r}const Ca=e=>(t,n)=>{const s=f.useContext(ds),r=f.useContext(us),o=()=>vd(e,t,s,r);return n?o():hr(o)};function _r(e,t,n){const{style:s}=e,r={};for(const o in s)(Se(s[o])||t.style&&Se(t.style[o])||ba(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(r[o]=s[o]);return r}const Sd=Ca({scrapeMotionValuesFromProps:_r,createRenderState:Br});function ja(e,t,n){const s=_r(e,t,n);for(const r in e)if(Se(e[r])||Se(t[r])){const o=Jt.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;s[o]=e[r]}return s}const Td=Ca({scrapeMotionValuesFromProps:ja,createRenderState:Sa}),Cd=Symbol.for("motionComponentSymbol");function zt(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function jd(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):zt(n)&&(n.current=s))},[t])}const Xr=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Pd="framerAppearId",Pa="data-"+Xr(Pd),Aa=f.createContext({});function Ad(e,t,n,s,r){const{visualElement:o}=f.useContext(ds),i=f.useContext(Or),a=f.useContext(us),l=f.useContext(Ir).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(Aa);d&&!d.projection&&r&&(d.type==="html"||d.type==="svg")&&Ed(u.current,n,r,h);const m=f.useRef(!1);f.useInsertionEffect(()=>{d&&m.current&&d.update(n,a)});const p=n[Pa],S=f.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return jo(()=>{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 Ed(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:Ea(e.parent)),e.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!i||a&&zt(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:d,layoutScroll:l,layoutRoot:u})}function Ea(e){if(e)return e.options.allowProjection!==!1?e.projection:Ea(e.parent)}function ns(e,{forwardMotionProps:t=!1}={},n,s){n&&er(n);const r=zr(e)?Td:Sd;function o(a,l){let u;const d={...f.useContext(Ir),...a,layoutId:Md(a)},{isStatic:h}=d,m=od(a),p=r(a,h);if(!h&&fr){kd(d,n);const S=Nd(d);u=S.MeasureLayout,m.visualElement=Ad(e,p,d,s,S.ProjectionNode)}return c.jsxs(ds.Provider,{value:m,children:[u&&m.visualElement?c.jsx(u,{visualElement:m.visualElement,...d}):null,bd(e,a,jd(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[Cd]=e,i}function Md({layoutId:e}){const t=f.useContext(dr).id;return t&&e!==void 0?t+"-"+e:e}function kd(e,t){const n=f.useContext(Or).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?Yt(!1,s,"lazy-strict-mode"):st(!1,s,"lazy-strict-mode")}}function Nd(e){const{drag:t,layout:n}=Gt;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Dd(e,t){if(typeof Proxy>"u")return ns;const n=new Map,s=(o,i)=>ns(o,i,e,t),r=(o,i)=>(process.env.NODE_ENV!=="production"&&xr(!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,ns(i,void 0,e,t)),n.get(i))})}function Ma({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Rd({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Vd(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 Ms(e){return e===void 0||e===1}function tr({scale:e,scaleX:t,scaleY:n}){return!Ms(e)||!Ms(t)||!Ms(n)}function Pt(e){return tr(e)||ka(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function ka(e){return Pi(e.x)||Pi(e.y)}function Pi(e){return e&&e!=="0%"}function ls(e,t,n){const s=e-n,r=t*s;return n+r}function Ai(e,t,n,s,r){return r!==void 0&&(e=ls(e,r,s)),ls(e,n,s)+t}function nr(e,t=0,n=1,s,r){e.min=Ai(e.min,t,n,s,r),e.max=Ai(e.max,t,n,s,r)}function Na(e,{x:t,y:n}){nr(e.x,t.translate,t.scale,t.originPoint),nr(e.y,n.translate,n.scale,n.originPoint)}const Ei=.999999999999,Mi=1.0000000000001;function Id(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&&_t(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Na(e,i)),s&&Pt(o.latestValues)&&_t(e,o.latestValues))}t.x<Mi&&t.x>Ei&&(t.x=1),t.y<Mi&&t.y>Ei&&(t.y=1)}function Ut(e,t){e.min=e.min+t,e.max=e.max+t}function ki(e,t,n,s,r=.5){const o=de(e.min,e.max,r);nr(e,t,n,o,s)}function _t(e,t){ki(e.x,t.x,t.scaleX,t.scale,t.originX),ki(e.y,t.y,t.scaleY,t.scale,t.originY)}function Da(e,t){return Ma(Vd(e.getBoundingClientRect(),t))}function Od(e,t,n){const s=Da(e,n),{scroll:r}=t;return r&&(Ut(s.x,r.offset.x),Ut(s.y,r.offset.y)),s}const Ni=()=>({translate:0,scale:1,origin:0,originPoint:0}),Xt=()=>({x:Ni(),y:Ni()}),Di=()=>({min:0,max:0}),me=()=>({x:Di(),y:Di()}),sr={current:null},Ra={current:!1};function Ld(){if(Ra.current=!0,!!fr)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>sr.current=e.matches;e.addEventListener("change",t),t()}else sr.current=!1}const $d=new WeakMap;function Fd(e,t,n){for(const s in t){const r=t[s],o=n[s];if(Se(r))e.addValue(s,r);else if(Se(o))e.addValue(s,Kt(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,Kt(i!==void 0?i:r,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Ri=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Bd{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=kr,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,ce.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=fs(n),this.isVariantNode=xa(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&&Se(p)&&p.set(l[m])}}mount(t){this.current=t,$d.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)),Ra.current||Ld(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:sr.current,process.env.NODE_ENV!=="production"&&xr(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(),ht(this.notifyUpdate),ht(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=Zt.has(t);s&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",i=>{this.latestValues[t]=i,this.props.onUpdate&&ce.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 Gt){const n=Gt[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):me()}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<Ri.length;s++){const r=Ri[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=Fd(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=Kt(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"&&(Po(s)||Eo(s))?s=parseFloat(s):!Ku(s)&&ft.test(n)&&(s=ca(t,n)),this.setBaseTarget(t,Se(s)?s.get():s)),Se(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=Ur(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&&!Se(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 yr),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Rr.render(this.render)}}class Va extends Bd{constructor(){super(...arguments),this.KeyframeResolver=Iu}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;Se(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Ia(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 zd(e){return window.getComputedStyle(e)}class Ud extends Va{constructor(){super(...arguments),this.type="html",this.renderInstance=Ia}readValueFromInstance(t,n){if(Zt.has(n))return this.projection?.isProjecting?Ks(n):Qc(t,n);{const s=zd(t),r=(wr(n)?s.getPropertyValue(n):s[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Da(t,n)}build(t,n,s){Fr(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return _r(t,n,s)}}const Oa=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 _d(e,t,n,s){Ia(e,t,void 0,s);for(const r in t.attrs)e.setAttribute(Oa.has(r)?r:Xr(r),t.attrs[r])}class Xd extends Va{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=me}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Zt.has(n)){const s=la(n);return s&&s.default||0}return n=Oa.has(n)?n:Xr(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return ja(t,n,s)}build(t,n,s){wa(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,r){_d(t,n,s,r)}mount(t){this.isSVGTag=Ta(t.tagName),super.mount(t)}}const La=(e,t)=>zr(e)?new Xd(t):new Ud(t,{allowProjection:e!==f.Fragment});function qt(e,t,n){const s=e.getProps();return Ur(s,t,n!==void 0?n:s.custom,e)}const rr=e=>Array.isArray(e);function Wd(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Kt(n))}function qd(e){return rr(e)?e[e.length-1]||0:e}function Kd(e,t){const n=qt(e,t);let{transitionEnd:s={},transition:r={},...o}=n||{};o={...o,...s};for(const i in o){const a=qd(o[i]);Wd(e,i,a)}}function Gd(e){return!!(Se(e)&&e.add)}function ir(e,t){const n=e.getValue("willChange");if(Gd(n))return n.add(t);if(!n&&rt.WillChange){const s=new rt.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function $a(e){return e.props[Pa]}const Yd=e=>e!==null;function Hd(e,{repeat:t,repeatType:n="loop"},s){const r=e.filter(Yd),o=t&&n!=="loop"&&t%2===1?0:r.length-1;return r[o]}const Jd={type:"spring",stiffness:500,damping:25,restSpeed:10},Zd=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Qd={type:"keyframes",duration:.8},eh={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},th=(e,{keyframes:t})=>t.length>2?Qd:Zt.has(e)?e.startsWith("scale")?Zd(t[1]):Jd:eh;function nh({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 Wr=(e,t,n,s={},r,o)=>i=>{const a=Nr(s,e)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-qe(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};nh(a)||Object.assign(d,th(e,d)),d.duration&&(d.duration=qe(d.duration)),d.repeatDelay&&(d.repeatDelay=qe(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let h=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(Zs(d),d.delay===0&&(h=!0)),(rt.instantAnimations||rt.skipAnimations)&&(h=!0,Zs(d),d.delay=0),d.allowFlatten=!a.type&&!a.ease,h&&!o&&t.get()!==void 0){const m=Hd(d.keyframes,a);if(m!==void 0){ce.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new Mr(d):new Su(d)};function sh({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function Fa(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&&sh(u,d))continue;const p={delay:n,...Nr(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 v=$a(e);if(v){const E=window.MotionHandoffAnimation(v,d,ce);E!==null&&(p.startTime=E,w=!0)}}ir(e,d),h.start(Wr(d,h,m,e.shouldReduceMotion&&ia.has(d)?{type:!1}:p,e,w));const T=h.animation;T&&l.push(T)}return i&&Promise.all(l).then(()=>{ce.update(()=>{i&&Kd(e,i)})}),l}function Ba(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 or(e,t,n={}){const s=qt(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(Fa(e,s,n)):()=>Promise.resolve(),i=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:d,staggerDirection:h}=r;return rh(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 rh(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(or(l,t,{...i,delay:n+(typeof s=="function"?0:s)+Ba(e.variantChildren,l,s,r,o)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function ih(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const r=t.map(o=>or(e,o,n));s=Promise.all(r)}else if(typeof t=="string")s=or(e,t,n);else{const r=typeof t=="function"?qt(e,t,n.custom):t;s=Promise.all(Fa(e,r,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function za(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 oh=$r.length;function Ua(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Ua(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<oh;n++){const s=$r[n],r=e.props[s];(Nn(r)||r===!1)&&(t[s]=r)}return t}const ah=[...Lr].reverse(),lh=Lr.length;function ch(e){return t=>Promise.all(t.map(({animation:n,options:s})=>ih(e,n,s)))}function uh(e){let t=ch(e),n=Vi(),s=!0;const r=l=>(u,d)=>{const h=qt(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=Ua(e.parent)||{},h=[],m=new Set;let p={},S=1/0;for(let T=0;T<lh;T++){const v=ah[T],E=n[v],M=u[v]!==void 0?u[v]:d[v],F=Nn(M),D=v===l?E.isActive:null;D===!1&&(S=T);let O=M===d[v]&&M!==u[v]&&F;if(O&&s&&e.manuallyAnimateOnMount&&(O=!1),E.protectedKeys={...p},!E.isActive&&D===null||!M&&!E.prevProp||hs(M)||typeof M=="boolean")continue;const N=dh(E.prevProp,M);let j=N||v===l&&E.isActive&&!O&&F||T>S&&F,L=!1;const A=Array.isArray(M)?M:[M];let k=A.reduce(r(v),{});D===!1&&(k={});const{prevResolvedValues:B={}}=E,V={...B,...k},I=J=>{j=!0,m.has(J)&&(L=!0,m.delete(J)),E.needsAnimating[J]=!0;const se=e.getValue(J);se&&(se.liveStyle=!1)};for(const J in V){const se=k[J],Ce=B[J];if(p.hasOwnProperty(J))continue;let De=!1;rr(se)&&rr(Ce)?De=!za(se,Ce):De=se!==Ce,De?se!=null?I(J):m.add(J):se!==void 0&&m.has(J)?I(J):E.protectedKeys[J]=!0}E.prevProp=M,E.prevResolvedValues=k,E.isActive&&(p={...p,...k}),s&&e.blockInitialAnimation&&(j=!1);const K=O&&N;j&&(!K||L)&&h.push(...A.map(J=>{const se={type:v};if(typeof J=="string"&&s&&!K&&e.manuallyAnimateOnMount&&e.parent){const{parent:Ce}=e,De=qt(Ce,J);if(Ce.enteringChildren&&De){const{delayChildren:$e}=De.transition||{};se.delay=Ba(Ce.enteringChildren,e,$e)}}return{animation:J,options:se}}))}if(m.size){const T={};if(typeof u.initial!="boolean"){const v=qt(e,Array.isArray(u.initial)?u.initial[0]:u.initial);v&&v.transition&&(T.transition=v.transition)}m.forEach(v=>{const E=e.getBaseTarget(v),M=e.getValue(v);M&&(M.liveStyle=!0),T[v]=E??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=Vi()}}}function dh(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!za(t,e):!1}function Ct(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Vi(){return{animate:Ct(!0),whileInView:Ct(),whileHover:Ct(),whileTap:Ct(),whileDrag:Ct(),whileFocus:Ct(),exit:Ct()}}class mt{constructor(t){this.isMounted=!1,this.node=t}update(){}}class hh extends mt{constructor(t){super(t),t.animationState||(t.animationState=uh(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();hs(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 fh=0;class mh extends mt{constructor(){super(...arguments),this.id=fh++}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 _a={animation:{Feature:hh},exit:{Feature:mh}};function Rn(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function Ln(e){return{point:{x:e.pageX,y:e.pageY}}}const ph=e=>t=>Vr(t)&&e(t,Ln(t));function Cn(e,t,n,s){return Rn(e,t,ph(n),s)}const Xa=1e-4,gh=1-Xa,yh=1+Xa,Wa=.01,xh=0-Wa,bh=0+Wa;function Ae(e){return e.max-e.min}function vh(e,t,n){return Math.abs(e-t)<=n}function Ii(e,t,n,s=.5){e.origin=s,e.originPoint=de(t.min,t.max,e.origin),e.scale=Ae(n)/Ae(t),e.translate=de(n.min,n.max,e.origin)-e.originPoint,(e.scale>=gh&&e.scale<=yh||isNaN(e.scale))&&(e.scale=1),(e.translate>=xh&&e.translate<=bh||isNaN(e.translate))&&(e.translate=0)}function jn(e,t,n,s){Ii(e.x,t.x,n.x,s?s.originX:void 0),Ii(e.y,t.y,n.y,s?s.originY:void 0)}function Oi(e,t,n){e.min=n.min+t.min,e.max=e.min+Ae(t)}function wh(e,t,n){Oi(e.x,t.x,n.x),Oi(e.y,t.y,n.y)}function Li(e,t,n){e.min=t.min-n.min,e.max=e.min+Ae(t)}function Pn(e,t,n){Li(e.x,t.x,n.x),Li(e.y,t.y,n.y)}function Ve(e){return[e("x"),e("y")]}const qa=({current:e})=>e?e.ownerDocument.defaultView:null,$i=(e,t)=>Math.abs(e-t);function Sh(e,t){const n=$i(e.x,t.x),s=$i(e.y,t.y);return Math.sqrt(n**2+s**2)}class Ka{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=Ns(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,S=Sh(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!S)return;const{point:w}=m,{timestamp:T}=be;this.history.push({...w,timestamp:T});const{onStart:v,onMove:E}=this.handlers;p||(v&&v(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),E&&E(this.lastMoveEvent,m)},this.handlePointerMove=(m,p)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=ks(p,this.transformPagePoint),ce.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 v=Ns(m.type==="pointercancel"?this.lastMoveEventInfo:ks(p,this.transformPagePoint),this.history);this.startEvent&&S&&S(m,v),w&&w(m,v)},!Vr(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=i,this.contextWindow=r||window;const a=Ln(t),l=ks(a,this.transformPagePoint),{point:u}=l,{timestamp:d}=be;this.history=[{...u,timestamp:d}];const{onSessionStart:h}=n;h&&h(t,Ns(l,this.history)),this.removeListeners=Vn(Cn(this.contextWindow,"pointermove",this.handlePointerMove),Cn(this.contextWindow,"pointerup",this.handlePointerUp),Cn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),ht(this.updatePoint)}}function ks(e,t){return t?{point:t(e.point)}:e}function Fi(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ns({point:e},t){return{point:e,delta:Fi(e,Ga(t)),offset:Fi(e,Th(t)),velocity:Ch(t,.1)}}function Th(e){return e[0]}function Ga(e){return e[e.length-1]}function Ch(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Ga(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>qe(t)));)n--;if(!s)return{x:0,y:0};const o=Oe(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 jh(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?de(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?de(n,e,s.max):Math.min(e,n)),e}function Bi(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 Ph(e,{top:t,left:n,bottom:s,right:r}){return{x:Bi(e.x,n,r),y:Bi(e.y,t,s)}}function zi(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 Ah(e,t){return{x:zi(e.x,t.x),y:zi(e.y,t.y)}}function Eh(e,t){let n=.5;const s=Ae(e),r=Ae(t);return r>s?n=En(t.min,t.max-s,e.min):s>r&&(n=En(e.min,e.max-r,t.min)),nt(0,1,n)}function Mh(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 ar=.35;function kh(e=ar){return e===!1?e=0:e===!0&&(e=ar),{x:Ui(e,"left","right"),y:Ui(e,"top","bottom")}}function Ui(e,t,n){return{min:_i(e,t),max:_i(e,n)}}function _i(e,t){return typeof e=="number"?e:e[t]||0}const Nh=new WeakMap;class Dh{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=me(),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(Ln(h).point)},i=(h,m)=>{const{drag:p,dragPropagation:S,onDragStart:w}=this.getProps();if(p&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Fu(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),Ve(v=>{let E=this.getAxisMotionValue(v).get()||0;if(Qe.test(E)){const{projection:M}=this.visualElement;if(M&&M.layout){const F=M.layout.layoutBox[v];F&&(E=Ae(F)*(parseFloat(E)/100))}}this.originPoint[v]=E}),w&&ce.postRender(()=>w(h,m)),ir(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:v}=m;if(S&&this.currentDirection===null){this.currentDirection=Rh(v),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",m.point,v),this.updateAxis("y",m.point,v),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=()=>Ve(h=>this.getAnimationState(h)==="paused"&&this.getAxisMotionValue(h).animation?.play()),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Ka(t,{onSessionStart:o,onStart:i,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:qa(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&&ce.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||!Yn(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(i=jh(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&&zt(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=Ph(s.layoutBox,t):this.constraints=!1,this.elastic=kh(n),r!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&Ve(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Mh(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!zt(t))return!1;const s=t.current;st(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=Od(s,r.root,this.visualElement.getTransformPagePoint());let i=Ah(r.layout.layoutBox,o);if(n){const a=n(Rd(i));this.hasMutatedConstraints=!!a,a&&(i=Ma(a))}return i}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=Ve(d=>{if(!Yn(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 ir(this.visualElement,t),s.start(Wr(t,s,0,n,this.visualElement,!1))}stopAnimation(){Ve(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Ve(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){Ve(n=>{const{drag:s}=this.getProps();if(!Yn(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]-de(i,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!zt(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Ve(i=>{const a=this.getAxisMotionValue(i);if(a&&this.constraints!==!1){const l=a.get();r[i]=Eh({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(),Ve(i=>{if(!Yn(i,t,null))return;const a=this.getAxisMotionValue(i),{min:l,max:u}=this.constraints[i];a.set(de(l,u,r[i]))})}addListeners(){if(!this.visualElement.current)return;Nh.set(this.visualElement,this);const t=this.visualElement.current,n=Cn(t,"pointerdown",l=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();zt(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()),ce.read(s);const i=Rn(window,"resize",()=>this.scalePositionWithinConstraints()),a=r.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(Ve(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=ar,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:o,dragElastic:i,dragMomentum:a}}}function Yn(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Rh(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Vh extends mt{constructor(t){super(t),this.removeGroupControls=Le,this.removeListeners=Le,this.controls=new Dh(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Le}unmount(){this.removeGroupControls(),this.removeListeners()}}const Xi=e=>(t,n)=>{e&&ce.postRender(()=>e(t,n))};class Ih extends mt{constructor(){super(...arguments),this.removePointerDownListener=Le}onPointerDown(t){this.session=new Ka(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:qa(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:Xi(t),onStart:Xi(n),onMove:s,onEnd:(o,i)=>{delete this.session,r&&ce.postRender(()=>r(o,i))}}}mount(){this.removePointerDownListener=Cn(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 ss={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Wi(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const bn={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(z.test(e))e=parseFloat(e);else return e;const n=Wi(e,t.target.x),s=Wi(e,t.target.y);return`${n}% ${s}%`}},Oh={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,r=ft.parse(e);if(r.length>5)return s;const o=ft.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=de(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 Ds=!1;class Lh extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:o}=t;ad($h),o&&(n.group&&n.group.add(o),s&&s.register&&r&&s.register(o),Ds&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),ss.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:r,isPresent:o}=this.props,{projection:i}=s;return i&&(i.isPresent=o,Ds=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==o?i.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?i.promote():i.relegate()||ce.postRender(()=>{const a=i.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Rr.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;Ds=!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 Ya(e){const[t,n]=ga(),s=f.useContext(dr);return c.jsx(Lh,{...e,layoutGroup:s,switchLayoutGroup:f.useContext(Aa),isPresent:t,safeToRemove:n})}const $h={borderRadius:{...bn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:bn,borderTopRightRadius:bn,borderBottomLeftRadius:bn,borderBottomRightRadius:bn,boxShadow:Oh};function Fh(e,t,n){const s=Se(e)?e:Kt(e);return s.start(Wr("",s,t,n)),s.animation}const Bh=(e,t)=>e.depth-t.depth;class zh{constructor(){this.children=[],this.isDirty=!1}add(t){mr(this.children,t),this.isDirty=!0}remove(t){pr(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Bh),this.isDirty=!1,this.children.forEach(t)}}function Uh(e,t){const n=Me.now(),s=({timestamp:r})=>{const o=r-n;o>=t&&(ht(s),e(o-t))};return ce.setup(s,!0),()=>ht(s)}const Ha=["TopLeft","TopRight","BottomLeft","BottomRight"],_h=Ha.length,qi=e=>typeof e=="string"?parseFloat(e):e,Ki=e=>typeof e=="number"||z.test(e);function Xh(e,t,n,s,r,o){r?(e.opacity=de(0,n.opacity??1,Wh(s)),e.opacityExit=de(t.opacity??1,0,qh(s))):o&&(e.opacity=de(t.opacity??1,n.opacity??1,s));for(let i=0;i<_h;i++){const a=`border${Ha[i]}Radius`;let l=Gi(t,a),u=Gi(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Ki(l)===Ki(u)?(e[a]=Math.max(de(qi(l),qi(u),s),0),(Qe.test(u)||Qe.test(l))&&(e[a]+="%")):e[a]=u}(t.rotate||n.rotate)&&(e.rotate=de(t.rotate||0,n.rotate||0,s))}function Gi(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const Wh=Ja(0,.5,Oo),qh=Ja(.5,.95,Le);function Ja(e,t,n){return s=>s<e?0:s>t?1:n(En(e,t,s))}function Yi(e,t){e.min=t.min,e.max=t.max}function Re(e,t){Yi(e.x,t.x),Yi(e.y,t.y)}function Hi(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function Ji(e,t,n,s,r){return e-=t,e=ls(e,1/n,s),r!==void 0&&(e=ls(e,1/r,s)),e}function Kh(e,t=0,n=1,s=.5,r,o=e,i=e){if(Qe.test(t)&&(t=parseFloat(t),t=de(i.min,i.max,t/100)-i.min),typeof t!="number")return;let a=de(o.min,o.max,s);e===o&&(a-=t),e.min=Ji(e.min,t,n,a,r),e.max=Ji(e.max,t,n,a,r)}function Zi(e,t,[n,s,r],o,i){Kh(e,t[n],t[s],t[r],t.scale,o,i)}const Gh=["x","scaleX","originX"],Yh=["y","scaleY","originY"];function Qi(e,t,n,s){Zi(e.x,t,Gh,n?n.x:void 0,s?s.x:void 0),Zi(e.y,t,Yh,n?n.y:void 0,s?s.y:void 0)}function eo(e){return e.translate===0&&e.scale===1}function Za(e){return eo(e.x)&&eo(e.y)}function to(e,t){return e.min===t.min&&e.max===t.max}function Hh(e,t){return to(e.x,t.x)&&to(e.y,t.y)}function no(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Qa(e,t){return no(e.x,t.x)&&no(e.y,t.y)}function so(e){return Ae(e.x)/Ae(e.y)}function ro(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Jh{constructor(){this.members=[]}add(t){mr(this.members,t),t.scheduleRender()}remove(t){if(pr(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 Zh(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 Rs=["","X","Y","Z"],Qh=1e3;let ef=0;function Vs(e,t,n,s){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),s&&(s[e]=0))}function el(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=$a(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ce,!(r||o))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&el(s)}function tl({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:r}){return class{constructor(i={},a=t?.()){this.id=ef++,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(sf),this.nodes.forEach(lf),this.nodes.forEach(cf),this.nodes.forEach(rf)},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 zh)}addEventListener(i,a){return this.eventHandlers.has(i)||this.eventHandlers.set(i,new yr),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=pa(i)&&!Wu(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;ce.read(()=>{h=window.innerWidth}),e(i,()=>{const p=window.innerWidth;p!==h&&(h=p,this.root.updateBlockedByResize=!0,d&&d(),d=Uh(m,250),ss.hasAnimatedSinceResize&&(ss.hasAnimatedSinceResize=!1,this.nodes.forEach(ao)))})}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()||mf,{onLayoutAnimationStart:w,onLayoutAnimationComplete:T}=u.getProps(),v=!this.targetLayout||!Qa(this.targetLayout,p),E=!h&&m;if(this.options.layoutRoot||this.resumeFrom||E||h&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const M={...Nr(S,"layout"),onPlay:w,onComplete:T};(u.shouldReduceMotion||this.options.layoutRoot)&&(M.delay=0,M.type=!1),this.startAnimation(M),this.setAnimationOrigin(d,E)}else h||ao(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(),ht(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(uf),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&&el(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(io);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(oo);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(af),this.nodes.forEach(tf),this.nodes.forEach(nf)):this.nodes.forEach(oo),this.clearAllSnapshots();const a=Me.now();be.delta=nt(0,1e3/60,a-be.timestamp),be.timestamp=a,be.isProcessing=!0,Ss.update.process(be),Ss.preRender.process(be),Ss.render.process(be),be.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Rr.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(of),this.sharedNodes.forEach(df)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ce.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ce.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ae(this.snapshot.measuredBox.x)&&!Ae(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=me(),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&&!Za(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;i&&this.instance&&(a||Pt(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)),pf(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:i}=this.options;if(!i)return me();const a=i.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(gf))){const{scroll:u}=this.root;u&&(Ut(a.x,u.offset.x),Ut(a.y,u.offset.y))}return a}removeElementScroll(i){const a=me();if(Re(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&&Re(a,i),Ut(a.x,d.offset.x),Ut(a.y,d.offset.y))}return a}applyTransform(i,a=!1){const l=me();Re(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&&_t(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),Pt(d.latestValues)&&_t(l,d.latestValues)}return Pt(this.latestValues)&&_t(l,this.latestValues),l}removeTransform(i){const a=me();Re(a,i);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Pt(u.latestValues))continue;tr(u.latestValues)&&u.updateSnapshot();const d=me(),h=u.measurePageBox();Re(d,h),Qi(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return Pt(this.latestValues)&&Qi(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!==be.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=be.timestamp,!this.targetDelta&&!this.relativeTarget){const m=this.getClosestProjectingParent();m&&m.layout&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=me(),this.relativeTargetOrigin=me(),Pn(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),Re(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=me(),this.targetWithTransforms=me()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),wh(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Re(this.target,this.layout.layoutBox),Na(this.target,this.targetDelta)):Re(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=me(),this.relativeTargetOrigin=me(),Pn(this.relativeTargetOrigin,this.target,m.target),Re(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||tr(this.parent.latestValues)||ka(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===be.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;Re(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,m=this.treeScale.y;Id(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=me());const{target:p}=i;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Hi(this.prevProjectionDelta.x,this.projectionDelta.x),Hi(this.prevProjectionDelta.y,this.projectionDelta.y)),jn(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==m||!ro(this.projectionDelta.x,this.prevProjectionDelta.x)||!ro(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=Xt(),this.projectionDelta=Xt(),this.projectionDeltaWithTransform=Xt()}setAnimationOrigin(i,a=!1){const l=this.snapshot,u=l?l.latestValues:{},d={...this.latestValues},h=Xt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=me(),p=l?l.source:void 0,S=this.layout?this.layout.source:void 0,w=p!==S,T=this.getStack(),v=!T||T.members.length<=1,E=!!(w&&!v&&this.options.crossfade===!0&&!this.path.some(ff));this.animationProgress=0;let M;this.mixTargetDelta=F=>{const D=F/1e3;lo(h.x,i.x,D),lo(h.y,i.y,D),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Pn(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),hf(this.relativeTarget,this.relativeTargetOrigin,m,D),M&&Hh(this.relativeTarget,M)&&(this.isProjectionDirty=!1),M||(M=me()),Re(M,this.relativeTarget)),w&&(this.animationValues=d,Xh(d,u,this.latestValues,D,E,v)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=D},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(i){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(ht(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ce.update(()=>{ss.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Kt(0)),this.currentAnimation=Fh(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(Qh),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&&nl(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||me();const h=Ae(this.layout.layoutBox.x);l.x.min=i.target.x.min,l.x.max=l.x.min+h;const m=Ae(this.layout.layoutBox.y);l.y.min=i.target.y.min,l.y.max=l.y.min+m}Re(a,l),_t(a,d),jn(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(i,a){this.sharedNodes.has(i)||this.sharedNodes.set(i,new Jh),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&&Vs("z",i,u,this.animationValues);for(let d=0;d<Rs.length;d++)Vs(`rotate${Rs[d]}`,i,u,this.animationValues),Vs(`skew${Rs[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=ts(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=ts(a?.pointerEvents)||""),this.hasProjected&&!Pt(this.latestValues)&&(i.transform=l?l({},""):"none",this.hasProjected=!1);return}i.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let h=Zh(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 Dn){if(d[S]===void 0)continue;const{correct:w,applyTo:T,isCSSVariable:v}=Dn[S],E=h==="none"?d[S]:w(d[S],u);if(T){const M=T.length;for(let F=0;F<M;F++)i[T[F]]=E}else v?this.options.visualElement.renderState.vars[S]=E:i[S]=E}this.options.layoutId&&(i.pointerEvents=u===this?ts(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(i=>i.currentAnimation?.stop()),this.root.nodes.forEach(io),this.root.sharedNodes.clear()}}}function tf(e){e.updateLayout()}function nf(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"?Ve(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Ae(h);h.min=n[d].min,h.max=h.min+m}):nl(r,t.layoutBox,n)&&Ve(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Ae(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=Xt();jn(i,n,t.layoutBox);const a=Xt();o?jn(a,e.applyTransform(s,!0),t.measuredBox):jn(a,n,t.layoutBox);const l=!Za(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=me();Pn(p,t.layoutBox,h.layoutBox);const S=me();Pn(S,n,m.layoutBox),Qa(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 sf(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 rf(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function of(e){e.clearSnapshot()}function io(e){e.clearMeasurements()}function oo(e){e.isLayoutDirty=!1}function af(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function ao(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function lf(e){e.resolveTargetDelta()}function cf(e){e.calcProjection()}function uf(e){e.resetSkewAndRotation()}function df(e){e.removeLeadSnapshot()}function lo(e,t,n){e.translate=de(t.translate,0,n),e.scale=de(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function co(e,t,n,s){e.min=de(t.min,n.min,s),e.max=de(t.max,n.max,s)}function hf(e,t,n,s){co(e.x,t.x,n.x,s),co(e.y,t.y,n.y,s)}function ff(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const mf={duration:.45,ease:[.4,0,.1,1]},uo=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),ho=uo("applewebkit/")&&!uo("chrome/")?Math.round:Le;function fo(e){e.min=ho(e.min),e.max=ho(e.max)}function pf(e){fo(e.x),fo(e.y)}function nl(e,t,n){return e==="position"||e==="preserve-aspect"&&!vh(so(t),so(n),.2)}function gf(e){return e!==e.root&&e.scroll?.wasRoot}const yf=tl({attachResizeListener:(e,t)=>Rn(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Is={current:void 0},sl=tl({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Is.current){const e=new yf({});e.mount(window),e.setOptions({layoutScroll:!0}),Is.current=e}return Is.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),xf={pan:{Feature:Ih},drag:{Feature:Vh,ProjectionNode:sl,MeasureLayout:Ya}};function mo(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&&ce.postRender(()=>o(t,Ln(t)))}class bf extends mt{mount(){const{current:t}=this.node;t&&(this.unmount=Bu(t,(n,s)=>(mo(this.node,s,"Start"),r=>mo(this.node,r,"End"))))}unmount(){}}class vf extends mt{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=Vn(Rn(this.node.current,"focus",()=>this.onFocus()),Rn(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function po(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&&ce.postRender(()=>o(t,Ln(t)))}class wf extends mt{mount(){const{current:t}=this.node;t&&(this.unmount=Xu(t,(n,s)=>(po(this.node,s,"Start"),(r,{success:o})=>po(this.node,r,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const lr=new WeakMap,Os=new WeakMap,Sf=e=>{const t=lr.get(e.target);t&&t(e)},Tf=e=>{e.forEach(Sf)};function Cf({root:e,...t}){const n=e||document;Os.has(n)||Os.set(n,{});const s=Os.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(Tf,{root:e,...t})),s[r]}function jf(e,t,n){const s=Cf(t);return lr.set(e,n),s.observe(e),()=>{lr.delete(e),s.unobserve(e)}}const Pf={some:0,all:1};class Af extends mt{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:Pf[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 jf(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(Ef(t,n))&&this.startObserver()}unmount(){}}function Ef({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const rl={inView:{Feature:Af},tap:{Feature:wf},focus:{Feature:vf},hover:{Feature:bf}},Mf={layout:{ProjectionNode:sl,MeasureLayout:Ya}},kf={..._a,...rl,...xf,...Mf},Nf=Dd(kf,La),Df={renderer:La,..._a,...rl};function qr(e,t){return ns(e,t)}const Rf=qr("button"),Hn=qr("div"),Vf=qr("p");function If({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(Te,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[c.jsx(te.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),c.jsx(Te,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:r,children:c.jsx(te.X,{className:"h-3 w-3"})})]})]})})}function Of({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(te.ChevronDown,{className:"h-3 w-3"}):c.jsx(te.ChevronRight,{className:"h-3 w-3"})}),n?c.jsx(te.X,{className:"h-3 w-3"}):s?c.jsx(te.Zap,{className:"h-3 w-3"}):c.jsx(te.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 Lf({...e}){return c.jsx(cr.Root,{"data-slot":"collapsible",...e})}function $f({...e}){return c.jsx(cr.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function Ff({...e}){return c.jsx(cr.CollapsibleContent,{"data-slot":"collapsible-content",...e})}const Bf=f.lazy(()=>import("streamdown").then(e=>({default:e.Streamdown}))),Kr=f.memo(({className:e,...t})=>typeof window>"u"?null:c.jsx(f.Suspense,{fallback:null,children:c.jsx(Bf,{className:ne("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t})}),(e,t)=>e.children===t.children);Kr.displayName="Response";const zf=Object.freeze(Object.defineProperty({__proto__:null,Response:Kr},Symbol.toStringTag,{value:"Module"})),Uf=({children:e,as:t="p",className:n,duration:s=2,spread:r=2})=>{const o=Nf.create(t),i=f.useMemo(()=>(e?.length??0)*r,[e,r]);return c.jsx(o,{animate:{backgroundPosition:"0% center"},className:ne("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})},_f=f.memo(Uf),il=f.createContext(null),Xf=()=>{const e=f.useContext(il);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Wf=1e3,qf=1e3,ol=f.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:s=!0,onOpenChange:r,duration:o,children:i,...a})=>{const[l,u]=Zr.useControllableState({prop:n,defaultProp:s,onChange:r}),[d,h]=Zr.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)/qf)),w(null))},[t,S,h]),f.useEffect(()=>{if(s&&!t&&l&&!m){const v=setTimeout(()=>{u(!1),p(!0)},Wf);return()=>clearTimeout(v)}},[t,l,s,u,m]);const T=v=>{u(v)};return c.jsx(il.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:c.jsx(Lf,{className:ne("not-prose mb-4",e),onOpenChange:T,open:l,...a,children:i})})}),Kf=(e,t)=>e||t===0?c.jsx(_f,{duration:1,children:"Thinking..."}):t===void 0?c.jsx("p",{children:"Thought for a few seconds"}):c.jsxs("p",{children:["Thought for ",t," seconds"]}),al=f.memo(({className:e,children:t,...n})=>{const{isStreaming:s,isOpen:r,duration:o}=Xf();return c.jsx($f,{className:ne("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(te.BrainIcon,{className:"size-4"}),Kf(s,o),c.jsx(te.ChevronDownIcon,{className:ne("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),ll=f.memo(({className:e,children:t,...n})=>c.jsx(Ff,{className:ne("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(Kr,{className:"grid gap-2",children:t})}));ol.displayName="Reasoning";al.displayName="ReasoningTrigger";ll.displayName="ReasoningContent";function go(e){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=16`}function Gf({sources:e,citationNumber:t,className:n}){const s=e.find(o=>o.number===t);if(!s)return null;const r=go(s.domain);return c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsxs("button",{className:ne("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(ut,{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:ne("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:go(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 Yf({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 v,E=!1;const M=new WeakSet,F=()=>{if(!u.current||E)return;E=!0;const O=u.current,N=/\[(\d+)\]/g,j=document.createTreeWalker(O,NodeFilter.SHOW_TEXT,null),L=[];let A;for(;A=j.nextNode();)if(A.nodeType===Node.TEXT_NODE&&!M.has(A)){const B=A,V=B.textContent||"";let I=B.parentElement,K=!1;for(;I&&I!==O;){if(I.tagName==="A"||I.tagName==="CODE"||I.tagName==="PRE"){K=!0;break}I=I.parentElement}if(!K){const J=Array.from(V.matchAll(N)).filter(se=>{if(!se[1])return!1;const Ce=parseInt(se[1],10);return n.has(Ce)});J.length>0&&L.push({node:B,matches:J})}}if(L.length===0){E=!1;return}const k=[];L.forEach(({node:B,matches:V})=>{M.add(B);const I=B.textContent||"",K=document.createDocumentFragment();let Z=0;V.forEach(J=>{if(!J[1])return;J.index!==void 0&&J.index>Z&&K.appendChild(document.createTextNode(I.slice(Z,J.index)));const se=document.createElement("span");se.className="inline-flex items-center citation-button-container";const Ce=parseInt(J[1],10);se.setAttribute("data-citation",J[1]),K.appendChild(se),k.push({element:se,citationNum:Ce}),Z=(J.index||0)+J[0].length}),Z<I.length&&K.appendChild(document.createTextNode(I.slice(Z))),B.parentNode&&B.parentNode.replaceChild(K,B)}),k.length>0&&h(B=>{const V=new Set(B.map(Z=>Z.element)),I=B.filter(Z=>Z.element.isConnected),K=k.filter(Z=>!V.has(Z.element));return[...I,...K]}),E=!1},D=new MutationObserver(()=>{clearTimeout(v),v=setTimeout(F,100)});return D.observe(T,{childList:!0,subtree:!0,characterData:!0}),v=setTimeout(F,200),()=>{D.disconnect(),clearTimeout(v)}},[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,v)=>{const E=T.title||T.baseUrl,M=S(T.url),F=p(M);return c.jsxs("a",{href:T.url,target:"_blank",rel:"noopener noreferrer",className:ne("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:F,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:D=>{const O=D.target;O.style.display="none"}}),c.jsx("span",{className:"leading-none",children:E})]},`group-${v}`)}):Array.from(n.entries()).sort(([T],[v])=>T-v).map(([T,v])=>{const E=S(v),M=p(E);return c.jsxs("a",{href:v,target:"_blank",rel:"noopener noreferrer",className:ne("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:M,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:F=>{const D=F.target;D.style.display="none"}}),c.jsx("span",{className:"leading-none",children:v})]},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:v},E)=>{if(!t.find(D=>D.number===v))return null;const F=Array.from(new Map(t.map(D=>{const O=D.url.replace(/\/+$/,""),N=s?.find(j=>j.url.replace(/\/+$/,"")===O);return[O,{number:D.number,url:D.url,domain:S(D.url),title:N?.title}]})).values());return Pl.createPortal(c.jsx(Gf,{sources:F,citationNumber:v},`citation-${v}-${T}`),T,`citation-${v}-${E}`)}),w]})}function Qt({...e}){return c.jsx(Nt.Root,{"data-slot":"dialog",...e})}function Hf({...e}){return c.jsx(Nt.Portal,{"data-slot":"dialog-portal",...e})}function Jf({className:e,...t}){return c.jsx(Nt.Overlay,{"data-slot":"dialog-overlay",className:ne("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 en({className:e,children:t,showCloseButton:n=!0,...s}){return c.jsxs(Hf,{"data-slot":"dialog-portal",children:[c.jsx(Jf,{}),c.jsxs(Nt.Content,{"data-slot":"dialog-content",className:ne("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(Nt.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(te.XIcon,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function tn({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-header",className:ne("flex flex-col gap-2 text-center sm:text-left",e),...t})}function nn({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-footer",className:ne("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function sn({className:e,...t}){return c.jsx(Nt.Title,{"data-slot":"dialog-title",className:ne("text-lg leading-none font-semibold",e),...t})}function rn({className:e,...t}){return c.jsx(Nt.Description,{"data-slot":"dialog-description",className:ne("text-muted-foreground text-sm",e),...t})}function on({className:e,type:t,...n}){return c.jsx("input",{type:t,"data-slot":"input",className:ne("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 Zf({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(Qt,{open:e,children:c.jsx(en,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(tn,{children:[c.jsx(sn,{children:t}),c.jsx(rn,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsxs("div",{className:"relative",children:[c.jsx(on,{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(te.EyeOff,{className:"h-4 w-4"}):c.jsx(te.Eye,{className:"h-4 w-4"})})]})}),c.jsxs(nn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:m,disabled:u,children:"Cancel"}),c.jsx(Te,{type:"submit",disabled:!o.trim()||u,children:u?"Submitting...":"Submit"})]})]})})})}function Qf({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(Qt,{open:e,children:c.jsx(en,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:p,children:[c.jsxs(tn,{children:[c.jsxs(sn,{className:"flex items-center gap-2",children:[c.jsx(te.Mail,{className:"h-5 w-5"}),t]}),c.jsx(rn,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(on,{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(nn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:S,disabled:u,children:"Cancel"}),c.jsx(Te,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function em({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 v=T.replace(/\D/g,"");return v.length<=3?v:v.length<=6?`(${v.slice(0,3)}) ${v.slice(3)}`:`(${v.slice(0,3)}) ${v.slice(3,6)}-${v.slice(6,10)}`},m=T=>T.replace(/\D/g,"").length===10,p=T=>{const v=h(T);i(v),v.trim()?l(m(v)):l(!0)},S=async T=>{if(T.preventDefault(),!o.trim()||!m(o)){l(!1);return}d(!0);try{const v=o.replace(/\D/g,"");r(v)}finally{d(!1)}},w=()=>{i(""),l(!0),r(null)};return c.jsx(Qt,{open:e,children:c.jsx(en,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:S,children:[c.jsxs(tn,{children:[c.jsxs(sn,{className:"flex items-center gap-2",children:[c.jsx(te.Phone,{className:"h-5 w-5"}),t]}),c.jsx(rn,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(on,{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(nn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:w,disabled:u,children:"Cancel"}),c.jsx(Te,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function tm({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(Qt,{open:e,children:c.jsx(en,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(tn,{children:[c.jsxs(sn,{className:"flex items-center gap-2",children:[c.jsx(te.Shield,{className:"h-5 w-5"}),t]}),c.jsx(rn,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(on,{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(nn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:m,disabled:l,children:"Cancel"}),c.jsx(Te,{type:"submit",disabled:i.length!==r||l,children:l?"Submitting...":"Submit"})]})]})})})}function Ls({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(Qt,{open:e,children:c.jsx(en,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:d,children:[c.jsxs(tn,{children:[c.jsxs(sn,{className:"flex items-center gap-2",children:[c.jsx(te.Lock,{className:"h-5 w-5"}),t]}),c.jsx(rn,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsx(on,{type:r,value:i,onChange:m=>a(m.target.value),placeholder:s,autoFocus:!0,disabled:l})}),c.jsxs(nn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:h,disabled:l,children:"Cancel"}),c.jsx(Te,{type:"submit",disabled:!i.trim()||l,children:l?"Submitting...":"Submit"})]})]})})})}function nm({isOpen:e,title:t,description:n,fields:s,onComplete:r,submitText:o="Submit",cancelText:i="Cancel"}){const[a,l]=f.useState(()=>{const A={};return s.forEach(k=>{A[k.name]=k.value||""}),A}),[u,d]=f.useState({}),[h,m]=f.useState({}),[p,S]=f.useState(!1),w=A=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(A)?null:"Please enter a valid email address",T=A=>A.replace(/\D/g,"").length===10?null:"Please enter a valid 10-digit phone number",v=(A,k=4)=>A.length===k?null:`PIN must be ${k} digits`,E=A=>{const k=A.replace(/\D/g,"");return k.length<=3?k:k.length<=6?`(${k.slice(0,3)}) ${k.slice(3)}`:`(${k.slice(0,3)}) ${k.slice(3,6)}-${k.slice(6,10)}`},M=(A,k,B)=>{let V=k,I=null;switch(B.type){case"phone":V=E(k),V.trim()&&(I=T(V));break;case"email":k.trim()&&(I=w(k));break;case"pin":V=k.replace(/\D/g,"").slice(0,6),V.trim()&&(I=v(V));break}!I&&B.validation&&V.trim()&&(I=B.validation(V)),l(K=>({...K,[A]:V})),d(K=>({...K,[A]:I||""}))},F=()=>{const A={};let k=!0;return s.forEach(B=>{const V=a[B.name]||"";let I=null;if(B.required&&!V.trim())I=`${B.label} is required`;else if(V.trim()){switch(B.type){case"email":I=w(V);break;case"phone":I=T(V);break;case"pin":I=v(V);break}!I&&B.validation&&(I=B.validation(V))}I&&(A[B.name]=I,k=!1)}),d(A),k},D=async A=>{if(A.preventDefault(),!!F()){S(!0);try{const k={};s.forEach(B=>{const V=a[B.name]?.trim();V&&(B.type==="phone"?k[B.name]=V.replace(/\D/g,""):k[B.name]=V)}),r(k)}finally{S(!1)}}},O=()=>{l({}),d({}),m({}),r(null)},N=A=>{m(k=>({...k,[A]:!k[A]}))},j=A=>{switch(A.type){case"password":return h[A.name]?"text":"password";case"email":return"email";case"phone":return"tel";case"pin":case"ssn":return"password";default:return"text"}},L=A=>{if(A.placeholder)return A.placeholder;switch(A.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 ${A.label.toLowerCase()}...`}};return c.jsx(Qt,{open:e,children:c.jsx(en,{showCloseButton:!1,className:"max-w-md",children:c.jsxs("form",{onSubmit:D,children:[c.jsxs(tn,{children:[c.jsx(sn,{children:t}),n&&c.jsx(rn,{children:n})]}),c.jsx("div",{className:"py-4 space-y-4",children:s.map(A=>c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm font-medium mb-1",children:[A.label,A.required&&c.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),c.jsxs("div",{className:"relative",children:[c.jsx(on,{type:j(A),value:a[A.name]||"",onChange:k=>M(A.name,k.target.value,A),placeholder:L(A),className:u[A.name]?"border-red-500":"",disabled:p,autoFocus:A===s[0],maxLength:A.type==="pin"?6:A.type==="phone"?14:void 0}),A.type==="password"&&c.jsx("button",{type:"button",onClick:()=>N(A.name),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:p,children:h[A.name]?c.jsx(te.EyeOff,{className:"h-4 w-4"}):c.jsx(te.Eye,{className:"h-4 w-4"})})]}),u[A.name]&&c.jsxs("div",{className:"flex items-center gap-1 mt-1 text-sm text-red-500",children:[c.jsx(te.AlertCircle,{className:"h-3 w-3"}),u[A.name]]})]},A.name))}),c.jsxs(nn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:O,disabled:p,children:i}),c.jsx(Te,{type:"submit",disabled:p,children:p?"Submitting...":o})]})]})})})}const cl=f.createContext(void 0);function ul(){const e=f.useContext(cl);if(!e)throw new Error("useSecureModal must be used within a SecureModalProvider");return e}function dl({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(nm,{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(Zf,{...p});case"email":return c.jsx(Qf,{...p});case"phone":return c.jsx(em,{...p});case"pin":return c.jsx(tm,{...p});case"ssn":return c.jsx(Ls,{...p,title:t.title||"SSN Required",placeholder:t.placeholder||"XXX-XX-XXXX"});case"creditCard":return c.jsx(Ls,{...p,title:t.title||"Credit Card Required",placeholder:t.placeholder||"XXXX XXXX XXXX XXXX",type:"text"});case"text":default:return c.jsx(Ls,{...p})}},m=f.useMemo(()=>({showSecureModal:a,showSecureForm:l}),[a,l]);return c.jsxs(cl.Provider,{value:m,children:[e,h()]})}function sm(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 rm(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 yo(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 j=s[1],L=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let A;for(;(A=L.exec(j))!==null;)if(A[1]&&A[2]){const k=parseInt(A[1],10),B=A[2].replace(/[.,;:!?]+$/,""),V=B.replace(/\/+$/,"");if(a.has(V)||a.set(V,B),i.has(V)||i.set(V,[]),i.get(V).push(k),!l.has(V))l.set(V,k);else{const I=l.get(V);k<I&&l.set(V,k)}}for(const[k,B]of i.entries()){const V=l.get(k);for(const I of B)I!==V&&u.set(I,V)}for(const[k,B]of l.entries()){const V=a.get(k)||k;r.set(B,V),o.push({number:B,url:V})}}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(j=>{if(j.type==="code")return j.content;let L=j.content;return L=L.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(k,B,V)=>{const I=parseInt(B,10),K=V.replace(/\/+$/,""),Z=u.get(I)||I;return l.has(K)||(l.set(K,Z),r.has(Z)||(r.set(Z,V),o.push({number:Z,url:V}))),`[${Z}]`}),L=L.replace(/\[(\d+)\]/g,(k,B)=>{const V=parseInt(B,10);return`[${u.get(V)||V}]`}),L}),v=[];for(const[j,L]of l.entries()){const A=a.get(j)||j,{baseUrl:k,anchor:B}=sm(A),V=rm(A);v.push({url:A,baseUrl:k,numbers:[L],anchor:B,title:V})}v.sort((j,L)=>(j.numbers[0]||0)-(L.numbers[0]||0));const E=new Map;let M=1;for(const j of v){const L=j.numbers[0];E.set(L,M),j.numbers=[M],M++}const F=new Map;for(const[j,L]of r.entries()){const A=E.get(j);A&&F.set(A,L)}const D=o.map(j=>{const L=E.get(j.number);return L?{number:L,url:j.url}:j}).filter(j=>E.has(j.number)),O=Array.from(E.entries()).sort((j,L)=>L[0]-j[0]);let N=T.join("");for(const[j,L]of O){const A=new RegExp(`\\[${j}\\](?!\\d)`,"g");N=N.replace(A,`[${L}]`)}return{processedText:N,citations:D.sort((j,L)=>j.number-L.number),citationMap:F,groupedCitations:v,referencesText:d}}function An(e){if(typeof e=="string")try{const t=JSON.parse(e);return An(t)}catch{return e}if(Array.isArray(e))return e.map(An);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=An(s);return t}return e}function $s(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return An(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?An(e):{}}function im({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=[],safeToolNames:m,toolMetadata:p,systemPrompt:S="",agentId:w,agentName:T,tokenEndpoint:v="/api/arcten/token",apiBaseUrl:E="https://api.arcten.com",user:M,state:F,onStateChange:D,allowStateEdits:O=!0,sources:N,ragConfig:j,showCitations:L=!0,sensitiveParams:A,autoDetectSensitive:k=!1}){const{showSecureModal:B}=ul(),V=To({apiBaseUrl:E,tokenEndpoint:v,user:M,tools:d,safeTools:h,toolMetadata:p,sensitiveParams:A,autoDetectSensitive:k,agentId:w,agentName:T,state:F,onStateChange:D,allowStateEdits:O,sources:N,ragConfig:j});f.useMemo(()=>j!==void 0?j:N&&N.length>0?{enabled:!0,organizationId:N[0],autoExecute:!0,filters:void 0}:{enabled:!1},[N,j]);const[I,K]=f.useState(u),[Z,J]=f.useState(i),[se,Ce]=f.useState(600),[De,$e]=f.useState(!1),[q,Dt]=f.useState(!1),[Ee,pt]=f.useState(!1),[je,Fe]=f.useState({x:100,y:100}),[an,oe]=f.useState(!1),[ln,gt]=f.useState({x:0,y:0}),[cn,$n]=f.useState(!1),Be=f.useRef(null),yt=f.useRef(null),[xt,ke]=f.useState(""),[un,ms]=f.useState(null),[Rt,Fn]=f.useState("Thinking..."),[bt,it]=f.useState(new Set),[ps,Bn]=f.useState(""),[Ke,gs]=f.useState([]),zn=f.useRef(new Map),Vt=f.useRef(!1),dn=f.useRef(""),[le,hn]=f.useState(!1),[ze,ve]=f.useState(!1),Ge=f.useMemo(()=>[...d,...h],[d,h]),Ue=f.useMemo(()=>ur(Ge,p),[Ge,p]),It=f.useMemo(()=>{const C=new Map,_=new Map(Ue.map(U=>[U.name,U]));return Ge.forEach(U=>{const H=U[Ie];if(H){const Y=_.get(H);if(Y){C.set(Y.name,U);return}}const G=Ue.find(Y=>Y.name===U.name);G&&C.set(G.name,U)}),C},[Ge,Ue]),vt=f.useMemo(()=>{const C=new Set,_=new Map(Ue.map(U=>[U.name,U]));return h.forEach(U=>{const H=U[Ie];if(H&&_.has(H))C.add(H);else{const G=Ue.find(Y=>Y.name===U.name);G&&C.add(G.name)}}),m&&Array.isArray(m)&&m.forEach(U=>{typeof U=="string"&&C.add(U)}),C},[h,Ue,m]),wt=["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&&K(JSON.parse(C));const _=localStorage.getItem("arcten-sidebar-width");_&&J(parseInt(_));const U=localStorage.getItem("arcten-sidebar-height");U&&Ce(parseInt(U));const H=localStorage.getItem("arcten-sidebar-detached");H&&Dt(JSON.parse(H));const G=localStorage.getItem("arcten-sidebar-position");if(G){const ge=JSON.parse(G),re=50,we=Math.max(re-i,Math.min(ge.x,window.innerWidth-re)),X=Math.max(0,Math.min(ge.y,window.innerHeight-re));Fe({x:we,y:X})}const Y=localStorage.getItem("arcten-sidebar-minimized");Y&&pt(JSON.parse(Y)),$n(!0)}},[]),f.useMemo(()=>M,[M?.id]),f.useEffect(()=>{(async()=>{if(Ge.length===0)return;const _=Ge.map(U=>`${U.name}:${U.toString()}`).join("|");if(_!==dn.current&&!Vt.current){Vt.current=!0,dn.current=_;try{const U=Ge.map(G=>({name:G.name,code:G.toString()})),H=await fetch(`${E}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:U})});if(H.ok){const G=await H.json();G.tools&&G.tools.forEach(Y=>{zn.current.set(Y.name,Y)}),gs(G.tools)}}catch(U){console.error("Failed to fetch tool descriptions:",U)}finally{Vt.current=!1}}})()},[Ge,E]),f.useEffect(()=>{Promise.resolve().then(()=>zf).then(C=>{ms(()=>C.Response)})},[]),f.useEffect(()=>{const C=()=>{Bn(window.location.pathname)};C(),window.addEventListener("popstate",C);const _=setInterval(C,500);return()=>{window.removeEventListener("popstate",C),clearInterval(_)}},[]);const{id:fn,messages:Ne,sendMessage:St,status:ye,error:Un,stop:Ot,addToolOutput:et,setMessages:Gr,clientToken:mn,tokenError:pn,conversations:Ye,isLoadingConversations:ot,loadConversation:Lt,deleteConversation:_e,startNewConversation:He}=V;f.useEffect(()=>{I&&yt.current&&yt.current.focus()},[I,Ne]),f.useEffect(()=>{const C=Ne[Ne.length-1];if(!C||C.role!=="assistant")return;const _=C.parts?.filter(U=>U.type?.startsWith("tool-")&&U.state==="input-available"&&typeof U.toolCallId=="string"&&U.input!==void 0)||[];for(const U of _){const H=U,G=H.type?.replace("tool-","")||"",Y=H.toolCallId;if(vt.has(G)){if(bt.has(Y))continue;it(re=>re.has(Y)?re:new Set(re).add(Y)),(async()=>{try{const re=It.get(G);if(!re){console.warn(`[ArctenAgent] Tool ${G} not found in toolsMap`),et({toolCallId:Y,tool:G,output:`Error: Tool ${G} not found`}),it(Q=>{const Pe=new Set(Q);return Pe.delete(Y),Pe});return}const we=$s(H.input),X=Ue.find(Q=>Q.name===G);let he;if(X&&X.jsonSchema?.properties){const Pe=Object.keys(X.jsonSchema.properties).map(fe=>we[fe]);he=await re(...Pe)}else he=await re(...Object.values(we));et({toolCallId:Y,tool:G,output:he}),it(Q=>{const Pe=new Set(Q);return Pe.delete(Y),Pe})}catch(re){console.error(`[ArctenAgent] Error executing safe tool ${G}:`,re),et({toolCallId:Y,tool:G,output:`Error: ${re instanceof Error?re.message:String(re)}`}),it(we=>{const X=new Set(we);return X.delete(Y),X})}})()}}},[Ne,vt,It,Ue,et,bt]);function _n(){K(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Xn(){K(!1),localStorage.setItem("arcten-sidebar-expanded","false")}f.useEffect(()=>{},[I]),f.useEffect(()=>{Be.current&&Be.current.scrollIntoView({behavior:"smooth"})},[Ne]),f.useEffect(()=>{function C(_){_.key==="Escape"&&(ye==="streaming"||ye==="submitted")&&(_.preventDefault(),Ot())}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[ye,Ot]);function tt(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 Tt(){He(),ve(!1)}function gn(C){if(C.preventDefault(),!xt.trim())return;(ye==="streaming"||ye==="submitted")&&Ot();const _=wt[Math.floor(Math.random()*wt.length)]||"Thinking...";Fn(_),St({text:xt}),ke("")}function Wn(C){const _=C.target.value;ke(_)}f.useEffect(()=>{if(!De)return;function C(U){if(q){const H=U.clientX-je.x,G=U.clientY-je.y;H>=a&&H<=l&&J(H),G>=400&&G<=1e3&&Ce(G)}else{const H=window.innerWidth-U.clientX;H>=a&&H<=l&&J(H)}}function _(){$e(!1),localStorage.setItem("arcten-sidebar-width",Z.toString()),localStorage.setItem("arcten-sidebar-height",se.toString())}return window.addEventListener("mousemove",C),window.addEventListener("mouseup",_),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",_)}},[De,Z,se,q,je,a,l]);function at(C){C.preventDefault(),$e(!0)}function $t(){Dt(!0),pt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function ys(){Dt(!1),pt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function yn(){pt(!Ee),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!Ee))}function Je(C){q&&(oe(!0),gt({x:C.clientX-je.x,y:C.clientY-je.y}))}return f.useEffect(()=>{if(!q)return;function C(){Fe(_=>{const H=window.innerWidth-50,G=window.innerHeight-50,Y=50-Z,ge=0,re=Math.max(Y,Math.min(_.x,H)),we=Math.max(ge,Math.min(_.y,G));if(re!==_.x||we!==_.y){const X={x:re,y:we};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(X)),X}return _})}return window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[q,Z]),f.useEffect(()=>{if(!an)return;function C(U){const H=U.clientX-ln.x,G=U.clientY-ln.y,Y=50,ge=window.innerWidth-Y,re=window.innerHeight-Y,we=Y-Z,X=0,he=Math.max(we,Math.min(H,ge)),Q=Math.max(X,Math.min(G,re));Fe({x:he,y:Q})}function _(){oe(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(je))}return window.addEventListener("mousemove",C),window.addEventListener("mouseup",_),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",_)}},[an,ln,je,Z]),cn?pn?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: ",pn]})}):mn?c.jsx(td,{features:Df,children:c.jsx(Hn,{id:"arcten-sidebar","data-theme":e,"data-layout":t,"data-model":n,initial:q?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:q?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
11
|
+
${q?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
|
|
12
|
+
${I?"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"}
|
|
13
|
+
${q?"border border-border":"border-l border-border"}
|
|
14
|
+
${I?"":"w-[30px]"}
|
|
15
|
+
`,style:I?q?{width:`${Z}px`,height:Ee?"auto":`${se}px`,left:`${je.x}px`,top:`${je.y}px`}:{width:`${Z}px`}:void 0,onClick:I?void 0:_n,children:I?c.jsxs(c.Fragment,{children:[!q&&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:at,children:c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),q&&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(),$e(!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(),oe(!0),gt({x:C.clientX-je.x,y:C.clientY-je.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(),$e(!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 ${q?"cursor-move":""}`,onMouseDown:q?Je:void 0,children:[c.jsx("h2",{className:`text-base font-semibold ${q&&Ee?"cursor-pointer":""}`,onClick:q&&Ee?C=>{C.stopPropagation(),yn()}:void 0,children:r}),c.jsxs("div",{className:"flex items-center gap-1",onClick:C=>C.stopPropagation(),children:[c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(jt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Tt,"aria-label":"New chat",children:c.jsx(te.Plus,{className:"h-4 w-4"})})}),c.jsx(ut,{children:"Start a new conversation"})]}),c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(jt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:q?ys:$t,"aria-label":q?"Dock sidebar":"Float sidebar",children:q?c.jsx(te.Dock,{className:"h-4 w-4"}):c.jsx(te.PictureInPicture2,{className:"h-4 w-4"})})}),c.jsx(ut,{children:q?"Dock to sidebar":"Undock to floating window"})]}),c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(jt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:q?yn:Xn,"aria-label":q?Ee?"Maximize":"Minimize":"Close sidebar",children:q?Ee?c.jsx(te.Maximize2,{className:"h-4 w-4"}):c.jsx(te.Minimize2,{className:"h-4 w-4"}):c.jsx(te.X,{className:"h-4 w-4"})})}),c.jsx(ut,{children:q?Ee?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!Ee&&c.jsxs(c.Fragment,{children:[M&&Ye.length>0&&c.jsxs("div",{className:`border-b border-border ${ze?"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(Te,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{ve(!ze)},children:ze?"Show less":"View all"})]}),c.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${ze?"flex-1 overflow-y-auto":""}`,children:Ye.slice(0,ze?void 0:3).map(C=>c.jsxs("div",{className:"group relative",children:[c.jsxs(Rf,{type:"button",className:ne(jt({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal active:scale-[0.99]"),onClick:()=>{Lt(C.chatId||C._id),ve(!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:tt(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(),_e(C._id)},"aria-label":"Delete conversation",children:c.jsx(te.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:Ne.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?"}),Ke.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:[(le?Ke:Ke.slice(0,10)).map(C=>c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx(ws,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{ke(C.sampleUsage),yt.current?.focus()},children:C.friendlyName})}),c.jsx(ut,{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)),Ke.length>10&&!le&&c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsxs(ws,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>hn(!0),children:["+",Ke.length-10," more"]})}),c.jsx(ut,{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:Ke.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"})]})})]}),le&&Ke.length>10&&c.jsx(ws,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>hn(!1),children:"Show less"})]})})]}):c.jsxs(c.Fragment,{children:[Ne.map(C=>{const U=C.parts.filter(X=>X.type==="text").map(X=>X.text).join("");let H=C.parts;C.role==="assistant"&&C.parts.some(he=>he.timestamp)&&(H=[...C.parts].sort((he,Q)=>{const Pe=he.timestamp||0,fe=Q.timestamp||0;return Pe-fe}));let G=[],Y=new Map,ge=[],re,we=!0;if(C.role==="assistant"){const X=H.filter(fe=>fe.type==="text"&&fe.text),he=[],Q=[];X.forEach(fe=>{const{citations:y,citationMap:g,groupedCitations:x,referencesText:b}=yo(fe.text);G.push(...y),he.push(g),x&&Q.push(...x),b&&(re=b)}),he.forEach(fe=>{fe.forEach((y,g)=>{Y.has(g)||Y.set(g,y)})}),ge=Array.from(new Map(Q.map(fe=>[fe.url,fe])).values()).sort((fe,y)=>(fe.numbers[0]||0)-(y.numbers[0]||0)),we=!(ye==="streaming"&&C.id===Ne.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(Vf,{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:U}):c.jsx("div",{className:"space-y-2",children:H.map((X,he)=>{if(X.type?.startsWith("tool-")){const Q=X.type?.replace("tool-","")||"",Pe=Ue.find(g=>g.name===Q),fe=X.state==="input-available",y=X.state==="output-available";if(fe&&vt.has(Q),fe){if(vt.has(Q))return null;const g=$s(X.input);return c.jsx(Hn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:c.jsx(If,{toolName:Q,description:Pe?.description||"",args:g,onApprove:async()=>{if(bt.has(X.toolCallId))return;it(b=>new Set(b).add(X.toolCallId));const x=It.get(Q);if(x)try{const b=await x(...Object.values(g));et({toolCallId:X.toolCallId,tool:Q,output:b})}catch(b){et({toolCallId:X.toolCallId,tool:Q,output:`Error: ${b}`})}},onDeny:async()=>{bt.has(X.toolCallId)||(it(x=>new Set(x).add(X.toolCallId)),et({toolCallId:X.toolCallId,tool:Q,output:"User denied tool execution"}))}})},`${X.toolCallId}-${he}`)}else if(y){const g=X.output==="User denied tool execution",x=$s(X.input);return c.jsx(Of,{toolName:Q,args:x,isDenied:g,isSafe:vt.has(Q)},`${X.toolCallId}-${he}`)}return null}if(X.type==="text"&&X.text&&un){const{processedText:Q}=yo(X.text),g=!H.slice(he+1).some(x=>x.type==="text"&&x.text)&&we&&Y.size>0;return c.jsx(Yf,{text:Q,citations:G,citationMap:Y,groupedCitations:g?ge:void 0,referencesText:g?re:void 0,ResponseComponent:un,className:"text-sm prose prose-sm dark:prose-invert max-w-none",showCitations:L,showReferences:g},`${C.id}-${he}`)}return X.type==="reasoning"&&X.text?c.jsxs(ol,{className:"w-full",isStreaming:ye==="streaming"&&he===C.parts.length-1&&C.id===Ne.at(-1)?.id,children:[c.jsx(al,{}),c.jsx(ll,{children:X.text})]},`${C.id}-${he}`):null})})})},C.id)}),c.jsx("div",{ref:Be})]})}),Un&&c.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",Un.message]}),c.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[c.jsx(ed,{mode:"wait",children:(ye==="streaming"||ye==="submitted")&&c.jsxs(Hn,{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(Hn,{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:Rt})]})}),c.jsxs("form",{onSubmit:gn,className:"relative",children:[c.jsx(Co,{ref:yt,value:xt,onChange:Wn,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(),gn(C))}}),ye==="streaming"||ye==="submitted"?c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(jt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Ot,children:c.jsx(te.Square,{className:"h-4 w-4"})})}),c.jsxs(ut,{children:[c.jsx(Qr,{children:"Escape"})," to stop"]})]}):c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx("button",{type:"submit",className:ne(jt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!xt.trim(),children:c.jsx(te.ArrowRight,{className:"h-4 w-4"})})}),c.jsxs(ut,{children:[c.jsx(Qr,{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(te.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 om(e){return c.jsx(dl,{children:c.jsx(im,{...e})})}exports.verifyToken=El.verifyToken;exports.ARCTEN_ORIGINAL_NAME=Ie;exports.ArctenAgent=om;exports.SecureModalProvider=dl;exports.extractToolsMetadata=ur;exports.preserveToolName=Ml;exports.useAgent=To;exports.useSecureModal=ul;
|