@sciol/xyzen 1.9.94-beta.ef75ea7 → 1.9.94-beta.fa6bb03

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/xyzen.umd.js CHANGED
@@ -106,8 +106,8 @@ border-radius:50%;animation:spin .8s linear infinite;margin:0 auto}
106
106
  `)){if(o.startsWith(":"))continue;const l=o.indexOf(":");if(l===-1)continue;const u=o.slice(0,l),d=o.slice(l+1).trimStart();switch(u){case"id":i.id=d;break;case"event":i.event=d;break;case"data":i.data=i.data?`${i.data}
107
107
  ${d}`:d;break}}(i.data!==void 0||i.event!==void 0)&&(yield{event:i,remaining:e})}yield{event:{},remaining:e}}class t8n{connections=new Map;retryTimeouts=new Map;constructor(){setTimeout(()=>{try{sd().visibility.onVisible(()=>{this._retryAllPending()})}catch{typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&this._retryAllPending()})}},0)}_retryAllPending(){for(const[e,n]of this.retryTimeouts){clearTimeout(n),this.retryTimeouts.delete(e);const r=this.connections.get(e);r&&(r.retryCount=0,r.controller=new AbortController,this._startStream(r))}}get baseUrl(){const e=sd().env.backendUrl;return(!e||e==="")&&typeof window<"u"?`${window.location.protocol}//${window.location.host}`:e}connect(e,n){this.disconnect(e);const r=new AbortController,i={topicId:e,controller:r,lastEventId:null,retryCount:0,callbacks:n};this.connections.set(e,i),this._startStream(i)}disconnect(e){const n=this.connections.get(e);n&&(n.controller.abort(),this.connections.delete(e));const r=this.retryTimeouts.get(e);r&&(clearTimeout(r),this.retryTimeouts.delete(e))}disconnectAll(){for(const e of[...this.connections.keys()])this.disconnect(e)}getOpenTopicIds(){return[...this.connections.keys()]}hasConnection(e){return this.connections.has(e)}updateCallbacks(e,n){const r=this.connections.get(e);return r?(r.callbacks=n,!0):!1}async _startStream(e){const{topicId:n,controller:r,callbacks:i}=e,o=Di.getToken();if(!o){i.onStatusChange({connected:!1,error:"Authentication required"});return}const l={Authorization:`Bearer ${o}`,Accept:"text/event-stream"};e.lastEventId&&(l["Last-Event-ID"]=e.lastEventId);const u=`${this.baseUrl}/xyzen/api/v1/topics/${n}/events`;try{const d=sd().streamingFetch,p=await d(u,{headers:l,signal:r.signal});if(!p.ok){if(p.status===401){Di.removeToken(),i.onStatusChange({connected:!1,error:"Authentication failed"}),WOn();return}throw new Error(`SSE HTTP ${p.status}`)}if(!p.body)throw new Error("SSE response has no body");e.retryCount=0,i.onStatusChange({connected:!0});const m=p.body.getReader(),g=new TextDecoder;let h="";for(;;){const{done:f,value:b}=await m.read();if(f)break;h+=g.decode(b,{stream:!0});let y=h;for(const{event:v,remaining:_}of e8n(h))if(y=_,v.data!==void 0){v.id&&(e.lastEventId=v.id);try{const w=JSON.parse(v.data),x=v.event||w.type||"message";i.onMessageEvent({type:x,data:w.data!==void 0?w.data:w})}catch{console.warn("SSE: failed to parse event data",v.data)}}h=y}this._handleDisconnect(e)}catch(d){if(r.signal.aborted)return;console.warn(`SSE error for topic ${n}:`,d),this._handleDisconnect(e)}}_handleDisconnect(e){const{topicId:n,callbacks:r}=e;if(this.connections.get(n)!==e)return;if(r.onStatusChange({connected:!1}),e.retryCount>=ZFn){r.onStatusChange({connected:!1,error:"Connection closed. Please refresh the page."}),this.connections.delete(n);return}const i=Math.min(XFn*Math.pow(2,e.retryCount),JFn);e.retryCount++,e.controller=new AbortController;const o=setTimeout(()=>{this.retryTimeouts.delete(n),this.connections.get(n)===e&&this._startStream(e)},i);this.retryTimeouts.set(n,o)}}const Ub=new t8n;class n8n{async createTopic(e){return nn.post("/xyzen/api/v1/topics/",e)}async updateTopic(e,n){return nn.put(`/xyzen/api/v1/topics/${e}`,n)}async deleteTopic(e){return nn.delete(`/xyzen/api/v1/topics/${e}`)}async getMessages(e,n){const r=new URLSearchParams;n?.before&&r.set("before",n.before),n?.limit&&r.set("limit",String(n.limit));const i=r.toString();return nn.get(`/xyzen/api/v1/topics/${e}/messages${i?`?${i}`:""}`)}async getMessageNav(e){return nn.get(`/xyzen/api/v1/topics/${e}/message-nav`)}async getTokenStats(e){return nn.get(`/xyzen/api/v1/topics/${e}/token-stats`)}async compactTopic(e,n){return nn.post(`/xyzen/api/v1/topics/${e}/compact`,n?{up_to_message_id:n}:{})}async sendMessage(e,n){return nn.post(`/xyzen/api/v1/topics/${e}/messages`,n)}async abort(e){return nn.post(`/xyzen/api/v1/topics/${e}/abort`)}async regenerate(e){return nn.post(`/xyzen/api/v1/topics/${e}/regenerate`)}async answerQuestion(e,n){return nn.post(`/xyzen/api/v1/topics/${e}/question-response`,n)}}const hg=new n8n,gx=787,iy="Asia/Shanghai",Cke=576,Ske=640,QN="app.chatConfig.defaultTitle",hot="/workspace";class r8n{getProviderDisplayName(e){return{openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",google:"Google",google_vertex:"Google Vertex AI"}[e]||e}async getProviderTemplates(){const e=await nn.get("/xyzen/api/v1/providers/templates",{auth:!1});return Object.entries(e).map(([n,r])=>({type:n,display_name:this.getProviderDisplayName(n),models:r}))}async getSupportedModels(){return nn.get("/xyzen/api/v1/providers/models",{auth:!1})}async getAvailableModels(){return nn.get("/xyzen/api/v1/providers/available-models")}async getTierModels(){return nn.get("/xyzen/api/v1/providers/tier-models")}async getDefaultModelConfig(){return nn.get("/xyzen/api/v1/providers/default-model",{auth:!1})}async getMyProviders(){return nn.get("/xyzen/api/v1/providers/me")}async getSystemProviders(){return nn.get("/xyzen/api/v1/providers/system")}async createProvider(e){return nn.post("/xyzen/api/v1/providers/",e)}async getProvider(e){return nn.get(`/xyzen/api/v1/providers/${e}`)}async updateProvider(e,n){return nn.patch(`/xyzen/api/v1/providers/${e}`,n)}async deleteProvider(e){return nn.delete(`/xyzen/api/v1/providers/${e}`)}async getUserModels(){return nn.get("/xyzen/api/v1/providers/user-models")}}const hx=new r8n;class a8n{defaultModelConfig=null;defaultModelConfigPromise=null;async getDefaultModelConfig(){return this.defaultModelConfig?this.defaultModelConfig:this.defaultModelConfigPromise?this.defaultModelConfigPromise:(this.defaultModelConfigPromise=hx.getDefaultModelConfig().then(e=>(this.defaultModelConfig=e,this.defaultModelConfigPromise=null,e)).catch(e=>{throw console.error("Failed to fetch default model config:",e),this.defaultModelConfigPromise=null,e}),this.defaultModelConfigPromise)}async getDefaultSystemProviderId(e){try{const n=await this.getDefaultModelConfig();return e.find(i=>i.provider_type===n.provider_type&&i.is_system)?.id||null}catch(n){return console.error("Failed to get default system provider:",n),null}}async getDefaultModelName(){try{return(await this.getDefaultModelConfig()).key}catch(e){return console.error("Failed to get default model name:",e),null}}async getDefaultProviderAndModel(e){try{const n=await this.getDefaultModelConfig(),r={openai:"openai",azure:"azure_openai",google:"google",vertex_ai:"google_vertex","vertex_ai-language-models":"google_vertex"};let i=e.find(o=>o.provider_type===n.provider_type);if(!i&&n.litellm_provider){const o=r[n.litellm_provider];o&&(i=e.find(l=>l.provider_type===o))}return i?{providerId:i.id,model:n.key}:(console.error("No matching provider found for default model"),{providerId:null,model:null})}catch(n){return console.error("Failed to get default provider and model:",n),{providerId:null,model:null}}}clearCache(){this.defaultModelConfig=null,this.defaultModelConfigPromise=null}}const fot=new a8n,D1=new Map,Z5=new Set,i8n=5e3,s8n=100;function Aot(t){Ub.disconnect(t);const e=D1.get(t);e&&(clearTimeout(e),D1.delete(t))}function o8n(t,e,n){const{reconcileChannelFromBackend:r,getAgentNameById:i,waitForChannelConnection:o}=n;return{setActiveChatChannel:l=>t({activeChatChannel:l}),fetchChatHistory:async()=>{const{setLoading:l}=e();l("chatHistory",!0);try{const u=await Lp.getSessions(),d=e().channels,p={...d},m=Object.entries(d).filter(([,h])=>h.responding).map(([h,f])=>`${h.slice(0,8)}(msgs=${f.messages.length})`);m.length>0&&console.warn("[fetchChatHistory] DANGER: overwriting channels while responding:",m.join(", "));const g=u.flatMap(h=>h.topics?.map(f=>(p[f.id]?p[f.id]={...p[f.id],sessionId:h.id,title:f.name,agentId:h.agent_id}:p[f.id]={id:f.id,sessionId:h.id,title:f.name,messages:[],agentId:h.agent_id,provider_id:h.provider_id,model:h.model,model_tier:h.model_tier,knowledge_set_id:h.knowledge_set_id,sandbox_backend:h.sandbox_backend,connected:!1,error:null},{id:f.id,sessionId:h.id,title:f.name,updatedAt:f.updated_at,assistantTitle:i(h.agent_id),lastMessage:"",isPinned:f.is_pinned??!1}))||[]);t(h=>{h.chatHistory=g,h.chatHistoryLoading=!1;for(const[f,b]of Object.entries(p)){const y=h.channels[f];if(!y)h.channels[f]=b;else{if(y.responding)continue;y.sessionId=b.sessionId,y.title=b.title,y.agentId=b.agentId,b.provider_id!==void 0&&(y.provider_id=b.provider_id),b.model!==void 0&&(y.model=b.model),b.model_tier!==void 0&&(y.model_tier=b.model_tier),b.knowledge_set_id!==void 0&&(y.knowledge_set_id=b.knowledge_set_id),b.sandbox_backend!==void 0&&(y.sandbox_backend=b.sandbox_backend)}}})}catch(u){console.error("ChatSlice: Failed to fetch chat history:",u),t({chatHistoryLoading:!1})}finally{e().setLoading("chatHistory",!1)}},togglePinChat:l=>{const u=e().chatHistory.find(p=>p.id===l);if(!u)return;const d=!u.isPinned;t(p=>{const m=p.chatHistory.find(g=>g.id===l);m&&(m.isPinned=d)}),hg.updateTopic(l,{is_pinned:d}).catch(p=>{console.error("Failed to persist pin state:",p),t(m=>{const g=m.chatHistory.find(h=>h.id===l);g&&(g.isPinned=!d)})})},activateChannel:async l=>{const{channels:u,activeChatChannel:d,connectToChannel:p}=e();if(console.debug(`[activateChannel] topic=${l.slice(0,8)} current=${d?.slice(0,8)} connected=${u[l]?.connected} msgs=${u[l]?.messages.length} responding=${u[l]?.responding}`),l===d&&u[l]?.connected){console.debug("[activateChannel] SKIP (already active & connected)");return}const m=u[l];m?.agentId&&t(h=>{h.activeTopicByAgent[m.agentId]=l});let g=u[l];if(!g)try{const h=await Lp.getSessionByTopic(l),f=h.topics.find(E=>E.id===l),b=h.id,y=f?.name??null,v=h.agent_id,_=h.provider_id,w=h.model,x=h.model_tier,k=h.knowledge_set_id,C=h.sandbox_backend;if(y)g={id:l,sessionId:b,title:y,messages:[],agentId:v,provider_id:_,model:w,model_tier:x,knowledge_set_id:k,sandbox_backend:C,connected:!1,error:null},t(E=>{E.channels[l]=g});else{console.error(`Topic ${l} not found in any session, refetching history...`),await e().fetchChatHistory();const E=e().channels;if(E[l])g=E[l];else{console.error(`Topic ${l} still not found after refetch.`);return}}}catch(h){console.error("Failed to find session for topic:",h);return}if(g){if(t({activeChatChannel:l}),Ub.hasConnection(l))console.debug("[activateChannel] hasLiveWs, skipping reconcile");else{const f=g.messages.some(b=>b.status==="pending"||b.status==="streaming"||b.status==="thinking");console.debug(`[activateChannel] noLiveWs, msgs=${g.messages.length} stale=${f} → ${g.messages.length===0||f?"RECONCILE":"SKIP"}`),(g.messages.length===0||f)&&await r(l)}p(g.sessionId,g.id),await o(l,{logFailure:!0})}},activateChannelForAgent:async l=>{const u=`activate:${l}`;if(!Z5.has(u)){Z5.add(u);try{try{const d=await Lp.getSessionByAgent(l);if(d.topics&&d.topics.length>0){const p=d.topics[0],m={id:p.id,sessionId:d.id,title:p.name,messages:[],agentId:d.agent_id,provider_id:d.provider_id,model:d.model,model_tier:d.model_tier,knowledge_set_id:d.knowledge_set_id,sandbox_backend:d.sandbox_backend,connected:!1,error:null};t(g=>{const h=g.channels[p.id];g.channels[p.id]=uot(h,m)}),await e().activateChannel(p.id)}else{const p=await hg.createTopic({name:os.t(QN),session_id:d.id}),m={id:p.id,sessionId:d.id,title:p.name,messages:[],agentId:d.agent_id,provider_id:d.provider_id,model:d.model,model_tier:d.model_tier,knowledge_set_id:d.knowledge_set_id,sandbox_backend:d.sandbox_backend,connected:!1,error:null};t(g=>{g.channels[p.id]=m}),await e().activateChannel(p.id)}}catch(d){d instanceof mg&&d.status===404?await e().createDefaultChannel(l):(console.error("Failed to activate channel for agent:",d),await e().createDefaultChannel(l))}}finally{Z5.delete(u)}}},createDefaultChannel:async l=>{const u=l||e().rootAgentId;if(!u){console.error("createDefaultChannel: no agentId and rootAgentId not loaded");return}const d=`create:${u}`;if(!Z5.has(d)){Z5.add(d);try{const p=u;let m;try{m=await Lp.getSessionByAgent(p)}catch(y){if(y instanceof mg&&y.status===404)m=null;else throw y}if(m){if(!m.provider_id||!m.model){console.log(" - Existing session missing provider/model, updating with defaults...");try{const x=e().agents.find(E=>E.id===m.agent_id);let k=m.provider_id,C=m.model;if(x?.provider_id&&x?.model)k=x.provider_id,C=x.model;else{const E=await hx.getMyProviders(),S=await fot.getDefaultProviderAndModel(E);k=k||S.providerId||void 0,C=C||S.model||void 0}k&&C&&(await Lp.updateSession(m.id,{provider_id:k,model:C}),m.provider_id=k,m.model=C,console.log(` - Updated session with provider (${k}) and model (${C})`))}catch(w){console.warn(" - Failed to update session with defaults:",w)}}const y=await hg.createTopic({name:os.t(QN),session_id:m.id}),v={id:y.id,sessionId:m.id,title:y.name,messages:[],agentId:m.agent_id,provider_id:m.provider_id,model:m.model,model_tier:m.model_tier,knowledge_set_id:m.knowledge_set_id,sandbox_backend:m.sandbox_backend,connected:!1,error:null},_={id:y.id,sessionId:m.id,title:y.name,updatedAt:y.updated_at,assistantTitle:i(m.agent_id),lastMessage:"",isPinned:!1};t(w=>{w.channels[y.id]=v,w.chatHistory.unshift(_),w.activeChatChannel=y.id,w.activeTabIndex=1}),e().connectToChannel(m.id,y.id);return}const g=e().resolveAgent(u),h={name:"New Session",agent_id:u};g?.mcp_servers?.length&&(h.mcp_server_ids=g.mcp_servers.map(y=>y.id));let f=[];try{f=await hx.getMyProviders()}catch(y){console.error("Failed to fetch providers:",y)}try{if(g?.provider_id&&g?.model)h.provider_id=g.provider_id,h.model=g.model;else{const{providerId:y,model:v}=await fot.getDefaultProviderAndModel(f);y&&v&&(h.provider_id=y,h.model=v)}}catch(y){console.error("Error getting provider/model:",y)}const b=await Lp.createSession(h);if(b.topics&&b.topics.length>0){const y=b.topics[0],v={id:y.id,sessionId:b.id,title:y.name,messages:[],agentId:b.agent_id,provider_id:b.provider_id,model:b.model,model_tier:b.model_tier,connected:!1,error:null},_={id:y.id,sessionId:b.id,title:y.name,updatedAt:y.updated_at,assistantTitle:i(b.agent_id),lastMessage:"",isPinned:!1};t(w=>{w.channels[y.id]=v,w.chatHistory.unshift(_),w.activeChatChannel=y.id,w.activeTabIndex=1}),e().connectToChannel(b.id,y.id)}else{const y=await hg.createTopic({name:os.t(QN),session_id:b.id}),v={id:y.id,sessionId:b.id,title:y.name,messages:[],agentId:b.agent_id,provider_id:b.provider_id,model:b.model,model_tier:b.model_tier,connected:!1,error:null},_={id:y.id,sessionId:b.id,title:y.name,updatedAt:y.updated_at,assistantTitle:i(b.agent_id),lastMessage:"",isPinned:!1};t(w=>{w.channels[y.id]=v,w.chatHistory.unshift(_),w.activeChatChannel=y.id,w.activeTabIndex=1}),e().connectToChannel(b.id,y.id)}}catch(p){console.error("Failed to create channel:",p)}finally{Z5.delete(d)}}},updateTopicName:async(l,u)=>{try{await hg.updateTopic(l,{name:u}),t(d=>{d.channels[l]&&(d.channels[l].title=u);const p=d.chatHistory.find(m=>m.id===l);p&&(p.title=u)}),console.log(`Topic ${l} name updated to: ${u}`)}catch(d){throw console.error("Failed to update topic name:",d),d}},deleteTopic:async l=>{try{await hg.deleteTopic(l),Aot(l);const u=e().chatHistory,p=u.find(h=>h.id===l)?.sessionId,m=e().activeChatChannel===l,g=m?u.find(h=>h.id!==l&&h.sessionId===p)?.id??null:null;t(h=>{delete h.channels[l],h.chatHistory=h.chatHistory.filter(f=>f.id!==l),m&&(h.activeChatChannel=g)}),m&&g&&e().activateChannel(g),console.log(`Topic ${l} deleted`)}catch(u){throw console.error("Failed to delete topic:",u),u}},clearSessionTopics:async l=>{try{const u=e().channels;for(const[p,m]of Object.entries(u))m.sessionId===l&&Aot(p);await Lp.clearSessionTopics(l);const d=e().activeChatChannel;d&&u[d]?.sessionId===l&&t({activeChatChannel:null}),await e().fetchChatHistory(),console.log(`Session ${l} topics cleared`)}catch(u){console.error("Failed to clear session topics:",u)}},updateSessionConfig:async(l,u)=>{try{const d=await Lp.updateSession(l,u);t(p=>{for(const m of Object.values(p.channels))m.sessionId===l&&(m.provider_id=d.provider_id,m.model=d.model,m.model_tier=d.model_tier,m.knowledge_set_id=d.knowledge_set_id,m.sandbox_backend=d.sandbox_backend)})}catch(d){console.error("Failed to update session config:",d),e().showNotification("Error","Failed to update session configuration","error")}},ensureChannelForTopic:async(l,u,d)=>{const{channels:p}=e();if(!p[l]){let m;try{m=await Lp.getSessionByAgent(d)}catch{}const g={id:l,sessionId:u,title:"",messages:[],agentId:d,provider_id:m?.provider_id,model:m?.model,model_tier:m?.model_tier,knowledge_set_id:m?.knowledge_set_id,sandbox_backend:m?.sandbox_backend,connected:!1,error:null};t(h=>{const f=h.channels[l];h.channels[l]=uot(f,g)})}await e().activateChannel(l)},updateSessionProviderAndModel:async(l,u,d)=>{try{await Lp.updateSession(l,{provider_id:u,model:d}),t(p=>{const m=p.activeChatChannel;m&&p.channels[m]?.sessionId===l&&(p.channels[m].provider_id=u,p.channels[m].model=d),Object.keys(p.channels).forEach(g=>{p.channels[g].sessionId===l&&(p.channels[g].provider_id=u,p.channels[g].model=d)})})}catch(p){console.error("Failed to update session provider and model:",p),e().showNotification("Error","Failed to update model selection","error")}}}}class l8n{constructor(e){this.mutateChannel=e}buffer=[];rafId=null;pushStreaming(e,n,r){this.buffer.push({type:"streaming",id:e,content:n,execution_id:r}),this.scheduleFlush()}pushThinking(e,n){this.buffer.push({type:"thinking",id:e,content:n}),this.scheduleFlush()}flushSync(){this.buffer.length!==0&&(this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.flush())}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.buffer=[]}get hasPending(){return this.buffer.length>0}scheduleFlush(){this.rafId===null&&(this.rafId=requestAnimationFrame(()=>this.flush()))}flush(){if(this.rafId=null,this.buffer.length===0)return;const e=this.buffer;this.buffer=[],this.mutateChannel(n=>{for(const r of e)r.type==="streaming"?this.applyStreamingChunk(n,r):this.applyThinkingChunk(n,r);Eke(n)})}applyStreamingChunk(e,n){const r=mx(e,n.id,n.execution_id);if(r===-1){e.messages.push({id:n.id,streamId:n.id,clientId:ON(),role:"assistant",content:n.content,created_at:new Date().toISOString(),status:"streaming"});return}const i=e.messages[r];if(i.streamId=n.id,i.status="streaming",i.agentExecution&&i.agentExecution.phases.length>0){const o=i.agentExecution;let l=o.currentNode?o.phases.findLast(d=>d.nodeId===o.currentNode):null;l||(l=o.phases.findLast(d=>d.status==="running")),l||(l=o.phases[o.phases.length-1]);const u=l.streamedContent||"";u.length>100&&n.content.length>u.length&&n.content.startsWith(u.slice(0,100))?l.streamedContent=n.content:l.streamedContent=u+n.content}else{const o=i.content;e.messages[r].content=o+n.content}}applyThinkingChunk(e,n){let r=e.messages.findIndex(i=>i.id===n.id);if(r===-1&&(r=e.messages.findLastIndex(i=>i.status==="thinking"&&i.agentExecution?.status==="running")),r!==-1){const i=e.messages[r].thinkingContent??"";e.messages[r].thinkingContent=i+n.content}}}function c8n(t,e){if(t.responding=!0,mx(t,e)!==-1)return;FN(t)===-1&&t.messages.push({id:e,streamId:e,clientId:ON(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"pending",isNewMessage:!0})}function u8n(t,e){t.responding=!0;let n=mx(t,e.stream_id,e.execution_id);if(n===-1&&(n=FN(t)),n!==-1){const r=t.messages[n];r.id=e.stream_id,r.streamId=e.stream_id,r.status="streaming",r.content||(r.content="");return}t.messages.push({id:e.stream_id,streamId:e.stream_id,clientId:ON(),role:"assistant",content:"",isNewMessage:!0,created_at:new Date().toISOString(),status:"streaming"})}function d8n(t,e){let n=mx(t,e.stream_id,e.execution_id);if(n===-1){const r=t.messages.map((i,o)=>i.status==="streaming"?o:-1).filter(i=>i!==-1);n=r.length===1?r[0]:-1}if(n!==-1){const r=t.messages[n];if(!r.content&&r.agentExecution&&r.agentExecution.phases.length>0){const i=r.agentExecution.phases.map(o=>o.streamedContent||"").filter(Boolean).join(`
108
108
 
109
- `);i&&(r.content=i)}r.agentExecution?.status==="running"||Nte(r,{status:"completed",onlyIfRunning:!0}),r.created_at=e.created_at||new Date().toISOString(),console.debug("[ChatSlice] streaming_end: finalized message at index",n)}else console.warn("[ChatSlice] streaming_end: no message found to finalize")}function p8n(t,e){t.messages.some(n=>n.id===e.id)||t.messages.push({...e,status:e.status||"completed",isNewMessage:!0})}function m8n(t,e){let n=mx(t,e.stream_id);if(n===-1)for(let r=t.messages.length-1;r>=0;r--){const i=t.messages[r];if(i.role==="assistant"&&i.error&&!oot(i.id)){n=r;break}}if(n!==-1){if(t.messages.findIndex((l,u)=>u!==n&&l.id===e.db_id)!==-1){t.messages.splice(n,1);return}const i=t.messages[n];i.dbId=e.db_id,i.id=e.db_id,i.created_at=e.created_at,i.status==="waiting_for_user"||i.userQuestion?.status==="pending"||Nte(i,{status:"completed",onlyIfRunning:!0})}}function g8n(t,e){t.responding=!0;const n=FN(t);if(n!==-1){const i=t.messages[n];i.id=e.stream_id,i.status="thinking",i.thinkingContent="",i.content=i.content||"";return}const r=rz(t);if(r!==-1){const i=t.messages[r];i.status="thinking",i.thinkingContent=i.thinkingContent??"";return}t.messages.push({id:e.stream_id,clientId:`thinking-${Date.now()}`,role:"assistant",content:"",isNewMessage:!0,created_at:new Date().toISOString(),status:"thinking",thinkingContent:""})}function PAs(t,e){}function h8n(t,e){t.responding=!0;const{context:n}=e;let r=-1;n.stream_id&&(r=mx(t,n.stream_id)),r===-1&&(r=FN(t));const i={agentId:n.agent_id,agentName:n.agent_name,agentType:n.agent_type,executionId:n.execution_id,status:"running",startedAt:n.started_at,phases:[],subagents:[]};if(r!==-1){const o=t.messages[r];t.messages[r]={...o,id:`agent-${n.execution_id}`,streamId:n.stream_id||o.streamId,status:"pending",agentExecution:i}}else t.messages.push({id:`agent-${n.execution_id}`,streamId:n.stream_id,clientId:ON(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"pending",isNewMessage:!0,agentExecution:i})}function f8n(t,e){t.responding=!1;const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r];i.agentExecution?Nte(i,{status:e.status==="completed"?"completed":e.status==="cancelled"?"cancelled":"failed",durationMs:e.duration_ms}):xke(i)}}function A8n(t,e){t.responding=!1;const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r],o=i.agentExecution;o?(o.error={type:e.error_type,message:e.error_message,recoverable:e.recoverable,nodeId:e.node_id},Nte(i,{status:"failed"})):xke(i)}}function b8n(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;if(i){const o=i.phases.find(p=>p.status==="running");o&&(o.status="completed",o.endedAt=Date.now(),o.startedAt&&(o.durationMs=Date.now()-o.startedAt));const l=WFn(e.node_id),u=i.phases.filter(p=>p.nodeId===e.node_id).length,d=u>0?`${e.node_id}__${u}`:e.node_id;i.phases.push({id:d,nodeId:e.node_id,name:l,componentKey:e.component_key,status:"running",startedAt:Date.now(),nodes:[],streamedContent:""}),i.currentPhase=l,i.currentNode=e.node_id}}}function y8n(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;if(i){const o=i.phases.findLast(l=>l.nodeId===e.node_id&&l.status==="running");o&&(o.status=e.status==="completed"?"completed":e.status==="skipped"?"skipped":"failed",o.endedAt=Date.now(),o.durationMs=e.duration_ms,o.outputSummary=e.output_summary)}}}function v8n(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution&&(i.agentExecution.executionId===n.parent_execution_id||i.agentExecution.executionId===n.execution_id));if(r!==-1){const i=t.messages[r].agentExecution;i&&i.subagents.push({id:e.subagent_id,name:e.subagent_name,type:e.subagent_type,status:"running",depth:n.depth,executionPath:n.execution_path,startedAt:n.started_at})}}function _8n(t,e){const n=t.messages.findIndex(r=>r.agentExecution?.subagents?.some(i=>i.id===e.subagent_id));if(n!==-1){const r=t.messages[n].agentExecution;if(r){const i=r.subagents.find(o=>o.id===e.subagent_id);i&&(i.status=e.status==="completed"?"completed":"failed",i.endedAt=Date.now(),i.durationMs=e.duration_ms,i.outputSummary=e.output_summary)}}}function w8n(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;i&&(i.progressPercent=e.progress_percent,i.progressMessage=e.message)}}function x8n(t,e){t.responding=!1;const n=e.error_code?{code:e.error_code,category:e.error_category||e.error_code.split(".")[0],message:e.error,recoverable:e.recoverable??!1,detail:e.detail,errorRef:e.error_ref,occurredAt:e.occurred_at}:{code:"system.internal_error",category:"system",message:e.error||"An error occurred",recoverable:!1};let r=mx(t,e.stream_id);r===-1&&(r=FN(t)),r===-1&&(r=YFn(t)),r===-1&&(r=rz(t)),r!==-1?t.messages[r]={...t.messages[r],status:"failed",error:n}:t.messages.push({id:e.stream_id,streamId:e.stream_id,clientId:ON(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"failed",isNewMessage:!0,error:n}),console.error("Chat error:",e.error_code||e.error)}function k8n(t,e){console.warn("Insufficient balance:",e),t.responding=!1;let n=mx(t,e.stream_id);return n===-1&&(n=FN(t)),n!==-1&&(t.messages[n]={...t.messages[n],content:"",status:"failed",error:{code:"billing.insufficient_balance",category:"billing",message:e.message||"Insufficient balance. Please recharge to continue.",recoverable:!1}}),{isOpen:!0,title:"积分用尽",message:"您的积分已用尽。目前产品处于内测阶段,欢迎填写问卷参与内测,获取更多使用额度。",type:"warning",actionLabel:"填写问卷",actionUrl:"https://sii-czxy.feishu.cn/share/base/form/shrcnYu8Y3GNgI7M14En1xJ7rMb"}}function E8n(t,e){console.warn("Parallel chat limit reached:",e),t.responding=!1;const n=FN(t);return n!==-1&&t.messages.splice(n,1),{isOpen:!0,title:"并行会话已达上限",message:`您已达到并行会话上限(${e.current??"?"}/${e.limit??"?"})。请等待其他会话完成后重试。`,type:"warning"}}function C8n(t,e,n){console.log("Stream aborted:",e);const r=n.get(t.id);r&&(clearTimeout(r),n.delete(t.id)),t.responding=!1,t.aborting=!1,kke(t)}function S8n(t,e){t.responding=!0;const n=t.messages.findIndex(l=>l.status==="pending"&&!l.agentExecution);n!==-1&&t.messages.splice(n,1);const r={id:e.id,name:e.name,description:e.description,arguments:e.arguments,status:e.status,timestamp:new Date(e.timestamp*1e3).toISOString()};let i=rz(t);if(i===-1&&e.stream_id&&(i=mx(t,e.stream_id)),i!==-1){const l=t.messages[i].agentExecution;if(l){let u=l.currentNode?l.phases.findLast(d=>d.nodeId===l.currentNode):null;if(u||(u=l.phases.findLast(d=>d.status==="running")),!u&&l.phases.length>0&&(u=l.phases[l.phases.length-1]),u){u.toolCalls||(u.toolCalls=[]);const d=u.streamedContent?.length??0;r.contentOffset=d,u.toolCalls.push(r),console.log(`ChatSlice: Added tool call ${e.name} to phase ${u.id}`);return}}}const o=`tool-call-${e.id}`;t.messages.push({id:o,streamId:e.stream_id,clientId:ON(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"streaming",isNewMessage:!0,toolCalls:[r]}),console.log(`ChatSlice: Created new tool call message with tool ${e.name}`)}function I8n(t,e){const n=rz(t);if(n!==-1){const r=t.messages[n].agentExecution;if(r){for(const i of r.phases)if(i.toolCalls){const o=i.toolCalls.find(l=>l.id===e.toolCallId);if(o){o.status=e.status,e.result!=null&&(o.result=e.result),e.error&&(o.error=e.error),e.duration_ms!==void 0&&(o.duration_ms=e.duration_ms);break}}}}t.messages.forEach(r=>{r.toolCalls&&r.toolCalls.forEach(i=>{i.id===e.toolCallId&&(i.status=e.status,e.result!=null&&(i.result=e.result),e.error&&(i.error=e.error),e.duration_ms!==void 0&&(i.duration_ms=e.duration_ms))})})}function T8n(t,e,n){t.title=e.name;const r=n.find(i=>i.id===e.id);r&&(r.title=e.name,r.updatedAt=e.updated_at)}function B8n(t,e){const n=dot(t,"citations");n!==-1?(t.messages[n].citations=e.citations,console.log(`Attached ${e.citations.length} citations to message ${t.messages[n].id}`)):console.warn("[Citation Debug] Could not find assistant message to attach citations")}function D8n(t,e){const n=dot(t,"attachments");if(n!==-1){t.messages[n].attachments||(t.messages[n].attachments=[]);const i=t.messages[n].attachments||[],o=e.files.filter(l=>!i.some(u=>u.id===l.id)).map(l=>({...l,download_url:`/xyzen/api/v1/files/${l.id}/download`}));t.messages[n].attachments=[...i,...o]}}function N8n(t,e){t.contextUsage={estimatedTokens:e.estimated_tokens,maxTokens:e.max_tokens,usagePercent:e.usage_percent,nearLimit:e.near_limit,critical:e.critical,truncated:e.truncated,truncatedCount:e.truncated_count}}function R8n(t){return{questionId:t.question_id,question:t.question,options:t.options?.map(e=>({id:e.id,label:e.label,description:e.description,markdown:e.markdown})),multiSelect:t.multi_select??!1,allowTextInput:t.allow_text_input,timeoutSeconds:t.timeout_seconds,threadId:t.thread_id,status:"pending",askedAt:Date.now()}}function L8n(t,e){let n=mx(t,e.stream_id);if(n===-1&&(n=rz(t)),n===-1){for(let o=t.messages.length-1;o>=0;o--)if(t.messages[o].role==="assistant"){n=o;break}}if(n===-1){console.warn("[questionHandlers] No target message found for ask_user_question event");return}const r=t.messages[n],i=R8n(e);r.agentExecution&&r.agentExecution.phases.length>0&&(i.afterPhaseIndex=r.agentExecution.phases.length-1),r.userQuestion&&r.userQuestion.status!=="pending"&&(r.answeredQuestions||(r.answeredQuestions=[]),r.answeredQuestions.push(r.userQuestion)),r.status="waiting_for_user",r.userQuestion=i,t.responding=!0}const $N=new Map;function M8n(t,e,n){const{updateDerivedStatus:r,closeIdleNonPrimaryConnection:i}=n;return{connectToChannel:(o,l)=>{console.debug(`[connectToChannel] topic=${l.slice(0,8)} hasExistingSSE=${Ub.hasConnection(l)} msgs=${e().channels[l]?.messages.length}`),$N.get(l)?.destroy();const u=new l8n(m=>{t(g=>{const h=g.channels[l];h&&m(h)})});$N.set(l,u);const d=m=>{const g=m;if(g.type==="streaming_chunk"){u.pushStreaming(g.data.stream_id,g.data.content,g.data.execution_id);return}if(g.type==="thinking_chunk"){u.pushThinking(g.data.stream_id,g.data.content);return}const h=u.hasPending;u.flushSync();const f=e().channels[l]?.responding;console.groupCollapsed(`[ChatEvent] ${g.type} | topic=${l.slice(0,8)} | responding=${f}`),t(y=>{const v=y.channels[l];if(v){switch(console.debug(`msgs=${v.messages.length}`,`| latestAssist=${(()=>{const _=[...v.messages].reverse().find(w=>w.role==="assistant");return _?`id=${_.id.slice(0,12)} status=${_.status} agentExec=${_.agentExecution?.status}`:"none"})()}`),g.type){case"processing":case"loading":{c8n(v,g.data.stream_id);break}case"streaming_start":{u8n(v,g.data);break}case"streaming_end":{d8n(v,g.data);break}case"message":{const _=g.data,w=_.client_id;if(w){const x=v.messages.findIndex(k=>k.clientId===w);if(x!==-1){const k=v.messages[x];v.messages[x]={...k,..._,id:_.id,status:_.status||"completed",isNewMessage:!1};break}}p8n(v,_);break}case"search_citations":{B8n(v,g.data);break}case"generated_files":{D8n(v,g.data);break}case"message_saved":{m8n(v,g.data);break}case"message_ack":{const{message_id:_,client_id:w}=g.data;if(w){const x=v.messages.findIndex(k=>k.clientId===w);if(x!==-1){const k=v.messages[x];k.id=_,k.status==="sending"&&(k.status="completed")}}break}case"tool_call_request":{S8n(v,g.data);break}case"tool_call_response":{I8n(v,g.data);break}case"error":{x8n(v,g.data);break}case"insufficient_balance":{const _=k8n(v,g.data);_&&(y.notification={..._,onAction:()=>window.open(_.actionUrl,"_blank")});break}case"parallel_chat_limit":{const _=E8n(v,g.data);y.notification=_;break}case"stream_aborted":{C8n(v,g.data,D1);break}case"thinking_start":{g8n(v,g.data);break}case"thinking_end":{g.data;break}case"topic_updated":{T8n(v,g.data,y.chatHistory);break}case"agent_start":{h8n(v,g.data);break}case"agent_end":{f8n(v,g.data);break}case"agent_error":{A8n(v,g.data);break}case"node_start":{b8n(v,g.data);break}case"node_end":{y8n(v,g.data);break}case"subagent_start":{v8n(v,g.data);break}case"subagent_end":{_8n(v,g.data);break}case"progress_update":{w8n(v,g.data);break}case"ask_user_question":{L8n(v,g.data);break}case"token_usage":{const{total_tokens:_,input_tokens:w}=g.data;v.tokenUsage=_,w!=null&&(v.inputTokens=w);break}case"context_usage":{N8n(v,g.data);break}}Eke(v)}});const b=e().channels[l]?.responding;if(f!==b&&console.debug(`responding changed: ${f} → ${b}`,`| hadPendingChunks: ${h}`),console.groupEnd(),g.type==="topic_updated"&&e().renameTab(g.data.id,g.data.name),g.type==="agent_end"){const y=e().channels[l];y?.sessionId&&!y.sandbox_backend&&Lp.getSessionByTopic(l).then(v=>{v.sandbox_backend&&t(_=>{const w=_.channels[l];w&&!w.sandbox_backend&&(w.sandbox_backend=v.sandbox_backend)})}).catch(()=>{})}r(),i(l)};if(Ub.hasConnection(l)){Ub.updateCallbacks(l,{onMessageEvent:d,onStatusChange:m=>{m.connected||$N.get(l)?.destroy(),t(g=>{const h=g.channels[l];h&&(h.connected=m.connected,h.error=m.error??null)})}}),t(m=>{m.channels[l]&&(m.channels[l].connected=!0,m.channels[l].error=null)});return}const p=Ub.getOpenTopicIds();for(const m of p){if(m===l)continue;e().channels[m]?.responding||Ub.disconnect(m)}t(m=>{Object.entries(m.channels).forEach(([g,h])=>{Ub.hasConnection(g)||(h.connected=!1)}),m.channels[l]&&(m.channels[l].error=null)}),Ub.connect(l,{onMessageEvent:d,onStatusChange:m=>{m.connected||$N.get(l)?.destroy(),t(g=>{const h=g.channels[l];h&&(h.connected=m.connected,h.error=m.error??null)})}}),t(m=>{m.channels[l]&&(m.channels[l].connected=!0,m.channels[l].error=null)})},disconnectFromChannel:()=>{for(const[,o]of $N)o.destroy();$N.clear();for(const[o,l]of D1)clearTimeout(l),D1.delete(o);Ub.disconnectAll()},abortGeneration:o=>{hg.abort(o).catch(p=>{console.error("Failed to send abort signal:",p)});const l=D1.get(o);l&&(clearTimeout(l),D1.delete(o));const u=$N.get(o);u&&u.destroy(),t(p=>{const m=p.channels[o];m&&(m.aborting=!0,kke(m))}),r();const d=setTimeout(()=>{D1.delete(o),e().channels[o]?.aborting&&(console.warn("Abort timeout: Backend did not respond, resetting state"),t(g=>{const h=g.channels[o];h&&(h.aborting=!1,h.responding=!1,kke(h))}),r())},1e4);D1.set(o,d)},respondToQuestion:(o,l,u)=>{hg.answerQuestion(o,{question_id:l,selected_options:u.selectedOptions,text:u.text||""}).catch(d=>{console.error("Failed to send question response:",d)}),t(d=>{const p=d.channels[o];if(!p)return;const m=p.messages.find(h=>h.userQuestion?.questionId===l||h.answeredQuestions?.some(f=>f.questionId===l));if(!m)return;const g=m.userQuestion?.questionId===l?m.userQuestion:m.answeredQuestions?.find(h=>h.questionId===l);g&&(g.status="answered",g.selectedOptions=u.selectedOptions,g.userText=u.text,m.status="pending")}),r()},confirmToolCall:(o,l)=>{console.warn("confirmToolCall: not implemented in SSE mode"),t(u=>{u.channels[o]&&u.channels[o].messages.forEach(d=>{d.toolCalls&&d.toolCalls.forEach(p=>{p.id===l&&p.status==="waiting_confirmation"&&(p.status="executing")})})})},cancelToolCall:(o,l)=>{console.warn("cancelToolCall: not implemented in SSE mode"),t(u=>{u.channels[o]&&u.channels[o].messages.forEach(d=>{d.toolCalls&&d.toolCalls.forEach(p=>{p.id===l&&p.status==="waiting_confirmation"&&(p.status="failed",p.error="用户取消执行")})})})}}}const P8n=["image/jpeg","image/jpg","image/png","image/gif","image/webp","application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/json","application/xml","application/x-yaml","text/plain","text/markdown","text/csv","text/html","text/xml","text/yaml","text/x-yaml","audio/mpeg","audio/wav","audio/wave","audio/x-wav",".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"],O8n=[".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"];class F8n{appendUploadFields(e,n){e.append("file",n.file),e.append("scope",n.scope),n.category&&e.append("category",n.category),n.parentId&&e.append("parent_id",n.parentId),n.knowledgeSetId&&e.append("knowledge_set_id",n.knowledgeSetId),n.purpose&&e.append("purpose",n.purpose)}getUploadError(e){if(e.status===429)return new Error("Too many requests. Please wait a moment and try again.");try{const n=JSON.parse(e.responseText);if(typeof n.detail=="string"&&n.detail.trim())return new Error(n.detail)}catch{}return new Error(`Upload failed: ${e.statusText||`HTTP ${e.status}`}`)}uploadWithXhr(e,n){const r=new FormData;this.appendUploadFields(r,e);const i=new XMLHttpRequest,o=nn.baseUrl;return{promise:new Promise((u,d)=>{i.upload.addEventListener("progress",m=>{if(n&&m.lengthComputable){const g=Math.round(m.loaded*100/m.total);n({loaded:m.loaded,total:m.total,percentage:g})}}),i.addEventListener("load",()=>{i.status>=200&&i.status<300?u(JSON.parse(i.responseText)):d(this.getUploadError(i))}),i.addEventListener("error",()=>{d(new Error("Upload failed"))}),i.addEventListener("abort",()=>{d(new Error("Upload cancelled"))}),i.open("POST",`${o}/xyzen/api/v1/files/upload`);const p=Di.getToken();p&&i.setRequestHeader("Authorization",`Bearer ${p}`),i.send(r)}),abort:()=>i.abort()}}isAllowedType(e,n){return n.endsWith("/*")?e.type.startsWith(n.slice(0,-1)):n.startsWith(".")?e.name.toLowerCase().endsWith(n.toLowerCase()):e.type===n}uploadFileWithProgress(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o},l)}async uploadFile(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o},l).promise}async uploadChatAttachment(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o,purpose:"chat_attachment"},l).promise}async getFile(e){return nn.get(`/xyzen/api/v1/files/${e}`)}async listFiles(e){const n=new URLSearchParams;e&&(e.scope&&n.append("scope",e.scope),e.category&&n.append("category",e.category),e.include_deleted&&n.append("include_deleted","true"),e.limit&&n.append("limit",e.limit.toString()),e.offset&&n.append("offset",e.offset.toString()),e.parent_id&&n.append("parent_id",e.parent_id),e.filter_by_parent&&n.append("filter_by_parent","true"),e.is_dir!==void 0&&n.append("is_dir",e.is_dir.toString()),e.knowledge_set_id&&n.append("knowledge_set_id",e.knowledge_set_id));const r=n.toString()?"?"+n.toString():"";return nn.get(`/xyzen/api/v1/files/${r}`)}async getFileUrl(e,n=3600){return nn.get(`/xyzen/api/v1/files/${e}/url`,{params:{expires_in:n}})}async updateFile(e,n){return nn.patch(`/xyzen/api/v1/files/${e}`,n)}async confirmFiles(e,n){await Promise.all(e.map(r=>this.updateFile(r,{message_id:n,status:"confirmed"})))}async deleteFile(e,n=!1){return nn.delete(`/xyzen/api/v1/files/${e}`,void 0,{params:{hard_delete:n}})}async restoreFile(e){return nn.post(`/xyzen/api/v1/files/${e}/restore`)}async getStorageStats(){return nn.get("/xyzen/api/v1/files/stats/summary")}async getChatUploadCapabilities(){return nn.get("/xyzen/api/v1/files/chat-upload-capabilities")}async emptyTrash(){return nn.post("/xyzen/api/v1/files/empty-trash")}async bulkDeleteFiles(e){return nn.delete("/xyzen/api/v1/files/bulk",e)}async updateFileContent(e,n,r){const i=new Blob([n],{type:r||"text/plain"}),o=new FormData;return o.append("file",i,"content"),nn.put(`/xyzen/api/v1/files/${e}/content`,o)}async downloadRaw(e,n){return nn.raw(`/xyzen/api/v1/files/${e}/download`,{signal:n?.signal})}validateFile(e,n={}){const{maxSize:r=100*1024*1024,allowedTypes:i=P8n}=n;return e.size>r?{valid:!1,reason:"file_too_large",maxSize:r,actualSize:e.size,error:`File size exceeds ${(r/(1024*1024)).toFixed(0)}MB limit`}:i.length>0&&!i.some(l=>this.isAllowedType(e,l))?{valid:!1,reason:"unsupported_type",fileType:e.type||"unknown",error:`File type ${e.type||"unknown"} is not supported`}:{valid:!0}}getFileCategory(e){if(e.type.startsWith("image/"))return"images";if(e.type.startsWith("audio/"))return"audio";const n=e.name.toLowerCase();return e.type.includes("pdf")||e.type.includes("text")||e.type.includes("document")||e.type.includes("sheet")||e.type.includes("presentation")||e.type.includes("json")||e.type.includes("xml")||e.type.includes("yaml")||O8n.some(r=>n.endsWith(r))?"documents":"others"}getAttachmentAccessHint(e,n){const r=n||this.getFileCategory({name:e.name,type:e.type});return r==="images"||r==="audio"?"view":"read"}generateThumbnail(e){return new Promise((n,r)=>{if(!e.type.startsWith("image/")){r(new Error("File is not an image"));return}const i=160,o=URL.createObjectURL(e),l=new Image;l.onload=()=>{URL.revokeObjectURL(o);let u=l.width,d=l.height;u>d?u>i&&(d=Math.round(d*i/u),u=i):d>i&&(u=Math.round(u*i/d),d=i);const p=document.createElement("canvas");p.width=u,p.height=d;const m=p.getContext("2d");if(!m){r(new Error("Failed to get canvas context"));return}m.drawImage(l,0,0,u,d);const g=p.toDataURL("image/jpeg",.8);n(g)},l.onerror=()=>{URL.revokeObjectURL(o),r(new Error("Failed to load image"))},l.src=o})}}const go=new F8n;class Q8n{async editMessage(e,n){return nn.patch(`/xyzen/api/v1/messages/${e}`,n)}async deleteMessage(e){return nn.delete(`/xyzen/api/v1/messages/${e}`)}}const bot=new Q8n;function $8n(t,e,n){const{updateDerivedStatus:r,waitForChannelConnection:i}=n;return{sendMessage:async o=>{const{activeChatChannel:l,uploadedFiles:u,clearFiles:d,isUploading:p,channels:m,connectToChannel:g,showNotification:h}=e();if(!l)return;if(p){console.warn("Cannot send message while files are uploading");return}const f=m[l];if(!f)return;if(f.responding){console.warn("Cannot send message while assistant is responding");return}Ub.hasConnection(l)||(g(f.sessionId,f.id),await i(l));const b=e().channels[l];if(!b?.connected){h("Connection not ready","Please wait for chat connection and try again.","warning");return}const y=ON(),v=u.filter(k=>k.status==="completed"&&k.uploadedId),_=v.map(k=>({id:k.uploadedId,name:k.file.name,type:k.file.type,size:k.file.size,category:go.getFileCategory(k.file)}));t(k=>{const C=k.channels[l];C&&(C.responding=!0,C.messages.push({id:y,clientId:y,role:"user",content:o,created_at:new Date().toISOString(),status:"sending",isNewMessage:!0,..._.length>0?{attachments:_}:{}}))}),r();const w={message:o,client_id:y};v.length>0&&(w.file_ids=v.map(k=>k.uploadedId));const x=b;x?.knowledgeContext&&(w.context=x.knowledgeContext);try{await hg.sendMessage(l,w)}catch(k){console.error("Failed to send message via REST:",k),t(E=>{const S=E.channels[l];if(S){S.responding=!1;const I=S.messages.find(B=>B.clientId===y);I&&(I.status="failed")}}),r();const C=k instanceof Error&&"detail"in k?k.detail:void 0;if(C&&typeof C=="object"&&C.type==="parallel_chat_limit"){const E=C.data;e().showNotification(os.t("app.chat.parallelLimitTitle","Parallel chat limit reached"),os.t("app.chat.parallelLimitMessage","You have reached the parallel chat limit ({{current}}/{{limit}}). Please wait for other chats to finish.",{current:E?.current??"?",limit:E?.limit??"?"}),"warning")}else C&&typeof C=="object"&&C.error_code==="INSUFFICIENT_BALANCE"&&e().showNotification(os.t("app.chat.insufficientBalance","Insufficient balance"),os.t("app.chat.insufficientBalanceMessage","Your photon balance is insufficient. Please top up to continue."),"warning");return}d(!1)},startEditMessage:(o,l,u)=>{t({editingMessageId:o,editingContent:l,editingMode:u})},cancelEditMessage:()=>{t({editingMessageId:null,editingContent:"",editingMode:null})},submitEditMessage:async()=>{const{editingMessageId:o,editingContent:l,editingMode:u,activeChatChannel:d,channels:p}=e();if(!o||!d||!u)return;const m=p[d];if(!m)return;if(!m.messages.some(f=>f.id===o)){console.error("Message not found in active channel, skipping edit"),e().cancelEditMessage();return}const h=u==="edit_and_regenerate";try{const f=await bot.editMessage(o,{content:l,truncate_and_regenerate:h});t(b=>{const y=b.channels[d];if(!y)return;const v=y.messages.findIndex(_=>_.id===o);v!==-1&&(y.messages[v].content=f.message.content,y.messages[v].created_at=f.message.created_at,h&&(y.messages=y.messages.slice(0,v+1),y.responding=!1),b.editingMessageId=null,b.editingContent="",b.editingMode=null)}),f.regenerate&&e().triggerRegeneration()}catch(f){console.error("Failed to edit message:",f),e().showNotification("Error",os.t("app.message.editFailed"),"error")}},triggerRegeneration:()=>{const{activeChatChannel:o}=e();if(o){if(!Ub.hasConnection(o)){console.warn("[triggerRegeneration] No SSE connection, skipping");return}t(l=>{const u=l.channels[o];u&&(u.responding=!0)}),hg.regenerate(o).catch(l=>{console.error("Failed to trigger regeneration:",l),t(u=>{const d=u.channels[o];d&&(d.responding=!1)}),r()})}},deleteMessage:async o=>{const{activeChatChannel:l,channels:u}=e();if(!l)return;const d=u[l];if(!d)return;if(!oot(o)){const g=d.messages.find(h=>h.id===o)?.status==="streaming"?os.t("app.message.deleteStillStreaming"):os.t("app.message.deleteNotSaved");console.error(`Cannot delete message: ${g} (id: ${o.slice(0,20)}...)`),e().showNotification(os.t("app.message.cannotDelete"),g,"warning");return}if(!d.messages.some(m=>m.id===o)){console.error("Message not found in active channel, skipping delete");return}try{await bot.deleteMessage(o),t(m=>{const g=m.channels[l];g&&(g.messages=g.messages.filter(h=>h.id!==o))})}catch(m){console.error("Failed to delete message:",m),e().showNotification("Error",os.t("app.message.deleteFailed"),"error")}},retryMessage:o=>{const{activeChatChannel:l,channels:u,sendMessage:d}=e();if(!l)return;const p=u[l];if(!p)return;const m=p.messages.find(h=>h.id===o);if(!m||m.status!=="failed")return;const g=m.content;t(h=>{const f=h.channels[l];f&&(f.messages=f.messages.filter(b=>b.id!==o))}),d(g)}}}const Rte=50,j8n=(t,e)=>{const n=d=>d&&e().resolveAgent(d)?.name||"通用助理",r=async(d,p)=>{const m=Date.now();for(;Date.now()-m<=i8n;){const g=e().channels[d];if(g?.connected)return!0;if(g?.error)return p?.logFailure&&console.warn(`Connection failed for topic ${d}: ${g.error}`),!1;await new Promise(h=>{setTimeout(h,s8n)})}return p?.logFailure&&console.warn(`Connection timeout for topic ${d}`),!1},i=()=>{const d=e().respondingChannelIds;t(p=>{const m=new Set,g=new Set,h={};for(const b of Object.values(p.channels)){const y=HFn(b);(y==="running"||y==="stopping")&&(m.add(b.id),b.agentId&&g.add(b.agentId)),y==="running"&&b.agentId&&(h[b.agentId]=(h[b.agentId]||0)+1)}p.respondingChannelIds=m,p.runningAgentIds=g,p.activeTopicCountByAgent=h;const f=p.activeChatChannel;if(f){const b=d.has(f),y=m.has(f);b!==y&&console.debug(`[updateDerivedStatus] active channel ${f}: respondingChannelIds ${b} → ${y}`,`| channel.responding: ${p.channels[f]?.responding}`)}})},u={reconcileChannelFromBackend:async d=>{const{setLoading:p}=e(),m=`topicMessages-${d}`,g=e().channels[d];if(g?.responding){console.debug(`[reconcile] SKIP — channel is responding, topic=${d.slice(0,8)} msgs=${g.messages.length}`);return}console.groupCollapsed(`[reconcile] topic=${d.slice(0,8)} responding=${g?.responding} msgs=${g?.messages.length}`),console.debug(new Error().stack?.split(`
110
- `).slice(1,5).join(" <- ")),p(m,!0);try{const[h,f]=await Promise.all([hg.getMessages(d,{limit:Rte}),hg.getTokenStats(d).catch(()=>null)]),b=Bte(h);t(y=>{const v=y.channels[d];if(v){const _=new Set(b.map(E=>E.id)),w=v.messages.filter(E=>_.has(E.id)||E.dbId&&_.has(E.dbId)?!1:!!(E.status==="pending"||E.status==="streaming"||E.status==="thinking"||E.agentExecution)),x=new Set,k=[];for(const E of w){let S=-1;if(E.role==="assistant"){for(let I=b.length-1;I>=0;I--)if(b[I].role==="assistant"&&!x.has(I)){S=I;break}}if(S!==-1){const I=b[S];I.streamId=E.streamId,I.status=E.status,I.agentExecution=E.agentExecution,I.thinkingContent=E.thinkingContent,x.add(S)}else k.push(E)}const C=[...b,...k];console.debug(`[reconcile] OVERWRITE topic=${d.slice(0,8)} oldMsgs=${v.messages.length} dbMsgs=${b.length} preserved=${w.length} merged=${w.length-k.length} new=${k.length} responding=${v.responding}`),v.messages=C,v.hasOlderMessages=h.length>=Rte,f?.total_tokens!=null&&(v.tokenUsage=f.total_tokens),f?.input_tokens!=null&&(v.inputTokens=f.input_tokens),v.contextUsage=void 0,Eke(v)}}),i()}catch(h){console.error("Failed to reconcile topic messages:",h)}finally{console.groupEnd(),p(m,!1)}},updateDerivedStatus:i,closeIdleNonPrimaryConnection:d=>{setTimeout(()=>{e().channels[d]?.responding||e().activeChatChannel===d||Ub.disconnect(d)},0)},getAgentNameById:n,waitForChannelConnection:r};return{activeChatChannel:null,activeTopicByAgent:{},chatHistory:[],chatHistoryLoading:!0,channels:{},respondingChannelIds:new Set,runningAgentIds:new Set,activeTopicCountByAgent:{},notification:null,editingMessageId:null,editingContent:"",editingMode:null,setKnowledgeContext:(d,p)=>{t(m=>{m.channels[d]&&(m.channels[d].knowledgeContext=p||void 0)})},showNotification:(d,p,m="info",g,h)=>{t(f=>{f.notification={isOpen:!0,title:d,message:p,type:m,actionLabel:g,onAction:h}})},closeNotification:()=>{t({notification:null})},loadOlderMessages:async d=>{const p=e().channels[d];if(!p||p.loadingOlderMessages||!p.hasOlderMessages)return;const m=p.messages.find(g=>g.id);if(m?.id){t(g=>{const h=g.channels[d];h&&(h.loadingOlderMessages=!0)});try{const g=await hg.getMessages(d,{before:m.id,limit:Rte}),h=Bte(g);t(f=>{const b=f.channels[d];if(b){const y=new Set(b.messages.map(_=>_.id)),v=h.filter(_=>!y.has(_.id));b.messages=[...v,...b.messages],b.hasOlderMessages=g.length>=Rte,b.loadingOlderMessages=!1}})}catch(g){console.error("Failed to load older messages:",g),t(h=>{const f=h.channels[d];f&&(f.loadingOlderMessages=!1)})}}},...o8n(t,e,u),...$8n(t,e,u),...M8n(t,e,u)}},z8n={maxSize:10*1024*1024,maxFiles:5,maxTotalSize:20*1024*1024,allowedTypes:["image/jpeg","image/jpg","image/png","image/gif","image/webp","application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/json","application/xml","application/x-yaml","text/plain","text/markdown","text/csv","text/html","text/xml","text/yaml","text/x-yaml","audio/mpeg","audio/wav","audio/wave","audio/x-wav",".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"],autoUpload:!0};function jN(t){return(t/(1024*1024)).toFixed(1)}function yot(t){const e=t.slice(0,3).map(r=>r.name).join(", "),n=t.length>3?os.t("app.input.moreFilesSuffix",{count:t.length-3}):"";return e+n}function vot(t,e){switch(e.reason){case"file_too_large":return os.t("app.input.fileTooLargeDetail",{name:t.name,maxSize:jN(e.maxSize??t.size),actualSize:jN(e.actualSize??t.size)});case"unsupported_type":return os.t("app.input.unsupportedFileTypeDetail",{name:t.name});default:return e.error||t.name}}const U8n=(t,e)=>({uploadedFiles:[],isUploading:!1,uploadError:null,fileUploadOptions:{...z8n},validateFiles:n=>{const r=e(),i=r.fileUploadOptions,o=r.uploadedFiles,l=[];o.length+n.length>(i.maxFiles||5)&&l.push(`Maximum ${i.maxFiles} files allowed. You have ${o.length} files and are trying to add ${n.length} more.`);for(const m of n){const g=go.validateFile(m,{maxSize:i.maxSize,allowedTypes:i.allowedTypes});g.valid||l.push(vot(m,g))}const u=r.getTotalSize(),d=n.reduce((m,g)=>m+g.size,0),p=u+d;return p>(i.maxTotalSize||20*1024*1024)&&l.push(os.t("app.input.totalSizeExceededMessage",{maxSize:jN(i.maxTotalSize||20*1024*1024),actualSize:jN(p)})),{valid:l.length===0,errors:l.length>0?l:void 0,error:l.length>0?l.join("; "):void 0}},addFiles:async n=>{const r=e(),i=r.fileUploadOptions,o=r.uploadedFiles,l=[],u=[],d=[];for(const C of n){const E=go.validateFile(C,{maxSize:i.maxSize,allowedTypes:i.allowedTypes});E.valid?l.push(C):(u.push({file:C,validation:E}),d.push(vot(C,E)))}const p=u.filter(({validation:C})=>C.reason==="file_too_large").map(({file:C})=>C);p.length>0&&e().showNotification(os.t("app.input.fileTooLargeTitle"),os.t("app.input.fileTooLargeMessage",{files:yot(p),maxSize:jN(i.maxSize||10*1024*1024)}),"warning");const m=u.filter(({validation:C})=>C.reason==="unsupported_type").map(({file:C})=>C);m.length>0&&e().showNotification(os.t("app.input.unsupportedFilesTitle"),os.t("app.input.unsupportedFilesMessage",{files:yot(m)}),"warning");const g=Math.max(0,(i.maxFiles||5)-o.length);if(g===0){const C=os.t("app.dragDrop.maxReached");t({uploadError:C}),e().showNotification(os.t("app.input.fileLimitTitle"),C,"warning");return}const h=l.slice(0,g);l.slice(g).length>0&&e().showNotification(os.t("app.input.fileLimitTitle"),os.t("app.input.fileLimitMessage",{count:g}),"warning");const b=i.maxTotalSize||20*1024*1024,y=r.getTotalSize(),v=y+h.reduce((C,E)=>C+E.size,0);let _=y;const w=[],x=[];for(const C of h){if(_+C.size>b){x.push(C);continue}w.push(C),_+=C.size}if(x.length>0){const C=os.t("app.input.totalSizeExceededMessage",{maxSize:jN(b),actualSize:jN(v)});t({uploadError:C}),e().showNotification(os.t("app.input.totalSizeExceededTitle"),C,"warning")}if(w.length===0){d.length>0&&t({uploadError:d.join("; ")});return}const k=w.map(C=>({id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,file:C,name:C.name,size:C.size,type:C.type,category:go.getFileCategory(C),status:"pending",progress:0,createdAt:new Date}));if(t(C=>({uploadedFiles:[...C.uploadedFiles,...k],uploadError:d.length>0?d.join("; "):null})),r.fileUploadOptions.autoUpload)for(const C of k)await r.uploadFile(C.file)},uploadFile:async n=>{const i=e().uploadedFiles.find(o=>o.file===n);if(!i)return null;try{if(t(p=>({uploadedFiles:p.uploadedFiles.map(m=>m.id===i.id?{...m,status:"uploading",progress:0}:m),isUploading:!0})),n.type.startsWith("image/"))try{const p=await go.generateThumbnail(n);t(m=>({uploadedFiles:m.uploadedFiles.map(g=>g.id===i.id?{...g,thumbnailUrl:p}:g)}))}catch(p){console.warn("Failed to generate thumbnail:",p)}const o=e().activeChatChannel,u=(o?e().channels[o]:null)?.knowledge_set_id??null,d=await go.uploadChatAttachment(n,"private",i.category,null,u,p=>{t(m=>({uploadedFiles:m.uploadedFiles.map(g=>g.id===i.id?{...g,progress:p.percentage}:g)}))});return t(p=>({uploadedFiles:p.uploadedFiles.map(m=>m.id===i.id?{...m,status:"completed",progress:100,uploadedId:d.id,downloadUrl:d.download_url}:m),isUploading:p.uploadedFiles.some(m=>m.id!==i.id&&m.status==="uploading")})),d.id}catch(o){const l=o instanceof Error?o.message:"Upload failed";return t(u=>({uploadedFiles:u.uploadedFiles.map(d=>d.id===i.id?{...d,status:"error",error:l}:d),isUploading:u.uploadedFiles.some(d=>d.id!==i.id&&d.status==="uploading"),uploadError:l})),null}},removeFile:n=>{const i=e().uploadedFiles.find(o=>o.id===n);i?.uploadedId&&go.deleteFile(i.uploadedId,!1).catch(o=>{console.error("Failed to delete file from server:",o)}),t(o=>({uploadedFiles:o.uploadedFiles.filter(l=>l.id!==n)}))},clearFiles:(n=!1)=>{const r=e();if(n){const i=r.uploadedFiles.filter(o=>o.uploadedId).map(o=>o.uploadedId);i.length>0&&go.bulkDeleteFiles(i).catch(o=>{console.error("Failed to delete files from server:",o)})}t({uploadedFiles:[],isUploading:!1,uploadError:null})},confirmFilesForMessage:async n=>{const i=e().uploadedFiles.filter(o=>o.uploadedId&&o.status==="completed").map(o=>o.uploadedId);if(i.length>0)try{await go.confirmFiles(i,n),t({uploadedFiles:[]})}catch(o){throw console.error("Failed to confirm files:",o),o}},cancelUpload:n=>{t(r=>({uploadedFiles:r.uploadedFiles.map(i=>i.id===n?{...i,status:"error",error:"Cancelled"}:i)}))},retryUpload:async n=>{const r=e(),i=r.uploadedFiles.find(o=>o.id===n);i&&await r.uploadFile(i.file)},updateFileUploadOptions:n=>{t(r=>({fileUploadOptions:{...r.fileUploadOptions,...n}}))},getTotalSize:()=>e().uploadedFiles.reduce((r,i)=>r+i.size,0),canAddMoreFiles:()=>{const n=e();return n.uploadedFiles.length<(n.fileUploadOptions.maxFiles||5)}});class q8n{async createFolder(e){return nn.post("/xyzen/api/v1/folders/",e)}async listFolders(e=null,n=!1,r){return nn.get("/xyzen/api/v1/folders/",{params:{parent_id:e??void 0,include_deleted:n||void 0,knowledge_set_id:r}})}async getTree(e,n){return nn.get("/xyzen/api/v1/folders/tree",{params:{knowledge_set_id:e,only_deleted:n||void 0}})}async getFolder(e){return nn.get(`/xyzen/api/v1/folders/${e}`)}async getFolderPath(e){return nn.get(`/xyzen/api/v1/folders/${e}/path`)}async updateFolder(e,n){return nn.patch(`/xyzen/api/v1/folders/${e}`,n)}async deleteFolder(e,n=!1){return nn.delete(`/xyzen/api/v1/folders/${e}`,void 0,{params:{hard_delete:n}})}}const bf=new q8n,G8n=(t,e)=>({knowledgeActiveTab:"home",knowledgeFolderId:null,knowledgeSetId:null,knowledgeTreeItems:[],knowledgeTreeLoading:!1,knowledgeTreeSignal:0,trashTreeItems:[],trashTreeLoading:!1,navigateKnowledge:(n,r=null)=>{t(i=>{i.knowledgeActiveTab=n,i.knowledgeSetId=n==="knowledge"?r??null:null,i.knowledgeFolderId=null})},setKnowledgeFolderId:n=>{t(r=>{r.knowledgeFolderId=n})},fetchKnowledgeTree:async()=>{const{knowledgeActiveTab:n,knowledgeSetId:r}=e();if(n==="trash"){t(i=>{i.trashTreeLoading=!0});try{const i=await bf.getTree(void 0,!0);t(o=>{o.trashTreeItems=i,o.trashTreeLoading=!1})}catch(i){console.error("Failed to fetch trash tree",i),t(o=>{o.trashTreeLoading=!1})}return}if(!(n!=="all"&&n!=="knowledge"&&n!=="images"&&n!=="documents")){if(n==="knowledge"&&!r){t(i=>{i.knowledgeTreeItems=[],i.knowledgeTreeLoading=!1});return}t(i=>{i.knowledgeTreeLoading=!0});try{const i=n==="knowledge"?r??void 0:void 0,o=await bf.getTree(i);t(l=>{l.knowledgeTreeItems=o,l.knowledgeTreeLoading=!1})}catch(i){console.error("Failed to fetch knowledge tree",i),t(o=>{o.knowledgeTreeLoading=!1})}}},refreshKnowledge:()=>{t(n=>{n.knowledgeTreeSignal+=1})},removeTreeItems:n=>{t(r=>{const i=new Set(n);r.knowledgeActiveTab==="trash"?r.trashTreeItems=r.trashTreeItems.filter(o=>!i.has(o.id)):r.knowledgeTreeItems=r.knowledgeTreeItems.filter(o=>!i.has(o.id))})},renameTreeItem:(n,r)=>{t(i=>{const l=(i.knowledgeActiveTab==="trash"?i.trashTreeItems:i.knowledgeTreeItems).find(u=>u.id===n);l&&(l.name=r)})}}),H8n=(t,e)=>({loadingStates:{},setLoading:(n,r)=>{t(i=>{r?i.loadingStates[n]=!0:delete i.loadingStates[n]})},getLoading:n=>e().loadingStates[n]||!1,clearAllLoading:()=>{t(n=>{n.loadingStates={}})}}),PA={MCP_SERVERS:"mcpServers",MCP_SERVER_CREATE:"mcpServerCreate",MCP_SERVER_UPDATE:"mcpServerUpdate",MCP_SERVER_DELETE:"mcpServerDelete"},N1={async getMcpServers(){return nn.get("/xyzen/api/v1/mcps")},async createMcpServer(t){return nn.post("/xyzen/api/v1/mcps",t)},async updateMcpServer(t,e){return nn.patch(`/xyzen/api/v1/mcps/${t}`,e)},async deleteMcpServer(t){return nn.delete(`/xyzen/api/v1/mcps/${t}`)},async refreshMcpServers(){return nn.post("/xyzen/api/v1/mcps/refresh")},async activateSmitheryServer(t,e){return nn.post("/xyzen/api/v1/mcps/smithery/activate",{qualifiedName:t,profile:e})},async getBuiltinMcpServers(){try{return await nn.get("/xyzen/api/v1/mcps/discover")}catch(t){return console.warn("Error discovering builtin MCP servers:",t),[]}},async getBuiltinSearchServers(){try{return await nn.get("/xyzen/api/v1/mcps/search-servers/discover")}catch(t){return console.warn("Error discovering builtin search servers:",t),[]}},async getSearchServers(){return nn.get("/xyzen/api/v1/mcps")},async getSessionSearchEngine(t){try{return await nn.get(`/xyzen/api/v1/sessions/${t}/search-engine`)}catch(e){if(e instanceof Error&&"status"in e&&e.status===404)return null;throw e}},async setSessionSearchEngine(t,e){return nn.put(`/xyzen/api/v1/sessions/${t}/search-engine`,{mcp_server_id:e})},async removeSessionSearchEngine(t){return nn.delete(`/xyzen/api/v1/sessions/${t}/search-engine`)},async testTool(t,e,n){return nn.post(`/xyzen/api/v1/mcps/${t}/tools/${e}/test`,{parameters:n})}};function W8n(t){if("data"in t&&"source"in t&&t.source==="official")return t;const e=t,n={name:e.name,module_name:e.module_name,mount_path:e.mount_path,description:e.description,is_builtin:!0,requires_auth:e.requires_auth||!1,is_default:e.is_default,banner:e.banner};return{id:e.module_name,name:e.name,description:e.description,source:"official",cover:e.banner,data:n}}function Y8n(t){return Array.isArray(t)?t.filter(e=>e&&typeof e=="object").map(e=>W8n(e)):(console.warn("convertBuiltinServers: input is not an array",t),[])}const V8n=(t,e)=>({mcpServers:[],builtinMcpServers:[],lastFetchTime:0,isEditMcpServerModalOpen:!1,editingMcpServer:null,openEditMcpServerModal:n=>{t({isEditMcpServerModalOpen:!0,editingMcpServer:n})},closeEditMcpServerModal:()=>{t({isEditMcpServerModalOpen:!1,editingMcpServer:null})},fetchMcpServers:async()=>{const{setLoading:n}=e(),r=Date.now(),{lastFetchTime:i}=e();if(r-i<5e3){console.log("McpSlice: 使用缓存的MCP服务器数据");return}n(PA.MCP_SERVERS,!0);try{console.log("McpSlice: Starting to fetch MCP servers...");const o=await N1.getMcpServers();console.log(`McpSlice: Loaded ${o.length} MCP servers`),t({mcpServers:o,lastFetchTime:r})}catch(o){console.error("Failed to fetch MCP servers:",o)}finally{n(PA.MCP_SERVERS,!1)}},fetchBuiltinMcpServers:async()=>{try{const n=await N1.getBuiltinMcpServers(),r=Y8n(n),{mcpServers:i,backendUrl:o}=e(),l=i.map(d=>d.url),u=r.filter(d=>{const p=d.data.mount_path.endsWith("/")?d.data.mount_path:`${d.data.mount_path}/`,m=`${o}${p}`;return!l.includes(m)});t({builtinMcpServers:u})}catch(n){console.error("Failed to fetch builtin MCP servers:",n),t({builtinMcpServers:[]})}},refreshMcpServers:async()=>{const{setLoading:n}=e();n(PA.MCP_SERVERS,!0);try{await N1.refreshMcpServers(),setTimeout(()=>{e().fetchMcpServers()},1e3)}catch(r){console.error("Failed to refresh MCP servers:",r)}finally{setTimeout(()=>n(PA.MCP_SERVERS,!1),1500)}},addMcpServer:async n=>{const{setLoading:r}=e();r(PA.MCP_SERVER_CREATE,!0);try{const i=await N1.createMcpServer(n);t(o=>{o.mcpServers.push(i)}),e().closeAddMcpServerModal()}catch(i){throw console.error("Failed to add MCP server:",i),i}finally{r(PA.MCP_SERVER_CREATE,!1)}},quickAddBuiltinServer:async n=>{const{backendUrl:r,token:i,setLoading:o}=e();o(PA.MCP_SERVER_CREATE,!0);try{const l=n.data.mount_path.endsWith("/")?n.data.mount_path:`${n.data.mount_path}/`,u={name:n.name,description:n.description,url:`${r}${l}`,token:i||""},d=await N1.createMcpServer(u);return t(p=>{p.mcpServers.push(d),p.builtinMcpServers=p.builtinMcpServers.filter(m=>m.data.module_name!==n.data.module_name)}),e().closeAddMcpServerModal(),d}catch(l){throw console.error("Failed to add builtin MCP server:",l),l}finally{o(PA.MCP_SERVER_CREATE,!1)}},activateSmitheryServer:async(n,r)=>{const{setLoading:i}=e();i(PA.MCP_SERVER_CREATE,!0);try{const o=await N1.activateSmitheryServer(n,r);t(l=>{l.mcpServers.push(o)}),e().closeAddMcpServerModal()}catch(o){throw console.error("Failed to activate Smithery MCP server:",o),o}finally{i(PA.MCP_SERVER_CREATE,!1)}},editMcpServer:async(n,r)=>{const{setLoading:i}=e();i(PA.MCP_SERVER_UPDATE,!0);try{const o=await N1.updateMcpServer(n,r);t(l=>{const u=l.mcpServers.findIndex(d=>d.id===n);u!==-1&&(l.mcpServers[u]=o)})}catch(o){throw console.error("Failed to edit MCP server:",o),o}finally{i(PA.MCP_SERVER_UPDATE,!1)}},removeMcpServer:async n=>{const{setLoading:r}=e();r(PA.MCP_SERVER_DELETE,!0);try{await N1.deleteMcpServer(n),t(i=>{i.mcpServers=i.mcpServers.filter(o=>o.id!==n)})}catch(i){throw console.error("Failed to remove MCP server:",i),i}finally{r(PA.MCP_SERVER_DELETE,!1)}},updateMcpServerInList:n=>{t(r=>{const i=r.mcpServers.findIndex(o=>o.id===n.id);i!==-1?r.mcpServers[i]=n:r.mcpServers.push(n)})}}),K8n=(t,e)=>({toolTestModal:{isOpen:!1},toolExecutionHistory:[],openToolTestModal:(n,r,i)=>{t(o=>{o.toolTestModal={isOpen:!0,server:n,toolName:r,toolDescription:i}})},closeToolTestModal:()=>{t(n=>{n.toolTestModal={isOpen:!1}})},addToolExecution:n=>{t(r=>{const i={...n,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,timestamp:new Date};r.toolExecutionHistory.unshift(i),r.toolExecutionHistory.length>100&&(r.toolExecutionHistory=r.toolExecutionHistory.slice(0,100))})},clearToolExecutionHistory:()=>{t(n=>{n.toolExecutionHistory=[]})},getToolExecutionHistory:(n,r)=>{const{toolExecutionHistory:i}=e();return!n&&!r?i:i.filter(o=>{const l=!n||o.serverId===n,u=!r||o.toolName===r;return l&&u})}}),Z8n=t=>({notificationEnabled:!1,novuAppIdentifier:"",novuApiUrl:"",novuWsUrl:"",pushPermission:typeof Notification<"u"&&typeof Notification.permission=="string"?Notification.permission:"default",pushSubscribed:!1,setNotificationConfig:(e,n,r,i)=>{t(o=>{o.notificationEnabled=e,o.novuAppIdentifier=n,o.novuApiUrl=r,o.novuWsUrl=i})},setPushPermission:e=>{t(n=>{n.pushPermission=e})},setPushSubscribed:e=>{t(n=>{n.pushSubscribed=e})}});class Ike{static STORAGE_KEY="xyzen_provider_preferences";static getPreferences(){try{const e=localStorage.getItem(this.STORAGE_KEY);if(e){const n=JSON.parse(e);return{defaultProviderId:n.defaultProviderId||null,lastUsedProviders:n.lastUsedProviders||{}}}}catch(e){console.warn("Failed to load provider preferences:",e)}return{defaultProviderId:null,lastUsedProviders:{}}}static savePreferences(e){try{localStorage.setItem(this.STORAGE_KEY,JSON.stringify(e))}catch(n){console.error("Failed to save provider preferences:",n)}}static setDefaultProvider(e){const n=this.getPreferences();n.defaultProviderId=e,this.savePreferences(n)}static getDefaultProviderId(){return this.getPreferences().defaultProviderId}static getDefaultProvider(e){const n=this.getDefaultProviderId();return n&&e.find(r=>r.id===n)||null}static setLastUsedProviderForAgent(e,n){const r=this.getPreferences();r.lastUsedProviders[e]=n,this.savePreferences(r)}static getLastUsedProviderForAgent(e){return this.getPreferences().lastUsedProviders[e]||null}static clearPreferences(){try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.error("Failed to clear provider preferences:",e)}}static migrateFromDatabaseDefault(e){if(!this.getPreferences().defaultProviderId){const r=e.find(i=>i.is_default&&!i.is_system);r&&(console.info("Migrating database default provider to local preferences:",r.name),this.setDefaultProvider(r.id))}}}function X8n(t,e){if(t?.provider_id){const o=e.find(l=>l.id===t.provider_id);if(o)return o}const n=Ike.getDefaultProvider(e);if(n&&!n.is_system)return n;const r=e.find(o=>o.is_system);return r||e.filter(o=>!o.is_system)[0]||null}const J8n=(t,e)=>({userDefaultProviderId:null,initializeProviderPreferences:()=>{const n=Ike.getDefaultProviderId();t({userDefaultProviderId:n})},setUserDefaultProvider:n=>{Ike.setDefaultProvider(n),t({userDefaultProviderId:n})},getUserDefaultProvider:n=>{const{userDefaultProviderId:r}=e();return r&&n.find(i=>i.id===r)||null},resolveProviderForAgent:(n,r)=>X8n(n,r),llmProviders:[],llmProvidersLoading:!1,providerTemplates:[],templatesLoading:!1,availableModels:{},availableModelsLoading:!1,fetchProviderTemplates:async()=>{console.warn("[DEPRECATED] fetchProviderTemplates is deprecated. Use useProviderTemplates() hook instead.")},fetchMyProviders:async()=>{console.warn("[DEPRECATED] fetchMyProviders is deprecated. Use useMyProviders() hook instead."),e().initializeProviderPreferences()},fetchAvailableModels:async()=>{console.warn("[DEPRECATED] fetchAvailableModels is deprecated. Use useAvailableModels() hook instead.")},addProvider:async()=>{throw console.warn("[DEPRECATED] addProvider is deprecated. Use useCreateProvider().mutateAsync instead."),new Error("addProvider is deprecated. Use useCreateProvider().mutateAsync instead.")},updateProvider:async()=>{throw console.warn("[DEPRECATED] updateProvider is deprecated. Use useUpdateProvider().mutateAsync instead."),new Error("updateProvider is deprecated. Use useUpdateProvider().mutateAsync instead.")},removeProvider:async()=>{throw console.warn("[DEPRECATED] removeProvider is deprecated. Use useDeleteProvider().mutateAsync instead."),new Error("removeProvider is deprecated. Use useDeleteProvider().mutateAsync instead.")}});class e6n{async listRunners(){return nn.get("/xyzen/api/v1/runners/")}async createRunnerToken(e){return nn.post("/xyzen/api/v1/runners/token",{name:e})}async updateRunner(e,n){return nn.patch(`/xyzen/api/v1/runners/${e}`,n)}async deleteRunner(e){return nn.delete(`/xyzen/api/v1/runners/${e}`)}}const Lte=new e6n;class t6n{ws=null;handlers=new Map;reconnectTimer=null;reconnectDelay=1e3;maxReconnectDelay=3e4;intentionalClose=!1;connect(){if(this.ws?.readyState===WebSocket.OPEN)return;const e=Di.getToken();if(!e)return;const n=sd().env.backendUrl;if(!n)return;const r=`${n.replace(/^http(s?):\/\//,"ws$1://")}/xyzen/ws/v1/user/events?token=${encodeURIComponent(e)}`;this.intentionalClose=!1;try{this.ws=new WebSocket(r)}catch{this.scheduleReconnect();return}this.ws.onopen=()=>{this.reconnectDelay=1e3},this.ws.onmessage=i=>{try{const o=JSON.parse(i.data);if(o.type==="pong")return;const l=this.handlers.get(o.type);if(l)for(const u of l)u(o)}catch{}},this.ws.onclose=()=>{this.ws=null,this.intentionalClose||this.scheduleReconnect()},this.ws.onerror=()=>{}}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}on(e,n){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(n),()=>{r.delete(n),r.size===0&&this.handlers.delete(e)}}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*2,this.maxReconnectDelay),this.connect()},this.reconnectDelay))}}const X5=new t6n,n6n=(t,e)=>({runners:[],runnersLoading:!1,fetchRunners:async()=>{t({runnersLoading:!0});try{const n=await Lte.listRunners();t({runners:n,runnersLoading:!1})}catch{t({runnersLoading:!1})}},createRunnerToken:async n=>{try{const r=await Lte.createRunnerToken(n);return t(i=>{i.runners.unshift(r.runner)}),{runner:r.runner,token:r.token,connect_command:r.connect_command}}catch{return null}},deleteRunner:async n=>{try{await Lte.deleteRunner(n),t(r=>{r.runners=r.runners.filter(i=>i.id!==n)})}catch{}},updateRunner:async(n,r)=>{try{const i=await Lte.updateRunner(n,r);t(o=>{const l=o.runners.findIndex(u=>u.id===n);l>=0&&(o.runners[l]=i)})}catch{}},connectRunnerEvents:()=>{X5.connect();const n=X5.on("runner_status",r=>{const{runner_id:i,is_online:o}=r.data;let l=!1;if(t(u=>{const d=u.runners.find(p=>p.id===i);d&&(l=!0,d.is_online=o)}),!l){e().fetchRunners();return}e().fetchRunners()});return()=>{n(),X5.disconnect()}}}),r6n=t=>({isTerminalOpen:!1,activeSessionId:null,terminalSessions:{},pendingCommand:"",pendingArgs:[],pendingRunnerId:null,openTerminal:(e="",n=[],r)=>{t(i=>{i.isTerminalOpen=!0,i.pendingCommand=e,i.pendingArgs=n,i.pendingRunnerId=r??null})},closeTerminalModal:()=>{t(e=>{e.isTerminalOpen=!1})},addSession:e=>{t(n=>{n.terminalSessions[e.id]=e,n.activeSessionId=e.id})},updateSession:(e,n)=>{t(r=>{const i=r.terminalSessions[e];i&&Object.assign(i,n)})},removeSession:e=>{t(n=>{if(delete n.terminalSessions[e],n.activeSessionId===e){const r=Object.keys(n.terminalSessions);n.activeSessionId=r.length>0?r[0]:null}})},setActiveSession:e=>{t({activeSessionId:e})}}),_ot={Sidebar:"sidebar"},a6n=t=>({backendUrl:sd().env.backendUrl,isXyzenOpen:!1,panelWidth:Ske,activeTabIndex:0,activePanel:"chat",theme:sd().storage.getItem("theme")||"system",layoutStyle:sd().storage.getItem("layoutStyle")||sd().env.layoutStyle||_ot.Sidebar,inputPosition:sd().storage.getItem("inputPosition")||"bottom",isMcpListModalOpen:!1,isLlmProvidersModalOpen:!1,isAddMcpServerModalOpen:!1,isAddLlmProviderModalOpen:!1,isSettingsModalOpen:!1,activeSettingsCategory:"account",activeUiSetting:"theme",selectedProviderId:null,pendingInput:"",spatialSidebarCollapsed:!1,capsuleOpen:!1,capsuleActiveTab:"knowledge",showOfficialRecommendations:sd().storage.getItem("officialRecommendationsDismissed")!=="true",mobileCeoOverlay:!0,mobilePage:0,pendingFocusAgentId:null,highlightMessageId:null,dockMinimized:!1,openTabsByAgent:{},toggleXyzen:()=>t(e=>({isXyzenOpen:!e.isXyzenOpen})),openXyzen:()=>t({isXyzenOpen:!0}),closeXyzen:()=>t({isXyzenOpen:!1}),setPanelWidth:e=>t({panelWidth:e}),setTabIndex:e=>t({activeTabIndex:e}),setActivePanel:e=>t({activePanel:e}),setTheme:e=>{sd().storage.setItem("theme",e),t({theme:e})},setLayoutStyle:e=>{sd().storage.setItem("layoutStyle",e),t({layoutStyle:e})},setInputPosition:e=>{sd().storage.setItem("inputPosition",e),t({inputPosition:e})},setBackendUrl:e=>{sd().env.backendUrl=e,t({backendUrl:e})},openMcpListModal:()=>t({isMcpListModalOpen:!0}),closeMcpListModal:()=>t({isMcpListModalOpen:!1}),openLlmProvidersModal:()=>t({isLlmProvidersModalOpen:!0}),closeLlmProvidersModal:()=>t({isLlmProvidersModalOpen:!1}),openAddMcpServerModal:()=>t({isAddMcpServerModalOpen:!0}),closeAddMcpServerModal:()=>t({isAddMcpServerModalOpen:!1}),openAddLlmProviderModal:()=>t({isAddLlmProviderModalOpen:!0}),closeAddLlmProviderModal:()=>t({isAddLlmProviderModalOpen:!1}),openSettingsModal:(e="account")=>t({isSettingsModalOpen:!0,activeSettingsCategory:e}),closeSettingsModal:()=>t({isSettingsModalOpen:!1,selectedProviderId:null}),setActiveSettingsCategory:e=>t({activeSettingsCategory:e}),setActiveUiSetting:e=>t({activeUiSetting:e}),setSelectedProvider:e=>t({selectedProviderId:e}),setPendingInput:e=>t({pendingInput:e}),submitInput:()=>t(()=>({isXyzenOpen:!0,activeTabIndex:1,activePanel:"chat"})),setSpatialSidebarCollapsed:e=>t({spatialSidebarCollapsed:e}),setCapsuleOpen:e=>t({capsuleOpen:e}),setCapsuleActiveTab:e=>t({capsuleActiveTab:e}),setShowOfficialRecommendations:e=>{sd().storage.setItem("officialRecommendationsDismissed",e?"false":"true"),t({showOfficialRecommendations:e})},setMobileCeoOverlay:e=>t({mobileCeoOverlay:e}),setMobilePage:e=>t({mobilePage:e}),requestFocusAgent:e=>t({pendingFocusAgentId:e}),highlightMessage:e=>t({highlightMessageId:e}),openTab:(e,n)=>t(r=>{const i=r.openTabsByAgent[e]??[];i.some(o=>o.id===n.id)||(r.openTabsByAgent[e]=[...i,n])}),closeTab:(e,n)=>t(r=>{const i=r.openTabsByAgent[e];i&&(r.openTabsByAgent[e]=i.filter(o=>o.id!==n))}),setOpenTabs:(e,n)=>t(r=>{r.openTabsByAgent[e]=n}),setDockMinimized:e=>t({dockMinimized:e}),renameTab:(e,n)=>t(r=>{for(const i of Object.values(r.openTabsByAgent)){const o=i.find(l=>l.id===e);if(o){o.name=n;break}}})});class i6n{async redeemCode(e){return nn.post("/xyzen/api/v1/redemption/redeem",{code:e})}async getUserWallet(){return nn.get("/xyzen/api/v1/redemption/wallet")}async getRedemptionHistory(e=100,n=0){return nn.get("/xyzen/api/v1/redemption/history",{params:{limit:e,offset:n}})}async getDailyTokenStats(e,n,r){return nn.get("/xyzen/api/v1/redemption/admin/stats/daily-tokens",{auth:!1,headers:{"X-Admin-Secret":e},params:{date:n,tz:r}})}async getTopUsersByConsumption(e,n=20){return nn.get("/xyzen/api/v1/redemption/admin/stats/top-users",{auth:!1,headers:{"X-Admin-Secret":e},params:{limit:n}})}async getConsumeRecords(e,n,r,i,o=1e4,l=0){return nn.get("/xyzen/api/v1/redemption/admin/stats/consume-records",{auth:!1,headers:{"X-Admin-Secret":e},params:{start_date:n,end_date:r,tz:i,limit:o,offset:l}})}async getAllConsumeRecords(e,n,r,i,o=1e4){const l=[];let u=0;for(;;){const d=await this.getConsumeRecords(e,n,r,i,o,u);if(l.push(...d),d.length<o)break;u+=o}return l}async getUserActivityStats(e,n,r,i){return nn.get("/xyzen/api/v1/redemption/admin/stats/user-activity",{auth:!1,headers:{"X-Admin-Secret":e},params:{start_date:n,end_date:r,tz:i}})}async adminListCodes(e,n=50){return nn.get("/xyzen/api/v1/redemption/admin/codes",{auth:!1,headers:{"X-Admin-Secret":e},params:{limit:n}})}async adminCreateCode(e,n){return nn.post("/xyzen/api/v1/redemption/admin/codes",n,{auth:!1,headers:{"X-Admin-Secret":e}})}async adminDeactivateCode(e,n){return nn.post(`/xyzen/api/v1/redemption/admin/codes/${n}/deactivate`,void 0,{auth:!1,headers:{"X-Admin-Secret":e}})}async getConsumptionHeatmap(e,n,r,i,o,l,u){return nn.get("/xyzen/api/v1/redemption/admin/stats/consumption-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,model_tier:i,model_name:o,provider:l,tool_name:u}})}async getUserConsumptionHeatmap(e,n,r,i,o,l,u){return nn.get("/xyzen/api/v1/redemption/admin/stats/user-consumption-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,model_tier:i,model_name:o,provider:l,tool_name:u}})}async getConsumptionTopUsers(e,n,r,i,o,l,u=20,d,p,m,g){return nn.get("/xyzen/api/v1/redemption/admin/stats/consumption-top-users",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,date:i,model_tier:o,model_name:l,limit:u,search:d,provider:p,include_tiers:m||void 0,tool_name:g}})}async getRedemptionHeatmap(e,n,r){return nn.get("/xyzen/api/v1/redemption/admin/stats/redemption-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r}})}async getRedemptionRankings(e,n,r,i,o=20,l){return nn.get("/xyzen/api/v1/redemption/admin/stats/redemption-rankings",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,date:i,limit:o,search:l}})}async getNewUsersHeatmap(e,n,r){return nn.get("/xyzen/api/v1/redemption/admin/stats/new-users-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r}})}async getFilterOptions(e,n,r,i){return nn.get("/xyzen/api/v1/redemption/admin/stats/filter-options",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,provider:i}})}async getModelOptions(e){return nn.get("/xyzen/api/v1/redemption/admin/stats/model-options",{auth:!1,headers:{"X-Admin-Secret":e}})}async getCreditSources(e){return nn.get("/xyzen/api/v1/redemption/admin/stats/credit-sources",{auth:!1,headers:{"X-Admin-Secret":e}})}async getCreditHeatmap(e,n,r,i,o){return nn.get("/xyzen/api/v1/redemption/admin/stats/credit-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,source:i,tier:o}})}async getCreditRankings(e,n,r,i,o,l,u=20,d){return nn.get("/xyzen/api/v1/redemption/admin/stats/credit-rankings",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,source:i,tier:o,date:l,limit:u,search:d}})}}const OA=new i6n,s6n=t=>({walletBalance:null,walletLoading:!1,fetchWallet:async()=>{t({walletLoading:!0});try{const e=await OA.getUserWallet();t({walletBalance:{free:e.free_balance,paid:e.paid_balance,earned:e.earned_balance,total:e.virtual_balance},walletLoading:!1})}catch{t({walletLoading:!1})}},connectWalletEvents:()=>{X5.connect();const e=X5.on("credit_updated",n=>{const r=n.data;t({walletBalance:{free:r.free_balance??0,paid:r.paid_balance??0,earned:r.earned_balance??0,total:r.virtual_balance??0}})});return()=>{e(),X5.disconnect()}},_handleCreditUpdated:e=>{t({walletBalance:{free:e.free_balance??0,paid:e.paid_balance??0,earned:e.earned_balance??0,total:e.virtual_balance??0}})}});let Tke=null;function o6n(t){Tke=t}function az(){if(!Tke)throw new Error("toolbarActions not initialized — call initToolbarActions() at app startup");return Tke()}async function l6n(t,e){try{await az()(t,{model_tier:e,provider_id:null,model:null})}catch(n){console.error("Failed to update session tier:",n)}}async function c6n(t,e,n,r){try{await az()(t,{model_tier:e,provider_id:n,model:r})}catch(i){console.error("Failed to update session tier model:",i)}}async function u6n(t,e,n){try{await az()(t,{model_tier:null,provider_id:e,model:n})}catch(r){console.error("Failed to update custom model:",r)}}async function d6n(t,e){try{await az()(t,{sandbox_backend:e})}catch(n){console.error("Failed to update session sandbox backend:",n)}}async function p6n(t,e){try{await az()(t,{knowledge_set_id:e})}catch(n){console.error("Failed to update session knowledge set:",n)}}qOn(not),nn.configure({getToken:()=>Di.getToken(),onRefreshToken:async()=>(await Di.refreshAccessToken())?.access_token??null,onUnauthorized:()=>{Promise.resolve().then(()=>XOn).then(t=>t.logout()).catch(()=>{})}}),AFn();let m6n;const g6n={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},Un=wFn()(Zst(IFn((...t)=>({...a6n(...t),...j8n(...t),...PFn(...t),...V8n(...t),...K8n(...t),...J8n(...t),...OFn(...t),...H8n(...t),...U8n(...t),...G8n(...t),...Z8n(...t),...n6n(...t),...r6n(...t),...s6n(...t)})),{name:"xyzen-storage",storage:Kst(()=>m6n??(typeof localStorage<"u"?localStorage:g6n)),partialize:t=>({isXyzenOpen:t.isXyzenOpen,panelWidth:t.panelWidth,activePanel:t.activePanel,theme:t.theme,token:t.token,user:t.user,activeChatChannel:t.activeChatChannel,spatialSidebarCollapsed:t.spatialSidebarCollapsed,capsuleOpen:t.capsuleOpen,capsuleActiveTab:t.capsuleActiveTab,mobileCeoOverlay:t.mobileCeoOverlay,mobilePage:t.mobilePage,openTabsByAgent:t.openTabsByAgent,terminalSessions:t.terminalSessions}),onRehydrateStorage:()=>t=>{if(!t)return;const e=t.terminalSessions;if(e)for(const n of Object.keys(e)){const r=e[n];(r.status==="connected"||r.status==="connecting"||r.status==="reconnecting")&&(r.status="detached")}}}));if(ZOn(Un),o6n(()=>Un.getState().updateSessionConfig),typeof window<"u"){const t=new Map;Un.subscribe(e=>{const n=e.activeChatChannel;if(!n)return;const r=e.channels[n];if(!r)return;const i=t.get(n)??0,o=r.messages.length;i>0&&o<i&&console.error(`[DIAGNOSTIC] MESSAGE COUNT DROP: ${n.slice(0,8)} ${i} → ${o}`,`| responding=${r.responding}`,`| latestAssist=${(()=>{const l=[...r.messages].reverse().find(u=>u.role==="assistant");return l?`id=${l.id.slice(0,12)} agentExec=${l.agentExecution?.status}`:"none"})()}`,new Error("trace").stack),t.set(n,o)})}function h6n(t){return Un.getState().status!=="succeeded"&&localStorage.getItem("platform")==="bohrium"?(t("provider_bohrium"),!0):!1}async function Bke(){try{const t=await Di.getAuthStatus();if(!t.is_configured||!t.provider)throw new Error("Authentication is not configured");const e=await Di.getAuthConfig(),n=t.provider,r=`${window.location.origin}${window.location.pathname}`;let i=null;if(n==="casdoor"){const o=Math.random().toString(36).substring(7);sessionStorage.setItem("auth_state",o),i=MN(n,e,r,o)}else i=MN(n,e,r);if(i)window.location.href=i;else throw new Error(`Unsupported auth provider: ${n}`)}catch(t){throw console.error("Failed to initiate OAuth login:",t),t}}function f6n(t){const e=Un(M=>M.setBackendUrl),[n,r]=T.useState(!1),[i,o]=T.useState(!1),[l,u]=T.useState(!1),[d,p]=T.useState(),m=T.useRef(!1),g=T.useRef(null);T.useEffect(()=>{e(t),!m.current&&(m.current=!0,Tst().then(()=>{h6n(M=>g.current?.(M))}))},[t,e]);const h=T.useCallback(async M=>{const R=Math.random().toString(36).substring(7);sessionStorage.setItem("auth_state",R);const D=`${window.location.origin}${window.location.pathname}`;let P=null;try{const O=await Di.getOAuthUrl(M,D,R);O.url&&(P=O.url)}catch{}if(!P)try{const O=await Di.getAuthConfig();P=MN("casdoor",O,D,R,M)}catch{}if(P){u(!0);try{const O=await eFn(P);await px(O.access_token,O.user_info,O.refresh_token)}catch(O){const F=O.message;if(F!=="OAuth popup was closed")if(F==="Popup blocked by browser"){window.location.href=P;return}else console.error("Failed to initiate provider login:",O),o(!1),r(!0)}finally{u(!1)}}},[]);g.current=h;const f=T.useCallback(async()=>{try{const[M,R]=await Promise.all([Di.getAuthStatus(),Di.getAuthConfig(),Lst()]),D=R?.provider??M?.provider;if(D==="casdoor"){R?.turnstile_site_key&&p(R.turnstile_site_key),o(!0);return}if(D&&D!=="bohr_app"){const P=MN(D,R,`${window.location.origin}${window.location.pathname}`);if(P){window.location.href=P;return}}}catch{}r(!0)},[]),b=T.useCallback(()=>{Tst()},[]),y=T.useCallback(()=>{o(!1)},[]),v=T.useCallback(async(M,R)=>Di.sendVerificationCode(M,R),[]),_=T.useCallback(async(M,R)=>{await ike(M,R,"email")},[]),w=T.useCallback(async(M,R,D,P)=>{await ske(M,R,D,P)},[]),x=T.useCallback(async(M,R)=>{await kst(M,R)},[]),k=T.useCallback(async M=>{await Di.sendResetCode(M)},[]),C=T.useCallback(async(M,R,D)=>{await Cst(M,R,D)},[]),E=T.useCallback(async M=>Di.sendPhoneVerificationCode(M),[]),S=T.useCallback(async M=>Di.checkPhoneExists(M),[]),I=T.useCallback(async(M,R)=>{await ike(M,R,"phone")},[]),B=T.useCallback(async(M,R)=>{await Est(M,R)},[]),N=T.useCallback(async(M,R,D,P)=>{await ske("",R,D,P,"phone",M)},[]),L=T.useCallback(()=>{r(!1),o(!1)},[]);return{state:{showAuthScreen:n,showLoginPage:i,oauthLoading:l,turnstileSiteKey:d},handlers:{handleRetry:b,handleShowAuthScreen:f,handleSelectProvider:h,handleLoginBack:y,handleSendCode:v,handleCodeLogin:_,handleSignup:w,handlePasswordLogin:x,handleSendResetCode:k,handleResetPassword:C,handleSendPhoneCode:E,handleCheckPhone:S,handlePhoneCodeLogin:I,handlePhonePasswordLogin:B,handlePhoneSignup:N},resetAuthScreens:L}}var zN=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},A6n=class extends zN{#e;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Dke=new A6n,b6n={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},y6n=class{#e=b6n;#t=!1;setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&this.#t&&t!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:t}),this.#e=t,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},UN=new y6n;function v6n(t){setTimeout(t,0)}var _6n=typeof window>"u"||"Deno"in globalThis;function sh(){}function w6n(t,e){return typeof t=="function"?t(e):t}function Nke(t){return typeof t=="number"&&t>=0&&t!==1/0}function wot(t,e){return Math.max(t+(e||0)-Date.now(),0)}function hI(t,e){return typeof t=="function"?t(e):t}function sy(t,e){return typeof t=="function"?t(e):t}function xot(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:o,queryKey:l,stale:u}=t;if(l){if(r){if(e.queryHash!==Rke(l,e.options))return!1}else if(!iz(e.queryKey,l))return!1}if(n!=="all"){const d=e.isActive();if(n==="active"&&!d||n==="inactive"&&d)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||i&&i!==e.state.fetchStatus||o&&!o(e))}function kot(t,e){const{exact:n,status:r,predicate:i,mutationKey:o}=t;if(o){if(!e.options.mutationKey)return!1;if(n){if(qN(e.options.mutationKey)!==qN(o))return!1}else if(!iz(e.options.mutationKey,o))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function Rke(t,e){return(e?.queryKeyHashFn||qN)(t)}function qN(t){return JSON.stringify(t,(e,n)=>Lke(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function iz(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>iz(t[n],e[n])):!1}var x6n=Object.prototype.hasOwnProperty;function Mte(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=Eot(t)&&Eot(e);if(!r&&!(Lke(t)&&Lke(e)))return e;const o=(r?t:Object.keys(t)).length,l=r?e:Object.keys(e),u=l.length,d=r?new Array(u):{};let p=0;for(let m=0;m<u;m++){const g=r?m:l[m],h=t[g],f=e[g];if(h===f){d[g]=h,(r?m<o:x6n.call(t,g))&&p++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){d[g]=f;continue}const b=Mte(h,f,n+1);d[g]=b,b===h&&p++}return o===u&&p===o?t:d}function sz(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function Eot(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Lke(t){if(!Cot(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Cot(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Cot(t){return Object.prototype.toString.call(t)==="[object Object]"}function k6n(t){return new Promise(e=>{UN.setTimeout(e,t)})}function Mke(t,e,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(t,e);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Mte(t,e)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return Mte(t,e)}return e}function E6n(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function C6n(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var Pte=Symbol();function Sot(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===Pte&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===Pte?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Pke(t,e){return typeof t=="function"?t(...e):!!t}function S6n(t,e,n){let r=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??=e(),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),t}var oz=(()=>{let t=()=>_6n;return{isServer(){return t()},setIsServer(e){t=e}}})();function Oke(){let t,e;const n=new Promise((i,o)=>{t=i,e=o});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var I6n=v6n;function T6n(){let t=[],e=0,n=u=>{u()},r=u=>{u()},i=I6n;const o=u=>{e?t.push(u):i(()=>{n(u)})},l=()=>{const u=t;t=[],u.length&&i(()=>{r(()=>{u.forEach(d=>{n(d)})})})};return{batch:u=>{let d;e++;try{d=u()}finally{e--,e||l()}return d},batchCalls:u=>(...d)=>{o(()=>{u(...d)})},schedule:o,setNotifyFunction:u=>{n=u},setBatchNotifyFunction:u=>{r=u},setScheduler:u=>{i=u}}}var od=T6n(),B6n=class extends zN{#e=!0;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},Ote=new B6n;function D6n(t){return Math.min(1e3*2**t,3e4)}function Iot(t){return(t??"online")==="online"?Ote.isOnline():!0}var Fke=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Tot(t){let e=!1,n=0,r;const i=Oke(),o=()=>i.status!=="pending",l=y=>{if(!o()){const v=new Fke(y);h(v),t.onCancel?.(v)}},u=()=>{e=!0},d=()=>{e=!1},p=()=>Dke.isFocused()&&(t.networkMode==="always"||Ote.isOnline())&&t.canRun(),m=()=>Iot(t.networkMode)&&t.canRun(),g=y=>{o()||(r?.(),i.resolve(y))},h=y=>{o()||(r?.(),i.reject(y))},f=()=>new Promise(y=>{r=v=>{(o()||p())&&y(v)},t.onPause?.()}).then(()=>{r=void 0,o()||t.onContinue?.()}),b=()=>{if(o())return;let y;const v=n===0?t.initialPromise:void 0;try{y=v??t.fn()}catch(_){y=Promise.reject(_)}Promise.resolve(y).then(g).catch(_=>{if(o())return;const w=t.retry??(oz.isServer()?0:3),x=t.retryDelay??D6n,k=typeof x=="function"?x(n,_):x,C=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,_);if(e||!C){h(_);return}n++,t.onFail?.(n,_),k6n(k).then(()=>p()?void 0:f()).then(()=>{e?h(_):b()})})};return{promise:i,status:()=>i.status,cancel:l,continue:()=>(r?.(),i),cancelRetry:u,continueRetry:d,canStart:m,start:()=>(m()?b():f().then(b),i)}}var Bot=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Nke(this.gcTime)&&(this.#e=UN.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(oz.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(UN.clearTimeout(this.#e),this.#e=void 0)}},N6n=class extends Bot{#e;#t;#r;#n;#a;#s;#i;constructor(t){super(),this.#i=!1,this.#s=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#n=t.client,this.#r=this.#n.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=Rot(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#a?.promise}setOptions(t){if(this.options={...this.#s,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=Rot(this.options);e.data!==void 0&&(this.setState(Not(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(t,e){const n=Mke(this.state.data,t,this.options);return this.#l({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#l({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#a?.promise;return this.#a?.cancel(t),e?e.then(sh).catch(sh):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>sy(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Pte||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>hI(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!wot(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#a&&(this.#i||this.#o()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#o(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#a?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(t&&this.setOptions(t),!this.options.queryFn){const u=this.observers.find(d=>d.options.queryFn);u&&this.setOptions(u.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,r=u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:()=>(this.#i=!0,n.signal)})},i=()=>{const u=Sot(this.options,e),p=(()=>{const m={client:this.#n,queryKey:this.queryKey,meta:this.meta};return r(m),m})();return this.#i=!1,this.options.persister?this.options.persister(u,p,this):u(p)},l=(()=>{const u={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#n,state:this.state,fetchFn:i};return r(u),u})();this.options.behavior?.onFetch(l,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==l.fetchOptions?.meta)&&this.#l({type:"fetch",meta:l.fetchOptions?.meta}),this.#a=Tot({initialPromise:e?.initialPromise,fn:l.fetchFn,onCancel:u=>{u instanceof Fke&&u.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(u,d)=>{this.#l({type:"failed",failureCount:u,error:d})},onPause:()=>{this.#l({type:"pause"})},onContinue:()=>{this.#l({type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0});try{const u=await this.#a.start();if(u===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(u),this.#r.config.onSuccess?.(u,this),this.#r.config.onSettled?.(u,this.state.error,this),u}catch(u){if(u instanceof Fke){if(u.silent)return this.#a.promise;if(u.revert){if(this.state.data===void 0)throw u;return this.state.data}}throw this.#l({type:"error",error:u}),this.#r.config.onError?.(u,this),this.#r.config.onSettled?.(this.state.data,u,this),u}finally{this.scheduleGc()}}#l(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Dot(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...Not(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),od.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:t})})}};function Dot(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Iot(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Not(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Rot(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,r=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Fte=class extends zN{constructor(t,e){super(),this.options=e,this.#e=t,this.#o=null,this.#i=Oke(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#r=void 0;#n=void 0;#a;#s;#i;#o;#l;#c;#p;#u;#m;#h;#g=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Lot(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Qke(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Qke(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#k(),this.#x(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof sy(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#v(),this.#t.setOptions(this.options),e._defaulted&&!sz(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&Mot(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||sy(this.options.enabled,this.#t)!==sy(e.enabled,this.#t)||hI(this.options.staleTime,this.#t)!==hI(e.staleTime,this.#t))&&this.#f();const i=this.#A();r&&(this.#t!==n||sy(this.options.enabled,this.#t)!==sy(e.enabled,this.#t)||i!==this.#h)&&this.#y(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return L6n(this,n)&&(this.#n=n,this.#s=this.options,this.#a=this.#t.state),n}getCurrentResult(){return this.#n}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#i.status==="pending"&&this.#i.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#g.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#n))}#d(t){this.#v();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(sh)),e}#f(){this.#k();const t=hI(this.options.staleTime,this.#t);if(oz.isServer()||this.#n.isStale||!Nke(t))return;const n=wot(this.#n.dataUpdatedAt,t)+1;this.#u=UN.setTimeout(()=>{this.#n.isStale||this.updateResult()},n)}#A(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#x(),this.#h=t,!(oz.isServer()||sy(this.options.enabled,this.#t)===!1||!Nke(this.#h)||this.#h===0)&&(this.#m=UN.setInterval(()=>{(this.options.refetchIntervalInBackground||Dke.isFocused())&&this.#d()},this.#h))}#b(){this.#f(),this.#y(this.#A())}#k(){this.#u&&(UN.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#m&&(UN.clearInterval(this.#m),this.#m=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#n,o=this.#a,l=this.#s,d=t!==n?t.state:this.#r,{state:p}=t;let m={...p},g=!1,h;if(e._optimisticResults){const I=this.hasListeners(),B=!I&&Lot(t,e),N=I&&Mot(t,n,e,r);(B||N)&&(m={...m,...Dot(p.data,t.options)}),e._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:f,errorUpdatedAt:b,status:y}=m;h=m.data;let v=!1;if(e.placeholderData!==void 0&&h===void 0&&y==="pending"){let I;i?.isPlaceholderData&&e.placeholderData===l?.placeholderData?(I=i.data,v=!0):I=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,I!==void 0&&(y="success",h=Mke(i?.data,I,e),g=!0)}if(e.select&&h!==void 0&&!v)if(i&&h===o?.data&&e.select===this.#l)h=this.#c;else try{this.#l=e.select,h=e.select(h),h=Mke(i?.data,h,e),this.#c=h,this.#o=null}catch(I){this.#o=I}this.#o&&(f=this.#o,h=this.#c,b=Date.now(),y="error");const _=m.fetchStatus==="fetching",w=y==="pending",x=y==="error",k=w&&_,C=h!==void 0,S={status:y,fetchStatus:m.fetchStatus,isPending:w,isSuccess:y==="success",isError:x,isInitialLoading:k,isLoading:k,data:h,dataUpdatedAt:m.dataUpdatedAt,error:f,errorUpdatedAt:b,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>d.dataUpdateCount||m.errorUpdateCount>d.errorUpdateCount,isFetching:_,isRefetching:_&&!w,isLoadingError:x&&!C,isPaused:m.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:x&&C,isStale:$ke(t,e),refetch:this.refetch,promise:this.#i,isEnabled:sy(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=S.data!==void 0,B=S.status==="error"&&!I,N=R=>{B?R.reject(S.error):I&&R.resolve(S.data)},L=()=>{const R=this.#i=S.promise=Oke();N(R)},M=this.#i;switch(M.status){case"pending":t.queryHash===n.queryHash&&N(M);break;case"fulfilled":(B||S.data!==M.value)&&L();break;case"rejected":(!B||S.error!==M.reason)&&L();break}}return S}updateResult(){const t=this.#n,e=this.createResult(this.#t,this.options);if(this.#a=this.#t.state,this.#s=this.options,this.#a.data!==void 0&&(this.#p=this.#t),sz(e,t))return;this.#n=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#g.size)return!0;const o=new Set(i??this.#g);return this.options.throwOnError&&o.add("error"),Object.keys(this.#n).some(l=>{const u=l;return this.#n[u]!==t[u]&&o.has(u)})};this.#C({listeners:n()})}#v(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#C(t){od.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#n)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function R6n(t,e){return sy(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Lot(t,e){return R6n(t,e)||t.state.data!==void 0&&Qke(t,e,e.refetchOnMount)}function Qke(t,e,n){if(sy(e.enabled,t)!==!1&&hI(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&$ke(t,e)}return!1}function Mot(t,e,n,r){return(t!==e||sy(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&$ke(t,n)}function $ke(t,e){return sy(e.enabled,t)!==!1&&t.isStaleByTime(hI(e.staleTime,t))}function L6n(t,e){return!sz(t.getCurrentResult(),e)}function Qte(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,o=e.state.data?.pages||[],l=e.state.data?.pageParams||[];let u={pages:[],pageParams:[]},d=0;const p=async()=>{let m=!1;const g=b=>{S6n(b,()=>e.signal,()=>m=!0)},h=Sot(e.options,e.fetchOptions),f=async(b,y,v)=>{if(m)return Promise.reject();if(y==null&&b.pages.length)return Promise.resolve(b);const w=(()=>{const E={client:e.client,queryKey:e.queryKey,pageParam:y,direction:v?"backward":"forward",meta:e.options.meta};return g(E),E})(),x=await h(w),{maxPages:k}=e.options,C=v?C6n:E6n;return{pages:C(b.pages,x,k),pageParams:C(b.pageParams,y,k)}};if(i&&o.length){const b=i==="backward",y=b?Pot:jke,v={pages:o,pageParams:l},_=y(r,v);u=await f(v,_,b)}else{const b=t??o.length;do{const y=d===0?l[0]??r.initialPageParam:jke(r,u);if(d>0&&y==null)break;u=await f(u,y),d++}while(d<b)}return u};e.options.persister?e.fetchFn=()=>e.options.persister?.(p,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=p}}}function jke(t,{pages:e,pageParams:n}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,n[r],n):void 0}function Pot(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}function M6n(t,e){return e?jke(t,e)!=null:!1}function P6n(t,e){return!e||!t.getPreviousPageParam?!1:Pot(t,e)!=null}var O6n=class extends Fte{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:Qte()})}getOptimisticResult(t){return t.behavior=Qte(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,e){const{state:n}=t,r=super.createResult(t,e),{isFetching:i,isRefetching:o,isError:l,isRefetchError:u}=r,d=n.fetchMeta?.fetchMore?.direction,p=l&&d==="forward",m=i&&d==="forward",g=l&&d==="backward",h=i&&d==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:M6n(e,n.data),hasPreviousPage:P6n(e,n.data),isFetchNextPageError:p,isFetchingNextPage:m,isFetchPreviousPageError:g,isFetchingPreviousPage:h,isRefetchError:u&&!p&&!g,isRefetching:o&&!m&&!h}}},F6n=class extends Bot{#e;#t;#r;#n;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#t=[],this.state=t.state||Oot(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#a({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#n=Tot({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(o,l)=>{this.#a({type:"failed",failureCount:o,error:l})},onPause:()=>{this.#a({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#r.canRun(this)});const r=this.state.status==="pending",i=!this.#n.canStart();try{if(r)e();else{this.#a({type:"pending",variables:t,isPaused:i}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,n);const l=await this.options.onMutate?.(t,n);l!==this.state.context&&this.#a({type:"pending",context:l,variables:t,isPaused:i})}const o=await this.#n.start();return await this.#r.config.onSuccess?.(o,t,this.state.context,this,n),await this.options.onSuccess?.(o,t,this.state.context,n),await this.#r.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,t,this.state.context,n),this.#a({type:"success",data:o}),o}catch(o){try{await this.#r.config.onError?.(o,t,this.state.context,this,n)}catch(l){Promise.reject(l)}try{await this.options.onError?.(o,t,this.state.context,n)}catch(l){Promise.reject(l)}try{await this.#r.config.onSettled?.(void 0,o,this.state.variables,this.state.context,this,n)}catch(l){Promise.reject(l)}try{await this.options.onSettled?.(void 0,o,t,this.state.context,n)}catch(l){Promise.reject(l)}throw this.#a({type:"error",error:o}),o}finally{this.#r.runNext(this)}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),od.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Oot(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Q6n=class extends zN{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(t,e,n){const r=new F6n({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#e.add(t);const e=$te(t);if(typeof e=="string"){const n=this.#t.get(e);n?n.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=$te(t);if(typeof e=="string"){const n=this.#t.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=$te(t);if(typeof e=="string"){const r=this.#t.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=$te(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){od.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>kot(e,n))}findAll(t={}){return this.getAll().filter(e=>kot(t,e))}notify(t){od.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return od.batch(()=>Promise.all(t.map(e=>e.continue().catch(sh))))}};function $te(t){return t.options.scope?.id}var $6n=class extends zN{#e;#t=void 0;#r;#n;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#a()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),sz(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#r,observer:this}),n?.mutationKey&&this.options.mutationKey&&qN(n.mutationKey)!==qN(this.options.mutationKey)?this.reset():this.#r?.state.status==="pending"&&this.#r.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#r?.removeObserver(this)}onMutationUpdate(e){this.#a(),this.#s(e)}getCurrentResult(){return this.#t}reset(){this.#r?.removeObserver(this),this.#r=void 0,this.#a(),this.#s()}mutate(e,n){return this.#n=n,this.#r?.removeObserver(this),this.#r=this.#e.getMutationCache().build(this.#e,this.options),this.#r.addObserver(this),this.#r.execute(e)}#a(){const e=this.#r?.state??Oot();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#s(e){od.batch(()=>{if(this.#n&&this.hasListeners()){const n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#n.onSuccess?.(e.data,n,r,i)}catch(o){Promise.reject(o)}try{this.#n.onSettled?.(e.data,null,n,r,i)}catch(o){Promise.reject(o)}}else if(e?.type==="error"){try{this.#n.onError?.(e.error,n,r,i)}catch(o){Promise.reject(o)}try{this.#n.onSettled?.(void 0,e.error,n,r,i)}catch(o){Promise.reject(o)}}}this.listeners.forEach(n=>{n(this.#t)})})}};function Fot(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function j6n(t,e,n){const r=t.slice(0);return r[e]=n,r}var z6n=class extends zN{#e;#t;#r;#n;#a;#s;#i;#o;#l;#c=[];constructor(t,e,n){super(),this.#e=t,this.#n=n,this.#r=[],this.#a=[],this.#t=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#a.forEach(t=>{t.subscribe(e=>{this.#h(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#a.forEach(t=>{t.destroy()})}setQueries(t,e){if(this.#r=t,this.#n=e,process.env.NODE_ENV!=="production"){const n=t.map(r=>this.#e.defaultQueryOptions(r).queryHash);new Set(n).size!==n.length&&console.warn("[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.")}od.batch(()=>{const n=this.#a,r=this.#m(this.#r);r.forEach(m=>m.observer.setOptions(m.defaultedQueryOptions));const i=r.map(m=>m.observer),o=i.map(m=>m.getCurrentResult()),l=n.length!==i.length,u=i.some((m,g)=>m!==n[g]),d=l||u,p=d?!0:o.some((m,g)=>{const h=this.#t[g];return!h||!sz(m,h)});!d&&!p||(d&&(this.#c=r,this.#a=i),this.#t=o,this.hasListeners()&&(d&&(Fot(n,i).forEach(m=>{m.destroy()}),Fot(i,n).forEach(m=>{m.subscribe(g=>{this.#h(m,g)})})),this.#g()))})}getCurrentResult(){return this.#t}getQueries(){return this.#a.map(t=>t.getCurrentQuery())}getObservers(){return this.#a}getOptimisticResult(t,e){const n=this.#m(t),r=n.map(o=>o.observer.getOptimisticResult(o.defaultedQueryOptions)),i=n.map(o=>o.defaultedQueryOptions.queryHash);return[r,o=>this.#u(o??r,e,i),()=>this.#p(r,n)]}#p(t,e){return e.map((n,r)=>{const i=t[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,o=>{e.forEach(l=>{l.observer.trackProp(o)})})})}#u(t,e,n){if(e){const r=this.#l,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((o,l)=>o!==r[l]));return(!this.#s||this.#t!==this.#o||i||e!==this.#i)&&(this.#i=e,this.#o=this.#t,n!==void 0&&(this.#l=n),this.#s=Mte(this.#s,e(t))),this.#s}return t}#m(t){const e=new Map;this.#a.forEach(r=>{const i=r.options.queryHash;if(!i)return;const o=e.get(i);o?o.push(r):e.set(i,[r])});const n=[];return t.forEach(r=>{const i=this.#e.defaultQueryOptions(r),l=e.get(i.queryHash)?.shift()??new Fte(this.#e,i);n.push({defaultedQueryOptions:i,observer:l})}),n}#h(t,e){const n=this.#a.indexOf(t);n!==-1&&(this.#t=j6n(this.#t,n,e),this.#g())}#g(){if(this.hasListeners()){const t=this.#s,e=this.#p(this.#t,this.#c),n=this.#u(e,this.#n?.combine);t!==n&&od.batch(()=>{this.listeners.forEach(r=>{r(this.#t)})})}}},U6n=class extends zN{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??Rke(r,e);let o=this.get(i);return o||(o=new N6n({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){od.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>xot(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>xot(t,n)):e}notify(t){od.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){od.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){od.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},q6n=class{#e;#t;#r;#n;#a;#s;#i;#o;constructor(t={}){this.#e=t.queryCache||new U6n,this.#t=t.mutationCache||new Q6n,this.#r=t.defaultOptions||{},this.#n=new Map,this.#a=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#i=Dke.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#o=Ote.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#i?.(),this.#i=void 0,this.#o?.(),this.#o=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(hI(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),o=this.#e.get(r.queryHash)?.state.data,l=w6n(e,o);if(l!==void 0)return this.#e.build(this,r).setData(l,{...n,manual:!0})}setQueriesData(t,e,n){return od.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;od.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return od.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=od.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(sh).catch(sh)}invalidateQueries(t,e={}){return od.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=od.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let o=i.fetch(void 0,n);return n.throwOnError||(o=o.catch(sh)),i.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(sh)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(hI(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(sh).catch(sh)}fetchInfiniteQuery(t){return t.behavior=Qte(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(sh).catch(sh)}ensureInfiniteQueryData(t){return t.behavior=Qte(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Ote.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#n.set(qN(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#n.values()],n={};return e.forEach(r=>{iz(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#a.set(qN(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#a.values()],n={};return e.forEach(r=>{iz(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#r.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Rke(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Pte&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Qot=ee.createContext(void 0),Ol=t=>{const e=ee.useContext(Qot);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},J5=({client:t,children:e})=>(ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),A.jsx(Qot.Provider,{value:t,children:e})),$ot=ee.createContext(!1),jot=()=>ee.useContext($ot);$ot.Provider;function G6n(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var H6n=ee.createContext(G6n()),zot=()=>ee.useContext(H6n),Uot=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?Pke(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},qot=t=>{ee.useEffect(()=>{t.clearReset()},[t])},Got=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||Pke(n,[t.error,r])),Hot=t=>{if(t.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},W6n=(t,e)=>t.isLoading&&t.isFetching&&!e,zke=(t,e)=>t?.suspense&&e.isPending,Uke=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Y6n({queries:t,...e},n){const r=Ol(),i=jot(),o=zot(),l=ee.useMemo(()=>t.map(y=>{const v=r.defaultQueryOptions(y);return v._optimisticResults=i?"isRestoring":"optimistic",v}),[t,r,i]);l.forEach(y=>{Hot(y);const v=r.getQueryCache().get(y.queryHash);Uot(y,o,v)}),qot(o);const[u]=ee.useState(()=>new z6n(r,l,e)),[d,p,m]=u.getOptimisticResult(l,e.combine),g=!i&&e.subscribed!==!1;ee.useSyncExternalStore(ee.useCallback(y=>g?u.subscribe(od.batchCalls(y)):sh,[u,g]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),ee.useEffect(()=>{u.setQueries(l,e)},[l,e,u]);const f=d.some((y,v)=>zke(l[v],y))?d.flatMap((y,v)=>{const _=l[v];if(_&&zke(_,y)){const w=new Fte(r,_);return Uke(_,w,o)}return[]}):[];if(f.length>0)throw Promise.all(f);const b=d.find((y,v)=>{const _=l[v];return _&&Got({result:y,errorResetBoundary:o,throwOnError:_.throwOnError,query:r.getQueryCache().get(_.queryHash),suspense:_.suspense})});if(b?.error)throw b.error;return p(m())}function Wot(t,e,n){if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=jot(),i=zot(),o=Ol(),l=o.defaultQueryOptions(t);o.getDefaultOptions().queries?._experimental_beforeQuery?.(l);const u=o.getQueryCache().get(l.queryHash);process.env.NODE_ENV!=="production"&&(l.queryFn||console.error(`[${l.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),l._optimisticResults=r?"isRestoring":"optimistic",Hot(l),Uot(l,i,u),qot(i);const d=!o.getQueryCache().get(l.queryHash),[p]=ee.useState(()=>new e(o,l)),m=p.getOptimisticResult(l),g=!r&&t.subscribed!==!1;if(ee.useSyncExternalStore(ee.useCallback(h=>{const f=g?p.subscribe(od.batchCalls(h)):sh;return p.updateResult(),f},[p,g]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),ee.useEffect(()=>{p.setOptions(l)},[l,p]),zke(l,m))throw Uke(l,p,i);if(Got({result:m,errorResetBoundary:i,throwOnError:l.throwOnError,query:u,suspense:l.suspense}))throw m.error;return o.getDefaultOptions().queries?._experimental_afterQuery?.(l,m),l.experimental_prefetchInRender&&!oz.isServer()&&W6n(m,r)&&(d?Uke(l,p,i):u?.promise)?.catch(sh).finally(()=>{p.updateResult()}),l.notifyOnChangeProps?m:p.trackResult(m)}function Js(t,e){return Wot(t,Fte)}function fg(t,e){const n=Ol(),[r]=ee.useState(()=>new $6n(n,t));ee.useEffect(()=>{r.setOptions(t)},[r,t]);const i=ee.useSyncExternalStore(ee.useCallback(l=>r.subscribe(od.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=ee.useCallback((l,u)=>{r.mutate(l,u).catch(sh)},[r]);if(i.error&&Pke(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}function Yot(t,e){return Wot(t,O6n)}class V6n{async getActiveCampaigns(){return nn.get("/xyzen/api/v1/gifts/active")}async claimGift(e){return nn.post(`/xyzen/api/v1/gifts/${e}/claim`)}}const Vot=new V6n,eP=not.env.backendUrl;typeof localStorage<"u"&&localStorage.getItem("layoutStyle")&&localStorage.getItem("layoutStyle");function _l(){return typeof window<"u"&&"__TAURI__"in window}const qke="xyzen.desktop.runner",Kot="xyzen.desktop.prevent_sleep",Gke="xyzen:desktop-prevent-sleep-changed",jte="Desktop Runner";async function GN(t,e){const{invoke:n}=await Promise.resolve().then(()=>vJn);return n(t,e)}async function zte(t,e,n){return GN("runner_start",{token:t,url:e,workDir:n})}async function K6n(){return GN("runner_stop")}async function Hke(){return GN("runner_status")}async function Wke(){return _l()?GN("desktop_computer_use_status"):{supported:!1,platform:"browser",screen_capture_permission:"unsupported",accessibility_permission:"unsupported",reason:null}}function Zot(t){if(!t)return null;const e=t.screen_capture_permission==="denied",n=t.accessibility_permission==="denied";return e&&n?"both":e?"screen_capture":n?"accessibility":null}async function Xot(t){if(_l())return GN("desktop_open_url",{url:t})}function Z6n(){return Xot("x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture")}function X6n(){return Xot("x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")}async function Jot(){return _l()?GN("desktop_sleep_prevention_status"):{enabled:!1,supported:!1}}async function Yke(t){return _l()?GN("desktop_sleep_prevention_set_enabled",{enabled:t}):{enabled:!1,supported:!1}}function Ute(){const e=sd().env.backendUrl||`${window.location.protocol}//${window.location.host}`,n=new URL(e);return`${n.protocol==="https:"?"wss:":"ws:"}//${n.host}/xyzen/ws/v1/runner`}function qte(){if(typeof window>"u")return null;const t=window.localStorage.getItem(qke);if(!t)return null;try{const e=JSON.parse(t);if(typeof e.runnerId=="string"&&typeof e.token=="string"&&typeof e.name=="string")return{runnerId:e.runnerId,token:e.token,name:e.name}}catch{}return null}function elt(t){typeof window>"u"||window.localStorage.setItem(qke,JSON.stringify(t))}function lz(){typeof window>"u"||window.localStorage.removeItem(qke)}function cz(){return typeof window>"u"?!1:window.localStorage.getItem(Kot)==="true"}function tlt(t){typeof window>"u"||(window.localStorage.setItem(Kot,t?"true":"false"),window.dispatchEvent(new CustomEvent(Gke,{detail:{enabled:t}})))}function nlt(t){if(typeof window>"u")return()=>{};const e=n=>{t(n.detail.enabled)};return window.addEventListener(Gke,e),()=>{window.removeEventListener(Gke,e)}}const rlt=38,J6n=88,e9n=16;function t9n(){const[t,e]=T.useState(!1);return T.useEffect(()=>{if(!_l())return;let n=!1;const r=async()=>{try{const{getCurrentWindow:o}=await Promise.resolve().then(()=>BJn),l=o(),u=await l.isFullscreen();return n||e(u),await l.onResized(async()=>{const p=await l.isFullscreen();n||e(p)})}catch{return}};let i;return r().then(o=>{n?o?.():i=o}),()=>{n=!0,i?.()}},[]),t}function n9n(){const e=t9n()?e9n:J6n;return A.jsxs("div",{"data-tauri-drag-region":!0,className:"fixed top-0 left-0 right-0 z-[100] flex items-center select-none",style:{height:rlt},children:[A.jsx("div",{"data-tauri-drag-region":!0,className:"shrink-0 flex items-center",style:{paddingLeft:e},children:A.jsx("img",{src:"/icon.png",alt:"",className:"h-4 w-4 rounded-sm",draggable:!1})}),A.jsx("div",{"data-tauri-drag-region":!0,className:"flex-1"})]})}const r9n=Object.freeze({billing:!1,admin:!1,checkIn:!1,subscription:!1,developerReward:!1}),a9n=Object.freeze({billing:!0,admin:!0,checkIn:!0,subscription:!0,developerReward:!0}),Vke=Object.freeze({edition:"ce",isEE:!1,features:r9n}),i9n=Object.freeze({edition:"ee",isEE:!0,features:a9n});let tP=Vke,alt=!1;async function s9n(){if(alt)return tP;try{const[t,e]=await Promise.all([vte.getEdition(),vte.getFeatures().catch(()=>null)]),n=t.edition==="ee"?i9n:Vke;if(e){const r={...n.features,developerReward:n.features.developerReward&&e.developer_reward};tP=Object.freeze({...n,features:Object.freeze(r)})}else tP=n}catch{tP=Vke}return alt=!0,tP}function FA(t){return tP.features[t]}const Gte=()=>{const[t,e]=T.useState("system"),n=Un(l=>l.setTheme),r=T.useCallback(l=>{const u=window.document.documentElement,d=l==="dark"||l==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches,p=document.createElement("style");p.innerHTML="*, *::before, *::after { transition: none !important; }",document.head.appendChild(p),u.classList.toggle("dark",d),localStorage.setItem("theme",l);const m=d?"#000000":"#ffffff";document.querySelectorAll('meta[name="theme-color"]').forEach(g=>{g.content=m}),setTimeout(()=>{document.head.contains(p)&&document.head.removeChild(p)},50)},[]);return T.useEffect(()=>{const u=localStorage.getItem("theme")||"system";e(u),r(u)},[r]),T.useEffect(()=>{const l=window.matchMedia("(prefers-color-scheme: dark)"),u=()=>{t==="system"&&r("system")};return l.addEventListener("change",u),()=>l.removeEventListener("change",u)},[t,r]),{theme:t,cycleTheme:()=>{const l=["light","dark","system"],u=l.indexOf(t),d=l[(u+1)%l.length];e(d),r(d)},setTheme:l=>{e(l),r(l),n(l)}}};function o9n(t){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}const l9n=t=>{switch(t){case"success":return d9n;case"info":return m9n;case"warning":return p9n;case"error":return g9n;default:return null}},c9n=Array(12).fill(0),u9n=({visible:t,className:e})=>T.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},T.createElement("div",{className:"sonner-spinner"},c9n.map((n,r)=>T.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),d9n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),p9n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),m9n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),g9n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),h9n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},T.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),T.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),f9n=()=>{const[t,e]=T.useState(document.hidden);return T.useEffect(()=>{const n=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t};let Kke=1;class A9n{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const n=this.subscribers.indexOf(e);this.subscribers.splice(n,1)}),this.publish=e=>{this.subscribers.forEach(n=>n(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var n;const{message:r,...i}=e,o=typeof e?.id=="number"||((n=e.id)==null?void 0:n.length)>0?e.id:Kke++,l=this.toasts.find(d=>d.id===o),u=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),l?this.toasts=this.toasts.map(d=>d.id===o?(this.publish({...d,...e,id:o,title:r}),{...d,...e,id:o,dismissible:u,title:r}):d):this.addToast({title:r,...i,dismissible:u,id:o}),o},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:e,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),e),this.message=(e,n)=>this.create({...n,message:e}),this.error=(e,n)=>this.create({...n,message:e,type:"error"}),this.success=(e,n)=>this.create({...n,type:"success",message:e}),this.info=(e,n)=>this.create({...n,type:"info",message:e}),this.warning=(e,n)=>this.create({...n,type:"warning",message:e}),this.loading=(e,n)=>this.create({...n,type:"loading",message:e}),this.promise=(e,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:e,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const i=Promise.resolve(e instanceof Function?e():e);let o=r!==void 0,l;const u=i.then(async p=>{if(l=["resolve",p],T.isValidElement(p))o=!1,this.create({id:r,type:"default",message:p});else if(y9n(p)&&!p.ok){o=!1;const g=typeof n.error=="function"?await n.error(`HTTP error! status: ${p.status}`):n.error,h=typeof n.description=="function"?await n.description(`HTTP error! status: ${p.status}`):n.description,b=typeof g=="object"&&!T.isValidElement(g)?g:{message:g};this.create({id:r,type:"error",description:h,...b})}else if(p instanceof Error){o=!1;const g=typeof n.error=="function"?await n.error(p):n.error,h=typeof n.description=="function"?await n.description(p):n.description,b=typeof g=="object"&&!T.isValidElement(g)?g:{message:g};this.create({id:r,type:"error",description:h,...b})}else if(n.success!==void 0){o=!1;const g=typeof n.success=="function"?await n.success(p):n.success,h=typeof n.description=="function"?await n.description(p):n.description,b=typeof g=="object"&&!T.isValidElement(g)?g:{message:g};this.create({id:r,type:"success",description:h,...b})}}).catch(async p=>{if(l=["reject",p],n.error!==void 0){o=!1;const m=typeof n.error=="function"?await n.error(p):n.error,g=typeof n.description=="function"?await n.description(p):n.description,f=typeof m=="object"&&!T.isValidElement(m)?m:{message:m};this.create({id:r,type:"error",description:g,...f})}}).finally(()=>{o&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),d=()=>new Promise((p,m)=>u.then(()=>l[0]==="reject"?m(l[1]):p(l[1])).catch(m));return typeof r!="string"&&typeof r!="number"?{unwrap:d}:Object.assign(r,{unwrap:d})},this.custom=(e,n)=>{const r=n?.id||Kke++;return this.create({jsx:e(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const QA=new A9n,b9n=(t,e)=>{const n=e?.id||Kke++;return QA.addToast({title:t,...e,id:n}),n},y9n=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",v9n=b9n,_9n=()=>QA.toasts,w9n=()=>QA.getActiveToasts(),Rr=Object.assign(v9n,{success:QA.success,info:QA.info,warning:QA.warning,error:QA.error,custom:QA.custom,message:QA.message,promise:QA.promise,dismiss:QA.dismiss,loading:QA.loading},{getHistory:_9n,getToasts:w9n});o9n("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Hte(t){return t.label!==void 0}const x9n=3,k9n="24px",E9n="16px",ilt=4e3,C9n=356,S9n=14,I9n=45,T9n=200;function fx(...t){return t.filter(Boolean).join(" ")}function B9n(t){const[e,n]=t.split("-"),r=[];return e&&r.push(e),n&&r.push(n),r}const D9n=t=>{var e,n,r,i,o,l,u,d,p;const{invert:m,toast:g,unstyled:h,interacting:f,setHeights:b,visibleToasts:y,heights:v,index:_,toasts:w,expanded:x,removeToast:k,defaultRichColors:C,closeButton:E,style:S,cancelButtonStyle:I,actionButtonStyle:B,className:N="",descriptionClassName:L="",duration:M,position:R,gap:D,expandByDefault:P,classNames:O,icons:F,closeButtonAriaLabel:$="Close toast"}=t,[j,Q]=T.useState(null),[z,U]=T.useState(null),[H,te]=T.useState(!1),[V,ae]=T.useState(!1),[ie,Z]=T.useState(!1),[W,q]=T.useState(!1),[Y,X]=T.useState(!1),[ne,ce]=T.useState(0),[oe,ue]=T.useState(0),me=T.useRef(g.duration||M||ilt),fe=T.useRef(null),Be=T.useRef(null),He=_===0,Le=_+1<=y,et=g.type,mt=g.dismissible!==!1,yt=g.className||"",wt=g.descriptionClassName||"",$e=T.useMemo(()=>v.findIndex(Ae=>Ae.toastId===g.id)||0,[v,g.id]),st=T.useMemo(()=>{var Ae;return(Ae=g.closeButton)!=null?Ae:E},[g.closeButton,E]),Ce=T.useMemo(()=>g.duration||M||ilt,[g.duration,M]),tt=T.useRef(0),Rt=T.useRef(0),pe=T.useRef(0),Xe=T.useRef(null),[se,Re]=R.split("-"),ye=T.useMemo(()=>v.reduce((Ae,xe,pt)=>pt>=$e?Ae:Ae+xe.height,0),[v,$e]),Qe=f9n(),we=g.invert||m,ot=et==="loading";Rt.current=T.useMemo(()=>$e*D+ye,[$e,ye]),T.useEffect(()=>{me.current=Ce},[Ce]),T.useEffect(()=>{te(!0)},[]),T.useEffect(()=>{const Ae=Be.current;if(Ae){const xe=Ae.getBoundingClientRect().height;return ue(xe),b(pt=>[{toastId:g.id,height:xe,position:g.position},...pt]),()=>b(pt=>pt.filter(nt=>nt.toastId!==g.id))}},[b,g.id]),T.useLayoutEffect(()=>{if(!H)return;const Ae=Be.current,xe=Ae.style.height;Ae.style.height="auto";const pt=Ae.getBoundingClientRect().height;Ae.style.height=xe,ue(pt),b(nt=>nt.find(sn=>sn.toastId===g.id)?nt.map(sn=>sn.toastId===g.id?{...sn,height:pt}:sn):[{toastId:g.id,height:pt,position:g.position},...nt])},[H,g.title,g.description,b,g.id,g.jsx,g.action,g.cancel]);const vt=T.useCallback(()=>{ae(!0),ce(Rt.current),b(Ae=>Ae.filter(xe=>xe.toastId!==g.id)),setTimeout(()=>{k(g)},T9n)},[g,k,b,Rt]);T.useEffect(()=>{if(g.promise&&et==="loading"||g.duration===1/0||g.type==="loading")return;let Ae;return x||f||Qe?(()=>{if(pe.current<tt.current){const nt=new Date().getTime()-tt.current;me.current=me.current-nt}pe.current=new Date().getTime()})():me.current!==1/0&&(tt.current=new Date().getTime(),Ae=setTimeout(()=>{g.onAutoClose==null||g.onAutoClose.call(g,g),vt()},me.current)),()=>clearTimeout(Ae)},[x,f,g,et,Qe,vt]),T.useEffect(()=>{g.delete&&(vt(),g.onDismiss==null||g.onDismiss.call(g,g))},[vt,g.delete]);function de(){var Ae;if(F?.loading){var xe;return T.createElement("div",{className:fx(O?.loader,g==null||(xe=g.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":et==="loading"},F.loading)}return T.createElement(u9n,{className:fx(O?.loader,g==null||(Ae=g.classNames)==null?void 0:Ae.loader),visible:et==="loading"})}const rt=g.icon||F?.[et]||l9n(et);var lt,Ne;return T.createElement("li",{tabIndex:0,ref:Be,className:fx(N,yt,O?.toast,g==null||(e=g.classNames)==null?void 0:e.toast,O?.default,O?.[et],g==null||(n=g.classNames)==null?void 0:n[et]),"data-sonner-toast":"","data-rich-colors":(lt=g.richColors)!=null?lt:C,"data-styled":!(g.jsx||g.unstyled||h),"data-mounted":H,"data-promise":!!g.promise,"data-swiped":Y,"data-removed":V,"data-visible":Le,"data-y-position":se,"data-x-position":Re,"data-index":_,"data-front":He,"data-swiping":ie,"data-dismissible":mt,"data-type":et,"data-invert":we,"data-swipe-out":W,"data-swipe-direction":z,"data-expanded":!!(x||P&&H),"data-testid":g.testId,style:{"--index":_,"--toasts-before":_,"--z-index":w.length-_,"--offset":`${V?ne:Rt.current}px`,"--initial-height":P?"auto":`${oe}px`,...S,...g.style},onDragEnd:()=>{Z(!1),Q(null),Xe.current=null},onPointerDown:Ae=>{Ae.button!==2&&(ot||!mt||(fe.current=new Date,ce(Rt.current),Ae.target.setPointerCapture(Ae.pointerId),Ae.target.tagName!=="BUTTON"&&(Z(!0),Xe.current={x:Ae.clientX,y:Ae.clientY})))},onPointerUp:()=>{var Ae,xe,pt;if(W||!mt)return;Xe.current=null;const nt=Number(((Ae=Be.current)==null?void 0:Ae.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Vt=Number(((xe=Be.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),sn=new Date().getTime()-((pt=fe.current)==null?void 0:pt.getTime()),rn=j==="x"?nt:Vt,Xt=Math.abs(rn)/sn;if(Math.abs(rn)>=I9n||Xt>.11){ce(Rt.current),g.onDismiss==null||g.onDismiss.call(g,g),U(j==="x"?nt>0?"right":"left":Vt>0?"down":"up"),vt(),q(!0);return}else{var Lt,Dt;(Lt=Be.current)==null||Lt.style.setProperty("--swipe-amount-x","0px"),(Dt=Be.current)==null||Dt.style.setProperty("--swipe-amount-y","0px")}X(!1),Z(!1),Q(null)},onPointerMove:Ae=>{var xe,pt,nt;if(!Xe.current||!mt||((xe=window.getSelection())==null?void 0:xe.toString().length)>0)return;const sn=Ae.clientY-Xe.current.y,rn=Ae.clientX-Xe.current.x;var Xt;const Lt=(Xt=t.swipeDirections)!=null?Xt:B9n(R);!j&&(Math.abs(rn)>1||Math.abs(sn)>1)&&Q(Math.abs(rn)>Math.abs(sn)?"x":"y");let Dt={x:0,y:0};const at=mn=>1/(1.5+Math.abs(mn)/20);if(j==="y"){if(Lt.includes("top")||Lt.includes("bottom"))if(Lt.includes("top")&&sn<0||Lt.includes("bottom")&&sn>0)Dt.y=sn;else{const mn=sn*at(sn);Dt.y=Math.abs(mn)<Math.abs(sn)?mn:sn}}else if(j==="x"&&(Lt.includes("left")||Lt.includes("right")))if(Lt.includes("left")&&rn<0||Lt.includes("right")&&rn>0)Dt.x=rn;else{const mn=rn*at(rn);Dt.x=Math.abs(mn)<Math.abs(rn)?mn:rn}(Math.abs(Dt.x)>0||Math.abs(Dt.y)>0)&&X(!0),(pt=Be.current)==null||pt.style.setProperty("--swipe-amount-x",`${Dt.x}px`),(nt=Be.current)==null||nt.style.setProperty("--swipe-amount-y",`${Dt.y}px`)}},st&&!g.jsx&&et!=="loading"?T.createElement("button",{"aria-label":$,"data-disabled":ot,"data-close-button":!0,onClick:ot||!mt?()=>{}:()=>{vt(),g.onDismiss==null||g.onDismiss.call(g,g)},className:fx(O?.closeButton,g==null||(r=g.classNames)==null?void 0:r.closeButton)},(Ne=F?.close)!=null?Ne:h9n):null,(et||g.icon||g.promise)&&g.icon!==null&&(F?.[et]!==null||g.icon)?T.createElement("div",{"data-icon":"",className:fx(O?.icon,g==null||(i=g.classNames)==null?void 0:i.icon)},g.promise||g.type==="loading"&&!g.icon?g.icon||de():null,g.type!=="loading"?rt:null):null,T.createElement("div",{"data-content":"",className:fx(O?.content,g==null||(o=g.classNames)==null?void 0:o.content)},T.createElement("div",{"data-title":"",className:fx(O?.title,g==null||(l=g.classNames)==null?void 0:l.title)},g.jsx?g.jsx:typeof g.title=="function"?g.title():g.title),g.description?T.createElement("div",{"data-description":"",className:fx(L,wt,O?.description,g==null||(u=g.classNames)==null?void 0:u.description)},typeof g.description=="function"?g.description():g.description):null),T.isValidElement(g.cancel)?g.cancel:g.cancel&&Hte(g.cancel)?T.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||I,onClick:Ae=>{Hte(g.cancel)&&mt&&(g.cancel.onClick==null||g.cancel.onClick.call(g.cancel,Ae),vt())},className:fx(O?.cancelButton,g==null||(d=g.classNames)==null?void 0:d.cancelButton)},g.cancel.label):null,T.isValidElement(g.action)?g.action:g.action&&Hte(g.action)?T.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||B,onClick:Ae=>{Hte(g.action)&&(g.action.onClick==null||g.action.onClick.call(g.action,Ae),!Ae.defaultPrevented&&vt())},className:fx(O?.actionButton,g==null||(p=g.classNames)==null?void 0:p.actionButton)},g.action.label):null)};function slt(){if(typeof window>"u"||typeof document>"u")return"ltr";const t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function N9n(t,e){const n={};return[t,e].forEach((r,i)=>{const o=i===1,l=o?"--mobile-offset":"--offset",u=o?E9n:k9n;function d(p){["top","right","bottom","left"].forEach(m=>{n[`${l}-${m}`]=typeof p=="number"?`${p}px`:p})}typeof r=="number"||typeof r=="string"?d(r):typeof r=="object"?["top","right","bottom","left"].forEach(p=>{r[p]===void 0?n[`${l}-${p}`]=u:n[`${l}-${p}`]=typeof r[p]=="number"?`${r[p]}px`:r[p]}):d(u)}),n}const R9n=T.forwardRef(function(e,n){const{id:r,invert:i,position:o="bottom-right",hotkey:l=["altKey","KeyT"],expand:u,closeButton:d,className:p,offset:m,mobileOffset:g,theme:h="light",richColors:f,duration:b,style:y,visibleToasts:v=x9n,toastOptions:_,dir:w=slt(),gap:x=S9n,icons:k,containerAriaLabel:C="Notifications"}=e,[E,S]=T.useState([]),I=T.useMemo(()=>r?E.filter(H=>H.toasterId===r):E.filter(H=>!H.toasterId),[E,r]),B=T.useMemo(()=>Array.from(new Set([o].concat(I.filter(H=>H.position).map(H=>H.position)))),[I,o]),[N,L]=T.useState([]),[M,R]=T.useState(!1),[D,P]=T.useState(!1),[O,F]=T.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),$=T.useRef(null),j=l.join("+").replace(/Key/g,"").replace(/Digit/g,""),Q=T.useRef(null),z=T.useRef(!1),U=T.useCallback(H=>{S(te=>{var V;return(V=te.find(ae=>ae.id===H.id))!=null&&V.delete||QA.dismiss(H.id),te.filter(({id:ae})=>ae!==H.id)})},[]);return T.useEffect(()=>QA.subscribe(H=>{if(H.dismiss){requestAnimationFrame(()=>{S(te=>te.map(V=>V.id===H.id?{...V,delete:!0}:V))});return}setTimeout(()=>{Qi.flushSync(()=>{S(te=>{const V=te.findIndex(ae=>ae.id===H.id);return V!==-1?[...te.slice(0,V),{...te[V],...H},...te.slice(V+1)]:[H,...te]})})})}),[E]),T.useEffect(()=>{if(h!=="system"){F(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?F("dark"):F("light")),typeof window>"u")return;const H=window.matchMedia("(prefers-color-scheme: dark)");try{H.addEventListener("change",({matches:te})=>{F(te?"dark":"light")})}catch{H.addListener(({matches:V})=>{try{F(V?"dark":"light")}catch(ae){console.error(ae)}})}},[h]),T.useEffect(()=>{E.length<=1&&R(!1)},[E]),T.useEffect(()=>{const H=te=>{var V;if(l.every(Z=>te[Z]||te.code===Z)){var ie;R(!0),(ie=$.current)==null||ie.focus()}te.code==="Escape"&&(document.activeElement===$.current||(V=$.current)!=null&&V.contains(document.activeElement))&&R(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[l]),T.useEffect(()=>{if($.current)return()=>{Q.current&&(Q.current.focus({preventScroll:!0}),Q.current=null,z.current=!1)}},[$.current]),T.createElement("section",{ref:n,"aria-label":`${C} ${j}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},B.map((H,te)=>{var V;const[ae,ie]=H.split("-");return I.length?T.createElement("ol",{key:H,dir:w==="auto"?slt():w,tabIndex:-1,ref:$,className:p,"data-sonner-toaster":!0,"data-sonner-theme":O,"data-y-position":ae,"data-x-position":ie,style:{"--front-toast-height":`${((V=N[0])==null?void 0:V.height)||0}px`,"--width":`${C9n}px`,"--gap":`${x}px`,...y,...N9n(m,g)},onBlur:Z=>{z.current&&!Z.currentTarget.contains(Z.relatedTarget)&&(z.current=!1,Q.current&&(Q.current.focus({preventScroll:!0}),Q.current=null))},onFocus:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||z.current||(z.current=!0,Q.current=Z.relatedTarget)},onMouseEnter:()=>R(!0),onMouseMove:()=>R(!0),onMouseLeave:()=>{D||R(!1)},onDragEnd:()=>R(!1),onPointerDown:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||P(!0)},onPointerUp:()=>P(!1)},I.filter(Z=>!Z.position&&te===0||Z.position===H).map((Z,W)=>{var q,Y;return T.createElement(D9n,{key:Z.id,icons:k,index:W,toast:Z,defaultRichColors:f,duration:(q=_?.duration)!=null?q:b,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:i,visibleToasts:v,closeButton:(Y=_?.closeButton)!=null?Y:d,interacting:D,position:H,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:U,toasts:I.filter(X=>X.position==Z.position),heights:N.filter(X=>X.position==Z.position),setHeights:L,expandByDefault:u,gap:x,expanded:M,swipeDirections:e.swipeDirections})})):null}))});function L9n(){return{needRefresh:[!1,()=>{}],offlineReady:[!1,()=>{}],updateServiceWorker:async()=>{}}}const olt=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const M9n=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const P9n=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const llt=t=>{const e=P9n(t);return e.charAt(0).toUpperCase()+e.slice(1)};var O9n={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const F9n=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Q9n=T.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:o,iconNode:l,...u},d)=>T.createElement("svg",{ref:d,...O9n,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:olt("lucide",i),...!o&&!F9n(u)&&{"aria-hidden":"true"},...u},[...l.map(([p,m])=>T.createElement(p,m)),...Array.isArray(o)?o:[o]]));const Wr=(t,e)=>{const n=T.forwardRef(({className:r,...i},o)=>T.createElement(Q9n,{ref:o,iconNode:e,className:olt(`lucide-${M9n(llt(t))}`,`lucide-${t}`,r),...i}));return n.displayName=llt(t),n};const Zke=Wr("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);const $9n=Wr("arrow-left-right",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);const Ax=Wr("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const nP=Wr("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const clt=Wr("audio-lines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);const j9n=Wr("bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);const z9n=Wr("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);const rP=Wr("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);const U9n=Wr("braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const Wte=Wr("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]);const q9n=Wr("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);const oh=Wr("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const yf=Wr("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Xke=Wr("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const fI=Wr("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Yte=Wr("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const G9n=Wr("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const ult=Wr("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);const H9n=Wr("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const W9n=Wr("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Y9n=Wr("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);const V9n=Wr("cloud-off",[["path",{d:"M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057",key:"1uxyv8"}],["path",{d:"M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78",key:"99tcn7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const Jke=Wr("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const dlt=Wr("coins",[["path",{d:"M13.744 17.736a6 6 0 1 1-7.48-7.48",key:"bq4yh3"}],["path",{d:"M15 6h1v4",key:"11y1tn"}],["path",{d:"m6.134 14.768.866-.5 2 3.464",key:"17snzx"}],["circle",{cx:"16",cy:"8",r:"6",key:"14bfc9"}]]);const K9n=Wr("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const Z9n=Wr("compass",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]);const eEe=Wr("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const X9n=Wr("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);const tEe=Wr("credit-card",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);const R1=Wr("crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);const L1=Wr("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const plt=Wr("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const mlt=Wr("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const glt=Wr("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const J9n=Wr("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]);const eQn=Wr("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const nEe=Wr("file-up",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);const hlt=Wr("film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);const flt=Wr("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const rEe=Wr("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const Vte=Wr("gem",[["path",{d:"M10.5 3 8 9l4 13 4-13-2.5-6",key:"b3dvk1"}],["path",{d:"M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z",key:"7w4byz"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);const Alt=Wr("gift",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8",key:"1sqzm4"}],["path",{d:"M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5",key:"kc0143"}],["rect",{x:"3",y:"7",width:"18",height:"4",rx:"1",key:"1hberx"}]]);const blt=Wr("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);const uz=Wr("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const tQn=Wr("heading-1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);const nQn=Wr("heading-2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);const rQn=Wr("heading-3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);const aQn=Wr("heading-4",[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]]);const iQn=Wr("heading-5",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]]);const sQn=Wr("heading-6",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]]);const HN=Wr("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const oQn=Wr("inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);const dz=Wr("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);const lQn=Wr("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);const aP=Wr("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const ylt=Wr("list-ordered",[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]);const vlt=Wr("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);const Ag=Wr("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const aEe=Wr("log-in",[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]);const _lt=Wr("mail-open",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);const Kte=Wr("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const cQn=Wr("message-square-plus",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]]);const iEe=Wr("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const wlt=Wr("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const uQn=Wr("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const dQn=Wr("octagon-x",[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const pQn=Wr("panel-right-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);const pz=Wr("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);const mQn=Wr("pilcrow",[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]]);const xlt=Wr("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const gQn=Wr("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);const hQn=Wr("redo-2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);const klt=Wr("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const fQn=Wr("scale",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]]);const AQn=Wr("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const bQn=Wr("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);const yQn=Wr("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const Zte=Wr("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const vQn=Wr("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const bx=Wr("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);const _Qn=Wr("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const wQn=Wr("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);const Elt=Wr("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const xQn=Wr("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]);const Xte=Wr("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const sEe=Wr("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Clt=Wr("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);const kQn=Wr("unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);const Jte=Wr("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const ene=Wr("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);const Slt=Wr("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);const EQn=Wr("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);const M1=Wr("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const tne=Wr("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function CQn({title:t,description:e,actionLabel:n,cancelLabel:r,onAction:i,onCancel:o}){return A.jsxs("div",{className:"flex w-[calc(100vw-2rem)] max-w-[360px] flex-col gap-3 rounded-lg border border-neutral-200/60 bg-white p-4 shadow-lg dark:border-neutral-800/60 dark:bg-neutral-900",children:[A.jsxs("div",{className:"flex items-start gap-3",children:[A.jsx("div",{className:"mt-0.5 shrink-0 rounded-full bg-indigo-500/10 p-1.5",children:A.jsx(klt,{className:"size-4 text-indigo-500"})}),A.jsxs("div",{className:"min-w-0",children:[A.jsx("p",{className:"text-[13px] font-semibold text-neutral-900 dark:text-neutral-100",children:t}),A.jsx("p",{className:"mt-0.5 text-xs text-neutral-500 dark:text-neutral-400",children:e})]})]}),A.jsxs("div",{className:"flex flex-col gap-1.5",children:[A.jsx("button",{onClick:i,className:"w-full rounded-lg bg-indigo-500 px-3 py-2 text-[13px] font-semibold text-white transition-colors hover:bg-indigo-600 active:bg-indigo-700",children:n}),A.jsx("button",{onClick:o,className:"w-full rounded-lg bg-neutral-100/80 px-3 py-2 text-[13px] text-neutral-600 transition-colors hover:bg-neutral-200/80 dark:bg-white/[0.06] dark:text-neutral-400 dark:hover:bg-white/[0.1]",children:r})]})]})}function SQn(){const{t}=kn(),e=T.useRef(null),n=T.useRef(null),{needRefresh:[r],updateServiceWorker:i}=L9n();T.useEffect(()=>()=>{n.current?.(),n.current=null},[]);const o=T.useCallback(()=>{i()},[i]);T.useEffect(()=>{if(!r){e.current!=null&&(Rr.dismiss(e.current),e.current=null);return}e.current=Rr.custom(l=>CQn({title:t("app.pwa.updateAvailableTitle","New version available"),description:t("app.pwa.updateAvailableDescription","A new version of Xyzen is ready. Refresh to update."),actionLabel:t("app.pwa.updateAction","Refresh"),cancelLabel:t("app.pwa.updateDismiss","Dismiss"),onAction:o,onCancel:()=>{Rr.dismiss(l),e.current=null}}),{duration:1/0})},[r,o,t])}function IQn(){const t=ih(),e=(t.isAuthenticated||!!t.token)&&FA("billing"),n=Un(i=>i.fetchWallet),r=Un(i=>i.connectWalletEvents);T.useEffect(()=>e?(n(),r()):void 0,[e,n,r])}const Ilt=[];function AI(){return Cm(Ys(t=>{const e=t.activeChatChannel,n=e?t.channels[e]:void 0;return{channelId:e,agentId:n?.agentId??null,sessionId:n?.sessionId??null,connected:n?.connected??!1,responding:n?.responding??!1,aborting:n?.aborting??!1,model_tier:n?.model_tier??null,model:n?.model??null,knowledge_set_id:n?.knowledge_set_id??null,sandbox_backend:n?.sandbox_backend??null,provider_id:n?.provider_id??null,title:n?.title??"",tokenUsage:n?.tokenUsage??0,inputTokens:n?.inputTokens??0,contextUsage:n?.contextUsage}}))}function TQn(){return Cm(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.messages??Ilt:Ilt})}function BQn(){return Cm(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.responding??!1:!1})}function DQn(){return Cm(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.agentId??null:null})}function Tlt(){return Cm(t=>t.runningAgentIds)}function NQn(){return Cm(t=>t.activeTopicCountByAgent)}function Blt(){return Cm(t=>t.respondingChannelIds)}function Dlt(){return Cm(Ys(t=>{const e={};for(const[n,r]of Object.entries(t.channels))r.agentId&&(e[n]=r.agentId);return e}))}function RQn(t){return t==="Connecting"||typeof t=="object"&&"Connected"in t}async function Nlt(t){const e=qte(),n=Un.getState().runners;if(e){if(n.find(l=>l.id===e.runnerId)?.is_active)return e;lz()}const r=await t(jte);if(!r)return null;const i={runnerId:r.runner.id,token:r.token,name:jte};return elt(i),i}function LQn(t){const{createRunnerToken:e,fetchRunners:n,runners:r,updateSessionConfig:i}=Un(Ys(u=>({createRunnerToken:u.createRunnerToken,fetchRunners:u.fetchRunners,runners:u.runners,updateSessionConfig:u.updateSessionConfig}))),o=AI(),l=T.useRef(null);T.useEffect(()=>{if(!_l()||t!=="succeeded")return;let u=!1;return(async()=>{if(await n(),u)return;const p=await Hke().catch(()=>"Disconnected");if(RQn(p)){await n();return}let m=await Nlt(e);if(!(!m||u)){try{await zte(m.token,Ute())}catch(g){if(String(g).includes("already running")){await n();return}if(lz(),m=await Nlt(e),!m||u)return;await zte(m.token,Ute())}await n()}})(),()=>{u=!0}},[t,e,n]),T.useEffect(()=>{if(!_l()||t!=="succeeded"||!o.sessionId||o.sandbox_backend)return;const u=qte();if(!u)return;const d=r.find(m=>m.id===u.runnerId);if(!d?.is_online||!d.is_active)return;const p=`${o.sessionId}:${u.runnerId}`;l.current!==p&&(l.current=p,i(o.sessionId,{sandbox_backend:`runner:${u.runnerId}`}).catch(()=>{l.current=null}))},[t,o.sandbox_backend,o.sessionId,r,i])}let mz={state:"idle"};const oEe=new Set;let lEe=null;function P1(t){mz=t,oEe.forEach(e=>e(t))}function MQn(){return mz}function PQn(t){return oEe.add(t),()=>oEe.delete(t)}async function Rlt(){if(_l()){P1({state:"checking"});try{const{check:t}=await Promise.resolve().then(()=>NJn),e=await t();e?(lEe=e,P1({state:"available",info:{version:e.version,date:e.date??void 0,body:e.body??void 0}})):P1({state:"idle"})}catch(t){console.error("[updater] check failed:",t),P1({state:"error",message:t instanceof Error?t.message:"Update check failed"}),setTimeout(()=>{mz.state==="error"&&P1({state:"idle"})},5e3)}}}async function OQn(){if(lEe)try{let t=0,e=0;await lEe.downloadAndInstall(r=>{switch(r.event){case"Started":t=r.data.contentLength??0,P1({state:"downloading",progress:0});break;case"Progress":e+=r.data.chunkLength,P1({state:"downloading",progress:t>0?e/t:0});break;case"Finished":P1({state:"ready"});break}});const{relaunch:n}=await Promise.resolve().then(()=>MJn);await n()}catch(t){console.error("[updater] download failed:",t),P1({state:"error",message:t instanceof Error?t.message:"Download failed"})}}const FQn=14400*1e3;function QQn(){if(!_l())return()=>{};const t=setTimeout(()=>Rlt(),5e3),e=setInterval(()=>{(mz.state==="idle"||mz.state==="error")&&Rlt()},FQn);return()=>{clearTimeout(t),clearInterval(e)}}function $Qn(){const{t}=kn(),e=T.useSyncExternalStore(PQn,MQn),n=T.useRef(null);return T.useEffect(()=>{if(_l())return QQn()},[]),T.useEffect(()=>{e.state==="available"&&n.current!==e.info.version&&(n.current=e.info.version,Rr(t("settings.about.updateAvailable",{version:e.info.version,defaultValue:"New version {{version}} is available"}),{description:t("settings.about.updateDescription",{defaultValue:"Restart to apply the update."}),duration:1/0,action:{label:t("settings.about.updateNow",{defaultValue:"Update Now"}),onClick:()=>OQn()}}))},[e,t]),e}const jQn=({...t})=>A.jsx(R9n,{theme:"system",className:"toaster group",richColors:!0,icons:{success:A.jsx(G9n,{className:"size-4"}),info:A.jsx(dz,{className:"size-4"}),warning:A.jsx(sEe,{className:"size-4"}),error:A.jsx(dQn,{className:"size-4"}),loading:A.jsx(Ag,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...t}),gz=T.createContext({});function bI(t){const e=T.useRef(null);return e.current===null&&(e.current=t()),e.current}const nne=typeof window<"u"?T.useLayoutEffect:T.useEffect,rne=T.createContext(null);function cEe(t,e){t.indexOf(e)===-1&&t.push(e)}function iP(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const yx=(t,e,n)=>n>e?e:n<t?t:n;function uEe(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let sP=()=>{},Xv=()=>{};typeof process<"u"&&process.env?.NODE_ENV!=="production"&&(sP=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(uEe(e,n))},Xv=(t,e,n)=>{if(!t)throw new Error(uEe(e,n))});const yI={},Llt=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Mlt(t){return typeof t=="object"&&t!==null}const Plt=t=>/^0[^.\s]+$/u.test(t);function Olt(t){let e;return()=>(e===void 0&&(e=t()),e)}const oy=t=>t,zQn=(t,e)=>n=>e(t(n)),hz=(...t)=>t.reduce(zQn),oP=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class dEe{constructor(){this.subscriptions=[]}add(e){return cEe(this.subscriptions,e),()=>iP(this.subscriptions,e)}notify(e,n,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,r);else for(let o=0;o<i;o++){const l=this.subscriptions[o];l&&l(e,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const vf=t=>t*1e3,ly=t=>t/1e3;function Flt(t,e){return e?t*(1e3/e):0}const Qlt=new Set;function pEe(t,e,n){t||Qlt.has(e)||(console.warn(uEe(e,n)),Qlt.add(e))}const UQn=(t,e,n)=>{const r=e-t;return((n-t)%r+r)%r+t},$lt=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,qQn=1e-7,GQn=12;function HQn(t,e,n,r,i){let o,l,u=0;do l=e+(n-e)/2,o=$lt(l,r,i)-t,o>0?n=l:e=l;while(Math.abs(o)>qQn&&++u<GQn);return l}function fz(t,e,n,r){if(t===e&&n===r)return oy;const i=o=>HQn(o,0,1,t,n);return o=>o===0||o===1?o:$lt(i(o),e,r)}const jlt=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,zlt=t=>e=>1-t(1-e),Ult=fz(.33,1.53,.69,.99),mEe=zlt(Ult),qlt=jlt(mEe),Glt=t=>t>=1?1:(t*=2)<1?.5*mEe(t):.5*(2-Math.pow(2,-10*(t-1))),gEe=t=>1-Math.sin(Math.acos(t)),Hlt=zlt(gEe),Wlt=jlt(gEe),WQn=fz(.42,0,1,1),hEe=fz(0,0,.58,1),Ylt=fz(.42,0,.58,1),Vlt=t=>Array.isArray(t)&&typeof t[0]!="number";function Klt(t,e){return Vlt(t)?t[UQn(0,t.length,e)]:t}const Zlt=t=>Array.isArray(t)&&typeof t[0]=="number",Xlt={linear:oy,easeIn:WQn,easeInOut:Ylt,easeOut:hEe,circIn:gEe,circInOut:Wlt,circOut:Hlt,backIn:mEe,backInOut:qlt,backOut:Ult,anticipate:Glt},YQn=t=>typeof t=="string",Jlt=t=>{if(Zlt(t)){Xv(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,r,i]=t;return fz(e,n,r,i)}else if(YQn(t))return Xv(Xlt[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Xlt[t];return t},ane=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function VQn(t,e){let n=new Set,r=new Set,i=!1,o=!1;const l=new WeakSet;let u={delta:0,timestamp:0,isProcessing:!1};function d(m){l.has(m)&&(p.schedule(m),t()),m(u)}const p={schedule:(m,g=!1,h=!1)=>{const b=h&&i?n:r;return g&&l.add(m),b.add(m),m},cancel:m=>{r.delete(m),l.delete(m)},process:m=>{if(u=m,i){o=!0;return}i=!0;const g=n;n=r,r=g,n.forEach(d),n.clear(),i=!1,o&&(o=!1,p.process(m))}};return p}const KQn=40;function ect(t,e){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,l=ane.reduce((x,k)=>(x[k]=VQn(o),x),{}),{setup:u,read:d,resolveKeyframes:p,preUpdate:m,update:g,preRender:h,render:f,postRender:b}=l,y=()=>{const x=yI.useManualTiming,k=x?i.timestamp:performance.now();n=!1,x||(i.delta=r?1e3/60:Math.max(Math.min(k-i.timestamp,KQn),1)),i.timestamp=k,i.isProcessing=!0,u.process(i),d.process(i),p.process(i),m.process(i),g.process(i),h.process(i),f.process(i),b.process(i),i.isProcessing=!1,n&&e&&(r=!1,t(y))},v=()=>{n=!0,r=!0,i.isProcessing||t(y)};return{schedule:ane.reduce((x,k)=>{const C=l[k];return x[k]=(E,S=!1,I=!1)=>(n||v(),C.schedule(E,S,I)),x},{}),cancel:x=>{for(let k=0;k<ane.length;k++)l[ane[k]].cancel(x)},state:i,steps:l}}const{schedule:Fl,cancel:O1,state:bg,steps:fEe}=ect(typeof requestAnimationFrame<"u"?requestAnimationFrame:oy,!0);let ine;function ZQn(){ine=void 0}const _f={now:()=>(ine===void 0&&_f.set(bg.isProcessing||yI.useManualTiming?bg.timestamp:performance.now()),ine),set:t=>{ine=t,queueMicrotask(ZQn)}},tct=t=>e=>typeof e=="string"&&e.startsWith(t),nct=tct("--"),XQn=tct("var(--"),AEe=t=>XQn(t)?JQn.test(t.split("/*")[0].trim()):!1,JQn=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function rct(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const lP={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Az={...lP,transform:t=>yx(0,1,t)},sne={...lP,default:1},bz=t=>Math.round(t*1e5)/1e5,bEe=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function e$n(t){return t==null}const t$n=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,yEe=(t,e)=>n=>!!(typeof n=="string"&&t$n.test(n)&&n.startsWith(t)||e&&!e$n(n)&&Object.prototype.hasOwnProperty.call(n,e)),act=(t,e,n)=>r=>{if(typeof r!="string")return r;const[i,o,l,u]=r.match(bEe);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(l),alpha:u!==void 0?parseFloat(u):1}},n$n=t=>yx(0,255,t),vEe={...lP,transform:t=>Math.round(n$n(t))},WN={test:yEe("rgb","red"),parse:act("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+vEe.transform(t)+", "+vEe.transform(e)+", "+vEe.transform(n)+", "+bz(Az.transform(r))+")"};function r$n(t){let e="",n="",r="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,r+=r,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const _Ee={test:yEe("#"),parse:r$n,transform:WN.transform},yz=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),vI=yz("deg"),vx=yz("%"),ei=yz("px"),a$n=yz("vh"),i$n=yz("vw"),ict={...vx,parse:t=>vx.parse(t)/100,transform:t=>vx.transform(t*100)},cP={test:yEe("hsl","hue"),parse:act("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+vx.transform(bz(e))+", "+vx.transform(bz(n))+", "+bz(Az.transform(r))+")"},np={test:t=>WN.test(t)||_Ee.test(t)||cP.test(t),parse:t=>WN.test(t)?WN.parse(t):cP.test(t)?cP.parse(t):_Ee.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?WN.transform(t):cP.transform(t),getAnimatableNone:t=>{const e=np.parse(t);return e.alpha=0,np.transform(e)}},s$n=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function o$n(t){return isNaN(t)&&typeof t=="string"&&(t.match(bEe)?.length||0)+(t.match(s$n)?.length||0)>0}const sct="number",oct="color",l$n="var",c$n="var(",lct="${}",u$n=/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 uP(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},i=[];let o=0;const u=e.replace(u$n,d=>(np.test(d)?(r.color.push(o),i.push(oct),n.push(np.parse(d))):d.startsWith(c$n)?(r.var.push(o),i.push(l$n),n.push(d)):(r.number.push(o),i.push(sct),n.push(parseFloat(d))),++o,lct)).split(lct);return{values:n,split:u,indexes:r,types:i}}function d$n(t){return uP(t).values}function cct({split:t,types:e}){const n=t.length;return r=>{let i="";for(let o=0;o<n;o++)if(i+=t[o],r[o]!==void 0){const l=e[o];l===sct?i+=bz(r[o]):l===oct?i+=np.transform(r[o]):i+=r[o]}return i}}function p$n(t){return cct(uP(t))}const m$n=t=>typeof t=="number"?0:np.test(t)?np.getAnimatableNone(t):t,g$n=(t,e)=>typeof t=="number"?e?.trim().endsWith("/")?t:0:m$n(t);function h$n(t){const e=uP(t);return cct(e)(e.values.map((r,i)=>g$n(r,e.split[i])))}const Jv={test:o$n,parse:d$n,createTransformer:p$n,getAnimatableNone:h$n};function wEe(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function f$n({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let i=0,o=0,l=0;if(!e)i=o=l=n;else{const u=n<.5?n*(1+e):n+e-n*e,d=2*n-u;i=wEe(d,u,t+1/3),o=wEe(d,u,t),l=wEe(d,u,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:r}}function one(t,e){return n=>n>0?e:t}const Nc=(t,e,n)=>t+(e-t)*n,xEe=(t,e,n)=>{const r=t*t,i=n*(e*e-r)+r;return i<0?0:Math.sqrt(i)},A$n=[_Ee,WN,cP],b$n=t=>A$n.find(e=>e.test(t));function uct(t){const e=b$n(t);if(sP(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===cP&&(n=f$n(n)),n}const dct=(t,e)=>{const n=uct(t),r=uct(e);if(!n||!r)return one(t,e);const i={...n};return o=>(i.red=xEe(n.red,r.red,o),i.green=xEe(n.green,r.green,o),i.blue=xEe(n.blue,r.blue,o),i.alpha=Nc(n.alpha,r.alpha,o),WN.transform(i))},kEe=new Set(["none","hidden"]);function y$n(t,e){return kEe.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function v$n(t,e){return n=>Nc(t,e,n)}function EEe(t){return typeof t=="number"?v$n:typeof t=="string"?AEe(t)?one:np.test(t)?dct:x$n:Array.isArray(t)?pct:typeof t=="object"?np.test(t)?dct:_$n:one}function pct(t,e){const n=[...t],r=n.length,i=t.map((o,l)=>EEe(o)(o,e[l]));return o=>{for(let l=0;l<r;l++)n[l]=i[l](o);return n}}function _$n(t,e){const n={...t,...e},r={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(r[i]=EEe(t[i])(t[i],e[i]));return i=>{for(const o in r)n[o]=r[o](i);return n}}function w$n(t,e){const n=[],r={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],l=t.indexes[o][r[o]],u=t.values[l]??0;n[i]=u,r[o]++}return n}const x$n=(t,e)=>{const n=Jv.createTransformer(e),r=uP(t),i=uP(e);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?kEe.has(t)&&!i.values.length||kEe.has(e)&&!r.values.length?y$n(t,e):hz(pct(w$n(r,i),i.values),n):(sP(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),one(t,e))};function mct(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Nc(t,e,n):EEe(t)(t,e)}const k$n=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Fl.update(e,n),stop:()=>O1(e),now:()=>bg.isProcessing?bg.timestamp:_f.now()}},gct=(t,e,n=10)=>{let r="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)r+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},lne=2e4;function CEe(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<lne;)e+=n,r=t.next(e);return e>=lne?1/0:e}function hct(t,e=100,n){const r=n({...t,keyframes:[0,e]}),i=Math.min(CEe(r),lne);return{type:"keyframes",ease:o=>r.next(i*o).value/e,duration:ly(i)}}const Mu={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};function SEe(t,e){return t*Math.sqrt(1-e*e)}const E$n=12;function C$n(t,e,n){let r=n;for(let i=1;i<E$n;i++)r=r-t(r)/e(r);return r}const IEe=.001;function S$n({duration:t=Mu.duration,bounce:e=Mu.bounce,velocity:n=Mu.velocity,mass:r=Mu.mass}){let i,o;sP(t<=vf(Mu.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let l=1-e;l=yx(Mu.minDamping,Mu.maxDamping,l),t=yx(Mu.minDuration,Mu.maxDuration,ly(t)),l<1?(i=p=>{const m=p*l,g=m*t,h=m-n,f=SEe(p,l),b=Math.exp(-g);return IEe-h/f*b},o=p=>{const g=p*l*t,h=g*n+n,f=Math.pow(l,2)*Math.pow(p,2)*t,b=Math.exp(-g),y=SEe(Math.pow(p,2),l);return(-i(p)+IEe>0?-1:1)*((h-f)*b)/y}):(i=p=>{const m=Math.exp(-p*t),g=(p-n)*t+1;return-IEe+m*g},o=p=>{const m=Math.exp(-p*t),g=(n-p)*(t*t);return m*g});const u=5/t,d=C$n(i,o,u);if(t=vf(t),isNaN(d))return{stiffness:Mu.stiffness,damping:Mu.damping,duration:t};{const p=Math.pow(d,2)*r;return{stiffness:p,damping:l*2*Math.sqrt(r*p),duration:t}}}const I$n=["duration","bounce"],T$n=["stiffness","damping","mass"];function fct(t,e){return e.some(n=>t[n]!==void 0)}function B$n(t){let e={velocity:Mu.velocity,stiffness:Mu.stiffness,damping:Mu.damping,mass:Mu.mass,isResolvedFromDuration:!1,...t};if(!fct(t,T$n)&&fct(t,I$n))if(e.velocity=0,t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,o=2*yx(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:Mu.mass,stiffness:i,damping:o}}else{const n=S$n({...t,velocity:0});e={...e,...n,mass:Mu.mass},e.isResolvedFromDuration=!0}return e}function vz(t=Mu.visualDuration,e=Mu.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:i}=n;const o=n.keyframes[0],l=n.keyframes[n.keyframes.length-1],u={done:!1,value:o},{stiffness:d,damping:p,mass:m,duration:g,velocity:h,isResolvedFromDuration:f}=B$n({...n,velocity:-ly(n.velocity||0)}),b=h||0,y=p/(2*Math.sqrt(d*m)),v=l-o,_=ly(Math.sqrt(d/m)),w=Math.abs(v)<5;r||(r=w?Mu.restSpeed.granular:Mu.restSpeed.default),i||(i=w?Mu.restDelta.granular:Mu.restDelta.default);let x,k,C,E,S,I;if(y<1)C=SEe(_,y),E=(b+y*_*v)/C,x=N=>{const L=Math.exp(-y*_*N);return l-L*(E*Math.sin(C*N)+v*Math.cos(C*N))},S=y*_*E+v*C,I=y*_*v-E*C,k=N=>Math.exp(-y*_*N)*(S*Math.sin(C*N)+I*Math.cos(C*N));else if(y===1){x=L=>l-Math.exp(-_*L)*(v+(b+_*v)*L);const N=b+_*v;k=L=>Math.exp(-_*L)*(_*N*L-b)}else{const N=_*Math.sqrt(y*y-1);x=D=>{const P=Math.exp(-y*_*D),O=Math.min(N*D,300);return l-P*((b+y*_*v)*Math.sinh(O)+N*v*Math.cosh(O))/N};const L=(b+y*_*v)/N,M=y*_*L-v*N,R=y*_*v-L*N;k=D=>{const P=Math.exp(-y*_*D),O=Math.min(N*D,300);return P*(M*Math.sinh(O)+R*Math.cosh(O))}}const B={calculatedDuration:f&&g||null,velocity:N=>vf(k(N)),next:N=>{if(!f&&y<1){const M=Math.exp(-y*_*N),R=Math.sin(C*N),D=Math.cos(C*N),P=l-M*(E*R+v*D),O=vf(M*(S*R+I*D));return u.done=Math.abs(O)<=r&&Math.abs(l-P)<=i,u.value=u.done?l:P,u}const L=x(N);if(f)u.done=N>=g;else{const M=vf(k(N));u.done=Math.abs(M)<=r&&Math.abs(l-L)<=i}return u.value=u.done?l:L,u},toString:()=>{const N=Math.min(CEe(B),lne),L=gct(M=>B.next(N*M).value,N,30);return N+"ms "+L},toTransition:()=>{}};return B}vz.applyToOptions=t=>{const e=hct(t,100,vz);return t.ease=e.ease,t.duration=vf(e.duration),t.type="keyframes",t};const D$n=5;function Act(t,e,n){const r=Math.max(e-D$n,0);return Flt(n-t(r),e-r)}function TEe({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:l,min:u,max:d,restDelta:p=.5,restSpeed:m}){const g=t[0],h={done:!1,value:g},f=I=>u!==void 0&&I<u||d!==void 0&&I>d,b=I=>u===void 0?d:d===void 0||Math.abs(u-I)<Math.abs(d-I)?u:d;let y=n*e;const v=g+y,_=l===void 0?v:l(v);_!==v&&(y=_-g);const w=I=>-y*Math.exp(-I/r),x=I=>_+w(I),k=I=>{const B=w(I),N=x(I);h.done=Math.abs(B)<=p,h.value=h.done?_:N};let C,E;const S=I=>{f(h.value)&&(C=I,E=vz({keyframes:[h.value,b(h.value)],velocity:Act(x,I,h.value),damping:i,stiffness:o,restDelta:p,restSpeed:m}))};return S(0),{calculatedDuration:null,next:I=>{let B=!1;return!E&&C===void 0&&(B=!0,k(I),S(I)),C!==void 0&&I>=C?E.next(I-C):(!B&&k(I),h)}}}function N$n(t,e,n){const r=[],i=n||yI.mix||mct,o=t.length-1;for(let l=0;l<o;l++){let u=i(t[l],t[l+1]);if(e){const d=Array.isArray(e)?e[l]||oy:e;u=hz(d,u)}r.push(u)}return r}function bct(t,e,{clamp:n=!0,ease:r,mixer:i}={}){const o=t.length;if(Xv(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const l=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const u=N$n(e,r,i),d=u.length,p=m=>{if(l&&m<t[0])return e[0];let g=0;if(d>1)for(;g<t.length-2&&!(m<t[g+1]);g++);const h=oP(t[g],t[g+1],m);return u[g](h)};return n?m=>p(yx(t[0],t[o-1],m)):p}function yct(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const i=oP(0,e,r);t.push(Nc(n,1,i))}}function vct(t){const e=[0];return yct(e,t.length-1),e}function R$n(t,e){return t.map(n=>n*e)}function L$n(t,e){return t.map(()=>e||Ylt).splice(0,t.length-1)}function dP({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const i=Vlt(r)?r.map(Jlt):Jlt(r),o={done:!1,value:e[0]},l=R$n(n&&n.length===e.length?n:vct(e),t),u=bct(l,e,{ease:Array.isArray(i)?i:L$n(e,i)});return{calculatedDuration:t,next:d=>(o.value=u(d),o.done=d>=t,o)}}const M$n=t=>t!==null;function cne(t,{repeat:e,repeatType:n="loop"},r,i=1){const o=t.filter(M$n),u=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!u||r===void 0?o[u]:r}const P$n={decay:TEe,inertia:TEe,tween:dP,keyframes:dP,spring:vz};function _ct(t){typeof t.type=="string"&&(t.type=P$n[t.type])}class BEe{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const O$n=t=>t/100;class _z extends BEe{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==_f.now()&&this.tick(_f.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;_ct(e);const{type:n=dP,repeat:r=0,repeatDelay:i=0,repeatType:o,velocity:l=0}=e;let{keyframes:u}=e;const d=n||dP;process.env.NODE_ENV!=="production"&&d!==dP&&Xv(u.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${u}`,"spring-two-frames"),d!==dP&&typeof u[0]!="number"&&(this.mixKeyframes=hz(O$n,mct(u[0],u[1])),u=[0,100]);const p=d({...e,keyframes:u});o==="mirror"&&(this.mirroredGenerator=d({...e,keyframes:[...u].reverse(),velocity:-l})),p.calculatedDuration===null&&(p.calculatedDuration=CEe(p));const{calculatedDuration:m}=p;this.calculatedDuration=m,this.resolvedDuration=m+i,this.totalDuration=this.resolvedDuration*(r+1)-i,this.generator=p}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:r,totalDuration:i,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:u,calculatedDuration:d}=this;if(this.startTime===null)return r.next(0);const{delay:p=0,keyframes:m,repeat:g,repeatType:h,repeatDelay:f,type:b,onUpdate:y,finalKeyframe:v}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const _=this.currentTime-p*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?_<0:_>i;this.currentTime=Math.max(_,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let x=this.currentTime,k=r;if(g){const I=Math.min(this.currentTime,i)/u;let B=Math.floor(I),N=I%1;!N&&I>=1&&(N=1),N===1&&B--,B=Math.min(B,g+1),B%2&&(h==="reverse"?(N=1-N,f&&(N-=f/u)):h==="mirror"&&(k=l)),x=yx(0,1,N)*u}let C;w?(this.delayState.value=m[0],C=this.delayState):C=k.next(x),o&&!w&&(C.value=o(C.value));let{done:E}=C;!w&&d!==null&&(E=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const S=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return S&&b!==TEe&&(C.value=cne(m,this.options,v,this.speed)),y&&y(C.value),S&&this.finish(),C}then(e,n){return this.finished.then(e,n)}get duration(){return ly(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ly(e)}get time(){return ly(this.currentTime)}set time(e){e=vf(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=e,this.tick(e))}getGeneratorVelocity(){const e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);const n=this.generator.next(e).value;return Act(r=>this.generator.next(r).value,e,n)}get speed(){return this.playbackSpeed}set speed(e){const n=this.playbackSpeed!==e;n&&this.driver&&this.updateTime(_f.now()),this.playbackSpeed=e,n&&this.driver&&(this.time=ly(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=k$n,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),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(_f.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function F$n(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const YN=t=>t*180/Math.PI,DEe=t=>{const e=YN(Math.atan2(t[1],t[0]));return NEe(e)},Q$n={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:DEe,rotateZ:DEe,skewX:t=>YN(Math.atan(t[1])),skewY:t=>YN(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},NEe=t=>(t=t%360,t<0&&(t+=360),t),wct=DEe,xct=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),kct=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),$$n={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:xct,scaleY:kct,scale:t=>(xct(t)+kct(t))/2,rotateX:t=>NEe(YN(Math.atan2(t[6],t[5]))),rotateY:t=>NEe(YN(Math.atan2(-t[2],t[0]))),rotateZ:wct,rotate:wct,skewX:t=>YN(Math.atan(t[4])),skewY:t=>YN(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function REe(t){return t.includes("scale")?1:0}function LEe(t,e){if(!t||t==="none")return REe(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=$$n,i=n;else{const u=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Q$n,i=u}if(!i)return REe(e);const o=r[e],l=i[1].split(",").map(z$n);return typeof o=="function"?o(l):l[o]}const j$n=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return LEe(n,e)};function z$n(t){return parseFloat(t.trim())}const pP=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],mP=new Set(pP),Ect=t=>t===lP||t===ei,U$n=new Set(["x","y","z"]),q$n=pP.filter(t=>!U$n.has(t));function G$n(t){const e=[];return q$n.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const _I={width:({x:t},{paddingLeft:e="0",paddingRight:n="0",boxSizing:r})=>{const i=t.max-t.min;return r==="border-box"?i:i-parseFloat(e)-parseFloat(n)},height:({y:t},{paddingTop:e="0",paddingBottom:n="0",boxSizing:r})=>{const i=t.max-t.min;return r==="border-box"?i:i-parseFloat(e)-parseFloat(n)},top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>LEe(e,"x"),y:(t,{transform:e})=>LEe(e,"y")};_I.translateX=_I.x,_I.translateY=_I.y;const VN=new Set;let MEe=!1,PEe=!1,OEe=!1;function Cct(){if(PEe){const t=Array.from(VN).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const i=G$n(r);i.length&&(n.set(r,i),r.render())}),t.forEach(r=>r.measureInitialState()),e.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([o,l])=>{r.getValue(o)?.set(l)})}),t.forEach(r=>r.measureEndState()),t.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}PEe=!1,MEe=!1,VN.forEach(t=>t.complete(OEe)),VN.clear()}function Sct(){VN.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(PEe=!0)})}function H$n(){OEe=!0,Sct(),Cct(),OEe=!1}class FEe{constructor(e,n,r,i,o,l=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=r,this.motionValue=i,this.element=o,this.isAsync=l}scheduleResolve(){this.state="scheduled",this.isAsync?(VN.add(this),MEe||(MEe=!0,Fl.read(Sct),Fl.resolveKeyframes(Cct))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:r,motionValue:i}=this;if(e[0]===null){const o=i?.get(),l=e[e.length-1];if(o!==void 0)e[0]=o;else if(r&&n){const u=r.readValue(n,l);u!=null&&(e[0]=u)}e[0]===void 0&&(e[0]=l),i&&o===void 0&&i.set(e[0])}F$n(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),VN.delete(this)}cancel(){this.state==="scheduled"&&(VN.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const W$n=t=>t.startsWith("--");function Ict(t,e,n){W$n(e)?t.style.setProperty(e,n):t.style[e]=n}const Y$n={};function Tct(t,e){const n=Olt(t);return()=>Y$n[e]??n()}const V$n=Tct(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),Bct=Tct(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),wz=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,Dct={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:wz([0,.65,.55,1]),circOut:wz([.55,0,1,.45]),backIn:wz([.31,.01,.66,-.59]),backOut:wz([.33,1.53,.69,.99])};function Nct(t,e){if(t)return typeof t=="function"?Bct()?gct(t,e):"ease-out":Zlt(t)?wz(t):Array.isArray(t)?t.map(n=>Nct(n,e)||Dct.easeOut):Dct[t]}function K$n(t,e,n,{delay:r=0,duration:i=300,repeat:o=0,repeatType:l="loop",ease:u="easeOut",times:d}={},p=void 0){const m={[e]:n};d&&(m.offset=d);const g=Nct(u,i);Array.isArray(g)&&(m.easing=g);const h={delay:r,duration:i,easing:Array.isArray(g)?"linear":g,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return p&&(h.pseudoElement=p),t.animate(m,h)}function QEe(t){return typeof t=="function"&&"applyToOptions"in t}function Z$n({type:t,...e}){return QEe(t)&&Bct()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Rct extends BEe{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:n,name:r,keyframes:i,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:u,onComplete:d}=e;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=e,Xv(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const p=Z$n(e);this.animation=K$n(n,r,i,p,o),p.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const m=cne(i,this.options,u,this.speed);this.updateMotionValue&&this.updateMotionValue(m),Ict(n,r,m),this.animation.cancel()}d?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return ly(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ly(e)}get time(){return ly(Number(this.animation.currentTime)||0)}set time(e){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=vf(e),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:n,rangeEnd:r,observe:i}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&V$n()?(this.animation.timeline=e,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),oy):i(this)}}const Lct={anticipate:Glt,backInOut:qlt,circInOut:Wlt};function X$n(t){return t in Lct}function J$n(t){typeof t.ease=="string"&&X$n(t.ease)&&(t.ease=Lct[t.ease])}const $Ee=10;class ejn extends Rct{constructor(e){J$n(e),_ct(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:r,onComplete:i,element:o,...l}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const u=new _z({...l,autoplay:!1}),d=Math.max($Ee,_f.now()-this.startTime),p=yx(0,$Ee,d-$Ee),m=u.sample(d).value,{name:g}=this.options;o&&g&&Ict(o,g,m),n.setWithVelocity(u.sample(Math.max(0,d-p)).value,m,p),u.stop()}}const Mct=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Jv.test(t)||t==="0")&&!t.startsWith("url("));function tjn(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function njn(t,e,n,r){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],l=Mct(i,e),u=Mct(o,e);return sP(l===u,`You are trying to animate ${e} from "${i}" to "${o}". "${l?o:i}" is not an animatable value.`,"value-not-animatable"),!l||!u?!1:tjn(t)||(n==="spring"||QEe(n))&&r}function jEe(t){t.duration=0,t.type="keyframes"}const Pct=new Set(["opacity","clipPath","filter","transform"]),rjn=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ajn(t){for(let e=0;e<t.length;e++)if(typeof t[e]=="string"&&rjn.test(t[e]))return!0;return!1}const ijn=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),sjn=Olt(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function ojn(t){const{motionValue:e,name:n,repeatDelay:r,repeatType:i,damping:o,type:l,keyframes:u}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:p,transformTemplate:m}=e.owner.getProps();return sjn()&&n&&(Pct.has(n)||ijn.has(n)&&ajn(u))&&(n!=="transform"||!m)&&!p&&!r&&i!=="mirror"&&o!==0&&l!=="inertia"}const ljn=40;class cjn extends BEe{constructor({autoplay:e=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:l="loop",keyframes:u,name:d,motionValue:p,element:m,...g}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=_f.now();const h={autoplay:e,delay:n,type:r,repeat:i,repeatDelay:o,repeatType:l,name:d,motionValue:p,element:m,...g},f=m?.KeyframeResolver||FEe;this.keyframeResolver=new f(u,(b,y,v)=>this.onKeyframesResolved(b,y,h,!v),d,p,m),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,r,i){this.keyframeResolver=void 0;const{name:o,type:l,velocity:u,delay:d,isHandoff:p,onUpdate:m}=r;this.resolvedAt=_f.now();let g=!0;njn(e,o,l,u)||(g=!1,(yI.instantAnimations||!d)&&m?.(cne(e,r,n)),e[0]=e[e.length-1],jEe(r),r.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>ljn?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},b=g&&!p&&ojn(f),y=f.motionValue?.owner?.current;let v;if(b)try{v=new ejn({...f,element:y})}catch{v=new _z(f)}else v=new _z(f);v.finished.then(()=>{this.notifyFinished()}).catch(oy),this.pendingTimeline&&(this.stopTimeline=v.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=v}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),H$n()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}class ujn{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,n){for(let r=0;r<this.animations.length;r++)this.animations[r][e]=n}attachTimeline(e){const n=this.animations.map(r=>r.attachTimeline(e));return()=>{n.forEach((r,i)=>{r&&r(),this.animations[i].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return Oct(this.animations,"duration")}get iterationDuration(){return Oct(this.animations,"iterationDuration")}runAll(e){this.animations.forEach(n=>n[e]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function Oct(t,e){let n=0;for(let r=0;r<t.length;r++){const i=t[r][e];i!==null&&i>n&&(n=i)}return n}class djn extends ujn{then(e,n){return this.finished.finally(e).then(()=>{})}}function Fct(t,e,n,r=0,i=1){const o=Array.from(t).sort((p,m)=>p.sortNodePosition(m)).indexOf(e),l=t.size,u=(l-1)*r;return typeof n=="function"?n(o,l):i===1?o*r:u-o*r}const pjn=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function mjn(t){const e=pjn.exec(t);if(!e)return[,];const[,n,r,i]=e;return[`--${n??r}`,i]}const gjn=4;function Qct(t,e,n=1){Xv(n<=gjn,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,i]=mjn(t);if(!r)return;const o=window.getComputedStyle(e).getPropertyValue(r);if(o){const l=o.trim();return Llt(l)?parseFloat(l):l}return AEe(i)?Qct(i,e,n+1):i}const hjn={type:"spring",stiffness:500,damping:25,restSpeed:10},fjn=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Ajn={type:"keyframes",duration:.8},bjn={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},yjn=(t,{keyframes:e})=>e.length>2?Ajn:mP.has(t)?t.startsWith("scale")?fjn(e[1]):hjn:bjn;function $ct(t,e){if(t?.inherit&&e){const{inherit:n,...r}=t;return{...e,...r}}return t}function zEe(t,e){const n=t?.[e]??t?.default??t;return n!==t?$ct(n,t):n}const vjn=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function _jn(t){for(const e in t)if(!vjn.has(e))return!0;return!1}const UEe=(t,e,n,r={},i,o)=>l=>{const u=zEe(r,t)||{},d=u.delay||r.delay||0;let{elapsed:p=0}=r;p=p-vf(d);const m={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...u,delay:-p,onUpdate:h=>{e.set(h),u.onUpdate&&u.onUpdate(h)},onComplete:()=>{l(),u.onComplete&&u.onComplete()},name:t,motionValue:e,element:o?void 0:i};_jn(u)||Object.assign(m,yjn(t,m)),m.duration&&(m.duration=vf(m.duration)),m.repeatDelay&&(m.repeatDelay=vf(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let g=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&(jEe(m),m.delay===0&&(g=!0)),(yI.instantAnimations||yI.skipAnimations||i?.shouldSkipAnimations)&&(g=!0,jEe(m),m.delay=0),m.allowFlatten=!u.type&&!u.ease,g&&!o&&e.get()!==void 0){const h=cne(m.keyframes,u);if(h!==void 0){Fl.update(()=>{m.onUpdate(h),m.onComplete()});return}}return u.isSync?new _z(m):new cjn(m)};function jct(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function qEe(t,e,n,r){if(typeof e=="function"){const[i,o]=jct(r);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=jct(r);e=e(n!==void 0?n:t.custom,i,o)}return e}function KN(t,e,n){const r=t.getProps();return qEe(r,e,n!==void 0?n:r.custom,t)}const zct=new Set(["width","height","top","left","right","bottom",...pP]),Uct=30,wjn=t=>!isNaN(parseFloat(t)),xz={current:void 0};class xjn{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const i=_f.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=_f.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=wjn(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&pEe(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new dEe);const r=this.events[e].add(n);return e==="change"?()=>{r(),Fl.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return xz.current&&xz.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=_f.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Uct)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Uct);return Flt(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function wI(t,e){return new xjn(t,e)}const GEe=t=>Array.isArray(t);function kjn(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,wI(n))}function Ejn(t){return GEe(t)?t[t.length-1]||0:t}function Cjn(t,e){const n=KN(t,e);let{transitionEnd:r={},transition:i={},...o}=n||{};o={...o,...r};for(const l in o){const u=Ejn(o[l]);kjn(t,l,u)}}const Bd=t=>!!(t&&t.getVelocity);function Sjn(t){return!!(Bd(t)&&t.add)}function HEe(t,e){const n=t.getValue("willChange");if(Sjn(n))return n.add(e);if(!n&&yI.WillChange){const r=new yI.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function WEe(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const qct="data-"+WEe("framerAppearId");function Gct(t){return t.props[qct]}function Ijn({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function YEe(t,e,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:o,transitionEnd:l,...u}=e;const d=t.getDefaultTransition();o=o?$ct(o,d):d;const p=o?.reduceMotion;r&&(o=r);const m=[],g=i&&t.animationState&&t.animationState.getState()[i];for(const h in u){const f=t.getValue(h,t.latestValues[h]??null),b=u[h];if(b===void 0||g&&Ijn(g,h))continue;const y={delay:n,...zEe(o||{},h)},v=f.get();if(v!==void 0&&!f.isAnimating()&&!Array.isArray(b)&&b===v&&!y.velocity){Fl.update(()=>f.set(b));continue}let _=!1;if(window.MotionHandoffAnimation){const k=Gct(t);if(k){const C=window.MotionHandoffAnimation(k,h,Fl);C!==null&&(y.startTime=C,_=!0)}}HEe(t,h);const w=p??t.shouldReduceMotion;f.start(UEe(h,f,b,w&&zct.has(h)?{type:!1}:y,t,_));const x=f.animation;x&&m.push(x)}if(l){const h=()=>Fl.update(()=>{l&&Cjn(t,l)});m.length?Promise.all(m).then(h):h()}return m}function VEe(t,e,n={}){const r=KN(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);const o=r?()=>Promise.all(YEe(t,r,n)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(d=0)=>{const{delayChildren:p=0,staggerChildren:m,staggerDirection:g}=i;return Tjn(t,e,d,p,m,g,n)}:()=>Promise.resolve(),{when:u}=i;if(u){const[d,p]=u==="beforeChildren"?[o,l]:[l,o];return d().then(()=>p())}else return Promise.all([o(),l(n.delay)])}function Tjn(t,e,n=0,r=0,i=0,o=1,l){const u=[];for(const d of t.variantChildren)d.notify("AnimationStart",e),u.push(VEe(d,e,{...l,delay:n+(typeof r=="function"?0:r)+Fct(t.variantChildren,d,r,i,o)}).then(()=>d.notify("AnimationComplete",e)));return Promise.all(u)}function Bjn(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const i=e.map(o=>VEe(t,o,n));r=Promise.all(i)}else if(typeof e=="string")r=VEe(t,e,n);else{const i=typeof e=="function"?KN(t,e,n.custom):e;r=Promise.all(YEe(t,i,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}const Djn={test:t=>t==="auto",parse:t=>t},Hct=t=>e=>e.test(t),Wct=[lP,ei,vx,vI,i$n,a$n,Djn],Yct=t=>Wct.find(Hct(t));function Njn(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Plt(t):!0}const Rjn=new Set(["brightness","contrast","saturate","opacity"]);function Ljn(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(bEe)||[];if(!r)return t;const i=n.replace(r,"");let o=Rjn.has(e)?1:0;return r!==n&&(o*=100),e+"("+o+i+")"}const Mjn=/\b([a-z-]*)\(.*?\)/gu,KEe={...Jv,getAnimatableNone:t=>{const e=t.match(Mjn);return e?e.map(Ljn).join(" "):t}},ZEe={...Jv,getAnimatableNone:t=>{const e=Jv.parse(t);return Jv.createTransformer(t)(e.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},Vct={...lP,transform:Math.round},XEe={borderWidth:ei,borderTopWidth:ei,borderRightWidth:ei,borderBottomWidth:ei,borderLeftWidth:ei,borderRadius:ei,borderTopLeftRadius:ei,borderTopRightRadius:ei,borderBottomRightRadius:ei,borderBottomLeftRadius:ei,width:ei,maxWidth:ei,height:ei,maxHeight:ei,top:ei,right:ei,bottom:ei,left:ei,inset:ei,insetBlock:ei,insetBlockStart:ei,insetBlockEnd:ei,insetInline:ei,insetInlineStart:ei,insetInlineEnd:ei,padding:ei,paddingTop:ei,paddingRight:ei,paddingBottom:ei,paddingLeft:ei,paddingBlock:ei,paddingBlockStart:ei,paddingBlockEnd:ei,paddingInline:ei,paddingInlineStart:ei,paddingInlineEnd:ei,margin:ei,marginTop:ei,marginRight:ei,marginBottom:ei,marginLeft:ei,marginBlock:ei,marginBlockStart:ei,marginBlockEnd:ei,marginInline:ei,marginInlineStart:ei,marginInlineEnd:ei,fontSize:ei,backgroundPositionX:ei,backgroundPositionY:ei,...{rotate:vI,rotateX:vI,rotateY:vI,rotateZ:vI,scale:sne,scaleX:sne,scaleY:sne,scaleZ:sne,skew:vI,skewX:vI,skewY:vI,distance:ei,translateX:ei,translateY:ei,translateZ:ei,x:ei,y:ei,z:ei,perspective:ei,transformPerspective:ei,opacity:Az,originX:ict,originY:ict,originZ:ei},zIndex:Vct,fillOpacity:Az,strokeOpacity:Az,numOctaves:Vct},Pjn={...XEe,color:np,backgroundColor:np,outlineColor:np,fill:np,stroke:np,borderColor:np,borderTopColor:np,borderRightColor:np,borderBottomColor:np,borderLeftColor:np,filter:KEe,WebkitFilter:KEe,mask:ZEe,WebkitMask:ZEe},Kct=t=>Pjn[t],Ojn=new Set([KEe,ZEe]);function Zct(t,e){let n=Kct(t);return Ojn.has(n)||(n=Jv),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Fjn=new Set(["auto","none","0"]);function Qjn(t,e,n){let r=0,i;for(;r<t.length&&!i;){const o=t[r];typeof o=="string"&&!Fjn.has(o)&&uP(o).values.length&&(i=t[r]),r++}if(i&&n)for(const o of e)t[o]=Zct(n,i)}class $jn extends FEe{constructor(e,n,r,i,o){super(e,n,r,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let m=0;m<e.length;m++){let g=e[m];if(typeof g=="string"&&(g=g.trim(),AEe(g))){const h=Qct(g,n.current);h!==void 0&&(e[m]=h),m===e.length-1&&(this.finalKeyframe=g)}}if(this.resolveNoneKeyframes(),!zct.has(r)||e.length!==2)return;const[i,o]=e,l=Yct(i),u=Yct(o),d=rct(i),p=rct(o);if(d!==p&&_I[r]){this.needsMeasurement=!0;return}if(l!==u)if(Ect(l)&&Ect(u))for(let m=0;m<e.length;m++){const g=e[m];typeof g=="string"&&(e[m]=parseFloat(g))}else _I[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let i=0;i<e.length;i++)(e[i]===null||Njn(e[i]))&&r.push(i);r.length&&Qjn(e,r,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:r}=this;if(!e||!e.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=_I[r](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(r,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:r}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=r.length-1,l=r[o];r[o]=_I[n](e.measureViewportBox(),window.getComputedStyle(e.current)),l!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=l),this.removedTransforms?.length&&this.removedTransforms.forEach(([u,d])=>{e.getValue(u).set(d)}),this.resolveNoneKeyframes()}}function une(t,e,n){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let r=document;e&&(r=e.current);const i=n?.[t]??r.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t).filter(r=>r!=null)}const Xct=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function dne(t){return Mlt(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:JEe}=ect(queueMicrotask,!1),e_={x:!1,y:!1};function Jct(){return e_.x||e_.y}function jjn(t){return t==="x"||t==="y"?e_[t]?null:(e_[t]=!0,()=>{e_[t]=!1}):e_.x||e_.y?null:(e_.x=e_.y=!0,()=>{e_.x=e_.y=!1})}function eut(t,e){const n=une(t),r=new AbortController,i={passive:!0,...e,signal:r.signal};return[n,i,()=>r.abort()]}function zjn(t){return!(t.pointerType==="touch"||Jct())}function Ujn(t,e,n={}){const[r,i,o]=eut(t,n);return r.forEach(l=>{let u=!1,d=!1,p;const m=()=>{l.removeEventListener("pointerleave",b)},g=v=>{p&&(p(v),p=void 0),m()},h=v=>{u=!1,window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),d&&(d=!1,g(v))},f=()=>{u=!0,window.addEventListener("pointerup",h,i),window.addEventListener("pointercancel",h,i)},b=v=>{if(v.pointerType!=="touch"){if(u){d=!0;return}g(v)}},y=v=>{if(!zjn(v))return;d=!1;const _=e(l,v);typeof _=="function"&&(p=_,l.addEventListener("pointerleave",b,i))};l.addEventListener("pointerenter",y,i),l.addEventListener("pointerdown",f,i)}),o}const tut=(t,e)=>e?t===e?!0:tut(t,e.parentElement):!1,e1e=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,qjn=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Gjn(t){return qjn.has(t.tagName)||t.isContentEditable===!0}const Hjn=new Set(["INPUT","SELECT","TEXTAREA"]);function Wjn(t){return Hjn.has(t.tagName)||t.isContentEditable===!0}const pne=new WeakSet;function nut(t){return e=>{e.key==="Enter"&&t(e)}}function t1e(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Yjn=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=nut(()=>{if(pne.has(n))return;t1e(n,"down");const i=nut(()=>{t1e(n,"up")}),o=()=>t1e(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",r,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),e)};function rut(t){return e1e(t)&&!Jct()}const aut=new WeakSet;function Vjn(t,e,n={}){const[r,i,o]=eut(t,n),l=u=>{const d=u.currentTarget;if(!rut(u)||aut.has(u))return;pne.add(d),n.stopPropagation&&aut.add(u);const p=e(d,u),m=(f,b)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",h),pne.has(d)&&pne.delete(d),rut(f)&&typeof p=="function"&&p(f,{success:b})},g=f=>{m(f,d===window||d===document||n.useGlobalTarget||tut(d,f.target))},h=f=>{m(f,!1)};window.addEventListener("pointerup",g,i),window.addEventListener("pointercancel",h,i)};return r.forEach(u=>{(n.useGlobalTarget?window:u).addEventListener("pointerdown",l,i),dne(u)&&(u.addEventListener("focus",p=>Yjn(p,i)),!Gjn(u)&&!u.hasAttribute("tabindex")&&(u.tabIndex=0))}),o}function mne(t){return Mlt(t)&&"ownerSVGElement"in t}const gne=new WeakMap;let hne;const iut=(t,e,n)=>(r,i)=>i&&i[0]?i[0][t+"Size"]:mne(r)&&"getBBox"in r?r.getBBox()[e]:r[n],Kjn=iut("inline","width","offsetWidth"),Zjn=iut("block","height","offsetHeight");function Xjn({target:t,borderBoxSize:e}){gne.get(t)?.forEach(n=>{n(t,{get width(){return Kjn(t,e)},get height(){return Zjn(t,e)}})})}function Jjn(t){t.forEach(Xjn)}function e7n(){typeof ResizeObserver>"u"||(hne=new ResizeObserver(Jjn))}function t7n(t,e){hne||e7n();const n=une(t);return n.forEach(r=>{let i=gne.get(r);i||(i=new Set,gne.set(r,i)),i.add(e),hne?.observe(r)}),()=>{n.forEach(r=>{const i=gne.get(r);i?.delete(e),i?.size||hne?.unobserve(r)})}}const fne=new Set;let gP;function n7n(){gP=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};fne.forEach(e=>e(t))},window.addEventListener("resize",gP)}function r7n(t){return fne.add(t),gP||n7n(),()=>{fne.delete(t),!fne.size&&typeof gP=="function"&&(window.removeEventListener("resize",gP),gP=void 0)}}function sut(t,e){return typeof t=="function"?r7n(t):t7n(t,e)}function out(t){return mne(t)&&t.tagName==="svg"}function a7n(...t){const e=!Array.isArray(t[0]),n=e?0:-1,r=t[0+n],i=t[1+n],o=t[2+n],l=t[3+n],u=bct(i,o,l);return e?u(r):u}function i7n(t,e,n={}){const r=t.get();let i=null,o=r,l;const u=typeof r=="string"?r.replace(/[\d.-]/g,""):void 0,d=()=>{i&&(i.stop(),i=null),t.animation=void 0},p=()=>{const g=lut(t.get()),h=lut(o);if(g===h){d();return}const f=i?i.getGeneratorVelocity():t.getVelocity();d(),i=new _z({keyframes:[g,h],velocity:f,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:l})},m=()=>{p(),t.animation=i??void 0,t.events.animationStart?.notify(),i?.then(()=>{t.animation=void 0,t.events.animationComplete?.notify()})};if(t.attach((g,h)=>{o=g,l=f=>h(n1e(f,u)),Fl.postRender(m)},d),Bd(e)){let g=n.skipInitialAnimation===!0;const h=e.on("change",b=>{g?(g=!1,t.jump(n1e(b,u),!1)):t.set(n1e(b,u))}),f=t.on("destroy",h);return()=>{h(),f()}}return d}function n1e(t,e){return e?t+e:t}function lut(t){return typeof t=="number"?t:parseFloat(t)}const s7n=[...Wct,np,Jv],o7n=t=>s7n.find(Hct(t)),cut=()=>({translate:0,scale:1,origin:0,originPoint:0}),hP=()=>({x:cut(),y:cut()}),uut=()=>({min:0,max:0}),rp=()=>({x:uut(),y:uut()}),kz=new WeakMap;function Ane(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Ez(t){return typeof t=="string"||Array.isArray(t)}const r1e=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],a1e=["initial",...r1e];function bne(t){return Ane(t.animate)||a1e.some(e=>Ez(t[e]))}function dut(t){return!!(bne(t)||t.variants)}function l7n(t,e,n){for(const r in e){const i=e[r],o=n[r];if(Bd(i))t.addValue(r,i);else if(Bd(o))t.addValue(r,wI(i,{owner:t}));else if(o!==i)if(t.hasValue(r)){const l=t.getValue(r);l.liveStyle===!0?l.jump(i):l.hasAnimated||l.set(i)}else{const l=t.getStaticValue(r);t.addValue(r,wI(l!==void 0?l:i,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const i1e={current:null},put={current:!1},c7n=typeof window<"u";function u7n(){if(put.current=!0,!!c7n)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>i1e.current=t.matches;t.addEventListener("change",e),e()}else i1e.current=!1}const mut=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let yne={};function gut(t){yne=t}function d7n(){return yne}class hut{scrapeMotionValuesFromProps(e,n,r){return{}}constructor({parent:e,props:n,presenceContext:r,reducedMotionConfig:i,skipAnimations:o,blockInitialAnimation:l,visualState:u},d={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=FEe,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=_f.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,Fl.render(this.render,!1,!0))};const{latestValues:p,renderState:m}=u;this.latestValues=p,this.baseTarget={...p},this.initialValues=n.initial?{...p}:{},this.renderState=m,this.parent=e,this.props=n,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=o,this.options=d,this.blockInitialAnimation=!!l,this.isControllingVariants=bne(n),this.isVariantNode=dut(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:g,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in h){const b=h[f];p[f]!==void 0&&Bd(b)&&b.set(p[f])}}mount(e){if(this.hasBeenMounted)for(const n in this.initialValues)this.values.get(n)?.jump(this.initialValues[n]),this.latestValues[n]=this.initialValues[n];this.current=e,kz.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(put.current||u7n(),this.shouldReduceMotion=i1e.current),process.env.NODE_ENV!=="production"&&pEe(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),O1(this.notifyUpdate),O1(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),n.accelerate&&Pct.has(e)&&this.current instanceof HTMLElement){const{factory:l,keyframes:u,times:d,ease:p,duration:m}=n.accelerate,g=new Rct({element:this.current,name:e,keyframes:u,times:d,ease:p,duration:vf(m)}),h=l(g);this.valueSubscriptions.set(e,()=>{h(),g.cancel()});return}const r=mP.has(e);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",l=>{this.latestValues[e]=l,this.props.onUpdate&&Fl.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in yne){const n=yne[e];if(!n)continue;const{isEnabled:r,Feature:i}=n;if(!this.features[e]&&i&&r(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):rp()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<mut.length;r++){const i=mut[r];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,l=e[o];l&&(this.propEventSubscriptions[i]=this.on(i,l))}this.prevMotionValues=l7n(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const r=this.values.get(e);n!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return r===void 0&&n!==void 0&&(r=wI(n===null?void 0:n,{owner:this}),this.addValue(e,r)),r}readValue(e,n){let r=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return r!=null&&(typeof r=="string"&&(Llt(r)||Plt(r))?r=parseFloat(r):!o7n(r)&&Jv.test(n)&&(r=Zct(e,n)),this.setBaseTarget(e,Bd(r)?r.get():r)),Bd(r)?r.get():r}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const o=qEe(this.props,n,this.presenceContext?.custom);o&&(r=o[e])}if(n&&r!==void 0)return r;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!Bd(i)?i:this.initialValues[e]!==void 0&&r===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new dEe),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){JEe.render(this.render)}}class fut extends hut{constructor(){super(...arguments),this.KeyframeResolver=$jn}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){const r=e.style;return r?r[n]:void 0}removeValueFromRenderState(e,{vars:n,style:r}){delete n[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Bd(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class xI{constructor(e){this.isMounted=!1,this.node=e}update(){}}function Aut({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function p7n({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function m7n(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function s1e(t){return t===void 0||t===1}function o1e({scale:t,scaleX:e,scaleY:n}){return!s1e(t)||!s1e(e)||!s1e(n)}function ZN(t){return o1e(t)||but(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function but(t){return yut(t.x)||yut(t.y)}function yut(t){return t&&t!=="0%"}function vne(t,e,n){const r=t-n,i=e*r;return n+i}function vut(t,e,n,r,i){return i!==void 0&&(t=vne(t,i,r)),vne(t,n,r)+e}function l1e(t,e=0,n=1,r,i){t.min=vut(t.min,e,n,r,i),t.max=vut(t.max,e,n,r,i)}function _ut(t,{x:e,y:n}){l1e(t.x,e.translate,e.scale,e.originPoint),l1e(t.y,n.translate,n.scale,n.originPoint)}const wut=.999999999999,xut=1.0000000000001;function g7n(t,e,n,r=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,l;for(let u=0;u<i;u++){o=n[u],l=o.projectionDelta;const{visualElement:d}=o.options;d&&d.props.style&&d.props.style.display==="contents"||(r&&o.options.layoutScroll&&o.scroll&&o!==o.root&&(_x(t.x,-o.scroll.offset.x),_x(t.y,-o.scroll.offset.y)),l&&(e.x*=l.x.scale,e.y*=l.y.scale,_ut(t,l)),r&&ZN(o.latestValues)&&_ne(t,o.latestValues,o.layout?.layoutBox))}e.x<xut&&e.x>wut&&(e.x=1),e.y<xut&&e.y>wut&&(e.y=1)}function _x(t,e){t.min+=e,t.max+=e}function kut(t,e,n,r,i=.5){const o=Nc(t.min,t.max,i);l1e(t,e,n,o,r)}function Eut(t,e){return typeof t=="string"?parseFloat(t)/100*(e.max-e.min):t}function _ne(t,e,n){const r=n??t;kut(t.x,Eut(e.x,r.x),e.scaleX,e.scale,e.originX),kut(t.y,Eut(e.y,r.y),e.scaleY,e.scale,e.originY)}function Cut(t,e){return Aut(m7n(t.getBoundingClientRect(),e))}function h7n(t,e,n){const r=Cut(t,n),{scroll:i}=e;return i&&(_x(r.x,i.offset.x),_x(r.y,i.offset.y)),r}const f7n={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},A7n=pP.length;function b7n(t,e,n){let r="",i=!0;for(let o=0;o<A7n;o++){const l=pP[o],u=t[l];if(u===void 0)continue;let d=!0;if(typeof u=="number")d=u===(l.startsWith("scale")?1:0);else{const p=parseFloat(u);d=l.startsWith("scale")?p===1:p===0}if(!d||n){const p=Xct(u,XEe[l]);if(!d){i=!1;const m=f7n[l]||l;r+=`${m}(${p}) `}n&&(e[l]=p)}}return r=r.trim(),n?r=n(e,i?"":r):i&&(r="none"),r}function c1e(t,e,n){const{style:r,vars:i,transformOrigin:o}=t;let l=!1,u=!1;for(const d in e){const p=e[d];if(mP.has(d)){l=!0;continue}else if(nct(d)){i[d]=p;continue}else{const m=Xct(p,XEe[d]);d.startsWith("origin")?(u=!0,o[d]=m):r[d]=m}}if(e.transform||(l||n?r.transform=b7n(e,t.transform,n):r.transform&&(r.transform="none")),u){const{originX:d="50%",originY:p="50%",originZ:m=0}=o;r.transformOrigin=`${d} ${p} ${m}`}}function Sut(t,{style:e,vars:n},r,i){const o=t.style;let l;for(l in e)o[l]=e[l];i?.applyProjectionStyles(o,r);for(l in n)o.setProperty(l,n[l])}function Iut(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Cz={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(ei.test(t))t=parseFloat(t);else return t;const n=Iut(t,e.target.x),r=Iut(t,e.target.y);return`${n}% ${r}%`}},y7n={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,i=Jv.parse(t);if(i.length>5)return r;const o=Jv.createTransformer(t),l=typeof i[0]!="number"?1:0,u=n.x.scale*e.x,d=n.y.scale*e.y;i[0+l]/=u,i[1+l]/=d;const p=Nc(u,d,.5);return typeof i[2+l]=="number"&&(i[2+l]/=p),typeof i[3+l]=="number"&&(i[3+l]/=p),o(i)}},u1e={borderRadius:{...Cz,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Cz,borderTopRightRadius:Cz,borderBottomLeftRadius:Cz,borderBottomRightRadius:Cz,boxShadow:y7n};function Tut(t,{layout:e,layoutId:n}){return mP.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!u1e[t]||t==="opacity")}function d1e(t,e,n){const r=t.style,i=e?.style,o={};if(!r)return o;for(const l in r)(Bd(r[l])||i&&Bd(i[l])||Tut(l,t)||n?.getValue(l)?.liveStyle!==void 0)&&(o[l]=r[l]);return o}function v7n(t){return window.getComputedStyle(t)}class But extends fut{constructor(){super(...arguments),this.type="html",this.renderInstance=Sut}readValueFromInstance(e,n){if(mP.has(n))return this.projection?.isProjecting?REe(n):j$n(e,n);{const r=v7n(e),i=(nct(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Cut(e,n)}build(e,n,r){c1e(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return d1e(e,n,r)}}function _7n(t,e){return t in e}class w7n extends hut{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,n){if(_7n(n,e)){const r=e[n];if(typeof r=="string"||typeof r=="number")return r}}getBaseTargetFromProps(){}removeValueFromRenderState(e,n){delete n.output[e]}measureInstanceViewportBox(){return rp()}build(e,n){Object.assign(e.output,n)}renderInstance(e,{output:n}){Object.assign(e,n)}sortInstanceNodePosition(){return 0}}const x7n={offset:"stroke-dashoffset",array:"stroke-dasharray"},k7n={offset:"strokeDashoffset",array:"strokeDasharray"};function E7n(t,e,n=1,r=0,i=!0){t.pathLength=1;const o=i?x7n:k7n;t[o.offset]=`${-r}`,t[o.array]=`${e} ${n}`}const C7n=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Dut(t,{attrX:e,attrY:n,attrScale:r,pathLength:i,pathSpacing:o=1,pathOffset:l=0,...u},d,p,m){if(c1e(t,u,p),d){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:g,style:h}=t;g.transform&&(h.transform=g.transform,delete g.transform),(h.transform||g.transformOrigin)&&(h.transformOrigin=g.transformOrigin??"50% 50%",delete g.transformOrigin),h.transform&&(h.transformBox=m?.transformBox??"fill-box",delete g.transformBox);for(const f of C7n)g[f]!==void 0&&(h[f]=g[f],delete g[f]);e!==void 0&&(g.x=e),n!==void 0&&(g.y=n),r!==void 0&&(g.scale=r),i!==void 0&&E7n(g,i,o,l,!1)}const Nut=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"]),Rut=t=>typeof t=="string"&&t.toLowerCase()==="svg";function S7n(t,e,n,r){Sut(t,e,void 0,r);for(const i in e.attrs)t.setAttribute(Nut.has(i)?i:WEe(i),e.attrs[i])}function Lut(t,e,n){const r=d1e(t,e,n);for(const i in t)if(Bd(t[i])||Bd(e[i])){const o=pP.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[o]=t[i]}return r}class Mut extends fut{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=rp}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(mP.has(n)){const r=Kct(n);return r&&r.default||0}return n=Nut.has(n)?n:WEe(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return Lut(e,n,r)}build(e,n,r){Dut(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,i){S7n(e,n,r,i)}mount(e){this.isSVGTag=Rut(e.tagName),super.mount(e)}}const I7n=a1e.length;function Put(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Put(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<I7n;n++){const r=a1e[n],i=t.props[r];(Ez(i)||i===!1)&&(e[r]=i)}return e}function Out(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}const T7n=[...r1e].reverse(),B7n=r1e.length;function D7n(t){return e=>Promise.all(e.map(({animation:n,options:r})=>Bjn(t,n,r)))}function N7n(t){let e=D7n(t),n=Fut(),r=!0,i=!1;const o=p=>(m,g)=>{const h=KN(t,g,p==="exit"?t.presenceContext?.custom:void 0);if(h){const{transition:f,transitionEnd:b,...y}=h;m={...m,...y,...b}}return m};function l(p){e=p(t)}function u(p){const{props:m}=t,g=Put(t.parent)||{},h=[],f=new Set;let b={},y=1/0;for(let _=0;_<B7n;_++){const w=T7n[_],x=n[w],k=m[w]!==void 0?m[w]:g[w],C=Ez(k),E=w===p?x.isActive:null;E===!1&&(y=_);let S=k===g[w]&&k!==m[w]&&C;if(S&&(r||i)&&t.manuallyAnimateOnMount&&(S=!1),x.protectedKeys={...b},!x.isActive&&E===null||!k&&!x.prevProp||Ane(k)||typeof k=="boolean")continue;if(w==="exit"&&x.isActive&&E!==!0){x.prevResolvedValues&&(b={...b,...x.prevResolvedValues});continue}const I=R7n(x.prevProp,k);let B=I||w===p&&x.isActive&&!S&&C||_>y&&C,N=!1;const L=Array.isArray(k)?k:[k];let M=L.reduce(o(w),{});E===!1&&(M={});const{prevResolvedValues:R={}}=x,D={...R,...M},P=$=>{B=!0,f.has($)&&(N=!0,f.delete($)),x.needsAnimating[$]=!0;const j=t.getValue($);j&&(j.liveStyle=!1)};for(const $ in D){const j=M[$],Q=R[$];if(b.hasOwnProperty($))continue;let z=!1;GEe(j)&&GEe(Q)?z=!Out(j,Q):z=j!==Q,z?j!=null?P($):f.add($):j!==void 0&&f.has($)?P($):x.protectedKeys[$]=!0}x.prevProp=k,x.prevResolvedValues=M,x.isActive&&(b={...b,...M}),(r||i)&&t.blockInitialAnimation&&(B=!1);const O=S&&I;B&&(!O||N)&&h.push(...L.map($=>{const j={type:w};if(typeof $=="string"&&(r||i)&&!O&&t.manuallyAnimateOnMount&&t.parent){const{parent:Q}=t,z=KN(Q,$);if(Q.enteringChildren&&z){const{delayChildren:U}=z.transition||{};j.delay=Fct(Q.enteringChildren,t,U)}}return{animation:$,options:j}}))}if(f.size){const _={};if(typeof m.initial!="boolean"){const w=KN(t,Array.isArray(m.initial)?m.initial[0]:m.initial);w&&w.transition&&(_.transition=w.transition)}f.forEach(w=>{const x=t.getBaseTarget(w),k=t.getValue(w);k&&(k.liveStyle=!0),_[w]=x??null}),h.push({animation:_})}let v=!!h.length;return r&&(m.initial===!1||m.initial===m.animate)&&!t.manuallyAnimateOnMount&&(v=!1),r=!1,i=!1,v?e(h):Promise.resolve()}function d(p,m){if(n[p].isActive===m)return Promise.resolve();t.variantChildren?.forEach(h=>h.animationState?.setActive(p,m)),n[p].isActive=m;const g=u(p);for(const h in n)n[h].protectedKeys={};return g}return{animateChanges:u,setActive:d,setAnimateFunction:l,getState:()=>n,reset:()=>{n=Fut(),i=!0}}}function R7n(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Out(e,t):!1}function XN(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Fut(){return{animate:XN(!0),whileInView:XN(),whileHover:XN(),whileTap:XN(),whileDrag:XN(),whileFocus:XN(),exit:XN()}}function p1e(t,e){t.min=e.min,t.max=e.max}function t_(t,e){p1e(t.x,e.x),p1e(t.y,e.y)}function Qut(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const $ut=1e-4,L7n=1-$ut,M7n=1+$ut,jut=.01,P7n=0-jut,O7n=0+jut;function wf(t){return t.max-t.min}function F7n(t,e,n){return Math.abs(t-e)<=n}function zut(t,e,n,r=.5){t.origin=r,t.originPoint=Nc(e.min,e.max,t.origin),t.scale=wf(n)/wf(e),t.translate=Nc(n.min,n.max,t.origin)-t.originPoint,(t.scale>=L7n&&t.scale<=M7n||isNaN(t.scale))&&(t.scale=1),(t.translate>=P7n&&t.translate<=O7n||isNaN(t.translate))&&(t.translate=0)}function Sz(t,e,n,r){zut(t.x,e.x,n.x,r?r.originX:void 0),zut(t.y,e.y,n.y,r?r.originY:void 0)}function Uut(t,e,n,r=0){const i=r?Nc(n.min,n.max,r):n.min;t.min=i+e.min,t.max=t.min+wf(e)}function Q7n(t,e,n,r){Uut(t.x,e.x,n.x,r?.x),Uut(t.y,e.y,n.y,r?.y)}function qut(t,e,n,r=0){const i=r?Nc(n.min,n.max,r):n.min;t.min=e.min-i,t.max=t.min+wf(e)}function wne(t,e,n,r){qut(t.x,e.x,n.x,r?.x),qut(t.y,e.y,n.y,r?.y)}function Gut(t,e,n,r,i){return t-=e,t=vne(t,1/n,r),i!==void 0&&(t=vne(t,1/i,r)),t}function $7n(t,e=0,n=1,r=.5,i,o=t,l=t){if(vx.test(e)&&(e=parseFloat(e),e=Nc(l.min,l.max,e/100)-l.min),typeof e!="number")return;let u=Nc(o.min,o.max,r);t===o&&(u-=e),t.min=Gut(t.min,e,n,u,i),t.max=Gut(t.max,e,n,u,i)}function Hut(t,e,[n,r,i],o,l){$7n(t,e[n],e[r],e[i],e.scale,o,l)}const j7n=["x","scaleX","originX"],z7n=["y","scaleY","originY"];function Wut(t,e,n,r){Hut(t.x,e,j7n,n?n.x:void 0,r?r.x:void 0),Hut(t.y,e,z7n,n?n.y:void 0,r?r.y:void 0)}function Yut(t){return t.translate===0&&t.scale===1}function Vut(t){return Yut(t.x)&&Yut(t.y)}function Kut(t,e){return t.min===e.min&&t.max===e.max}function U7n(t,e){return Kut(t.x,e.x)&&Kut(t.y,e.y)}function Zut(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Xut(t,e){return Zut(t.x,e.x)&&Zut(t.y,e.y)}function Jut(t){return wf(t.x)/wf(t.y)}function edt(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function xx(t){return[t("x"),t("y")]}function q7n(t,e,n){let r="";const i=t.x.translate/e.x,o=t.y.translate/e.y,l=n?.z||0;if((i||o||l)&&(r=`translate3d(${i}px, ${o}px, ${l}px) `),(e.x!==1||e.y!==1)&&(r+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:p,rotate:m,rotateX:g,rotateY:h,skewX:f,skewY:b}=n;p&&(r=`perspective(${p}px) ${r}`),m&&(r+=`rotate(${m}deg) `),g&&(r+=`rotateX(${g}deg) `),h&&(r+=`rotateY(${h}deg) `),f&&(r+=`skewX(${f}deg) `),b&&(r+=`skewY(${b}deg) `)}const u=t.x.scale*e.x,d=t.y.scale*e.y;return(u!==1||d!==1)&&(r+=`scale(${u}, ${d})`),r||"none"}const tdt=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],G7n=tdt.length,ndt=t=>typeof t=="string"?parseFloat(t):t,rdt=t=>typeof t=="number"||ei.test(t);function H7n(t,e,n,r,i,o){i?(t.opacity=Nc(0,n.opacity??1,W7n(r)),t.opacityExit=Nc(e.opacity??1,0,Y7n(r))):o&&(t.opacity=Nc(e.opacity??1,n.opacity??1,r));for(let l=0;l<G7n;l++){const u=tdt[l];let d=adt(e,u),p=adt(n,u);if(d===void 0&&p===void 0)continue;d||(d=0),p||(p=0),d===0||p===0||rdt(d)===rdt(p)?(t[u]=Math.max(Nc(ndt(d),ndt(p),r),0),(vx.test(p)||vx.test(d))&&(t[u]+="%")):t[u]=p}(e.rotate||n.rotate)&&(t.rotate=Nc(e.rotate||0,n.rotate||0,r))}function adt(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const W7n=idt(0,.5,Hlt),Y7n=idt(.5,.95,oy);function idt(t,e,n){return r=>r<t?0:r>e?1:n(oP(t,e,r))}function sdt(t,e,n){const r=Bd(t)?t:wI(t);return r.start(UEe("",r,e,n)),r.animation}function Iz(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}const V7n=(t,e)=>t.depth-e.depth;class K7n{constructor(){this.children=[],this.isDirty=!1}add(e){cEe(this.children,e),this.isDirty=!0}remove(e){iP(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(V7n),this.isDirty=!1,this.children.forEach(e)}}function Z7n(t,e){const n=_f.now(),r=({timestamp:i})=>{const o=i-n;o>=e&&(O1(r),t(o-e))};return Fl.setup(r,!0),()=>O1(r)}function xne(t){return Bd(t)?t.get():t}class X7n{constructor(){this.members=[]}add(e){cEe(this.members,e);for(let n=this.members.length-1;n>=0;n--){const r=this.members[n];if(r===e||r===this.lead||r===this.prevLead)continue;const i=r.instance;(!i||i.isConnected===!1)&&!r.snapshot&&(iP(this.members,r),r.unmount())}e.scheduleRender()}remove(e){if(iP(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){for(let n=this.members.indexOf(e)-1;n>=0;n--){const r=this.members[n];if(r.isPresent!==!1&&r.instance?.isConnected!==!1)return this.promote(r),!0}return!1}promote(e,n){const r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.updateSnapshot(),e.scheduleRender();const{layoutDependency:i}=r.options,{layoutDependency:o}=e.options;(i===void 0||i!==o)&&(e.resumeFrom=r,n&&(r.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}const kne={hasAnimatedSinceResize:!0,hasEverUpdated:!1},m1e=["","X","Y","Z"],J7n=1e3;let ezn=0;function g1e(t,e,n,r){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),r&&(r[t]=0))}function odt(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Gct(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Fl,!(i||o))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&odt(r)}function ldt({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(l={},u=e?.()){this.id=ezn++,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.layoutVersion=0,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(rzn),this.nodes.forEach(czn),this.nodes.forEach(uzn),this.nodes.forEach(azn)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=u?u.root||u:this,this.path=u?[...u.path,u]:[],this.parent=u,this.depth=u?u.depth+1:0;for(let d=0;d<this.path.length;d++)this.path[d].shouldResetTransform=!0;this.root===this&&(this.nodes=new K7n)}addEventListener(l,u){return this.eventHandlers.has(l)||this.eventHandlers.set(l,new dEe),this.eventHandlers.get(l).add(u)}notifyListeners(l,...u){const d=this.eventHandlers.get(l);d&&d.notify(...u)}hasListeners(l){return this.eventHandlers.has(l)}mount(l){if(this.instance)return;this.isSVG=mne(l)&&!out(l),this.instance=l;const{layoutId:u,layout:d,visualElement:p}=this.options;if(p&&!p.current&&p.mount(l),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(d||u)&&(this.isLayoutDirty=!0),t){let m,g=0;const h=()=>this.root.updateBlockedByResize=!1;Fl.read(()=>{g=window.innerWidth}),t(l,()=>{const f=window.innerWidth;f!==g&&(g=f,this.root.updateBlockedByResize=!0,m&&m(),m=Z7n(h,250),kne.hasAnimatedSinceResize&&(kne.hasAnimatedSinceResize=!1,this.nodes.forEach(ddt)))})}u&&this.root.registerSharedNode(u,this),this.options.animate!==!1&&p&&(u||d)&&this.addEventListener("didUpdate",({delta:m,hasLayoutChanged:g,hasRelativeLayoutChanged:h,layout:f})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||p.getDefaultTransition()||hzn,{onLayoutAnimationStart:y,onLayoutAnimationComplete:v}=p.getProps(),_=!this.targetLayout||!Xut(this.targetLayout,f),w=!g&&h;if(this.options.layoutRoot||this.resumeFrom||w||g&&(_||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const x={...zEe(b,"layout"),onPlay:y,onComplete:v};(p.shouldReduceMotion||this.options.layoutRoot)&&(x.delay=0,x.type=!1),this.startAnimation(x),this.setAnimationOrigin(m,w)}else g||ddt(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=f})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),O1(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(dzn),this.animationId++)}getTransformTemplate(){const{visualElement:l}=this.options;return l&&l.getProps().transformTemplate}willUpdate(l=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&odt(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let m=0;m<this.path.length;m++){const g=this.path[m];g.shouldResetTransform=!0,(typeof g.latestValues.x=="string"||typeof g.latestValues.y=="string")&&(g.isLayoutDirty=!0),g.updateScroll("snapshot"),g.options.layoutRoot&&g.willUpdate(!1)}const{layoutId:u,layout:d}=this.options;if(u===void 0&&!d)return;const p=this.getTransformTemplate();this.prevTransformTemplateValue=p?p(this.latestValues,""):void 0,this.updateSnapshot(),l&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const d=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),d&&this.nodes.forEach(szn),this.nodes.forEach(cdt);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(udt);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ozn),this.nodes.forEach(lzn),this.nodes.forEach(tzn),this.nodes.forEach(nzn)):this.nodes.forEach(udt),this.clearAllSnapshots();const u=_f.now();bg.delta=yx(0,1e3/60,u-bg.timestamp),bg.timestamp=u,bg.isProcessing=!0,fEe.update.process(bg),fEe.preRender.process(bg),fEe.render.process(bg),bg.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,JEe.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(izn),this.sharedNodes.forEach(pzn)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Fl.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Fl.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!wf(this.snapshot.measuredBox.x)&&!wf(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 d=0;d<this.path.length;d++)this.path[d].updateScroll();const l=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=rp()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:u}=this.options;u&&u.notify("LayoutMeasure",this.layout.layoutBox,l?l.layoutBox:void 0)}updateScroll(l="measure"){let u=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===l&&(u=!1),u&&this.instance){const d=r(this.instance);this.scroll={animationId:this.root.animationId,phase:l,isRoot:d,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:d}}}resetTransform(){if(!i)return;const l=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,u=this.projectionDelta&&!Vut(this.projectionDelta),d=this.getTransformTemplate(),p=d?d(this.latestValues,""):void 0,m=p!==this.prevTransformTemplateValue;l&&this.instance&&(u||ZN(this.latestValues)||m)&&(i(this.instance,p),this.shouldResetTransform=!1,this.scheduleRender())}measure(l=!0){const u=this.measurePageBox();let d=this.removeElementScroll(u);return l&&(d=this.removeTransform(d)),fzn(d),{animationId:this.root.animationId,measuredBox:u,layoutBox:d,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:l}=this.options;if(!l)return rp();const u=l.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Azn))){const{scroll:p}=this.root;p&&(_x(u.x,p.offset.x),_x(u.y,p.offset.y))}return u}removeElementScroll(l){const u=rp();if(t_(u,l),this.scroll?.wasRoot)return u;for(let d=0;d<this.path.length;d++){const p=this.path[d],{scroll:m,options:g}=p;p!==this.root&&m&&g.layoutScroll&&(m.wasRoot&&t_(u,l),_x(u.x,m.offset.x),_x(u.y,m.offset.y))}return u}applyTransform(l,u=!1,d){const p=d||rp();t_(p,l);for(let m=0;m<this.path.length;m++){const g=this.path[m];!u&&g.options.layoutScroll&&g.scroll&&g!==g.root&&(_x(p.x,-g.scroll.offset.x),_x(p.y,-g.scroll.offset.y)),ZN(g.latestValues)&&_ne(p,g.latestValues,g.layout?.layoutBox)}return ZN(this.latestValues)&&_ne(p,this.latestValues,this.layout?.layoutBox),p}removeTransform(l){const u=rp();t_(u,l);for(let d=0;d<this.path.length;d++){const p=this.path[d];if(!ZN(p.latestValues))continue;let m;p.instance&&(o1e(p.latestValues)&&p.updateSnapshot(),m=rp(),t_(m,p.measurePageBox())),Wut(u,p.latestValues,p.snapshot?.layoutBox,m)}return ZN(this.latestValues)&&Wut(u,this.latestValues),u}setTargetDelta(l){this.targetDelta=l,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(l){this.options={...this.options,...l,crossfade:l.crossfade!==void 0?l.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!==bg.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(l=!1){const u=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=u.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=u.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=u.isSharedProjectionDirty);const d=!!this.resumingFrom||this!==u;if(!(l||d&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:m,layoutId:g}=this.options;if(!this.layout||!(m||g))return;this.resolvedRelativeTargetAt=bg.timestamp;const h=this.getClosestProjectingParent();h&&this.linkedParentVersion!==h.layoutVersion&&!h.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&h&&h.layout?this.createRelativeTarget(h,this.layout.layoutBox,h.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=rp(),this.targetWithTransforms=rp()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Q7n(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):t_(this.target,this.layout.layoutBox),_ut(this.target,this.targetDelta)):t_(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&h&&!!h.resumingFrom==!!this.resumingFrom&&!h.options.layoutScroll&&h.target&&this.animationProgress!==1?this.createRelativeTarget(h,this.target,h.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||o1e(this.parent.latestValues)||but(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(l,u,d){this.relativeParent=l,this.linkedParentVersion=l.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=rp(),this.relativeTargetOrigin=rp(),wne(this.relativeTargetOrigin,u,d,this.options.layoutAnchor||void 0),t_(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const l=this.getLead(),u=!!this.resumingFrom||this!==l;let d=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(d=!1),u&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(d=!1),this.resolvedRelativeTargetAt===bg.timestamp&&(d=!1),d)return;const{layout:p,layoutId:m}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(p||m))return;t_(this.layoutCorrected,this.layout.layoutBox);const g=this.treeScale.x,h=this.treeScale.y;g7n(this.layoutCorrected,this.treeScale,this.path,u),l.layout&&!l.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(l.target=l.layout.layoutBox,l.targetWithTransforms=rp());const{target:f}=l;if(!f){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Qut(this.prevProjectionDelta.x,this.projectionDelta.x),Qut(this.prevProjectionDelta.y,this.projectionDelta.y)),Sz(this.projectionDelta,this.layoutCorrected,f,this.latestValues),(this.treeScale.x!==g||this.treeScale.y!==h||!edt(this.projectionDelta.x,this.prevProjectionDelta.x)||!edt(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",f))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(l=!0){if(this.options.visualElement?.scheduleRender(),l){const u=this.getStack();u&&u.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=hP(),this.projectionDelta=hP(),this.projectionDeltaWithTransform=hP()}setAnimationOrigin(l,u=!1){const d=this.snapshot,p=d?d.latestValues:{},m={...this.latestValues},g=hP();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!u;const h=rp(),f=d?d.source:void 0,b=this.layout?this.layout.source:void 0,y=f!==b,v=this.getStack(),_=!v||v.members.length<=1,w=!!(y&&!_&&this.options.crossfade===!0&&!this.path.some(gzn));this.animationProgress=0;let x;this.mixTargetDelta=k=>{const C=k/1e3;pdt(g.x,l.x,C),pdt(g.y,l.y,C),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(wne(h,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),mzn(this.relativeTarget,this.relativeTargetOrigin,h,C),x&&U7n(this.relativeTarget,x)&&(this.isProjectionDirty=!1),x||(x=rp()),t_(x,this.relativeTarget)),y&&(this.animationValues=m,H7n(m,p,this.latestValues,C,w,_)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=C},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(O1(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Fl.update(()=>{kne.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=wI(0)),this.motionValue.jump(0,!1),this.currentAnimation=sdt(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),l.onUpdate&&l.onUpdate(u)},onStop:()=>{},onComplete:()=>{l.onComplete&&l.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 l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(J7n),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:u,target:d,layout:p,latestValues:m}=l;if(!(!u||!d||!p)){if(this!==l&&this.layout&&p&&Adt(this.options.animationType,this.layout.layoutBox,p.layoutBox)){d=this.target||rp();const g=wf(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+g;const h=wf(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+h}t_(u,d),_ne(u,m),Sz(this.projectionDeltaWithTransform,this.layoutCorrected,u,m)}}registerSharedNode(l,u){this.sharedNodes.has(l)||this.sharedNodes.set(l,new X7n),this.sharedNodes.get(l).add(u);const p=u.options.initialPromotionConfig;u.promote({transition:p?p.transition:void 0,preserveFollowOpacity:p&&p.shouldPreserveFollowOpacity?p.shouldPreserveFollowOpacity(u):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){const{layoutId:l}=this.options;return l?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:l}=this.options;return l?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:u,preserveFollowOpacity:d}={}){const p=this.getStack();p&&p.promote(this,d),l&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let u=!1;const{latestValues:d}=l;if((d.z||d.rotate||d.rotateX||d.rotateY||d.rotateZ||d.skewX||d.skewY)&&(u=!0),!u)return;const p={};d.z&&g1e("z",l,p,this.animationValues);for(let m=0;m<m1e.length;m++)g1e(`rotate${m1e[m]}`,l,p,this.animationValues),g1e(`skew${m1e[m]}`,l,p,this.animationValues);l.render();for(const m in p)l.setStaticValue(m,p[m]),this.animationValues&&(this.animationValues[m]=p[m]);l.scheduleRender()}applyProjectionStyles(l,u){if(!this.instance||this.isSVG)return;if(!this.isVisible){l.visibility="hidden";return}const d=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,l.visibility="",l.opacity="",l.pointerEvents=xne(u?.pointerEvents)||"",l.transform=d?d(this.latestValues,""):"none";return}const p=this.getLead();if(!this.projectionDelta||!this.layout||!p.target){this.options.layoutId&&(l.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,l.pointerEvents=xne(u?.pointerEvents)||""),this.hasProjected&&!ZN(this.latestValues)&&(l.transform=d?d({},""):"none",this.hasProjected=!1);return}l.visibility="";const m=p.animationValues||p.latestValues;this.applyTransformsToTarget();let g=q7n(this.projectionDeltaWithTransform,this.treeScale,m);d&&(g=d(m,g)),l.transform=g;const{x:h,y:f}=this.projectionDelta;l.transformOrigin=`${h.origin*100}% ${f.origin*100}% 0`,p.animationValues?l.opacity=p===this?m.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:m.opacityExit:l.opacity=p===this?m.opacity!==void 0?m.opacity:"":m.opacityExit!==void 0?m.opacityExit:0;for(const b in u1e){if(m[b]===void 0)continue;const{correct:y,applyTo:v,isCSSVariable:_}=u1e[b],w=g==="none"?m[b]:y(m[b],p);if(v){const x=v.length;for(let k=0;k<x;k++)l[v[k]]=w}else _?this.options.visualElement.renderState.vars[b]=w:l[b]=w}this.options.layoutId&&(l.pointerEvents=p===this?xne(u?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(l=>l.currentAnimation?.stop()),this.root.nodes.forEach(cdt),this.root.sharedNodes.clear()}}}function tzn(t){t.updateLayout()}function nzn(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;if(i==="size")xx(m=>{const g=o?e.measuredBox[m]:e.layoutBox[m],h=wf(g);g.min=n[m].min,g.max=g.min+h});else if(i==="x"||i==="y"){const m=i==="x"?"y":"x";p1e(o?e.measuredBox[m]:e.layoutBox[m],n[m])}else Adt(i,e.layoutBox,n)&&xx(m=>{const g=o?e.measuredBox[m]:e.layoutBox[m],h=wf(n[m]);g.max=g.min+h,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[m].max=t.relativeTarget[m].min+h)});const l=hP();Sz(l,n,e.layoutBox);const u=hP();o?Sz(u,t.applyTransform(r,!0),e.measuredBox):Sz(u,n,e.layoutBox);const d=!Vut(l);let p=!1;if(!t.resumeFrom){const m=t.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:g,layout:h}=m;if(g&&h){const f=t.options.layoutAnchor||void 0,b=rp();wne(b,e.layoutBox,g.layoutBox,f);const y=rp();wne(y,n,h.layoutBox,f),Xut(b,y)||(p=!0),m.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=b,t.relativeParent=m)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:u,layoutDelta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function rzn(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function azn(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function izn(t){t.clearSnapshot()}function cdt(t){t.clearMeasurements()}function szn(t){t.isLayoutDirty=!0,t.updateLayout()}function udt(t){t.isLayoutDirty=!1}function ozn(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function lzn(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function ddt(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function czn(t){t.resolveTargetDelta()}function uzn(t){t.calcProjection()}function dzn(t){t.resetSkewAndRotation()}function pzn(t){t.removeLeadSnapshot()}function pdt(t,e,n){t.translate=Nc(e.translate,0,n),t.scale=Nc(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function mdt(t,e,n,r){t.min=Nc(e.min,n.min,r),t.max=Nc(e.max,n.max,r)}function mzn(t,e,n,r){mdt(t.x,e.x,n.x,r),mdt(t.y,e.y,n.y,r)}function gzn(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const hzn={duration:.45,ease:[.4,0,.1,1]},gdt=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),hdt=gdt("applewebkit/")&&!gdt("chrome/")?Math.round:oy;function fdt(t){t.min=hdt(t.min),t.max=hdt(t.max)}function fzn(t){fdt(t.x),fdt(t.y)}function Adt(t,e,n){return t==="position"||t==="preserve-aspect"&&!F7n(Jut(e),Jut(n),.2)}function Azn(t){return t!==t.root&&t.scroll?.wasRoot}const bzn=ldt({attachResizeListener:(t,e)=>Iz(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),yzn=t=>!t.isLayoutDirty&&t.willUpdate(!1);function bdt(){const t=new Set,e=new WeakMap,n=()=>t.forEach(yzn);return{add:r=>{t.add(r),e.set(r,r.addEventListener("willUpdate",n))},remove:r=>{t.delete(r);const i=e.get(r);i&&(i(),e.delete(r)),n()},dirty:n}}const h1e={current:void 0},ydt=ldt({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!h1e.current){const t=new bzn({});t.mount(window),t.setOptions({layoutScroll:!0}),h1e.current=t}return h1e.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Tz=T.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function vdt(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function vzn(...t){return e=>{let n=!1;const r=t.map(i=>{const o=vdt(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<r.length;i++){const o=r[i];typeof o=="function"?o():vdt(t[i],null)}}}}function _zn(...t){return ee.useCallback(vzn(...t),t)}class wzn extends ee.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(dne(n)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const r=n.offsetParent,i=dne(r)&&r.offsetWidth||0,o=dne(r)&&r.offsetHeight||0,l=getComputedStyle(n),u=this.props.sizeRef.current;u.height=parseFloat(l.height),u.width=parseFloat(l.width),u.top=n.offsetTop,u.left=n.offsetLeft,u.right=i-u.width-u.left,u.bottom=o-u.height-u.top}return null}componentDidUpdate(){}render(){return this.props.children}}function xzn({children:t,isPresent:e,anchorX:n,anchorY:r,root:i,pop:o}){const l=T.useId(),u=T.useRef(null),d=T.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:p}=T.useContext(Tz),m=t.props?.ref??t?.ref,g=_zn(u,m);return T.useInsertionEffect(()=>{const{width:h,height:f,top:b,left:y,right:v,bottom:_}=d.current;if(e||o===!1||!u.current||!h||!f)return;const w=n==="left"?`left: ${y}`:`right: ${v}`,x=r==="bottom"?`bottom: ${_}`:`top: ${b}`;u.current.dataset.motionPopId=l;const k=document.createElement("style");p&&(k.nonce=p);const C=i??document.head;return C.appendChild(k),k.sheet&&k.sheet.insertRule(`
109
+ `);i&&(r.content=i)}r.agentExecution?.status==="running"||Nte(r,{status:"completed",onlyIfRunning:!0}),r.created_at=e.created_at||new Date().toISOString(),console.debug("[ChatSlice] streaming_end: finalized message at index",n)}else console.warn("[ChatSlice] streaming_end: no message found to finalize")}function p8n(t,e){t.messages.some(n=>n.id===e.id)||t.messages.push({...e,status:e.status||"completed",isNewMessage:!0})}function m8n(t,e){let n=mx(t,e.stream_id);if(n===-1)for(let r=t.messages.length-1;r>=0;r--){const i=t.messages[r];if(i.role==="assistant"&&i.error&&!oot(i.id)){n=r;break}}if(n!==-1){if(t.messages.findIndex((l,u)=>u!==n&&l.id===e.db_id)!==-1){t.messages.splice(n,1);return}const i=t.messages[n];i.dbId=e.db_id,i.id=e.db_id,i.created_at=e.created_at,i.status==="waiting_for_user"||i.userQuestion?.status==="pending"||Nte(i,{status:"completed",onlyIfRunning:!0})}}function g8n(t,e){t.responding=!0;const n=FN(t);if(n!==-1){const i=t.messages[n];i.id=e.stream_id,i.status="thinking",i.thinkingContent="",i.content=i.content||"";return}const r=rz(t);if(r!==-1){const i=t.messages[r];i.status="thinking",i.thinkingContent=i.thinkingContent??"";return}t.messages.push({id:e.stream_id,clientId:`thinking-${Date.now()}`,role:"assistant",content:"",isNewMessage:!0,created_at:new Date().toISOString(),status:"thinking",thinkingContent:""})}function PAs(t,e){}function h8n(t,e){t.responding=!0;const{context:n}=e;let r=-1;n.stream_id&&(r=mx(t,n.stream_id)),r===-1&&(r=FN(t));const i={agentId:n.agent_id,agentName:n.agent_name,agentType:n.agent_type,executionId:n.execution_id,status:"running",startedAt:n.started_at,phases:[],subagents:[]};if(r!==-1){const o=t.messages[r];t.messages[r]={...o,id:`agent-${n.execution_id}`,streamId:n.stream_id||o.streamId,status:"pending",agentExecution:i}}else t.messages.push({id:`agent-${n.execution_id}`,streamId:n.stream_id,clientId:ON(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"pending",isNewMessage:!0,agentExecution:i})}function f8n(t,e){t.responding=!1;const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r];i.agentExecution?Nte(i,{status:e.status==="completed"?"completed":e.status==="cancelled"?"cancelled":"failed",durationMs:e.duration_ms}):xke(i)}}function A8n(t,e){t.responding=!1;const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r],o=i.agentExecution;o?(o.error={type:e.error_type,message:e.error_message,recoverable:e.recoverable,nodeId:e.node_id},Nte(i,{status:"failed"})):xke(i)}}function b8n(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;if(i){const o=i.phases.find(p=>p.status==="running");o&&(o.status="completed",o.endedAt=Date.now(),o.startedAt&&(o.durationMs=Date.now()-o.startedAt));const l=WFn(e.node_id),u=i.phases.filter(p=>p.nodeId===e.node_id).length,d=u>0?`${e.node_id}__${u}`:e.node_id;i.phases.push({id:d,nodeId:e.node_id,name:l,componentKey:e.component_key,status:"running",startedAt:Date.now(),nodes:[],streamedContent:""}),i.currentPhase=l,i.currentNode=e.node_id}}}function y8n(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;if(i){const o=i.phases.findLast(l=>l.nodeId===e.node_id&&l.status==="running");o&&(o.status=e.status==="completed"?"completed":e.status==="skipped"?"skipped":"failed",o.endedAt=Date.now(),o.durationMs=e.duration_ms,o.outputSummary=e.output_summary)}}}function v8n(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution&&(i.agentExecution.executionId===n.parent_execution_id||i.agentExecution.executionId===n.execution_id));if(r!==-1){const i=t.messages[r].agentExecution;i&&i.subagents.push({id:e.subagent_id,name:e.subagent_name,type:e.subagent_type,status:"running",depth:n.depth,executionPath:n.execution_path,startedAt:n.started_at})}}function _8n(t,e){const n=t.messages.findIndex(r=>r.agentExecution?.subagents?.some(i=>i.id===e.subagent_id));if(n!==-1){const r=t.messages[n].agentExecution;if(r){const i=r.subagents.find(o=>o.id===e.subagent_id);i&&(i.status=e.status==="completed"?"completed":"failed",i.endedAt=Date.now(),i.durationMs=e.duration_ms,i.outputSummary=e.output_summary)}}}function w8n(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;i&&(i.progressPercent=e.progress_percent,i.progressMessage=e.message)}}function x8n(t,e){t.responding=!1;const n=e.error_code?{code:e.error_code,category:e.error_category||e.error_code.split(".")[0],message:e.error,recoverable:e.recoverable??!1,detail:e.detail,errorRef:e.error_ref,occurredAt:e.occurred_at}:{code:"system.internal_error",category:"system",message:e.error||"An error occurred",recoverable:!1};let r=mx(t,e.stream_id);r===-1&&(r=FN(t)),r===-1&&(r=YFn(t)),r===-1&&(r=rz(t)),r!==-1?t.messages[r]={...t.messages[r],status:"failed",error:n}:t.messages.push({id:e.stream_id,streamId:e.stream_id,clientId:ON(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"failed",isNewMessage:!0,error:n}),console.error("Chat error:",e.error_code||e.error)}function k8n(t,e){console.warn("Insufficient balance:",e),t.responding=!1;let n=mx(t,e.stream_id);return n===-1&&(n=FN(t)),n!==-1&&(t.messages[n]={...t.messages[n],content:"",status:"failed",error:{code:"billing.insufficient_balance",category:"billing",message:e.message||"Insufficient balance. Please recharge to continue.",recoverable:!1}}),{isOpen:!0,title:"积分用尽",message:"您的积分已用尽。目前产品处于内测阶段,欢迎填写问卷参与内测,获取更多使用额度。",type:"warning",actionLabel:"填写问卷",actionUrl:"https://sii-czxy.feishu.cn/share/base/form/shrcnYu8Y3GNgI7M14En1xJ7rMb"}}function E8n(t,e){console.warn("Parallel chat limit reached:",e),t.responding=!1;const n=FN(t);return n!==-1&&t.messages.splice(n,1),{isOpen:!0,title:"并行会话已达上限",message:`您已达到并行会话上限(${e.current??"?"}/${e.limit??"?"})。请等待其他会话完成后重试。`,type:"warning"}}function C8n(t,e,n){console.log("Stream aborted:",e);const r=n.get(t.id);r&&(clearTimeout(r),n.delete(t.id)),t.responding=!1,t.aborting=!1,kke(t)}function S8n(t,e){t.responding=!0;const n=t.messages.findIndex(l=>l.status==="pending"&&!l.agentExecution);n!==-1&&t.messages.splice(n,1);const r={id:e.id,name:e.name,description:e.description,arguments:e.arguments,status:e.status,timestamp:new Date(e.timestamp*1e3).toISOString()};let i=rz(t);if(i===-1&&e.stream_id&&(i=mx(t,e.stream_id)),i!==-1){const l=t.messages[i].agentExecution;if(l){let u=l.currentNode?l.phases.findLast(d=>d.nodeId===l.currentNode):null;if(u||(u=l.phases.findLast(d=>d.status==="running")),!u&&l.phases.length>0&&(u=l.phases[l.phases.length-1]),u){u.toolCalls||(u.toolCalls=[]);const d=u.streamedContent?.length??0;r.contentOffset=d,u.toolCalls.push(r),console.log(`ChatSlice: Added tool call ${e.name} to phase ${u.id}`);return}}}const o=`tool-call-${e.id}`;t.messages.push({id:o,streamId:e.stream_id,clientId:ON(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"streaming",isNewMessage:!0,toolCalls:[r]}),console.log(`ChatSlice: Created new tool call message with tool ${e.name}`)}function I8n(t,e){const n=rz(t);if(n!==-1){const r=t.messages[n].agentExecution;if(r){for(const i of r.phases)if(i.toolCalls){const o=i.toolCalls.find(l=>l.id===e.toolCallId);if(o){o.status=e.status,e.result!=null&&(o.result=e.result),e.error&&(o.error=e.error),e.duration_ms!==void 0&&(o.duration_ms=e.duration_ms);break}}}}t.messages.forEach(r=>{r.toolCalls&&r.toolCalls.forEach(i=>{i.id===e.toolCallId&&(i.status=e.status,e.result!=null&&(i.result=e.result),e.error&&(i.error=e.error),e.duration_ms!==void 0&&(i.duration_ms=e.duration_ms))})})}function T8n(t,e,n){t.title=e.name;const r=n.find(i=>i.id===e.id);r&&(r.title=e.name,r.updatedAt=e.updated_at)}function B8n(t,e){const n=dot(t,"citations");n!==-1?(t.messages[n].citations=e.citations,console.log(`Attached ${e.citations.length} citations to message ${t.messages[n].id}`)):console.warn("[Citation Debug] Could not find assistant message to attach citations")}function D8n(t,e){const n=dot(t,"attachments");if(n!==-1){t.messages[n].attachments||(t.messages[n].attachments=[]);const i=t.messages[n].attachments||[],o=e.files.filter(l=>!i.some(u=>u.id===l.id)).map(l=>({...l,download_url:`/xyzen/api/v1/files/${l.id}/download`}));t.messages[n].attachments=[...i,...o]}}function N8n(t,e){t.contextUsage={estimatedTokens:e.estimated_tokens,maxTokens:e.max_tokens,usagePercent:e.usage_percent,nearLimit:e.near_limit,critical:e.critical,truncated:e.truncated,truncatedCount:e.truncated_count}}function R8n(t){return{questionId:t.question_id,question:t.question,options:t.options?.map(e=>({id:e.id,label:e.label,description:e.description,markdown:e.markdown})),multiSelect:t.multi_select??!1,allowTextInput:t.allow_text_input,timeoutSeconds:t.timeout_seconds,threadId:t.thread_id,status:"pending",askedAt:Date.now()}}function L8n(t,e){let n=mx(t,e.stream_id);if(n===-1&&(n=rz(t)),n===-1){for(let o=t.messages.length-1;o>=0;o--)if(t.messages[o].role==="assistant"){n=o;break}}if(n===-1){console.warn("[questionHandlers] No target message found for ask_user_question event");return}const r=t.messages[n],i=R8n(e);r.agentExecution&&r.agentExecution.phases.length>0&&(i.afterPhaseIndex=r.agentExecution.phases.length-1),r.userQuestion&&r.userQuestion.status!=="pending"&&(r.answeredQuestions||(r.answeredQuestions=[]),r.answeredQuestions.push(r.userQuestion)),r.status="waiting_for_user",r.userQuestion=i,t.responding=!0}const $N=new Map;function M8n(t,e,n){const{updateDerivedStatus:r,closeIdleNonPrimaryConnection:i}=n;return{connectToChannel:(o,l)=>{console.debug(`[connectToChannel] topic=${l.slice(0,8)} hasExistingSSE=${Ub.hasConnection(l)} msgs=${e().channels[l]?.messages.length}`),$N.get(l)?.destroy();const u=new l8n(m=>{t(g=>{const h=g.channels[l];h&&m(h)})});$N.set(l,u);const d=m=>{const g=m;if(g.type==="streaming_chunk"){u.pushStreaming(g.data.stream_id,g.data.content,g.data.execution_id);return}if(g.type==="thinking_chunk"){u.pushThinking(g.data.stream_id,g.data.content);return}const h=u.hasPending;u.flushSync();const f=e().channels[l]?.responding;console.groupCollapsed(`[ChatEvent] ${g.type} | topic=${l.slice(0,8)} | responding=${f}`),t(y=>{const v=y.channels[l];if(v){switch(console.debug(`msgs=${v.messages.length}`,`| latestAssist=${(()=>{const _=[...v.messages].reverse().find(w=>w.role==="assistant");return _?`id=${_.id.slice(0,12)} status=${_.status} agentExec=${_.agentExecution?.status}`:"none"})()}`),g.type){case"processing":case"loading":{c8n(v,g.data.stream_id);break}case"streaming_start":{u8n(v,g.data);break}case"streaming_end":{d8n(v,g.data);break}case"message":{const _=g.data,w=_.client_id;if(w){const x=v.messages.findIndex(k=>k.clientId===w);if(x!==-1){const k=v.messages[x];v.messages[x]={...k,..._,id:_.id,status:_.status||"completed",isNewMessage:!1};break}}p8n(v,_);break}case"search_citations":{B8n(v,g.data);break}case"generated_files":{D8n(v,g.data);break}case"message_saved":{m8n(v,g.data);break}case"message_ack":{const{message_id:_,client_id:w}=g.data;if(w){const x=v.messages.findIndex(k=>k.clientId===w);if(x!==-1){const k=v.messages[x];k.id=_,k.status==="sending"&&(k.status="completed")}}break}case"tool_call_request":{S8n(v,g.data);break}case"tool_call_response":{I8n(v,g.data);break}case"error":{x8n(v,g.data);break}case"insufficient_balance":{const _=k8n(v,g.data);_&&(y.notification={..._,onAction:()=>window.open(_.actionUrl,"_blank")});break}case"parallel_chat_limit":{const _=E8n(v,g.data);y.notification=_;break}case"stream_aborted":{C8n(v,g.data,D1);break}case"thinking_start":{g8n(v,g.data);break}case"thinking_end":{g.data;break}case"topic_updated":{T8n(v,g.data,y.chatHistory);break}case"agent_start":{h8n(v,g.data);break}case"agent_end":{f8n(v,g.data);break}case"agent_error":{A8n(v,g.data);break}case"node_start":{b8n(v,g.data);break}case"node_end":{y8n(v,g.data);break}case"subagent_start":{v8n(v,g.data);break}case"subagent_end":{_8n(v,g.data);break}case"progress_update":{w8n(v,g.data);break}case"ask_user_question":{L8n(v,g.data);break}case"token_usage":{const{total_tokens:_,input_tokens:w}=g.data;v.tokenUsage=_,w!=null&&(v.inputTokens=w);break}case"context_usage":{N8n(v,g.data);break}}Eke(v)}});const b=e().channels[l]?.responding;if(f!==b&&console.debug(`responding changed: ${f} → ${b}`,`| hadPendingChunks: ${h}`),console.groupEnd(),g.type==="topic_updated"&&e().renameTab(g.data.id,g.data.name),g.type==="agent_end"){const y=e().channels[l];y?.sessionId&&!y.sandbox_backend&&Lp.getSessionByTopic(l).then(v=>{v.sandbox_backend&&t(_=>{const w=_.channels[l];w&&!w.sandbox_backend&&(w.sandbox_backend=v.sandbox_backend)})}).catch(()=>{})}r(),i(l)};if(Ub.hasConnection(l)){Ub.updateCallbacks(l,{onMessageEvent:d,onStatusChange:m=>{m.connected||$N.get(l)?.destroy(),t(g=>{const h=g.channels[l];h&&(h.connected=m.connected,h.error=m.error??null)})}}),t(m=>{m.channels[l]&&(m.channels[l].connected=!0,m.channels[l].error=null)});return}const p=Ub.getOpenTopicIds();for(const m of p){if(m===l)continue;e().channels[m]?.responding||Ub.disconnect(m)}t(m=>{Object.entries(m.channels).forEach(([g,h])=>{Ub.hasConnection(g)||(h.connected=!1)}),m.channels[l]&&(m.channels[l].error=null)}),Ub.connect(l,{onMessageEvent:d,onStatusChange:m=>{m.connected||$N.get(l)?.destroy(),t(g=>{const h=g.channels[l];h&&(h.connected=m.connected,h.error=m.error??null)})}}),t(m=>{m.channels[l]&&(m.channels[l].connected=!0,m.channels[l].error=null)})},disconnectFromChannel:()=>{for(const[,o]of $N)o.destroy();$N.clear();for(const[o,l]of D1)clearTimeout(l),D1.delete(o);Ub.disconnectAll()},abortGeneration:o=>{hg.abort(o).catch(p=>{console.error("Failed to send abort signal:",p)});const l=D1.get(o);l&&(clearTimeout(l),D1.delete(o));const u=$N.get(o);u&&u.destroy(),t(p=>{const m=p.channels[o];m&&(m.aborting=!0,kke(m))}),r();const d=setTimeout(()=>{D1.delete(o),e().channels[o]?.aborting&&(console.warn("Abort timeout: Backend did not respond, resetting state"),t(g=>{const h=g.channels[o];h&&(h.aborting=!1,h.responding=!1,kke(h))}),r())},1e4);D1.set(o,d)},respondToQuestion:(o,l,u)=>{hg.answerQuestion(o,{question_id:l,selected_options:u.selectedOptions,text:u.text||""}).catch(d=>{console.error("Failed to send question response:",d)}),t(d=>{const p=d.channels[o];if(!p)return;const m=p.messages.find(h=>h.userQuestion?.questionId===l||h.answeredQuestions?.some(f=>f.questionId===l));if(!m)return;const g=m.userQuestion?.questionId===l?m.userQuestion:m.answeredQuestions?.find(h=>h.questionId===l);g&&(g.status="answered",g.selectedOptions=u.selectedOptions,g.userText=u.text,m.status="pending")}),r()},confirmToolCall:(o,l)=>{console.warn("confirmToolCall: not implemented in SSE mode"),t(u=>{u.channels[o]&&u.channels[o].messages.forEach(d=>{d.toolCalls&&d.toolCalls.forEach(p=>{p.id===l&&p.status==="waiting_confirmation"&&(p.status="executing")})})})},cancelToolCall:(o,l)=>{console.warn("cancelToolCall: not implemented in SSE mode"),t(u=>{u.channels[o]&&u.channels[o].messages.forEach(d=>{d.toolCalls&&d.toolCalls.forEach(p=>{p.id===l&&p.status==="waiting_confirmation"&&(p.status="failed",p.error="用户取消执行")})})})}}}const P8n=["image/jpeg","image/jpg","image/png","image/gif","image/webp","application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/json","application/xml","application/x-yaml","text/plain","text/markdown","text/csv","text/html","text/xml","text/yaml","text/x-yaml","audio/mpeg","audio/wav","audio/wave","audio/x-wav",".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"],O8n=[".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"];class F8n{appendUploadFields(e,n){e.append("file",n.file),e.append("scope",n.scope),n.category&&e.append("category",n.category),n.parentId&&e.append("parent_id",n.parentId),n.knowledgeSetId&&e.append("knowledge_set_id",n.knowledgeSetId),n.purpose&&e.append("purpose",n.purpose)}getUploadError(e){if(e.status===429)return new Error("Too many requests. Please wait a moment and try again.");try{const n=JSON.parse(e.responseText);if(typeof n.detail=="string"&&n.detail.trim())return new Error(n.detail)}catch{}return new Error(`Upload failed: ${e.statusText||`HTTP ${e.status}`}`)}uploadWithXhr(e,n){const r=new FormData;this.appendUploadFields(r,e);const i=new XMLHttpRequest,o=nn.baseUrl;return{promise:new Promise((u,d)=>{i.upload.addEventListener("progress",m=>{if(n&&m.lengthComputable){const g=Math.round(m.loaded*100/m.total);n({loaded:m.loaded,total:m.total,percentage:g})}}),i.addEventListener("load",()=>{i.status>=200&&i.status<300?u(JSON.parse(i.responseText)):d(this.getUploadError(i))}),i.addEventListener("error",()=>{d(new Error("Upload failed"))}),i.addEventListener("abort",()=>{d(new Error("Upload cancelled"))}),i.open("POST",`${o}/xyzen/api/v1/files/upload`);const p=Di.getToken();p&&i.setRequestHeader("Authorization",`Bearer ${p}`),i.send(r)}),abort:()=>i.abort()}}isAllowedType(e,n){return n.endsWith("/*")?e.type.startsWith(n.slice(0,-1)):n.startsWith(".")?e.name.toLowerCase().endsWith(n.toLowerCase()):e.type===n}uploadFileWithProgress(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o},l)}async uploadFile(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o},l).promise}async uploadChatAttachment(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o,purpose:"chat_attachment"},l).promise}async getFile(e){return nn.get(`/xyzen/api/v1/files/${e}`)}async listFiles(e){const n=new URLSearchParams;e&&(e.scope&&n.append("scope",e.scope),e.category&&n.append("category",e.category),e.include_deleted&&n.append("include_deleted","true"),e.limit&&n.append("limit",e.limit.toString()),e.offset&&n.append("offset",e.offset.toString()),e.parent_id&&n.append("parent_id",e.parent_id),e.filter_by_parent&&n.append("filter_by_parent","true"),e.is_dir!==void 0&&n.append("is_dir",e.is_dir.toString()),e.knowledge_set_id&&n.append("knowledge_set_id",e.knowledge_set_id));const r=n.toString()?"?"+n.toString():"";return nn.get(`/xyzen/api/v1/files/${r}`)}async getFileUrl(e,n=3600){return nn.get(`/xyzen/api/v1/files/${e}/url`,{params:{expires_in:n}})}async updateFile(e,n){return nn.patch(`/xyzen/api/v1/files/${e}`,n)}async confirmFiles(e,n){await Promise.all(e.map(r=>this.updateFile(r,{message_id:n,status:"confirmed"})))}async deleteFile(e,n=!1){return nn.delete(`/xyzen/api/v1/files/${e}`,void 0,{params:{hard_delete:n}})}async restoreFile(e){return nn.post(`/xyzen/api/v1/files/${e}/restore`)}async getStorageStats(){return nn.get("/xyzen/api/v1/files/stats/summary")}async getChatUploadCapabilities(){return nn.get("/xyzen/api/v1/files/chat-upload-capabilities")}async emptyTrash(){return nn.post("/xyzen/api/v1/files/empty-trash")}async bulkDeleteFiles(e){return nn.delete("/xyzen/api/v1/files/bulk",e)}async updateFileContent(e,n,r){const i=new Blob([n],{type:r||"text/plain"}),o=new FormData;return o.append("file",i,"content"),nn.put(`/xyzen/api/v1/files/${e}/content`,o)}async downloadRaw(e,n){return nn.raw(`/xyzen/api/v1/files/${e}/download`,{signal:n?.signal})}validateFile(e,n={}){const{maxSize:r=100*1024*1024,allowedTypes:i=P8n}=n;return e.size>r?{valid:!1,reason:"file_too_large",maxSize:r,actualSize:e.size,error:`File size exceeds ${(r/(1024*1024)).toFixed(0)}MB limit`}:i.length>0&&!i.some(l=>this.isAllowedType(e,l))?{valid:!1,reason:"unsupported_type",fileType:e.type||"unknown",error:`File type ${e.type||"unknown"} is not supported`}:{valid:!0}}getFileCategory(e){if(e.type.startsWith("image/"))return"images";if(e.type.startsWith("audio/"))return"audio";const n=e.name.toLowerCase();return e.type.includes("pdf")||e.type.includes("text")||e.type.includes("document")||e.type.includes("sheet")||e.type.includes("presentation")||e.type.includes("json")||e.type.includes("xml")||e.type.includes("yaml")||O8n.some(r=>n.endsWith(r))?"documents":"others"}getAttachmentAccessHint(e,n){const r=n||this.getFileCategory({name:e.name,type:e.type});return r==="images"||r==="audio"?"view":"read"}generateThumbnail(e){return new Promise((n,r)=>{if(!e.type.startsWith("image/")){r(new Error("File is not an image"));return}const i=160,o=URL.createObjectURL(e),l=new Image;l.onload=()=>{URL.revokeObjectURL(o);let u=l.width,d=l.height;u>d?u>i&&(d=Math.round(d*i/u),u=i):d>i&&(u=Math.round(u*i/d),d=i);const p=document.createElement("canvas");p.width=u,p.height=d;const m=p.getContext("2d");if(!m){r(new Error("Failed to get canvas context"));return}m.drawImage(l,0,0,u,d);const g=p.toDataURL("image/jpeg",.8);n(g)},l.onerror=()=>{URL.revokeObjectURL(o),r(new Error("Failed to load image"))},l.src=o})}}const go=new F8n;class Q8n{async editMessage(e,n){return nn.patch(`/xyzen/api/v1/messages/${e}`,n)}async deleteMessage(e){return nn.delete(`/xyzen/api/v1/messages/${e}`)}}const bot=new Q8n;function $8n(t,e,n){const{updateDerivedStatus:r,waitForChannelConnection:i}=n;return{sendMessage:async o=>{const{activeChatChannel:l,uploadedFiles:u,clearFiles:d,isUploading:p,channels:m,connectToChannel:g,showNotification:h}=e();if(!l)return;if(p){console.warn("Cannot send message while files are uploading");return}const f=m[l];if(!f)return;if(f.responding){console.warn("Cannot send message while assistant is responding");return}Ub.hasConnection(l)||(g(f.sessionId,f.id),await i(l));const b=e().channels[l];if(!b?.connected){h("Connection not ready","Please wait for chat connection and try again.","warning");return}const y=ON(),v=u.filter(C=>C.status==="completed"&&C.uploadedId),_=v.map(C=>({id:C.uploadedId,name:C.file.name,type:C.file.type,size:C.file.size,category:go.getFileCategory(C.file)}));t(C=>{const E=C.channels[l];E&&(E.responding=!0,E.messages.push({id:y,clientId:y,role:"user",content:o,created_at:new Date().toISOString(),status:"sending",isNewMessage:!0,..._.length>0?{attachments:_}:{}}))}),r();const x={message:o,client_id:y};v.length>0&&(x.file_ids=v.map(C=>C.uploadedId));const k=b;k?.knowledgeContext&&(x.context=k.knowledgeContext);try{await hg.sendMessage(l,x)}catch(C){console.error("Failed to send message via REST:",C),t(S=>{const I=S.channels[l];if(I){I.responding=!1;const B=I.messages.find(N=>N.clientId===y);B&&(B.status="failed")}}),r();const E=C instanceof Error&&"detail"in C?C.detail:void 0;if(E&&typeof E=="object"&&E.type==="parallel_chat_limit"){const S=E.data;e().showNotification(os.t("app.chat.parallelLimitTitle","Parallel chat limit reached"),os.t("app.chat.parallelLimitMessage","You have reached the parallel chat limit ({{current}}/{{limit}}). Please wait for other chats to finish.",{current:S?.current??"?",limit:S?.limit??"?"}),"warning")}else E&&typeof E=="object"&&E.error_code==="INSUFFICIENT_BALANCE"&&e().showNotification(os.t("app.chat.insufficientBalance","Insufficient balance"),os.t("app.chat.insufficientBalanceMessage","Your photon balance is insufficient. Please top up to continue."),"warning");return}d(!1)},startEditMessage:(o,l,u)=>{t({editingMessageId:o,editingContent:l,editingMode:u})},cancelEditMessage:()=>{t({editingMessageId:null,editingContent:"",editingMode:null})},submitEditMessage:async()=>{const{editingMessageId:o,editingContent:l,editingMode:u,activeChatChannel:d,channels:p}=e();if(!o||!d||!u)return;const m=p[d];if(!m)return;if(!m.messages.some(f=>f.id===o)){console.error("Message not found in active channel, skipping edit"),e().cancelEditMessage();return}const h=u==="edit_and_regenerate";try{const f=await bot.editMessage(o,{content:l,truncate_and_regenerate:h});t(b=>{const y=b.channels[d];if(!y)return;const v=y.messages.findIndex(_=>_.id===o);v!==-1&&(y.messages[v].content=f.message.content,y.messages[v].created_at=f.message.created_at,h&&(y.messages=y.messages.slice(0,v+1),y.responding=!1),b.editingMessageId=null,b.editingContent="",b.editingMode=null)}),f.regenerate&&e().triggerRegeneration()}catch(f){console.error("Failed to edit message:",f),e().showNotification("Error",os.t("app.message.editFailed"),"error")}},triggerRegeneration:()=>{const{activeChatChannel:o}=e();if(o){if(!Ub.hasConnection(o)){console.warn("[triggerRegeneration] No SSE connection, skipping");return}t(l=>{const u=l.channels[o];u&&(u.responding=!0)}),hg.regenerate(o).catch(l=>{console.error("Failed to trigger regeneration:",l),t(u=>{const d=u.channels[o];d&&(d.responding=!1)}),r()})}},deleteMessage:async o=>{const{activeChatChannel:l,channels:u}=e();if(!l)return;const d=u[l];if(!d)return;if(!oot(o)){const g=d.messages.find(h=>h.id===o)?.status==="streaming"?os.t("app.message.deleteStillStreaming"):os.t("app.message.deleteNotSaved");console.error(`Cannot delete message: ${g} (id: ${o.slice(0,20)}...)`),e().showNotification(os.t("app.message.cannotDelete"),g,"warning");return}if(!d.messages.some(m=>m.id===o)){console.error("Message not found in active channel, skipping delete");return}try{await bot.deleteMessage(o),t(m=>{const g=m.channels[l];g&&(g.messages=g.messages.filter(h=>h.id!==o))})}catch(m){console.error("Failed to delete message:",m),e().showNotification("Error",os.t("app.message.deleteFailed"),"error")}},retryMessage:o=>{const{activeChatChannel:l,channels:u,sendMessage:d}=e();if(!l)return;const p=u[l];if(!p)return;const m=p.messages.find(h=>h.id===o);if(!m||m.status!=="failed")return;const g=m.content;t(h=>{const f=h.channels[l];f&&(f.messages=f.messages.filter(b=>b.id!==o))}),d(g)}}}const Rte=50,j8n=(t,e)=>{const n=d=>d&&e().resolveAgent(d)?.name||"通用助理",r=async(d,p)=>{const m=Date.now();for(;Date.now()-m<=i8n;){const g=e().channels[d];if(g?.connected)return!0;if(g?.error)return p?.logFailure&&console.warn(`Connection failed for topic ${d}: ${g.error}`),!1;await new Promise(h=>{setTimeout(h,s8n)})}return p?.logFailure&&console.warn(`Connection timeout for topic ${d}`),!1},i=()=>{const d=e().respondingChannelIds;t(p=>{const m=new Set,g=new Set,h={};for(const b of Object.values(p.channels)){const y=HFn(b);(y==="running"||y==="stopping")&&(m.add(b.id),b.agentId&&g.add(b.agentId)),y==="running"&&b.agentId&&(h[b.agentId]=(h[b.agentId]||0)+1)}p.respondingChannelIds=m,p.runningAgentIds=g,p.activeTopicCountByAgent=h;const f=p.activeChatChannel;if(f){const b=d.has(f),y=m.has(f);b!==y&&console.debug(`[updateDerivedStatus] active channel ${f}: respondingChannelIds ${b} → ${y}`,`| channel.responding: ${p.channels[f]?.responding}`)}})},u={reconcileChannelFromBackend:async d=>{const{setLoading:p}=e(),m=`topicMessages-${d}`,g=e().channels[d];if(g?.responding){console.debug(`[reconcile] SKIP — channel is responding, topic=${d.slice(0,8)} msgs=${g.messages.length}`);return}console.groupCollapsed(`[reconcile] topic=${d.slice(0,8)} responding=${g?.responding} msgs=${g?.messages.length}`),console.debug(new Error().stack?.split(`
110
+ `).slice(1,5).join(" <- ")),p(m,!0);try{const[h,f]=await Promise.all([hg.getMessages(d,{limit:Rte}),hg.getTokenStats(d).catch(()=>null)]),b=Bte(h);t(y=>{const v=y.channels[d];if(v){const _=new Set(b.map(E=>E.id)),w=v.messages.filter(E=>_.has(E.id)||E.dbId&&_.has(E.dbId)?!1:!!(E.status==="pending"||E.status==="streaming"||E.status==="thinking"||E.agentExecution)),x=new Set,k=[];for(const E of w){let S=-1;if(E.role==="assistant"){for(let I=b.length-1;I>=0;I--)if(b[I].role==="assistant"&&!x.has(I)){S=I;break}}if(S!==-1){const I=b[S];I.streamId=E.streamId,I.status=E.status,I.agentExecution=E.agentExecution,I.thinkingContent=E.thinkingContent,x.add(S)}else k.push(E)}const C=[...b,...k];console.debug(`[reconcile] OVERWRITE topic=${d.slice(0,8)} oldMsgs=${v.messages.length} dbMsgs=${b.length} preserved=${w.length} merged=${w.length-k.length} new=${k.length} responding=${v.responding}`),v.messages=C,v.hasOlderMessages=h.length>=Rte,f?.total_tokens!=null&&(v.tokenUsage=f.total_tokens),f?.input_tokens!=null&&(v.inputTokens=f.input_tokens),v.contextUsage=void 0,Eke(v)}}),i()}catch(h){console.error("Failed to reconcile topic messages:",h)}finally{console.groupEnd(),p(m,!1)}},updateDerivedStatus:i,closeIdleNonPrimaryConnection:d=>{setTimeout(()=>{e().channels[d]?.responding||e().activeChatChannel===d||Ub.disconnect(d)},0)},getAgentNameById:n,waitForChannelConnection:r};return{activeChatChannel:null,activeTopicByAgent:{},chatHistory:[],chatHistoryLoading:!0,channels:{},respondingChannelIds:new Set,runningAgentIds:new Set,activeTopicCountByAgent:{},notification:null,editingMessageId:null,editingContent:"",editingMode:null,setKnowledgeContext:(d,p)=>{t(m=>{m.channels[d]&&(m.channels[d].knowledgeContext=p||void 0)})},showNotification:(d,p,m="info",g,h)=>{t(f=>{f.notification={isOpen:!0,title:d,message:p,type:m,actionLabel:g,onAction:h}})},closeNotification:()=>{t({notification:null})},loadOlderMessages:async d=>{const p=e().channels[d];if(!p||p.loadingOlderMessages||!p.hasOlderMessages)return;const m=p.messages.find(g=>g.id);if(m?.id){t(g=>{const h=g.channels[d];h&&(h.loadingOlderMessages=!0)});try{const g=await hg.getMessages(d,{before:m.id,limit:Rte}),h=Bte(g);t(f=>{const b=f.channels[d];if(b){const y=new Set(b.messages.map(_=>_.id)),v=h.filter(_=>!y.has(_.id));b.messages=[...v,...b.messages],b.hasOlderMessages=g.length>=Rte,b.loadingOlderMessages=!1}})}catch(g){console.error("Failed to load older messages:",g),t(h=>{const f=h.channels[d];f&&(f.loadingOlderMessages=!1)})}}},...o8n(t,e,u),...$8n(t,e,u),...M8n(t,e,u)}},z8n={maxSize:10*1024*1024,maxFiles:5,maxTotalSize:20*1024*1024,allowedTypes:["image/jpeg","image/jpg","image/png","image/gif","image/webp","application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/json","application/xml","application/x-yaml","text/plain","text/markdown","text/csv","text/html","text/xml","text/yaml","text/x-yaml","audio/mpeg","audio/wav","audio/wave","audio/x-wav",".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"],autoUpload:!0};function jN(t){return(t/(1024*1024)).toFixed(1)}function yot(t){const e=t.slice(0,3).map(r=>r.name).join(", "),n=t.length>3?os.t("app.input.moreFilesSuffix",{count:t.length-3}):"";return e+n}function vot(t,e){switch(e.reason){case"file_too_large":return os.t("app.input.fileTooLargeDetail",{name:t.name,maxSize:jN(e.maxSize??t.size),actualSize:jN(e.actualSize??t.size)});case"unsupported_type":return os.t("app.input.unsupportedFileTypeDetail",{name:t.name});default:return e.error||t.name}}const U8n=(t,e)=>({uploadedFiles:[],isUploading:!1,uploadError:null,fileUploadOptions:{...z8n},validateFiles:n=>{const r=e(),i=r.fileUploadOptions,o=r.uploadedFiles,l=[];o.length+n.length>(i.maxFiles||5)&&l.push(`Maximum ${i.maxFiles} files allowed. You have ${o.length} files and are trying to add ${n.length} more.`);for(const m of n){const g=go.validateFile(m,{maxSize:i.maxSize,allowedTypes:i.allowedTypes});g.valid||l.push(vot(m,g))}const u=r.getTotalSize(),d=n.reduce((m,g)=>m+g.size,0),p=u+d;return p>(i.maxTotalSize||20*1024*1024)&&l.push(os.t("app.input.totalSizeExceededMessage",{maxSize:jN(i.maxTotalSize||20*1024*1024),actualSize:jN(p)})),{valid:l.length===0,errors:l.length>0?l:void 0,error:l.length>0?l.join("; "):void 0}},addFiles:async n=>{const r=e(),i=r.fileUploadOptions,o=r.uploadedFiles,l=[],u=[],d=[];for(const C of n){const E=go.validateFile(C,{maxSize:i.maxSize,allowedTypes:i.allowedTypes});E.valid?l.push(C):(u.push({file:C,validation:E}),d.push(vot(C,E)))}const p=u.filter(({validation:C})=>C.reason==="file_too_large").map(({file:C})=>C);p.length>0&&e().showNotification(os.t("app.input.fileTooLargeTitle"),os.t("app.input.fileTooLargeMessage",{files:yot(p),maxSize:jN(i.maxSize||10*1024*1024)}),"warning");const m=u.filter(({validation:C})=>C.reason==="unsupported_type").map(({file:C})=>C);m.length>0&&e().showNotification(os.t("app.input.unsupportedFilesTitle"),os.t("app.input.unsupportedFilesMessage",{files:yot(m)}),"warning");const g=Math.max(0,(i.maxFiles||5)-o.length);if(g===0){const C=os.t("app.dragDrop.maxReached");t({uploadError:C}),e().showNotification(os.t("app.input.fileLimitTitle"),C,"warning");return}const h=l.slice(0,g);l.slice(g).length>0&&e().showNotification(os.t("app.input.fileLimitTitle"),os.t("app.input.fileLimitMessage",{count:g}),"warning");const b=i.maxTotalSize||20*1024*1024,y=r.getTotalSize(),v=y+h.reduce((C,E)=>C+E.size,0);let _=y;const w=[],x=[];for(const C of h){if(_+C.size>b){x.push(C);continue}w.push(C),_+=C.size}if(x.length>0){const C=os.t("app.input.totalSizeExceededMessage",{maxSize:jN(b),actualSize:jN(v)});t({uploadError:C}),e().showNotification(os.t("app.input.totalSizeExceededTitle"),C,"warning")}if(w.length===0){d.length>0&&t({uploadError:d.join("; ")});return}const k=w.map(C=>({id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,file:C,name:C.name,size:C.size,type:C.type,category:go.getFileCategory(C),status:"pending",progress:0,createdAt:new Date}));if(t(C=>({uploadedFiles:[...C.uploadedFiles,...k],uploadError:d.length>0?d.join("; "):null})),r.fileUploadOptions.autoUpload)for(const C of k)await r.uploadFile(C.file)},uploadFile:async n=>{const i=e().uploadedFiles.find(o=>o.file===n);if(!i)return null;try{if(t(p=>({uploadedFiles:p.uploadedFiles.map(m=>m.id===i.id?{...m,status:"uploading",progress:0}:m),isUploading:!0})),n.type.startsWith("image/"))try{const p=await go.generateThumbnail(n);t(m=>({uploadedFiles:m.uploadedFiles.map(g=>g.id===i.id?{...g,thumbnailUrl:p}:g)}))}catch(p){console.warn("Failed to generate thumbnail:",p)}const o=e().activeChatChannel,u=(o?e().channels[o]:null)?.knowledge_set_id??null,d=await go.uploadChatAttachment(n,"private",i.category,null,u,p=>{t(m=>({uploadedFiles:m.uploadedFiles.map(g=>g.id===i.id?{...g,progress:p.percentage}:g)}))});return t(p=>({uploadedFiles:p.uploadedFiles.map(m=>m.id===i.id?{...m,status:"completed",progress:100,uploadedId:d.id,downloadUrl:d.download_url}:m),isUploading:p.uploadedFiles.some(m=>m.id!==i.id&&m.status==="uploading")})),d.id}catch(o){const l=o instanceof Error?o.message:"Upload failed";return t(u=>({uploadedFiles:u.uploadedFiles.map(d=>d.id===i.id?{...d,status:"error",error:l}:d),isUploading:u.uploadedFiles.some(d=>d.id!==i.id&&d.status==="uploading"),uploadError:l})),null}},removeFile:n=>{const i=e().uploadedFiles.find(o=>o.id===n);i?.uploadedId&&go.deleteFile(i.uploadedId,!1).catch(o=>{console.error("Failed to delete file from server:",o)}),t(o=>({uploadedFiles:o.uploadedFiles.filter(l=>l.id!==n)}))},clearFiles:(n=!1)=>{const r=e();if(n){const i=r.uploadedFiles.filter(o=>o.uploadedId).map(o=>o.uploadedId);i.length>0&&go.bulkDeleteFiles(i).catch(o=>{console.error("Failed to delete files from server:",o)})}t({uploadedFiles:[],isUploading:!1,uploadError:null})},confirmFilesForMessage:async n=>{const i=e().uploadedFiles.filter(o=>o.uploadedId&&o.status==="completed").map(o=>o.uploadedId);if(i.length>0)try{await go.confirmFiles(i,n),t({uploadedFiles:[]})}catch(o){throw console.error("Failed to confirm files:",o),o}},cancelUpload:n=>{t(r=>({uploadedFiles:r.uploadedFiles.map(i=>i.id===n?{...i,status:"error",error:"Cancelled"}:i)}))},retryUpload:async n=>{const r=e(),i=r.uploadedFiles.find(o=>o.id===n);i&&await r.uploadFile(i.file)},updateFileUploadOptions:n=>{t(r=>({fileUploadOptions:{...r.fileUploadOptions,...n}}))},getTotalSize:()=>e().uploadedFiles.reduce((r,i)=>r+i.size,0),canAddMoreFiles:()=>{const n=e();return n.uploadedFiles.length<(n.fileUploadOptions.maxFiles||5)}});class q8n{async createFolder(e){return nn.post("/xyzen/api/v1/folders/",e)}async listFolders(e=null,n=!1,r){return nn.get("/xyzen/api/v1/folders/",{params:{parent_id:e??void 0,include_deleted:n||void 0,knowledge_set_id:r}})}async getTree(e,n){return nn.get("/xyzen/api/v1/folders/tree",{params:{knowledge_set_id:e,only_deleted:n||void 0}})}async getFolder(e){return nn.get(`/xyzen/api/v1/folders/${e}`)}async getFolderPath(e){return nn.get(`/xyzen/api/v1/folders/${e}/path`)}async updateFolder(e,n){return nn.patch(`/xyzen/api/v1/folders/${e}`,n)}async deleteFolder(e,n=!1){return nn.delete(`/xyzen/api/v1/folders/${e}`,void 0,{params:{hard_delete:n}})}}const bf=new q8n,G8n=(t,e)=>({knowledgeActiveTab:"home",knowledgeFolderId:null,knowledgeSetId:null,knowledgeTreeItems:[],knowledgeTreeLoading:!1,knowledgeTreeSignal:0,trashTreeItems:[],trashTreeLoading:!1,navigateKnowledge:(n,r=null)=>{t(i=>{i.knowledgeActiveTab=n,i.knowledgeSetId=n==="knowledge"?r??null:null,i.knowledgeFolderId=null})},setKnowledgeFolderId:n=>{t(r=>{r.knowledgeFolderId=n})},fetchKnowledgeTree:async()=>{const{knowledgeActiveTab:n,knowledgeSetId:r}=e();if(n==="trash"){t(i=>{i.trashTreeLoading=!0});try{const i=await bf.getTree(void 0,!0);t(o=>{o.trashTreeItems=i,o.trashTreeLoading=!1})}catch(i){console.error("Failed to fetch trash tree",i),t(o=>{o.trashTreeLoading=!1})}return}if(!(n!=="all"&&n!=="knowledge"&&n!=="images"&&n!=="documents")){if(n==="knowledge"&&!r){t(i=>{i.knowledgeTreeItems=[],i.knowledgeTreeLoading=!1});return}t(i=>{i.knowledgeTreeLoading=!0});try{const i=n==="knowledge"?r??void 0:void 0,o=await bf.getTree(i);t(l=>{l.knowledgeTreeItems=o,l.knowledgeTreeLoading=!1})}catch(i){console.error("Failed to fetch knowledge tree",i),t(o=>{o.knowledgeTreeLoading=!1})}}},refreshKnowledge:()=>{t(n=>{n.knowledgeTreeSignal+=1})},removeTreeItems:n=>{t(r=>{const i=new Set(n);r.knowledgeActiveTab==="trash"?r.trashTreeItems=r.trashTreeItems.filter(o=>!i.has(o.id)):r.knowledgeTreeItems=r.knowledgeTreeItems.filter(o=>!i.has(o.id))})},renameTreeItem:(n,r)=>{t(i=>{const l=(i.knowledgeActiveTab==="trash"?i.trashTreeItems:i.knowledgeTreeItems).find(u=>u.id===n);l&&(l.name=r)})}}),H8n=(t,e)=>({loadingStates:{},setLoading:(n,r)=>{t(i=>{r?i.loadingStates[n]=!0:delete i.loadingStates[n]})},getLoading:n=>e().loadingStates[n]||!1,clearAllLoading:()=>{t(n=>{n.loadingStates={}})}}),PA={MCP_SERVERS:"mcpServers",MCP_SERVER_CREATE:"mcpServerCreate",MCP_SERVER_UPDATE:"mcpServerUpdate",MCP_SERVER_DELETE:"mcpServerDelete"},N1={async getMcpServers(){return nn.get("/xyzen/api/v1/mcps")},async createMcpServer(t){return nn.post("/xyzen/api/v1/mcps",t)},async updateMcpServer(t,e){return nn.patch(`/xyzen/api/v1/mcps/${t}`,e)},async deleteMcpServer(t){return nn.delete(`/xyzen/api/v1/mcps/${t}`)},async refreshMcpServers(){return nn.post("/xyzen/api/v1/mcps/refresh")},async activateSmitheryServer(t,e){return nn.post("/xyzen/api/v1/mcps/smithery/activate",{qualifiedName:t,profile:e})},async getBuiltinMcpServers(){try{return await nn.get("/xyzen/api/v1/mcps/discover")}catch(t){return console.warn("Error discovering builtin MCP servers:",t),[]}},async getBuiltinSearchServers(){try{return await nn.get("/xyzen/api/v1/mcps/search-servers/discover")}catch(t){return console.warn("Error discovering builtin search servers:",t),[]}},async getSearchServers(){return nn.get("/xyzen/api/v1/mcps")},async getSessionSearchEngine(t){try{return await nn.get(`/xyzen/api/v1/sessions/${t}/search-engine`)}catch(e){if(e instanceof Error&&"status"in e&&e.status===404)return null;throw e}},async setSessionSearchEngine(t,e){return nn.put(`/xyzen/api/v1/sessions/${t}/search-engine`,{mcp_server_id:e})},async removeSessionSearchEngine(t){return nn.delete(`/xyzen/api/v1/sessions/${t}/search-engine`)},async testTool(t,e,n){return nn.post(`/xyzen/api/v1/mcps/${t}/tools/${e}/test`,{parameters:n})}};function W8n(t){if("data"in t&&"source"in t&&t.source==="official")return t;const e=t,n={name:e.name,module_name:e.module_name,mount_path:e.mount_path,description:e.description,is_builtin:!0,requires_auth:e.requires_auth||!1,is_default:e.is_default,banner:e.banner};return{id:e.module_name,name:e.name,description:e.description,source:"official",cover:e.banner,data:n}}function Y8n(t){return Array.isArray(t)?t.filter(e=>e&&typeof e=="object").map(e=>W8n(e)):(console.warn("convertBuiltinServers: input is not an array",t),[])}const V8n=(t,e)=>({mcpServers:[],builtinMcpServers:[],lastFetchTime:0,isEditMcpServerModalOpen:!1,editingMcpServer:null,openEditMcpServerModal:n=>{t({isEditMcpServerModalOpen:!0,editingMcpServer:n})},closeEditMcpServerModal:()=>{t({isEditMcpServerModalOpen:!1,editingMcpServer:null})},fetchMcpServers:async()=>{const{setLoading:n}=e(),r=Date.now(),{lastFetchTime:i}=e();if(r-i<5e3){console.log("McpSlice: 使用缓存的MCP服务器数据");return}n(PA.MCP_SERVERS,!0);try{console.log("McpSlice: Starting to fetch MCP servers...");const o=await N1.getMcpServers();console.log(`McpSlice: Loaded ${o.length} MCP servers`),t({mcpServers:o,lastFetchTime:r})}catch(o){console.error("Failed to fetch MCP servers:",o)}finally{n(PA.MCP_SERVERS,!1)}},fetchBuiltinMcpServers:async()=>{try{const n=await N1.getBuiltinMcpServers(),r=Y8n(n),{mcpServers:i,backendUrl:o}=e(),l=i.map(d=>d.url),u=r.filter(d=>{const p=d.data.mount_path.endsWith("/")?d.data.mount_path:`${d.data.mount_path}/`,m=`${o}${p}`;return!l.includes(m)});t({builtinMcpServers:u})}catch(n){console.error("Failed to fetch builtin MCP servers:",n),t({builtinMcpServers:[]})}},refreshMcpServers:async()=>{const{setLoading:n}=e();n(PA.MCP_SERVERS,!0);try{await N1.refreshMcpServers(),setTimeout(()=>{e().fetchMcpServers()},1e3)}catch(r){console.error("Failed to refresh MCP servers:",r)}finally{setTimeout(()=>n(PA.MCP_SERVERS,!1),1500)}},addMcpServer:async n=>{const{setLoading:r}=e();r(PA.MCP_SERVER_CREATE,!0);try{const i=await N1.createMcpServer(n);t(o=>{o.mcpServers.push(i)}),e().closeAddMcpServerModal()}catch(i){throw console.error("Failed to add MCP server:",i),i}finally{r(PA.MCP_SERVER_CREATE,!1)}},quickAddBuiltinServer:async n=>{const{backendUrl:r,token:i,setLoading:o}=e();o(PA.MCP_SERVER_CREATE,!0);try{const l=n.data.mount_path.endsWith("/")?n.data.mount_path:`${n.data.mount_path}/`,u={name:n.name,description:n.description,url:`${r}${l}`,token:i||""},d=await N1.createMcpServer(u);return t(p=>{p.mcpServers.push(d),p.builtinMcpServers=p.builtinMcpServers.filter(m=>m.data.module_name!==n.data.module_name)}),e().closeAddMcpServerModal(),d}catch(l){throw console.error("Failed to add builtin MCP server:",l),l}finally{o(PA.MCP_SERVER_CREATE,!1)}},activateSmitheryServer:async(n,r)=>{const{setLoading:i}=e();i(PA.MCP_SERVER_CREATE,!0);try{const o=await N1.activateSmitheryServer(n,r);t(l=>{l.mcpServers.push(o)}),e().closeAddMcpServerModal()}catch(o){throw console.error("Failed to activate Smithery MCP server:",o),o}finally{i(PA.MCP_SERVER_CREATE,!1)}},editMcpServer:async(n,r)=>{const{setLoading:i}=e();i(PA.MCP_SERVER_UPDATE,!0);try{const o=await N1.updateMcpServer(n,r);t(l=>{const u=l.mcpServers.findIndex(d=>d.id===n);u!==-1&&(l.mcpServers[u]=o)})}catch(o){throw console.error("Failed to edit MCP server:",o),o}finally{i(PA.MCP_SERVER_UPDATE,!1)}},removeMcpServer:async n=>{const{setLoading:r}=e();r(PA.MCP_SERVER_DELETE,!0);try{await N1.deleteMcpServer(n),t(i=>{i.mcpServers=i.mcpServers.filter(o=>o.id!==n)})}catch(i){throw console.error("Failed to remove MCP server:",i),i}finally{r(PA.MCP_SERVER_DELETE,!1)}},updateMcpServerInList:n=>{t(r=>{const i=r.mcpServers.findIndex(o=>o.id===n.id);i!==-1?r.mcpServers[i]=n:r.mcpServers.push(n)})}}),K8n=(t,e)=>({toolTestModal:{isOpen:!1},toolExecutionHistory:[],openToolTestModal:(n,r,i)=>{t(o=>{o.toolTestModal={isOpen:!0,server:n,toolName:r,toolDescription:i}})},closeToolTestModal:()=>{t(n=>{n.toolTestModal={isOpen:!1}})},addToolExecution:n=>{t(r=>{const i={...n,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,timestamp:new Date};r.toolExecutionHistory.unshift(i),r.toolExecutionHistory.length>100&&(r.toolExecutionHistory=r.toolExecutionHistory.slice(0,100))})},clearToolExecutionHistory:()=>{t(n=>{n.toolExecutionHistory=[]})},getToolExecutionHistory:(n,r)=>{const{toolExecutionHistory:i}=e();return!n&&!r?i:i.filter(o=>{const l=!n||o.serverId===n,u=!r||o.toolName===r;return l&&u})}}),Z8n=t=>({notificationEnabled:!1,novuAppIdentifier:"",novuApiUrl:"",novuWsUrl:"",pushPermission:typeof Notification<"u"&&typeof Notification.permission=="string"?Notification.permission:"default",pushSubscribed:!1,setNotificationConfig:(e,n,r,i)=>{t(o=>{o.notificationEnabled=e,o.novuAppIdentifier=n,o.novuApiUrl=r,o.novuWsUrl=i})},setPushPermission:e=>{t(n=>{n.pushPermission=e})},setPushSubscribed:e=>{t(n=>{n.pushSubscribed=e})}});class Ike{static STORAGE_KEY="xyzen_provider_preferences";static getPreferences(){try{const e=localStorage.getItem(this.STORAGE_KEY);if(e){const n=JSON.parse(e);return{defaultProviderId:n.defaultProviderId||null,lastUsedProviders:n.lastUsedProviders||{}}}}catch(e){console.warn("Failed to load provider preferences:",e)}return{defaultProviderId:null,lastUsedProviders:{}}}static savePreferences(e){try{localStorage.setItem(this.STORAGE_KEY,JSON.stringify(e))}catch(n){console.error("Failed to save provider preferences:",n)}}static setDefaultProvider(e){const n=this.getPreferences();n.defaultProviderId=e,this.savePreferences(n)}static getDefaultProviderId(){return this.getPreferences().defaultProviderId}static getDefaultProvider(e){const n=this.getDefaultProviderId();return n&&e.find(r=>r.id===n)||null}static setLastUsedProviderForAgent(e,n){const r=this.getPreferences();r.lastUsedProviders[e]=n,this.savePreferences(r)}static getLastUsedProviderForAgent(e){return this.getPreferences().lastUsedProviders[e]||null}static clearPreferences(){try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.error("Failed to clear provider preferences:",e)}}static migrateFromDatabaseDefault(e){if(!this.getPreferences().defaultProviderId){const r=e.find(i=>i.is_default&&!i.is_system);r&&(console.info("Migrating database default provider to local preferences:",r.name),this.setDefaultProvider(r.id))}}}function X8n(t,e){if(t?.provider_id){const o=e.find(l=>l.id===t.provider_id);if(o)return o}const n=Ike.getDefaultProvider(e);if(n&&!n.is_system)return n;const r=e.find(o=>o.is_system);return r||e.filter(o=>!o.is_system)[0]||null}const J8n=(t,e)=>({userDefaultProviderId:null,initializeProviderPreferences:()=>{const n=Ike.getDefaultProviderId();t({userDefaultProviderId:n})},setUserDefaultProvider:n=>{Ike.setDefaultProvider(n),t({userDefaultProviderId:n})},getUserDefaultProvider:n=>{const{userDefaultProviderId:r}=e();return r&&n.find(i=>i.id===r)||null},resolveProviderForAgent:(n,r)=>X8n(n,r),llmProviders:[],llmProvidersLoading:!1,providerTemplates:[],templatesLoading:!1,availableModels:{},availableModelsLoading:!1,fetchProviderTemplates:async()=>{console.warn("[DEPRECATED] fetchProviderTemplates is deprecated. Use useProviderTemplates() hook instead.")},fetchMyProviders:async()=>{console.warn("[DEPRECATED] fetchMyProviders is deprecated. Use useMyProviders() hook instead."),e().initializeProviderPreferences()},fetchAvailableModels:async()=>{console.warn("[DEPRECATED] fetchAvailableModels is deprecated. Use useAvailableModels() hook instead.")},addProvider:async()=>{throw console.warn("[DEPRECATED] addProvider is deprecated. Use useCreateProvider().mutateAsync instead."),new Error("addProvider is deprecated. Use useCreateProvider().mutateAsync instead.")},updateProvider:async()=>{throw console.warn("[DEPRECATED] updateProvider is deprecated. Use useUpdateProvider().mutateAsync instead."),new Error("updateProvider is deprecated. Use useUpdateProvider().mutateAsync instead.")},removeProvider:async()=>{throw console.warn("[DEPRECATED] removeProvider is deprecated. Use useDeleteProvider().mutateAsync instead."),new Error("removeProvider is deprecated. Use useDeleteProvider().mutateAsync instead.")}});class e6n{async listRunners(){return nn.get("/xyzen/api/v1/runners/")}async createRunnerToken(e){return nn.post("/xyzen/api/v1/runners/token",{name:e})}async updateRunner(e,n){return nn.patch(`/xyzen/api/v1/runners/${e}`,n)}async deleteRunner(e){return nn.delete(`/xyzen/api/v1/runners/${e}`)}}const Lte=new e6n;class t6n{ws=null;handlers=new Map;reconnectTimer=null;reconnectDelay=1e3;maxReconnectDelay=3e4;intentionalClose=!1;connect(){if(this.ws?.readyState===WebSocket.OPEN)return;const e=Di.getToken();if(!e)return;const n=sd().env.backendUrl;if(!n)return;const r=`${n.replace(/^http(s?):\/\//,"ws$1://")}/xyzen/ws/v1/user/events?token=${encodeURIComponent(e)}`;this.intentionalClose=!1;try{this.ws=new WebSocket(r)}catch{this.scheduleReconnect();return}this.ws.onopen=()=>{this.reconnectDelay=1e3},this.ws.onmessage=i=>{try{const o=JSON.parse(i.data);if(o.type==="pong")return;const l=this.handlers.get(o.type);if(l)for(const u of l)u(o)}catch{}},this.ws.onclose=()=>{this.ws=null,this.intentionalClose||this.scheduleReconnect()},this.ws.onerror=()=>{}}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}on(e,n){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(n),()=>{r.delete(n),r.size===0&&this.handlers.delete(e)}}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*2,this.maxReconnectDelay),this.connect()},this.reconnectDelay))}}const X5=new t6n,n6n=(t,e)=>({runners:[],runnersLoading:!1,fetchRunners:async()=>{t({runnersLoading:!0});try{const n=await Lte.listRunners();t({runners:n,runnersLoading:!1})}catch{t({runnersLoading:!1})}},createRunnerToken:async n=>{try{const r=await Lte.createRunnerToken(n);return t(i=>{i.runners.unshift(r.runner)}),{runner:r.runner,token:r.token,connect_command:r.connect_command}}catch{return null}},deleteRunner:async n=>{try{await Lte.deleteRunner(n),t(r=>{r.runners=r.runners.filter(i=>i.id!==n)})}catch{}},updateRunner:async(n,r)=>{try{const i=await Lte.updateRunner(n,r);t(o=>{const l=o.runners.findIndex(u=>u.id===n);l>=0&&(o.runners[l]=i)})}catch{}},connectRunnerEvents:()=>{X5.connect();const n=X5.on("runner_status",r=>{const{runner_id:i,is_online:o}=r.data;let l=!1;if(t(u=>{const d=u.runners.find(p=>p.id===i);d&&(l=!0,d.is_online=o)}),!l){e().fetchRunners();return}e().fetchRunners()});return()=>{n(),X5.disconnect()}}}),r6n=t=>({isTerminalOpen:!1,activeSessionId:null,terminalSessions:{},pendingCommand:"",pendingArgs:[],pendingRunnerId:null,openTerminal:(e="",n=[],r)=>{t(i=>{i.isTerminalOpen=!0,i.pendingCommand=e,i.pendingArgs=n,i.pendingRunnerId=r??null})},closeTerminalModal:()=>{t(e=>{e.isTerminalOpen=!1})},addSession:e=>{t(n=>{n.terminalSessions[e.id]=e,n.activeSessionId=e.id})},updateSession:(e,n)=>{t(r=>{const i=r.terminalSessions[e];i&&Object.assign(i,n)})},removeSession:e=>{t(n=>{if(delete n.terminalSessions[e],n.activeSessionId===e){const r=Object.keys(n.terminalSessions);n.activeSessionId=r.length>0?r[0]:null}})},setActiveSession:e=>{t({activeSessionId:e})}}),_ot={Sidebar:"sidebar"},a6n=t=>({backendUrl:sd().env.backendUrl,isXyzenOpen:!1,panelWidth:Ske,activeTabIndex:0,activePanel:"chat",theme:sd().storage.getItem("theme")||"system",layoutStyle:sd().storage.getItem("layoutStyle")||sd().env.layoutStyle||_ot.Sidebar,inputPosition:sd().storage.getItem("inputPosition")||"bottom",isMcpListModalOpen:!1,isLlmProvidersModalOpen:!1,isAddMcpServerModalOpen:!1,isAddLlmProviderModalOpen:!1,isSettingsModalOpen:!1,activeSettingsCategory:"account",activeUiSetting:"theme",selectedProviderId:null,pendingInput:"",spatialSidebarCollapsed:!1,capsuleOpen:!1,capsuleActiveTab:"knowledge",showOfficialRecommendations:sd().storage.getItem("officialRecommendationsDismissed")!=="true",mobileCeoOverlay:!0,mobilePage:0,pendingFocusAgentId:null,highlightMessageId:null,dockMinimized:!1,openTabsByAgent:{},toggleXyzen:()=>t(e=>({isXyzenOpen:!e.isXyzenOpen})),openXyzen:()=>t({isXyzenOpen:!0}),closeXyzen:()=>t({isXyzenOpen:!1}),setPanelWidth:e=>t({panelWidth:e}),setTabIndex:e=>t({activeTabIndex:e}),setActivePanel:e=>t({activePanel:e}),setTheme:e=>{sd().storage.setItem("theme",e),t({theme:e})},setLayoutStyle:e=>{sd().storage.setItem("layoutStyle",e),t({layoutStyle:e})},setInputPosition:e=>{sd().storage.setItem("inputPosition",e),t({inputPosition:e})},setBackendUrl:e=>{sd().env.backendUrl=e,t({backendUrl:e})},openMcpListModal:()=>t({isMcpListModalOpen:!0}),closeMcpListModal:()=>t({isMcpListModalOpen:!1}),openLlmProvidersModal:()=>t({isLlmProvidersModalOpen:!0}),closeLlmProvidersModal:()=>t({isLlmProvidersModalOpen:!1}),openAddMcpServerModal:()=>t({isAddMcpServerModalOpen:!0}),closeAddMcpServerModal:()=>t({isAddMcpServerModalOpen:!1}),openAddLlmProviderModal:()=>t({isAddLlmProviderModalOpen:!0}),closeAddLlmProviderModal:()=>t({isAddLlmProviderModalOpen:!1}),openSettingsModal:(e="account")=>t({isSettingsModalOpen:!0,activeSettingsCategory:e}),closeSettingsModal:()=>t({isSettingsModalOpen:!1,selectedProviderId:null}),setActiveSettingsCategory:e=>t({activeSettingsCategory:e}),setActiveUiSetting:e=>t({activeUiSetting:e}),setSelectedProvider:e=>t({selectedProviderId:e}),setPendingInput:e=>t({pendingInput:e}),submitInput:()=>t(()=>({isXyzenOpen:!0,activeTabIndex:1,activePanel:"chat"})),setSpatialSidebarCollapsed:e=>t({spatialSidebarCollapsed:e}),setCapsuleOpen:e=>t({capsuleOpen:e}),setCapsuleActiveTab:e=>t({capsuleActiveTab:e}),setShowOfficialRecommendations:e=>{sd().storage.setItem("officialRecommendationsDismissed",e?"false":"true"),t({showOfficialRecommendations:e})},setMobileCeoOverlay:e=>t({mobileCeoOverlay:e}),setMobilePage:e=>t({mobilePage:e}),requestFocusAgent:e=>t({pendingFocusAgentId:e}),highlightMessage:e=>t({highlightMessageId:e}),openTab:(e,n)=>t(r=>{const i=r.openTabsByAgent[e]??[];i.some(o=>o.id===n.id)||(r.openTabsByAgent[e]=[...i,n])}),closeTab:(e,n)=>t(r=>{const i=r.openTabsByAgent[e];i&&(r.openTabsByAgent[e]=i.filter(o=>o.id!==n))}),setOpenTabs:(e,n)=>t(r=>{r.openTabsByAgent[e]=n}),setDockMinimized:e=>t({dockMinimized:e}),renameTab:(e,n)=>t(r=>{for(const i of Object.values(r.openTabsByAgent)){const o=i.find(l=>l.id===e);if(o){o.name=n;break}}})});class i6n{async redeemCode(e){return nn.post("/xyzen/api/v1/redemption/redeem",{code:e})}async getUserWallet(){return nn.get("/xyzen/api/v1/redemption/wallet")}async getRedemptionHistory(e=100,n=0){return nn.get("/xyzen/api/v1/redemption/history",{params:{limit:e,offset:n}})}async getDailyTokenStats(e,n,r){return nn.get("/xyzen/api/v1/redemption/admin/stats/daily-tokens",{auth:!1,headers:{"X-Admin-Secret":e},params:{date:n,tz:r}})}async getTopUsersByConsumption(e,n=20){return nn.get("/xyzen/api/v1/redemption/admin/stats/top-users",{auth:!1,headers:{"X-Admin-Secret":e},params:{limit:n}})}async getConsumeRecords(e,n,r,i,o=1e4,l=0){return nn.get("/xyzen/api/v1/redemption/admin/stats/consume-records",{auth:!1,headers:{"X-Admin-Secret":e},params:{start_date:n,end_date:r,tz:i,limit:o,offset:l}})}async getAllConsumeRecords(e,n,r,i,o=1e4){const l=[];let u=0;for(;;){const d=await this.getConsumeRecords(e,n,r,i,o,u);if(l.push(...d),d.length<o)break;u+=o}return l}async getUserActivityStats(e,n,r,i){return nn.get("/xyzen/api/v1/redemption/admin/stats/user-activity",{auth:!1,headers:{"X-Admin-Secret":e},params:{start_date:n,end_date:r,tz:i}})}async adminListCodes(e,n=50){return nn.get("/xyzen/api/v1/redemption/admin/codes",{auth:!1,headers:{"X-Admin-Secret":e},params:{limit:n}})}async adminCreateCode(e,n){return nn.post("/xyzen/api/v1/redemption/admin/codes",n,{auth:!1,headers:{"X-Admin-Secret":e}})}async adminDeactivateCode(e,n){return nn.post(`/xyzen/api/v1/redemption/admin/codes/${n}/deactivate`,void 0,{auth:!1,headers:{"X-Admin-Secret":e}})}async getConsumptionHeatmap(e,n,r,i,o,l,u){return nn.get("/xyzen/api/v1/redemption/admin/stats/consumption-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,model_tier:i,model_name:o,provider:l,tool_name:u}})}async getUserConsumptionHeatmap(e,n,r,i,o,l,u){return nn.get("/xyzen/api/v1/redemption/admin/stats/user-consumption-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,model_tier:i,model_name:o,provider:l,tool_name:u}})}async getConsumptionTopUsers(e,n,r,i,o,l,u=20,d,p,m,g){return nn.get("/xyzen/api/v1/redemption/admin/stats/consumption-top-users",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,date:i,model_tier:o,model_name:l,limit:u,search:d,provider:p,include_tiers:m||void 0,tool_name:g}})}async getRedemptionHeatmap(e,n,r){return nn.get("/xyzen/api/v1/redemption/admin/stats/redemption-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r}})}async getRedemptionRankings(e,n,r,i,o=20,l){return nn.get("/xyzen/api/v1/redemption/admin/stats/redemption-rankings",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,date:i,limit:o,search:l}})}async getNewUsersHeatmap(e,n,r){return nn.get("/xyzen/api/v1/redemption/admin/stats/new-users-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r}})}async getFilterOptions(e,n,r,i){return nn.get("/xyzen/api/v1/redemption/admin/stats/filter-options",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,provider:i}})}async getModelOptions(e){return nn.get("/xyzen/api/v1/redemption/admin/stats/model-options",{auth:!1,headers:{"X-Admin-Secret":e}})}async getCreditSources(e){return nn.get("/xyzen/api/v1/redemption/admin/stats/credit-sources",{auth:!1,headers:{"X-Admin-Secret":e}})}async getCreditHeatmap(e,n,r,i,o){return nn.get("/xyzen/api/v1/redemption/admin/stats/credit-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,source:i,tier:o}})}async getCreditRankings(e,n,r,i,o,l,u=20,d){return nn.get("/xyzen/api/v1/redemption/admin/stats/credit-rankings",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,source:i,tier:o,date:l,limit:u,search:d}})}}const OA=new i6n,s6n=t=>({walletBalance:null,walletLoading:!1,fetchWallet:async()=>{t({walletLoading:!0});try{const e=await OA.getUserWallet();t({walletBalance:{free:e.free_balance,paid:e.paid_balance,earned:e.earned_balance,total:e.virtual_balance},walletLoading:!1})}catch{t({walletLoading:!1})}},connectWalletEvents:()=>{X5.connect();const e=X5.on("credit_updated",n=>{const r=n.data;t({walletBalance:{free:r.free_balance??0,paid:r.paid_balance??0,earned:r.earned_balance??0,total:r.virtual_balance??0}})});return()=>{e(),X5.disconnect()}},_handleCreditUpdated:e=>{t({walletBalance:{free:e.free_balance??0,paid:e.paid_balance??0,earned:e.earned_balance??0,total:e.virtual_balance??0}})}});let Tke=null;function o6n(t){Tke=t}function az(){if(!Tke)throw new Error("toolbarActions not initialized — call initToolbarActions() at app startup");return Tke()}async function l6n(t,e){try{await az()(t,{model_tier:e,provider_id:null,model:null})}catch(n){console.error("Failed to update session tier:",n)}}async function c6n(t,e,n,r){try{await az()(t,{model_tier:e,provider_id:n,model:r})}catch(i){console.error("Failed to update session tier model:",i)}}async function u6n(t,e,n){try{await az()(t,{model_tier:null,provider_id:e,model:n})}catch(r){console.error("Failed to update custom model:",r)}}async function d6n(t,e){try{await az()(t,{sandbox_backend:e})}catch(n){console.error("Failed to update session sandbox backend:",n)}}async function p6n(t,e){try{await az()(t,{knowledge_set_id:e})}catch(n){console.error("Failed to update session knowledge set:",n)}}qOn(not),nn.configure({getToken:()=>Di.getToken(),onRefreshToken:async()=>(await Di.refreshAccessToken())?.access_token??null,onUnauthorized:()=>{Promise.resolve().then(()=>XOn).then(t=>t.logout()).catch(()=>{})}}),AFn();let m6n;const g6n={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},Un=wFn()(Zst(IFn((...t)=>({...a6n(...t),...j8n(...t),...PFn(...t),...V8n(...t),...K8n(...t),...J8n(...t),...OFn(...t),...H8n(...t),...U8n(...t),...G8n(...t),...Z8n(...t),...n6n(...t),...r6n(...t),...s6n(...t)})),{name:"xyzen-storage",storage:Kst(()=>m6n??(typeof localStorage<"u"?localStorage:g6n)),partialize:t=>({isXyzenOpen:t.isXyzenOpen,panelWidth:t.panelWidth,activePanel:t.activePanel,theme:t.theme,token:t.token,user:t.user,activeChatChannel:t.activeChatChannel,spatialSidebarCollapsed:t.spatialSidebarCollapsed,capsuleOpen:t.capsuleOpen,capsuleActiveTab:t.capsuleActiveTab,mobileCeoOverlay:t.mobileCeoOverlay,mobilePage:t.mobilePage,openTabsByAgent:t.openTabsByAgent,terminalSessions:t.terminalSessions}),onRehydrateStorage:()=>t=>{if(!t)return;const e=t.terminalSessions;if(e)for(const n of Object.keys(e)){const r=e[n];(r.status==="connected"||r.status==="connecting"||r.status==="reconnecting")&&(r.status="detached")}}}));if(ZOn(Un),o6n(()=>Un.getState().updateSessionConfig),typeof window<"u"){const t=new Map;Un.subscribe(e=>{const n=e.activeChatChannel;if(!n)return;const r=e.channels[n];if(!r)return;const i=t.get(n)??0,o=r.messages.length;i>0&&o<i&&console.error(`[DIAGNOSTIC] MESSAGE COUNT DROP: ${n.slice(0,8)} ${i} → ${o}`,`| responding=${r.responding}`,`| latestAssist=${(()=>{const l=[...r.messages].reverse().find(u=>u.role==="assistant");return l?`id=${l.id.slice(0,12)} agentExec=${l.agentExecution?.status}`:"none"})()}`,new Error("trace").stack),t.set(n,o)})}function h6n(t){return Un.getState().status!=="succeeded"&&new URLSearchParams(window.location.search).get("platform")==="bohrium"?(t("provider_bohrium"),!0):!1}async function Bke(){try{const t=await Di.getAuthStatus();if(!t.is_configured||!t.provider)throw new Error("Authentication is not configured");const e=await Di.getAuthConfig(),n=t.provider,r=`${window.location.origin}${window.location.pathname}`;let i=null;if(n==="casdoor"){const o=Math.random().toString(36).substring(7);sessionStorage.setItem("auth_state",o),i=MN(n,e,r,o)}else i=MN(n,e,r);if(i)window.location.href=i;else throw new Error(`Unsupported auth provider: ${n}`)}catch(t){throw console.error("Failed to initiate OAuth login:",t),t}}function f6n(t){const e=Un(M=>M.setBackendUrl),[n,r]=T.useState(!1),[i,o]=T.useState(!1),[l,u]=T.useState(!1),[d,p]=T.useState(),m=T.useRef(!1),g=T.useRef(null);T.useEffect(()=>{e(t),!m.current&&(m.current=!0,Tst().then(()=>{h6n(M=>g.current?.(M))}))},[t,e]);const h=T.useCallback(async M=>{const R=Math.random().toString(36).substring(7);sessionStorage.setItem("auth_state",R);const D=`${window.location.origin}${window.location.pathname}`;let P=null;try{const O=await Di.getOAuthUrl(M,D,R);O.url&&(P=O.url)}catch{}if(!P)try{const O=await Di.getAuthConfig();P=MN("casdoor",O,D,R,M)}catch{}if(P){u(!0);try{const O=await eFn(P);await px(O.access_token,O.user_info,O.refresh_token)}catch(O){const F=O.message;if(F!=="OAuth popup was closed")if(F==="Popup blocked by browser"){window.location.href=P;return}else console.error("Failed to initiate provider login:",O),o(!1),r(!0)}finally{u(!1)}}},[]);g.current=h;const f=T.useCallback(async()=>{try{const[M,R]=await Promise.all([Di.getAuthStatus(),Di.getAuthConfig(),Lst()]),D=R?.provider??M?.provider;if(D==="casdoor"){R?.turnstile_site_key&&p(R.turnstile_site_key),o(!0);return}if(D&&D!=="bohr_app"){const P=MN(D,R,`${window.location.origin}${window.location.pathname}`);if(P){window.location.href=P;return}}}catch{}r(!0)},[]),b=T.useCallback(()=>{Tst()},[]),y=T.useCallback(()=>{o(!1)},[]),v=T.useCallback(async(M,R)=>Di.sendVerificationCode(M,R),[]),_=T.useCallback(async(M,R)=>{await ike(M,R,"email")},[]),w=T.useCallback(async(M,R,D,P)=>{await ske(M,R,D,P)},[]),x=T.useCallback(async(M,R)=>{await kst(M,R)},[]),k=T.useCallback(async M=>{await Di.sendResetCode(M)},[]),C=T.useCallback(async(M,R,D)=>{await Cst(M,R,D)},[]),E=T.useCallback(async M=>Di.sendPhoneVerificationCode(M),[]),S=T.useCallback(async M=>Di.checkPhoneExists(M),[]),I=T.useCallback(async(M,R)=>{await ike(M,R,"phone")},[]),B=T.useCallback(async(M,R)=>{await Est(M,R)},[]),N=T.useCallback(async(M,R,D,P)=>{await ske("",R,D,P,"phone",M)},[]),L=T.useCallback(()=>{r(!1),o(!1)},[]);return{state:{showAuthScreen:n,showLoginPage:i,oauthLoading:l,turnstileSiteKey:d},handlers:{handleRetry:b,handleShowAuthScreen:f,handleSelectProvider:h,handleLoginBack:y,handleSendCode:v,handleCodeLogin:_,handleSignup:w,handlePasswordLogin:x,handleSendResetCode:k,handleResetPassword:C,handleSendPhoneCode:E,handleCheckPhone:S,handlePhoneCodeLogin:I,handlePhonePasswordLogin:B,handlePhoneSignup:N},resetAuthScreens:L}}var zN=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},A6n=class extends zN{#e;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Dke=new A6n,b6n={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},y6n=class{#e=b6n;#t=!1;setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&this.#t&&t!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:t}),this.#e=t,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},UN=new y6n;function v6n(t){setTimeout(t,0)}var _6n=typeof window>"u"||"Deno"in globalThis;function sh(){}function w6n(t,e){return typeof t=="function"?t(e):t}function Nke(t){return typeof t=="number"&&t>=0&&t!==1/0}function wot(t,e){return Math.max(t+(e||0)-Date.now(),0)}function hI(t,e){return typeof t=="function"?t(e):t}function sy(t,e){return typeof t=="function"?t(e):t}function xot(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:o,queryKey:l,stale:u}=t;if(l){if(r){if(e.queryHash!==Rke(l,e.options))return!1}else if(!iz(e.queryKey,l))return!1}if(n!=="all"){const d=e.isActive();if(n==="active"&&!d||n==="inactive"&&d)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||i&&i!==e.state.fetchStatus||o&&!o(e))}function kot(t,e){const{exact:n,status:r,predicate:i,mutationKey:o}=t;if(o){if(!e.options.mutationKey)return!1;if(n){if(qN(e.options.mutationKey)!==qN(o))return!1}else if(!iz(e.options.mutationKey,o))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function Rke(t,e){return(e?.queryKeyHashFn||qN)(t)}function qN(t){return JSON.stringify(t,(e,n)=>Lke(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function iz(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>iz(t[n],e[n])):!1}var x6n=Object.prototype.hasOwnProperty;function Mte(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=Eot(t)&&Eot(e);if(!r&&!(Lke(t)&&Lke(e)))return e;const o=(r?t:Object.keys(t)).length,l=r?e:Object.keys(e),u=l.length,d=r?new Array(u):{};let p=0;for(let m=0;m<u;m++){const g=r?m:l[m],h=t[g],f=e[g];if(h===f){d[g]=h,(r?m<o:x6n.call(t,g))&&p++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){d[g]=f;continue}const b=Mte(h,f,n+1);d[g]=b,b===h&&p++}return o===u&&p===o?t:d}function sz(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function Eot(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Lke(t){if(!Cot(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Cot(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Cot(t){return Object.prototype.toString.call(t)==="[object Object]"}function k6n(t){return new Promise(e=>{UN.setTimeout(e,t)})}function Mke(t,e,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(t,e);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Mte(t,e)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return Mte(t,e)}return e}function E6n(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function C6n(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var Pte=Symbol();function Sot(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===Pte&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===Pte?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Pke(t,e){return typeof t=="function"?t(...e):!!t}function S6n(t,e,n){let r=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??=e(),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),t}var oz=(()=>{let t=()=>_6n;return{isServer(){return t()},setIsServer(e){t=e}}})();function Oke(){let t,e;const n=new Promise((i,o)=>{t=i,e=o});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var I6n=v6n;function T6n(){let t=[],e=0,n=u=>{u()},r=u=>{u()},i=I6n;const o=u=>{e?t.push(u):i(()=>{n(u)})},l=()=>{const u=t;t=[],u.length&&i(()=>{r(()=>{u.forEach(d=>{n(d)})})})};return{batch:u=>{let d;e++;try{d=u()}finally{e--,e||l()}return d},batchCalls:u=>(...d)=>{o(()=>{u(...d)})},schedule:o,setNotifyFunction:u=>{n=u},setBatchNotifyFunction:u=>{r=u},setScheduler:u=>{i=u}}}var od=T6n(),B6n=class extends zN{#e=!0;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},Ote=new B6n;function D6n(t){return Math.min(1e3*2**t,3e4)}function Iot(t){return(t??"online")==="online"?Ote.isOnline():!0}var Fke=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Tot(t){let e=!1,n=0,r;const i=Oke(),o=()=>i.status!=="pending",l=y=>{if(!o()){const v=new Fke(y);h(v),t.onCancel?.(v)}},u=()=>{e=!0},d=()=>{e=!1},p=()=>Dke.isFocused()&&(t.networkMode==="always"||Ote.isOnline())&&t.canRun(),m=()=>Iot(t.networkMode)&&t.canRun(),g=y=>{o()||(r?.(),i.resolve(y))},h=y=>{o()||(r?.(),i.reject(y))},f=()=>new Promise(y=>{r=v=>{(o()||p())&&y(v)},t.onPause?.()}).then(()=>{r=void 0,o()||t.onContinue?.()}),b=()=>{if(o())return;let y;const v=n===0?t.initialPromise:void 0;try{y=v??t.fn()}catch(_){y=Promise.reject(_)}Promise.resolve(y).then(g).catch(_=>{if(o())return;const w=t.retry??(oz.isServer()?0:3),x=t.retryDelay??D6n,k=typeof x=="function"?x(n,_):x,C=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,_);if(e||!C){h(_);return}n++,t.onFail?.(n,_),k6n(k).then(()=>p()?void 0:f()).then(()=>{e?h(_):b()})})};return{promise:i,status:()=>i.status,cancel:l,continue:()=>(r?.(),i),cancelRetry:u,continueRetry:d,canStart:m,start:()=>(m()?b():f().then(b),i)}}var Bot=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Nke(this.gcTime)&&(this.#e=UN.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(oz.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(UN.clearTimeout(this.#e),this.#e=void 0)}},N6n=class extends Bot{#e;#t;#r;#n;#a;#s;#i;constructor(t){super(),this.#i=!1,this.#s=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#n=t.client,this.#r=this.#n.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=Rot(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#a?.promise}setOptions(t){if(this.options={...this.#s,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=Rot(this.options);e.data!==void 0&&(this.setState(Not(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(t,e){const n=Mke(this.state.data,t,this.options);return this.#l({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#l({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#a?.promise;return this.#a?.cancel(t),e?e.then(sh).catch(sh):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>sy(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Pte||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>hI(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!wot(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#a&&(this.#i||this.#o()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#o(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#a?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(t&&this.setOptions(t),!this.options.queryFn){const u=this.observers.find(d=>d.options.queryFn);u&&this.setOptions(u.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,r=u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:()=>(this.#i=!0,n.signal)})},i=()=>{const u=Sot(this.options,e),p=(()=>{const m={client:this.#n,queryKey:this.queryKey,meta:this.meta};return r(m),m})();return this.#i=!1,this.options.persister?this.options.persister(u,p,this):u(p)},l=(()=>{const u={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#n,state:this.state,fetchFn:i};return r(u),u})();this.options.behavior?.onFetch(l,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==l.fetchOptions?.meta)&&this.#l({type:"fetch",meta:l.fetchOptions?.meta}),this.#a=Tot({initialPromise:e?.initialPromise,fn:l.fetchFn,onCancel:u=>{u instanceof Fke&&u.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(u,d)=>{this.#l({type:"failed",failureCount:u,error:d})},onPause:()=>{this.#l({type:"pause"})},onContinue:()=>{this.#l({type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0});try{const u=await this.#a.start();if(u===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(u),this.#r.config.onSuccess?.(u,this),this.#r.config.onSettled?.(u,this.state.error,this),u}catch(u){if(u instanceof Fke){if(u.silent)return this.#a.promise;if(u.revert){if(this.state.data===void 0)throw u;return this.state.data}}throw this.#l({type:"error",error:u}),this.#r.config.onError?.(u,this),this.#r.config.onSettled?.(this.state.data,u,this),u}finally{this.scheduleGc()}}#l(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Dot(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...Not(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),od.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:t})})}};function Dot(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Iot(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Not(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Rot(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,r=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Fte=class extends zN{constructor(t,e){super(),this.options=e,this.#e=t,this.#o=null,this.#i=Oke(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#r=void 0;#n=void 0;#a;#s;#i;#o;#l;#c;#p;#u;#m;#h;#g=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Lot(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Qke(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Qke(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#k(),this.#x(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof sy(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#v(),this.#t.setOptions(this.options),e._defaulted&&!sz(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&Mot(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||sy(this.options.enabled,this.#t)!==sy(e.enabled,this.#t)||hI(this.options.staleTime,this.#t)!==hI(e.staleTime,this.#t))&&this.#f();const i=this.#A();r&&(this.#t!==n||sy(this.options.enabled,this.#t)!==sy(e.enabled,this.#t)||i!==this.#h)&&this.#y(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return L6n(this,n)&&(this.#n=n,this.#s=this.options,this.#a=this.#t.state),n}getCurrentResult(){return this.#n}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#i.status==="pending"&&this.#i.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#g.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#n))}#d(t){this.#v();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(sh)),e}#f(){this.#k();const t=hI(this.options.staleTime,this.#t);if(oz.isServer()||this.#n.isStale||!Nke(t))return;const n=wot(this.#n.dataUpdatedAt,t)+1;this.#u=UN.setTimeout(()=>{this.#n.isStale||this.updateResult()},n)}#A(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#x(),this.#h=t,!(oz.isServer()||sy(this.options.enabled,this.#t)===!1||!Nke(this.#h)||this.#h===0)&&(this.#m=UN.setInterval(()=>{(this.options.refetchIntervalInBackground||Dke.isFocused())&&this.#d()},this.#h))}#b(){this.#f(),this.#y(this.#A())}#k(){this.#u&&(UN.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#m&&(UN.clearInterval(this.#m),this.#m=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#n,o=this.#a,l=this.#s,d=t!==n?t.state:this.#r,{state:p}=t;let m={...p},g=!1,h;if(e._optimisticResults){const I=this.hasListeners(),B=!I&&Lot(t,e),N=I&&Mot(t,n,e,r);(B||N)&&(m={...m,...Dot(p.data,t.options)}),e._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:f,errorUpdatedAt:b,status:y}=m;h=m.data;let v=!1;if(e.placeholderData!==void 0&&h===void 0&&y==="pending"){let I;i?.isPlaceholderData&&e.placeholderData===l?.placeholderData?(I=i.data,v=!0):I=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,I!==void 0&&(y="success",h=Mke(i?.data,I,e),g=!0)}if(e.select&&h!==void 0&&!v)if(i&&h===o?.data&&e.select===this.#l)h=this.#c;else try{this.#l=e.select,h=e.select(h),h=Mke(i?.data,h,e),this.#c=h,this.#o=null}catch(I){this.#o=I}this.#o&&(f=this.#o,h=this.#c,b=Date.now(),y="error");const _=m.fetchStatus==="fetching",w=y==="pending",x=y==="error",k=w&&_,C=h!==void 0,S={status:y,fetchStatus:m.fetchStatus,isPending:w,isSuccess:y==="success",isError:x,isInitialLoading:k,isLoading:k,data:h,dataUpdatedAt:m.dataUpdatedAt,error:f,errorUpdatedAt:b,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>d.dataUpdateCount||m.errorUpdateCount>d.errorUpdateCount,isFetching:_,isRefetching:_&&!w,isLoadingError:x&&!C,isPaused:m.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:x&&C,isStale:$ke(t,e),refetch:this.refetch,promise:this.#i,isEnabled:sy(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=S.data!==void 0,B=S.status==="error"&&!I,N=R=>{B?R.reject(S.error):I&&R.resolve(S.data)},L=()=>{const R=this.#i=S.promise=Oke();N(R)},M=this.#i;switch(M.status){case"pending":t.queryHash===n.queryHash&&N(M);break;case"fulfilled":(B||S.data!==M.value)&&L();break;case"rejected":(!B||S.error!==M.reason)&&L();break}}return S}updateResult(){const t=this.#n,e=this.createResult(this.#t,this.options);if(this.#a=this.#t.state,this.#s=this.options,this.#a.data!==void 0&&(this.#p=this.#t),sz(e,t))return;this.#n=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#g.size)return!0;const o=new Set(i??this.#g);return this.options.throwOnError&&o.add("error"),Object.keys(this.#n).some(l=>{const u=l;return this.#n[u]!==t[u]&&o.has(u)})};this.#C({listeners:n()})}#v(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#C(t){od.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#n)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function R6n(t,e){return sy(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Lot(t,e){return R6n(t,e)||t.state.data!==void 0&&Qke(t,e,e.refetchOnMount)}function Qke(t,e,n){if(sy(e.enabled,t)!==!1&&hI(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&$ke(t,e)}return!1}function Mot(t,e,n,r){return(t!==e||sy(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&$ke(t,n)}function $ke(t,e){return sy(e.enabled,t)!==!1&&t.isStaleByTime(hI(e.staleTime,t))}function L6n(t,e){return!sz(t.getCurrentResult(),e)}function Qte(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,o=e.state.data?.pages||[],l=e.state.data?.pageParams||[];let u={pages:[],pageParams:[]},d=0;const p=async()=>{let m=!1;const g=b=>{S6n(b,()=>e.signal,()=>m=!0)},h=Sot(e.options,e.fetchOptions),f=async(b,y,v)=>{if(m)return Promise.reject();if(y==null&&b.pages.length)return Promise.resolve(b);const w=(()=>{const E={client:e.client,queryKey:e.queryKey,pageParam:y,direction:v?"backward":"forward",meta:e.options.meta};return g(E),E})(),x=await h(w),{maxPages:k}=e.options,C=v?C6n:E6n;return{pages:C(b.pages,x,k),pageParams:C(b.pageParams,y,k)}};if(i&&o.length){const b=i==="backward",y=b?Pot:jke,v={pages:o,pageParams:l},_=y(r,v);u=await f(v,_,b)}else{const b=t??o.length;do{const y=d===0?l[0]??r.initialPageParam:jke(r,u);if(d>0&&y==null)break;u=await f(u,y),d++}while(d<b)}return u};e.options.persister?e.fetchFn=()=>e.options.persister?.(p,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=p}}}function jke(t,{pages:e,pageParams:n}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,n[r],n):void 0}function Pot(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}function M6n(t,e){return e?jke(t,e)!=null:!1}function P6n(t,e){return!e||!t.getPreviousPageParam?!1:Pot(t,e)!=null}var O6n=class extends Fte{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:Qte()})}getOptimisticResult(t){return t.behavior=Qte(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,e){const{state:n}=t,r=super.createResult(t,e),{isFetching:i,isRefetching:o,isError:l,isRefetchError:u}=r,d=n.fetchMeta?.fetchMore?.direction,p=l&&d==="forward",m=i&&d==="forward",g=l&&d==="backward",h=i&&d==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:M6n(e,n.data),hasPreviousPage:P6n(e,n.data),isFetchNextPageError:p,isFetchingNextPage:m,isFetchPreviousPageError:g,isFetchingPreviousPage:h,isRefetchError:u&&!p&&!g,isRefetching:o&&!m&&!h}}},F6n=class extends Bot{#e;#t;#r;#n;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#t=[],this.state=t.state||Oot(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#a({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#n=Tot({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(o,l)=>{this.#a({type:"failed",failureCount:o,error:l})},onPause:()=>{this.#a({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#r.canRun(this)});const r=this.state.status==="pending",i=!this.#n.canStart();try{if(r)e();else{this.#a({type:"pending",variables:t,isPaused:i}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,n);const l=await this.options.onMutate?.(t,n);l!==this.state.context&&this.#a({type:"pending",context:l,variables:t,isPaused:i})}const o=await this.#n.start();return await this.#r.config.onSuccess?.(o,t,this.state.context,this,n),await this.options.onSuccess?.(o,t,this.state.context,n),await this.#r.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,t,this.state.context,n),this.#a({type:"success",data:o}),o}catch(o){try{await this.#r.config.onError?.(o,t,this.state.context,this,n)}catch(l){Promise.reject(l)}try{await this.options.onError?.(o,t,this.state.context,n)}catch(l){Promise.reject(l)}try{await this.#r.config.onSettled?.(void 0,o,this.state.variables,this.state.context,this,n)}catch(l){Promise.reject(l)}try{await this.options.onSettled?.(void 0,o,t,this.state.context,n)}catch(l){Promise.reject(l)}throw this.#a({type:"error",error:o}),o}finally{this.#r.runNext(this)}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),od.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Oot(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Q6n=class extends zN{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(t,e,n){const r=new F6n({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#e.add(t);const e=$te(t);if(typeof e=="string"){const n=this.#t.get(e);n?n.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=$te(t);if(typeof e=="string"){const n=this.#t.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=$te(t);if(typeof e=="string"){const r=this.#t.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=$te(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){od.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>kot(e,n))}findAll(t={}){return this.getAll().filter(e=>kot(t,e))}notify(t){od.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return od.batch(()=>Promise.all(t.map(e=>e.continue().catch(sh))))}};function $te(t){return t.options.scope?.id}var $6n=class extends zN{#e;#t=void 0;#r;#n;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#a()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),sz(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#r,observer:this}),n?.mutationKey&&this.options.mutationKey&&qN(n.mutationKey)!==qN(this.options.mutationKey)?this.reset():this.#r?.state.status==="pending"&&this.#r.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#r?.removeObserver(this)}onMutationUpdate(e){this.#a(),this.#s(e)}getCurrentResult(){return this.#t}reset(){this.#r?.removeObserver(this),this.#r=void 0,this.#a(),this.#s()}mutate(e,n){return this.#n=n,this.#r?.removeObserver(this),this.#r=this.#e.getMutationCache().build(this.#e,this.options),this.#r.addObserver(this),this.#r.execute(e)}#a(){const e=this.#r?.state??Oot();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#s(e){od.batch(()=>{if(this.#n&&this.hasListeners()){const n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#n.onSuccess?.(e.data,n,r,i)}catch(o){Promise.reject(o)}try{this.#n.onSettled?.(e.data,null,n,r,i)}catch(o){Promise.reject(o)}}else if(e?.type==="error"){try{this.#n.onError?.(e.error,n,r,i)}catch(o){Promise.reject(o)}try{this.#n.onSettled?.(void 0,e.error,n,r,i)}catch(o){Promise.reject(o)}}}this.listeners.forEach(n=>{n(this.#t)})})}};function Fot(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function j6n(t,e,n){const r=t.slice(0);return r[e]=n,r}var z6n=class extends zN{#e;#t;#r;#n;#a;#s;#i;#o;#l;#c=[];constructor(t,e,n){super(),this.#e=t,this.#n=n,this.#r=[],this.#a=[],this.#t=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#a.forEach(t=>{t.subscribe(e=>{this.#h(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#a.forEach(t=>{t.destroy()})}setQueries(t,e){if(this.#r=t,this.#n=e,process.env.NODE_ENV!=="production"){const n=t.map(r=>this.#e.defaultQueryOptions(r).queryHash);new Set(n).size!==n.length&&console.warn("[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.")}od.batch(()=>{const n=this.#a,r=this.#m(this.#r);r.forEach(m=>m.observer.setOptions(m.defaultedQueryOptions));const i=r.map(m=>m.observer),o=i.map(m=>m.getCurrentResult()),l=n.length!==i.length,u=i.some((m,g)=>m!==n[g]),d=l||u,p=d?!0:o.some((m,g)=>{const h=this.#t[g];return!h||!sz(m,h)});!d&&!p||(d&&(this.#c=r,this.#a=i),this.#t=o,this.hasListeners()&&(d&&(Fot(n,i).forEach(m=>{m.destroy()}),Fot(i,n).forEach(m=>{m.subscribe(g=>{this.#h(m,g)})})),this.#g()))})}getCurrentResult(){return this.#t}getQueries(){return this.#a.map(t=>t.getCurrentQuery())}getObservers(){return this.#a}getOptimisticResult(t,e){const n=this.#m(t),r=n.map(o=>o.observer.getOptimisticResult(o.defaultedQueryOptions)),i=n.map(o=>o.defaultedQueryOptions.queryHash);return[r,o=>this.#u(o??r,e,i),()=>this.#p(r,n)]}#p(t,e){return e.map((n,r)=>{const i=t[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,o=>{e.forEach(l=>{l.observer.trackProp(o)})})})}#u(t,e,n){if(e){const r=this.#l,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((o,l)=>o!==r[l]));return(!this.#s||this.#t!==this.#o||i||e!==this.#i)&&(this.#i=e,this.#o=this.#t,n!==void 0&&(this.#l=n),this.#s=Mte(this.#s,e(t))),this.#s}return t}#m(t){const e=new Map;this.#a.forEach(r=>{const i=r.options.queryHash;if(!i)return;const o=e.get(i);o?o.push(r):e.set(i,[r])});const n=[];return t.forEach(r=>{const i=this.#e.defaultQueryOptions(r),l=e.get(i.queryHash)?.shift()??new Fte(this.#e,i);n.push({defaultedQueryOptions:i,observer:l})}),n}#h(t,e){const n=this.#a.indexOf(t);n!==-1&&(this.#t=j6n(this.#t,n,e),this.#g())}#g(){if(this.hasListeners()){const t=this.#s,e=this.#p(this.#t,this.#c),n=this.#u(e,this.#n?.combine);t!==n&&od.batch(()=>{this.listeners.forEach(r=>{r(this.#t)})})}}},U6n=class extends zN{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??Rke(r,e);let o=this.get(i);return o||(o=new N6n({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){od.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>xot(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>xot(t,n)):e}notify(t){od.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){od.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){od.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},q6n=class{#e;#t;#r;#n;#a;#s;#i;#o;constructor(t={}){this.#e=t.queryCache||new U6n,this.#t=t.mutationCache||new Q6n,this.#r=t.defaultOptions||{},this.#n=new Map,this.#a=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#i=Dke.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#o=Ote.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#i?.(),this.#i=void 0,this.#o?.(),this.#o=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(hI(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),o=this.#e.get(r.queryHash)?.state.data,l=w6n(e,o);if(l!==void 0)return this.#e.build(this,r).setData(l,{...n,manual:!0})}setQueriesData(t,e,n){return od.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;od.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return od.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=od.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(sh).catch(sh)}invalidateQueries(t,e={}){return od.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=od.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let o=i.fetch(void 0,n);return n.throwOnError||(o=o.catch(sh)),i.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(sh)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(hI(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(sh).catch(sh)}fetchInfiniteQuery(t){return t.behavior=Qte(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(sh).catch(sh)}ensureInfiniteQueryData(t){return t.behavior=Qte(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Ote.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#n.set(qN(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#n.values()],n={};return e.forEach(r=>{iz(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#a.set(qN(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#a.values()],n={};return e.forEach(r=>{iz(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#r.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Rke(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Pte&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Qot=ee.createContext(void 0),Ol=t=>{const e=ee.useContext(Qot);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},J5=({client:t,children:e})=>(ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),A.jsx(Qot.Provider,{value:t,children:e})),$ot=ee.createContext(!1),jot=()=>ee.useContext($ot);$ot.Provider;function G6n(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var H6n=ee.createContext(G6n()),zot=()=>ee.useContext(H6n),Uot=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?Pke(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},qot=t=>{ee.useEffect(()=>{t.clearReset()},[t])},Got=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||Pke(n,[t.error,r])),Hot=t=>{if(t.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},W6n=(t,e)=>t.isLoading&&t.isFetching&&!e,zke=(t,e)=>t?.suspense&&e.isPending,Uke=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Y6n({queries:t,...e},n){const r=Ol(),i=jot(),o=zot(),l=ee.useMemo(()=>t.map(y=>{const v=r.defaultQueryOptions(y);return v._optimisticResults=i?"isRestoring":"optimistic",v}),[t,r,i]);l.forEach(y=>{Hot(y);const v=r.getQueryCache().get(y.queryHash);Uot(y,o,v)}),qot(o);const[u]=ee.useState(()=>new z6n(r,l,e)),[d,p,m]=u.getOptimisticResult(l,e.combine),g=!i&&e.subscribed!==!1;ee.useSyncExternalStore(ee.useCallback(y=>g?u.subscribe(od.batchCalls(y)):sh,[u,g]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),ee.useEffect(()=>{u.setQueries(l,e)},[l,e,u]);const f=d.some((y,v)=>zke(l[v],y))?d.flatMap((y,v)=>{const _=l[v];if(_&&zke(_,y)){const w=new Fte(r,_);return Uke(_,w,o)}return[]}):[];if(f.length>0)throw Promise.all(f);const b=d.find((y,v)=>{const _=l[v];return _&&Got({result:y,errorResetBoundary:o,throwOnError:_.throwOnError,query:r.getQueryCache().get(_.queryHash),suspense:_.suspense})});if(b?.error)throw b.error;return p(m())}function Wot(t,e,n){if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=jot(),i=zot(),o=Ol(),l=o.defaultQueryOptions(t);o.getDefaultOptions().queries?._experimental_beforeQuery?.(l);const u=o.getQueryCache().get(l.queryHash);process.env.NODE_ENV!=="production"&&(l.queryFn||console.error(`[${l.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),l._optimisticResults=r?"isRestoring":"optimistic",Hot(l),Uot(l,i,u),qot(i);const d=!o.getQueryCache().get(l.queryHash),[p]=ee.useState(()=>new e(o,l)),m=p.getOptimisticResult(l),g=!r&&t.subscribed!==!1;if(ee.useSyncExternalStore(ee.useCallback(h=>{const f=g?p.subscribe(od.batchCalls(h)):sh;return p.updateResult(),f},[p,g]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),ee.useEffect(()=>{p.setOptions(l)},[l,p]),zke(l,m))throw Uke(l,p,i);if(Got({result:m,errorResetBoundary:i,throwOnError:l.throwOnError,query:u,suspense:l.suspense}))throw m.error;return o.getDefaultOptions().queries?._experimental_afterQuery?.(l,m),l.experimental_prefetchInRender&&!oz.isServer()&&W6n(m,r)&&(d?Uke(l,p,i):u?.promise)?.catch(sh).finally(()=>{p.updateResult()}),l.notifyOnChangeProps?m:p.trackResult(m)}function Js(t,e){return Wot(t,Fte)}function fg(t,e){const n=Ol(),[r]=ee.useState(()=>new $6n(n,t));ee.useEffect(()=>{r.setOptions(t)},[r,t]);const i=ee.useSyncExternalStore(ee.useCallback(l=>r.subscribe(od.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=ee.useCallback((l,u)=>{r.mutate(l,u).catch(sh)},[r]);if(i.error&&Pke(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}function Yot(t,e){return Wot(t,O6n)}class V6n{async getActiveCampaigns(){return nn.get("/xyzen/api/v1/gifts/active")}async claimGift(e){return nn.post(`/xyzen/api/v1/gifts/${e}/claim`)}}const Vot=new V6n,eP=not.env.backendUrl;typeof localStorage<"u"&&localStorage.getItem("layoutStyle")&&localStorage.getItem("layoutStyle");function _l(){return typeof window<"u"&&"__TAURI__"in window}const qke="xyzen.desktop.runner",Kot="xyzen.desktop.prevent_sleep",Gke="xyzen:desktop-prevent-sleep-changed",jte="Desktop Runner";async function GN(t,e){const{invoke:n}=await Promise.resolve().then(()=>vJn);return n(t,e)}async function zte(t,e,n){return GN("runner_start",{token:t,url:e,workDir:n})}async function K6n(){return GN("runner_stop")}async function Hke(){return GN("runner_status")}async function Wke(){return _l()?GN("desktop_computer_use_status"):{supported:!1,platform:"browser",screen_capture_permission:"unsupported",accessibility_permission:"unsupported",reason:null}}function Zot(t){if(!t)return null;const e=t.screen_capture_permission==="denied",n=t.accessibility_permission==="denied";return e&&n?"both":e?"screen_capture":n?"accessibility":null}async function Xot(t){if(_l())return GN("desktop_open_url",{url:t})}function Z6n(){return Xot("x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture")}function X6n(){return Xot("x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")}async function Jot(){return _l()?GN("desktop_sleep_prevention_status"):{enabled:!1,supported:!1}}async function Yke(t){return _l()?GN("desktop_sleep_prevention_set_enabled",{enabled:t}):{enabled:!1,supported:!1}}function Ute(){const e=sd().env.backendUrl||`${window.location.protocol}//${window.location.host}`,n=new URL(e);return`${n.protocol==="https:"?"wss:":"ws:"}//${n.host}/xyzen/ws/v1/runner`}function qte(){if(typeof window>"u")return null;const t=window.localStorage.getItem(qke);if(!t)return null;try{const e=JSON.parse(t);if(typeof e.runnerId=="string"&&typeof e.token=="string"&&typeof e.name=="string")return{runnerId:e.runnerId,token:e.token,name:e.name}}catch{}return null}function elt(t){typeof window>"u"||window.localStorage.setItem(qke,JSON.stringify(t))}function lz(){typeof window>"u"||window.localStorage.removeItem(qke)}function cz(){return typeof window>"u"?!1:window.localStorage.getItem(Kot)==="true"}function tlt(t){typeof window>"u"||(window.localStorage.setItem(Kot,t?"true":"false"),window.dispatchEvent(new CustomEvent(Gke,{detail:{enabled:t}})))}function nlt(t){if(typeof window>"u")return()=>{};const e=n=>{t(n.detail.enabled)};return window.addEventListener(Gke,e),()=>{window.removeEventListener(Gke,e)}}const rlt=38,J6n=88,e9n=16;function t9n(){const[t,e]=T.useState(!1);return T.useEffect(()=>{if(!_l())return;let n=!1;const r=async()=>{try{const{getCurrentWindow:o}=await Promise.resolve().then(()=>BJn),l=o(),u=await l.isFullscreen();return n||e(u),await l.onResized(async()=>{const p=await l.isFullscreen();n||e(p)})}catch{return}};let i;return r().then(o=>{n?o?.():i=o}),()=>{n=!0,i?.()}},[]),t}function n9n(){const e=t9n()?e9n:J6n;return A.jsxs("div",{"data-tauri-drag-region":!0,className:"fixed top-0 left-0 right-0 z-[100] flex items-center select-none",style:{height:rlt},children:[A.jsx("div",{"data-tauri-drag-region":!0,className:"shrink-0 flex items-center",style:{paddingLeft:e},children:A.jsx("img",{src:"/icon.png",alt:"",className:"h-4 w-4 rounded-sm",draggable:!1})}),A.jsx("div",{"data-tauri-drag-region":!0,className:"flex-1"})]})}const r9n=Object.freeze({billing:!1,admin:!1,checkIn:!1,subscription:!1,developerReward:!1}),a9n=Object.freeze({billing:!0,admin:!0,checkIn:!0,subscription:!0,developerReward:!0}),Vke=Object.freeze({edition:"ce",isEE:!1,features:r9n}),i9n=Object.freeze({edition:"ee",isEE:!0,features:a9n});let tP=Vke,alt=!1;async function s9n(){if(alt)return tP;try{const[t,e]=await Promise.all([vte.getEdition(),vte.getFeatures().catch(()=>null)]),n=t.edition==="ee"?i9n:Vke;if(e){const r={...n.features,developerReward:n.features.developerReward&&e.developer_reward};tP=Object.freeze({...n,features:Object.freeze(r)})}else tP=n}catch{tP=Vke}return alt=!0,tP}function FA(t){return tP.features[t]}const Gte=()=>{const[t,e]=T.useState("system"),n=Un(l=>l.setTheme),r=T.useCallback(l=>{const u=window.document.documentElement,d=l==="dark"||l==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches,p=document.createElement("style");p.innerHTML="*, *::before, *::after { transition: none !important; }",document.head.appendChild(p),u.classList.toggle("dark",d),localStorage.setItem("theme",l);const m=d?"#000000":"#ffffff";document.querySelectorAll('meta[name="theme-color"]').forEach(g=>{g.content=m}),setTimeout(()=>{document.head.contains(p)&&document.head.removeChild(p)},50)},[]);return T.useEffect(()=>{const u=localStorage.getItem("theme")||"system";e(u),r(u)},[r]),T.useEffect(()=>{const l=window.matchMedia("(prefers-color-scheme: dark)"),u=()=>{t==="system"&&r("system")};return l.addEventListener("change",u),()=>l.removeEventListener("change",u)},[t,r]),{theme:t,cycleTheme:()=>{const l=["light","dark","system"],u=l.indexOf(t),d=l[(u+1)%l.length];e(d),r(d)},setTheme:l=>{e(l),r(l),n(l)}}};function o9n(t){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}const l9n=t=>{switch(t){case"success":return d9n;case"info":return m9n;case"warning":return p9n;case"error":return g9n;default:return null}},c9n=Array(12).fill(0),u9n=({visible:t,className:e})=>T.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},T.createElement("div",{className:"sonner-spinner"},c9n.map((n,r)=>T.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),d9n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),p9n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),m9n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),g9n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),h9n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},T.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),T.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),f9n=()=>{const[t,e]=T.useState(document.hidden);return T.useEffect(()=>{const n=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t};let Kke=1;class A9n{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const n=this.subscribers.indexOf(e);this.subscribers.splice(n,1)}),this.publish=e=>{this.subscribers.forEach(n=>n(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var n;const{message:r,...i}=e,o=typeof e?.id=="number"||((n=e.id)==null?void 0:n.length)>0?e.id:Kke++,l=this.toasts.find(d=>d.id===o),u=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),l?this.toasts=this.toasts.map(d=>d.id===o?(this.publish({...d,...e,id:o,title:r}),{...d,...e,id:o,dismissible:u,title:r}):d):this.addToast({title:r,...i,dismissible:u,id:o}),o},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:e,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),e),this.message=(e,n)=>this.create({...n,message:e}),this.error=(e,n)=>this.create({...n,message:e,type:"error"}),this.success=(e,n)=>this.create({...n,type:"success",message:e}),this.info=(e,n)=>this.create({...n,type:"info",message:e}),this.warning=(e,n)=>this.create({...n,type:"warning",message:e}),this.loading=(e,n)=>this.create({...n,type:"loading",message:e}),this.promise=(e,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:e,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const i=Promise.resolve(e instanceof Function?e():e);let o=r!==void 0,l;const u=i.then(async p=>{if(l=["resolve",p],T.isValidElement(p))o=!1,this.create({id:r,type:"default",message:p});else if(y9n(p)&&!p.ok){o=!1;const g=typeof n.error=="function"?await n.error(`HTTP error! status: ${p.status}`):n.error,h=typeof n.description=="function"?await n.description(`HTTP error! status: ${p.status}`):n.description,b=typeof g=="object"&&!T.isValidElement(g)?g:{message:g};this.create({id:r,type:"error",description:h,...b})}else if(p instanceof Error){o=!1;const g=typeof n.error=="function"?await n.error(p):n.error,h=typeof n.description=="function"?await n.description(p):n.description,b=typeof g=="object"&&!T.isValidElement(g)?g:{message:g};this.create({id:r,type:"error",description:h,...b})}else if(n.success!==void 0){o=!1;const g=typeof n.success=="function"?await n.success(p):n.success,h=typeof n.description=="function"?await n.description(p):n.description,b=typeof g=="object"&&!T.isValidElement(g)?g:{message:g};this.create({id:r,type:"success",description:h,...b})}}).catch(async p=>{if(l=["reject",p],n.error!==void 0){o=!1;const m=typeof n.error=="function"?await n.error(p):n.error,g=typeof n.description=="function"?await n.description(p):n.description,f=typeof m=="object"&&!T.isValidElement(m)?m:{message:m};this.create({id:r,type:"error",description:g,...f})}}).finally(()=>{o&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),d=()=>new Promise((p,m)=>u.then(()=>l[0]==="reject"?m(l[1]):p(l[1])).catch(m));return typeof r!="string"&&typeof r!="number"?{unwrap:d}:Object.assign(r,{unwrap:d})},this.custom=(e,n)=>{const r=n?.id||Kke++;return this.create({jsx:e(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const QA=new A9n,b9n=(t,e)=>{const n=e?.id||Kke++;return QA.addToast({title:t,...e,id:n}),n},y9n=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",v9n=b9n,_9n=()=>QA.toasts,w9n=()=>QA.getActiveToasts(),Rr=Object.assign(v9n,{success:QA.success,info:QA.info,warning:QA.warning,error:QA.error,custom:QA.custom,message:QA.message,promise:QA.promise,dismiss:QA.dismiss,loading:QA.loading},{getHistory:_9n,getToasts:w9n});o9n("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Hte(t){return t.label!==void 0}const x9n=3,k9n="24px",E9n="16px",ilt=4e3,C9n=356,S9n=14,I9n=45,T9n=200;function fx(...t){return t.filter(Boolean).join(" ")}function B9n(t){const[e,n]=t.split("-"),r=[];return e&&r.push(e),n&&r.push(n),r}const D9n=t=>{var e,n,r,i,o,l,u,d,p;const{invert:m,toast:g,unstyled:h,interacting:f,setHeights:b,visibleToasts:y,heights:v,index:_,toasts:w,expanded:x,removeToast:k,defaultRichColors:C,closeButton:E,style:S,cancelButtonStyle:I,actionButtonStyle:B,className:N="",descriptionClassName:L="",duration:M,position:R,gap:D,expandByDefault:P,classNames:O,icons:F,closeButtonAriaLabel:$="Close toast"}=t,[j,Q]=T.useState(null),[z,U]=T.useState(null),[H,te]=T.useState(!1),[V,ae]=T.useState(!1),[ie,Z]=T.useState(!1),[W,q]=T.useState(!1),[Y,X]=T.useState(!1),[ne,ce]=T.useState(0),[oe,ue]=T.useState(0),me=T.useRef(g.duration||M||ilt),fe=T.useRef(null),Be=T.useRef(null),He=_===0,Le=_+1<=y,et=g.type,mt=g.dismissible!==!1,yt=g.className||"",wt=g.descriptionClassName||"",$e=T.useMemo(()=>v.findIndex(Ae=>Ae.toastId===g.id)||0,[v,g.id]),st=T.useMemo(()=>{var Ae;return(Ae=g.closeButton)!=null?Ae:E},[g.closeButton,E]),Ce=T.useMemo(()=>g.duration||M||ilt,[g.duration,M]),tt=T.useRef(0),Rt=T.useRef(0),pe=T.useRef(0),Xe=T.useRef(null),[se,Re]=R.split("-"),ye=T.useMemo(()=>v.reduce((Ae,xe,pt)=>pt>=$e?Ae:Ae+xe.height,0),[v,$e]),Qe=f9n(),we=g.invert||m,ot=et==="loading";Rt.current=T.useMemo(()=>$e*D+ye,[$e,ye]),T.useEffect(()=>{me.current=Ce},[Ce]),T.useEffect(()=>{te(!0)},[]),T.useEffect(()=>{const Ae=Be.current;if(Ae){const xe=Ae.getBoundingClientRect().height;return ue(xe),b(pt=>[{toastId:g.id,height:xe,position:g.position},...pt]),()=>b(pt=>pt.filter(nt=>nt.toastId!==g.id))}},[b,g.id]),T.useLayoutEffect(()=>{if(!H)return;const Ae=Be.current,xe=Ae.style.height;Ae.style.height="auto";const pt=Ae.getBoundingClientRect().height;Ae.style.height=xe,ue(pt),b(nt=>nt.find(sn=>sn.toastId===g.id)?nt.map(sn=>sn.toastId===g.id?{...sn,height:pt}:sn):[{toastId:g.id,height:pt,position:g.position},...nt])},[H,g.title,g.description,b,g.id,g.jsx,g.action,g.cancel]);const vt=T.useCallback(()=>{ae(!0),ce(Rt.current),b(Ae=>Ae.filter(xe=>xe.toastId!==g.id)),setTimeout(()=>{k(g)},T9n)},[g,k,b,Rt]);T.useEffect(()=>{if(g.promise&&et==="loading"||g.duration===1/0||g.type==="loading")return;let Ae;return x||f||Qe?(()=>{if(pe.current<tt.current){const nt=new Date().getTime()-tt.current;me.current=me.current-nt}pe.current=new Date().getTime()})():me.current!==1/0&&(tt.current=new Date().getTime(),Ae=setTimeout(()=>{g.onAutoClose==null||g.onAutoClose.call(g,g),vt()},me.current)),()=>clearTimeout(Ae)},[x,f,g,et,Qe,vt]),T.useEffect(()=>{g.delete&&(vt(),g.onDismiss==null||g.onDismiss.call(g,g))},[vt,g.delete]);function de(){var Ae;if(F?.loading){var xe;return T.createElement("div",{className:fx(O?.loader,g==null||(xe=g.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":et==="loading"},F.loading)}return T.createElement(u9n,{className:fx(O?.loader,g==null||(Ae=g.classNames)==null?void 0:Ae.loader),visible:et==="loading"})}const rt=g.icon||F?.[et]||l9n(et);var lt,Ne;return T.createElement("li",{tabIndex:0,ref:Be,className:fx(N,yt,O?.toast,g==null||(e=g.classNames)==null?void 0:e.toast,O?.default,O?.[et],g==null||(n=g.classNames)==null?void 0:n[et]),"data-sonner-toast":"","data-rich-colors":(lt=g.richColors)!=null?lt:C,"data-styled":!(g.jsx||g.unstyled||h),"data-mounted":H,"data-promise":!!g.promise,"data-swiped":Y,"data-removed":V,"data-visible":Le,"data-y-position":se,"data-x-position":Re,"data-index":_,"data-front":He,"data-swiping":ie,"data-dismissible":mt,"data-type":et,"data-invert":we,"data-swipe-out":W,"data-swipe-direction":z,"data-expanded":!!(x||P&&H),"data-testid":g.testId,style:{"--index":_,"--toasts-before":_,"--z-index":w.length-_,"--offset":`${V?ne:Rt.current}px`,"--initial-height":P?"auto":`${oe}px`,...S,...g.style},onDragEnd:()=>{Z(!1),Q(null),Xe.current=null},onPointerDown:Ae=>{Ae.button!==2&&(ot||!mt||(fe.current=new Date,ce(Rt.current),Ae.target.setPointerCapture(Ae.pointerId),Ae.target.tagName!=="BUTTON"&&(Z(!0),Xe.current={x:Ae.clientX,y:Ae.clientY})))},onPointerUp:()=>{var Ae,xe,pt;if(W||!mt)return;Xe.current=null;const nt=Number(((Ae=Be.current)==null?void 0:Ae.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Vt=Number(((xe=Be.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),sn=new Date().getTime()-((pt=fe.current)==null?void 0:pt.getTime()),rn=j==="x"?nt:Vt,Xt=Math.abs(rn)/sn;if(Math.abs(rn)>=I9n||Xt>.11){ce(Rt.current),g.onDismiss==null||g.onDismiss.call(g,g),U(j==="x"?nt>0?"right":"left":Vt>0?"down":"up"),vt(),q(!0);return}else{var Lt,Dt;(Lt=Be.current)==null||Lt.style.setProperty("--swipe-amount-x","0px"),(Dt=Be.current)==null||Dt.style.setProperty("--swipe-amount-y","0px")}X(!1),Z(!1),Q(null)},onPointerMove:Ae=>{var xe,pt,nt;if(!Xe.current||!mt||((xe=window.getSelection())==null?void 0:xe.toString().length)>0)return;const sn=Ae.clientY-Xe.current.y,rn=Ae.clientX-Xe.current.x;var Xt;const Lt=(Xt=t.swipeDirections)!=null?Xt:B9n(R);!j&&(Math.abs(rn)>1||Math.abs(sn)>1)&&Q(Math.abs(rn)>Math.abs(sn)?"x":"y");let Dt={x:0,y:0};const at=mn=>1/(1.5+Math.abs(mn)/20);if(j==="y"){if(Lt.includes("top")||Lt.includes("bottom"))if(Lt.includes("top")&&sn<0||Lt.includes("bottom")&&sn>0)Dt.y=sn;else{const mn=sn*at(sn);Dt.y=Math.abs(mn)<Math.abs(sn)?mn:sn}}else if(j==="x"&&(Lt.includes("left")||Lt.includes("right")))if(Lt.includes("left")&&rn<0||Lt.includes("right")&&rn>0)Dt.x=rn;else{const mn=rn*at(rn);Dt.x=Math.abs(mn)<Math.abs(rn)?mn:rn}(Math.abs(Dt.x)>0||Math.abs(Dt.y)>0)&&X(!0),(pt=Be.current)==null||pt.style.setProperty("--swipe-amount-x",`${Dt.x}px`),(nt=Be.current)==null||nt.style.setProperty("--swipe-amount-y",`${Dt.y}px`)}},st&&!g.jsx&&et!=="loading"?T.createElement("button",{"aria-label":$,"data-disabled":ot,"data-close-button":!0,onClick:ot||!mt?()=>{}:()=>{vt(),g.onDismiss==null||g.onDismiss.call(g,g)},className:fx(O?.closeButton,g==null||(r=g.classNames)==null?void 0:r.closeButton)},(Ne=F?.close)!=null?Ne:h9n):null,(et||g.icon||g.promise)&&g.icon!==null&&(F?.[et]!==null||g.icon)?T.createElement("div",{"data-icon":"",className:fx(O?.icon,g==null||(i=g.classNames)==null?void 0:i.icon)},g.promise||g.type==="loading"&&!g.icon?g.icon||de():null,g.type!=="loading"?rt:null):null,T.createElement("div",{"data-content":"",className:fx(O?.content,g==null||(o=g.classNames)==null?void 0:o.content)},T.createElement("div",{"data-title":"",className:fx(O?.title,g==null||(l=g.classNames)==null?void 0:l.title)},g.jsx?g.jsx:typeof g.title=="function"?g.title():g.title),g.description?T.createElement("div",{"data-description":"",className:fx(L,wt,O?.description,g==null||(u=g.classNames)==null?void 0:u.description)},typeof g.description=="function"?g.description():g.description):null),T.isValidElement(g.cancel)?g.cancel:g.cancel&&Hte(g.cancel)?T.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||I,onClick:Ae=>{Hte(g.cancel)&&mt&&(g.cancel.onClick==null||g.cancel.onClick.call(g.cancel,Ae),vt())},className:fx(O?.cancelButton,g==null||(d=g.classNames)==null?void 0:d.cancelButton)},g.cancel.label):null,T.isValidElement(g.action)?g.action:g.action&&Hte(g.action)?T.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||B,onClick:Ae=>{Hte(g.action)&&(g.action.onClick==null||g.action.onClick.call(g.action,Ae),!Ae.defaultPrevented&&vt())},className:fx(O?.actionButton,g==null||(p=g.classNames)==null?void 0:p.actionButton)},g.action.label):null)};function slt(){if(typeof window>"u"||typeof document>"u")return"ltr";const t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function N9n(t,e){const n={};return[t,e].forEach((r,i)=>{const o=i===1,l=o?"--mobile-offset":"--offset",u=o?E9n:k9n;function d(p){["top","right","bottom","left"].forEach(m=>{n[`${l}-${m}`]=typeof p=="number"?`${p}px`:p})}typeof r=="number"||typeof r=="string"?d(r):typeof r=="object"?["top","right","bottom","left"].forEach(p=>{r[p]===void 0?n[`${l}-${p}`]=u:n[`${l}-${p}`]=typeof r[p]=="number"?`${r[p]}px`:r[p]}):d(u)}),n}const R9n=T.forwardRef(function(e,n){const{id:r,invert:i,position:o="bottom-right",hotkey:l=["altKey","KeyT"],expand:u,closeButton:d,className:p,offset:m,mobileOffset:g,theme:h="light",richColors:f,duration:b,style:y,visibleToasts:v=x9n,toastOptions:_,dir:w=slt(),gap:x=S9n,icons:k,containerAriaLabel:C="Notifications"}=e,[E,S]=T.useState([]),I=T.useMemo(()=>r?E.filter(H=>H.toasterId===r):E.filter(H=>!H.toasterId),[E,r]),B=T.useMemo(()=>Array.from(new Set([o].concat(I.filter(H=>H.position).map(H=>H.position)))),[I,o]),[N,L]=T.useState([]),[M,R]=T.useState(!1),[D,P]=T.useState(!1),[O,F]=T.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),$=T.useRef(null),j=l.join("+").replace(/Key/g,"").replace(/Digit/g,""),Q=T.useRef(null),z=T.useRef(!1),U=T.useCallback(H=>{S(te=>{var V;return(V=te.find(ae=>ae.id===H.id))!=null&&V.delete||QA.dismiss(H.id),te.filter(({id:ae})=>ae!==H.id)})},[]);return T.useEffect(()=>QA.subscribe(H=>{if(H.dismiss){requestAnimationFrame(()=>{S(te=>te.map(V=>V.id===H.id?{...V,delete:!0}:V))});return}setTimeout(()=>{Qi.flushSync(()=>{S(te=>{const V=te.findIndex(ae=>ae.id===H.id);return V!==-1?[...te.slice(0,V),{...te[V],...H},...te.slice(V+1)]:[H,...te]})})})}),[E]),T.useEffect(()=>{if(h!=="system"){F(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?F("dark"):F("light")),typeof window>"u")return;const H=window.matchMedia("(prefers-color-scheme: dark)");try{H.addEventListener("change",({matches:te})=>{F(te?"dark":"light")})}catch{H.addListener(({matches:V})=>{try{F(V?"dark":"light")}catch(ae){console.error(ae)}})}},[h]),T.useEffect(()=>{E.length<=1&&R(!1)},[E]),T.useEffect(()=>{const H=te=>{var V;if(l.every(Z=>te[Z]||te.code===Z)){var ie;R(!0),(ie=$.current)==null||ie.focus()}te.code==="Escape"&&(document.activeElement===$.current||(V=$.current)!=null&&V.contains(document.activeElement))&&R(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[l]),T.useEffect(()=>{if($.current)return()=>{Q.current&&(Q.current.focus({preventScroll:!0}),Q.current=null,z.current=!1)}},[$.current]),T.createElement("section",{ref:n,"aria-label":`${C} ${j}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},B.map((H,te)=>{var V;const[ae,ie]=H.split("-");return I.length?T.createElement("ol",{key:H,dir:w==="auto"?slt():w,tabIndex:-1,ref:$,className:p,"data-sonner-toaster":!0,"data-sonner-theme":O,"data-y-position":ae,"data-x-position":ie,style:{"--front-toast-height":`${((V=N[0])==null?void 0:V.height)||0}px`,"--width":`${C9n}px`,"--gap":`${x}px`,...y,...N9n(m,g)},onBlur:Z=>{z.current&&!Z.currentTarget.contains(Z.relatedTarget)&&(z.current=!1,Q.current&&(Q.current.focus({preventScroll:!0}),Q.current=null))},onFocus:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||z.current||(z.current=!0,Q.current=Z.relatedTarget)},onMouseEnter:()=>R(!0),onMouseMove:()=>R(!0),onMouseLeave:()=>{D||R(!1)},onDragEnd:()=>R(!1),onPointerDown:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||P(!0)},onPointerUp:()=>P(!1)},I.filter(Z=>!Z.position&&te===0||Z.position===H).map((Z,W)=>{var q,Y;return T.createElement(D9n,{key:Z.id,icons:k,index:W,toast:Z,defaultRichColors:f,duration:(q=_?.duration)!=null?q:b,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:i,visibleToasts:v,closeButton:(Y=_?.closeButton)!=null?Y:d,interacting:D,position:H,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:U,toasts:I.filter(X=>X.position==Z.position),heights:N.filter(X=>X.position==Z.position),setHeights:L,expandByDefault:u,gap:x,expanded:M,swipeDirections:e.swipeDirections})})):null}))});function L9n(){return{needRefresh:[!1,()=>{}],offlineReady:[!1,()=>{}],updateServiceWorker:async()=>{}}}const olt=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const M9n=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const P9n=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const llt=t=>{const e=P9n(t);return e.charAt(0).toUpperCase()+e.slice(1)};var O9n={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const F9n=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Q9n=T.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:o,iconNode:l,...u},d)=>T.createElement("svg",{ref:d,...O9n,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:olt("lucide",i),...!o&&!F9n(u)&&{"aria-hidden":"true"},...u},[...l.map(([p,m])=>T.createElement(p,m)),...Array.isArray(o)?o:[o]]));const Wr=(t,e)=>{const n=T.forwardRef(({className:r,...i},o)=>T.createElement(Q9n,{ref:o,iconNode:e,className:olt(`lucide-${M9n(llt(t))}`,`lucide-${t}`,r),...i}));return n.displayName=llt(t),n};const Zke=Wr("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);const $9n=Wr("arrow-left-right",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);const Ax=Wr("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const nP=Wr("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const clt=Wr("audio-lines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);const j9n=Wr("bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);const z9n=Wr("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);const rP=Wr("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);const U9n=Wr("braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const Wte=Wr("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]);const q9n=Wr("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);const oh=Wr("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const yf=Wr("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Xke=Wr("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const fI=Wr("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Yte=Wr("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const G9n=Wr("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const ult=Wr("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);const H9n=Wr("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const W9n=Wr("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Y9n=Wr("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);const V9n=Wr("cloud-off",[["path",{d:"M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057",key:"1uxyv8"}],["path",{d:"M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78",key:"99tcn7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const Jke=Wr("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const dlt=Wr("coins",[["path",{d:"M13.744 17.736a6 6 0 1 1-7.48-7.48",key:"bq4yh3"}],["path",{d:"M15 6h1v4",key:"11y1tn"}],["path",{d:"m6.134 14.768.866-.5 2 3.464",key:"17snzx"}],["circle",{cx:"16",cy:"8",r:"6",key:"14bfc9"}]]);const K9n=Wr("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const Z9n=Wr("compass",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]);const eEe=Wr("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const X9n=Wr("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);const tEe=Wr("credit-card",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);const R1=Wr("crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);const L1=Wr("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const plt=Wr("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const mlt=Wr("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const glt=Wr("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const J9n=Wr("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]);const eQn=Wr("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const nEe=Wr("file-up",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);const hlt=Wr("film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);const flt=Wr("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const rEe=Wr("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const Vte=Wr("gem",[["path",{d:"M10.5 3 8 9l4 13 4-13-2.5-6",key:"b3dvk1"}],["path",{d:"M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z",key:"7w4byz"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);const Alt=Wr("gift",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8",key:"1sqzm4"}],["path",{d:"M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5",key:"kc0143"}],["rect",{x:"3",y:"7",width:"18",height:"4",rx:"1",key:"1hberx"}]]);const blt=Wr("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);const uz=Wr("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const tQn=Wr("heading-1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);const nQn=Wr("heading-2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);const rQn=Wr("heading-3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);const aQn=Wr("heading-4",[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]]);const iQn=Wr("heading-5",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]]);const sQn=Wr("heading-6",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]]);const HN=Wr("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const oQn=Wr("inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);const dz=Wr("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);const lQn=Wr("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);const aP=Wr("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const ylt=Wr("list-ordered",[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]);const vlt=Wr("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);const Ag=Wr("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const aEe=Wr("log-in",[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]);const _lt=Wr("mail-open",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);const Kte=Wr("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const cQn=Wr("message-square-plus",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]]);const iEe=Wr("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const wlt=Wr("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const uQn=Wr("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const dQn=Wr("octagon-x",[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const pQn=Wr("panel-right-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);const pz=Wr("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);const mQn=Wr("pilcrow",[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]]);const xlt=Wr("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const gQn=Wr("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);const hQn=Wr("redo-2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);const klt=Wr("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const fQn=Wr("scale",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]]);const AQn=Wr("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const bQn=Wr("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);const yQn=Wr("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const Zte=Wr("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const vQn=Wr("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const bx=Wr("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);const _Qn=Wr("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const wQn=Wr("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);const Elt=Wr("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const xQn=Wr("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]);const Xte=Wr("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const sEe=Wr("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Clt=Wr("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);const kQn=Wr("unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);const Jte=Wr("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const ene=Wr("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);const Slt=Wr("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);const EQn=Wr("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);const M1=Wr("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const tne=Wr("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function CQn({title:t,description:e,actionLabel:n,cancelLabel:r,onAction:i,onCancel:o}){return A.jsxs("div",{className:"flex w-[calc(100vw-2rem)] max-w-[360px] flex-col gap-3 rounded-lg border border-neutral-200/60 bg-white p-4 shadow-lg dark:border-neutral-800/60 dark:bg-neutral-900",children:[A.jsxs("div",{className:"flex items-start gap-3",children:[A.jsx("div",{className:"mt-0.5 shrink-0 rounded-full bg-indigo-500/10 p-1.5",children:A.jsx(klt,{className:"size-4 text-indigo-500"})}),A.jsxs("div",{className:"min-w-0",children:[A.jsx("p",{className:"text-[13px] font-semibold text-neutral-900 dark:text-neutral-100",children:t}),A.jsx("p",{className:"mt-0.5 text-xs text-neutral-500 dark:text-neutral-400",children:e})]})]}),A.jsxs("div",{className:"flex flex-col gap-1.5",children:[A.jsx("button",{onClick:i,className:"w-full rounded-lg bg-indigo-500 px-3 py-2 text-[13px] font-semibold text-white transition-colors hover:bg-indigo-600 active:bg-indigo-700",children:n}),A.jsx("button",{onClick:o,className:"w-full rounded-lg bg-neutral-100/80 px-3 py-2 text-[13px] text-neutral-600 transition-colors hover:bg-neutral-200/80 dark:bg-white/[0.06] dark:text-neutral-400 dark:hover:bg-white/[0.1]",children:r})]})]})}function SQn(){const{t}=kn(),e=T.useRef(null),n=T.useRef(null),{needRefresh:[r],updateServiceWorker:i}=L9n();T.useEffect(()=>()=>{n.current?.(),n.current=null},[]);const o=T.useCallback(()=>{i()},[i]);T.useEffect(()=>{if(!r){e.current!=null&&(Rr.dismiss(e.current),e.current=null);return}e.current=Rr.custom(l=>CQn({title:t("app.pwa.updateAvailableTitle","New version available"),description:t("app.pwa.updateAvailableDescription","A new version of Xyzen is ready. Refresh to update."),actionLabel:t("app.pwa.updateAction","Refresh"),cancelLabel:t("app.pwa.updateDismiss","Dismiss"),onAction:o,onCancel:()=>{Rr.dismiss(l),e.current=null}}),{duration:1/0})},[r,o,t])}function IQn(){const t=ih(),e=(t.isAuthenticated||!!t.token)&&FA("billing"),n=Un(i=>i.fetchWallet),r=Un(i=>i.connectWalletEvents);T.useEffect(()=>e?(n(),r()):void 0,[e,n,r])}const Ilt=[];function AI(){return Cm(Ys(t=>{const e=t.activeChatChannel,n=e?t.channels[e]:void 0;return{channelId:e,agentId:n?.agentId??null,sessionId:n?.sessionId??null,connected:n?.connected??!1,responding:n?.responding??!1,aborting:n?.aborting??!1,model_tier:n?.model_tier??null,model:n?.model??null,knowledge_set_id:n?.knowledge_set_id??null,sandbox_backend:n?.sandbox_backend??null,provider_id:n?.provider_id??null,title:n?.title??"",tokenUsage:n?.tokenUsage??0,inputTokens:n?.inputTokens??0,contextUsage:n?.contextUsage}}))}function TQn(){return Cm(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.messages??Ilt:Ilt})}function BQn(){return Cm(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.responding??!1:!1})}function DQn(){return Cm(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.agentId??null:null})}function Tlt(){return Cm(t=>t.runningAgentIds)}function NQn(){return Cm(t=>t.activeTopicCountByAgent)}function Blt(){return Cm(t=>t.respondingChannelIds)}function Dlt(){return Cm(Ys(t=>{const e={};for(const[n,r]of Object.entries(t.channels))r.agentId&&(e[n]=r.agentId);return e}))}function RQn(t){return t==="Connecting"||typeof t=="object"&&"Connected"in t}async function Nlt(t){const e=qte(),n=Un.getState().runners;if(e){if(n.find(l=>l.id===e.runnerId)?.is_active)return e;lz()}const r=await t(jte);if(!r)return null;const i={runnerId:r.runner.id,token:r.token,name:jte};return elt(i),i}function LQn(t){const{createRunnerToken:e,fetchRunners:n,runners:r,updateSessionConfig:i}=Un(Ys(u=>({createRunnerToken:u.createRunnerToken,fetchRunners:u.fetchRunners,runners:u.runners,updateSessionConfig:u.updateSessionConfig}))),o=AI(),l=T.useRef(null);T.useEffect(()=>{if(!_l()||t!=="succeeded")return;let u=!1;return(async()=>{if(await n(),u)return;const p=await Hke().catch(()=>"Disconnected");if(RQn(p)){await n();return}let m=await Nlt(e);if(!(!m||u)){try{await zte(m.token,Ute())}catch(g){if(String(g).includes("already running")){await n();return}if(lz(),m=await Nlt(e),!m||u)return;await zte(m.token,Ute())}await n()}})(),()=>{u=!0}},[t,e,n]),T.useEffect(()=>{if(!_l()||t!=="succeeded"||!o.sessionId||o.sandbox_backend)return;const u=qte();if(!u)return;const d=r.find(m=>m.id===u.runnerId);if(!d?.is_online||!d.is_active)return;const p=`${o.sessionId}:${u.runnerId}`;l.current!==p&&(l.current=p,i(o.sessionId,{sandbox_backend:`runner:${u.runnerId}`}).catch(()=>{l.current=null}))},[t,o.sandbox_backend,o.sessionId,r,i])}let mz={state:"idle"};const oEe=new Set;let lEe=null;function P1(t){mz=t,oEe.forEach(e=>e(t))}function MQn(){return mz}function PQn(t){return oEe.add(t),()=>oEe.delete(t)}async function Rlt(){if(_l()){P1({state:"checking"});try{const{check:t}=await Promise.resolve().then(()=>NJn),e=await t();e?(lEe=e,P1({state:"available",info:{version:e.version,date:e.date??void 0,body:e.body??void 0}})):P1({state:"idle"})}catch(t){console.error("[updater] check failed:",t),P1({state:"error",message:t instanceof Error?t.message:"Update check failed"}),setTimeout(()=>{mz.state==="error"&&P1({state:"idle"})},5e3)}}}async function OQn(){if(lEe)try{let t=0,e=0;await lEe.downloadAndInstall(r=>{switch(r.event){case"Started":t=r.data.contentLength??0,P1({state:"downloading",progress:0});break;case"Progress":e+=r.data.chunkLength,P1({state:"downloading",progress:t>0?e/t:0});break;case"Finished":P1({state:"ready"});break}});const{relaunch:n}=await Promise.resolve().then(()=>MJn);await n()}catch(t){console.error("[updater] download failed:",t),P1({state:"error",message:t instanceof Error?t.message:"Download failed"})}}const FQn=14400*1e3;function QQn(){if(!_l())return()=>{};const t=setTimeout(()=>Rlt(),5e3),e=setInterval(()=>{(mz.state==="idle"||mz.state==="error")&&Rlt()},FQn);return()=>{clearTimeout(t),clearInterval(e)}}function $Qn(){const{t}=kn(),e=T.useSyncExternalStore(PQn,MQn),n=T.useRef(null);return T.useEffect(()=>{if(_l())return QQn()},[]),T.useEffect(()=>{e.state==="available"&&n.current!==e.info.version&&(n.current=e.info.version,Rr(t("settings.about.updateAvailable",{version:e.info.version,defaultValue:"New version {{version}} is available"}),{description:t("settings.about.updateDescription",{defaultValue:"Restart to apply the update."}),duration:1/0,action:{label:t("settings.about.updateNow",{defaultValue:"Update Now"}),onClick:()=>OQn()}}))},[e,t]),e}const jQn=({...t})=>A.jsx(R9n,{theme:"system",className:"toaster group",richColors:!0,icons:{success:A.jsx(G9n,{className:"size-4"}),info:A.jsx(dz,{className:"size-4"}),warning:A.jsx(sEe,{className:"size-4"}),error:A.jsx(dQn,{className:"size-4"}),loading:A.jsx(Ag,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...t}),gz=T.createContext({});function bI(t){const e=T.useRef(null);return e.current===null&&(e.current=t()),e.current}const nne=typeof window<"u"?T.useLayoutEffect:T.useEffect,rne=T.createContext(null);function cEe(t,e){t.indexOf(e)===-1&&t.push(e)}function iP(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const yx=(t,e,n)=>n>e?e:n<t?t:n;function uEe(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let sP=()=>{},Xv=()=>{};typeof process<"u"&&process.env?.NODE_ENV!=="production"&&(sP=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(uEe(e,n))},Xv=(t,e,n)=>{if(!t)throw new Error(uEe(e,n))});const yI={},Llt=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Mlt(t){return typeof t=="object"&&t!==null}const Plt=t=>/^0[^.\s]+$/u.test(t);function Olt(t){let e;return()=>(e===void 0&&(e=t()),e)}const oy=t=>t,zQn=(t,e)=>n=>e(t(n)),hz=(...t)=>t.reduce(zQn),oP=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class dEe{constructor(){this.subscriptions=[]}add(e){return cEe(this.subscriptions,e),()=>iP(this.subscriptions,e)}notify(e,n,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,r);else for(let o=0;o<i;o++){const l=this.subscriptions[o];l&&l(e,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const vf=t=>t*1e3,ly=t=>t/1e3;function Flt(t,e){return e?t*(1e3/e):0}const Qlt=new Set;function pEe(t,e,n){t||Qlt.has(e)||(console.warn(uEe(e,n)),Qlt.add(e))}const UQn=(t,e,n)=>{const r=e-t;return((n-t)%r+r)%r+t},$lt=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,qQn=1e-7,GQn=12;function HQn(t,e,n,r,i){let o,l,u=0;do l=e+(n-e)/2,o=$lt(l,r,i)-t,o>0?n=l:e=l;while(Math.abs(o)>qQn&&++u<GQn);return l}function fz(t,e,n,r){if(t===e&&n===r)return oy;const i=o=>HQn(o,0,1,t,n);return o=>o===0||o===1?o:$lt(i(o),e,r)}const jlt=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,zlt=t=>e=>1-t(1-e),Ult=fz(.33,1.53,.69,.99),mEe=zlt(Ult),qlt=jlt(mEe),Glt=t=>t>=1?1:(t*=2)<1?.5*mEe(t):.5*(2-Math.pow(2,-10*(t-1))),gEe=t=>1-Math.sin(Math.acos(t)),Hlt=zlt(gEe),Wlt=jlt(gEe),WQn=fz(.42,0,1,1),hEe=fz(0,0,.58,1),Ylt=fz(.42,0,.58,1),Vlt=t=>Array.isArray(t)&&typeof t[0]!="number";function Klt(t,e){return Vlt(t)?t[UQn(0,t.length,e)]:t}const Zlt=t=>Array.isArray(t)&&typeof t[0]=="number",Xlt={linear:oy,easeIn:WQn,easeInOut:Ylt,easeOut:hEe,circIn:gEe,circInOut:Wlt,circOut:Hlt,backIn:mEe,backInOut:qlt,backOut:Ult,anticipate:Glt},YQn=t=>typeof t=="string",Jlt=t=>{if(Zlt(t)){Xv(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,r,i]=t;return fz(e,n,r,i)}else if(YQn(t))return Xv(Xlt[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Xlt[t];return t},ane=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function VQn(t,e){let n=new Set,r=new Set,i=!1,o=!1;const l=new WeakSet;let u={delta:0,timestamp:0,isProcessing:!1};function d(m){l.has(m)&&(p.schedule(m),t()),m(u)}const p={schedule:(m,g=!1,h=!1)=>{const b=h&&i?n:r;return g&&l.add(m),b.add(m),m},cancel:m=>{r.delete(m),l.delete(m)},process:m=>{if(u=m,i){o=!0;return}i=!0;const g=n;n=r,r=g,n.forEach(d),n.clear(),i=!1,o&&(o=!1,p.process(m))}};return p}const KQn=40;function ect(t,e){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,l=ane.reduce((x,k)=>(x[k]=VQn(o),x),{}),{setup:u,read:d,resolveKeyframes:p,preUpdate:m,update:g,preRender:h,render:f,postRender:b}=l,y=()=>{const x=yI.useManualTiming,k=x?i.timestamp:performance.now();n=!1,x||(i.delta=r?1e3/60:Math.max(Math.min(k-i.timestamp,KQn),1)),i.timestamp=k,i.isProcessing=!0,u.process(i),d.process(i),p.process(i),m.process(i),g.process(i),h.process(i),f.process(i),b.process(i),i.isProcessing=!1,n&&e&&(r=!1,t(y))},v=()=>{n=!0,r=!0,i.isProcessing||t(y)};return{schedule:ane.reduce((x,k)=>{const C=l[k];return x[k]=(E,S=!1,I=!1)=>(n||v(),C.schedule(E,S,I)),x},{}),cancel:x=>{for(let k=0;k<ane.length;k++)l[ane[k]].cancel(x)},state:i,steps:l}}const{schedule:Fl,cancel:O1,state:bg,steps:fEe}=ect(typeof requestAnimationFrame<"u"?requestAnimationFrame:oy,!0);let ine;function ZQn(){ine=void 0}const _f={now:()=>(ine===void 0&&_f.set(bg.isProcessing||yI.useManualTiming?bg.timestamp:performance.now()),ine),set:t=>{ine=t,queueMicrotask(ZQn)}},tct=t=>e=>typeof e=="string"&&e.startsWith(t),nct=tct("--"),XQn=tct("var(--"),AEe=t=>XQn(t)?JQn.test(t.split("/*")[0].trim()):!1,JQn=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function rct(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const lP={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Az={...lP,transform:t=>yx(0,1,t)},sne={...lP,default:1},bz=t=>Math.round(t*1e5)/1e5,bEe=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function e$n(t){return t==null}const t$n=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,yEe=(t,e)=>n=>!!(typeof n=="string"&&t$n.test(n)&&n.startsWith(t)||e&&!e$n(n)&&Object.prototype.hasOwnProperty.call(n,e)),act=(t,e,n)=>r=>{if(typeof r!="string")return r;const[i,o,l,u]=r.match(bEe);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(l),alpha:u!==void 0?parseFloat(u):1}},n$n=t=>yx(0,255,t),vEe={...lP,transform:t=>Math.round(n$n(t))},WN={test:yEe("rgb","red"),parse:act("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+vEe.transform(t)+", "+vEe.transform(e)+", "+vEe.transform(n)+", "+bz(Az.transform(r))+")"};function r$n(t){let e="",n="",r="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,r+=r,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const _Ee={test:yEe("#"),parse:r$n,transform:WN.transform},yz=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),vI=yz("deg"),vx=yz("%"),ei=yz("px"),a$n=yz("vh"),i$n=yz("vw"),ict={...vx,parse:t=>vx.parse(t)/100,transform:t=>vx.transform(t*100)},cP={test:yEe("hsl","hue"),parse:act("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+vx.transform(bz(e))+", "+vx.transform(bz(n))+", "+bz(Az.transform(r))+")"},np={test:t=>WN.test(t)||_Ee.test(t)||cP.test(t),parse:t=>WN.test(t)?WN.parse(t):cP.test(t)?cP.parse(t):_Ee.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?WN.transform(t):cP.transform(t),getAnimatableNone:t=>{const e=np.parse(t);return e.alpha=0,np.transform(e)}},s$n=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function o$n(t){return isNaN(t)&&typeof t=="string"&&(t.match(bEe)?.length||0)+(t.match(s$n)?.length||0)>0}const sct="number",oct="color",l$n="var",c$n="var(",lct="${}",u$n=/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 uP(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},i=[];let o=0;const u=e.replace(u$n,d=>(np.test(d)?(r.color.push(o),i.push(oct),n.push(np.parse(d))):d.startsWith(c$n)?(r.var.push(o),i.push(l$n),n.push(d)):(r.number.push(o),i.push(sct),n.push(parseFloat(d))),++o,lct)).split(lct);return{values:n,split:u,indexes:r,types:i}}function d$n(t){return uP(t).values}function cct({split:t,types:e}){const n=t.length;return r=>{let i="";for(let o=0;o<n;o++)if(i+=t[o],r[o]!==void 0){const l=e[o];l===sct?i+=bz(r[o]):l===oct?i+=np.transform(r[o]):i+=r[o]}return i}}function p$n(t){return cct(uP(t))}const m$n=t=>typeof t=="number"?0:np.test(t)?np.getAnimatableNone(t):t,g$n=(t,e)=>typeof t=="number"?e?.trim().endsWith("/")?t:0:m$n(t);function h$n(t){const e=uP(t);return cct(e)(e.values.map((r,i)=>g$n(r,e.split[i])))}const Jv={test:o$n,parse:d$n,createTransformer:p$n,getAnimatableNone:h$n};function wEe(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function f$n({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let i=0,o=0,l=0;if(!e)i=o=l=n;else{const u=n<.5?n*(1+e):n+e-n*e,d=2*n-u;i=wEe(d,u,t+1/3),o=wEe(d,u,t),l=wEe(d,u,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:r}}function one(t,e){return n=>n>0?e:t}const Nc=(t,e,n)=>t+(e-t)*n,xEe=(t,e,n)=>{const r=t*t,i=n*(e*e-r)+r;return i<0?0:Math.sqrt(i)},A$n=[_Ee,WN,cP],b$n=t=>A$n.find(e=>e.test(t));function uct(t){const e=b$n(t);if(sP(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===cP&&(n=f$n(n)),n}const dct=(t,e)=>{const n=uct(t),r=uct(e);if(!n||!r)return one(t,e);const i={...n};return o=>(i.red=xEe(n.red,r.red,o),i.green=xEe(n.green,r.green,o),i.blue=xEe(n.blue,r.blue,o),i.alpha=Nc(n.alpha,r.alpha,o),WN.transform(i))},kEe=new Set(["none","hidden"]);function y$n(t,e){return kEe.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function v$n(t,e){return n=>Nc(t,e,n)}function EEe(t){return typeof t=="number"?v$n:typeof t=="string"?AEe(t)?one:np.test(t)?dct:x$n:Array.isArray(t)?pct:typeof t=="object"?np.test(t)?dct:_$n:one}function pct(t,e){const n=[...t],r=n.length,i=t.map((o,l)=>EEe(o)(o,e[l]));return o=>{for(let l=0;l<r;l++)n[l]=i[l](o);return n}}function _$n(t,e){const n={...t,...e},r={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(r[i]=EEe(t[i])(t[i],e[i]));return i=>{for(const o in r)n[o]=r[o](i);return n}}function w$n(t,e){const n=[],r={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],l=t.indexes[o][r[o]],u=t.values[l]??0;n[i]=u,r[o]++}return n}const x$n=(t,e)=>{const n=Jv.createTransformer(e),r=uP(t),i=uP(e);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?kEe.has(t)&&!i.values.length||kEe.has(e)&&!r.values.length?y$n(t,e):hz(pct(w$n(r,i),i.values),n):(sP(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),one(t,e))};function mct(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Nc(t,e,n):EEe(t)(t,e)}const k$n=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Fl.update(e,n),stop:()=>O1(e),now:()=>bg.isProcessing?bg.timestamp:_f.now()}},gct=(t,e,n=10)=>{let r="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)r+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},lne=2e4;function CEe(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<lne;)e+=n,r=t.next(e);return e>=lne?1/0:e}function hct(t,e=100,n){const r=n({...t,keyframes:[0,e]}),i=Math.min(CEe(r),lne);return{type:"keyframes",ease:o=>r.next(i*o).value/e,duration:ly(i)}}const Mu={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};function SEe(t,e){return t*Math.sqrt(1-e*e)}const E$n=12;function C$n(t,e,n){let r=n;for(let i=1;i<E$n;i++)r=r-t(r)/e(r);return r}const IEe=.001;function S$n({duration:t=Mu.duration,bounce:e=Mu.bounce,velocity:n=Mu.velocity,mass:r=Mu.mass}){let i,o;sP(t<=vf(Mu.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let l=1-e;l=yx(Mu.minDamping,Mu.maxDamping,l),t=yx(Mu.minDuration,Mu.maxDuration,ly(t)),l<1?(i=p=>{const m=p*l,g=m*t,h=m-n,f=SEe(p,l),b=Math.exp(-g);return IEe-h/f*b},o=p=>{const g=p*l*t,h=g*n+n,f=Math.pow(l,2)*Math.pow(p,2)*t,b=Math.exp(-g),y=SEe(Math.pow(p,2),l);return(-i(p)+IEe>0?-1:1)*((h-f)*b)/y}):(i=p=>{const m=Math.exp(-p*t),g=(p-n)*t+1;return-IEe+m*g},o=p=>{const m=Math.exp(-p*t),g=(n-p)*(t*t);return m*g});const u=5/t,d=C$n(i,o,u);if(t=vf(t),isNaN(d))return{stiffness:Mu.stiffness,damping:Mu.damping,duration:t};{const p=Math.pow(d,2)*r;return{stiffness:p,damping:l*2*Math.sqrt(r*p),duration:t}}}const I$n=["duration","bounce"],T$n=["stiffness","damping","mass"];function fct(t,e){return e.some(n=>t[n]!==void 0)}function B$n(t){let e={velocity:Mu.velocity,stiffness:Mu.stiffness,damping:Mu.damping,mass:Mu.mass,isResolvedFromDuration:!1,...t};if(!fct(t,T$n)&&fct(t,I$n))if(e.velocity=0,t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,o=2*yx(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:Mu.mass,stiffness:i,damping:o}}else{const n=S$n({...t,velocity:0});e={...e,...n,mass:Mu.mass},e.isResolvedFromDuration=!0}return e}function vz(t=Mu.visualDuration,e=Mu.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:i}=n;const o=n.keyframes[0],l=n.keyframes[n.keyframes.length-1],u={done:!1,value:o},{stiffness:d,damping:p,mass:m,duration:g,velocity:h,isResolvedFromDuration:f}=B$n({...n,velocity:-ly(n.velocity||0)}),b=h||0,y=p/(2*Math.sqrt(d*m)),v=l-o,_=ly(Math.sqrt(d/m)),w=Math.abs(v)<5;r||(r=w?Mu.restSpeed.granular:Mu.restSpeed.default),i||(i=w?Mu.restDelta.granular:Mu.restDelta.default);let x,k,C,E,S,I;if(y<1)C=SEe(_,y),E=(b+y*_*v)/C,x=N=>{const L=Math.exp(-y*_*N);return l-L*(E*Math.sin(C*N)+v*Math.cos(C*N))},S=y*_*E+v*C,I=y*_*v-E*C,k=N=>Math.exp(-y*_*N)*(S*Math.sin(C*N)+I*Math.cos(C*N));else if(y===1){x=L=>l-Math.exp(-_*L)*(v+(b+_*v)*L);const N=b+_*v;k=L=>Math.exp(-_*L)*(_*N*L-b)}else{const N=_*Math.sqrt(y*y-1);x=D=>{const P=Math.exp(-y*_*D),O=Math.min(N*D,300);return l-P*((b+y*_*v)*Math.sinh(O)+N*v*Math.cosh(O))/N};const L=(b+y*_*v)/N,M=y*_*L-v*N,R=y*_*v-L*N;k=D=>{const P=Math.exp(-y*_*D),O=Math.min(N*D,300);return P*(M*Math.sinh(O)+R*Math.cosh(O))}}const B={calculatedDuration:f&&g||null,velocity:N=>vf(k(N)),next:N=>{if(!f&&y<1){const M=Math.exp(-y*_*N),R=Math.sin(C*N),D=Math.cos(C*N),P=l-M*(E*R+v*D),O=vf(M*(S*R+I*D));return u.done=Math.abs(O)<=r&&Math.abs(l-P)<=i,u.value=u.done?l:P,u}const L=x(N);if(f)u.done=N>=g;else{const M=vf(k(N));u.done=Math.abs(M)<=r&&Math.abs(l-L)<=i}return u.value=u.done?l:L,u},toString:()=>{const N=Math.min(CEe(B),lne),L=gct(M=>B.next(N*M).value,N,30);return N+"ms "+L},toTransition:()=>{}};return B}vz.applyToOptions=t=>{const e=hct(t,100,vz);return t.ease=e.ease,t.duration=vf(e.duration),t.type="keyframes",t};const D$n=5;function Act(t,e,n){const r=Math.max(e-D$n,0);return Flt(n-t(r),e-r)}function TEe({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:l,min:u,max:d,restDelta:p=.5,restSpeed:m}){const g=t[0],h={done:!1,value:g},f=I=>u!==void 0&&I<u||d!==void 0&&I>d,b=I=>u===void 0?d:d===void 0||Math.abs(u-I)<Math.abs(d-I)?u:d;let y=n*e;const v=g+y,_=l===void 0?v:l(v);_!==v&&(y=_-g);const w=I=>-y*Math.exp(-I/r),x=I=>_+w(I),k=I=>{const B=w(I),N=x(I);h.done=Math.abs(B)<=p,h.value=h.done?_:N};let C,E;const S=I=>{f(h.value)&&(C=I,E=vz({keyframes:[h.value,b(h.value)],velocity:Act(x,I,h.value),damping:i,stiffness:o,restDelta:p,restSpeed:m}))};return S(0),{calculatedDuration:null,next:I=>{let B=!1;return!E&&C===void 0&&(B=!0,k(I),S(I)),C!==void 0&&I>=C?E.next(I-C):(!B&&k(I),h)}}}function N$n(t,e,n){const r=[],i=n||yI.mix||mct,o=t.length-1;for(let l=0;l<o;l++){let u=i(t[l],t[l+1]);if(e){const d=Array.isArray(e)?e[l]||oy:e;u=hz(d,u)}r.push(u)}return r}function bct(t,e,{clamp:n=!0,ease:r,mixer:i}={}){const o=t.length;if(Xv(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const l=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const u=N$n(e,r,i),d=u.length,p=m=>{if(l&&m<t[0])return e[0];let g=0;if(d>1)for(;g<t.length-2&&!(m<t[g+1]);g++);const h=oP(t[g],t[g+1],m);return u[g](h)};return n?m=>p(yx(t[0],t[o-1],m)):p}function yct(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const i=oP(0,e,r);t.push(Nc(n,1,i))}}function vct(t){const e=[0];return yct(e,t.length-1),e}function R$n(t,e){return t.map(n=>n*e)}function L$n(t,e){return t.map(()=>e||Ylt).splice(0,t.length-1)}function dP({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const i=Vlt(r)?r.map(Jlt):Jlt(r),o={done:!1,value:e[0]},l=R$n(n&&n.length===e.length?n:vct(e),t),u=bct(l,e,{ease:Array.isArray(i)?i:L$n(e,i)});return{calculatedDuration:t,next:d=>(o.value=u(d),o.done=d>=t,o)}}const M$n=t=>t!==null;function cne(t,{repeat:e,repeatType:n="loop"},r,i=1){const o=t.filter(M$n),u=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!u||r===void 0?o[u]:r}const P$n={decay:TEe,inertia:TEe,tween:dP,keyframes:dP,spring:vz};function _ct(t){typeof t.type=="string"&&(t.type=P$n[t.type])}class BEe{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const O$n=t=>t/100;class _z extends BEe{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==_f.now()&&this.tick(_f.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;_ct(e);const{type:n=dP,repeat:r=0,repeatDelay:i=0,repeatType:o,velocity:l=0}=e;let{keyframes:u}=e;const d=n||dP;process.env.NODE_ENV!=="production"&&d!==dP&&Xv(u.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${u}`,"spring-two-frames"),d!==dP&&typeof u[0]!="number"&&(this.mixKeyframes=hz(O$n,mct(u[0],u[1])),u=[0,100]);const p=d({...e,keyframes:u});o==="mirror"&&(this.mirroredGenerator=d({...e,keyframes:[...u].reverse(),velocity:-l})),p.calculatedDuration===null&&(p.calculatedDuration=CEe(p));const{calculatedDuration:m}=p;this.calculatedDuration=m,this.resolvedDuration=m+i,this.totalDuration=this.resolvedDuration*(r+1)-i,this.generator=p}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:r,totalDuration:i,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:u,calculatedDuration:d}=this;if(this.startTime===null)return r.next(0);const{delay:p=0,keyframes:m,repeat:g,repeatType:h,repeatDelay:f,type:b,onUpdate:y,finalKeyframe:v}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const _=this.currentTime-p*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?_<0:_>i;this.currentTime=Math.max(_,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let x=this.currentTime,k=r;if(g){const I=Math.min(this.currentTime,i)/u;let B=Math.floor(I),N=I%1;!N&&I>=1&&(N=1),N===1&&B--,B=Math.min(B,g+1),B%2&&(h==="reverse"?(N=1-N,f&&(N-=f/u)):h==="mirror"&&(k=l)),x=yx(0,1,N)*u}let C;w?(this.delayState.value=m[0],C=this.delayState):C=k.next(x),o&&!w&&(C.value=o(C.value));let{done:E}=C;!w&&d!==null&&(E=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const S=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return S&&b!==TEe&&(C.value=cne(m,this.options,v,this.speed)),y&&y(C.value),S&&this.finish(),C}then(e,n){return this.finished.then(e,n)}get duration(){return ly(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ly(e)}get time(){return ly(this.currentTime)}set time(e){e=vf(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=e,this.tick(e))}getGeneratorVelocity(){const e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);const n=this.generator.next(e).value;return Act(r=>this.generator.next(r).value,e,n)}get speed(){return this.playbackSpeed}set speed(e){const n=this.playbackSpeed!==e;n&&this.driver&&this.updateTime(_f.now()),this.playbackSpeed=e,n&&this.driver&&(this.time=ly(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=k$n,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),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(_f.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function F$n(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const YN=t=>t*180/Math.PI,DEe=t=>{const e=YN(Math.atan2(t[1],t[0]));return NEe(e)},Q$n={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:DEe,rotateZ:DEe,skewX:t=>YN(Math.atan(t[1])),skewY:t=>YN(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},NEe=t=>(t=t%360,t<0&&(t+=360),t),wct=DEe,xct=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),kct=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),$$n={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:xct,scaleY:kct,scale:t=>(xct(t)+kct(t))/2,rotateX:t=>NEe(YN(Math.atan2(t[6],t[5]))),rotateY:t=>NEe(YN(Math.atan2(-t[2],t[0]))),rotateZ:wct,rotate:wct,skewX:t=>YN(Math.atan(t[4])),skewY:t=>YN(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function REe(t){return t.includes("scale")?1:0}function LEe(t,e){if(!t||t==="none")return REe(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=$$n,i=n;else{const u=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Q$n,i=u}if(!i)return REe(e);const o=r[e],l=i[1].split(",").map(z$n);return typeof o=="function"?o(l):l[o]}const j$n=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return LEe(n,e)};function z$n(t){return parseFloat(t.trim())}const pP=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],mP=new Set(pP),Ect=t=>t===lP||t===ei,U$n=new Set(["x","y","z"]),q$n=pP.filter(t=>!U$n.has(t));function G$n(t){const e=[];return q$n.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const _I={width:({x:t},{paddingLeft:e="0",paddingRight:n="0",boxSizing:r})=>{const i=t.max-t.min;return r==="border-box"?i:i-parseFloat(e)-parseFloat(n)},height:({y:t},{paddingTop:e="0",paddingBottom:n="0",boxSizing:r})=>{const i=t.max-t.min;return r==="border-box"?i:i-parseFloat(e)-parseFloat(n)},top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>LEe(e,"x"),y:(t,{transform:e})=>LEe(e,"y")};_I.translateX=_I.x,_I.translateY=_I.y;const VN=new Set;let MEe=!1,PEe=!1,OEe=!1;function Cct(){if(PEe){const t=Array.from(VN).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const i=G$n(r);i.length&&(n.set(r,i),r.render())}),t.forEach(r=>r.measureInitialState()),e.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([o,l])=>{r.getValue(o)?.set(l)})}),t.forEach(r=>r.measureEndState()),t.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}PEe=!1,MEe=!1,VN.forEach(t=>t.complete(OEe)),VN.clear()}function Sct(){VN.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(PEe=!0)})}function H$n(){OEe=!0,Sct(),Cct(),OEe=!1}class FEe{constructor(e,n,r,i,o,l=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=r,this.motionValue=i,this.element=o,this.isAsync=l}scheduleResolve(){this.state="scheduled",this.isAsync?(VN.add(this),MEe||(MEe=!0,Fl.read(Sct),Fl.resolveKeyframes(Cct))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:r,motionValue:i}=this;if(e[0]===null){const o=i?.get(),l=e[e.length-1];if(o!==void 0)e[0]=o;else if(r&&n){const u=r.readValue(n,l);u!=null&&(e[0]=u)}e[0]===void 0&&(e[0]=l),i&&o===void 0&&i.set(e[0])}F$n(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),VN.delete(this)}cancel(){this.state==="scheduled"&&(VN.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const W$n=t=>t.startsWith("--");function Ict(t,e,n){W$n(e)?t.style.setProperty(e,n):t.style[e]=n}const Y$n={};function Tct(t,e){const n=Olt(t);return()=>Y$n[e]??n()}const V$n=Tct(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),Bct=Tct(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),wz=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,Dct={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:wz([0,.65,.55,1]),circOut:wz([.55,0,1,.45]),backIn:wz([.31,.01,.66,-.59]),backOut:wz([.33,1.53,.69,.99])};function Nct(t,e){if(t)return typeof t=="function"?Bct()?gct(t,e):"ease-out":Zlt(t)?wz(t):Array.isArray(t)?t.map(n=>Nct(n,e)||Dct.easeOut):Dct[t]}function K$n(t,e,n,{delay:r=0,duration:i=300,repeat:o=0,repeatType:l="loop",ease:u="easeOut",times:d}={},p=void 0){const m={[e]:n};d&&(m.offset=d);const g=Nct(u,i);Array.isArray(g)&&(m.easing=g);const h={delay:r,duration:i,easing:Array.isArray(g)?"linear":g,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return p&&(h.pseudoElement=p),t.animate(m,h)}function QEe(t){return typeof t=="function"&&"applyToOptions"in t}function Z$n({type:t,...e}){return QEe(t)&&Bct()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Rct extends BEe{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:n,name:r,keyframes:i,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:u,onComplete:d}=e;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=e,Xv(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const p=Z$n(e);this.animation=K$n(n,r,i,p,o),p.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const m=cne(i,this.options,u,this.speed);this.updateMotionValue&&this.updateMotionValue(m),Ict(n,r,m),this.animation.cancel()}d?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return ly(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ly(e)}get time(){return ly(Number(this.animation.currentTime)||0)}set time(e){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=vf(e),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:n,rangeEnd:r,observe:i}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&V$n()?(this.animation.timeline=e,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),oy):i(this)}}const Lct={anticipate:Glt,backInOut:qlt,circInOut:Wlt};function X$n(t){return t in Lct}function J$n(t){typeof t.ease=="string"&&X$n(t.ease)&&(t.ease=Lct[t.ease])}const $Ee=10;class ejn extends Rct{constructor(e){J$n(e),_ct(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:r,onComplete:i,element:o,...l}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const u=new _z({...l,autoplay:!1}),d=Math.max($Ee,_f.now()-this.startTime),p=yx(0,$Ee,d-$Ee),m=u.sample(d).value,{name:g}=this.options;o&&g&&Ict(o,g,m),n.setWithVelocity(u.sample(Math.max(0,d-p)).value,m,p),u.stop()}}const Mct=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Jv.test(t)||t==="0")&&!t.startsWith("url("));function tjn(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function njn(t,e,n,r){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],l=Mct(i,e),u=Mct(o,e);return sP(l===u,`You are trying to animate ${e} from "${i}" to "${o}". "${l?o:i}" is not an animatable value.`,"value-not-animatable"),!l||!u?!1:tjn(t)||(n==="spring"||QEe(n))&&r}function jEe(t){t.duration=0,t.type="keyframes"}const Pct=new Set(["opacity","clipPath","filter","transform"]),rjn=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ajn(t){for(let e=0;e<t.length;e++)if(typeof t[e]=="string"&&rjn.test(t[e]))return!0;return!1}const ijn=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),sjn=Olt(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function ojn(t){const{motionValue:e,name:n,repeatDelay:r,repeatType:i,damping:o,type:l,keyframes:u}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:p,transformTemplate:m}=e.owner.getProps();return sjn()&&n&&(Pct.has(n)||ijn.has(n)&&ajn(u))&&(n!=="transform"||!m)&&!p&&!r&&i!=="mirror"&&o!==0&&l!=="inertia"}const ljn=40;class cjn extends BEe{constructor({autoplay:e=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:l="loop",keyframes:u,name:d,motionValue:p,element:m,...g}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=_f.now();const h={autoplay:e,delay:n,type:r,repeat:i,repeatDelay:o,repeatType:l,name:d,motionValue:p,element:m,...g},f=m?.KeyframeResolver||FEe;this.keyframeResolver=new f(u,(b,y,v)=>this.onKeyframesResolved(b,y,h,!v),d,p,m),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,r,i){this.keyframeResolver=void 0;const{name:o,type:l,velocity:u,delay:d,isHandoff:p,onUpdate:m}=r;this.resolvedAt=_f.now();let g=!0;njn(e,o,l,u)||(g=!1,(yI.instantAnimations||!d)&&m?.(cne(e,r,n)),e[0]=e[e.length-1],jEe(r),r.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>ljn?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},b=g&&!p&&ojn(f),y=f.motionValue?.owner?.current;let v;if(b)try{v=new ejn({...f,element:y})}catch{v=new _z(f)}else v=new _z(f);v.finished.then(()=>{this.notifyFinished()}).catch(oy),this.pendingTimeline&&(this.stopTimeline=v.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=v}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),H$n()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}class ujn{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,n){for(let r=0;r<this.animations.length;r++)this.animations[r][e]=n}attachTimeline(e){const n=this.animations.map(r=>r.attachTimeline(e));return()=>{n.forEach((r,i)=>{r&&r(),this.animations[i].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return Oct(this.animations,"duration")}get iterationDuration(){return Oct(this.animations,"iterationDuration")}runAll(e){this.animations.forEach(n=>n[e]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function Oct(t,e){let n=0;for(let r=0;r<t.length;r++){const i=t[r][e];i!==null&&i>n&&(n=i)}return n}class djn extends ujn{then(e,n){return this.finished.finally(e).then(()=>{})}}function Fct(t,e,n,r=0,i=1){const o=Array.from(t).sort((p,m)=>p.sortNodePosition(m)).indexOf(e),l=t.size,u=(l-1)*r;return typeof n=="function"?n(o,l):i===1?o*r:u-o*r}const pjn=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function mjn(t){const e=pjn.exec(t);if(!e)return[,];const[,n,r,i]=e;return[`--${n??r}`,i]}const gjn=4;function Qct(t,e,n=1){Xv(n<=gjn,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,i]=mjn(t);if(!r)return;const o=window.getComputedStyle(e).getPropertyValue(r);if(o){const l=o.trim();return Llt(l)?parseFloat(l):l}return AEe(i)?Qct(i,e,n+1):i}const hjn={type:"spring",stiffness:500,damping:25,restSpeed:10},fjn=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Ajn={type:"keyframes",duration:.8},bjn={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},yjn=(t,{keyframes:e})=>e.length>2?Ajn:mP.has(t)?t.startsWith("scale")?fjn(e[1]):hjn:bjn;function $ct(t,e){if(t?.inherit&&e){const{inherit:n,...r}=t;return{...e,...r}}return t}function zEe(t,e){const n=t?.[e]??t?.default??t;return n!==t?$ct(n,t):n}const vjn=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function _jn(t){for(const e in t)if(!vjn.has(e))return!0;return!1}const UEe=(t,e,n,r={},i,o)=>l=>{const u=zEe(r,t)||{},d=u.delay||r.delay||0;let{elapsed:p=0}=r;p=p-vf(d);const m={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...u,delay:-p,onUpdate:h=>{e.set(h),u.onUpdate&&u.onUpdate(h)},onComplete:()=>{l(),u.onComplete&&u.onComplete()},name:t,motionValue:e,element:o?void 0:i};_jn(u)||Object.assign(m,yjn(t,m)),m.duration&&(m.duration=vf(m.duration)),m.repeatDelay&&(m.repeatDelay=vf(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let g=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&(jEe(m),m.delay===0&&(g=!0)),(yI.instantAnimations||yI.skipAnimations||i?.shouldSkipAnimations)&&(g=!0,jEe(m),m.delay=0),m.allowFlatten=!u.type&&!u.ease,g&&!o&&e.get()!==void 0){const h=cne(m.keyframes,u);if(h!==void 0){Fl.update(()=>{m.onUpdate(h),m.onComplete()});return}}return u.isSync?new _z(m):new cjn(m)};function jct(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function qEe(t,e,n,r){if(typeof e=="function"){const[i,o]=jct(r);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=jct(r);e=e(n!==void 0?n:t.custom,i,o)}return e}function KN(t,e,n){const r=t.getProps();return qEe(r,e,n!==void 0?n:r.custom,t)}const zct=new Set(["width","height","top","left","right","bottom",...pP]),Uct=30,wjn=t=>!isNaN(parseFloat(t)),xz={current:void 0};class xjn{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const i=_f.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=_f.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=wjn(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&pEe(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new dEe);const r=this.events[e].add(n);return e==="change"?()=>{r(),Fl.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return xz.current&&xz.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=_f.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Uct)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Uct);return Flt(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function wI(t,e){return new xjn(t,e)}const GEe=t=>Array.isArray(t);function kjn(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,wI(n))}function Ejn(t){return GEe(t)?t[t.length-1]||0:t}function Cjn(t,e){const n=KN(t,e);let{transitionEnd:r={},transition:i={},...o}=n||{};o={...o,...r};for(const l in o){const u=Ejn(o[l]);kjn(t,l,u)}}const Bd=t=>!!(t&&t.getVelocity);function Sjn(t){return!!(Bd(t)&&t.add)}function HEe(t,e){const n=t.getValue("willChange");if(Sjn(n))return n.add(e);if(!n&&yI.WillChange){const r=new yI.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function WEe(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const qct="data-"+WEe("framerAppearId");function Gct(t){return t.props[qct]}function Ijn({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function YEe(t,e,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:o,transitionEnd:l,...u}=e;const d=t.getDefaultTransition();o=o?$ct(o,d):d;const p=o?.reduceMotion;r&&(o=r);const m=[],g=i&&t.animationState&&t.animationState.getState()[i];for(const h in u){const f=t.getValue(h,t.latestValues[h]??null),b=u[h];if(b===void 0||g&&Ijn(g,h))continue;const y={delay:n,...zEe(o||{},h)},v=f.get();if(v!==void 0&&!f.isAnimating()&&!Array.isArray(b)&&b===v&&!y.velocity){Fl.update(()=>f.set(b));continue}let _=!1;if(window.MotionHandoffAnimation){const k=Gct(t);if(k){const C=window.MotionHandoffAnimation(k,h,Fl);C!==null&&(y.startTime=C,_=!0)}}HEe(t,h);const w=p??t.shouldReduceMotion;f.start(UEe(h,f,b,w&&zct.has(h)?{type:!1}:y,t,_));const x=f.animation;x&&m.push(x)}if(l){const h=()=>Fl.update(()=>{l&&Cjn(t,l)});m.length?Promise.all(m).then(h):h()}return m}function VEe(t,e,n={}){const r=KN(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);const o=r?()=>Promise.all(YEe(t,r,n)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(d=0)=>{const{delayChildren:p=0,staggerChildren:m,staggerDirection:g}=i;return Tjn(t,e,d,p,m,g,n)}:()=>Promise.resolve(),{when:u}=i;if(u){const[d,p]=u==="beforeChildren"?[o,l]:[l,o];return d().then(()=>p())}else return Promise.all([o(),l(n.delay)])}function Tjn(t,e,n=0,r=0,i=0,o=1,l){const u=[];for(const d of t.variantChildren)d.notify("AnimationStart",e),u.push(VEe(d,e,{...l,delay:n+(typeof r=="function"?0:r)+Fct(t.variantChildren,d,r,i,o)}).then(()=>d.notify("AnimationComplete",e)));return Promise.all(u)}function Bjn(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const i=e.map(o=>VEe(t,o,n));r=Promise.all(i)}else if(typeof e=="string")r=VEe(t,e,n);else{const i=typeof e=="function"?KN(t,e,n.custom):e;r=Promise.all(YEe(t,i,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}const Djn={test:t=>t==="auto",parse:t=>t},Hct=t=>e=>e.test(t),Wct=[lP,ei,vx,vI,i$n,a$n,Djn],Yct=t=>Wct.find(Hct(t));function Njn(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Plt(t):!0}const Rjn=new Set(["brightness","contrast","saturate","opacity"]);function Ljn(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(bEe)||[];if(!r)return t;const i=n.replace(r,"");let o=Rjn.has(e)?1:0;return r!==n&&(o*=100),e+"("+o+i+")"}const Mjn=/\b([a-z-]*)\(.*?\)/gu,KEe={...Jv,getAnimatableNone:t=>{const e=t.match(Mjn);return e?e.map(Ljn).join(" "):t}},ZEe={...Jv,getAnimatableNone:t=>{const e=Jv.parse(t);return Jv.createTransformer(t)(e.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},Vct={...lP,transform:Math.round},XEe={borderWidth:ei,borderTopWidth:ei,borderRightWidth:ei,borderBottomWidth:ei,borderLeftWidth:ei,borderRadius:ei,borderTopLeftRadius:ei,borderTopRightRadius:ei,borderBottomRightRadius:ei,borderBottomLeftRadius:ei,width:ei,maxWidth:ei,height:ei,maxHeight:ei,top:ei,right:ei,bottom:ei,left:ei,inset:ei,insetBlock:ei,insetBlockStart:ei,insetBlockEnd:ei,insetInline:ei,insetInlineStart:ei,insetInlineEnd:ei,padding:ei,paddingTop:ei,paddingRight:ei,paddingBottom:ei,paddingLeft:ei,paddingBlock:ei,paddingBlockStart:ei,paddingBlockEnd:ei,paddingInline:ei,paddingInlineStart:ei,paddingInlineEnd:ei,margin:ei,marginTop:ei,marginRight:ei,marginBottom:ei,marginLeft:ei,marginBlock:ei,marginBlockStart:ei,marginBlockEnd:ei,marginInline:ei,marginInlineStart:ei,marginInlineEnd:ei,fontSize:ei,backgroundPositionX:ei,backgroundPositionY:ei,...{rotate:vI,rotateX:vI,rotateY:vI,rotateZ:vI,scale:sne,scaleX:sne,scaleY:sne,scaleZ:sne,skew:vI,skewX:vI,skewY:vI,distance:ei,translateX:ei,translateY:ei,translateZ:ei,x:ei,y:ei,z:ei,perspective:ei,transformPerspective:ei,opacity:Az,originX:ict,originY:ict,originZ:ei},zIndex:Vct,fillOpacity:Az,strokeOpacity:Az,numOctaves:Vct},Pjn={...XEe,color:np,backgroundColor:np,outlineColor:np,fill:np,stroke:np,borderColor:np,borderTopColor:np,borderRightColor:np,borderBottomColor:np,borderLeftColor:np,filter:KEe,WebkitFilter:KEe,mask:ZEe,WebkitMask:ZEe},Kct=t=>Pjn[t],Ojn=new Set([KEe,ZEe]);function Zct(t,e){let n=Kct(t);return Ojn.has(n)||(n=Jv),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Fjn=new Set(["auto","none","0"]);function Qjn(t,e,n){let r=0,i;for(;r<t.length&&!i;){const o=t[r];typeof o=="string"&&!Fjn.has(o)&&uP(o).values.length&&(i=t[r]),r++}if(i&&n)for(const o of e)t[o]=Zct(n,i)}class $jn extends FEe{constructor(e,n,r,i,o){super(e,n,r,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let m=0;m<e.length;m++){let g=e[m];if(typeof g=="string"&&(g=g.trim(),AEe(g))){const h=Qct(g,n.current);h!==void 0&&(e[m]=h),m===e.length-1&&(this.finalKeyframe=g)}}if(this.resolveNoneKeyframes(),!zct.has(r)||e.length!==2)return;const[i,o]=e,l=Yct(i),u=Yct(o),d=rct(i),p=rct(o);if(d!==p&&_I[r]){this.needsMeasurement=!0;return}if(l!==u)if(Ect(l)&&Ect(u))for(let m=0;m<e.length;m++){const g=e[m];typeof g=="string"&&(e[m]=parseFloat(g))}else _I[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let i=0;i<e.length;i++)(e[i]===null||Njn(e[i]))&&r.push(i);r.length&&Qjn(e,r,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:r}=this;if(!e||!e.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=_I[r](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(r,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:r}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=r.length-1,l=r[o];r[o]=_I[n](e.measureViewportBox(),window.getComputedStyle(e.current)),l!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=l),this.removedTransforms?.length&&this.removedTransforms.forEach(([u,d])=>{e.getValue(u).set(d)}),this.resolveNoneKeyframes()}}function une(t,e,n){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let r=document;e&&(r=e.current);const i=n?.[t]??r.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t).filter(r=>r!=null)}const Xct=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function dne(t){return Mlt(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:JEe}=ect(queueMicrotask,!1),e_={x:!1,y:!1};function Jct(){return e_.x||e_.y}function jjn(t){return t==="x"||t==="y"?e_[t]?null:(e_[t]=!0,()=>{e_[t]=!1}):e_.x||e_.y?null:(e_.x=e_.y=!0,()=>{e_.x=e_.y=!1})}function eut(t,e){const n=une(t),r=new AbortController,i={passive:!0,...e,signal:r.signal};return[n,i,()=>r.abort()]}function zjn(t){return!(t.pointerType==="touch"||Jct())}function Ujn(t,e,n={}){const[r,i,o]=eut(t,n);return r.forEach(l=>{let u=!1,d=!1,p;const m=()=>{l.removeEventListener("pointerleave",b)},g=v=>{p&&(p(v),p=void 0),m()},h=v=>{u=!1,window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),d&&(d=!1,g(v))},f=()=>{u=!0,window.addEventListener("pointerup",h,i),window.addEventListener("pointercancel",h,i)},b=v=>{if(v.pointerType!=="touch"){if(u){d=!0;return}g(v)}},y=v=>{if(!zjn(v))return;d=!1;const _=e(l,v);typeof _=="function"&&(p=_,l.addEventListener("pointerleave",b,i))};l.addEventListener("pointerenter",y,i),l.addEventListener("pointerdown",f,i)}),o}const tut=(t,e)=>e?t===e?!0:tut(t,e.parentElement):!1,e1e=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,qjn=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Gjn(t){return qjn.has(t.tagName)||t.isContentEditable===!0}const Hjn=new Set(["INPUT","SELECT","TEXTAREA"]);function Wjn(t){return Hjn.has(t.tagName)||t.isContentEditable===!0}const pne=new WeakSet;function nut(t){return e=>{e.key==="Enter"&&t(e)}}function t1e(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Yjn=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=nut(()=>{if(pne.has(n))return;t1e(n,"down");const i=nut(()=>{t1e(n,"up")}),o=()=>t1e(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",r,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),e)};function rut(t){return e1e(t)&&!Jct()}const aut=new WeakSet;function Vjn(t,e,n={}){const[r,i,o]=eut(t,n),l=u=>{const d=u.currentTarget;if(!rut(u)||aut.has(u))return;pne.add(d),n.stopPropagation&&aut.add(u);const p=e(d,u),m=(f,b)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",h),pne.has(d)&&pne.delete(d),rut(f)&&typeof p=="function"&&p(f,{success:b})},g=f=>{m(f,d===window||d===document||n.useGlobalTarget||tut(d,f.target))},h=f=>{m(f,!1)};window.addEventListener("pointerup",g,i),window.addEventListener("pointercancel",h,i)};return r.forEach(u=>{(n.useGlobalTarget?window:u).addEventListener("pointerdown",l,i),dne(u)&&(u.addEventListener("focus",p=>Yjn(p,i)),!Gjn(u)&&!u.hasAttribute("tabindex")&&(u.tabIndex=0))}),o}function mne(t){return Mlt(t)&&"ownerSVGElement"in t}const gne=new WeakMap;let hne;const iut=(t,e,n)=>(r,i)=>i&&i[0]?i[0][t+"Size"]:mne(r)&&"getBBox"in r?r.getBBox()[e]:r[n],Kjn=iut("inline","width","offsetWidth"),Zjn=iut("block","height","offsetHeight");function Xjn({target:t,borderBoxSize:e}){gne.get(t)?.forEach(n=>{n(t,{get width(){return Kjn(t,e)},get height(){return Zjn(t,e)}})})}function Jjn(t){t.forEach(Xjn)}function e7n(){typeof ResizeObserver>"u"||(hne=new ResizeObserver(Jjn))}function t7n(t,e){hne||e7n();const n=une(t);return n.forEach(r=>{let i=gne.get(r);i||(i=new Set,gne.set(r,i)),i.add(e),hne?.observe(r)}),()=>{n.forEach(r=>{const i=gne.get(r);i?.delete(e),i?.size||hne?.unobserve(r)})}}const fne=new Set;let gP;function n7n(){gP=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};fne.forEach(e=>e(t))},window.addEventListener("resize",gP)}function r7n(t){return fne.add(t),gP||n7n(),()=>{fne.delete(t),!fne.size&&typeof gP=="function"&&(window.removeEventListener("resize",gP),gP=void 0)}}function sut(t,e){return typeof t=="function"?r7n(t):t7n(t,e)}function out(t){return mne(t)&&t.tagName==="svg"}function a7n(...t){const e=!Array.isArray(t[0]),n=e?0:-1,r=t[0+n],i=t[1+n],o=t[2+n],l=t[3+n],u=bct(i,o,l);return e?u(r):u}function i7n(t,e,n={}){const r=t.get();let i=null,o=r,l;const u=typeof r=="string"?r.replace(/[\d.-]/g,""):void 0,d=()=>{i&&(i.stop(),i=null),t.animation=void 0},p=()=>{const g=lut(t.get()),h=lut(o);if(g===h){d();return}const f=i?i.getGeneratorVelocity():t.getVelocity();d(),i=new _z({keyframes:[g,h],velocity:f,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:l})},m=()=>{p(),t.animation=i??void 0,t.events.animationStart?.notify(),i?.then(()=>{t.animation=void 0,t.events.animationComplete?.notify()})};if(t.attach((g,h)=>{o=g,l=f=>h(n1e(f,u)),Fl.postRender(m)},d),Bd(e)){let g=n.skipInitialAnimation===!0;const h=e.on("change",b=>{g?(g=!1,t.jump(n1e(b,u),!1)):t.set(n1e(b,u))}),f=t.on("destroy",h);return()=>{h(),f()}}return d}function n1e(t,e){return e?t+e:t}function lut(t){return typeof t=="number"?t:parseFloat(t)}const s7n=[...Wct,np,Jv],o7n=t=>s7n.find(Hct(t)),cut=()=>({translate:0,scale:1,origin:0,originPoint:0}),hP=()=>({x:cut(),y:cut()}),uut=()=>({min:0,max:0}),rp=()=>({x:uut(),y:uut()}),kz=new WeakMap;function Ane(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Ez(t){return typeof t=="string"||Array.isArray(t)}const r1e=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],a1e=["initial",...r1e];function bne(t){return Ane(t.animate)||a1e.some(e=>Ez(t[e]))}function dut(t){return!!(bne(t)||t.variants)}function l7n(t,e,n){for(const r in e){const i=e[r],o=n[r];if(Bd(i))t.addValue(r,i);else if(Bd(o))t.addValue(r,wI(i,{owner:t}));else if(o!==i)if(t.hasValue(r)){const l=t.getValue(r);l.liveStyle===!0?l.jump(i):l.hasAnimated||l.set(i)}else{const l=t.getStaticValue(r);t.addValue(r,wI(l!==void 0?l:i,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const i1e={current:null},put={current:!1},c7n=typeof window<"u";function u7n(){if(put.current=!0,!!c7n)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>i1e.current=t.matches;t.addEventListener("change",e),e()}else i1e.current=!1}const mut=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let yne={};function gut(t){yne=t}function d7n(){return yne}class hut{scrapeMotionValuesFromProps(e,n,r){return{}}constructor({parent:e,props:n,presenceContext:r,reducedMotionConfig:i,skipAnimations:o,blockInitialAnimation:l,visualState:u},d={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=FEe,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=_f.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,Fl.render(this.render,!1,!0))};const{latestValues:p,renderState:m}=u;this.latestValues=p,this.baseTarget={...p},this.initialValues=n.initial?{...p}:{},this.renderState=m,this.parent=e,this.props=n,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=o,this.options=d,this.blockInitialAnimation=!!l,this.isControllingVariants=bne(n),this.isVariantNode=dut(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:g,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in h){const b=h[f];p[f]!==void 0&&Bd(b)&&b.set(p[f])}}mount(e){if(this.hasBeenMounted)for(const n in this.initialValues)this.values.get(n)?.jump(this.initialValues[n]),this.latestValues[n]=this.initialValues[n];this.current=e,kz.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(put.current||u7n(),this.shouldReduceMotion=i1e.current),process.env.NODE_ENV!=="production"&&pEe(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),O1(this.notifyUpdate),O1(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),n.accelerate&&Pct.has(e)&&this.current instanceof HTMLElement){const{factory:l,keyframes:u,times:d,ease:p,duration:m}=n.accelerate,g=new Rct({element:this.current,name:e,keyframes:u,times:d,ease:p,duration:vf(m)}),h=l(g);this.valueSubscriptions.set(e,()=>{h(),g.cancel()});return}const r=mP.has(e);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",l=>{this.latestValues[e]=l,this.props.onUpdate&&Fl.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in yne){const n=yne[e];if(!n)continue;const{isEnabled:r,Feature:i}=n;if(!this.features[e]&&i&&r(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):rp()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<mut.length;r++){const i=mut[r];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,l=e[o];l&&(this.propEventSubscriptions[i]=this.on(i,l))}this.prevMotionValues=l7n(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const r=this.values.get(e);n!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return r===void 0&&n!==void 0&&(r=wI(n===null?void 0:n,{owner:this}),this.addValue(e,r)),r}readValue(e,n){let r=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return r!=null&&(typeof r=="string"&&(Llt(r)||Plt(r))?r=parseFloat(r):!o7n(r)&&Jv.test(n)&&(r=Zct(e,n)),this.setBaseTarget(e,Bd(r)?r.get():r)),Bd(r)?r.get():r}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const o=qEe(this.props,n,this.presenceContext?.custom);o&&(r=o[e])}if(n&&r!==void 0)return r;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!Bd(i)?i:this.initialValues[e]!==void 0&&r===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new dEe),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){JEe.render(this.render)}}class fut extends hut{constructor(){super(...arguments),this.KeyframeResolver=$jn}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){const r=e.style;return r?r[n]:void 0}removeValueFromRenderState(e,{vars:n,style:r}){delete n[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Bd(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class xI{constructor(e){this.isMounted=!1,this.node=e}update(){}}function Aut({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function p7n({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function m7n(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function s1e(t){return t===void 0||t===1}function o1e({scale:t,scaleX:e,scaleY:n}){return!s1e(t)||!s1e(e)||!s1e(n)}function ZN(t){return o1e(t)||but(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function but(t){return yut(t.x)||yut(t.y)}function yut(t){return t&&t!=="0%"}function vne(t,e,n){const r=t-n,i=e*r;return n+i}function vut(t,e,n,r,i){return i!==void 0&&(t=vne(t,i,r)),vne(t,n,r)+e}function l1e(t,e=0,n=1,r,i){t.min=vut(t.min,e,n,r,i),t.max=vut(t.max,e,n,r,i)}function _ut(t,{x:e,y:n}){l1e(t.x,e.translate,e.scale,e.originPoint),l1e(t.y,n.translate,n.scale,n.originPoint)}const wut=.999999999999,xut=1.0000000000001;function g7n(t,e,n,r=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,l;for(let u=0;u<i;u++){o=n[u],l=o.projectionDelta;const{visualElement:d}=o.options;d&&d.props.style&&d.props.style.display==="contents"||(r&&o.options.layoutScroll&&o.scroll&&o!==o.root&&(_x(t.x,-o.scroll.offset.x),_x(t.y,-o.scroll.offset.y)),l&&(e.x*=l.x.scale,e.y*=l.y.scale,_ut(t,l)),r&&ZN(o.latestValues)&&_ne(t,o.latestValues,o.layout?.layoutBox))}e.x<xut&&e.x>wut&&(e.x=1),e.y<xut&&e.y>wut&&(e.y=1)}function _x(t,e){t.min+=e,t.max+=e}function kut(t,e,n,r,i=.5){const o=Nc(t.min,t.max,i);l1e(t,e,n,o,r)}function Eut(t,e){return typeof t=="string"?parseFloat(t)/100*(e.max-e.min):t}function _ne(t,e,n){const r=n??t;kut(t.x,Eut(e.x,r.x),e.scaleX,e.scale,e.originX),kut(t.y,Eut(e.y,r.y),e.scaleY,e.scale,e.originY)}function Cut(t,e){return Aut(m7n(t.getBoundingClientRect(),e))}function h7n(t,e,n){const r=Cut(t,n),{scroll:i}=e;return i&&(_x(r.x,i.offset.x),_x(r.y,i.offset.y)),r}const f7n={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},A7n=pP.length;function b7n(t,e,n){let r="",i=!0;for(let o=0;o<A7n;o++){const l=pP[o],u=t[l];if(u===void 0)continue;let d=!0;if(typeof u=="number")d=u===(l.startsWith("scale")?1:0);else{const p=parseFloat(u);d=l.startsWith("scale")?p===1:p===0}if(!d||n){const p=Xct(u,XEe[l]);if(!d){i=!1;const m=f7n[l]||l;r+=`${m}(${p}) `}n&&(e[l]=p)}}return r=r.trim(),n?r=n(e,i?"":r):i&&(r="none"),r}function c1e(t,e,n){const{style:r,vars:i,transformOrigin:o}=t;let l=!1,u=!1;for(const d in e){const p=e[d];if(mP.has(d)){l=!0;continue}else if(nct(d)){i[d]=p;continue}else{const m=Xct(p,XEe[d]);d.startsWith("origin")?(u=!0,o[d]=m):r[d]=m}}if(e.transform||(l||n?r.transform=b7n(e,t.transform,n):r.transform&&(r.transform="none")),u){const{originX:d="50%",originY:p="50%",originZ:m=0}=o;r.transformOrigin=`${d} ${p} ${m}`}}function Sut(t,{style:e,vars:n},r,i){const o=t.style;let l;for(l in e)o[l]=e[l];i?.applyProjectionStyles(o,r);for(l in n)o.setProperty(l,n[l])}function Iut(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Cz={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(ei.test(t))t=parseFloat(t);else return t;const n=Iut(t,e.target.x),r=Iut(t,e.target.y);return`${n}% ${r}%`}},y7n={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,i=Jv.parse(t);if(i.length>5)return r;const o=Jv.createTransformer(t),l=typeof i[0]!="number"?1:0,u=n.x.scale*e.x,d=n.y.scale*e.y;i[0+l]/=u,i[1+l]/=d;const p=Nc(u,d,.5);return typeof i[2+l]=="number"&&(i[2+l]/=p),typeof i[3+l]=="number"&&(i[3+l]/=p),o(i)}},u1e={borderRadius:{...Cz,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Cz,borderTopRightRadius:Cz,borderBottomLeftRadius:Cz,borderBottomRightRadius:Cz,boxShadow:y7n};function Tut(t,{layout:e,layoutId:n}){return mP.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!u1e[t]||t==="opacity")}function d1e(t,e,n){const r=t.style,i=e?.style,o={};if(!r)return o;for(const l in r)(Bd(r[l])||i&&Bd(i[l])||Tut(l,t)||n?.getValue(l)?.liveStyle!==void 0)&&(o[l]=r[l]);return o}function v7n(t){return window.getComputedStyle(t)}class But extends fut{constructor(){super(...arguments),this.type="html",this.renderInstance=Sut}readValueFromInstance(e,n){if(mP.has(n))return this.projection?.isProjecting?REe(n):j$n(e,n);{const r=v7n(e),i=(nct(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Cut(e,n)}build(e,n,r){c1e(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return d1e(e,n,r)}}function _7n(t,e){return t in e}class w7n extends hut{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,n){if(_7n(n,e)){const r=e[n];if(typeof r=="string"||typeof r=="number")return r}}getBaseTargetFromProps(){}removeValueFromRenderState(e,n){delete n.output[e]}measureInstanceViewportBox(){return rp()}build(e,n){Object.assign(e.output,n)}renderInstance(e,{output:n}){Object.assign(e,n)}sortInstanceNodePosition(){return 0}}const x7n={offset:"stroke-dashoffset",array:"stroke-dasharray"},k7n={offset:"strokeDashoffset",array:"strokeDasharray"};function E7n(t,e,n=1,r=0,i=!0){t.pathLength=1;const o=i?x7n:k7n;t[o.offset]=`${-r}`,t[o.array]=`${e} ${n}`}const C7n=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Dut(t,{attrX:e,attrY:n,attrScale:r,pathLength:i,pathSpacing:o=1,pathOffset:l=0,...u},d,p,m){if(c1e(t,u,p),d){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:g,style:h}=t;g.transform&&(h.transform=g.transform,delete g.transform),(h.transform||g.transformOrigin)&&(h.transformOrigin=g.transformOrigin??"50% 50%",delete g.transformOrigin),h.transform&&(h.transformBox=m?.transformBox??"fill-box",delete g.transformBox);for(const f of C7n)g[f]!==void 0&&(h[f]=g[f],delete g[f]);e!==void 0&&(g.x=e),n!==void 0&&(g.y=n),r!==void 0&&(g.scale=r),i!==void 0&&E7n(g,i,o,l,!1)}const Nut=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"]),Rut=t=>typeof t=="string"&&t.toLowerCase()==="svg";function S7n(t,e,n,r){Sut(t,e,void 0,r);for(const i in e.attrs)t.setAttribute(Nut.has(i)?i:WEe(i),e.attrs[i])}function Lut(t,e,n){const r=d1e(t,e,n);for(const i in t)if(Bd(t[i])||Bd(e[i])){const o=pP.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[o]=t[i]}return r}class Mut extends fut{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=rp}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(mP.has(n)){const r=Kct(n);return r&&r.default||0}return n=Nut.has(n)?n:WEe(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return Lut(e,n,r)}build(e,n,r){Dut(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,i){S7n(e,n,r,i)}mount(e){this.isSVGTag=Rut(e.tagName),super.mount(e)}}const I7n=a1e.length;function Put(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Put(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<I7n;n++){const r=a1e[n],i=t.props[r];(Ez(i)||i===!1)&&(e[r]=i)}return e}function Out(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}const T7n=[...r1e].reverse(),B7n=r1e.length;function D7n(t){return e=>Promise.all(e.map(({animation:n,options:r})=>Bjn(t,n,r)))}function N7n(t){let e=D7n(t),n=Fut(),r=!0,i=!1;const o=p=>(m,g)=>{const h=KN(t,g,p==="exit"?t.presenceContext?.custom:void 0);if(h){const{transition:f,transitionEnd:b,...y}=h;m={...m,...y,...b}}return m};function l(p){e=p(t)}function u(p){const{props:m}=t,g=Put(t.parent)||{},h=[],f=new Set;let b={},y=1/0;for(let _=0;_<B7n;_++){const w=T7n[_],x=n[w],k=m[w]!==void 0?m[w]:g[w],C=Ez(k),E=w===p?x.isActive:null;E===!1&&(y=_);let S=k===g[w]&&k!==m[w]&&C;if(S&&(r||i)&&t.manuallyAnimateOnMount&&(S=!1),x.protectedKeys={...b},!x.isActive&&E===null||!k&&!x.prevProp||Ane(k)||typeof k=="boolean")continue;if(w==="exit"&&x.isActive&&E!==!0){x.prevResolvedValues&&(b={...b,...x.prevResolvedValues});continue}const I=R7n(x.prevProp,k);let B=I||w===p&&x.isActive&&!S&&C||_>y&&C,N=!1;const L=Array.isArray(k)?k:[k];let M=L.reduce(o(w),{});E===!1&&(M={});const{prevResolvedValues:R={}}=x,D={...R,...M},P=$=>{B=!0,f.has($)&&(N=!0,f.delete($)),x.needsAnimating[$]=!0;const j=t.getValue($);j&&(j.liveStyle=!1)};for(const $ in D){const j=M[$],Q=R[$];if(b.hasOwnProperty($))continue;let z=!1;GEe(j)&&GEe(Q)?z=!Out(j,Q):z=j!==Q,z?j!=null?P($):f.add($):j!==void 0&&f.has($)?P($):x.protectedKeys[$]=!0}x.prevProp=k,x.prevResolvedValues=M,x.isActive&&(b={...b,...M}),(r||i)&&t.blockInitialAnimation&&(B=!1);const O=S&&I;B&&(!O||N)&&h.push(...L.map($=>{const j={type:w};if(typeof $=="string"&&(r||i)&&!O&&t.manuallyAnimateOnMount&&t.parent){const{parent:Q}=t,z=KN(Q,$);if(Q.enteringChildren&&z){const{delayChildren:U}=z.transition||{};j.delay=Fct(Q.enteringChildren,t,U)}}return{animation:$,options:j}}))}if(f.size){const _={};if(typeof m.initial!="boolean"){const w=KN(t,Array.isArray(m.initial)?m.initial[0]:m.initial);w&&w.transition&&(_.transition=w.transition)}f.forEach(w=>{const x=t.getBaseTarget(w),k=t.getValue(w);k&&(k.liveStyle=!0),_[w]=x??null}),h.push({animation:_})}let v=!!h.length;return r&&(m.initial===!1||m.initial===m.animate)&&!t.manuallyAnimateOnMount&&(v=!1),r=!1,i=!1,v?e(h):Promise.resolve()}function d(p,m){if(n[p].isActive===m)return Promise.resolve();t.variantChildren?.forEach(h=>h.animationState?.setActive(p,m)),n[p].isActive=m;const g=u(p);for(const h in n)n[h].protectedKeys={};return g}return{animateChanges:u,setActive:d,setAnimateFunction:l,getState:()=>n,reset:()=>{n=Fut(),i=!0}}}function R7n(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Out(e,t):!1}function XN(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Fut(){return{animate:XN(!0),whileInView:XN(),whileHover:XN(),whileTap:XN(),whileDrag:XN(),whileFocus:XN(),exit:XN()}}function p1e(t,e){t.min=e.min,t.max=e.max}function t_(t,e){p1e(t.x,e.x),p1e(t.y,e.y)}function Qut(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const $ut=1e-4,L7n=1-$ut,M7n=1+$ut,jut=.01,P7n=0-jut,O7n=0+jut;function wf(t){return t.max-t.min}function F7n(t,e,n){return Math.abs(t-e)<=n}function zut(t,e,n,r=.5){t.origin=r,t.originPoint=Nc(e.min,e.max,t.origin),t.scale=wf(n)/wf(e),t.translate=Nc(n.min,n.max,t.origin)-t.originPoint,(t.scale>=L7n&&t.scale<=M7n||isNaN(t.scale))&&(t.scale=1),(t.translate>=P7n&&t.translate<=O7n||isNaN(t.translate))&&(t.translate=0)}function Sz(t,e,n,r){zut(t.x,e.x,n.x,r?r.originX:void 0),zut(t.y,e.y,n.y,r?r.originY:void 0)}function Uut(t,e,n,r=0){const i=r?Nc(n.min,n.max,r):n.min;t.min=i+e.min,t.max=t.min+wf(e)}function Q7n(t,e,n,r){Uut(t.x,e.x,n.x,r?.x),Uut(t.y,e.y,n.y,r?.y)}function qut(t,e,n,r=0){const i=r?Nc(n.min,n.max,r):n.min;t.min=e.min-i,t.max=t.min+wf(e)}function wne(t,e,n,r){qut(t.x,e.x,n.x,r?.x),qut(t.y,e.y,n.y,r?.y)}function Gut(t,e,n,r,i){return t-=e,t=vne(t,1/n,r),i!==void 0&&(t=vne(t,1/i,r)),t}function $7n(t,e=0,n=1,r=.5,i,o=t,l=t){if(vx.test(e)&&(e=parseFloat(e),e=Nc(l.min,l.max,e/100)-l.min),typeof e!="number")return;let u=Nc(o.min,o.max,r);t===o&&(u-=e),t.min=Gut(t.min,e,n,u,i),t.max=Gut(t.max,e,n,u,i)}function Hut(t,e,[n,r,i],o,l){$7n(t,e[n],e[r],e[i],e.scale,o,l)}const j7n=["x","scaleX","originX"],z7n=["y","scaleY","originY"];function Wut(t,e,n,r){Hut(t.x,e,j7n,n?n.x:void 0,r?r.x:void 0),Hut(t.y,e,z7n,n?n.y:void 0,r?r.y:void 0)}function Yut(t){return t.translate===0&&t.scale===1}function Vut(t){return Yut(t.x)&&Yut(t.y)}function Kut(t,e){return t.min===e.min&&t.max===e.max}function U7n(t,e){return Kut(t.x,e.x)&&Kut(t.y,e.y)}function Zut(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Xut(t,e){return Zut(t.x,e.x)&&Zut(t.y,e.y)}function Jut(t){return wf(t.x)/wf(t.y)}function edt(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function xx(t){return[t("x"),t("y")]}function q7n(t,e,n){let r="";const i=t.x.translate/e.x,o=t.y.translate/e.y,l=n?.z||0;if((i||o||l)&&(r=`translate3d(${i}px, ${o}px, ${l}px) `),(e.x!==1||e.y!==1)&&(r+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:p,rotate:m,rotateX:g,rotateY:h,skewX:f,skewY:b}=n;p&&(r=`perspective(${p}px) ${r}`),m&&(r+=`rotate(${m}deg) `),g&&(r+=`rotateX(${g}deg) `),h&&(r+=`rotateY(${h}deg) `),f&&(r+=`skewX(${f}deg) `),b&&(r+=`skewY(${b}deg) `)}const u=t.x.scale*e.x,d=t.y.scale*e.y;return(u!==1||d!==1)&&(r+=`scale(${u}, ${d})`),r||"none"}const tdt=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],G7n=tdt.length,ndt=t=>typeof t=="string"?parseFloat(t):t,rdt=t=>typeof t=="number"||ei.test(t);function H7n(t,e,n,r,i,o){i?(t.opacity=Nc(0,n.opacity??1,W7n(r)),t.opacityExit=Nc(e.opacity??1,0,Y7n(r))):o&&(t.opacity=Nc(e.opacity??1,n.opacity??1,r));for(let l=0;l<G7n;l++){const u=tdt[l];let d=adt(e,u),p=adt(n,u);if(d===void 0&&p===void 0)continue;d||(d=0),p||(p=0),d===0||p===0||rdt(d)===rdt(p)?(t[u]=Math.max(Nc(ndt(d),ndt(p),r),0),(vx.test(p)||vx.test(d))&&(t[u]+="%")):t[u]=p}(e.rotate||n.rotate)&&(t.rotate=Nc(e.rotate||0,n.rotate||0,r))}function adt(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const W7n=idt(0,.5,Hlt),Y7n=idt(.5,.95,oy);function idt(t,e,n){return r=>r<t?0:r>e?1:n(oP(t,e,r))}function sdt(t,e,n){const r=Bd(t)?t:wI(t);return r.start(UEe("",r,e,n)),r.animation}function Iz(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}const V7n=(t,e)=>t.depth-e.depth;class K7n{constructor(){this.children=[],this.isDirty=!1}add(e){cEe(this.children,e),this.isDirty=!0}remove(e){iP(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(V7n),this.isDirty=!1,this.children.forEach(e)}}function Z7n(t,e){const n=_f.now(),r=({timestamp:i})=>{const o=i-n;o>=e&&(O1(r),t(o-e))};return Fl.setup(r,!0),()=>O1(r)}function xne(t){return Bd(t)?t.get():t}class X7n{constructor(){this.members=[]}add(e){cEe(this.members,e);for(let n=this.members.length-1;n>=0;n--){const r=this.members[n];if(r===e||r===this.lead||r===this.prevLead)continue;const i=r.instance;(!i||i.isConnected===!1)&&!r.snapshot&&(iP(this.members,r),r.unmount())}e.scheduleRender()}remove(e){if(iP(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){for(let n=this.members.indexOf(e)-1;n>=0;n--){const r=this.members[n];if(r.isPresent!==!1&&r.instance?.isConnected!==!1)return this.promote(r),!0}return!1}promote(e,n){const r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.updateSnapshot(),e.scheduleRender();const{layoutDependency:i}=r.options,{layoutDependency:o}=e.options;(i===void 0||i!==o)&&(e.resumeFrom=r,n&&(r.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}const kne={hasAnimatedSinceResize:!0,hasEverUpdated:!1},m1e=["","X","Y","Z"],J7n=1e3;let ezn=0;function g1e(t,e,n,r){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),r&&(r[t]=0))}function odt(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Gct(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Fl,!(i||o))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&odt(r)}function ldt({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(l={},u=e?.()){this.id=ezn++,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.layoutVersion=0,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(rzn),this.nodes.forEach(czn),this.nodes.forEach(uzn),this.nodes.forEach(azn)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=u?u.root||u:this,this.path=u?[...u.path,u]:[],this.parent=u,this.depth=u?u.depth+1:0;for(let d=0;d<this.path.length;d++)this.path[d].shouldResetTransform=!0;this.root===this&&(this.nodes=new K7n)}addEventListener(l,u){return this.eventHandlers.has(l)||this.eventHandlers.set(l,new dEe),this.eventHandlers.get(l).add(u)}notifyListeners(l,...u){const d=this.eventHandlers.get(l);d&&d.notify(...u)}hasListeners(l){return this.eventHandlers.has(l)}mount(l){if(this.instance)return;this.isSVG=mne(l)&&!out(l),this.instance=l;const{layoutId:u,layout:d,visualElement:p}=this.options;if(p&&!p.current&&p.mount(l),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(d||u)&&(this.isLayoutDirty=!0),t){let m,g=0;const h=()=>this.root.updateBlockedByResize=!1;Fl.read(()=>{g=window.innerWidth}),t(l,()=>{const f=window.innerWidth;f!==g&&(g=f,this.root.updateBlockedByResize=!0,m&&m(),m=Z7n(h,250),kne.hasAnimatedSinceResize&&(kne.hasAnimatedSinceResize=!1,this.nodes.forEach(ddt)))})}u&&this.root.registerSharedNode(u,this),this.options.animate!==!1&&p&&(u||d)&&this.addEventListener("didUpdate",({delta:m,hasLayoutChanged:g,hasRelativeLayoutChanged:h,layout:f})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||p.getDefaultTransition()||hzn,{onLayoutAnimationStart:y,onLayoutAnimationComplete:v}=p.getProps(),_=!this.targetLayout||!Xut(this.targetLayout,f),w=!g&&h;if(this.options.layoutRoot||this.resumeFrom||w||g&&(_||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const x={...zEe(b,"layout"),onPlay:y,onComplete:v};(p.shouldReduceMotion||this.options.layoutRoot)&&(x.delay=0,x.type=!1),this.startAnimation(x),this.setAnimationOrigin(m,w)}else g||ddt(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=f})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),O1(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(dzn),this.animationId++)}getTransformTemplate(){const{visualElement:l}=this.options;return l&&l.getProps().transformTemplate}willUpdate(l=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&odt(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let m=0;m<this.path.length;m++){const g=this.path[m];g.shouldResetTransform=!0,(typeof g.latestValues.x=="string"||typeof g.latestValues.y=="string")&&(g.isLayoutDirty=!0),g.updateScroll("snapshot"),g.options.layoutRoot&&g.willUpdate(!1)}const{layoutId:u,layout:d}=this.options;if(u===void 0&&!d)return;const p=this.getTransformTemplate();this.prevTransformTemplateValue=p?p(this.latestValues,""):void 0,this.updateSnapshot(),l&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const d=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),d&&this.nodes.forEach(szn),this.nodes.forEach(cdt);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(udt);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ozn),this.nodes.forEach(lzn),this.nodes.forEach(tzn),this.nodes.forEach(nzn)):this.nodes.forEach(udt),this.clearAllSnapshots();const u=_f.now();bg.delta=yx(0,1e3/60,u-bg.timestamp),bg.timestamp=u,bg.isProcessing=!0,fEe.update.process(bg),fEe.preRender.process(bg),fEe.render.process(bg),bg.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,JEe.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(izn),this.sharedNodes.forEach(pzn)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Fl.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Fl.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!wf(this.snapshot.measuredBox.x)&&!wf(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 d=0;d<this.path.length;d++)this.path[d].updateScroll();const l=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=rp()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:u}=this.options;u&&u.notify("LayoutMeasure",this.layout.layoutBox,l?l.layoutBox:void 0)}updateScroll(l="measure"){let u=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===l&&(u=!1),u&&this.instance){const d=r(this.instance);this.scroll={animationId:this.root.animationId,phase:l,isRoot:d,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:d}}}resetTransform(){if(!i)return;const l=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,u=this.projectionDelta&&!Vut(this.projectionDelta),d=this.getTransformTemplate(),p=d?d(this.latestValues,""):void 0,m=p!==this.prevTransformTemplateValue;l&&this.instance&&(u||ZN(this.latestValues)||m)&&(i(this.instance,p),this.shouldResetTransform=!1,this.scheduleRender())}measure(l=!0){const u=this.measurePageBox();let d=this.removeElementScroll(u);return l&&(d=this.removeTransform(d)),fzn(d),{animationId:this.root.animationId,measuredBox:u,layoutBox:d,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:l}=this.options;if(!l)return rp();const u=l.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Azn))){const{scroll:p}=this.root;p&&(_x(u.x,p.offset.x),_x(u.y,p.offset.y))}return u}removeElementScroll(l){const u=rp();if(t_(u,l),this.scroll?.wasRoot)return u;for(let d=0;d<this.path.length;d++){const p=this.path[d],{scroll:m,options:g}=p;p!==this.root&&m&&g.layoutScroll&&(m.wasRoot&&t_(u,l),_x(u.x,m.offset.x),_x(u.y,m.offset.y))}return u}applyTransform(l,u=!1,d){const p=d||rp();t_(p,l);for(let m=0;m<this.path.length;m++){const g=this.path[m];!u&&g.options.layoutScroll&&g.scroll&&g!==g.root&&(_x(p.x,-g.scroll.offset.x),_x(p.y,-g.scroll.offset.y)),ZN(g.latestValues)&&_ne(p,g.latestValues,g.layout?.layoutBox)}return ZN(this.latestValues)&&_ne(p,this.latestValues,this.layout?.layoutBox),p}removeTransform(l){const u=rp();t_(u,l);for(let d=0;d<this.path.length;d++){const p=this.path[d];if(!ZN(p.latestValues))continue;let m;p.instance&&(o1e(p.latestValues)&&p.updateSnapshot(),m=rp(),t_(m,p.measurePageBox())),Wut(u,p.latestValues,p.snapshot?.layoutBox,m)}return ZN(this.latestValues)&&Wut(u,this.latestValues),u}setTargetDelta(l){this.targetDelta=l,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(l){this.options={...this.options,...l,crossfade:l.crossfade!==void 0?l.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!==bg.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(l=!1){const u=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=u.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=u.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=u.isSharedProjectionDirty);const d=!!this.resumingFrom||this!==u;if(!(l||d&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:m,layoutId:g}=this.options;if(!this.layout||!(m||g))return;this.resolvedRelativeTargetAt=bg.timestamp;const h=this.getClosestProjectingParent();h&&this.linkedParentVersion!==h.layoutVersion&&!h.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&h&&h.layout?this.createRelativeTarget(h,this.layout.layoutBox,h.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=rp(),this.targetWithTransforms=rp()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Q7n(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):t_(this.target,this.layout.layoutBox),_ut(this.target,this.targetDelta)):t_(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&h&&!!h.resumingFrom==!!this.resumingFrom&&!h.options.layoutScroll&&h.target&&this.animationProgress!==1?this.createRelativeTarget(h,this.target,h.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||o1e(this.parent.latestValues)||but(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(l,u,d){this.relativeParent=l,this.linkedParentVersion=l.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=rp(),this.relativeTargetOrigin=rp(),wne(this.relativeTargetOrigin,u,d,this.options.layoutAnchor||void 0),t_(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const l=this.getLead(),u=!!this.resumingFrom||this!==l;let d=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(d=!1),u&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(d=!1),this.resolvedRelativeTargetAt===bg.timestamp&&(d=!1),d)return;const{layout:p,layoutId:m}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(p||m))return;t_(this.layoutCorrected,this.layout.layoutBox);const g=this.treeScale.x,h=this.treeScale.y;g7n(this.layoutCorrected,this.treeScale,this.path,u),l.layout&&!l.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(l.target=l.layout.layoutBox,l.targetWithTransforms=rp());const{target:f}=l;if(!f){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Qut(this.prevProjectionDelta.x,this.projectionDelta.x),Qut(this.prevProjectionDelta.y,this.projectionDelta.y)),Sz(this.projectionDelta,this.layoutCorrected,f,this.latestValues),(this.treeScale.x!==g||this.treeScale.y!==h||!edt(this.projectionDelta.x,this.prevProjectionDelta.x)||!edt(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",f))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(l=!0){if(this.options.visualElement?.scheduleRender(),l){const u=this.getStack();u&&u.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=hP(),this.projectionDelta=hP(),this.projectionDeltaWithTransform=hP()}setAnimationOrigin(l,u=!1){const d=this.snapshot,p=d?d.latestValues:{},m={...this.latestValues},g=hP();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!u;const h=rp(),f=d?d.source:void 0,b=this.layout?this.layout.source:void 0,y=f!==b,v=this.getStack(),_=!v||v.members.length<=1,w=!!(y&&!_&&this.options.crossfade===!0&&!this.path.some(gzn));this.animationProgress=0;let x;this.mixTargetDelta=k=>{const C=k/1e3;pdt(g.x,l.x,C),pdt(g.y,l.y,C),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(wne(h,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),mzn(this.relativeTarget,this.relativeTargetOrigin,h,C),x&&U7n(this.relativeTarget,x)&&(this.isProjectionDirty=!1),x||(x=rp()),t_(x,this.relativeTarget)),y&&(this.animationValues=m,H7n(m,p,this.latestValues,C,w,_)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=C},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(O1(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Fl.update(()=>{kne.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=wI(0)),this.motionValue.jump(0,!1),this.currentAnimation=sdt(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),l.onUpdate&&l.onUpdate(u)},onStop:()=>{},onComplete:()=>{l.onComplete&&l.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 l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(J7n),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:u,target:d,layout:p,latestValues:m}=l;if(!(!u||!d||!p)){if(this!==l&&this.layout&&p&&Adt(this.options.animationType,this.layout.layoutBox,p.layoutBox)){d=this.target||rp();const g=wf(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+g;const h=wf(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+h}t_(u,d),_ne(u,m),Sz(this.projectionDeltaWithTransform,this.layoutCorrected,u,m)}}registerSharedNode(l,u){this.sharedNodes.has(l)||this.sharedNodes.set(l,new X7n),this.sharedNodes.get(l).add(u);const p=u.options.initialPromotionConfig;u.promote({transition:p?p.transition:void 0,preserveFollowOpacity:p&&p.shouldPreserveFollowOpacity?p.shouldPreserveFollowOpacity(u):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){const{layoutId:l}=this.options;return l?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:l}=this.options;return l?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:u,preserveFollowOpacity:d}={}){const p=this.getStack();p&&p.promote(this,d),l&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let u=!1;const{latestValues:d}=l;if((d.z||d.rotate||d.rotateX||d.rotateY||d.rotateZ||d.skewX||d.skewY)&&(u=!0),!u)return;const p={};d.z&&g1e("z",l,p,this.animationValues);for(let m=0;m<m1e.length;m++)g1e(`rotate${m1e[m]}`,l,p,this.animationValues),g1e(`skew${m1e[m]}`,l,p,this.animationValues);l.render();for(const m in p)l.setStaticValue(m,p[m]),this.animationValues&&(this.animationValues[m]=p[m]);l.scheduleRender()}applyProjectionStyles(l,u){if(!this.instance||this.isSVG)return;if(!this.isVisible){l.visibility="hidden";return}const d=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,l.visibility="",l.opacity="",l.pointerEvents=xne(u?.pointerEvents)||"",l.transform=d?d(this.latestValues,""):"none";return}const p=this.getLead();if(!this.projectionDelta||!this.layout||!p.target){this.options.layoutId&&(l.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,l.pointerEvents=xne(u?.pointerEvents)||""),this.hasProjected&&!ZN(this.latestValues)&&(l.transform=d?d({},""):"none",this.hasProjected=!1);return}l.visibility="";const m=p.animationValues||p.latestValues;this.applyTransformsToTarget();let g=q7n(this.projectionDeltaWithTransform,this.treeScale,m);d&&(g=d(m,g)),l.transform=g;const{x:h,y:f}=this.projectionDelta;l.transformOrigin=`${h.origin*100}% ${f.origin*100}% 0`,p.animationValues?l.opacity=p===this?m.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:m.opacityExit:l.opacity=p===this?m.opacity!==void 0?m.opacity:"":m.opacityExit!==void 0?m.opacityExit:0;for(const b in u1e){if(m[b]===void 0)continue;const{correct:y,applyTo:v,isCSSVariable:_}=u1e[b],w=g==="none"?m[b]:y(m[b],p);if(v){const x=v.length;for(let k=0;k<x;k++)l[v[k]]=w}else _?this.options.visualElement.renderState.vars[b]=w:l[b]=w}this.options.layoutId&&(l.pointerEvents=p===this?xne(u?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(l=>l.currentAnimation?.stop()),this.root.nodes.forEach(cdt),this.root.sharedNodes.clear()}}}function tzn(t){t.updateLayout()}function nzn(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;if(i==="size")xx(m=>{const g=o?e.measuredBox[m]:e.layoutBox[m],h=wf(g);g.min=n[m].min,g.max=g.min+h});else if(i==="x"||i==="y"){const m=i==="x"?"y":"x";p1e(o?e.measuredBox[m]:e.layoutBox[m],n[m])}else Adt(i,e.layoutBox,n)&&xx(m=>{const g=o?e.measuredBox[m]:e.layoutBox[m],h=wf(n[m]);g.max=g.min+h,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[m].max=t.relativeTarget[m].min+h)});const l=hP();Sz(l,n,e.layoutBox);const u=hP();o?Sz(u,t.applyTransform(r,!0),e.measuredBox):Sz(u,n,e.layoutBox);const d=!Vut(l);let p=!1;if(!t.resumeFrom){const m=t.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:g,layout:h}=m;if(g&&h){const f=t.options.layoutAnchor||void 0,b=rp();wne(b,e.layoutBox,g.layoutBox,f);const y=rp();wne(y,n,h.layoutBox,f),Xut(b,y)||(p=!0),m.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=b,t.relativeParent=m)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:u,layoutDelta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function rzn(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function azn(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function izn(t){t.clearSnapshot()}function cdt(t){t.clearMeasurements()}function szn(t){t.isLayoutDirty=!0,t.updateLayout()}function udt(t){t.isLayoutDirty=!1}function ozn(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function lzn(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function ddt(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function czn(t){t.resolveTargetDelta()}function uzn(t){t.calcProjection()}function dzn(t){t.resetSkewAndRotation()}function pzn(t){t.removeLeadSnapshot()}function pdt(t,e,n){t.translate=Nc(e.translate,0,n),t.scale=Nc(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function mdt(t,e,n,r){t.min=Nc(e.min,n.min,r),t.max=Nc(e.max,n.max,r)}function mzn(t,e,n,r){mdt(t.x,e.x,n.x,r),mdt(t.y,e.y,n.y,r)}function gzn(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const hzn={duration:.45,ease:[.4,0,.1,1]},gdt=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),hdt=gdt("applewebkit/")&&!gdt("chrome/")?Math.round:oy;function fdt(t){t.min=hdt(t.min),t.max=hdt(t.max)}function fzn(t){fdt(t.x),fdt(t.y)}function Adt(t,e,n){return t==="position"||t==="preserve-aspect"&&!F7n(Jut(e),Jut(n),.2)}function Azn(t){return t!==t.root&&t.scroll?.wasRoot}const bzn=ldt({attachResizeListener:(t,e)=>Iz(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),yzn=t=>!t.isLayoutDirty&&t.willUpdate(!1);function bdt(){const t=new Set,e=new WeakMap,n=()=>t.forEach(yzn);return{add:r=>{t.add(r),e.set(r,r.addEventListener("willUpdate",n))},remove:r=>{t.delete(r);const i=e.get(r);i&&(i(),e.delete(r)),n()},dirty:n}}const h1e={current:void 0},ydt=ldt({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!h1e.current){const t=new bzn({});t.mount(window),t.setOptions({layoutScroll:!0}),h1e.current=t}return h1e.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Tz=T.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function vdt(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function vzn(...t){return e=>{let n=!1;const r=t.map(i=>{const o=vdt(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<r.length;i++){const o=r[i];typeof o=="function"?o():vdt(t[i],null)}}}}function _zn(...t){return ee.useCallback(vzn(...t),t)}class wzn extends ee.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(dne(n)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const r=n.offsetParent,i=dne(r)&&r.offsetWidth||0,o=dne(r)&&r.offsetHeight||0,l=getComputedStyle(n),u=this.props.sizeRef.current;u.height=parseFloat(l.height),u.width=parseFloat(l.width),u.top=n.offsetTop,u.left=n.offsetLeft,u.right=i-u.width-u.left,u.bottom=o-u.height-u.top}return null}componentDidUpdate(){}render(){return this.props.children}}function xzn({children:t,isPresent:e,anchorX:n,anchorY:r,root:i,pop:o}){const l=T.useId(),u=T.useRef(null),d=T.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:p}=T.useContext(Tz),m=t.props?.ref??t?.ref,g=_zn(u,m);return T.useInsertionEffect(()=>{const{width:h,height:f,top:b,left:y,right:v,bottom:_}=d.current;if(e||o===!1||!u.current||!h||!f)return;const w=n==="left"?`left: ${y}`:`right: ${v}`,x=r==="bottom"?`bottom: ${_}`:`top: ${b}`;u.current.dataset.motionPopId=l;const k=document.createElement("style");p&&(k.nonce=p);const C=i??document.head;return C.appendChild(k),k.sheet&&k.sheet.insertRule(`
111
111
  [data-motion-pop-id="${l}"] {
112
112
  position: absolute !important;
113
113
  width: ${h}px !important;