@sciol/xyzen 1.9.79-beta.4cc7ddd → 1.9.79-beta.e08d924
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.es.js +47 -64
- package/dist/xyzen.umd.js +2 -2
- package/package.json +1 -1
package/dist/xyzen.umd.js
CHANGED
|
@@ -107,7 +107,7 @@ border-radius:50%;animation:spin .8s linear infinite;margin:0 auto}
|
|
|
107
107
|
${d}`:d;break}}(i.data!==void 0||i.event!==void 0)&&(yield{event:i,remaining:e})}yield{event:{},remaining:e}}class ZOn{connections=new Map;retryTimeouts=new Map;constructor(){setTimeout(()=>{try{ad().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=ad().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=Co.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=ad().streamingFetch,p=await d(u,{headers:l,signal:r.signal});if(!p.ok){if(p.status===401){Co.removeToken(),i.onStatusChange({connected:!1,error:"Authentication failed"}),U5n();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 KOn(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.error(`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>=WOn){r.onStatusChange({connected:!1,error:"Connection closed. Please refresh the page."}),this.connections.delete(n);return}const i=Math.min(YOn*Math.pow(2,e.retryCount),VOn);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 jb=new ZOn;class XOn{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 pg=new XOn,ox=787,Gv="Asia/Shanghai",Jxe=576,eke=640,BN="app.chatConfig.defaultTitle",Sot="/workspace";class JOn{getProviderDisplayName(e){return{openai:"OpenAI",azure_openai:"Azure OpenAI",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}`)}}const O7=new JOn;class eFn{defaultModelConfig=null;defaultModelConfigPromise=null;async getDefaultModelConfig(){return this.defaultModelConfig?this.defaultModelConfig:this.defaultModelConfigPromise?this.defaultModelConfigPromise:(this.defaultModelConfigPromise=O7.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 Iot=new eFn,v1=new Map,FP=new Set,tFn=5e3,nFn=100;function Tot(t){jb.disconnect(t);const e=v1.get(t);e&&(clearTimeout(e),v1.delete(t))}function rFn(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 Rp.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)}),pg.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 Rp.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}),jb.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(!FP.has(u)){FP.add(u);try{try{const d=await Rp.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]=wot(h,m)}),await e().activateChannel(p.id)}else{const p=await pg.createTopic({name:no.t(BN),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 ug&&d.status===404?await e().createDefaultChannel(l):(console.error("Failed to activate channel for agent:",d),await e().createDefaultChannel(l))}}finally{FP.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(!FP.has(d)){FP.add(d);try{const p=u;let m;try{m=await Rp.getSessionByAgent(p)}catch(y){if(y instanceof ug&&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 O7.getMyProviders(),S=await Iot.getDefaultProviderAndModel(E);k=k||S.providerId||void 0,C=C||S.model||void 0}k&&C&&(await Rp.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 pg.createTopic({name:no.t(BN),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 O7.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 Iot.getDefaultProviderAndModel(f);y&&v&&(h.provider_id=y,h.model=v)}}catch(y){console.error("Error getting provider/model:",y)}const b=await Rp.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 pg.createTopic({name:no.t(BN),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{FP.delete(d)}}},updateTopicName:async(l,u)=>{try{await pg.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 pg.deleteTopic(l),Tot(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&&Tot(p);await Rp.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 Rp.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 Rp.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]=wot(f,g)})}await e().activateChannel(l)},updateSessionProviderAndModel:async(l,u,d)=>{try{await Rp.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 aFn{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);Xxe(n)})}applyStreamingChunk(e,n){const r=ix(e,n.id,n.execution_id);if(r===-1){e.messages.push({id:n.id,streamId:n.id,clientId:IN(),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 iFn(t,e){if(t.responding=!0,ix(t,e)!==-1)return;TN(t)===-1&&t.messages.push({id:e,streamId:e,clientId:IN(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"pending",isNewMessage:!0})}function oFn(t,e){t.responding=!0;let n=ix(t,e.stream_id,e.execution_id);if(n===-1&&(n=TN(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:IN(),role:"assistant",content:"",isNewMessage:!0,created_at:new Date().toISOString(),status:"streaming"})}function sFn(t,e){let n=ix(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
109
|
`);i&&(r.content=i)}r.agentExecution?.status==="running"||ute(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 lFn(t,e){t.messages.some(n=>n.id===e.id)||t.messages.push({...e,status:e.status||"completed",isNewMessage:!0})}function cFn(t,e){let n=ix(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&&!yot(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"||ute(i,{status:"completed",onlyIfRunning:!0})}}function uFn(t,e){t.responding=!0;const n=TN(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=P7(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 Vho(t,e){}function dFn(t,e){t.responding=!0;const{context:n}=e;let r=-1;n.stream_id&&(r=ix(t,n.stream_id)),r===-1&&(r=TN(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:IN(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"pending",isNewMessage:!0,agentExecution:i})}function pFn(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?ute(i,{status:e.status==="completed"?"completed":e.status==="cancelled"?"cancelled":"failed",durationMs:e.duration_ms}):Kxe(i)}}function mFn(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},ute(i,{status:"failed"})):Kxe(i)}}function gFn(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=UOn(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 hFn(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 fFn(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 AFn(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 bFn(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 yFn(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=ix(t,e.stream_id);r===-1&&(r=TN(t)),r===-1&&(r=qOn(t)),r===-1&&(r=P7(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:IN(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"failed",isNewMessage:!0,error:n}),console.error("Chat error:",e.error_code||e.error)}function vFn(t,e){console.warn("Insufficient balance:",e),t.responding=!1;let n=ix(t,e.stream_id);return n===-1&&(n=TN(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 _Fn(t,e){console.warn("Parallel chat limit reached:",e),t.responding=!1;const n=TN(t);return n!==-1&&t.messages.splice(n,1),{isOpen:!0,title:"并行会话已达上限",message:`您已达到并行会话上限(${e.current??"?"}/${e.limit??"?"})。请等待其他会话完成后重试。`,type:"warning"}}function wFn(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,Zxe(t)}function xFn(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=P7(t);if(i===-1&&e.stream_id&&(i=ix(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:IN(),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 kFn(t,e){const n=P7(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 EFn(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 CFn(t,e){const n=xot(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 SFn(t,e){const n=xot(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 IFn(t,e){t.contextUsage={estimatedTokens:e.estimated_tokens,maxTokens:e.max_tokens,usagePercent:e.usage_percent,nearLimit:e.near_limit,critical:e.critical}}function TFn(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 BFn(t,e){let n=ix(t,e.stream_id);if(n===-1&&(n=P7(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=TFn(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 F7=new Map;function DFn(t,e,n){const{updateDerivedStatus:r,closeIdleNonPrimaryConnection:i}=n;return{connectToChannel:(o,l)=>{console.debug(`[connectToChannel] topic=${l.slice(0,8)} hasExistingSSE=${jb.hasConnection(l)} msgs=${e().channels[l]?.messages.length}`),F7.get(l)?.destroy();const u=new aFn(m=>{t(g=>{const h=g.channels[l];h&&m(h)})});F7.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":{iFn(v,g.data.stream_id);break}case"streaming_start":{oFn(v,g.data);break}case"streaming_end":{sFn(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}}lFn(v,_);break}case"search_citations":{CFn(v,g.data);break}case"generated_files":{SFn(v,g.data);break}case"message_saved":{cFn(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":{xFn(v,g.data);break}case"tool_call_response":{kFn(v,g.data);break}case"error":{yFn(v,g.data);break}case"insufficient_balance":{const _=vFn(v,g.data);_&&(y.notification={..._,onAction:()=>window.open(_.actionUrl,"_blank")});break}case"parallel_chat_limit":{const _=_Fn(v,g.data);y.notification=_;break}case"stream_aborted":{wFn(v,g.data,v1);break}case"thinking_start":{uFn(v,g.data);break}case"thinking_end":{g.data;break}case"topic_updated":{EFn(v,g.data,y.chatHistory);break}case"agent_start":{dFn(v,g.data);break}case"agent_end":{pFn(v,g.data);break}case"agent_error":{mFn(v,g.data);break}case"node_start":{gFn(v,g.data);break}case"node_end":{hFn(v,g.data);break}case"subagent_start":{fFn(v,g.data);break}case"subagent_end":{AFn(v,g.data);break}case"progress_update":{bFn(v,g.data);break}case"ask_user_question":{BFn(v,g.data);break}case"token_usage":{const{total_tokens:_}=g.data;v.tokenUsage=_;break}case"context_usage":{IFn(v,g.data);break}}Xxe(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&&Rp.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(jb.hasConnection(l)){jb.updateCallbacks(l,{onMessageEvent:d,onStatusChange:m=>{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=jb.getOpenTopicIds();for(const m of p){if(m===l)continue;e().channels[m]?.responding||jb.disconnect(m)}t(m=>{Object.entries(m.channels).forEach(([g,h])=>{jb.hasConnection(g)||(h.connected=!1)}),m.channels[l]&&(m.channels[l].error=null)}),jb.connect(l,{onMessageEvent:d,onStatusChange:m=>{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 F7)o.destroy();F7.clear();for(const[o,l]of v1)clearTimeout(l),v1.delete(o);jb.disconnectAll()},abortGeneration:o=>{pg.abort(o).catch(p=>{console.error("Failed to send abort signal:",p)});const l=v1.get(o);l&&(clearTimeout(l),v1.delete(o));const u=F7.get(o);u&&u.destroy(),t(p=>{const m=p.channels[o];m&&(m.aborting=!0,Zxe(m))}),r();const d=setTimeout(()=>{v1.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,Zxe(h))}),r())},1e4);v1.set(o,d)},respondToQuestion:(o,l,u)=>{pg.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 NFn=["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"],RFn=[".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"];class LFn{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=Co.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=NFn}=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")||RFn.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 ys=new LFn;class MFn{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 MFn;function PFn(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}jb.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=IN(),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:ys.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 pg.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(no.t("app.chat.parallelLimitTitle","Parallel chat limit reached"),no.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(no.t("app.chat.insufficientBalance","Insufficient balance"),no.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",no.t("app.message.editFailed"),"error")}},triggerRegeneration:()=>{const{activeChatChannel:o}=e();if(o){if(!jb.hasConnection(o)){console.warn("[triggerRegeneration] No SSE connection, skipping");return}t(l=>{const u=l.channels[o];u&&(u.responding=!0)}),pg.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(!yot(o)){const g=d.messages.find(h=>h.id===o)?.status==="streaming"?no.t("app.message.deleteStillStreaming"):no.t("app.message.deleteNotSaved");console.error(`Cannot delete message: ${g} (id: ${o.slice(0,20)}...)`),e().showNotification(no.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",no.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 dte=50,OFn=(t,e)=>{const n=d=>d&&e().resolveAgent(d)?.name||"通用助理",r=async(d,p)=>{const m=Date.now();for(;Date.now()-m<=tFn;){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,nFn)})}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=zOn(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([pg.getMessages(d,{limit:dte}),pg.getTokenStats(d).catch(()=>null)]),b=Hxe(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>=dte,f?.total_tokens!=null&&(v.tokenUsage=f.total_tokens),Xxe(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||jb.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 pg.getMessages(d,{before:m.id,limit:dte}),h=Hxe(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>=dte,b.loadingOlderMessages=!1}})}catch(g){console.error("Failed to load older messages:",g),t(h=>{const f=h.channels[d];f&&(f.loadingOlderMessages=!1)})}}},...rFn(t,e,u),...PFn(t,e,u),...DFn(t,e,u)}},FFn={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 DN(t){return(t/(1024*1024)).toFixed(1)}function Dot(t){const e=t.slice(0,3).map(r=>r.name).join(", "),n=t.length>3?no.t("app.input.moreFilesSuffix",{count:t.length-3}):"";return e+n}function Not(t,e){switch(e.reason){case"file_too_large":return no.t("app.input.fileTooLargeDetail",{name:t.name,maxSize:DN(e.maxSize??t.size),actualSize:DN(e.actualSize??t.size)});case"unsupported_type":return no.t("app.input.unsupportedFileTypeDetail",{name:t.name});default:return e.error||t.name}}const QFn=(t,e)=>({uploadedFiles:[],isUploading:!1,uploadError:null,fileUploadOptions:{...FFn},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=ys.validateFile(m,{maxSize:i.maxSize,allowedTypes:i.allowedTypes});g.valid||l.push(Not(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(no.t("app.input.totalSizeExceededMessage",{maxSize:DN(i.maxTotalSize||20*1024*1024),actualSize:DN(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=ys.validateFile(C,{maxSize:i.maxSize,allowedTypes:i.allowedTypes});E.valid?l.push(C):(u.push({file:C,validation:E}),d.push(Not(C,E)))}const p=u.filter(({validation:C})=>C.reason==="file_too_large").map(({file:C})=>C);p.length>0&&e().showNotification(no.t("app.input.fileTooLargeTitle"),no.t("app.input.fileTooLargeMessage",{files:Dot(p),maxSize:DN(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(no.t("app.input.unsupportedFilesTitle"),no.t("app.input.unsupportedFilesMessage",{files:Dot(m)}),"warning");const g=Math.max(0,(i.maxFiles||5)-o.length);if(g===0){const C=no.t("app.dragDrop.maxReached");t({uploadError:C}),e().showNotification(no.t("app.input.fileLimitTitle"),C,"warning");return}const h=l.slice(0,g);l.slice(g).length>0&&e().showNotification(no.t("app.input.fileLimitTitle"),no.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=no.t("app.input.totalSizeExceededMessage",{maxSize:DN(b),actualSize:DN(v)});t({uploadError:C}),e().showNotification(no.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:ys.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 ys.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 ys.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&&ys.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&&ys.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 ys.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 $Fn{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 pf=new $Fn,jFn=(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 pf.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 pf.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)})}}),zFn=(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={}})}}),NA={MCP_SERVERS:"mcpServers",MCP_SERVER_CREATE:"mcpServerCreate",MCP_SERVER_UPDATE:"mcpServerUpdate",MCP_SERVER_DELETE:"mcpServerDelete"},_1={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 UFn(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 qFn(t){return Array.isArray(t)?t.filter(e=>e&&typeof e=="object").map(e=>UFn(e)):(console.warn("convertBuiltinServers: input is not an array",t),[])}const GFn=(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(NA.MCP_SERVERS,!0);try{console.log("McpSlice: Starting to fetch MCP servers...");const o=await _1.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(NA.MCP_SERVERS,!1)}},fetchBuiltinMcpServers:async()=>{try{const n=await _1.getBuiltinMcpServers(),r=qFn(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(NA.MCP_SERVERS,!0);try{await _1.refreshMcpServers(),setTimeout(()=>{e().fetchMcpServers()},1e3)}catch(r){console.error("Failed to refresh MCP servers:",r)}finally{setTimeout(()=>n(NA.MCP_SERVERS,!1),1500)}},addMcpServer:async n=>{const{setLoading:r}=e();r(NA.MCP_SERVER_CREATE,!0);try{const i=await _1.createMcpServer(n);t(o=>{o.mcpServers.push(i)}),e().closeAddMcpServerModal()}catch(i){throw console.error("Failed to add MCP server:",i),i}finally{r(NA.MCP_SERVER_CREATE,!1)}},quickAddBuiltinServer:async n=>{const{backendUrl:r,token:i,setLoading:o}=e();o(NA.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 _1.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(NA.MCP_SERVER_CREATE,!1)}},activateSmitheryServer:async(n,r)=>{const{setLoading:i}=e();i(NA.MCP_SERVER_CREATE,!0);try{const o=await _1.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(NA.MCP_SERVER_CREATE,!1)}},editMcpServer:async(n,r)=>{const{setLoading:i}=e();i(NA.MCP_SERVER_UPDATE,!0);try{const o=await _1.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(NA.MCP_SERVER_UPDATE,!1)}},removeMcpServer:async n=>{const{setLoading:r}=e();r(NA.MCP_SERVER_DELETE,!0);try{await _1.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(NA.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)})}}),HFn=(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})}}),WFn=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 tke{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 YFn(t,e){if(t?.provider_id){const o=e.find(l=>l.id===t.provider_id);if(o)return o}const n=tke.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 VFn=(t,e)=>({userDefaultProviderId:null,initializeProviderPreferences:()=>{const n=tke.getDefaultProviderId();t({userDefaultProviderId:n})},setUserDefaultProvider:n=>{tke.setDefaultProvider(n),t({userDefaultProviderId:n})},getUserDefaultProvider:n=>{const{userDefaultProviderId:r}=e();return r&&n.find(i=>i.id===r)||null},resolveProviderForAgent:(n,r)=>YFn(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 KFn{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 pte=new KFn;class ZFn{ws=null;handlers=new Map;reconnectTimer=null;reconnectDelay=1e3;maxReconnectDelay=3e4;intentionalClose=!1;connect(){if(this.ws?.readyState===WebSocket.OPEN)return;const e=Co.getToken();if(!e)return;const n=ad().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 QP=new ZFn,XFn=(t,e)=>({runners:[],runnersLoading:!1,fetchRunners:async()=>{t({runnersLoading:!0});try{const n=await pte.listRunners();t({runners:n,runnersLoading:!1})}catch{t({runnersLoading:!1})}},createRunnerToken:async n=>{try{const r=await pte.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 pte.deleteRunner(n),t(r=>{r.runners=r.runners.filter(i=>i.id!==n)})}catch{}},updateRunner:async(n,r)=>{try{const i=await pte.updateRunner(n,r);t(o=>{const l=o.runners.findIndex(u=>u.id===n);l>=0&&(o.runners[l]=i)})}catch{}},connectRunnerEvents:()=>{QP.connect();const n=QP.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(),QP.disconnect()}}}),JFn=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})}}),Rot={Sidebar:"sidebar"},e8n=t=>({backendUrl:ad().env.backendUrl,isXyzenOpen:!1,panelWidth:eke,activeTabIndex:0,activePanel:"chat",theme:ad().storage.getItem("theme")||"system",layoutStyle:ad().storage.getItem("layoutStyle")||ad().env.layoutStyle||Rot.Sidebar,inputPosition:ad().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:ad().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=>{ad().storage.setItem("theme",e),t({theme:e})},setLayoutStyle:e=>{ad().storage.setItem("layoutStyle",e),t({layoutStyle:e})},setInputPosition:e=>{ad().storage.setItem("inputPosition",e),t({inputPosition:e})},setBackendUrl:e=>{ad().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=>{ad().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 t8n{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 RA=new t8n,n8n=t=>({walletBalance:null,walletLoading:!1,fetchWallet:async()=>{t({walletLoading:!0});try{const e=await RA.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:()=>{QP.connect();const e=QP.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(),QP.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 nke=null;function r8n(t){nke=t}function mte(){if(!nke)throw new Error("toolbarActions not initialized — call initToolbarActions() at app startup");return nke()}async function a8n(t,e){try{await mte()(t,{model_tier:e,provider_id:null,model:null})}catch(n){console.error("Failed to update session tier:",n)}}async function i8n(t,e,n,r){try{await mte()(t,{model_tier:e,provider_id:n,model:r})}catch(i){console.error("Failed to update session tier model:",i)}}async function o8n(t,e){try{await mte()(t,{sandbox_backend:e})}catch(n){console.error("Failed to update session sandbox backend:",n)}}async function s8n(t,e){try{await mte()(t,{knowledge_set_id:e})}catch(n){console.error("Failed to update session knowledge set:",n)}}EOn(),$5n(TOn),nn.configure({getToken:()=>Co.getToken(),onUnauthorized:()=>{Promise.resolve().then(()=>Y5n).then(t=>t.logout()).catch(()=>{})}}),mOn();let l8n;const c8n={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},Un=bOn()(dot(kOn((...t)=>({...e8n(...t),...OFn(...t),...NOn(...t),...GFn(...t),...HFn(...t),...VFn(...t),...ROn(...t),...zFn(...t),...QFn(...t),...jFn(...t),...WFn(...t),...XFn(...t),...JFn(...t),...n8n(...t)})),{name:"xyzen-storage",storage:uot(()=>l8n??(typeof localStorage<"u"?localStorage:c8n)),partialize:t=>({isXyzenOpen:t.isXyzenOpen,panelWidth:t.panelWidth,activePanel:t.activePanel,theme:t.theme,token:t.token,user:t.user,backendUrl:t.backendUrl,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(W5n(Un),r8n(()=>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 u8n(t){return Un.getState().status!=="succeeded"&&localStorage.getItem("platform")==="bohrium"?(t("provider_bohrium"),!0):!1}async function rke(){try{const t=await Co.getAuthStatus();if(!t.is_configured||!t.provider)throw new Error("Authentication is not configured");const e=await Co.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=CN(n,e,r,o)}else i=CN(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 d8n(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,Uit().then(()=>{u8n(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 Co.getOAuthUrl(M,D,R);O.url&&(P=O.url)}catch{}if(!P)try{const O=await Co.getAuthConfig();P=CN("casdoor",O,D,R,M)}catch{}if(P){u(!0);try{const O=await K5n(P);await ax(O.access_token,O.user_info)}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([Co.getAuthStatus(),Co.getAuthConfig(),Yit()]),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=CN(D,R,`${window.location.origin}${window.location.pathname}`);if(P){window.location.href=P;return}}}catch{}r(!0)},[]),b=T.useCallback(()=>{Uit()},[]),y=T.useCallback(()=>{o(!1)},[]),v=T.useCallback(async(M,R)=>Co.sendVerificationCode(M,R),[]),_=T.useCallback(async(M,R)=>{await Dxe(M,R,"email")},[]),w=T.useCallback(async(M,R,D,P)=>{await Nxe(M,R,D,P)},[]),x=T.useCallback(async(M,R)=>{await Oit(M,R)},[]),k=T.useCallback(async M=>{await Co.sendResetCode(M)},[]),C=T.useCallback(async(M,R,D)=>{await Qit(M,R,D)},[]),E=T.useCallback(async M=>Co.sendPhoneVerificationCode(M),[]),S=T.useCallback(async M=>Co.checkPhoneExists(M),[]),I=T.useCallback(async(M,R)=>{await Dxe(M,R,"phone")},[]),B=T.useCallback(async(M,R)=>{await Fit(M,R)},[]),N=T.useCallback(async(M,R,D,P)=>{await Nxe("",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 NN=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(){}},p8n=class extends NN{#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"}},ake=new p8n,m8n={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},g8n=class{#e=m8n;#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)}},RN=new g8n;function h8n(t){setTimeout(t,0)}var f8n=typeof window>"u"||"Deno"in globalThis;function th(){}function A8n(t,e){return typeof t=="function"?t(e):t}function ike(t){return typeof t=="number"&&t>=0&&t!==1/0}function Lot(t,e){return Math.max(t+(e||0)-Date.now(),0)}function nI(t,e){return typeof t=="function"?t(e):t}function ny(t,e){return typeof t=="function"?t(e):t}function Mot(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:o,queryKey:l,stale:u}=t;if(l){if(r){if(e.queryHash!==oke(l,e.options))return!1}else if(!Q7(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 Pot(t,e){const{exact:n,status:r,predicate:i,mutationKey:o}=t;if(o){if(!e.options.mutationKey)return!1;if(n){if(LN(e.options.mutationKey)!==LN(o))return!1}else if(!Q7(e.options.mutationKey,o))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function oke(t,e){return(e?.queryKeyHashFn||LN)(t)}function LN(t){return JSON.stringify(t,(e,n)=>ske(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Q7(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>Q7(t[n],e[n])):!1}var b8n=Object.prototype.hasOwnProperty;function gte(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=Oot(t)&&Oot(e);if(!r&&!(ske(t)&&ske(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:b8n.call(t,g))&&p++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){d[g]=f;continue}const b=gte(h,f,n+1);d[g]=b,b===h&&p++}return o===u&&p===o?t:d}function $7(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 Oot(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function ske(t){if(!Fot(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Fot(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Fot(t){return Object.prototype.toString.call(t)==="[object Object]"}function y8n(t){return new Promise(e=>{RN.setTimeout(e,t)})}function lke(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 gte(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 gte(t,e)}return e}function v8n(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function _8n(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var hte=Symbol();function Qot(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===hte&&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===hte?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function cke(t,e){return typeof t=="function"?t(...e):!!t}function w8n(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 j7=(()=>{let t=()=>f8n;return{isServer(){return t()},setIsServer(e){t=e}}})();function uke(){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 x8n=h8n;function k8n(){let t=[],e=0,n=u=>{u()},r=u=>{u()},i=x8n;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 id=k8n(),E8n=class extends NN{#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}},fte=new E8n;function C8n(t){return Math.min(1e3*2**t,3e4)}function $ot(t){return(t??"online")==="online"?fte.isOnline():!0}var dke=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function jot(t){let e=!1,n=0,r;const i=uke(),o=()=>i.status!=="pending",l=y=>{if(!o()){const v=new dke(y);h(v),t.onCancel?.(v)}},u=()=>{e=!0},d=()=>{e=!1},p=()=>ake.isFocused()&&(t.networkMode==="always"||fte.isOnline())&&t.canRun(),m=()=>$ot(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??(j7.isServer()?0:3),x=t.retryDelay??C8n,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,_),y8n(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 zot=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ike(this.gcTime)&&(this.#e=RN.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(j7.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(RN.clearTimeout(this.#e),this.#e=void 0)}},S8n=class extends zot{#e;#t;#r;#n;#a;#o;#i;constructor(t){super(),this.#i=!1,this.#o=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=Got(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.#o,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=Got(this.options);e.data!==void 0&&(this.setState(qot(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(t,e){const n=lke(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(th).catch(th):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=>ny(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===hte||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>nI(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:!Lot(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.#s()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#s(){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=Qot(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=jot({initialPromise:e?.initialPromise,fn:l.fetchFn,onCancel:u=>{u instanceof dke&&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 dke){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,...Uot(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...qot(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),id.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:t})})}};function Uot(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:$ot(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function qot(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Got(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 Ate=class extends NN{constructor(t,e){super(),this.options=e,this.#e=t,this.#s=null,this.#i=uke(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#r=void 0;#n=void 0;#a;#o;#i;#s;#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),Hot(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return pke(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return pke(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 ny(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&&!$7(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&Wot(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||ny(this.options.enabled,this.#t)!==ny(e.enabled,this.#t)||nI(this.options.staleTime,this.#t)!==nI(e.staleTime,this.#t))&&this.#f();const i=this.#A();r&&(this.#t!==n||ny(this.options.enabled,this.#t)!==ny(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 T8n(this,n)&&(this.#n=n,this.#o=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(th)),e}#f(){this.#k();const t=nI(this.options.staleTime,this.#t);if(j7.isServer()||this.#n.isStale||!ike(t))return;const n=Lot(this.#n.dataUpdatedAt,t)+1;this.#u=RN.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,!(j7.isServer()||ny(this.options.enabled,this.#t)===!1||!ike(this.#h)||this.#h===0)&&(this.#m=RN.setInterval(()=>{(this.options.refetchIntervalInBackground||ake.isFocused())&&this.#d()},this.#h))}#b(){this.#f(),this.#y(this.#A())}#k(){this.#u&&(RN.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#m&&(RN.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.#o,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&&Hot(t,e),N=I&&Wot(t,n,e,r);(B||N)&&(m={...m,...Uot(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=lke(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=lke(i?.data,h,e),this.#c=h,this.#s=null}catch(I){this.#s=I}this.#s&&(f=this.#s,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:mke(t,e),refetch:this.refetch,promise:this.#i,isEnabled:ny(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=uke();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.#o=this.options,this.#a.data!==void 0&&(this.#p=this.#t),$7(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){id.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#n)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function I8n(t,e){return ny(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Hot(t,e){return I8n(t,e)||t.state.data!==void 0&&pke(t,e,e.refetchOnMount)}function pke(t,e,n){if(ny(e.enabled,t)!==!1&&nI(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&mke(t,e)}return!1}function Wot(t,e,n,r){return(t!==e||ny(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&mke(t,n)}function mke(t,e){return ny(e.enabled,t)!==!1&&t.isStaleByTime(nI(e.staleTime,t))}function T8n(t,e){return!$7(t.getCurrentResult(),e)}function bte(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=>{w8n(b,()=>e.signal,()=>m=!0)},h=Qot(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?_8n:v8n;return{pages:C(b.pages,x,k),pageParams:C(b.pageParams,y,k)}};if(i&&o.length){const b=i==="backward",y=b?Yot:gke,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:gke(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 gke(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 Yot(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}function B8n(t,e){return e?gke(t,e)!=null:!1}function D8n(t,e){return!e||!t.getPreviousPageParam?!1:Yot(t,e)!=null}var N8n=class extends Ate{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:bte()})}getOptimisticResult(t){return t.behavior=bte(),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:B8n(e,n.data),hasPreviousPage:D8n(e,n.data),isFetchNextPageError:p,isFetchingNextPage:m,isFetchPreviousPageError:g,isFetchingPreviousPage:h,isRefetchError:u&&!p&&!g,isRefetching:o&&!m&&!h}}},R8n=class extends zot{#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||Vot(),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=jot({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),id.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Vot(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var L8n=class extends NN{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 R8n({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=yte(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=yte(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=yte(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=yte(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){id.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=>Pot(e,n))}findAll(t={}){return this.getAll().filter(e=>Pot(t,e))}notify(t){id.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return id.batch(()=>Promise.all(t.map(e=>e.continue().catch(th))))}};function yte(t){return t.options.scope?.id}var M8n=class extends NN{#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),$7(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#r,observer:this}),n?.mutationKey&&this.options.mutationKey&&LN(n.mutationKey)!==LN(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.#o(e)}getCurrentResult(){return this.#t}reset(){this.#r?.removeObserver(this),this.#r=void 0,this.#a(),this.#o()}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??Vot();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}}#o(e){id.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 Kot(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function P8n(t,e,n){const r=t.slice(0);return r[e]=n,r}var O8n=class extends NN{#e;#t;#r;#n;#a;#o;#i;#s;#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.")}id.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||!$7(m,h)});!d&&!p||(d&&(this.#c=r,this.#a=i),this.#t=o,this.hasListeners()&&(d&&(Kot(n,i).forEach(m=>{m.destroy()}),Kot(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.#o||this.#t!==this.#s||i||e!==this.#i)&&(this.#i=e,this.#s=this.#t,n!==void 0&&(this.#l=n),this.#o=gte(this.#o,e(t))),this.#o}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 Ate(this.#e,i);n.push({defaultedQueryOptions:i,observer:l})}),n}#h(t,e){const n=this.#a.indexOf(t);n!==-1&&(this.#t=P8n(this.#t,n,e),this.#g())}#g(){if(this.hasListeners()){const t=this.#o,e=this.#p(this.#t,this.#c),n=this.#u(e,this.#n?.combine);t!==n&&id.batch(()=>{this.listeners.forEach(r=>{r(this.#t)})})}}},F8n=class extends NN{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??oke(r,e);let o=this.get(i);return o||(o=new S8n({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(){id.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=>Mot(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>Mot(t,n)):e}notify(t){id.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){id.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){id.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Q8n=class{#e;#t;#r;#n;#a;#o;#i;#s;constructor(t={}){this.#e=t.queryCache||new F8n,this.#t=t.mutationCache||new L8n,this.#r=t.defaultOptions||{},this.#n=new Map,this.#a=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=ake.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=fte.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#s?.(),this.#s=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(nI(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=A8n(e,o);if(l!==void 0)return this.#e.build(this,r).setData(l,{...n,manual:!0})}setQueriesData(t,e,n){return id.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;id.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return id.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=id.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(th).catch(th)}invalidateQueries(t,e={}){return id.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=id.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(th)),i.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(th)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(nI(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(th).catch(th)}fetchInfiniteQuery(t){return t.behavior=bte(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(th).catch(th)}ensureInfiniteQueryData(t){return t.behavior=bte(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return fte.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(LN(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#n.values()],n={};return e.forEach(r=>{Q7(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#a.set(LN(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#a.values()],n={};return e.forEach(r=>{Q7(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=oke(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===hte&&(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()}},Zot=ee.createContext(void 0),Tc=t=>{const e=ee.useContext(Zot);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},z7=({client:t,children:e})=>(ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),A.jsx(Zot.Provider,{value:t,children:e})),Xot=ee.createContext(!1),Jot=()=>ee.useContext(Xot);Xot.Provider;function $8n(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var j8n=ee.createContext($8n()),est=()=>ee.useContext(j8n),tst=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?cke(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},nst=t=>{ee.useEffect(()=>{t.clearReset()},[t])},rst=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||cke(n,[t.error,r])),ast=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))}},z8n=(t,e)=>t.isLoading&&t.isFetching&&!e,hke=(t,e)=>t?.suspense&&e.isPending,fke=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function U8n({queries:t,...e},n){const r=Tc(),i=Jot(),o=est(),l=ee.useMemo(()=>t.map(y=>{const v=r.defaultQueryOptions(y);return v._optimisticResults=i?"isRestoring":"optimistic",v}),[t,r,i]);l.forEach(y=>{ast(y);const v=r.getQueryCache().get(y.queryHash);tst(y,o,v)}),nst(o);const[u]=ee.useState(()=>new O8n(r,l,e)),[d,p,m]=u.getOptimisticResult(l,e.combine),g=!i&&e.subscribed!==!1;ee.useSyncExternalStore(ee.useCallback(y=>g?u.subscribe(id.batchCalls(y)):th,[u,g]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),ee.useEffect(()=>{u.setQueries(l,e)},[l,e,u]);const f=d.some((y,v)=>hke(l[v],y))?d.flatMap((y,v)=>{const _=l[v];if(_&&hke(_,y)){const w=new Ate(r,_);return fke(_,w,o)}return[]}):[];if(f.length>0)throw Promise.all(f);const b=d.find((y,v)=>{const _=l[v];return _&&rst({result:y,errorResetBoundary:o,throwOnError:_.throwOnError,query:r.getQueryCache().get(_.queryHash),suspense:_.suspense})});if(b?.error)throw b.error;return p(m())}function ist(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=est(),o=Tc(),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",ast(l),tst(l,i,u),nst(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(id.batchCalls(h)):th;return p.updateResult(),f},[p,g]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),ee.useEffect(()=>{p.setOptions(l)},[l,p]),hke(l,m))throw fke(l,p,i);if(rst({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&&!j7.isServer()&&z8n(m,r)&&(d?fke(l,p,i):u?.promise)?.catch(th).finally(()=>{p.updateResult()}),l.notifyOnChangeProps?m:p.trackResult(m)}function Rs(t,e){return ist(t,Ate)}function LA(t,e){const n=Tc(),[r]=ee.useState(()=>new M8n(n,t));ee.useEffect(()=>{r.setOptions(t)},[r,t]);const i=ee.useSyncExternalStore(ee.useCallback(l=>r.subscribe(id.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=ee.useCallback((l,u)=>{r.mutate(l,u).catch(th)},[r]);if(i.error&&cke(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}function ost(t,e){return ist(t,N8n)}class q8n{async getActiveCampaigns(){return nn.get("/xyzen/api/v1/gifts/active")}async claimGift(e){return nn.post(`/xyzen/api/v1/gifts/${e}/claim`)}}const sst=new q8n,G8n=!1,H8n=!0;console.log("=== Environment Debug ==="),console.log("MODE:","production"),console.log("isDevelopment:",G8n),console.log("isProduction:",H8n),console.log("VITE_XYZEN_BACKEND_URL:","https://xyzen.cc");const MN="https://xyzen.cc";console.log("Final DEFAULT_BACKEND_URL:",MN);const W8n=typeof localStorage<"u"&&localStorage.getItem("layoutStyle")?localStorage.getItem("layoutStyle"):"sidebar";console.log("Final DEFAULT_LAYOUT_STYLE:",W8n);function Bc(){return typeof window<"u"&&"__TAURI__"in window}const Ake="xyzen.desktop.runner",lst="xyzen.desktop.prevent_sleep",bke="xyzen:desktop-prevent-sleep-changed",vte="Desktop Runner";async function PN(t,e){const{invoke:n}=await Promise.resolve().then(()=>cXn);return n(t,e)}async function _te(t,e,n){return PN("runner_start",{token:t,url:e,workDir:n})}async function Y8n(){return PN("runner_stop")}async function yke(){return PN("runner_status")}async function vke(){return Bc()?PN("desktop_computer_use_status"):{supported:!1,platform:"browser",screen_capture_permission:"unsupported",accessibility_permission:"unsupported",reason:null}}function cst(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 ust(t){if(Bc())return PN("plugin:shell|open",{path:t})}function V8n(){return ust("x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture")}function K8n(){return ust("x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")}async function dst(){return Bc()?PN("desktop_sleep_prevention_status"):{enabled:!1,supported:!1}}async function _ke(t){return Bc()?PN("desktop_sleep_prevention_set_enabled",{enabled:t}):{enabled:!1,supported:!1}}function wte(){const e=ad().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 xte(){if(typeof window>"u")return null;const t=window.localStorage.getItem(Ake);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 pst(t){typeof window>"u"||window.localStorage.setItem(Ake,JSON.stringify(t))}function U7(){typeof window>"u"||window.localStorage.removeItem(Ake)}function q7(){return typeof window>"u"?!1:window.localStorage.getItem(lst)==="true"}function mst(t){typeof window>"u"||(window.localStorage.setItem(lst,t?"true":"false"),window.dispatchEvent(new CustomEvent(bke,{detail:{enabled:t}})))}function gst(t){if(typeof window>"u")return()=>{};const e=n=>{t(n.detail.enabled)};return window.addEventListener(bke,e),()=>{window.removeEventListener(bke,e)}}function Z8n(){return A.jsx("div",{"data-tauri-drag-region":!0,className:"fixed top-0 left-0 right-0 h-2 z-[100] select-none backdrop-blur-xl backdrop-saturate-150",style:{WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",background:"linear-gradient(to bottom, rgba(128,128,128,0.2) 0%, transparent 100%)"}})}const X8n=Object.freeze({billing:!1,admin:!1,checkIn:!1,subscription:!1,developerReward:!1}),J8n=Object.freeze({billing:!0,admin:!0,checkIn:!0,subscription:!0,developerReward:!0}),wke=Object.freeze({edition:"ce",isEE:!1,features:X8n}),e6n=Object.freeze({edition:"ee",isEE:!0,features:J8n});let $P=wke,hst=!1;async function t6n(){if(hst)return $P;try{const[t,e]=await Promise.all([Jee.getEdition(),Jee.getFeatures().catch(()=>null)]),n=t.edition==="ee"?e6n:wke;if(e){const r={...n.features,developerReward:n.features.developerReward&&e.developer_reward};$P=Object.freeze({...n,features:Object.freeze(r)})}else $P=n}catch{$P=wke}return hst=!0,$P}function MA(t){return $P.features[t]}const kte=()=>{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 n6n(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 r6n=t=>{switch(t){case"success":return o6n;case"info":return l6n;case"warning":return s6n;case"error":return c6n;default:return null}},a6n=Array(12).fill(0),i6n=({visible:t,className:e})=>T.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},T.createElement("div",{className:"sonner-spinner"},a6n.map((n,r)=>T.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),o6n=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"})),s6n=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"})),l6n=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"})),c6n=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"})),u6n=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"})),d6n=()=>{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 xke=1;class p6n{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:xke++,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(g6n(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||xke++;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 PA=new p6n,m6n=(t,e)=>{const n=e?.id||xke++;return PA.addToast({title:t,...e,id:n}),n},g6n=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",h6n=m6n,f6n=()=>PA.toasts,A6n=()=>PA.getActiveToasts(),Or=Object.assign(h6n,{success:PA.success,info:PA.info,warning:PA.warning,error:PA.error,custom:PA.custom,message:PA.message,promise:PA.promise,dismiss:PA.dismiss,loading:PA.loading},{getHistory:f6n,getToasts:A6n});n6n("[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 Ete(t){return t.label!==void 0}const b6n=3,y6n="24px",v6n="16px",fst=4e3,_6n=356,w6n=14,x6n=45,k6n=200;function sx(...t){return t.filter(Boolean).join(" ")}function E6n(t){const[e,n]=t.split("-"),r=[];return e&&r.push(e),n&&r.push(n),r}const C6n=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:Q="Close toast"}=t,[j,$]=T.useState(null),[z,U]=T.useState(null),[H,te]=T.useState(!1),[Z,ae]=T.useState(!1),[oe,X]=T.useState(!1),[W,q]=T.useState(!1),[Y,K]=T.useState(!1),[ne,ue]=T.useState(0),[se,ce]=T.useState(0),ge=T.useRef(g.duration||M||fst),ve=T.useRef(null),Be=T.useRef(null),We=_===0,Le=_+1<=y,rt=g.type,mt=g.dismissible!==!1,yt=g.className||"",xt=g.descriptionClassName||"",$e=T.useMemo(()=>v.findIndex(fe=>fe.toastId===g.id)||0,[v,g.id]),ot=T.useMemo(()=>{var fe;return(fe=g.closeButton)!=null?fe:E},[g.closeButton,E]),Ce=T.useMemo(()=>g.duration||M||fst,[g.duration,M]),et=T.useRef(0),Rt=T.useRef(0),pe=T.useRef(0),Ze=T.useRef(null),[ie,Re]=R.split("-"),be=T.useMemo(()=>v.reduce((fe,xe,pt)=>pt>=$e?fe:fe+xe.height,0),[v,$e]),Oe=d6n(),we=g.invert||m,st=rt==="loading";Rt.current=T.useMemo(()=>$e*D+be,[$e,be]),T.useEffect(()=>{ge.current=Ce},[Ce]),T.useEffect(()=>{te(!0)},[]),T.useEffect(()=>{const fe=Be.current;if(fe){const xe=fe.getBoundingClientRect().height;return ce(xe),b(pt=>[{toastId:g.id,height:xe,position:g.position},...pt]),()=>b(pt=>pt.filter(tt=>tt.toastId!==g.id))}},[b,g.id]),T.useLayoutEffect(()=>{if(!H)return;const fe=Be.current,xe=fe.style.height;fe.style.height="auto";const pt=fe.getBoundingClientRect().height;fe.style.height=xe,ce(pt),b(tt=>tt.find(an=>an.toastId===g.id)?tt.map(an=>an.toastId===g.id?{...an,height:pt}:an):[{toastId:g.id,height:pt,position:g.position},...tt])},[H,g.title,g.description,b,g.id,g.jsx,g.action,g.cancel]);const vt=T.useCallback(()=>{ae(!0),ue(Rt.current),b(fe=>fe.filter(xe=>xe.toastId!==g.id)),setTimeout(()=>{k(g)},k6n)},[g,k,b,Rt]);T.useEffect(()=>{if(g.promise&&rt==="loading"||g.duration===1/0||g.type==="loading")return;let fe;return x||f||Oe?(()=>{if(pe.current<et.current){const tt=new Date().getTime()-et.current;ge.current=ge.current-tt}pe.current=new Date().getTime()})():ge.current!==1/0&&(et.current=new Date().getTime(),fe=setTimeout(()=>{g.onAutoClose==null||g.onAutoClose.call(g,g),vt()},ge.current)),()=>clearTimeout(fe)},[x,f,g,rt,Oe,vt]),T.useEffect(()=>{g.delete&&(vt(),g.onDismiss==null||g.onDismiss.call(g,g))},[vt,g.delete]);function de(){var fe;if(F?.loading){var xe;return T.createElement("div",{className:sx(O?.loader,g==null||(xe=g.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":rt==="loading"},F.loading)}return T.createElement(i6n,{className:sx(O?.loader,g==null||(fe=g.classNames)==null?void 0:fe.loader),visible:rt==="loading"})}const nt=g.icon||F?.[rt]||r6n(rt);var ct,Ne;return T.createElement("li",{tabIndex:0,ref:Be,className:sx(N,yt,O?.toast,g==null||(e=g.classNames)==null?void 0:e.toast,O?.default,O?.[rt],g==null||(n=g.classNames)==null?void 0:n[rt]),"data-sonner-toast":"","data-rich-colors":(ct=g.richColors)!=null?ct:C,"data-styled":!(g.jsx||g.unstyled||h),"data-mounted":H,"data-promise":!!g.promise,"data-swiped":Y,"data-removed":Z,"data-visible":Le,"data-y-position":ie,"data-x-position":Re,"data-index":_,"data-front":We,"data-swiping":oe,"data-dismissible":mt,"data-type":rt,"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":`${Z?ne:Rt.current}px`,"--initial-height":P?"auto":`${se}px`,...S,...g.style},onDragEnd:()=>{X(!1),$(null),Ze.current=null},onPointerDown:fe=>{fe.button!==2&&(st||!mt||(ve.current=new Date,ue(Rt.current),fe.target.setPointerCapture(fe.pointerId),fe.target.tagName!=="BUTTON"&&(X(!0),Ze.current={x:fe.clientX,y:fe.clientY})))},onPointerUp:()=>{var fe,xe,pt;if(W||!mt)return;Ze.current=null;const tt=Number(((fe=Be.current)==null?void 0:fe.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),an=new Date().getTime()-((pt=ve.current)==null?void 0:pt.getTime()),on=j==="x"?tt:Vt,Xt=Math.abs(on)/an;if(Math.abs(on)>=x6n||Xt>.11){ue(Rt.current),g.onDismiss==null||g.onDismiss.call(g,g),U(j==="x"?tt>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")}K(!1),X(!1),$(null)},onPointerMove:fe=>{var xe,pt,tt;if(!Ze.current||!mt||((xe=window.getSelection())==null?void 0:xe.toString().length)>0)return;const an=fe.clientY-Ze.current.y,on=fe.clientX-Ze.current.x;var Xt;const Lt=(Xt=t.swipeDirections)!=null?Xt:E6n(R);!j&&(Math.abs(on)>1||Math.abs(an)>1)&&$(Math.abs(on)>Math.abs(an)?"x":"y");let Dt={x:0,y:0};const at=gn=>1/(1.5+Math.abs(gn)/20);if(j==="y"){if(Lt.includes("top")||Lt.includes("bottom"))if(Lt.includes("top")&&an<0||Lt.includes("bottom")&&an>0)Dt.y=an;else{const gn=an*at(an);Dt.y=Math.abs(gn)<Math.abs(an)?gn:an}}else if(j==="x"&&(Lt.includes("left")||Lt.includes("right")))if(Lt.includes("left")&&on<0||Lt.includes("right")&&on>0)Dt.x=on;else{const gn=on*at(on);Dt.x=Math.abs(gn)<Math.abs(on)?gn:on}(Math.abs(Dt.x)>0||Math.abs(Dt.y)>0)&&K(!0),(pt=Be.current)==null||pt.style.setProperty("--swipe-amount-x",`${Dt.x}px`),(tt=Be.current)==null||tt.style.setProperty("--swipe-amount-y",`${Dt.y}px`)}},ot&&!g.jsx&&rt!=="loading"?T.createElement("button",{"aria-label":Q,"data-disabled":st,"data-close-button":!0,onClick:st||!mt?()=>{}:()=>{vt(),g.onDismiss==null||g.onDismiss.call(g,g)},className:sx(O?.closeButton,g==null||(r=g.classNames)==null?void 0:r.closeButton)},(Ne=F?.close)!=null?Ne:u6n):null,(rt||g.icon||g.promise)&&g.icon!==null&&(F?.[rt]!==null||g.icon)?T.createElement("div",{"data-icon":"",className:sx(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"?nt:null):null,T.createElement("div",{"data-content":"",className:sx(O?.content,g==null||(o=g.classNames)==null?void 0:o.content)},T.createElement("div",{"data-title":"",className:sx(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:sx(L,xt,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&&Ete(g.cancel)?T.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||I,onClick:fe=>{Ete(g.cancel)&&mt&&(g.cancel.onClick==null||g.cancel.onClick.call(g.cancel,fe),vt())},className:sx(O?.cancelButton,g==null||(d=g.classNames)==null?void 0:d.cancelButton)},g.cancel.label):null,T.isValidElement(g.action)?g.action:g.action&&Ete(g.action)?T.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||B,onClick:fe=>{Ete(g.action)&&(g.action.onClick==null||g.action.onClick.call(g.action,fe),!fe.defaultPrevented&&vt())},className:sx(O?.actionButton,g==null||(p=g.classNames)==null?void 0:p.actionButton)},g.action.label):null)};function Ast(){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 S6n(t,e){const n={};return[t,e].forEach((r,i)=>{const o=i===1,l=o?"--mobile-offset":"--offset",u=o?v6n:y6n;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 I6n=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=b6n,toastOptions:_,dir:w=Ast(),gap:x=w6n,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"),Q=T.useRef(null),j=l.join("+").replace(/Key/g,"").replace(/Digit/g,""),$=T.useRef(null),z=T.useRef(!1),U=T.useCallback(H=>{S(te=>{var Z;return(Z=te.find(ae=>ae.id===H.id))!=null&&Z.delete||PA.dismiss(H.id),te.filter(({id:ae})=>ae!==H.id)})},[]);return T.useEffect(()=>PA.subscribe(H=>{if(H.dismiss){requestAnimationFrame(()=>{S(te=>te.map(Z=>Z.id===H.id?{...Z,delete:!0}:Z))});return}setTimeout(()=>{Qi.flushSync(()=>{S(te=>{const Z=te.findIndex(ae=>ae.id===H.id);return Z!==-1?[...te.slice(0,Z),{...te[Z],...H},...te.slice(Z+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:Z})=>{try{F(Z?"dark":"light")}catch(ae){console.error(ae)}})}},[h]),T.useEffect(()=>{E.length<=1&&R(!1)},[E]),T.useEffect(()=>{const H=te=>{var Z;if(l.every(X=>te[X]||te.code===X)){var oe;R(!0),(oe=Q.current)==null||oe.focus()}te.code==="Escape"&&(document.activeElement===Q.current||(Z=Q.current)!=null&&Z.contains(document.activeElement))&&R(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[l]),T.useEffect(()=>{if(Q.current)return()=>{$.current&&($.current.focus({preventScroll:!0}),$.current=null,z.current=!1)}},[Q.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 Z;const[ae,oe]=H.split("-");return I.length?T.createElement("ol",{key:H,dir:w==="auto"?Ast():w,tabIndex:-1,ref:Q,className:p,"data-sonner-toaster":!0,"data-sonner-theme":O,"data-y-position":ae,"data-x-position":oe,style:{"--front-toast-height":`${((Z=N[0])==null?void 0:Z.height)||0}px`,"--width":`${_6n}px`,"--gap":`${x}px`,...y,...S6n(m,g)},onBlur:X=>{z.current&&!X.currentTarget.contains(X.relatedTarget)&&(z.current=!1,$.current&&($.current.focus({preventScroll:!0}),$.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||z.current||(z.current=!0,$.current=X.relatedTarget)},onMouseEnter:()=>R(!0),onMouseMove:()=>R(!0),onMouseLeave:()=>{D||R(!1)},onDragEnd:()=>R(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||P(!0)},onPointerUp:()=>P(!1)},I.filter(X=>!X.position&&te===0||X.position===H).map((X,W)=>{var q,Y;return T.createElement(C6n,{key:X.id,icons:k,index:W,toast:X,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(K=>K.position==X.position),heights:N.filter(K=>K.position==X.position),setHeights:L,expandByDefault:u,gap:x,expanded:M,swipeDirections:e.swipeDirections})})):null}))});function T6n(){return{needRefresh:[!1,()=>{}],offlineReady:[!1,()=>{}],updateServiceWorker:async()=>{}}}const bst=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const B6n=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const D6n=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const yst=t=>{const e=D6n(t);return e.charAt(0).toUpperCase()+e.slice(1)};var N6n={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 R6n=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const L6n=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,...N6n,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:bst("lucide",i),...!o&&!R6n(u)&&{"aria-hidden":"true"},...u},[...l.map(([p,m])=>T.createElement(p,m)),...Array.isArray(o)?o:[o]]));const Hr=(t,e)=>{const n=T.forwardRef(({className:r,...i},o)=>T.createElement(L6n,{ref:o,iconNode:e,className:bst(`lucide-${B6n(yst(t))}`,`lucide-${t}`,r),...i}));return n.displayName=yst(t),n};const kke=Hr("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 M6n=Hr("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 lx=Hr("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const jP=Hr("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const vst=Hr("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 P6n=Hr("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 O6n=Hr("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 zP=Hr("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 F6n=Hr("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 Cte=Hr("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 Q6n=Hr("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);const nh=Hr("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const mf=Hr("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Eke=Hr("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const rI=Hr("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ste=Hr("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const $6n=Hr("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const _st=Hr("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 j6n=Hr("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 z6n=Hr("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const U6n=Hr("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 q6n=Hr("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 Cke=Hr("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 G6n=Hr("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 H6n=Hr("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 W6n=Hr("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 Ske=Hr("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 Y6n=Hr("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 Ike=Hr("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 w1=Hr("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 x1=Hr("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 wst=Hr("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 xst=Hr("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 kst=Hr("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 V6n=Hr("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 Tke=Hr("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 Est=Hr("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 Cst=Hr("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 Bke=Hr("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 Ite=Hr("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 Sst=Hr("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 Ist=Hr("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 Dke=Hr("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 K6n=Hr("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 Z6n=Hr("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 X6n=Hr("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 J6n=Hr("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 e9n=Hr("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 t9n=Hr("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 UP=Hr("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 n9n=Hr("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 G7=Hr("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 r9n=Hr("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 qP=Hr("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 Tst=Hr("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 Bst=Hr("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 rh=Hr("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Nke=Hr("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 Dst=Hr("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 Tte=Hr("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 a9n=Hr("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 Rke=Hr("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 Nst=Hr("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const i9n=Hr("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 o9n=Hr("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 s9n=Hr("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 H7=Hr("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 l9n=Hr("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 Rst=Hr("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const c9n=Hr("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 u9n=Hr("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 Lst=Hr("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 d9n=Hr("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 p9n=Hr("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const m9n=Hr("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 g9n=Hr("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 Bte=Hr("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 h9n=Hr("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const cx=Hr("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 f9n=Hr("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const A9n=Hr("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 b9n=Hr("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const y9n=Hr("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]);const Dte=Hr("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 Lke=Hr("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 Mst=Hr("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 v9n=Hr("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 Nte=Hr("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 Rte=Hr("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 _9n=Hr("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 w9n=Hr("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 k1=Hr("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const Lte=Hr("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 x9n({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(Lst,{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 k9n(){const{t}=Cn(),e=T.useRef(null),n=T.useRef(null),{needRefresh:[r],updateServiceWorker:i}=T6n();T.useEffect(()=>()=>{n.current?.(),n.current=null},[]);const o=T.useCallback(()=>{i()},[i]);T.useEffect(()=>{if(!r){e.current!=null&&(Or.dismiss(e.current),e.current=null);return}e.current=Or.custom(l=>x9n({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:()=>{Or.dismiss(l),e.current=null}}),{duration:1/0})},[r,o,t])}function E9n(){const t=Jg(),e=(t.isAuthenticated||!!t.token)&&MA("billing"),n=Un(i=>i.fetchWallet),r=Un(i=>i.connectWalletEvents);T.useEffect(()=>e?(n(),r()):void 0,[e,n,r])}const Pst=[];function aI(){return dg(Wo(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}}))}function C9n(){return dg(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.messages??Pst:Pst})}function S9n(){return dg(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.responding??!1:!1})}function I9n(){return dg(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.agentId??null:null})}function Ost(){return dg(t=>t.runningAgentIds)}function T9n(){return dg(t=>t.activeTopicCountByAgent)}function Fst(){return dg(t=>t.respondingChannelIds)}function Qst(){return dg(Wo(t=>{const e={};for(const[n,r]of Object.entries(t.channels))r.agentId&&(e[n]=r.agentId);return e}))}function B9n(t){return t==="Connecting"||typeof t=="object"&&"Connected"in t}async function $st(t){const e=xte(),n=Un.getState().runners;if(e){if(n.find(l=>l.id===e.runnerId)?.is_active)return e;U7()}const r=await t(vte);if(!r)return null;const i={runnerId:r.runner.id,token:r.token,name:vte};return pst(i),i}function D9n(t){const{createRunnerToken:e,fetchRunners:n,runners:r,updateSessionConfig:i}=Un(Wo(u=>({createRunnerToken:u.createRunnerToken,fetchRunners:u.fetchRunners,runners:u.runners,updateSessionConfig:u.updateSessionConfig}))),o=aI(),l=T.useRef(null);T.useEffect(()=>{if(!Bc()||t!=="succeeded")return;let u=!1;return(async()=>{if(await n(),u)return;const p=await yke().catch(()=>"Disconnected");if(B9n(p)){await n();return}let m=await $st(e);if(!(!m||u)){try{await _te(m.token,wte())}catch(g){if(String(g).includes("already running")){await n();return}if(U7(),m=await $st(e),!m||u)return;await _te(m.token,wte())}await n()}})(),()=>{u=!0}},[t,e,n]),T.useEffect(()=>{if(!Bc()||t!=="succeeded"||!o.sessionId||o.sandbox_backend)return;const u=xte();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])}const N9n=({...t})=>A.jsx(I6n,{theme:"system",className:"toaster group",richColors:!0,icons:{success:A.jsx($6n,{className:"size-4"}),info:A.jsx(G7,{className:"size-4"}),warning:A.jsx(Lke,{className:"size-4"}),error:A.jsx(o9n,{className:"size-4"}),loading:A.jsx(rh,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...t}),W7=T.createContext({});function iI(t){const e=T.useRef(null);return e.current===null&&(e.current=t()),e.current}const Mte=typeof window<"u"?T.useLayoutEffect:T.useEffect,Pte=T.createContext(null);function Mke(t,e){t.indexOf(e)===-1&&t.push(e)}function GP(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const ux=(t,e,n)=>n>e?e:n<t?t:n;function Pke(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let HP=()=>{},Hv=()=>{};typeof process<"u"&&process.env?.NODE_ENV!=="production"&&(HP=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(Pke(e,n))},Hv=(t,e,n)=>{if(!t)throw new Error(Pke(e,n))});const oI={},jst=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function zst(t){return typeof t=="object"&&t!==null}const Ust=t=>/^0[^.\s]+$/u.test(t);function qst(t){let e;return()=>(e===void 0&&(e=t()),e)}const ry=t=>t,R9n=(t,e)=>n=>e(t(n)),Y7=(...t)=>t.reduce(R9n),WP=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class Oke{constructor(){this.subscriptions=[]}add(e){return Mke(this.subscriptions,e),()=>GP(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 gf=t=>t*1e3,ay=t=>t/1e3;function Gst(t,e){return e?t*(1e3/e):0}const Hst=new Set;function Fke(t,e,n){t||Hst.has(e)||(console.warn(Pke(e,n)),Hst.add(e))}const L9n=(t,e,n)=>{const r=e-t;return((n-t)%r+r)%r+t},Wst=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,M9n=1e-7,P9n=12;function O9n(t,e,n,r,i){let o,l,u=0;do l=e+(n-e)/2,o=Wst(l,r,i)-t,o>0?n=l:e=l;while(Math.abs(o)>M9n&&++u<P9n);return l}function V7(t,e,n,r){if(t===e&&n===r)return ry;const i=o=>O9n(o,0,1,t,n);return o=>o===0||o===1?o:Wst(i(o),e,r)}const Yst=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Vst=t=>e=>1-t(1-e),Kst=V7(.33,1.53,.69,.99),Qke=Vst(Kst),Zst=Yst(Qke),Xst=t=>t>=1?1:(t*=2)<1?.5*Qke(t):.5*(2-Math.pow(2,-10*(t-1))),$ke=t=>1-Math.sin(Math.acos(t)),Jst=Vst($ke),elt=Yst($ke),F9n=V7(.42,0,1,1),jke=V7(0,0,.58,1),tlt=V7(.42,0,.58,1),nlt=t=>Array.isArray(t)&&typeof t[0]!="number";function rlt(t,e){return nlt(t)?t[L9n(0,t.length,e)]:t}const alt=t=>Array.isArray(t)&&typeof t[0]=="number",ilt={linear:ry,easeIn:F9n,easeInOut:tlt,easeOut:jke,circIn:$ke,circInOut:elt,circOut:Jst,backIn:Qke,backInOut:Zst,backOut:Kst,anticipate:Xst},Q9n=t=>typeof t=="string",olt=t=>{if(alt(t)){Hv(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,r,i]=t;return V7(e,n,r,i)}else if(Q9n(t))return Hv(ilt[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),ilt[t];return t},Ote=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function $9n(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 j9n=40;function slt(t,e){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,l=Ote.reduce((x,k)=>(x[k]=$9n(o),x),{}),{setup:u,read:d,resolveKeyframes:p,preUpdate:m,update:g,preRender:h,render:f,postRender:b}=l,y=()=>{const x=oI.useManualTiming,k=x?i.timestamp:performance.now();n=!1,x||(i.delta=r?1e3/60:Math.max(Math.min(k-i.timestamp,j9n),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:Ote.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<Ote.length;k++)l[Ote[k]].cancel(x)},state:i,steps:l}}const{schedule:Nl,cancel:E1,state:mg,steps:zke}=slt(typeof requestAnimationFrame<"u"?requestAnimationFrame:ry,!0);let Fte;function z9n(){Fte=void 0}const hf={now:()=>(Fte===void 0&&hf.set(mg.isProcessing||oI.useManualTiming?mg.timestamp:performance.now()),Fte),set:t=>{Fte=t,queueMicrotask(z9n)}},llt=t=>e=>typeof e=="string"&&e.startsWith(t),clt=llt("--"),U9n=llt("var(--"),Uke=t=>U9n(t)?q9n.test(t.split("/*")[0].trim()):!1,q9n=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function ult(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const YP={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},K7={...YP,transform:t=>ux(0,1,t)},Qte={...YP,default:1},Z7=t=>Math.round(t*1e5)/1e5,qke=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function G9n(t){return t==null}const H9n=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Gke=(t,e)=>n=>!!(typeof n=="string"&&H9n.test(n)&&n.startsWith(t)||e&&!G9n(n)&&Object.prototype.hasOwnProperty.call(n,e)),dlt=(t,e,n)=>r=>{if(typeof r!="string")return r;const[i,o,l,u]=r.match(qke);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(l),alpha:u!==void 0?parseFloat(u):1}},W9n=t=>ux(0,255,t),Hke={...YP,transform:t=>Math.round(W9n(t))},ON={test:Gke("rgb","red"),parse:dlt("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+Hke.transform(t)+", "+Hke.transform(e)+", "+Hke.transform(n)+", "+Z7(K7.transform(r))+")"};function Y9n(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 Wke={test:Gke("#"),parse:Y9n,transform:ON.transform},X7=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),sI=X7("deg"),dx=X7("%"),Ja=X7("px"),V9n=X7("vh"),K9n=X7("vw"),plt={...dx,parse:t=>dx.parse(t)/100,transform:t=>dx.transform(t*100)},VP={test:Gke("hsl","hue"),parse:dlt("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+dx.transform(Z7(e))+", "+dx.transform(Z7(n))+", "+Z7(K7.transform(r))+")"},tp={test:t=>ON.test(t)||Wke.test(t)||VP.test(t),parse:t=>ON.test(t)?ON.parse(t):VP.test(t)?VP.parse(t):Wke.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ON.transform(t):VP.transform(t),getAnimatableNone:t=>{const e=tp.parse(t);return e.alpha=0,tp.transform(e)}},Z9n=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function X9n(t){return isNaN(t)&&typeof t=="string"&&(t.match(qke)?.length||0)+(t.match(Z9n)?.length||0)>0}const mlt="number",glt="color",J9n="var",eQn="var(",hlt="${}",tQn=/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 KP(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},i=[];let o=0;const u=e.replace(tQn,d=>(tp.test(d)?(r.color.push(o),i.push(glt),n.push(tp.parse(d))):d.startsWith(eQn)?(r.var.push(o),i.push(J9n),n.push(d)):(r.number.push(o),i.push(mlt),n.push(parseFloat(d))),++o,hlt)).split(hlt);return{values:n,split:u,indexes:r,types:i}}function nQn(t){return KP(t).values}function flt({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===mlt?i+=Z7(r[o]):l===glt?i+=tp.transform(r[o]):i+=r[o]}return i}}function rQn(t){return flt(KP(t))}const aQn=t=>typeof t=="number"?0:tp.test(t)?tp.getAnimatableNone(t):t,iQn=(t,e)=>typeof t=="number"?e?.trim().endsWith("/")?t:0:aQn(t);function oQn(t){const e=KP(t);return flt(e)(e.values.map((r,i)=>iQn(r,e.split[i])))}const Wv={test:X9n,parse:nQn,createTransformer:rQn,getAnimatableNone:oQn};function Yke(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 sQn({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=Yke(d,u,t+1/3),o=Yke(d,u,t),l=Yke(d,u,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:r}}function $te(t,e){return n=>n>0?e:t}const Dc=(t,e,n)=>t+(e-t)*n,Vke=(t,e,n)=>{const r=t*t,i=n*(e*e-r)+r;return i<0?0:Math.sqrt(i)},lQn=[Wke,ON,VP],cQn=t=>lQn.find(e=>e.test(t));function Alt(t){const e=cQn(t);if(HP(!!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===VP&&(n=sQn(n)),n}const blt=(t,e)=>{const n=Alt(t),r=Alt(e);if(!n||!r)return $te(t,e);const i={...n};return o=>(i.red=Vke(n.red,r.red,o),i.green=Vke(n.green,r.green,o),i.blue=Vke(n.blue,r.blue,o),i.alpha=Dc(n.alpha,r.alpha,o),ON.transform(i))},Kke=new Set(["none","hidden"]);function uQn(t,e){return Kke.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function dQn(t,e){return n=>Dc(t,e,n)}function Zke(t){return typeof t=="number"?dQn:typeof t=="string"?Uke(t)?$te:tp.test(t)?blt:gQn:Array.isArray(t)?ylt:typeof t=="object"?tp.test(t)?blt:pQn:$te}function ylt(t,e){const n=[...t],r=n.length,i=t.map((o,l)=>Zke(o)(o,e[l]));return o=>{for(let l=0;l<r;l++)n[l]=i[l](o);return n}}function pQn(t,e){const n={...t,...e},r={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(r[i]=Zke(t[i])(t[i],e[i]));return i=>{for(const o in r)n[o]=r[o](i);return n}}function mQn(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 gQn=(t,e)=>{const n=Wv.createTransformer(e),r=KP(t),i=KP(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?Kke.has(t)&&!i.values.length||Kke.has(e)&&!r.values.length?uQn(t,e):Y7(ylt(mQn(r,i),i.values),n):(HP(!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"),$te(t,e))};function vlt(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Dc(t,e,n):Zke(t)(t,e)}const hQn=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Nl.update(e,n),stop:()=>E1(e),now:()=>mg.isProcessing?mg.timestamp:hf.now()}},_lt=(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)})`},jte=2e4;function Xke(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<jte;)e+=n,r=t.next(e);return e>=jte?1/0:e}function wlt(t,e=100,n){const r=n({...t,keyframes:[0,e]}),i=Math.min(Xke(r),jte);return{type:"keyframes",ease:o=>r.next(i*o).value/e,duration:ay(i)}}const Lu={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 Jke(t,e){return t*Math.sqrt(1-e*e)}const fQn=12;function AQn(t,e,n){let r=n;for(let i=1;i<fQn;i++)r=r-t(r)/e(r);return r}const eEe=.001;function bQn({duration:t=Lu.duration,bounce:e=Lu.bounce,velocity:n=Lu.velocity,mass:r=Lu.mass}){let i,o;HP(t<=gf(Lu.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let l=1-e;l=ux(Lu.minDamping,Lu.maxDamping,l),t=ux(Lu.minDuration,Lu.maxDuration,ay(t)),l<1?(i=p=>{const m=p*l,g=m*t,h=m-n,f=Jke(p,l),b=Math.exp(-g);return eEe-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=Jke(Math.pow(p,2),l);return(-i(p)+eEe>0?-1:1)*((h-f)*b)/y}):(i=p=>{const m=Math.exp(-p*t),g=(p-n)*t+1;return-eEe+m*g},o=p=>{const m=Math.exp(-p*t),g=(n-p)*(t*t);return m*g});const u=5/t,d=AQn(i,o,u);if(t=gf(t),isNaN(d))return{stiffness:Lu.stiffness,damping:Lu.damping,duration:t};{const p=Math.pow(d,2)*r;return{stiffness:p,damping:l*2*Math.sqrt(r*p),duration:t}}}const yQn=["duration","bounce"],vQn=["stiffness","damping","mass"];function xlt(t,e){return e.some(n=>t[n]!==void 0)}function _Qn(t){let e={velocity:Lu.velocity,stiffness:Lu.stiffness,damping:Lu.damping,mass:Lu.mass,isResolvedFromDuration:!1,...t};if(!xlt(t,vQn)&&xlt(t,yQn))if(e.velocity=0,t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,o=2*ux(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:Lu.mass,stiffness:i,damping:o}}else{const n=bQn({...t,velocity:0});e={...e,...n,mass:Lu.mass},e.isResolvedFromDuration=!0}return e}function J7(t=Lu.visualDuration,e=Lu.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}=_Qn({...n,velocity:-ay(n.velocity||0)}),b=h||0,y=p/(2*Math.sqrt(d*m)),v=l-o,_=ay(Math.sqrt(d/m)),w=Math.abs(v)<5;r||(r=w?Lu.restSpeed.granular:Lu.restSpeed.default),i||(i=w?Lu.restDelta.granular:Lu.restDelta.default);let x,k,C,E,S,I;if(y<1)C=Jke(_,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=>gf(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=gf(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=gf(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(Xke(B),jte),L=_lt(M=>B.next(N*M).value,N,30);return N+"ms "+L},toTransition:()=>{}};return B}J7.applyToOptions=t=>{const e=wlt(t,100,J7);return t.ease=e.ease,t.duration=gf(e.duration),t.type="keyframes",t};const wQn=5;function klt(t,e,n){const r=Math.max(e-wQn,0);return Gst(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=J7({keyframes:[h.value,b(h.value)],velocity:klt(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 xQn(t,e,n){const r=[],i=n||oI.mix||vlt,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]||ry:e;u=Y7(d,u)}r.push(u)}return r}function Elt(t,e,{clamp:n=!0,ease:r,mixer:i}={}){const o=t.length;if(Hv(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=xQn(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=WP(t[g],t[g+1],m);return u[g](h)};return n?m=>p(ux(t[0],t[o-1],m)):p}function Clt(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const i=WP(0,e,r);t.push(Dc(n,1,i))}}function Slt(t){const e=[0];return Clt(e,t.length-1),e}function kQn(t,e){return t.map(n=>n*e)}function EQn(t,e){return t.map(()=>e||tlt).splice(0,t.length-1)}function ZP({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const i=nlt(r)?r.map(olt):olt(r),o={done:!1,value:e[0]},l=kQn(n&&n.length===e.length?n:Slt(e),t),u=Elt(l,e,{ease:Array.isArray(i)?i:EQn(e,i)});return{calculatedDuration:t,next:d=>(o.value=u(d),o.done=d>=t,o)}}const CQn=t=>t!==null;function zte(t,{repeat:e,repeatType:n="loop"},r,i=1){const o=t.filter(CQn),u=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!u||r===void 0?o[u]:r}const SQn={decay:tEe,inertia:tEe,tween:ZP,keyframes:ZP,spring:J7};function Ilt(t){typeof t.type=="string"&&(t.type=SQn[t.type])}class nEe{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 IQn=t=>t/100;class ez extends nEe{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!==hf.now()&&this.tick(hf.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;Ilt(e);const{type:n=ZP,repeat:r=0,repeatDelay:i=0,repeatType:o,velocity:l=0}=e;let{keyframes:u}=e;const d=n||ZP;process.env.NODE_ENV!=="production"&&d!==ZP&&Hv(u.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${u}`,"spring-two-frames"),d!==ZP&&typeof u[0]!="number"&&(this.mixKeyframes=Y7(IQn,vlt(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=Xke(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=ux(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=zte(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 ay(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ay(e)}get time(){return ay(this.currentTime)}set time(e){e=gf(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 klt(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(hf.now()),this.playbackSpeed=e,n&&this.driver&&(this.time=ay(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=hQn,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(hf.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 TQn(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const FN=t=>t*180/Math.PI,rEe=t=>{const e=FN(Math.atan2(t[1],t[0]));return aEe(e)},BQn={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:rEe,rotateZ:rEe,skewX:t=>FN(Math.atan(t[1])),skewY:t=>FN(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},aEe=t=>(t=t%360,t<0&&(t+=360),t),Tlt=rEe,Blt=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Dlt=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),DQn={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Blt,scaleY:Dlt,scale:t=>(Blt(t)+Dlt(t))/2,rotateX:t=>aEe(FN(Math.atan2(t[6],t[5]))),rotateY:t=>aEe(FN(Math.atan2(-t[2],t[0]))),rotateZ:Tlt,rotate:Tlt,skewX:t=>FN(Math.atan(t[4])),skewY:t=>FN(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function iEe(t){return t.includes("scale")?1:0}function oEe(t,e){if(!t||t==="none")return iEe(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=DQn,i=n;else{const u=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=BQn,i=u}if(!i)return iEe(e);const o=r[e],l=i[1].split(",").map(RQn);return typeof o=="function"?o(l):l[o]}const NQn=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return oEe(n,e)};function RQn(t){return parseFloat(t.trim())}const XP=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],JP=new Set(XP),Nlt=t=>t===YP||t===Ja,LQn=new Set(["x","y","z"]),MQn=XP.filter(t=>!LQn.has(t));function PQn(t){const e=[];return MQn.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const lI={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})=>oEe(e,"x"),y:(t,{transform:e})=>oEe(e,"y")};lI.translateX=lI.x,lI.translateY=lI.y;const QN=new Set;let sEe=!1,lEe=!1,cEe=!1;function Rlt(){if(lEe){const t=Array.from(QN).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const i=PQn(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)})}lEe=!1,sEe=!1,QN.forEach(t=>t.complete(cEe)),QN.clear()}function Llt(){QN.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(lEe=!0)})}function OQn(){cEe=!0,Llt(),Rlt(),cEe=!1}class uEe{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?(QN.add(this),sEe||(sEe=!0,Nl.read(Llt),Nl.resolveKeyframes(Rlt))):(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])}TQn(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),QN.delete(this)}cancel(){this.state==="scheduled"&&(QN.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const FQn=t=>t.startsWith("--");function Mlt(t,e,n){FQn(e)?t.style.setProperty(e,n):t.style[e]=n}const QQn={};function Plt(t,e){const n=qst(t);return()=>QQn[e]??n()}const $Qn=Plt(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),Olt=Plt(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),tz=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,Flt={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:tz([0,.65,.55,1]),circOut:tz([.55,0,1,.45]),backIn:tz([.31,.01,.66,-.59]),backOut:tz([.33,1.53,.69,.99])};function Qlt(t,e){if(t)return typeof t=="function"?Olt()?_lt(t,e):"ease-out":alt(t)?tz(t):Array.isArray(t)?t.map(n=>Qlt(n,e)||Flt.easeOut):Flt[t]}function jQn(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=Qlt(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 dEe(t){return typeof t=="function"&&"applyToOptions"in t}function zQn({type:t,...e}){return dEe(t)&&Olt()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class $lt extends nEe{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,Hv(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const p=zQn(e);this.animation=jQn(n,r,i,p,o),p.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const m=zte(i,this.options,u,this.speed);this.updateMotionValue&&this.updateMotionValue(m),Mlt(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 ay(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ay(e)}get time(){return ay(Number(this.animation.currentTime)||0)}set time(e){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=gf(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&&$Qn()?(this.animation.timeline=e,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),ry):i(this)}}const jlt={anticipate:Xst,backInOut:Zst,circInOut:elt};function UQn(t){return t in jlt}function qQn(t){typeof t.ease=="string"&&UQn(t.ease)&&(t.ease=jlt[t.ease])}const pEe=10;class GQn extends $lt{constructor(e){qQn(e),Ilt(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 ez({...l,autoplay:!1}),d=Math.max(pEe,hf.now()-this.startTime),p=ux(0,pEe,d-pEe),m=u.sample(d).value,{name:g}=this.options;o&&g&&Mlt(o,g,m),n.setWithVelocity(u.sample(Math.max(0,d-p)).value,m,p),u.stop()}}const zlt=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Wv.test(t)||t==="0")&&!t.startsWith("url("));function HQn(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 WQn(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=zlt(i,e),u=zlt(o,e);return HP(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:HQn(t)||(n==="spring"||dEe(n))&&r}function mEe(t){t.duration=0,t.type="keyframes"}const Ult=new Set(["opacity","clipPath","filter","transform"]),YQn=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function VQn(t){for(let e=0;e<t.length;e++)if(typeof t[e]=="string"&&YQn.test(t[e]))return!0;return!1}const KQn=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),ZQn=qst(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function XQn(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 ZQn()&&n&&(Ult.has(n)||KQn.has(n)&&VQn(u))&&(n!=="transform"||!m)&&!p&&!r&&i!=="mirror"&&o!==0&&l!=="inertia"}const JQn=40;class e$n extends nEe{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=hf.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||uEe;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=hf.now();let g=!0;WQn(e,o,l,u)||(g=!1,(oI.instantAnimations||!d)&&m?.(zte(e,r,n)),e[0]=e[e.length-1],mEe(r),r.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>JQn?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},b=g&&!p&&XQn(f),y=f.motionValue?.owner?.current;let v;if(b)try{v=new GQn({...f,element:y})}catch{v=new ez(f)}else v=new ez(f);v.finished.then(()=>{this.notifyFinished()}).catch(ry),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(),OQn()),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 t$n{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 qlt(this.animations,"duration")}get iterationDuration(){return qlt(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 qlt(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 n$n extends t$n{then(e,n){return this.finished.finally(e).then(()=>{})}}function Glt(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 r$n=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function a$n(t){const e=r$n.exec(t);if(!e)return[,];const[,n,r,i]=e;return[`--${n??r}`,i]}const i$n=4;function Hlt(t,e,n=1){Hv(n<=i$n,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,i]=a$n(t);if(!r)return;const o=window.getComputedStyle(e).getPropertyValue(r);if(o){const l=o.trim();return jst(l)?parseFloat(l):l}return Uke(i)?Hlt(i,e,n+1):i}const o$n={type:"spring",stiffness:500,damping:25,restSpeed:10},s$n=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),l$n={type:"keyframes",duration:.8},c$n={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},u$n=(t,{keyframes:e})=>e.length>2?l$n:JP.has(t)?t.startsWith("scale")?s$n(e[1]):o$n:c$n;function Wlt(t,e){if(t?.inherit&&e){const{inherit:n,...r}=t;return{...e,...r}}return t}function gEe(t,e){const n=t?.[e]??t?.default??t;return n!==t?Wlt(n,t):n}const d$n=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function p$n(t){for(const e in t)if(!d$n.has(e))return!0;return!1}const hEe=(t,e,n,r={},i,o)=>l=>{const u=gEe(r,t)||{},d=u.delay||r.delay||0;let{elapsed:p=0}=r;p=p-gf(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};p$n(u)||Object.assign(m,u$n(t,m)),m.duration&&(m.duration=gf(m.duration)),m.repeatDelay&&(m.repeatDelay=gf(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let g=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&(mEe(m),m.delay===0&&(g=!0)),(oI.instantAnimations||oI.skipAnimations||i?.shouldSkipAnimations)&&(g=!0,mEe(m),m.delay=0),m.allowFlatten=!u.type&&!u.ease,g&&!o&&e.get()!==void 0){const h=zte(m.keyframes,u);if(h!==void 0){Nl.update(()=>{m.onUpdate(h),m.onComplete()});return}}return u.isSync?new ez(m):new e$n(m)};function Ylt(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function fEe(t,e,n,r){if(typeof e=="function"){const[i,o]=Ylt(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]=Ylt(r);e=e(n!==void 0?n:t.custom,i,o)}return e}function $N(t,e,n){const r=t.getProps();return fEe(r,e,n!==void 0?n:r.custom,t)}const Vlt=new Set(["width","height","top","left","right","bottom",...XP]),Klt=30,m$n=t=>!isNaN(parseFloat(t)),nz={current:void 0};class g$n{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const i=hf.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=hf.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=m$n(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Fke(!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 Oke);const r=this.events[e].add(n);return e==="change"?()=>{r(),Nl.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 nz.current&&nz.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=hf.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Klt)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Klt);return Gst(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 cI(t,e){return new g$n(t,e)}const AEe=t=>Array.isArray(t);function h$n(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,cI(n))}function f$n(t){return AEe(t)?t[t.length-1]||0:t}function A$n(t,e){const n=$N(t,e);let{transitionEnd:r={},transition:i={},...o}=n||{};o={...o,...r};for(const l in o){const u=f$n(o[l]);h$n(t,l,u)}}const Sd=t=>!!(t&&t.getVelocity);function b$n(t){return!!(Sd(t)&&t.add)}function bEe(t,e){const n=t.getValue("willChange");if(b$n(n))return n.add(e);if(!n&&oI.WillChange){const r=new oI.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function yEe(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const Zlt="data-"+yEe("framerAppearId");function Xlt(t){return t.props[Zlt]}function y$n({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function vEe(t,e,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:o,transitionEnd:l,...u}=e;const d=t.getDefaultTransition();o=o?Wlt(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&&y$n(g,h))continue;const y={delay:n,...gEe(o||{},h)},v=f.get();if(v!==void 0&&!f.isAnimating()&&!Array.isArray(b)&&b===v&&!y.velocity){Nl.update(()=>f.set(b));continue}let _=!1;if(window.MotionHandoffAnimation){const k=Xlt(t);if(k){const C=window.MotionHandoffAnimation(k,h,Nl);C!==null&&(y.startTime=C,_=!0)}}bEe(t,h);const w=p??t.shouldReduceMotion;f.start(hEe(h,f,b,w&&Vlt.has(h)?{type:!1}:y,t,_));const x=f.animation;x&&m.push(x)}if(l){const h=()=>Nl.update(()=>{l&&A$n(t,l)});m.length?Promise.all(m).then(h):h()}return m}function _Ee(t,e,n={}){const r=$N(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(vEe(t,r,n)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(d=0)=>{const{delayChildren:p=0,staggerChildren:m,staggerDirection:g}=i;return v$n(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 v$n(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(_Ee(d,e,{...l,delay:n+(typeof r=="function"?0:r)+Glt(t.variantChildren,d,r,i,o)}).then(()=>d.notify("AnimationComplete",e)));return Promise.all(u)}function _$n(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const i=e.map(o=>_Ee(t,o,n));r=Promise.all(i)}else if(typeof e=="string")r=_Ee(t,e,n);else{const i=typeof e=="function"?$N(t,e,n.custom):e;r=Promise.all(vEe(t,i,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}const w$n={test:t=>t==="auto",parse:t=>t},Jlt=t=>e=>e.test(t),ect=[YP,Ja,dx,sI,K9n,V9n,w$n],tct=t=>ect.find(Jlt(t));function x$n(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Ust(t):!0}const k$n=new Set(["brightness","contrast","saturate","opacity"]);function E$n(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(qke)||[];if(!r)return t;const i=n.replace(r,"");let o=k$n.has(e)?1:0;return r!==n&&(o*=100),e+"("+o+i+")"}const C$n=/\b([a-z-]*)\(.*?\)/gu,wEe={...Wv,getAnimatableNone:t=>{const e=t.match(C$n);return e?e.map(E$n).join(" "):t}},xEe={...Wv,getAnimatableNone:t=>{const e=Wv.parse(t);return Wv.createTransformer(t)(e.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},nct={...YP,transform:Math.round},kEe={borderWidth:Ja,borderTopWidth:Ja,borderRightWidth:Ja,borderBottomWidth:Ja,borderLeftWidth:Ja,borderRadius:Ja,borderTopLeftRadius:Ja,borderTopRightRadius:Ja,borderBottomRightRadius:Ja,borderBottomLeftRadius:Ja,width:Ja,maxWidth:Ja,height:Ja,maxHeight:Ja,top:Ja,right:Ja,bottom:Ja,left:Ja,inset:Ja,insetBlock:Ja,insetBlockStart:Ja,insetBlockEnd:Ja,insetInline:Ja,insetInlineStart:Ja,insetInlineEnd:Ja,padding:Ja,paddingTop:Ja,paddingRight:Ja,paddingBottom:Ja,paddingLeft:Ja,paddingBlock:Ja,paddingBlockStart:Ja,paddingBlockEnd:Ja,paddingInline:Ja,paddingInlineStart:Ja,paddingInlineEnd:Ja,margin:Ja,marginTop:Ja,marginRight:Ja,marginBottom:Ja,marginLeft:Ja,marginBlock:Ja,marginBlockStart:Ja,marginBlockEnd:Ja,marginInline:Ja,marginInlineStart:Ja,marginInlineEnd:Ja,fontSize:Ja,backgroundPositionX:Ja,backgroundPositionY:Ja,...{rotate:sI,rotateX:sI,rotateY:sI,rotateZ:sI,scale:Qte,scaleX:Qte,scaleY:Qte,scaleZ:Qte,skew:sI,skewX:sI,skewY:sI,distance:Ja,translateX:Ja,translateY:Ja,translateZ:Ja,x:Ja,y:Ja,z:Ja,perspective:Ja,transformPerspective:Ja,opacity:K7,originX:plt,originY:plt,originZ:Ja},zIndex:nct,fillOpacity:K7,strokeOpacity:K7,numOctaves:nct},S$n={...kEe,color:tp,backgroundColor:tp,outlineColor:tp,fill:tp,stroke:tp,borderColor:tp,borderTopColor:tp,borderRightColor:tp,borderBottomColor:tp,borderLeftColor:tp,filter:wEe,WebkitFilter:wEe,mask:xEe,WebkitMask:xEe},rct=t=>S$n[t],I$n=new Set([wEe,xEe]);function act(t,e){let n=rct(t);return I$n.has(n)||(n=Wv),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const T$n=new Set(["auto","none","0"]);function B$n(t,e,n){let r=0,i;for(;r<t.length&&!i;){const o=t[r];typeof o=="string"&&!T$n.has(o)&&KP(o).values.length&&(i=t[r]),r++}if(i&&n)for(const o of e)t[o]=act(n,i)}class D$n extends uEe{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(),Uke(g))){const h=Hlt(g,n.current);h!==void 0&&(e[m]=h),m===e.length-1&&(this.finalKeyframe=g)}}if(this.resolveNoneKeyframes(),!Vlt.has(r)||e.length!==2)return;const[i,o]=e,l=tct(i),u=tct(o),d=ult(i),p=ult(o);if(d!==p&&lI[r]){this.needsMeasurement=!0;return}if(l!==u)if(Nlt(l)&&Nlt(u))for(let m=0;m<e.length;m++){const g=e[m];typeof g=="string"&&(e[m]=parseFloat(g))}else lI[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let i=0;i<e.length;i++)(e[i]===null||x$n(e[i]))&&r.push(i);r.length&&B$n(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=lI[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]=lI[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 Ute(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 ict=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function qte(t){return zst(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:EEe}=slt(queueMicrotask,!1),Yv={x:!1,y:!1};function oct(){return Yv.x||Yv.y}function N$n(t){return t==="x"||t==="y"?Yv[t]?null:(Yv[t]=!0,()=>{Yv[t]=!1}):Yv.x||Yv.y?null:(Yv.x=Yv.y=!0,()=>{Yv.x=Yv.y=!1})}function sct(t,e){const n=Ute(t),r=new AbortController,i={passive:!0,...e,signal:r.signal};return[n,i,()=>r.abort()]}function R$n(t){return!(t.pointerType==="touch"||oct())}function L$n(t,e,n={}){const[r,i,o]=sct(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(!R$n(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 lct=(t,e)=>e?t===e?!0:lct(t,e.parentElement):!1,CEe=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,M$n=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function P$n(t){return M$n.has(t.tagName)||t.isContentEditable===!0}const O$n=new Set(["INPUT","SELECT","TEXTAREA"]);function F$n(t){return O$n.has(t.tagName)||t.isContentEditable===!0}const Gte=new WeakSet;function cct(t){return e=>{e.key==="Enter"&&t(e)}}function SEe(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Q$n=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=cct(()=>{if(Gte.has(n))return;SEe(n,"down");const i=cct(()=>{SEe(n,"up")}),o=()=>SEe(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 uct(t){return CEe(t)&&!oct()}const dct=new WeakSet;function $$n(t,e,n={}){const[r,i,o]=sct(t,n),l=u=>{const d=u.currentTarget;if(!uct(u)||dct.has(u))return;Gte.add(d),n.stopPropagation&&dct.add(u);const p=e(d,u),m=(f,b)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",h),Gte.has(d)&&Gte.delete(d),uct(f)&&typeof p=="function"&&p(f,{success:b})},g=f=>{m(f,d===window||d===document||n.useGlobalTarget||lct(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),qte(u)&&(u.addEventListener("focus",p=>Q$n(p,i)),!P$n(u)&&!u.hasAttribute("tabindex")&&(u.tabIndex=0))}),o}function Hte(t){return zst(t)&&"ownerSVGElement"in t}const Wte=new WeakMap;let Yte;const pct=(t,e,n)=>(r,i)=>i&&i[0]?i[0][t+"Size"]:Hte(r)&&"getBBox"in r?r.getBBox()[e]:r[n],j$n=pct("inline","width","offsetWidth"),z$n=pct("block","height","offsetHeight");function U$n({target:t,borderBoxSize:e}){Wte.get(t)?.forEach(n=>{n(t,{get width(){return j$n(t,e)},get height(){return z$n(t,e)}})})}function q$n(t){t.forEach(U$n)}function G$n(){typeof ResizeObserver>"u"||(Yte=new ResizeObserver(q$n))}function H$n(t,e){Yte||G$n();const n=Ute(t);return n.forEach(r=>{let i=Wte.get(r);i||(i=new Set,Wte.set(r,i)),i.add(e),Yte?.observe(r)}),()=>{n.forEach(r=>{const i=Wte.get(r);i?.delete(e),i?.size||Yte?.unobserve(r)})}}const Vte=new Set;let e5;function W$n(){e5=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Vte.forEach(e=>e(t))},window.addEventListener("resize",e5)}function Y$n(t){return Vte.add(t),e5||W$n(),()=>{Vte.delete(t),!Vte.size&&typeof e5=="function"&&(window.removeEventListener("resize",e5),e5=void 0)}}function mct(t,e){return typeof t=="function"?Y$n(t):H$n(t,e)}function gct(t){return Hte(t)&&t.tagName==="svg"}function V$n(...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=Elt(i,o,l);return e?u(r):u}function K$n(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=hct(t.get()),h=hct(o);if(g===h){d();return}const f=i?i.getGeneratorVelocity():t.getVelocity();d(),i=new ez({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(IEe(f,u)),Nl.postRender(m)},d),Sd(e)){let g=n.skipInitialAnimation===!0;const h=e.on("change",b=>{g?(g=!1,t.jump(IEe(b,u),!1)):t.set(IEe(b,u))}),f=t.on("destroy",h);return()=>{h(),f()}}return d}function IEe(t,e){return e?t+e:t}function hct(t){return typeof t=="number"?t:parseFloat(t)}const Z$n=[...ect,tp,Wv],X$n=t=>Z$n.find(Jlt(t)),fct=()=>({translate:0,scale:1,origin:0,originPoint:0}),t5=()=>({x:fct(),y:fct()}),Act=()=>({min:0,max:0}),np=()=>({x:Act(),y:Act()}),rz=new WeakMap;function Kte(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function az(t){return typeof t=="string"||Array.isArray(t)}const TEe=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],BEe=["initial",...TEe];function Zte(t){return Kte(t.animate)||BEe.some(e=>az(t[e]))}function bct(t){return!!(Zte(t)||t.variants)}function J$n(t,e,n){for(const r in e){const i=e[r],o=n[r];if(Sd(i))t.addValue(r,i);else if(Sd(o))t.addValue(r,cI(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,cI(l!==void 0?l:i,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const DEe={current:null},yct={current:!1},ejn=typeof window<"u";function tjn(){if(yct.current=!0,!!ejn)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>DEe.current=t.matches;t.addEventListener("change",e),e()}else DEe.current=!1}const vct=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Xte={};function _ct(t){Xte=t}function njn(){return Xte}class wct{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=uEe,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=hf.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,Nl.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=Zte(n),this.isVariantNode=bct(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&&Sd(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,rz.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:(yct.current||tjn(),this.shouldReduceMotion=DEe.current),process.env.NODE_ENV!=="production"&&Fke(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(),E1(this.notifyUpdate),E1(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&&Ult.has(e)&&this.current instanceof HTMLElement){const{factory:l,keyframes:u,times:d,ease:p,duration:m}=n.accelerate,g=new $lt({element:this.current,name:e,keyframes:u,times:d,ease:p,duration:gf(m)}),h=l(g);this.valueSubscriptions.set(e,()=>{h(),g.cancel()});return}const r=JP.has(e);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",l=>{this.latestValues[e]=l,this.props.onUpdate&&Nl.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 Xte){const n=Xte[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):np()}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<vct.length;r++){const i=vct[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=J$n(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=cI(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"&&(jst(r)||Ust(r))?r=parseFloat(r):!X$n(r)&&Wv.test(n)&&(r=act(e,n)),this.setBaseTarget(e,Sd(r)?r.get():r)),Sd(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=fEe(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&&!Sd(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 Oke),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){EEe.render(this.render)}}class xct extends wct{constructor(){super(...arguments),this.KeyframeResolver=D$n}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;Sd(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class uI{constructor(e){this.isMounted=!1,this.node=e}update(){}}function kct({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function rjn({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function ajn(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 NEe(t){return t===void 0||t===1}function REe({scale:t,scaleX:e,scaleY:n}){return!NEe(t)||!NEe(e)||!NEe(n)}function jN(t){return REe(t)||Ect(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Ect(t){return Cct(t.x)||Cct(t.y)}function Cct(t){return t&&t!=="0%"}function Jte(t,e,n){const r=t-n,i=e*r;return n+i}function Sct(t,e,n,r,i){return i!==void 0&&(t=Jte(t,i,r)),Jte(t,n,r)+e}function LEe(t,e=0,n=1,r,i){t.min=Sct(t.min,e,n,r,i),t.max=Sct(t.max,e,n,r,i)}function Ict(t,{x:e,y:n}){LEe(t.x,e.translate,e.scale,e.originPoint),LEe(t.y,n.translate,n.scale,n.originPoint)}const Tct=.999999999999,Bct=1.0000000000001;function ijn(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&&(px(t.x,-o.scroll.offset.x),px(t.y,-o.scroll.offset.y)),l&&(e.x*=l.x.scale,e.y*=l.y.scale,Ict(t,l)),r&&jN(o.latestValues)&&ene(t,o.latestValues,o.layout?.layoutBox))}e.x<Bct&&e.x>Tct&&(e.x=1),e.y<Bct&&e.y>Tct&&(e.y=1)}function px(t,e){t.min+=e,t.max+=e}function Dct(t,e,n,r,i=.5){const o=Dc(t.min,t.max,i);LEe(t,e,n,o,r)}function Nct(t,e){return typeof t=="string"?parseFloat(t)/100*(e.max-e.min):t}function ene(t,e,n){const r=n??t;Dct(t.x,Nct(e.x,r.x),e.scaleX,e.scale,e.originX),Dct(t.y,Nct(e.y,r.y),e.scaleY,e.scale,e.originY)}function Rct(t,e){return kct(ajn(t.getBoundingClientRect(),e))}function ojn(t,e,n){const r=Rct(t,n),{scroll:i}=e;return i&&(px(r.x,i.offset.x),px(r.y,i.offset.y)),r}const sjn={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},ljn=XP.length;function cjn(t,e,n){let r="",i=!0;for(let o=0;o<ljn;o++){const l=XP[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=ict(u,kEe[l]);if(!d){i=!1;const m=sjn[l]||l;r+=`${m}(${p}) `}n&&(e[l]=p)}}return r=r.trim(),n?r=n(e,i?"":r):i&&(r="none"),r}function MEe(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(JP.has(d)){l=!0;continue}else if(clt(d)){i[d]=p;continue}else{const m=ict(p,kEe[d]);d.startsWith("origin")?(u=!0,o[d]=m):r[d]=m}}if(e.transform||(l||n?r.transform=cjn(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 Lct(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 Mct(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const iz={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(Ja.test(t))t=parseFloat(t);else return t;const n=Mct(t,e.target.x),r=Mct(t,e.target.y);return`${n}% ${r}%`}},ujn={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,i=Wv.parse(t);if(i.length>5)return r;const o=Wv.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=Dc(u,d,.5);return typeof i[2+l]=="number"&&(i[2+l]/=p),typeof i[3+l]=="number"&&(i[3+l]/=p),o(i)}},PEe={borderRadius:{...iz,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:iz,borderTopRightRadius:iz,borderBottomLeftRadius:iz,borderBottomRightRadius:iz,boxShadow:ujn};function Pct(t,{layout:e,layoutId:n}){return JP.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!PEe[t]||t==="opacity")}function OEe(t,e,n){const r=t.style,i=e?.style,o={};if(!r)return o;for(const l in r)(Sd(r[l])||i&&Sd(i[l])||Pct(l,t)||n?.getValue(l)?.liveStyle!==void 0)&&(o[l]=r[l]);return o}function djn(t){return window.getComputedStyle(t)}class Oct extends xct{constructor(){super(...arguments),this.type="html",this.renderInstance=Lct}readValueFromInstance(e,n){if(JP.has(n))return this.projection?.isProjecting?iEe(n):NQn(e,n);{const r=djn(e),i=(clt(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Rct(e,n)}build(e,n,r){MEe(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return OEe(e,n,r)}}function pjn(t,e){return t in e}class mjn extends wct{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,n){if(pjn(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 np()}build(e,n){Object.assign(e.output,n)}renderInstance(e,{output:n}){Object.assign(e,n)}sortInstanceNodePosition(){return 0}}const gjn={offset:"stroke-dashoffset",array:"stroke-dasharray"},hjn={offset:"strokeDashoffset",array:"strokeDasharray"};function fjn(t,e,n=1,r=0,i=!0){t.pathLength=1;const o=i?gjn:hjn;t[o.offset]=`${-r}`,t[o.array]=`${e} ${n}`}const Ajn=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Fct(t,{attrX:e,attrY:n,attrScale:r,pathLength:i,pathSpacing:o=1,pathOffset:l=0,...u},d,p,m){if(MEe(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 Ajn)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&&fjn(g,i,o,l,!1)}const Qct=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"]),$ct=t=>typeof t=="string"&&t.toLowerCase()==="svg";function bjn(t,e,n,r){Lct(t,e,void 0,r);for(const i in e.attrs)t.setAttribute(Qct.has(i)?i:yEe(i),e.attrs[i])}function jct(t,e,n){const r=OEe(t,e,n);for(const i in t)if(Sd(t[i])||Sd(e[i])){const o=XP.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[o]=t[i]}return r}class zct extends xct{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=np}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(JP.has(n)){const r=rct(n);return r&&r.default||0}return n=Qct.has(n)?n:yEe(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return jct(e,n,r)}build(e,n,r){Fct(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,i){bjn(e,n,r,i)}mount(e){this.isSVGTag=$ct(e.tagName),super.mount(e)}}const yjn=BEe.length;function Uct(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Uct(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<yjn;n++){const r=BEe[n],i=t.props[r];(az(i)||i===!1)&&(e[r]=i)}return e}function qct(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 vjn=[...TEe].reverse(),_jn=TEe.length;function wjn(t){return e=>Promise.all(e.map(({animation:n,options:r})=>_$n(t,n,r)))}function xjn(t){let e=wjn(t),n=Gct(),r=!0,i=!1;const o=p=>(m,g)=>{const h=$N(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=Uct(t.parent)||{},h=[],f=new Set;let b={},y=1/0;for(let _=0;_<_jn;_++){const w=vjn[_],x=n[w],k=m[w]!==void 0?m[w]:g[w],C=az(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||Kte(k)||typeof k=="boolean")continue;if(w==="exit"&&x.isActive&&E!==!0){x.prevResolvedValues&&(b={...b,...x.prevResolvedValues});continue}const I=kjn(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=Q=>{B=!0,f.has(Q)&&(N=!0,f.delete(Q)),x.needsAnimating[Q]=!0;const j=t.getValue(Q);j&&(j.liveStyle=!1)};for(const Q in D){const j=M[Q],$=R[Q];if(b.hasOwnProperty(Q))continue;let z=!1;AEe(j)&&AEe($)?z=!qct(j,$):z=j!==$,z?j!=null?P(Q):f.add(Q):j!==void 0&&f.has(Q)?P(Q):x.protectedKeys[Q]=!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(Q=>{const j={type:w};if(typeof Q=="string"&&(r||i)&&!O&&t.manuallyAnimateOnMount&&t.parent){const{parent:$}=t,z=$N($,Q);if($.enteringChildren&&z){const{delayChildren:U}=z.transition||{};j.delay=Glt($.enteringChildren,t,U)}}return{animation:Q,options:j}}))}if(f.size){const _={};if(typeof m.initial!="boolean"){const w=$N(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=Gct(),i=!0}}}function kjn(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!qct(e,t):!1}function zN(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Gct(){return{animate:zN(!0),whileInView:zN(),whileHover:zN(),whileTap:zN(),whileDrag:zN(),whileFocus:zN(),exit:zN()}}function FEe(t,e){t.min=e.min,t.max=e.max}function Vv(t,e){FEe(t.x,e.x),FEe(t.y,e.y)}function Hct(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const Wct=1e-4,Ejn=1-Wct,Cjn=1+Wct,Yct=.01,Sjn=0-Yct,Ijn=0+Yct;function ff(t){return t.max-t.min}function Tjn(t,e,n){return Math.abs(t-e)<=n}function Vct(t,e,n,r=.5){t.origin=r,t.originPoint=Dc(e.min,e.max,t.origin),t.scale=ff(n)/ff(e),t.translate=Dc(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Ejn&&t.scale<=Cjn||isNaN(t.scale))&&(t.scale=1),(t.translate>=Sjn&&t.translate<=Ijn||isNaN(t.translate))&&(t.translate=0)}function oz(t,e,n,r){Vct(t.x,e.x,n.x,r?r.originX:void 0),Vct(t.y,e.y,n.y,r?r.originY:void 0)}function Kct(t,e,n,r=0){const i=r?Dc(n.min,n.max,r):n.min;t.min=i+e.min,t.max=t.min+ff(e)}function Bjn(t,e,n,r){Kct(t.x,e.x,n.x,r?.x),Kct(t.y,e.y,n.y,r?.y)}function Zct(t,e,n,r=0){const i=r?Dc(n.min,n.max,r):n.min;t.min=e.min-i,t.max=t.min+ff(e)}function tne(t,e,n,r){Zct(t.x,e.x,n.x,r?.x),Zct(t.y,e.y,n.y,r?.y)}function Xct(t,e,n,r,i){return t-=e,t=Jte(t,1/n,r),i!==void 0&&(t=Jte(t,1/i,r)),t}function Djn(t,e=0,n=1,r=.5,i,o=t,l=t){if(dx.test(e)&&(e=parseFloat(e),e=Dc(l.min,l.max,e/100)-l.min),typeof e!="number")return;let u=Dc(o.min,o.max,r);t===o&&(u-=e),t.min=Xct(t.min,e,n,u,i),t.max=Xct(t.max,e,n,u,i)}function Jct(t,e,[n,r,i],o,l){Djn(t,e[n],e[r],e[i],e.scale,o,l)}const Njn=["x","scaleX","originX"],Rjn=["y","scaleY","originY"];function eut(t,e,n,r){Jct(t.x,e,Njn,n?n.x:void 0,r?r.x:void 0),Jct(t.y,e,Rjn,n?n.y:void 0,r?r.y:void 0)}function tut(t){return t.translate===0&&t.scale===1}function nut(t){return tut(t.x)&&tut(t.y)}function rut(t,e){return t.min===e.min&&t.max===e.max}function Ljn(t,e){return rut(t.x,e.x)&&rut(t.y,e.y)}function aut(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function iut(t,e){return aut(t.x,e.x)&&aut(t.y,e.y)}function out(t){return ff(t.x)/ff(t.y)}function sut(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function mx(t){return[t("x"),t("y")]}function Mjn(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 lut=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],Pjn=lut.length,cut=t=>typeof t=="string"?parseFloat(t):t,uut=t=>typeof t=="number"||Ja.test(t);function Ojn(t,e,n,r,i,o){i?(t.opacity=Dc(0,n.opacity??1,Fjn(r)),t.opacityExit=Dc(e.opacity??1,0,Qjn(r))):o&&(t.opacity=Dc(e.opacity??1,n.opacity??1,r));for(let l=0;l<Pjn;l++){const u=lut[l];let d=dut(e,u),p=dut(n,u);if(d===void 0&&p===void 0)continue;d||(d=0),p||(p=0),d===0||p===0||uut(d)===uut(p)?(t[u]=Math.max(Dc(cut(d),cut(p),r),0),(dx.test(p)||dx.test(d))&&(t[u]+="%")):t[u]=p}(e.rotate||n.rotate)&&(t.rotate=Dc(e.rotate||0,n.rotate||0,r))}function dut(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Fjn=put(0,.5,Jst),Qjn=put(.5,.95,ry);function put(t,e,n){return r=>r<t?0:r>e?1:n(WP(t,e,r))}function mut(t,e,n){const r=Sd(t)?t:cI(t);return r.start(hEe("",r,e,n)),r.animation}function sz(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}const $jn=(t,e)=>t.depth-e.depth;class jjn{constructor(){this.children=[],this.isDirty=!1}add(e){Mke(this.children,e),this.isDirty=!0}remove(e){GP(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort($jn),this.isDirty=!1,this.children.forEach(e)}}function zjn(t,e){const n=hf.now(),r=({timestamp:i})=>{const o=i-n;o>=e&&(E1(r),t(o-e))};return Nl.setup(r,!0),()=>E1(r)}function nne(t){return Sd(t)?t.get():t}class Ujn{constructor(){this.members=[]}add(e){Mke(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&&(GP(this.members,r),r.unmount())}e.scheduleRender()}remove(e){if(GP(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 rne={hasAnimatedSinceResize:!0,hasEverUpdated:!1},QEe=["","X","Y","Z"],qjn=1e3;let Gjn=0;function $Ee(t,e,n,r){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),r&&(r[t]=0))}function gut(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Xlt(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Nl,!(i||o))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&gut(r)}function hut({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(l={},u=e?.()){this.id=Gjn++,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(Yjn),this.nodes.forEach(e7n),this.nodes.forEach(t7n),this.nodes.forEach(Vjn)},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 jjn)}addEventListener(l,u){return this.eventHandlers.has(l)||this.eventHandlers.set(l,new Oke),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=Hte(l)&&!gct(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;Nl.read(()=>{g=window.innerWidth}),t(l,()=>{const f=window.innerWidth;f!==g&&(g=f,this.root.updateBlockedByResize=!0,m&&m(),m=zjn(h,250),rne.hasAnimatedSinceResize&&(rne.hasAnimatedSinceResize=!1,this.nodes.forEach(but)))})}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()||o7n,{onLayoutAnimationStart:y,onLayoutAnimationComplete:v}=p.getProps(),_=!this.targetLayout||!iut(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={...gEe(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||but(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(),E1(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(n7n),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&&gut(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(Zjn),this.nodes.forEach(fut);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Aut);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Xjn),this.nodes.forEach(Jjn),this.nodes.forEach(Hjn),this.nodes.forEach(Wjn)):this.nodes.forEach(Aut),this.clearAllSnapshots();const u=hf.now();mg.delta=ux(0,1e3/60,u-mg.timestamp),mg.timestamp=u,mg.isProcessing=!0,zke.update.process(mg),zke.preRender.process(mg),zke.render.process(mg),mg.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,EEe.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Kjn),this.sharedNodes.forEach(r7n)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Nl.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Nl.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ff(this.snapshot.measuredBox.x)&&!ff(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=np()),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&&!nut(this.projectionDelta),d=this.getTransformTemplate(),p=d?d(this.latestValues,""):void 0,m=p!==this.prevTransformTemplateValue;l&&this.instance&&(u||jN(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)),s7n(d),{animationId:this.root.animationId,measuredBox:u,layoutBox:d,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:l}=this.options;if(!l)return np();const u=l.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(l7n))){const{scroll:p}=this.root;p&&(px(u.x,p.offset.x),px(u.y,p.offset.y))}return u}removeElementScroll(l){const u=np();if(Vv(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&&Vv(u,l),px(u.x,m.offset.x),px(u.y,m.offset.y))}return u}applyTransform(l,u=!1,d){const p=d||np();Vv(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&&(px(p.x,-g.scroll.offset.x),px(p.y,-g.scroll.offset.y)),jN(g.latestValues)&&ene(p,g.latestValues,g.layout?.layoutBox)}return jN(this.latestValues)&&ene(p,this.latestValues,this.layout?.layoutBox),p}removeTransform(l){const u=np();Vv(u,l);for(let d=0;d<this.path.length;d++){const p=this.path[d];if(!jN(p.latestValues))continue;let m;p.instance&&(REe(p.latestValues)&&p.updateSnapshot(),m=np(),Vv(m,p.measurePageBox())),eut(u,p.latestValues,p.snapshot?.layoutBox,m)}return jN(this.latestValues)&&eut(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!==mg.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=mg.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=np(),this.targetWithTransforms=np()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Bjn(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Vv(this.target,this.layout.layoutBox),Ict(this.target,this.targetDelta)):Vv(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||REe(this.parent.latestValues)||Ect(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=np(),this.relativeTargetOrigin=np(),tne(this.relativeTargetOrigin,u,d,this.options.layoutAnchor||void 0),Vv(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===mg.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;Vv(this.layoutCorrected,this.layout.layoutBox);const g=this.treeScale.x,h=this.treeScale.y;ijn(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=np());const{target:f}=l;if(!f){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Hct(this.prevProjectionDelta.x,this.projectionDelta.x),Hct(this.prevProjectionDelta.y,this.projectionDelta.y)),oz(this.projectionDelta,this.layoutCorrected,f,this.latestValues),(this.treeScale.x!==g||this.treeScale.y!==h||!sut(this.projectionDelta.x,this.prevProjectionDelta.x)||!sut(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=t5(),this.projectionDelta=t5(),this.projectionDeltaWithTransform=t5()}setAnimationOrigin(l,u=!1){const d=this.snapshot,p=d?d.latestValues:{},m={...this.latestValues},g=t5();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!u;const h=np(),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(i7n));this.animationProgress=0;let x;this.mixTargetDelta=k=>{const C=k/1e3;yut(g.x,l.x,C),yut(g.y,l.y,C),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(tne(h,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),a7n(this.relativeTarget,this.relativeTargetOrigin,h,C),x&&Ljn(this.relativeTarget,x)&&(this.isProjectionDirty=!1),x||(x=np()),Vv(x,this.relativeTarget)),y&&(this.animationValues=m,Ojn(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&&(E1(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Nl.update(()=>{rne.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=cI(0)),this.motionValue.jump(0,!1),this.currentAnimation=mut(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(qjn),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&&kut(this.options.animationType,this.layout.layoutBox,p.layoutBox)){d=this.target||np();const g=ff(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+g;const h=ff(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+h}Vv(u,d),ene(u,m),oz(this.projectionDeltaWithTransform,this.layoutCorrected,u,m)}}registerSharedNode(l,u){this.sharedNodes.has(l)||this.sharedNodes.set(l,new Ujn),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&&$Ee("z",l,p,this.animationValues);for(let m=0;m<QEe.length;m++)$Ee(`rotate${QEe[m]}`,l,p,this.animationValues),$Ee(`skew${QEe[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=nne(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=nne(u?.pointerEvents)||""),this.hasProjected&&!jN(this.latestValues)&&(l.transform=d?d({},""):"none",this.hasProjected=!1);return}l.visibility="";const m=p.animationValues||p.latestValues;this.applyTransformsToTarget();let g=Mjn(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 PEe){if(m[b]===void 0)continue;const{correct:y,applyTo:v,isCSSVariable:_}=PEe[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?nne(u?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(l=>l.currentAnimation?.stop()),this.root.nodes.forEach(fut),this.root.sharedNodes.clear()}}}function Hjn(t){t.updateLayout()}function Wjn(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")mx(m=>{const g=o?e.measuredBox[m]:e.layoutBox[m],h=ff(g);g.min=n[m].min,g.max=g.min+h});else if(i==="x"||i==="y"){const m=i==="x"?"y":"x";FEe(o?e.measuredBox[m]:e.layoutBox[m],n[m])}else kut(i,e.layoutBox,n)&&mx(m=>{const g=o?e.measuredBox[m]:e.layoutBox[m],h=ff(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=t5();oz(l,n,e.layoutBox);const u=t5();o?oz(u,t.applyTransform(r,!0),e.measuredBox):oz(u,n,e.layoutBox);const d=!nut(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=np();tne(b,e.layoutBox,g.layoutBox,f);const y=np();tne(y,n,h.layoutBox,f),iut(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 Yjn(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 Vjn(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Kjn(t){t.clearSnapshot()}function fut(t){t.clearMeasurements()}function Zjn(t){t.isLayoutDirty=!0,t.updateLayout()}function Aut(t){t.isLayoutDirty=!1}function Xjn(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function Jjn(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function but(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function e7n(t){t.resolveTargetDelta()}function t7n(t){t.calcProjection()}function n7n(t){t.resetSkewAndRotation()}function r7n(t){t.removeLeadSnapshot()}function yut(t,e,n){t.translate=Dc(e.translate,0,n),t.scale=Dc(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function vut(t,e,n,r){t.min=Dc(e.min,n.min,r),t.max=Dc(e.max,n.max,r)}function a7n(t,e,n,r){vut(t.x,e.x,n.x,r),vut(t.y,e.y,n.y,r)}function i7n(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const o7n={duration:.45,ease:[.4,0,.1,1]},_ut=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),wut=_ut("applewebkit/")&&!_ut("chrome/")?Math.round:ry;function xut(t){t.min=wut(t.min),t.max=wut(t.max)}function s7n(t){xut(t.x),xut(t.y)}function kut(t,e,n){return t==="position"||t==="preserve-aspect"&&!Tjn(out(e),out(n),.2)}function l7n(t){return t!==t.root&&t.scroll?.wasRoot}const c7n=hut({attachResizeListener:(t,e)=>sz(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),u7n=t=>!t.isLayoutDirty&&t.willUpdate(!1);function Eut(){const t=new Set,e=new WeakMap,n=()=>t.forEach(u7n);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 jEe={current:void 0},Cut=hut({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!jEe.current){const t=new c7n({});t.mount(window),t.setOptions({layoutScroll:!0}),jEe.current=t}return jEe.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),lz=T.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Sut(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function d7n(...t){return e=>{let n=!1;const r=t.map(i=>{const o=Sut(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():Sut(t[i],null)}}}}function p7n(...t){return ee.useCallback(d7n(...t),t)}class m7n extends ee.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(qte(n)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const r=n.offsetParent,i=qte(r)&&r.offsetWidth||0,o=qte(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 g7n({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(lz),m=t.props?.ref??t?.ref,g=p7n(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(`
|
|
110
|
+
`).slice(1,5).join(" <- ")),p(m,!0);try{const[h,f]=await Promise.all([pg.getMessages(d,{limit:dte}),pg.getTokenStats(d).catch(()=>null)]),b=Hxe(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>=dte,f?.total_tokens!=null&&(v.tokenUsage=f.total_tokens),Xxe(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||jb.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 pg.getMessages(d,{before:m.id,limit:dte}),h=Hxe(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>=dte,b.loadingOlderMessages=!1}})}catch(g){console.error("Failed to load older messages:",g),t(h=>{const f=h.channels[d];f&&(f.loadingOlderMessages=!1)})}}},...rFn(t,e,u),...PFn(t,e,u),...DFn(t,e,u)}},FFn={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 DN(t){return(t/(1024*1024)).toFixed(1)}function Dot(t){const e=t.slice(0,3).map(r=>r.name).join(", "),n=t.length>3?no.t("app.input.moreFilesSuffix",{count:t.length-3}):"";return e+n}function Not(t,e){switch(e.reason){case"file_too_large":return no.t("app.input.fileTooLargeDetail",{name:t.name,maxSize:DN(e.maxSize??t.size),actualSize:DN(e.actualSize??t.size)});case"unsupported_type":return no.t("app.input.unsupportedFileTypeDetail",{name:t.name});default:return e.error||t.name}}const QFn=(t,e)=>({uploadedFiles:[],isUploading:!1,uploadError:null,fileUploadOptions:{...FFn},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=ys.validateFile(m,{maxSize:i.maxSize,allowedTypes:i.allowedTypes});g.valid||l.push(Not(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(no.t("app.input.totalSizeExceededMessage",{maxSize:DN(i.maxTotalSize||20*1024*1024),actualSize:DN(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=ys.validateFile(C,{maxSize:i.maxSize,allowedTypes:i.allowedTypes});E.valid?l.push(C):(u.push({file:C,validation:E}),d.push(Not(C,E)))}const p=u.filter(({validation:C})=>C.reason==="file_too_large").map(({file:C})=>C);p.length>0&&e().showNotification(no.t("app.input.fileTooLargeTitle"),no.t("app.input.fileTooLargeMessage",{files:Dot(p),maxSize:DN(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(no.t("app.input.unsupportedFilesTitle"),no.t("app.input.unsupportedFilesMessage",{files:Dot(m)}),"warning");const g=Math.max(0,(i.maxFiles||5)-o.length);if(g===0){const C=no.t("app.dragDrop.maxReached");t({uploadError:C}),e().showNotification(no.t("app.input.fileLimitTitle"),C,"warning");return}const h=l.slice(0,g);l.slice(g).length>0&&e().showNotification(no.t("app.input.fileLimitTitle"),no.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=no.t("app.input.totalSizeExceededMessage",{maxSize:DN(b),actualSize:DN(v)});t({uploadError:C}),e().showNotification(no.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:ys.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 ys.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 ys.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&&ys.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&&ys.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 ys.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 $Fn{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 pf=new $Fn,jFn=(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 pf.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 pf.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)})}}),zFn=(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={}})}}),NA={MCP_SERVERS:"mcpServers",MCP_SERVER_CREATE:"mcpServerCreate",MCP_SERVER_UPDATE:"mcpServerUpdate",MCP_SERVER_DELETE:"mcpServerDelete"},_1={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 UFn(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 qFn(t){return Array.isArray(t)?t.filter(e=>e&&typeof e=="object").map(e=>UFn(e)):(console.warn("convertBuiltinServers: input is not an array",t),[])}const GFn=(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(NA.MCP_SERVERS,!0);try{console.log("McpSlice: Starting to fetch MCP servers...");const o=await _1.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(NA.MCP_SERVERS,!1)}},fetchBuiltinMcpServers:async()=>{try{const n=await _1.getBuiltinMcpServers(),r=qFn(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(NA.MCP_SERVERS,!0);try{await _1.refreshMcpServers(),setTimeout(()=>{e().fetchMcpServers()},1e3)}catch(r){console.error("Failed to refresh MCP servers:",r)}finally{setTimeout(()=>n(NA.MCP_SERVERS,!1),1500)}},addMcpServer:async n=>{const{setLoading:r}=e();r(NA.MCP_SERVER_CREATE,!0);try{const i=await _1.createMcpServer(n);t(o=>{o.mcpServers.push(i)}),e().closeAddMcpServerModal()}catch(i){throw console.error("Failed to add MCP server:",i),i}finally{r(NA.MCP_SERVER_CREATE,!1)}},quickAddBuiltinServer:async n=>{const{backendUrl:r,token:i,setLoading:o}=e();o(NA.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 _1.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(NA.MCP_SERVER_CREATE,!1)}},activateSmitheryServer:async(n,r)=>{const{setLoading:i}=e();i(NA.MCP_SERVER_CREATE,!0);try{const o=await _1.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(NA.MCP_SERVER_CREATE,!1)}},editMcpServer:async(n,r)=>{const{setLoading:i}=e();i(NA.MCP_SERVER_UPDATE,!0);try{const o=await _1.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(NA.MCP_SERVER_UPDATE,!1)}},removeMcpServer:async n=>{const{setLoading:r}=e();r(NA.MCP_SERVER_DELETE,!0);try{await _1.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(NA.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)})}}),HFn=(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})}}),WFn=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 tke{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 YFn(t,e){if(t?.provider_id){const o=e.find(l=>l.id===t.provider_id);if(o)return o}const n=tke.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 VFn=(t,e)=>({userDefaultProviderId:null,initializeProviderPreferences:()=>{const n=tke.getDefaultProviderId();t({userDefaultProviderId:n})},setUserDefaultProvider:n=>{tke.setDefaultProvider(n),t({userDefaultProviderId:n})},getUserDefaultProvider:n=>{const{userDefaultProviderId:r}=e();return r&&n.find(i=>i.id===r)||null},resolveProviderForAgent:(n,r)=>YFn(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 KFn{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 pte=new KFn;class ZFn{ws=null;handlers=new Map;reconnectTimer=null;reconnectDelay=1e3;maxReconnectDelay=3e4;intentionalClose=!1;connect(){if(this.ws?.readyState===WebSocket.OPEN)return;const e=Co.getToken();if(!e)return;const n=ad().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 QP=new ZFn,XFn=(t,e)=>({runners:[],runnersLoading:!1,fetchRunners:async()=>{t({runnersLoading:!0});try{const n=await pte.listRunners();t({runners:n,runnersLoading:!1})}catch{t({runnersLoading:!1})}},createRunnerToken:async n=>{try{const r=await pte.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 pte.deleteRunner(n),t(r=>{r.runners=r.runners.filter(i=>i.id!==n)})}catch{}},updateRunner:async(n,r)=>{try{const i=await pte.updateRunner(n,r);t(o=>{const l=o.runners.findIndex(u=>u.id===n);l>=0&&(o.runners[l]=i)})}catch{}},connectRunnerEvents:()=>{QP.connect();const n=QP.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(),QP.disconnect()}}}),JFn=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})}}),Rot={Sidebar:"sidebar"},e8n=t=>({backendUrl:ad().env.backendUrl,isXyzenOpen:!1,panelWidth:eke,activeTabIndex:0,activePanel:"chat",theme:ad().storage.getItem("theme")||"system",layoutStyle:ad().storage.getItem("layoutStyle")||ad().env.layoutStyle||Rot.Sidebar,inputPosition:ad().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:ad().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=>{ad().storage.setItem("theme",e),t({theme:e})},setLayoutStyle:e=>{ad().storage.setItem("layoutStyle",e),t({layoutStyle:e})},setInputPosition:e=>{ad().storage.setItem("inputPosition",e),t({inputPosition:e})},setBackendUrl:e=>{ad().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=>{ad().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 t8n{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 RA=new t8n,n8n=t=>({walletBalance:null,walletLoading:!1,fetchWallet:async()=>{t({walletLoading:!0});try{const e=await RA.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:()=>{QP.connect();const e=QP.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(),QP.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 nke=null;function r8n(t){nke=t}function mte(){if(!nke)throw new Error("toolbarActions not initialized — call initToolbarActions() at app startup");return nke()}async function a8n(t,e){try{await mte()(t,{model_tier:e,provider_id:null,model:null})}catch(n){console.error("Failed to update session tier:",n)}}async function i8n(t,e,n,r){try{await mte()(t,{model_tier:e,provider_id:n,model:r})}catch(i){console.error("Failed to update session tier model:",i)}}async function o8n(t,e){try{await mte()(t,{sandbox_backend:e})}catch(n){console.error("Failed to update session sandbox backend:",n)}}async function s8n(t,e){try{await mte()(t,{knowledge_set_id:e})}catch(n){console.error("Failed to update session knowledge set:",n)}}EOn(),$5n(TOn),nn.configure({getToken:()=>Co.getToken(),onUnauthorized:()=>{Promise.resolve().then(()=>Y5n).then(t=>t.logout()).catch(()=>{})}}),mOn();let l8n;const c8n={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},Un=bOn()(dot(kOn((...t)=>({...e8n(...t),...OFn(...t),...NOn(...t),...GFn(...t),...HFn(...t),...VFn(...t),...ROn(...t),...zFn(...t),...QFn(...t),...jFn(...t),...WFn(...t),...XFn(...t),...JFn(...t),...n8n(...t)})),{name:"xyzen-storage",storage:uot(()=>l8n??(typeof localStorage<"u"?localStorage:c8n)),partialize:t=>({isXyzenOpen:t.isXyzenOpen,panelWidth:t.panelWidth,activePanel:t.activePanel,theme:t.theme,token:t.token,user:t.user,backendUrl:t.backendUrl,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(W5n(Un),r8n(()=>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 u8n(t){return Un.getState().status!=="succeeded"&&localStorage.getItem("platform")==="bohrium"?(t("provider_bohrium"),!0):!1}async function rke(){try{const t=await Co.getAuthStatus();if(!t.is_configured||!t.provider)throw new Error("Authentication is not configured");const e=await Co.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=CN(n,e,r,o)}else i=CN(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 d8n(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,Uit().then(()=>{u8n(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 Co.getOAuthUrl(M,D,R);O.url&&(P=O.url)}catch{}if(!P)try{const O=await Co.getAuthConfig();P=CN("casdoor",O,D,R,M)}catch{}if(P){u(!0);try{const O=await K5n(P);await ax(O.access_token,O.user_info)}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([Co.getAuthStatus(),Co.getAuthConfig(),Yit()]),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=CN(D,R,`${window.location.origin}${window.location.pathname}`);if(P){window.location.href=P;return}}}catch{}r(!0)},[]),b=T.useCallback(()=>{Uit()},[]),y=T.useCallback(()=>{o(!1)},[]),v=T.useCallback(async(M,R)=>Co.sendVerificationCode(M,R),[]),_=T.useCallback(async(M,R)=>{await Dxe(M,R,"email")},[]),w=T.useCallback(async(M,R,D,P)=>{await Nxe(M,R,D,P)},[]),x=T.useCallback(async(M,R)=>{await Oit(M,R)},[]),k=T.useCallback(async M=>{await Co.sendResetCode(M)},[]),C=T.useCallback(async(M,R,D)=>{await Qit(M,R,D)},[]),E=T.useCallback(async M=>Co.sendPhoneVerificationCode(M),[]),S=T.useCallback(async M=>Co.checkPhoneExists(M),[]),I=T.useCallback(async(M,R)=>{await Dxe(M,R,"phone")},[]),B=T.useCallback(async(M,R)=>{await Fit(M,R)},[]),N=T.useCallback(async(M,R,D,P)=>{await Nxe("",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 NN=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(){}},p8n=class extends NN{#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"}},ake=new p8n,m8n={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},g8n=class{#e=m8n;#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)}},RN=new g8n;function h8n(t){setTimeout(t,0)}var f8n=typeof window>"u"||"Deno"in globalThis;function th(){}function A8n(t,e){return typeof t=="function"?t(e):t}function ike(t){return typeof t=="number"&&t>=0&&t!==1/0}function Lot(t,e){return Math.max(t+(e||0)-Date.now(),0)}function nI(t,e){return typeof t=="function"?t(e):t}function ny(t,e){return typeof t=="function"?t(e):t}function Mot(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:o,queryKey:l,stale:u}=t;if(l){if(r){if(e.queryHash!==oke(l,e.options))return!1}else if(!Q7(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 Pot(t,e){const{exact:n,status:r,predicate:i,mutationKey:o}=t;if(o){if(!e.options.mutationKey)return!1;if(n){if(LN(e.options.mutationKey)!==LN(o))return!1}else if(!Q7(e.options.mutationKey,o))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function oke(t,e){return(e?.queryKeyHashFn||LN)(t)}function LN(t){return JSON.stringify(t,(e,n)=>ske(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Q7(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>Q7(t[n],e[n])):!1}var b8n=Object.prototype.hasOwnProperty;function gte(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=Oot(t)&&Oot(e);if(!r&&!(ske(t)&&ske(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:b8n.call(t,g))&&p++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){d[g]=f;continue}const b=gte(h,f,n+1);d[g]=b,b===h&&p++}return o===u&&p===o?t:d}function $7(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 Oot(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function ske(t){if(!Fot(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Fot(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Fot(t){return Object.prototype.toString.call(t)==="[object Object]"}function y8n(t){return new Promise(e=>{RN.setTimeout(e,t)})}function lke(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 gte(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 gte(t,e)}return e}function v8n(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function _8n(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var hte=Symbol();function Qot(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===hte&&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===hte?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function cke(t,e){return typeof t=="function"?t(...e):!!t}function w8n(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 j7=(()=>{let t=()=>f8n;return{isServer(){return t()},setIsServer(e){t=e}}})();function uke(){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 x8n=h8n;function k8n(){let t=[],e=0,n=u=>{u()},r=u=>{u()},i=x8n;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 id=k8n(),E8n=class extends NN{#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}},fte=new E8n;function C8n(t){return Math.min(1e3*2**t,3e4)}function $ot(t){return(t??"online")==="online"?fte.isOnline():!0}var dke=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function jot(t){let e=!1,n=0,r;const i=uke(),o=()=>i.status!=="pending",l=y=>{if(!o()){const v=new dke(y);h(v),t.onCancel?.(v)}},u=()=>{e=!0},d=()=>{e=!1},p=()=>ake.isFocused()&&(t.networkMode==="always"||fte.isOnline())&&t.canRun(),m=()=>$ot(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??(j7.isServer()?0:3),x=t.retryDelay??C8n,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,_),y8n(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 zot=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ike(this.gcTime)&&(this.#e=RN.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(j7.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(RN.clearTimeout(this.#e),this.#e=void 0)}},S8n=class extends zot{#e;#t;#r;#n;#a;#o;#i;constructor(t){super(),this.#i=!1,this.#o=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=Got(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.#o,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=Got(this.options);e.data!==void 0&&(this.setState(qot(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(t,e){const n=lke(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(th).catch(th):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=>ny(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===hte||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>nI(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:!Lot(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.#s()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#s(){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=Qot(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=jot({initialPromise:e?.initialPromise,fn:l.fetchFn,onCancel:u=>{u instanceof dke&&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 dke){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,...Uot(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...qot(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),id.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:t})})}};function Uot(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:$ot(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function qot(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Got(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 Ate=class extends NN{constructor(t,e){super(),this.options=e,this.#e=t,this.#s=null,this.#i=uke(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#r=void 0;#n=void 0;#a;#o;#i;#s;#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),Hot(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return pke(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return pke(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 ny(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&&!$7(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&Wot(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||ny(this.options.enabled,this.#t)!==ny(e.enabled,this.#t)||nI(this.options.staleTime,this.#t)!==nI(e.staleTime,this.#t))&&this.#f();const i=this.#A();r&&(this.#t!==n||ny(this.options.enabled,this.#t)!==ny(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 T8n(this,n)&&(this.#n=n,this.#o=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(th)),e}#f(){this.#k();const t=nI(this.options.staleTime,this.#t);if(j7.isServer()||this.#n.isStale||!ike(t))return;const n=Lot(this.#n.dataUpdatedAt,t)+1;this.#u=RN.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,!(j7.isServer()||ny(this.options.enabled,this.#t)===!1||!ike(this.#h)||this.#h===0)&&(this.#m=RN.setInterval(()=>{(this.options.refetchIntervalInBackground||ake.isFocused())&&this.#d()},this.#h))}#b(){this.#f(),this.#y(this.#A())}#k(){this.#u&&(RN.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#m&&(RN.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.#o,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&&Hot(t,e),N=I&&Wot(t,n,e,r);(B||N)&&(m={...m,...Uot(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=lke(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=lke(i?.data,h,e),this.#c=h,this.#s=null}catch(I){this.#s=I}this.#s&&(f=this.#s,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:mke(t,e),refetch:this.refetch,promise:this.#i,isEnabled:ny(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=uke();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.#o=this.options,this.#a.data!==void 0&&(this.#p=this.#t),$7(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){id.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#n)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function I8n(t,e){return ny(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Hot(t,e){return I8n(t,e)||t.state.data!==void 0&&pke(t,e,e.refetchOnMount)}function pke(t,e,n){if(ny(e.enabled,t)!==!1&&nI(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&mke(t,e)}return!1}function Wot(t,e,n,r){return(t!==e||ny(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&mke(t,n)}function mke(t,e){return ny(e.enabled,t)!==!1&&t.isStaleByTime(nI(e.staleTime,t))}function T8n(t,e){return!$7(t.getCurrentResult(),e)}function bte(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=>{w8n(b,()=>e.signal,()=>m=!0)},h=Qot(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?_8n:v8n;return{pages:C(b.pages,x,k),pageParams:C(b.pageParams,y,k)}};if(i&&o.length){const b=i==="backward",y=b?Yot:gke,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:gke(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 gke(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 Yot(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}function B8n(t,e){return e?gke(t,e)!=null:!1}function D8n(t,e){return!e||!t.getPreviousPageParam?!1:Yot(t,e)!=null}var N8n=class extends Ate{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:bte()})}getOptimisticResult(t){return t.behavior=bte(),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:B8n(e,n.data),hasPreviousPage:D8n(e,n.data),isFetchNextPageError:p,isFetchingNextPage:m,isFetchPreviousPageError:g,isFetchingPreviousPage:h,isRefetchError:u&&!p&&!g,isRefetching:o&&!m&&!h}}},R8n=class extends zot{#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||Vot(),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=jot({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),id.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Vot(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var L8n=class extends NN{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 R8n({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=yte(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=yte(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=yte(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=yte(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){id.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=>Pot(e,n))}findAll(t={}){return this.getAll().filter(e=>Pot(t,e))}notify(t){id.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return id.batch(()=>Promise.all(t.map(e=>e.continue().catch(th))))}};function yte(t){return t.options.scope?.id}var M8n=class extends NN{#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),$7(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#r,observer:this}),n?.mutationKey&&this.options.mutationKey&&LN(n.mutationKey)!==LN(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.#o(e)}getCurrentResult(){return this.#t}reset(){this.#r?.removeObserver(this),this.#r=void 0,this.#a(),this.#o()}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??Vot();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}}#o(e){id.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 Kot(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function P8n(t,e,n){const r=t.slice(0);return r[e]=n,r}var O8n=class extends NN{#e;#t;#r;#n;#a;#o;#i;#s;#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.")}id.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||!$7(m,h)});!d&&!p||(d&&(this.#c=r,this.#a=i),this.#t=o,this.hasListeners()&&(d&&(Kot(n,i).forEach(m=>{m.destroy()}),Kot(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.#o||this.#t!==this.#s||i||e!==this.#i)&&(this.#i=e,this.#s=this.#t,n!==void 0&&(this.#l=n),this.#o=gte(this.#o,e(t))),this.#o}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 Ate(this.#e,i);n.push({defaultedQueryOptions:i,observer:l})}),n}#h(t,e){const n=this.#a.indexOf(t);n!==-1&&(this.#t=P8n(this.#t,n,e),this.#g())}#g(){if(this.hasListeners()){const t=this.#o,e=this.#p(this.#t,this.#c),n=this.#u(e,this.#n?.combine);t!==n&&id.batch(()=>{this.listeners.forEach(r=>{r(this.#t)})})}}},F8n=class extends NN{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??oke(r,e);let o=this.get(i);return o||(o=new S8n({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(){id.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=>Mot(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>Mot(t,n)):e}notify(t){id.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){id.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){id.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Q8n=class{#e;#t;#r;#n;#a;#o;#i;#s;constructor(t={}){this.#e=t.queryCache||new F8n,this.#t=t.mutationCache||new L8n,this.#r=t.defaultOptions||{},this.#n=new Map,this.#a=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=ake.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=fte.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#s?.(),this.#s=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(nI(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=A8n(e,o);if(l!==void 0)return this.#e.build(this,r).setData(l,{...n,manual:!0})}setQueriesData(t,e,n){return id.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;id.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return id.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=id.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(th).catch(th)}invalidateQueries(t,e={}){return id.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=id.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(th)),i.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(th)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(nI(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(th).catch(th)}fetchInfiniteQuery(t){return t.behavior=bte(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(th).catch(th)}ensureInfiniteQueryData(t){return t.behavior=bte(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return fte.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(LN(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#n.values()],n={};return e.forEach(r=>{Q7(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#a.set(LN(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#a.values()],n={};return e.forEach(r=>{Q7(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=oke(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===hte&&(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()}},Zot=ee.createContext(void 0),Tc=t=>{const e=ee.useContext(Zot);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},z7=({client:t,children:e})=>(ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),A.jsx(Zot.Provider,{value:t,children:e})),Xot=ee.createContext(!1),Jot=()=>ee.useContext(Xot);Xot.Provider;function $8n(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var j8n=ee.createContext($8n()),est=()=>ee.useContext(j8n),tst=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?cke(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},nst=t=>{ee.useEffect(()=>{t.clearReset()},[t])},rst=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||cke(n,[t.error,r])),ast=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))}},z8n=(t,e)=>t.isLoading&&t.isFetching&&!e,hke=(t,e)=>t?.suspense&&e.isPending,fke=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function U8n({queries:t,...e},n){const r=Tc(),i=Jot(),o=est(),l=ee.useMemo(()=>t.map(y=>{const v=r.defaultQueryOptions(y);return v._optimisticResults=i?"isRestoring":"optimistic",v}),[t,r,i]);l.forEach(y=>{ast(y);const v=r.getQueryCache().get(y.queryHash);tst(y,o,v)}),nst(o);const[u]=ee.useState(()=>new O8n(r,l,e)),[d,p,m]=u.getOptimisticResult(l,e.combine),g=!i&&e.subscribed!==!1;ee.useSyncExternalStore(ee.useCallback(y=>g?u.subscribe(id.batchCalls(y)):th,[u,g]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),ee.useEffect(()=>{u.setQueries(l,e)},[l,e,u]);const f=d.some((y,v)=>hke(l[v],y))?d.flatMap((y,v)=>{const _=l[v];if(_&&hke(_,y)){const w=new Ate(r,_);return fke(_,w,o)}return[]}):[];if(f.length>0)throw Promise.all(f);const b=d.find((y,v)=>{const _=l[v];return _&&rst({result:y,errorResetBoundary:o,throwOnError:_.throwOnError,query:r.getQueryCache().get(_.queryHash),suspense:_.suspense})});if(b?.error)throw b.error;return p(m())}function ist(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=est(),o=Tc(),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",ast(l),tst(l,i,u),nst(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(id.batchCalls(h)):th;return p.updateResult(),f},[p,g]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),ee.useEffect(()=>{p.setOptions(l)},[l,p]),hke(l,m))throw fke(l,p,i);if(rst({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&&!j7.isServer()&&z8n(m,r)&&(d?fke(l,p,i):u?.promise)?.catch(th).finally(()=>{p.updateResult()}),l.notifyOnChangeProps?m:p.trackResult(m)}function Rs(t,e){return ist(t,Ate)}function LA(t,e){const n=Tc(),[r]=ee.useState(()=>new M8n(n,t));ee.useEffect(()=>{r.setOptions(t)},[r,t]);const i=ee.useSyncExternalStore(ee.useCallback(l=>r.subscribe(id.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=ee.useCallback((l,u)=>{r.mutate(l,u).catch(th)},[r]);if(i.error&&cke(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}function ost(t,e){return ist(t,N8n)}class q8n{async getActiveCampaigns(){return nn.get("/xyzen/api/v1/gifts/active")}async claimGift(e){return nn.post(`/xyzen/api/v1/gifts/${e}/claim`)}}const sst=new q8n,G8n=!1,H8n=!0;console.log("=== Environment Debug ==="),console.log("MODE:","production"),console.log("isDevelopment:",G8n),console.log("isProduction:",H8n),console.log("VITE_XYZEN_BACKEND_URL:","https://xyzen.cc");const MN="https://xyzen.cc";console.log("Final DEFAULT_BACKEND_URL:",MN);const W8n=typeof localStorage<"u"&&localStorage.getItem("layoutStyle")?localStorage.getItem("layoutStyle"):"sidebar";console.log("Final DEFAULT_LAYOUT_STYLE:",W8n);function Bc(){return typeof window<"u"&&"__TAURI__"in window}const Ake="xyzen.desktop.runner",lst="xyzen.desktop.prevent_sleep",bke="xyzen:desktop-prevent-sleep-changed",vte="Desktop Runner";async function PN(t,e){const{invoke:n}=await Promise.resolve().then(()=>cXn);return n(t,e)}async function _te(t,e,n){return PN("runner_start",{token:t,url:e,workDir:n})}async function Y8n(){return PN("runner_stop")}async function yke(){return PN("runner_status")}async function vke(){return Bc()?PN("desktop_computer_use_status"):{supported:!1,platform:"browser",screen_capture_permission:"unsupported",accessibility_permission:"unsupported",reason:null}}function cst(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 ust(t){if(Bc())return PN("desktop_open_url",{url:t})}function V8n(){return ust("x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture")}function K8n(){return ust("x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")}async function dst(){return Bc()?PN("desktop_sleep_prevention_status"):{enabled:!1,supported:!1}}async function _ke(t){return Bc()?PN("desktop_sleep_prevention_set_enabled",{enabled:t}):{enabled:!1,supported:!1}}function wte(){const e=ad().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 xte(){if(typeof window>"u")return null;const t=window.localStorage.getItem(Ake);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 pst(t){typeof window>"u"||window.localStorage.setItem(Ake,JSON.stringify(t))}function U7(){typeof window>"u"||window.localStorage.removeItem(Ake)}function q7(){return typeof window>"u"?!1:window.localStorage.getItem(lst)==="true"}function mst(t){typeof window>"u"||(window.localStorage.setItem(lst,t?"true":"false"),window.dispatchEvent(new CustomEvent(bke,{detail:{enabled:t}})))}function gst(t){if(typeof window>"u")return()=>{};const e=n=>{t(n.detail.enabled)};return window.addEventListener(bke,e),()=>{window.removeEventListener(bke,e)}}function Z8n(){return A.jsx("div",{"data-tauri-drag-region":!0,className:"fixed top-0 left-0 right-0 h-2 z-[100] select-none backdrop-blur-xl backdrop-saturate-150",style:{WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",background:"linear-gradient(to bottom, rgba(128,128,128,0.2) 0%, transparent 100%)"}})}const X8n=Object.freeze({billing:!1,admin:!1,checkIn:!1,subscription:!1,developerReward:!1}),J8n=Object.freeze({billing:!0,admin:!0,checkIn:!0,subscription:!0,developerReward:!0}),wke=Object.freeze({edition:"ce",isEE:!1,features:X8n}),e6n=Object.freeze({edition:"ee",isEE:!0,features:J8n});let $P=wke,hst=!1;async function t6n(){if(hst)return $P;try{const[t,e]=await Promise.all([Jee.getEdition(),Jee.getFeatures().catch(()=>null)]),n=t.edition==="ee"?e6n:wke;if(e){const r={...n.features,developerReward:n.features.developerReward&&e.developer_reward};$P=Object.freeze({...n,features:Object.freeze(r)})}else $P=n}catch{$P=wke}return hst=!0,$P}function MA(t){return $P.features[t]}const kte=()=>{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 n6n(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 r6n=t=>{switch(t){case"success":return o6n;case"info":return l6n;case"warning":return s6n;case"error":return c6n;default:return null}},a6n=Array(12).fill(0),i6n=({visible:t,className:e})=>T.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},T.createElement("div",{className:"sonner-spinner"},a6n.map((n,r)=>T.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),o6n=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"})),s6n=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"})),l6n=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"})),c6n=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"})),u6n=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"})),d6n=()=>{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 xke=1;class p6n{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:xke++,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(g6n(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||xke++;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 PA=new p6n,m6n=(t,e)=>{const n=e?.id||xke++;return PA.addToast({title:t,...e,id:n}),n},g6n=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",h6n=m6n,f6n=()=>PA.toasts,A6n=()=>PA.getActiveToasts(),Or=Object.assign(h6n,{success:PA.success,info:PA.info,warning:PA.warning,error:PA.error,custom:PA.custom,message:PA.message,promise:PA.promise,dismiss:PA.dismiss,loading:PA.loading},{getHistory:f6n,getToasts:A6n});n6n("[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 Ete(t){return t.label!==void 0}const b6n=3,y6n="24px",v6n="16px",fst=4e3,_6n=356,w6n=14,x6n=45,k6n=200;function sx(...t){return t.filter(Boolean).join(" ")}function E6n(t){const[e,n]=t.split("-"),r=[];return e&&r.push(e),n&&r.push(n),r}const C6n=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:Q="Close toast"}=t,[j,$]=T.useState(null),[z,U]=T.useState(null),[H,te]=T.useState(!1),[Z,ae]=T.useState(!1),[oe,X]=T.useState(!1),[W,q]=T.useState(!1),[Y,K]=T.useState(!1),[ne,ue]=T.useState(0),[se,ce]=T.useState(0),ge=T.useRef(g.duration||M||fst),ve=T.useRef(null),Be=T.useRef(null),We=_===0,Le=_+1<=y,rt=g.type,mt=g.dismissible!==!1,yt=g.className||"",xt=g.descriptionClassName||"",$e=T.useMemo(()=>v.findIndex(fe=>fe.toastId===g.id)||0,[v,g.id]),ot=T.useMemo(()=>{var fe;return(fe=g.closeButton)!=null?fe:E},[g.closeButton,E]),Ce=T.useMemo(()=>g.duration||M||fst,[g.duration,M]),et=T.useRef(0),Rt=T.useRef(0),pe=T.useRef(0),Ze=T.useRef(null),[ie,Re]=R.split("-"),be=T.useMemo(()=>v.reduce((fe,xe,pt)=>pt>=$e?fe:fe+xe.height,0),[v,$e]),Oe=d6n(),we=g.invert||m,st=rt==="loading";Rt.current=T.useMemo(()=>$e*D+be,[$e,be]),T.useEffect(()=>{ge.current=Ce},[Ce]),T.useEffect(()=>{te(!0)},[]),T.useEffect(()=>{const fe=Be.current;if(fe){const xe=fe.getBoundingClientRect().height;return ce(xe),b(pt=>[{toastId:g.id,height:xe,position:g.position},...pt]),()=>b(pt=>pt.filter(tt=>tt.toastId!==g.id))}},[b,g.id]),T.useLayoutEffect(()=>{if(!H)return;const fe=Be.current,xe=fe.style.height;fe.style.height="auto";const pt=fe.getBoundingClientRect().height;fe.style.height=xe,ce(pt),b(tt=>tt.find(an=>an.toastId===g.id)?tt.map(an=>an.toastId===g.id?{...an,height:pt}:an):[{toastId:g.id,height:pt,position:g.position},...tt])},[H,g.title,g.description,b,g.id,g.jsx,g.action,g.cancel]);const vt=T.useCallback(()=>{ae(!0),ue(Rt.current),b(fe=>fe.filter(xe=>xe.toastId!==g.id)),setTimeout(()=>{k(g)},k6n)},[g,k,b,Rt]);T.useEffect(()=>{if(g.promise&&rt==="loading"||g.duration===1/0||g.type==="loading")return;let fe;return x||f||Oe?(()=>{if(pe.current<et.current){const tt=new Date().getTime()-et.current;ge.current=ge.current-tt}pe.current=new Date().getTime()})():ge.current!==1/0&&(et.current=new Date().getTime(),fe=setTimeout(()=>{g.onAutoClose==null||g.onAutoClose.call(g,g),vt()},ge.current)),()=>clearTimeout(fe)},[x,f,g,rt,Oe,vt]),T.useEffect(()=>{g.delete&&(vt(),g.onDismiss==null||g.onDismiss.call(g,g))},[vt,g.delete]);function de(){var fe;if(F?.loading){var xe;return T.createElement("div",{className:sx(O?.loader,g==null||(xe=g.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":rt==="loading"},F.loading)}return T.createElement(i6n,{className:sx(O?.loader,g==null||(fe=g.classNames)==null?void 0:fe.loader),visible:rt==="loading"})}const nt=g.icon||F?.[rt]||r6n(rt);var ct,Ne;return T.createElement("li",{tabIndex:0,ref:Be,className:sx(N,yt,O?.toast,g==null||(e=g.classNames)==null?void 0:e.toast,O?.default,O?.[rt],g==null||(n=g.classNames)==null?void 0:n[rt]),"data-sonner-toast":"","data-rich-colors":(ct=g.richColors)!=null?ct:C,"data-styled":!(g.jsx||g.unstyled||h),"data-mounted":H,"data-promise":!!g.promise,"data-swiped":Y,"data-removed":Z,"data-visible":Le,"data-y-position":ie,"data-x-position":Re,"data-index":_,"data-front":We,"data-swiping":oe,"data-dismissible":mt,"data-type":rt,"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":`${Z?ne:Rt.current}px`,"--initial-height":P?"auto":`${se}px`,...S,...g.style},onDragEnd:()=>{X(!1),$(null),Ze.current=null},onPointerDown:fe=>{fe.button!==2&&(st||!mt||(ve.current=new Date,ue(Rt.current),fe.target.setPointerCapture(fe.pointerId),fe.target.tagName!=="BUTTON"&&(X(!0),Ze.current={x:fe.clientX,y:fe.clientY})))},onPointerUp:()=>{var fe,xe,pt;if(W||!mt)return;Ze.current=null;const tt=Number(((fe=Be.current)==null?void 0:fe.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),an=new Date().getTime()-((pt=ve.current)==null?void 0:pt.getTime()),on=j==="x"?tt:Vt,Xt=Math.abs(on)/an;if(Math.abs(on)>=x6n||Xt>.11){ue(Rt.current),g.onDismiss==null||g.onDismiss.call(g,g),U(j==="x"?tt>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")}K(!1),X(!1),$(null)},onPointerMove:fe=>{var xe,pt,tt;if(!Ze.current||!mt||((xe=window.getSelection())==null?void 0:xe.toString().length)>0)return;const an=fe.clientY-Ze.current.y,on=fe.clientX-Ze.current.x;var Xt;const Lt=(Xt=t.swipeDirections)!=null?Xt:E6n(R);!j&&(Math.abs(on)>1||Math.abs(an)>1)&&$(Math.abs(on)>Math.abs(an)?"x":"y");let Dt={x:0,y:0};const at=gn=>1/(1.5+Math.abs(gn)/20);if(j==="y"){if(Lt.includes("top")||Lt.includes("bottom"))if(Lt.includes("top")&&an<0||Lt.includes("bottom")&&an>0)Dt.y=an;else{const gn=an*at(an);Dt.y=Math.abs(gn)<Math.abs(an)?gn:an}}else if(j==="x"&&(Lt.includes("left")||Lt.includes("right")))if(Lt.includes("left")&&on<0||Lt.includes("right")&&on>0)Dt.x=on;else{const gn=on*at(on);Dt.x=Math.abs(gn)<Math.abs(on)?gn:on}(Math.abs(Dt.x)>0||Math.abs(Dt.y)>0)&&K(!0),(pt=Be.current)==null||pt.style.setProperty("--swipe-amount-x",`${Dt.x}px`),(tt=Be.current)==null||tt.style.setProperty("--swipe-amount-y",`${Dt.y}px`)}},ot&&!g.jsx&&rt!=="loading"?T.createElement("button",{"aria-label":Q,"data-disabled":st,"data-close-button":!0,onClick:st||!mt?()=>{}:()=>{vt(),g.onDismiss==null||g.onDismiss.call(g,g)},className:sx(O?.closeButton,g==null||(r=g.classNames)==null?void 0:r.closeButton)},(Ne=F?.close)!=null?Ne:u6n):null,(rt||g.icon||g.promise)&&g.icon!==null&&(F?.[rt]!==null||g.icon)?T.createElement("div",{"data-icon":"",className:sx(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"?nt:null):null,T.createElement("div",{"data-content":"",className:sx(O?.content,g==null||(o=g.classNames)==null?void 0:o.content)},T.createElement("div",{"data-title":"",className:sx(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:sx(L,xt,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&&Ete(g.cancel)?T.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||I,onClick:fe=>{Ete(g.cancel)&&mt&&(g.cancel.onClick==null||g.cancel.onClick.call(g.cancel,fe),vt())},className:sx(O?.cancelButton,g==null||(d=g.classNames)==null?void 0:d.cancelButton)},g.cancel.label):null,T.isValidElement(g.action)?g.action:g.action&&Ete(g.action)?T.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||B,onClick:fe=>{Ete(g.action)&&(g.action.onClick==null||g.action.onClick.call(g.action,fe),!fe.defaultPrevented&&vt())},className:sx(O?.actionButton,g==null||(p=g.classNames)==null?void 0:p.actionButton)},g.action.label):null)};function Ast(){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 S6n(t,e){const n={};return[t,e].forEach((r,i)=>{const o=i===1,l=o?"--mobile-offset":"--offset",u=o?v6n:y6n;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 I6n=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=b6n,toastOptions:_,dir:w=Ast(),gap:x=w6n,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"),Q=T.useRef(null),j=l.join("+").replace(/Key/g,"").replace(/Digit/g,""),$=T.useRef(null),z=T.useRef(!1),U=T.useCallback(H=>{S(te=>{var Z;return(Z=te.find(ae=>ae.id===H.id))!=null&&Z.delete||PA.dismiss(H.id),te.filter(({id:ae})=>ae!==H.id)})},[]);return T.useEffect(()=>PA.subscribe(H=>{if(H.dismiss){requestAnimationFrame(()=>{S(te=>te.map(Z=>Z.id===H.id?{...Z,delete:!0}:Z))});return}setTimeout(()=>{Qi.flushSync(()=>{S(te=>{const Z=te.findIndex(ae=>ae.id===H.id);return Z!==-1?[...te.slice(0,Z),{...te[Z],...H},...te.slice(Z+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:Z})=>{try{F(Z?"dark":"light")}catch(ae){console.error(ae)}})}},[h]),T.useEffect(()=>{E.length<=1&&R(!1)},[E]),T.useEffect(()=>{const H=te=>{var Z;if(l.every(X=>te[X]||te.code===X)){var oe;R(!0),(oe=Q.current)==null||oe.focus()}te.code==="Escape"&&(document.activeElement===Q.current||(Z=Q.current)!=null&&Z.contains(document.activeElement))&&R(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[l]),T.useEffect(()=>{if(Q.current)return()=>{$.current&&($.current.focus({preventScroll:!0}),$.current=null,z.current=!1)}},[Q.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 Z;const[ae,oe]=H.split("-");return I.length?T.createElement("ol",{key:H,dir:w==="auto"?Ast():w,tabIndex:-1,ref:Q,className:p,"data-sonner-toaster":!0,"data-sonner-theme":O,"data-y-position":ae,"data-x-position":oe,style:{"--front-toast-height":`${((Z=N[0])==null?void 0:Z.height)||0}px`,"--width":`${_6n}px`,"--gap":`${x}px`,...y,...S6n(m,g)},onBlur:X=>{z.current&&!X.currentTarget.contains(X.relatedTarget)&&(z.current=!1,$.current&&($.current.focus({preventScroll:!0}),$.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||z.current||(z.current=!0,$.current=X.relatedTarget)},onMouseEnter:()=>R(!0),onMouseMove:()=>R(!0),onMouseLeave:()=>{D||R(!1)},onDragEnd:()=>R(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||P(!0)},onPointerUp:()=>P(!1)},I.filter(X=>!X.position&&te===0||X.position===H).map((X,W)=>{var q,Y;return T.createElement(C6n,{key:X.id,icons:k,index:W,toast:X,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(K=>K.position==X.position),heights:N.filter(K=>K.position==X.position),setHeights:L,expandByDefault:u,gap:x,expanded:M,swipeDirections:e.swipeDirections})})):null}))});function T6n(){return{needRefresh:[!1,()=>{}],offlineReady:[!1,()=>{}],updateServiceWorker:async()=>{}}}const bst=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const B6n=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const D6n=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const yst=t=>{const e=D6n(t);return e.charAt(0).toUpperCase()+e.slice(1)};var N6n={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 R6n=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const L6n=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,...N6n,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:bst("lucide",i),...!o&&!R6n(u)&&{"aria-hidden":"true"},...u},[...l.map(([p,m])=>T.createElement(p,m)),...Array.isArray(o)?o:[o]]));const Hr=(t,e)=>{const n=T.forwardRef(({className:r,...i},o)=>T.createElement(L6n,{ref:o,iconNode:e,className:bst(`lucide-${B6n(yst(t))}`,`lucide-${t}`,r),...i}));return n.displayName=yst(t),n};const kke=Hr("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 M6n=Hr("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 lx=Hr("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const jP=Hr("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const vst=Hr("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 P6n=Hr("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 O6n=Hr("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 zP=Hr("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 F6n=Hr("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 Cte=Hr("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 Q6n=Hr("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);const nh=Hr("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const mf=Hr("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Eke=Hr("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const rI=Hr("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ste=Hr("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const $6n=Hr("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const _st=Hr("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 j6n=Hr("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 z6n=Hr("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const U6n=Hr("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 q6n=Hr("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 Cke=Hr("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 G6n=Hr("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 H6n=Hr("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 W6n=Hr("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 Ske=Hr("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 Y6n=Hr("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 Ike=Hr("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 w1=Hr("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 x1=Hr("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 wst=Hr("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 xst=Hr("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 kst=Hr("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 V6n=Hr("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 Tke=Hr("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 Est=Hr("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 Cst=Hr("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 Bke=Hr("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 Ite=Hr("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 Sst=Hr("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 Ist=Hr("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 Dke=Hr("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 K6n=Hr("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 Z6n=Hr("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 X6n=Hr("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 J6n=Hr("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 e9n=Hr("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 t9n=Hr("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 UP=Hr("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 n9n=Hr("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 G7=Hr("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 r9n=Hr("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 qP=Hr("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 Tst=Hr("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 Bst=Hr("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 rh=Hr("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Nke=Hr("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 Dst=Hr("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 Tte=Hr("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 a9n=Hr("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 Rke=Hr("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 Nst=Hr("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const i9n=Hr("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 o9n=Hr("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 s9n=Hr("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 H7=Hr("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 l9n=Hr("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 Rst=Hr("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const c9n=Hr("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 u9n=Hr("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 Lst=Hr("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 d9n=Hr("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 p9n=Hr("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const m9n=Hr("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 g9n=Hr("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 Bte=Hr("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 h9n=Hr("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const cx=Hr("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 f9n=Hr("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const A9n=Hr("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 b9n=Hr("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const y9n=Hr("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]);const Dte=Hr("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 Lke=Hr("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 Mst=Hr("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 v9n=Hr("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 Nte=Hr("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 Rte=Hr("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 _9n=Hr("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 w9n=Hr("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 k1=Hr("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const Lte=Hr("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 x9n({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(Lst,{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 k9n(){const{t}=Cn(),e=T.useRef(null),n=T.useRef(null),{needRefresh:[r],updateServiceWorker:i}=T6n();T.useEffect(()=>()=>{n.current?.(),n.current=null},[]);const o=T.useCallback(()=>{i()},[i]);T.useEffect(()=>{if(!r){e.current!=null&&(Or.dismiss(e.current),e.current=null);return}e.current=Or.custom(l=>x9n({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:()=>{Or.dismiss(l),e.current=null}}),{duration:1/0})},[r,o,t])}function E9n(){const t=Jg(),e=(t.isAuthenticated||!!t.token)&&MA("billing"),n=Un(i=>i.fetchWallet),r=Un(i=>i.connectWalletEvents);T.useEffect(()=>e?(n(),r()):void 0,[e,n,r])}const Pst=[];function aI(){return dg(Wo(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}}))}function C9n(){return dg(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.messages??Pst:Pst})}function S9n(){return dg(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.responding??!1:!1})}function I9n(){return dg(t=>{const e=t.activeChatChannel;return e?t.channels[e]?.agentId??null:null})}function Ost(){return dg(t=>t.runningAgentIds)}function T9n(){return dg(t=>t.activeTopicCountByAgent)}function Fst(){return dg(t=>t.respondingChannelIds)}function Qst(){return dg(Wo(t=>{const e={};for(const[n,r]of Object.entries(t.channels))r.agentId&&(e[n]=r.agentId);return e}))}function B9n(t){return t==="Connecting"||typeof t=="object"&&"Connected"in t}async function $st(t){const e=xte(),n=Un.getState().runners;if(e){if(n.find(l=>l.id===e.runnerId)?.is_active)return e;U7()}const r=await t(vte);if(!r)return null;const i={runnerId:r.runner.id,token:r.token,name:vte};return pst(i),i}function D9n(t){const{createRunnerToken:e,fetchRunners:n,runners:r,updateSessionConfig:i}=Un(Wo(u=>({createRunnerToken:u.createRunnerToken,fetchRunners:u.fetchRunners,runners:u.runners,updateSessionConfig:u.updateSessionConfig}))),o=aI(),l=T.useRef(null);T.useEffect(()=>{if(!Bc()||t!=="succeeded")return;let u=!1;return(async()=>{if(await n(),u)return;const p=await yke().catch(()=>"Disconnected");if(B9n(p)){await n();return}let m=await $st(e);if(!(!m||u)){try{await _te(m.token,wte())}catch(g){if(String(g).includes("already running")){await n();return}if(U7(),m=await $st(e),!m||u)return;await _te(m.token,wte())}await n()}})(),()=>{u=!0}},[t,e,n]),T.useEffect(()=>{if(!Bc()||t!=="succeeded"||!o.sessionId||o.sandbox_backend)return;const u=xte();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])}const N9n=({...t})=>A.jsx(I6n,{theme:"system",className:"toaster group",richColors:!0,icons:{success:A.jsx($6n,{className:"size-4"}),info:A.jsx(G7,{className:"size-4"}),warning:A.jsx(Lke,{className:"size-4"}),error:A.jsx(o9n,{className:"size-4"}),loading:A.jsx(rh,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...t}),W7=T.createContext({});function iI(t){const e=T.useRef(null);return e.current===null&&(e.current=t()),e.current}const Mte=typeof window<"u"?T.useLayoutEffect:T.useEffect,Pte=T.createContext(null);function Mke(t,e){t.indexOf(e)===-1&&t.push(e)}function GP(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const ux=(t,e,n)=>n>e?e:n<t?t:n;function Pke(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let HP=()=>{},Hv=()=>{};typeof process<"u"&&process.env?.NODE_ENV!=="production"&&(HP=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(Pke(e,n))},Hv=(t,e,n)=>{if(!t)throw new Error(Pke(e,n))});const oI={},jst=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function zst(t){return typeof t=="object"&&t!==null}const Ust=t=>/^0[^.\s]+$/u.test(t);function qst(t){let e;return()=>(e===void 0&&(e=t()),e)}const ry=t=>t,R9n=(t,e)=>n=>e(t(n)),Y7=(...t)=>t.reduce(R9n),WP=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class Oke{constructor(){this.subscriptions=[]}add(e){return Mke(this.subscriptions,e),()=>GP(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 gf=t=>t*1e3,ay=t=>t/1e3;function Gst(t,e){return e?t*(1e3/e):0}const Hst=new Set;function Fke(t,e,n){t||Hst.has(e)||(console.warn(Pke(e,n)),Hst.add(e))}const L9n=(t,e,n)=>{const r=e-t;return((n-t)%r+r)%r+t},Wst=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,M9n=1e-7,P9n=12;function O9n(t,e,n,r,i){let o,l,u=0;do l=e+(n-e)/2,o=Wst(l,r,i)-t,o>0?n=l:e=l;while(Math.abs(o)>M9n&&++u<P9n);return l}function V7(t,e,n,r){if(t===e&&n===r)return ry;const i=o=>O9n(o,0,1,t,n);return o=>o===0||o===1?o:Wst(i(o),e,r)}const Yst=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Vst=t=>e=>1-t(1-e),Kst=V7(.33,1.53,.69,.99),Qke=Vst(Kst),Zst=Yst(Qke),Xst=t=>t>=1?1:(t*=2)<1?.5*Qke(t):.5*(2-Math.pow(2,-10*(t-1))),$ke=t=>1-Math.sin(Math.acos(t)),Jst=Vst($ke),elt=Yst($ke),F9n=V7(.42,0,1,1),jke=V7(0,0,.58,1),tlt=V7(.42,0,.58,1),nlt=t=>Array.isArray(t)&&typeof t[0]!="number";function rlt(t,e){return nlt(t)?t[L9n(0,t.length,e)]:t}const alt=t=>Array.isArray(t)&&typeof t[0]=="number",ilt={linear:ry,easeIn:F9n,easeInOut:tlt,easeOut:jke,circIn:$ke,circInOut:elt,circOut:Jst,backIn:Qke,backInOut:Zst,backOut:Kst,anticipate:Xst},Q9n=t=>typeof t=="string",olt=t=>{if(alt(t)){Hv(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,r,i]=t;return V7(e,n,r,i)}else if(Q9n(t))return Hv(ilt[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),ilt[t];return t},Ote=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function $9n(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 j9n=40;function slt(t,e){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,l=Ote.reduce((x,k)=>(x[k]=$9n(o),x),{}),{setup:u,read:d,resolveKeyframes:p,preUpdate:m,update:g,preRender:h,render:f,postRender:b}=l,y=()=>{const x=oI.useManualTiming,k=x?i.timestamp:performance.now();n=!1,x||(i.delta=r?1e3/60:Math.max(Math.min(k-i.timestamp,j9n),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:Ote.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<Ote.length;k++)l[Ote[k]].cancel(x)},state:i,steps:l}}const{schedule:Nl,cancel:E1,state:mg,steps:zke}=slt(typeof requestAnimationFrame<"u"?requestAnimationFrame:ry,!0);let Fte;function z9n(){Fte=void 0}const hf={now:()=>(Fte===void 0&&hf.set(mg.isProcessing||oI.useManualTiming?mg.timestamp:performance.now()),Fte),set:t=>{Fte=t,queueMicrotask(z9n)}},llt=t=>e=>typeof e=="string"&&e.startsWith(t),clt=llt("--"),U9n=llt("var(--"),Uke=t=>U9n(t)?q9n.test(t.split("/*")[0].trim()):!1,q9n=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function ult(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const YP={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},K7={...YP,transform:t=>ux(0,1,t)},Qte={...YP,default:1},Z7=t=>Math.round(t*1e5)/1e5,qke=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function G9n(t){return t==null}const H9n=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Gke=(t,e)=>n=>!!(typeof n=="string"&&H9n.test(n)&&n.startsWith(t)||e&&!G9n(n)&&Object.prototype.hasOwnProperty.call(n,e)),dlt=(t,e,n)=>r=>{if(typeof r!="string")return r;const[i,o,l,u]=r.match(qke);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(l),alpha:u!==void 0?parseFloat(u):1}},W9n=t=>ux(0,255,t),Hke={...YP,transform:t=>Math.round(W9n(t))},ON={test:Gke("rgb","red"),parse:dlt("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+Hke.transform(t)+", "+Hke.transform(e)+", "+Hke.transform(n)+", "+Z7(K7.transform(r))+")"};function Y9n(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 Wke={test:Gke("#"),parse:Y9n,transform:ON.transform},X7=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),sI=X7("deg"),dx=X7("%"),Ja=X7("px"),V9n=X7("vh"),K9n=X7("vw"),plt={...dx,parse:t=>dx.parse(t)/100,transform:t=>dx.transform(t*100)},VP={test:Gke("hsl","hue"),parse:dlt("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+dx.transform(Z7(e))+", "+dx.transform(Z7(n))+", "+Z7(K7.transform(r))+")"},tp={test:t=>ON.test(t)||Wke.test(t)||VP.test(t),parse:t=>ON.test(t)?ON.parse(t):VP.test(t)?VP.parse(t):Wke.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ON.transform(t):VP.transform(t),getAnimatableNone:t=>{const e=tp.parse(t);return e.alpha=0,tp.transform(e)}},Z9n=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function X9n(t){return isNaN(t)&&typeof t=="string"&&(t.match(qke)?.length||0)+(t.match(Z9n)?.length||0)>0}const mlt="number",glt="color",J9n="var",eQn="var(",hlt="${}",tQn=/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 KP(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},i=[];let o=0;const u=e.replace(tQn,d=>(tp.test(d)?(r.color.push(o),i.push(glt),n.push(tp.parse(d))):d.startsWith(eQn)?(r.var.push(o),i.push(J9n),n.push(d)):(r.number.push(o),i.push(mlt),n.push(parseFloat(d))),++o,hlt)).split(hlt);return{values:n,split:u,indexes:r,types:i}}function nQn(t){return KP(t).values}function flt({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===mlt?i+=Z7(r[o]):l===glt?i+=tp.transform(r[o]):i+=r[o]}return i}}function rQn(t){return flt(KP(t))}const aQn=t=>typeof t=="number"?0:tp.test(t)?tp.getAnimatableNone(t):t,iQn=(t,e)=>typeof t=="number"?e?.trim().endsWith("/")?t:0:aQn(t);function oQn(t){const e=KP(t);return flt(e)(e.values.map((r,i)=>iQn(r,e.split[i])))}const Wv={test:X9n,parse:nQn,createTransformer:rQn,getAnimatableNone:oQn};function Yke(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 sQn({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=Yke(d,u,t+1/3),o=Yke(d,u,t),l=Yke(d,u,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:r}}function $te(t,e){return n=>n>0?e:t}const Dc=(t,e,n)=>t+(e-t)*n,Vke=(t,e,n)=>{const r=t*t,i=n*(e*e-r)+r;return i<0?0:Math.sqrt(i)},lQn=[Wke,ON,VP],cQn=t=>lQn.find(e=>e.test(t));function Alt(t){const e=cQn(t);if(HP(!!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===VP&&(n=sQn(n)),n}const blt=(t,e)=>{const n=Alt(t),r=Alt(e);if(!n||!r)return $te(t,e);const i={...n};return o=>(i.red=Vke(n.red,r.red,o),i.green=Vke(n.green,r.green,o),i.blue=Vke(n.blue,r.blue,o),i.alpha=Dc(n.alpha,r.alpha,o),ON.transform(i))},Kke=new Set(["none","hidden"]);function uQn(t,e){return Kke.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function dQn(t,e){return n=>Dc(t,e,n)}function Zke(t){return typeof t=="number"?dQn:typeof t=="string"?Uke(t)?$te:tp.test(t)?blt:gQn:Array.isArray(t)?ylt:typeof t=="object"?tp.test(t)?blt:pQn:$te}function ylt(t,e){const n=[...t],r=n.length,i=t.map((o,l)=>Zke(o)(o,e[l]));return o=>{for(let l=0;l<r;l++)n[l]=i[l](o);return n}}function pQn(t,e){const n={...t,...e},r={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(r[i]=Zke(t[i])(t[i],e[i]));return i=>{for(const o in r)n[o]=r[o](i);return n}}function mQn(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 gQn=(t,e)=>{const n=Wv.createTransformer(e),r=KP(t),i=KP(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?Kke.has(t)&&!i.values.length||Kke.has(e)&&!r.values.length?uQn(t,e):Y7(ylt(mQn(r,i),i.values),n):(HP(!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"),$te(t,e))};function vlt(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Dc(t,e,n):Zke(t)(t,e)}const hQn=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Nl.update(e,n),stop:()=>E1(e),now:()=>mg.isProcessing?mg.timestamp:hf.now()}},_lt=(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)})`},jte=2e4;function Xke(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<jte;)e+=n,r=t.next(e);return e>=jte?1/0:e}function wlt(t,e=100,n){const r=n({...t,keyframes:[0,e]}),i=Math.min(Xke(r),jte);return{type:"keyframes",ease:o=>r.next(i*o).value/e,duration:ay(i)}}const Lu={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 Jke(t,e){return t*Math.sqrt(1-e*e)}const fQn=12;function AQn(t,e,n){let r=n;for(let i=1;i<fQn;i++)r=r-t(r)/e(r);return r}const eEe=.001;function bQn({duration:t=Lu.duration,bounce:e=Lu.bounce,velocity:n=Lu.velocity,mass:r=Lu.mass}){let i,o;HP(t<=gf(Lu.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let l=1-e;l=ux(Lu.minDamping,Lu.maxDamping,l),t=ux(Lu.minDuration,Lu.maxDuration,ay(t)),l<1?(i=p=>{const m=p*l,g=m*t,h=m-n,f=Jke(p,l),b=Math.exp(-g);return eEe-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=Jke(Math.pow(p,2),l);return(-i(p)+eEe>0?-1:1)*((h-f)*b)/y}):(i=p=>{const m=Math.exp(-p*t),g=(p-n)*t+1;return-eEe+m*g},o=p=>{const m=Math.exp(-p*t),g=(n-p)*(t*t);return m*g});const u=5/t,d=AQn(i,o,u);if(t=gf(t),isNaN(d))return{stiffness:Lu.stiffness,damping:Lu.damping,duration:t};{const p=Math.pow(d,2)*r;return{stiffness:p,damping:l*2*Math.sqrt(r*p),duration:t}}}const yQn=["duration","bounce"],vQn=["stiffness","damping","mass"];function xlt(t,e){return e.some(n=>t[n]!==void 0)}function _Qn(t){let e={velocity:Lu.velocity,stiffness:Lu.stiffness,damping:Lu.damping,mass:Lu.mass,isResolvedFromDuration:!1,...t};if(!xlt(t,vQn)&&xlt(t,yQn))if(e.velocity=0,t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,o=2*ux(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:Lu.mass,stiffness:i,damping:o}}else{const n=bQn({...t,velocity:0});e={...e,...n,mass:Lu.mass},e.isResolvedFromDuration=!0}return e}function J7(t=Lu.visualDuration,e=Lu.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}=_Qn({...n,velocity:-ay(n.velocity||0)}),b=h||0,y=p/(2*Math.sqrt(d*m)),v=l-o,_=ay(Math.sqrt(d/m)),w=Math.abs(v)<5;r||(r=w?Lu.restSpeed.granular:Lu.restSpeed.default),i||(i=w?Lu.restDelta.granular:Lu.restDelta.default);let x,k,C,E,S,I;if(y<1)C=Jke(_,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=>gf(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=gf(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=gf(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(Xke(B),jte),L=_lt(M=>B.next(N*M).value,N,30);return N+"ms "+L},toTransition:()=>{}};return B}J7.applyToOptions=t=>{const e=wlt(t,100,J7);return t.ease=e.ease,t.duration=gf(e.duration),t.type="keyframes",t};const wQn=5;function klt(t,e,n){const r=Math.max(e-wQn,0);return Gst(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=J7({keyframes:[h.value,b(h.value)],velocity:klt(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 xQn(t,e,n){const r=[],i=n||oI.mix||vlt,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]||ry:e;u=Y7(d,u)}r.push(u)}return r}function Elt(t,e,{clamp:n=!0,ease:r,mixer:i}={}){const o=t.length;if(Hv(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=xQn(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=WP(t[g],t[g+1],m);return u[g](h)};return n?m=>p(ux(t[0],t[o-1],m)):p}function Clt(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const i=WP(0,e,r);t.push(Dc(n,1,i))}}function Slt(t){const e=[0];return Clt(e,t.length-1),e}function kQn(t,e){return t.map(n=>n*e)}function EQn(t,e){return t.map(()=>e||tlt).splice(0,t.length-1)}function ZP({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const i=nlt(r)?r.map(olt):olt(r),o={done:!1,value:e[0]},l=kQn(n&&n.length===e.length?n:Slt(e),t),u=Elt(l,e,{ease:Array.isArray(i)?i:EQn(e,i)});return{calculatedDuration:t,next:d=>(o.value=u(d),o.done=d>=t,o)}}const CQn=t=>t!==null;function zte(t,{repeat:e,repeatType:n="loop"},r,i=1){const o=t.filter(CQn),u=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!u||r===void 0?o[u]:r}const SQn={decay:tEe,inertia:tEe,tween:ZP,keyframes:ZP,spring:J7};function Ilt(t){typeof t.type=="string"&&(t.type=SQn[t.type])}class nEe{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 IQn=t=>t/100;class ez extends nEe{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!==hf.now()&&this.tick(hf.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;Ilt(e);const{type:n=ZP,repeat:r=0,repeatDelay:i=0,repeatType:o,velocity:l=0}=e;let{keyframes:u}=e;const d=n||ZP;process.env.NODE_ENV!=="production"&&d!==ZP&&Hv(u.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${u}`,"spring-two-frames"),d!==ZP&&typeof u[0]!="number"&&(this.mixKeyframes=Y7(IQn,vlt(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=Xke(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=ux(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=zte(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 ay(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ay(e)}get time(){return ay(this.currentTime)}set time(e){e=gf(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 klt(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(hf.now()),this.playbackSpeed=e,n&&this.driver&&(this.time=ay(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=hQn,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(hf.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 TQn(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const FN=t=>t*180/Math.PI,rEe=t=>{const e=FN(Math.atan2(t[1],t[0]));return aEe(e)},BQn={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:rEe,rotateZ:rEe,skewX:t=>FN(Math.atan(t[1])),skewY:t=>FN(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},aEe=t=>(t=t%360,t<0&&(t+=360),t),Tlt=rEe,Blt=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Dlt=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),DQn={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Blt,scaleY:Dlt,scale:t=>(Blt(t)+Dlt(t))/2,rotateX:t=>aEe(FN(Math.atan2(t[6],t[5]))),rotateY:t=>aEe(FN(Math.atan2(-t[2],t[0]))),rotateZ:Tlt,rotate:Tlt,skewX:t=>FN(Math.atan(t[4])),skewY:t=>FN(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function iEe(t){return t.includes("scale")?1:0}function oEe(t,e){if(!t||t==="none")return iEe(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=DQn,i=n;else{const u=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=BQn,i=u}if(!i)return iEe(e);const o=r[e],l=i[1].split(",").map(RQn);return typeof o=="function"?o(l):l[o]}const NQn=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return oEe(n,e)};function RQn(t){return parseFloat(t.trim())}const XP=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],JP=new Set(XP),Nlt=t=>t===YP||t===Ja,LQn=new Set(["x","y","z"]),MQn=XP.filter(t=>!LQn.has(t));function PQn(t){const e=[];return MQn.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const lI={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})=>oEe(e,"x"),y:(t,{transform:e})=>oEe(e,"y")};lI.translateX=lI.x,lI.translateY=lI.y;const QN=new Set;let sEe=!1,lEe=!1,cEe=!1;function Rlt(){if(lEe){const t=Array.from(QN).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const i=PQn(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)})}lEe=!1,sEe=!1,QN.forEach(t=>t.complete(cEe)),QN.clear()}function Llt(){QN.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(lEe=!0)})}function OQn(){cEe=!0,Llt(),Rlt(),cEe=!1}class uEe{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?(QN.add(this),sEe||(sEe=!0,Nl.read(Llt),Nl.resolveKeyframes(Rlt))):(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])}TQn(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),QN.delete(this)}cancel(){this.state==="scheduled"&&(QN.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const FQn=t=>t.startsWith("--");function Mlt(t,e,n){FQn(e)?t.style.setProperty(e,n):t.style[e]=n}const QQn={};function Plt(t,e){const n=qst(t);return()=>QQn[e]??n()}const $Qn=Plt(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),Olt=Plt(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),tz=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,Flt={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:tz([0,.65,.55,1]),circOut:tz([.55,0,1,.45]),backIn:tz([.31,.01,.66,-.59]),backOut:tz([.33,1.53,.69,.99])};function Qlt(t,e){if(t)return typeof t=="function"?Olt()?_lt(t,e):"ease-out":alt(t)?tz(t):Array.isArray(t)?t.map(n=>Qlt(n,e)||Flt.easeOut):Flt[t]}function jQn(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=Qlt(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 dEe(t){return typeof t=="function"&&"applyToOptions"in t}function zQn({type:t,...e}){return dEe(t)&&Olt()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class $lt extends nEe{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,Hv(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const p=zQn(e);this.animation=jQn(n,r,i,p,o),p.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const m=zte(i,this.options,u,this.speed);this.updateMotionValue&&this.updateMotionValue(m),Mlt(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 ay(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ay(e)}get time(){return ay(Number(this.animation.currentTime)||0)}set time(e){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=gf(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&&$Qn()?(this.animation.timeline=e,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),ry):i(this)}}const jlt={anticipate:Xst,backInOut:Zst,circInOut:elt};function UQn(t){return t in jlt}function qQn(t){typeof t.ease=="string"&&UQn(t.ease)&&(t.ease=jlt[t.ease])}const pEe=10;class GQn extends $lt{constructor(e){qQn(e),Ilt(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 ez({...l,autoplay:!1}),d=Math.max(pEe,hf.now()-this.startTime),p=ux(0,pEe,d-pEe),m=u.sample(d).value,{name:g}=this.options;o&&g&&Mlt(o,g,m),n.setWithVelocity(u.sample(Math.max(0,d-p)).value,m,p),u.stop()}}const zlt=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Wv.test(t)||t==="0")&&!t.startsWith("url("));function HQn(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 WQn(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=zlt(i,e),u=zlt(o,e);return HP(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:HQn(t)||(n==="spring"||dEe(n))&&r}function mEe(t){t.duration=0,t.type="keyframes"}const Ult=new Set(["opacity","clipPath","filter","transform"]),YQn=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function VQn(t){for(let e=0;e<t.length;e++)if(typeof t[e]=="string"&&YQn.test(t[e]))return!0;return!1}const KQn=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),ZQn=qst(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function XQn(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 ZQn()&&n&&(Ult.has(n)||KQn.has(n)&&VQn(u))&&(n!=="transform"||!m)&&!p&&!r&&i!=="mirror"&&o!==0&&l!=="inertia"}const JQn=40;class e$n extends nEe{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=hf.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||uEe;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=hf.now();let g=!0;WQn(e,o,l,u)||(g=!1,(oI.instantAnimations||!d)&&m?.(zte(e,r,n)),e[0]=e[e.length-1],mEe(r),r.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>JQn?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},b=g&&!p&&XQn(f),y=f.motionValue?.owner?.current;let v;if(b)try{v=new GQn({...f,element:y})}catch{v=new ez(f)}else v=new ez(f);v.finished.then(()=>{this.notifyFinished()}).catch(ry),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(),OQn()),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 t$n{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 qlt(this.animations,"duration")}get iterationDuration(){return qlt(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 qlt(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 n$n extends t$n{then(e,n){return this.finished.finally(e).then(()=>{})}}function Glt(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 r$n=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function a$n(t){const e=r$n.exec(t);if(!e)return[,];const[,n,r,i]=e;return[`--${n??r}`,i]}const i$n=4;function Hlt(t,e,n=1){Hv(n<=i$n,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,i]=a$n(t);if(!r)return;const o=window.getComputedStyle(e).getPropertyValue(r);if(o){const l=o.trim();return jst(l)?parseFloat(l):l}return Uke(i)?Hlt(i,e,n+1):i}const o$n={type:"spring",stiffness:500,damping:25,restSpeed:10},s$n=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),l$n={type:"keyframes",duration:.8},c$n={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},u$n=(t,{keyframes:e})=>e.length>2?l$n:JP.has(t)?t.startsWith("scale")?s$n(e[1]):o$n:c$n;function Wlt(t,e){if(t?.inherit&&e){const{inherit:n,...r}=t;return{...e,...r}}return t}function gEe(t,e){const n=t?.[e]??t?.default??t;return n!==t?Wlt(n,t):n}const d$n=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function p$n(t){for(const e in t)if(!d$n.has(e))return!0;return!1}const hEe=(t,e,n,r={},i,o)=>l=>{const u=gEe(r,t)||{},d=u.delay||r.delay||0;let{elapsed:p=0}=r;p=p-gf(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};p$n(u)||Object.assign(m,u$n(t,m)),m.duration&&(m.duration=gf(m.duration)),m.repeatDelay&&(m.repeatDelay=gf(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let g=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&(mEe(m),m.delay===0&&(g=!0)),(oI.instantAnimations||oI.skipAnimations||i?.shouldSkipAnimations)&&(g=!0,mEe(m),m.delay=0),m.allowFlatten=!u.type&&!u.ease,g&&!o&&e.get()!==void 0){const h=zte(m.keyframes,u);if(h!==void 0){Nl.update(()=>{m.onUpdate(h),m.onComplete()});return}}return u.isSync?new ez(m):new e$n(m)};function Ylt(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function fEe(t,e,n,r){if(typeof e=="function"){const[i,o]=Ylt(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]=Ylt(r);e=e(n!==void 0?n:t.custom,i,o)}return e}function $N(t,e,n){const r=t.getProps();return fEe(r,e,n!==void 0?n:r.custom,t)}const Vlt=new Set(["width","height","top","left","right","bottom",...XP]),Klt=30,m$n=t=>!isNaN(parseFloat(t)),nz={current:void 0};class g$n{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const i=hf.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=hf.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=m$n(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Fke(!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 Oke);const r=this.events[e].add(n);return e==="change"?()=>{r(),Nl.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 nz.current&&nz.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=hf.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Klt)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Klt);return Gst(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 cI(t,e){return new g$n(t,e)}const AEe=t=>Array.isArray(t);function h$n(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,cI(n))}function f$n(t){return AEe(t)?t[t.length-1]||0:t}function A$n(t,e){const n=$N(t,e);let{transitionEnd:r={},transition:i={},...o}=n||{};o={...o,...r};for(const l in o){const u=f$n(o[l]);h$n(t,l,u)}}const Sd=t=>!!(t&&t.getVelocity);function b$n(t){return!!(Sd(t)&&t.add)}function bEe(t,e){const n=t.getValue("willChange");if(b$n(n))return n.add(e);if(!n&&oI.WillChange){const r=new oI.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function yEe(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const Zlt="data-"+yEe("framerAppearId");function Xlt(t){return t.props[Zlt]}function y$n({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function vEe(t,e,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:o,transitionEnd:l,...u}=e;const d=t.getDefaultTransition();o=o?Wlt(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&&y$n(g,h))continue;const y={delay:n,...gEe(o||{},h)},v=f.get();if(v!==void 0&&!f.isAnimating()&&!Array.isArray(b)&&b===v&&!y.velocity){Nl.update(()=>f.set(b));continue}let _=!1;if(window.MotionHandoffAnimation){const k=Xlt(t);if(k){const C=window.MotionHandoffAnimation(k,h,Nl);C!==null&&(y.startTime=C,_=!0)}}bEe(t,h);const w=p??t.shouldReduceMotion;f.start(hEe(h,f,b,w&&Vlt.has(h)?{type:!1}:y,t,_));const x=f.animation;x&&m.push(x)}if(l){const h=()=>Nl.update(()=>{l&&A$n(t,l)});m.length?Promise.all(m).then(h):h()}return m}function _Ee(t,e,n={}){const r=$N(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(vEe(t,r,n)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(d=0)=>{const{delayChildren:p=0,staggerChildren:m,staggerDirection:g}=i;return v$n(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 v$n(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(_Ee(d,e,{...l,delay:n+(typeof r=="function"?0:r)+Glt(t.variantChildren,d,r,i,o)}).then(()=>d.notify("AnimationComplete",e)));return Promise.all(u)}function _$n(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const i=e.map(o=>_Ee(t,o,n));r=Promise.all(i)}else if(typeof e=="string")r=_Ee(t,e,n);else{const i=typeof e=="function"?$N(t,e,n.custom):e;r=Promise.all(vEe(t,i,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}const w$n={test:t=>t==="auto",parse:t=>t},Jlt=t=>e=>e.test(t),ect=[YP,Ja,dx,sI,K9n,V9n,w$n],tct=t=>ect.find(Jlt(t));function x$n(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Ust(t):!0}const k$n=new Set(["brightness","contrast","saturate","opacity"]);function E$n(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(qke)||[];if(!r)return t;const i=n.replace(r,"");let o=k$n.has(e)?1:0;return r!==n&&(o*=100),e+"("+o+i+")"}const C$n=/\b([a-z-]*)\(.*?\)/gu,wEe={...Wv,getAnimatableNone:t=>{const e=t.match(C$n);return e?e.map(E$n).join(" "):t}},xEe={...Wv,getAnimatableNone:t=>{const e=Wv.parse(t);return Wv.createTransformer(t)(e.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},nct={...YP,transform:Math.round},kEe={borderWidth:Ja,borderTopWidth:Ja,borderRightWidth:Ja,borderBottomWidth:Ja,borderLeftWidth:Ja,borderRadius:Ja,borderTopLeftRadius:Ja,borderTopRightRadius:Ja,borderBottomRightRadius:Ja,borderBottomLeftRadius:Ja,width:Ja,maxWidth:Ja,height:Ja,maxHeight:Ja,top:Ja,right:Ja,bottom:Ja,left:Ja,inset:Ja,insetBlock:Ja,insetBlockStart:Ja,insetBlockEnd:Ja,insetInline:Ja,insetInlineStart:Ja,insetInlineEnd:Ja,padding:Ja,paddingTop:Ja,paddingRight:Ja,paddingBottom:Ja,paddingLeft:Ja,paddingBlock:Ja,paddingBlockStart:Ja,paddingBlockEnd:Ja,paddingInline:Ja,paddingInlineStart:Ja,paddingInlineEnd:Ja,margin:Ja,marginTop:Ja,marginRight:Ja,marginBottom:Ja,marginLeft:Ja,marginBlock:Ja,marginBlockStart:Ja,marginBlockEnd:Ja,marginInline:Ja,marginInlineStart:Ja,marginInlineEnd:Ja,fontSize:Ja,backgroundPositionX:Ja,backgroundPositionY:Ja,...{rotate:sI,rotateX:sI,rotateY:sI,rotateZ:sI,scale:Qte,scaleX:Qte,scaleY:Qte,scaleZ:Qte,skew:sI,skewX:sI,skewY:sI,distance:Ja,translateX:Ja,translateY:Ja,translateZ:Ja,x:Ja,y:Ja,z:Ja,perspective:Ja,transformPerspective:Ja,opacity:K7,originX:plt,originY:plt,originZ:Ja},zIndex:nct,fillOpacity:K7,strokeOpacity:K7,numOctaves:nct},S$n={...kEe,color:tp,backgroundColor:tp,outlineColor:tp,fill:tp,stroke:tp,borderColor:tp,borderTopColor:tp,borderRightColor:tp,borderBottomColor:tp,borderLeftColor:tp,filter:wEe,WebkitFilter:wEe,mask:xEe,WebkitMask:xEe},rct=t=>S$n[t],I$n=new Set([wEe,xEe]);function act(t,e){let n=rct(t);return I$n.has(n)||(n=Wv),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const T$n=new Set(["auto","none","0"]);function B$n(t,e,n){let r=0,i;for(;r<t.length&&!i;){const o=t[r];typeof o=="string"&&!T$n.has(o)&&KP(o).values.length&&(i=t[r]),r++}if(i&&n)for(const o of e)t[o]=act(n,i)}class D$n extends uEe{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(),Uke(g))){const h=Hlt(g,n.current);h!==void 0&&(e[m]=h),m===e.length-1&&(this.finalKeyframe=g)}}if(this.resolveNoneKeyframes(),!Vlt.has(r)||e.length!==2)return;const[i,o]=e,l=tct(i),u=tct(o),d=ult(i),p=ult(o);if(d!==p&&lI[r]){this.needsMeasurement=!0;return}if(l!==u)if(Nlt(l)&&Nlt(u))for(let m=0;m<e.length;m++){const g=e[m];typeof g=="string"&&(e[m]=parseFloat(g))}else lI[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let i=0;i<e.length;i++)(e[i]===null||x$n(e[i]))&&r.push(i);r.length&&B$n(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=lI[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]=lI[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 Ute(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 ict=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function qte(t){return zst(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:EEe}=slt(queueMicrotask,!1),Yv={x:!1,y:!1};function oct(){return Yv.x||Yv.y}function N$n(t){return t==="x"||t==="y"?Yv[t]?null:(Yv[t]=!0,()=>{Yv[t]=!1}):Yv.x||Yv.y?null:(Yv.x=Yv.y=!0,()=>{Yv.x=Yv.y=!1})}function sct(t,e){const n=Ute(t),r=new AbortController,i={passive:!0,...e,signal:r.signal};return[n,i,()=>r.abort()]}function R$n(t){return!(t.pointerType==="touch"||oct())}function L$n(t,e,n={}){const[r,i,o]=sct(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(!R$n(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 lct=(t,e)=>e?t===e?!0:lct(t,e.parentElement):!1,CEe=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,M$n=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function P$n(t){return M$n.has(t.tagName)||t.isContentEditable===!0}const O$n=new Set(["INPUT","SELECT","TEXTAREA"]);function F$n(t){return O$n.has(t.tagName)||t.isContentEditable===!0}const Gte=new WeakSet;function cct(t){return e=>{e.key==="Enter"&&t(e)}}function SEe(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Q$n=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=cct(()=>{if(Gte.has(n))return;SEe(n,"down");const i=cct(()=>{SEe(n,"up")}),o=()=>SEe(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 uct(t){return CEe(t)&&!oct()}const dct=new WeakSet;function $$n(t,e,n={}){const[r,i,o]=sct(t,n),l=u=>{const d=u.currentTarget;if(!uct(u)||dct.has(u))return;Gte.add(d),n.stopPropagation&&dct.add(u);const p=e(d,u),m=(f,b)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",h),Gte.has(d)&&Gte.delete(d),uct(f)&&typeof p=="function"&&p(f,{success:b})},g=f=>{m(f,d===window||d===document||n.useGlobalTarget||lct(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),qte(u)&&(u.addEventListener("focus",p=>Q$n(p,i)),!P$n(u)&&!u.hasAttribute("tabindex")&&(u.tabIndex=0))}),o}function Hte(t){return zst(t)&&"ownerSVGElement"in t}const Wte=new WeakMap;let Yte;const pct=(t,e,n)=>(r,i)=>i&&i[0]?i[0][t+"Size"]:Hte(r)&&"getBBox"in r?r.getBBox()[e]:r[n],j$n=pct("inline","width","offsetWidth"),z$n=pct("block","height","offsetHeight");function U$n({target:t,borderBoxSize:e}){Wte.get(t)?.forEach(n=>{n(t,{get width(){return j$n(t,e)},get height(){return z$n(t,e)}})})}function q$n(t){t.forEach(U$n)}function G$n(){typeof ResizeObserver>"u"||(Yte=new ResizeObserver(q$n))}function H$n(t,e){Yte||G$n();const n=Ute(t);return n.forEach(r=>{let i=Wte.get(r);i||(i=new Set,Wte.set(r,i)),i.add(e),Yte?.observe(r)}),()=>{n.forEach(r=>{const i=Wte.get(r);i?.delete(e),i?.size||Yte?.unobserve(r)})}}const Vte=new Set;let e5;function W$n(){e5=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Vte.forEach(e=>e(t))},window.addEventListener("resize",e5)}function Y$n(t){return Vte.add(t),e5||W$n(),()=>{Vte.delete(t),!Vte.size&&typeof e5=="function"&&(window.removeEventListener("resize",e5),e5=void 0)}}function mct(t,e){return typeof t=="function"?Y$n(t):H$n(t,e)}function gct(t){return Hte(t)&&t.tagName==="svg"}function V$n(...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=Elt(i,o,l);return e?u(r):u}function K$n(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=hct(t.get()),h=hct(o);if(g===h){d();return}const f=i?i.getGeneratorVelocity():t.getVelocity();d(),i=new ez({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(IEe(f,u)),Nl.postRender(m)},d),Sd(e)){let g=n.skipInitialAnimation===!0;const h=e.on("change",b=>{g?(g=!1,t.jump(IEe(b,u),!1)):t.set(IEe(b,u))}),f=t.on("destroy",h);return()=>{h(),f()}}return d}function IEe(t,e){return e?t+e:t}function hct(t){return typeof t=="number"?t:parseFloat(t)}const Z$n=[...ect,tp,Wv],X$n=t=>Z$n.find(Jlt(t)),fct=()=>({translate:0,scale:1,origin:0,originPoint:0}),t5=()=>({x:fct(),y:fct()}),Act=()=>({min:0,max:0}),np=()=>({x:Act(),y:Act()}),rz=new WeakMap;function Kte(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function az(t){return typeof t=="string"||Array.isArray(t)}const TEe=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],BEe=["initial",...TEe];function Zte(t){return Kte(t.animate)||BEe.some(e=>az(t[e]))}function bct(t){return!!(Zte(t)||t.variants)}function J$n(t,e,n){for(const r in e){const i=e[r],o=n[r];if(Sd(i))t.addValue(r,i);else if(Sd(o))t.addValue(r,cI(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,cI(l!==void 0?l:i,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const DEe={current:null},yct={current:!1},ejn=typeof window<"u";function tjn(){if(yct.current=!0,!!ejn)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>DEe.current=t.matches;t.addEventListener("change",e),e()}else DEe.current=!1}const vct=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Xte={};function _ct(t){Xte=t}function njn(){return Xte}class wct{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=uEe,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=hf.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,Nl.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=Zte(n),this.isVariantNode=bct(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&&Sd(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,rz.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:(yct.current||tjn(),this.shouldReduceMotion=DEe.current),process.env.NODE_ENV!=="production"&&Fke(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(),E1(this.notifyUpdate),E1(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&&Ult.has(e)&&this.current instanceof HTMLElement){const{factory:l,keyframes:u,times:d,ease:p,duration:m}=n.accelerate,g=new $lt({element:this.current,name:e,keyframes:u,times:d,ease:p,duration:gf(m)}),h=l(g);this.valueSubscriptions.set(e,()=>{h(),g.cancel()});return}const r=JP.has(e);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",l=>{this.latestValues[e]=l,this.props.onUpdate&&Nl.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 Xte){const n=Xte[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):np()}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<vct.length;r++){const i=vct[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=J$n(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=cI(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"&&(jst(r)||Ust(r))?r=parseFloat(r):!X$n(r)&&Wv.test(n)&&(r=act(e,n)),this.setBaseTarget(e,Sd(r)?r.get():r)),Sd(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=fEe(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&&!Sd(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 Oke),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){EEe.render(this.render)}}class xct extends wct{constructor(){super(...arguments),this.KeyframeResolver=D$n}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;Sd(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class uI{constructor(e){this.isMounted=!1,this.node=e}update(){}}function kct({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function rjn({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function ajn(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 NEe(t){return t===void 0||t===1}function REe({scale:t,scaleX:e,scaleY:n}){return!NEe(t)||!NEe(e)||!NEe(n)}function jN(t){return REe(t)||Ect(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Ect(t){return Cct(t.x)||Cct(t.y)}function Cct(t){return t&&t!=="0%"}function Jte(t,e,n){const r=t-n,i=e*r;return n+i}function Sct(t,e,n,r,i){return i!==void 0&&(t=Jte(t,i,r)),Jte(t,n,r)+e}function LEe(t,e=0,n=1,r,i){t.min=Sct(t.min,e,n,r,i),t.max=Sct(t.max,e,n,r,i)}function Ict(t,{x:e,y:n}){LEe(t.x,e.translate,e.scale,e.originPoint),LEe(t.y,n.translate,n.scale,n.originPoint)}const Tct=.999999999999,Bct=1.0000000000001;function ijn(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&&(px(t.x,-o.scroll.offset.x),px(t.y,-o.scroll.offset.y)),l&&(e.x*=l.x.scale,e.y*=l.y.scale,Ict(t,l)),r&&jN(o.latestValues)&&ene(t,o.latestValues,o.layout?.layoutBox))}e.x<Bct&&e.x>Tct&&(e.x=1),e.y<Bct&&e.y>Tct&&(e.y=1)}function px(t,e){t.min+=e,t.max+=e}function Dct(t,e,n,r,i=.5){const o=Dc(t.min,t.max,i);LEe(t,e,n,o,r)}function Nct(t,e){return typeof t=="string"?parseFloat(t)/100*(e.max-e.min):t}function ene(t,e,n){const r=n??t;Dct(t.x,Nct(e.x,r.x),e.scaleX,e.scale,e.originX),Dct(t.y,Nct(e.y,r.y),e.scaleY,e.scale,e.originY)}function Rct(t,e){return kct(ajn(t.getBoundingClientRect(),e))}function ojn(t,e,n){const r=Rct(t,n),{scroll:i}=e;return i&&(px(r.x,i.offset.x),px(r.y,i.offset.y)),r}const sjn={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},ljn=XP.length;function cjn(t,e,n){let r="",i=!0;for(let o=0;o<ljn;o++){const l=XP[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=ict(u,kEe[l]);if(!d){i=!1;const m=sjn[l]||l;r+=`${m}(${p}) `}n&&(e[l]=p)}}return r=r.trim(),n?r=n(e,i?"":r):i&&(r="none"),r}function MEe(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(JP.has(d)){l=!0;continue}else if(clt(d)){i[d]=p;continue}else{const m=ict(p,kEe[d]);d.startsWith("origin")?(u=!0,o[d]=m):r[d]=m}}if(e.transform||(l||n?r.transform=cjn(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 Lct(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 Mct(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const iz={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(Ja.test(t))t=parseFloat(t);else return t;const n=Mct(t,e.target.x),r=Mct(t,e.target.y);return`${n}% ${r}%`}},ujn={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,i=Wv.parse(t);if(i.length>5)return r;const o=Wv.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=Dc(u,d,.5);return typeof i[2+l]=="number"&&(i[2+l]/=p),typeof i[3+l]=="number"&&(i[3+l]/=p),o(i)}},PEe={borderRadius:{...iz,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:iz,borderTopRightRadius:iz,borderBottomLeftRadius:iz,borderBottomRightRadius:iz,boxShadow:ujn};function Pct(t,{layout:e,layoutId:n}){return JP.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!PEe[t]||t==="opacity")}function OEe(t,e,n){const r=t.style,i=e?.style,o={};if(!r)return o;for(const l in r)(Sd(r[l])||i&&Sd(i[l])||Pct(l,t)||n?.getValue(l)?.liveStyle!==void 0)&&(o[l]=r[l]);return o}function djn(t){return window.getComputedStyle(t)}class Oct extends xct{constructor(){super(...arguments),this.type="html",this.renderInstance=Lct}readValueFromInstance(e,n){if(JP.has(n))return this.projection?.isProjecting?iEe(n):NQn(e,n);{const r=djn(e),i=(clt(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Rct(e,n)}build(e,n,r){MEe(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return OEe(e,n,r)}}function pjn(t,e){return t in e}class mjn extends wct{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,n){if(pjn(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 np()}build(e,n){Object.assign(e.output,n)}renderInstance(e,{output:n}){Object.assign(e,n)}sortInstanceNodePosition(){return 0}}const gjn={offset:"stroke-dashoffset",array:"stroke-dasharray"},hjn={offset:"strokeDashoffset",array:"strokeDasharray"};function fjn(t,e,n=1,r=0,i=!0){t.pathLength=1;const o=i?gjn:hjn;t[o.offset]=`${-r}`,t[o.array]=`${e} ${n}`}const Ajn=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Fct(t,{attrX:e,attrY:n,attrScale:r,pathLength:i,pathSpacing:o=1,pathOffset:l=0,...u},d,p,m){if(MEe(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 Ajn)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&&fjn(g,i,o,l,!1)}const Qct=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"]),$ct=t=>typeof t=="string"&&t.toLowerCase()==="svg";function bjn(t,e,n,r){Lct(t,e,void 0,r);for(const i in e.attrs)t.setAttribute(Qct.has(i)?i:yEe(i),e.attrs[i])}function jct(t,e,n){const r=OEe(t,e,n);for(const i in t)if(Sd(t[i])||Sd(e[i])){const o=XP.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[o]=t[i]}return r}class zct extends xct{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=np}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(JP.has(n)){const r=rct(n);return r&&r.default||0}return n=Qct.has(n)?n:yEe(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return jct(e,n,r)}build(e,n,r){Fct(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,i){bjn(e,n,r,i)}mount(e){this.isSVGTag=$ct(e.tagName),super.mount(e)}}const yjn=BEe.length;function Uct(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Uct(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<yjn;n++){const r=BEe[n],i=t.props[r];(az(i)||i===!1)&&(e[r]=i)}return e}function qct(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 vjn=[...TEe].reverse(),_jn=TEe.length;function wjn(t){return e=>Promise.all(e.map(({animation:n,options:r})=>_$n(t,n,r)))}function xjn(t){let e=wjn(t),n=Gct(),r=!0,i=!1;const o=p=>(m,g)=>{const h=$N(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=Uct(t.parent)||{},h=[],f=new Set;let b={},y=1/0;for(let _=0;_<_jn;_++){const w=vjn[_],x=n[w],k=m[w]!==void 0?m[w]:g[w],C=az(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||Kte(k)||typeof k=="boolean")continue;if(w==="exit"&&x.isActive&&E!==!0){x.prevResolvedValues&&(b={...b,...x.prevResolvedValues});continue}const I=kjn(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=Q=>{B=!0,f.has(Q)&&(N=!0,f.delete(Q)),x.needsAnimating[Q]=!0;const j=t.getValue(Q);j&&(j.liveStyle=!1)};for(const Q in D){const j=M[Q],$=R[Q];if(b.hasOwnProperty(Q))continue;let z=!1;AEe(j)&&AEe($)?z=!qct(j,$):z=j!==$,z?j!=null?P(Q):f.add(Q):j!==void 0&&f.has(Q)?P(Q):x.protectedKeys[Q]=!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(Q=>{const j={type:w};if(typeof Q=="string"&&(r||i)&&!O&&t.manuallyAnimateOnMount&&t.parent){const{parent:$}=t,z=$N($,Q);if($.enteringChildren&&z){const{delayChildren:U}=z.transition||{};j.delay=Glt($.enteringChildren,t,U)}}return{animation:Q,options:j}}))}if(f.size){const _={};if(typeof m.initial!="boolean"){const w=$N(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=Gct(),i=!0}}}function kjn(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!qct(e,t):!1}function zN(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Gct(){return{animate:zN(!0),whileInView:zN(),whileHover:zN(),whileTap:zN(),whileDrag:zN(),whileFocus:zN(),exit:zN()}}function FEe(t,e){t.min=e.min,t.max=e.max}function Vv(t,e){FEe(t.x,e.x),FEe(t.y,e.y)}function Hct(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const Wct=1e-4,Ejn=1-Wct,Cjn=1+Wct,Yct=.01,Sjn=0-Yct,Ijn=0+Yct;function ff(t){return t.max-t.min}function Tjn(t,e,n){return Math.abs(t-e)<=n}function Vct(t,e,n,r=.5){t.origin=r,t.originPoint=Dc(e.min,e.max,t.origin),t.scale=ff(n)/ff(e),t.translate=Dc(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Ejn&&t.scale<=Cjn||isNaN(t.scale))&&(t.scale=1),(t.translate>=Sjn&&t.translate<=Ijn||isNaN(t.translate))&&(t.translate=0)}function oz(t,e,n,r){Vct(t.x,e.x,n.x,r?r.originX:void 0),Vct(t.y,e.y,n.y,r?r.originY:void 0)}function Kct(t,e,n,r=0){const i=r?Dc(n.min,n.max,r):n.min;t.min=i+e.min,t.max=t.min+ff(e)}function Bjn(t,e,n,r){Kct(t.x,e.x,n.x,r?.x),Kct(t.y,e.y,n.y,r?.y)}function Zct(t,e,n,r=0){const i=r?Dc(n.min,n.max,r):n.min;t.min=e.min-i,t.max=t.min+ff(e)}function tne(t,e,n,r){Zct(t.x,e.x,n.x,r?.x),Zct(t.y,e.y,n.y,r?.y)}function Xct(t,e,n,r,i){return t-=e,t=Jte(t,1/n,r),i!==void 0&&(t=Jte(t,1/i,r)),t}function Djn(t,e=0,n=1,r=.5,i,o=t,l=t){if(dx.test(e)&&(e=parseFloat(e),e=Dc(l.min,l.max,e/100)-l.min),typeof e!="number")return;let u=Dc(o.min,o.max,r);t===o&&(u-=e),t.min=Xct(t.min,e,n,u,i),t.max=Xct(t.max,e,n,u,i)}function Jct(t,e,[n,r,i],o,l){Djn(t,e[n],e[r],e[i],e.scale,o,l)}const Njn=["x","scaleX","originX"],Rjn=["y","scaleY","originY"];function eut(t,e,n,r){Jct(t.x,e,Njn,n?n.x:void 0,r?r.x:void 0),Jct(t.y,e,Rjn,n?n.y:void 0,r?r.y:void 0)}function tut(t){return t.translate===0&&t.scale===1}function nut(t){return tut(t.x)&&tut(t.y)}function rut(t,e){return t.min===e.min&&t.max===e.max}function Ljn(t,e){return rut(t.x,e.x)&&rut(t.y,e.y)}function aut(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function iut(t,e){return aut(t.x,e.x)&&aut(t.y,e.y)}function out(t){return ff(t.x)/ff(t.y)}function sut(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function mx(t){return[t("x"),t("y")]}function Mjn(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 lut=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],Pjn=lut.length,cut=t=>typeof t=="string"?parseFloat(t):t,uut=t=>typeof t=="number"||Ja.test(t);function Ojn(t,e,n,r,i,o){i?(t.opacity=Dc(0,n.opacity??1,Fjn(r)),t.opacityExit=Dc(e.opacity??1,0,Qjn(r))):o&&(t.opacity=Dc(e.opacity??1,n.opacity??1,r));for(let l=0;l<Pjn;l++){const u=lut[l];let d=dut(e,u),p=dut(n,u);if(d===void 0&&p===void 0)continue;d||(d=0),p||(p=0),d===0||p===0||uut(d)===uut(p)?(t[u]=Math.max(Dc(cut(d),cut(p),r),0),(dx.test(p)||dx.test(d))&&(t[u]+="%")):t[u]=p}(e.rotate||n.rotate)&&(t.rotate=Dc(e.rotate||0,n.rotate||0,r))}function dut(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Fjn=put(0,.5,Jst),Qjn=put(.5,.95,ry);function put(t,e,n){return r=>r<t?0:r>e?1:n(WP(t,e,r))}function mut(t,e,n){const r=Sd(t)?t:cI(t);return r.start(hEe("",r,e,n)),r.animation}function sz(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}const $jn=(t,e)=>t.depth-e.depth;class jjn{constructor(){this.children=[],this.isDirty=!1}add(e){Mke(this.children,e),this.isDirty=!0}remove(e){GP(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort($jn),this.isDirty=!1,this.children.forEach(e)}}function zjn(t,e){const n=hf.now(),r=({timestamp:i})=>{const o=i-n;o>=e&&(E1(r),t(o-e))};return Nl.setup(r,!0),()=>E1(r)}function nne(t){return Sd(t)?t.get():t}class Ujn{constructor(){this.members=[]}add(e){Mke(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&&(GP(this.members,r),r.unmount())}e.scheduleRender()}remove(e){if(GP(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 rne={hasAnimatedSinceResize:!0,hasEverUpdated:!1},QEe=["","X","Y","Z"],qjn=1e3;let Gjn=0;function $Ee(t,e,n,r){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),r&&(r[t]=0))}function gut(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Xlt(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Nl,!(i||o))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&gut(r)}function hut({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(l={},u=e?.()){this.id=Gjn++,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(Yjn),this.nodes.forEach(e7n),this.nodes.forEach(t7n),this.nodes.forEach(Vjn)},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 jjn)}addEventListener(l,u){return this.eventHandlers.has(l)||this.eventHandlers.set(l,new Oke),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=Hte(l)&&!gct(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;Nl.read(()=>{g=window.innerWidth}),t(l,()=>{const f=window.innerWidth;f!==g&&(g=f,this.root.updateBlockedByResize=!0,m&&m(),m=zjn(h,250),rne.hasAnimatedSinceResize&&(rne.hasAnimatedSinceResize=!1,this.nodes.forEach(but)))})}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()||o7n,{onLayoutAnimationStart:y,onLayoutAnimationComplete:v}=p.getProps(),_=!this.targetLayout||!iut(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={...gEe(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||but(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(),E1(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(n7n),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&&gut(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(Zjn),this.nodes.forEach(fut);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Aut);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Xjn),this.nodes.forEach(Jjn),this.nodes.forEach(Hjn),this.nodes.forEach(Wjn)):this.nodes.forEach(Aut),this.clearAllSnapshots();const u=hf.now();mg.delta=ux(0,1e3/60,u-mg.timestamp),mg.timestamp=u,mg.isProcessing=!0,zke.update.process(mg),zke.preRender.process(mg),zke.render.process(mg),mg.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,EEe.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Kjn),this.sharedNodes.forEach(r7n)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Nl.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Nl.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ff(this.snapshot.measuredBox.x)&&!ff(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=np()),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&&!nut(this.projectionDelta),d=this.getTransformTemplate(),p=d?d(this.latestValues,""):void 0,m=p!==this.prevTransformTemplateValue;l&&this.instance&&(u||jN(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)),s7n(d),{animationId:this.root.animationId,measuredBox:u,layoutBox:d,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:l}=this.options;if(!l)return np();const u=l.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(l7n))){const{scroll:p}=this.root;p&&(px(u.x,p.offset.x),px(u.y,p.offset.y))}return u}removeElementScroll(l){const u=np();if(Vv(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&&Vv(u,l),px(u.x,m.offset.x),px(u.y,m.offset.y))}return u}applyTransform(l,u=!1,d){const p=d||np();Vv(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&&(px(p.x,-g.scroll.offset.x),px(p.y,-g.scroll.offset.y)),jN(g.latestValues)&&ene(p,g.latestValues,g.layout?.layoutBox)}return jN(this.latestValues)&&ene(p,this.latestValues,this.layout?.layoutBox),p}removeTransform(l){const u=np();Vv(u,l);for(let d=0;d<this.path.length;d++){const p=this.path[d];if(!jN(p.latestValues))continue;let m;p.instance&&(REe(p.latestValues)&&p.updateSnapshot(),m=np(),Vv(m,p.measurePageBox())),eut(u,p.latestValues,p.snapshot?.layoutBox,m)}return jN(this.latestValues)&&eut(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!==mg.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=mg.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=np(),this.targetWithTransforms=np()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Bjn(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Vv(this.target,this.layout.layoutBox),Ict(this.target,this.targetDelta)):Vv(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||REe(this.parent.latestValues)||Ect(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=np(),this.relativeTargetOrigin=np(),tne(this.relativeTargetOrigin,u,d,this.options.layoutAnchor||void 0),Vv(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===mg.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;Vv(this.layoutCorrected,this.layout.layoutBox);const g=this.treeScale.x,h=this.treeScale.y;ijn(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=np());const{target:f}=l;if(!f){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Hct(this.prevProjectionDelta.x,this.projectionDelta.x),Hct(this.prevProjectionDelta.y,this.projectionDelta.y)),oz(this.projectionDelta,this.layoutCorrected,f,this.latestValues),(this.treeScale.x!==g||this.treeScale.y!==h||!sut(this.projectionDelta.x,this.prevProjectionDelta.x)||!sut(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=t5(),this.projectionDelta=t5(),this.projectionDeltaWithTransform=t5()}setAnimationOrigin(l,u=!1){const d=this.snapshot,p=d?d.latestValues:{},m={...this.latestValues},g=t5();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!u;const h=np(),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(i7n));this.animationProgress=0;let x;this.mixTargetDelta=k=>{const C=k/1e3;yut(g.x,l.x,C),yut(g.y,l.y,C),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(tne(h,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),a7n(this.relativeTarget,this.relativeTargetOrigin,h,C),x&&Ljn(this.relativeTarget,x)&&(this.isProjectionDirty=!1),x||(x=np()),Vv(x,this.relativeTarget)),y&&(this.animationValues=m,Ojn(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&&(E1(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Nl.update(()=>{rne.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=cI(0)),this.motionValue.jump(0,!1),this.currentAnimation=mut(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(qjn),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&&kut(this.options.animationType,this.layout.layoutBox,p.layoutBox)){d=this.target||np();const g=ff(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+g;const h=ff(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+h}Vv(u,d),ene(u,m),oz(this.projectionDeltaWithTransform,this.layoutCorrected,u,m)}}registerSharedNode(l,u){this.sharedNodes.has(l)||this.sharedNodes.set(l,new Ujn),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&&$Ee("z",l,p,this.animationValues);for(let m=0;m<QEe.length;m++)$Ee(`rotate${QEe[m]}`,l,p,this.animationValues),$Ee(`skew${QEe[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=nne(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=nne(u?.pointerEvents)||""),this.hasProjected&&!jN(this.latestValues)&&(l.transform=d?d({},""):"none",this.hasProjected=!1);return}l.visibility="";const m=p.animationValues||p.latestValues;this.applyTransformsToTarget();let g=Mjn(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 PEe){if(m[b]===void 0)continue;const{correct:y,applyTo:v,isCSSVariable:_}=PEe[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?nne(u?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(l=>l.currentAnimation?.stop()),this.root.nodes.forEach(fut),this.root.sharedNodes.clear()}}}function Hjn(t){t.updateLayout()}function Wjn(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")mx(m=>{const g=o?e.measuredBox[m]:e.layoutBox[m],h=ff(g);g.min=n[m].min,g.max=g.min+h});else if(i==="x"||i==="y"){const m=i==="x"?"y":"x";FEe(o?e.measuredBox[m]:e.layoutBox[m],n[m])}else kut(i,e.layoutBox,n)&&mx(m=>{const g=o?e.measuredBox[m]:e.layoutBox[m],h=ff(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=t5();oz(l,n,e.layoutBox);const u=t5();o?oz(u,t.applyTransform(r,!0),e.measuredBox):oz(u,n,e.layoutBox);const d=!nut(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=np();tne(b,e.layoutBox,g.layoutBox,f);const y=np();tne(y,n,h.layoutBox,f),iut(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 Yjn(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 Vjn(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Kjn(t){t.clearSnapshot()}function fut(t){t.clearMeasurements()}function Zjn(t){t.isLayoutDirty=!0,t.updateLayout()}function Aut(t){t.isLayoutDirty=!1}function Xjn(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function Jjn(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function but(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function e7n(t){t.resolveTargetDelta()}function t7n(t){t.calcProjection()}function n7n(t){t.resetSkewAndRotation()}function r7n(t){t.removeLeadSnapshot()}function yut(t,e,n){t.translate=Dc(e.translate,0,n),t.scale=Dc(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function vut(t,e,n,r){t.min=Dc(e.min,n.min,r),t.max=Dc(e.max,n.max,r)}function a7n(t,e,n,r){vut(t.x,e.x,n.x,r),vut(t.y,e.y,n.y,r)}function i7n(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const o7n={duration:.45,ease:[.4,0,.1,1]},_ut=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),wut=_ut("applewebkit/")&&!_ut("chrome/")?Math.round:ry;function xut(t){t.min=wut(t.min),t.max=wut(t.max)}function s7n(t){xut(t.x),xut(t.y)}function kut(t,e,n){return t==="position"||t==="preserve-aspect"&&!Tjn(out(e),out(n),.2)}function l7n(t){return t!==t.root&&t.scroll?.wasRoot}const c7n=hut({attachResizeListener:(t,e)=>sz(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),u7n=t=>!t.isLayoutDirty&&t.willUpdate(!1);function Eut(){const t=new Set,e=new WeakMap,n=()=>t.forEach(u7n);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 jEe={current:void 0},Cut=hut({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!jEe.current){const t=new c7n({});t.mount(window),t.setOptions({layoutScroll:!0}),jEe.current=t}return jEe.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),lz=T.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Sut(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function d7n(...t){return e=>{let n=!1;const r=t.map(i=>{const o=Sut(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():Sut(t[i],null)}}}}function p7n(...t){return ee.useCallback(d7n(...t),t)}class m7n extends ee.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(qte(n)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const r=n.offsetParent,i=qte(r)&&r.offsetWidth||0,o=qte(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 g7n({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(lz),m=t.props?.ref??t?.ref,g=p7n(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;
|
|
@@ -605,7 +605,7 @@ const partysocket = new PartySocket({
|
|
|
605
605
|
${g?"shadow-xl z-50 cursor-grabbing":""}
|
|
606
606
|
${E?"":"active:bg-neutral-50 dark:active:bg-neutral-800"}
|
|
607
607
|
${m?"animate-pulse":""}
|
|
608
|
-
`,children:U})]}),w&&Qi.createPortal(A.jsx(oRe,{x:w.x,y:w.y,onEdit:()=>l?.(t),onDelete:()=>u?.(t),onClose:()=>x(null),isDefaultAgent:D,isMarketplacePublished:e}),document.body)]})},b8r=({agent:t,isSelected:e=!1,status:n="idle",role:r,isMarketplacePublished:i=!1,onClick:o,onEdit:l,onDelete:u,isDragging:d=!1,sortMode:p=!1,onLongPress:m,wholeDragProps:g,style:h,setNodeRef:f})=>{const[b,y]=T.useState(null),v=t.tags?.some(x=>x.startsWith("default_")),_=XNt(m,p),w=x=>{if(_.isTracking()||_.didFire.current){x.preventDefault();return}!l&&!u||(x.preventDefault(),x.stopPropagation(),y({x:x.clientX,y:x.clientY}))};return A.jsxs(A.Fragment,{children:[A.jsxs("div",{ref:f,style:h,"data-agent-id":t.id,role:"button",tabIndex:0,"aria-pressed":e,onClick:()=>{d||_.didFire.current||p||o?.(t)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),!d&&!p&&o?.(t))},onContextMenu:w,..._.handlers,...p?g?.attributes:{},...p?g?.listeners:{},className:`w-full flex items-center gap-3 p-2 rounded-sm transition-all duration-200 group ${e?"bg-white/80 dark:bg-white/20 shadow-sm":"hover:bg-white/40 dark:hover:bg-white/10"} ${d?"shadow-xl z-50 cursor-grabbing":"cursor-pointer"} ${p&&!d?"agent-jiggle":""} ${p?"touch-none":""}`,children:[A.jsx("div",{className:"relative",children:A.jsx("img",{src:t.avatar||"https://api.dicebear.com/7.x/avataaars/svg?seed=default",alt:t.name,className:"w-10 h-10 rounded-full border border-white/50 object-cover"})}),A.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[A.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[A.jsx("div",{className:"truncate text-sm font-semibold text-neutral-800 dark:text-neutral-200",children:t.name}),n==="busy"&&A.jsx(eF,{status:"running",size:"xs",showLabel:!1,className:"shrink-0"})]}),r&&A.jsx("div",{className:"truncate text-[10px] text-neutral-500",children:r})]})]}),b&&(l||u)&&Qi.createPortal(A.jsx(oRe,{x:b.x,y:b.y,onEdit:()=>l?.(t),onDelete:()=>u?.(t),onClose:()=>y(null),isDefaultAgent:v,isMarketplacePublished:i}),document.body)]})},tF=t=>t.variant==="detailed"?A.jsx(A8r,{...t}):A.jsx(b8r,{...t}),y8r={hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.08,delayChildren:.1}}},eRt=({agent:t,variant:e,sortMode:n,onLongPress:r,isMarketplacePublished:i,lastConversationTime:o,activeTopicCount:l,isRootAgent:u,isSelected:d,status:p,role:m,onClick:g,onEdit:h,onDelete:f,isLoading:b})=>{const{attributes:y,listeners:v,setNodeRef:_,transform:w,transition:x,isDragging:k}=d8r({id:t.id,disabled:!n}),C={transform:Qx.Transform.toString(w),transition:x,opacity:k&&!n?.5:1},E=n?{attributes:y,listeners:v??{}}:void 0;return e==="detailed"?A.jsx(tF,{agent:t,variant:"detailed",isMarketplacePublished:i,lastConversationTime:o,activeTopicCount:l,isRootAgent:u,onClick:g,onEdit:h,onDelete:f,isLoading:b,isDragging:k,sortMode:n,onLongPress:r,wholeDragProps:E,style:C,setNodeRef:_}):A.jsx(tF,{agent:t,variant:"compact",isSelected:d,status:p,role:m,isMarketplacePublished:i,onClick:g,onEdit:h,onDelete:f,isDragging:k,sortMode:n,onLongPress:r,wholeDragProps:E,style:C,setNodeRef:_})},tRt=t=>{const{agents:e,variant:n,onAgentClick:r,loadingAgentId:i,sortable:o=!1,onReorder:l,onSortModeChange:u,rootAgentId:d}=t,{t:p}=Cn(),[m,g]=T.useState(e),[h,f]=T.useState(null),[b,y]=T.useState(!1),v=t.sortModeControlled!==void 0,_=v?t.sortModeControlled:b,w=T.useRef(!1);T.useEffect(()=>{if(w.current)return;const $=new Set(e.map(H=>H.id)),z=new Set(m.map(H=>H.id));($.size!==z.size||![...$].every(H=>z.has(H)))&&g(e)},[e]);const x=o?m:e,k=h?x.find($=>$.id===h):null,C=OSt(MBe(UBe,{activationConstraint:{distance:5}}),MBe(n2t,{activationConstraint:{distance:5}})),E=T.useCallback($=>{w.current=!0,f($.active.id)},[]),S=T.useCallback($=>{const{active:z,over:U}=$;w.current=!1,f(null),U&&z.id!==U.id&&g(H=>{const te=H.findIndex(oe=>oe.id===z.id),Z=H.findIndex(oe=>oe.id===U.id),ae=aRe(H,te,Z);return setTimeout(()=>{l?.(ae.map(oe=>oe.id))},0),ae})},[l]),I=T.useCallback(()=>{w.current=!1,f(null)},[]),B=T.useCallback(()=>{!o||v||(y(!0),u?.(!0))},[o,v,u]),N=T.useCallback(()=>{v||(y(!1),u?.(!1))},[v,u]),L=()=>{if(!k||_)return null;if(n==="detailed"){const{publishedAgentIds:te,lastConversationTimeByAgent:Z}=t;return A.jsx(tF,{agent:k,variant:"detailed",isMarketplacePublished:te?.has(k.id),lastConversationTime:Z?.[k.id],activeTopicCount:t.activeTopicCountByAgent?.[k.id],isRootAgent:k.id===d,isDragging:!0})}const{selectedAgentId:$,getAgentStatus:z,getAgentRole:U,publishedAgentIds:H}=t;return A.jsx(tF,{agent:k,variant:"compact",isSelected:k.id===$,status:z?.(k)??"idle",role:U?.(k),isMarketplacePublished:H?.has(k.id),isDragging:!0})},M=_&&!v&&A.jsx("div",{className:"fixed top-3 right-4 z-50",children:A.jsx("button",{onClick:N,className:"rounded-full bg-neutral-800 px-5 py-1.5 text-sm font-medium text-white shadow-lg active:scale-95 transition-transform dark:bg-neutral-200 dark:text-neutral-900",children:p("common.done",{defaultValue:"Done"})})});if(n==="detailed"){const{publishedAgentIds:$,lastConversationTimeByAgent:z,activeTopicCountByAgent:U,onEdit:H,onDelete:te}=t,Z=A.jsx(Ct.div,{className:"divide-y divide-neutral-100 dark:divide-neutral-800",variants:y8r,initial:"hidden",animate:"visible",children:x.map(ae=>o?A.jsx(eRt,{agent:ae,variant:"detailed",sortMode:_,onLongPress:v?void 0:B,isMarketplacePublished:$?.has(ae.id),lastConversationTime:z?.[ae.id],activeTopicCount:U?.[ae.id],isRootAgent:ae.id===d,onClick:r,onEdit:H,onDelete:te,isLoading:i===ae.id},ae.id):A.jsx(tF,{agent:ae,variant:"detailed",isMarketplacePublished:$?.has(ae.id),lastConversationTime:z?.[ae.id],activeTopicCount:U?.[ae.id],isRootAgent:ae.id===d,onClick:r,onEdit:H,onDelete:te,isLoading:i===ae.id},ae.id))});return o?A.jsxs(Toe,{sensors:C,collisionDetection:QSt,onDragStart:E,onDragEnd:S,onDragCancel:I,children:[A.jsx(KNt,{items:x.map(ae=>ae.id),strategy:WNt,children:Z}),M,Qi.createPortal(A.jsx(YBe,{children:L()}),document.body)]}):Z}const{selectedAgentId:R,getAgentStatus:D,getAgentRole:P,publishedAgentIds:O,onEdit:F,onDelete:Q}=t,j=A.jsx("div",{className:"space-y-1",children:x.map($=>o?A.jsx(eRt,{agent:$,variant:"compact",sortMode:_,onLongPress:v?void 0:B,isSelected:$.id===R,status:D?.($)??"idle",role:P?.($),isMarketplacePublished:O?.has($.id),onClick:r,onEdit:F,onDelete:Q},$.id):A.jsx(tF,{agent:$,variant:"compact",isSelected:$.id===R,status:D?.($)??"idle",role:P?.($),isMarketplacePublished:O?.has($.id),onClick:r,onEdit:F,onDelete:Q},$.id))});return o?A.jsxs(Toe,{sensors:C,collisionDetection:QSt,onDragStart:E,onDragEnd:S,onDragCancel:I,children:[A.jsx(KNt,{items:x.map($=>$.id),strategy:WNt,children:j}),M,Qi.createPortal(A.jsx(YBe,{children:L()}),document.body)]}):j};function v8r(){const{capsuleOpen:t,capsuleActiveTab:e,setCapsuleOpen:n,setCapsuleActiveTab:r}=Un(Wo(u=>({capsuleOpen:u.capsuleOpen,capsuleActiveTab:u.capsuleActiveTab,setCapsuleOpen:u.setCapsuleOpen,setCapsuleActiveTab:u.setCapsuleActiveTab}))),i=T.useCallback(u=>{n(!0),u&&r(u)},[n,r]),o=T.useCallback(()=>{n(!1)},[n]),l=T.useCallback(u=>{t?n(!1):(n(!0),u&&r(u))},[t,n,r]);return{isOpen:t,activeTab:e,setActiveTab:r,open:i,close:o,toggle:l}}class _8r{maxConcurrency;active=new Map;queue=[];constructor(e){this.maxConcurrency=e}enqueue(e,n,r){let i,o;const l=new Promise((p,m)=>{i=p,o=m}),u={id:e,onStart:n,execute:r,resolve:i,reject:o};return this.queue.push(u),this.tryNext(),{promise:l.then(p=>p.promise),abort:()=>{const p=this.queue.findIndex(g=>g.id===e);if(p!==-1){this.queue.splice(p,1),o(new Error("Upload cancelled"));return}const m=this.active.get(e);m&&m.abort()}}}cancel(e){const n=this.queue.findIndex(i=>i.id===e);if(n!==-1){this.queue.splice(n,1)[0].reject(new Error("Upload cancelled"));return}const r=this.active.get(e);r&&r.abort()}cancelAll(){for(const e of this.queue)e.reject(new Error("Upload cancelled"));this.queue=[];for(const e of this.active.values())e.abort()}tryNext(){for(;this.active.size<this.maxConcurrency&&this.queue.length>0;){const e=this.queue.shift();e.onStart();const n=e.execute();this.active.set(e.id,n),e.resolve(n),n.promise.finally(()=>{this.active.delete(e.id),this.tryNext()})}}}const nRt=new _8r(3);function rRt({...t}){return A.jsx(Dne,{"data-slot":"dialog",...t})}function w8r({...t}){return A.jsx(Nne,{"data-slot":"dialog-portal",...t})}function x8r({className:t,...e}){return A.jsx(Rne,{"data-slot":"dialog-overlay",className:Yt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1100] bg-black/50",t),...e})}function aRt({className:t,children:e,showCloseButton:n=!0,...r}){return A.jsxs(w8r,{"data-slot":"dialog-portal",children:[A.jsx(x8r,{}),A.jsxs(Lne,{"data-slot":"dialog-content",className:Yt("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-[1100] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",t),...r,children:[e,n&&A.jsxs(Mne,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[A.jsx(k1,{}),A.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function k8r({className:t,...e}){return A.jsx("div",{"data-slot":"dialog-header",className:Yt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function E8r({className:t,...e}){return A.jsx("div",{"data-slot":"dialog-footer",className:Yt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function iRt({className:t,...e}){return A.jsx(k1e,{"data-slot":"dialog-title",className:Yt("text-lg leading-none font-semibold",t),...e})}function C8r({className:t,...e}){return A.jsx(E1e,{"data-slot":"dialog-description",className:Yt("text-muted-foreground text-sm",t),...e})}function S8r({isOpen:t,onClose:e,onConfirm:n,title:r,message:i,initialValue:o="",placeholder:l="",confirmLabel:u="Confirm",cancelLabel:d="Cancel",className:p}){const[m,g]=T.useState(o);T.useEffect(()=>{t&&g(o)},[t,o]);const h=()=>{m.trim()&&(n(m.trim()),e())},f=b=>{b.key==="Enter"&&(b.preventDefault(),h())};return A.jsx(rRt,{open:t,onOpenChange:b=>!b&&e(),children:A.jsxs(aRt,{className:Yt("space-y-4 border border-neutral-200/20 bg-white/95 shadow-2xl shadow-black/20 backdrop-blur-xl dark:border-neutral-700/30 dark:bg-neutral-900/95 dark:shadow-black/40","p-6 sm:p-6 rounded-sm w-full max-w-md",p),children:[A.jsxs(k8r,{children:[A.jsx(iRt,{className:"text-lg font-bold text-neutral-900 dark:text-neutral-100",children:r}),i&&A.jsx(C8r,{className:"text-sm text-neutral-600 dark:text-neutral-400",children:i})]}),A.jsx("div",{className:"py-2",children:A.jsx(Hc,{type:"text",placeholder:l||"Input",value:m,onChange:b=>g(b.target.value),onKeyDown:f,autoFocus:!0})}),A.jsxs(E8r,{children:[A.jsx("button",{onClick:e,className:"inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-semibold text-neutral-900 hover:bg-neutral-100 dark:text-neutral-100 dark:hover:bg-neutral-800 transition-colors",children:d}),A.jsx("button",{onClick:h,className:"inline-flex items-center justify-center rounded-md bg-indigo-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:bg-indigo-500 dark:hover:bg-indigo-400",children:u})]})]})})}const I8r=ee.memo(S8r),oRt=({isOpen:t,onClose:e,title:n,message:r,type:i="info",actionLabel:o,onAction:l})=>{const u=()=>{switch(i){case"warning":return{icon:Ag,bgColor:"bg-yellow-100",iconColor:"text-yellow-600",buttonColor:"bg-yellow-600 data-[hover]:bg-yellow-500 dark:bg-yellow-500 dark:data-[hover]:bg-yellow-400"};case"error":return{icon:tU,bgColor:"bg-red-100",iconColor:"text-red-600",buttonColor:"bg-red-600 data-[hover]:bg-red-500 dark:bg-red-500 dark:data-[hover]:bg-red-400"};case"success":return{icon:nc,bgColor:"bg-green-100",iconColor:"text-green-600",buttonColor:"bg-green-600 data-[hover]:bg-green-500 dark:bg-green-500 dark:data-[hover]:bg-green-400"};default:return{icon:pu,bgColor:"bg-blue-100",iconColor:"text-blue-600",buttonColor:"bg-blue-600 data-[hover]:bg-blue-500 dark:bg-blue-500 dark:data-[hover]:bg-blue-400"}}},{icon:d,bgColor:p,iconColor:m,buttonColor:g}=u();return A.jsxs(P0t,{open:t,onClose:e,className:`relative ${i_.max}`,children:[A.jsx(O0t,{className:"fixed inset-0 bg-black/50 backdrop-blur-sm"}),A.jsx("div",{className:"fixed inset-0 flex w-screen items-center justify-center p-4",children:A.jsxs(F0t,{from:"top",className:"w-full max-w-md space-y-4 rounded-sm border border-neutral-200/20 bg-white/95 p-8 shadow-2xl shadow-black/20 backdrop-blur-xl dark:border-neutral-700/30 dark:bg-neutral-900/95 dark:shadow-black/40",children:[A.jsx(Q0t,{className:"text-lg font-bold text-neutral-900 dark:text-neutral-100",children:n}),A.jsx("div",{className:"mt-4",children:A.jsxs("div",{className:"flex items-start",children:[A.jsx("div",{className:`mx-auto flex h-12 w-12 shrink-0 items-center justify-center rounded-full ${p} sm:mx-0 sm:h-10 sm:w-10`,children:A.jsx(d,{className:`h-6 w-6 ${m}`,"aria-hidden":"true"})}),A.jsx("div",{className:"mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left",children:A.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:r})})]})}),A.jsx("div",{className:"mt-6 flex justify-end gap-4",children:o&&l?A.jsxs(A.Fragment,{children:[A.jsx(qc,{type:"button",onClick:e,className:"inline-flex items-center gap-2 rounded-sm bg-neutral-100 py-1.5 px-3 text-sm/6 font-semibold text-neutral-700 shadow-sm focus:outline-none data-[hover]:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-200 dark:data-[hover]:bg-neutral-700",children:"Close"}),A.jsx(qc,{type:"button",onClick:()=>{l(),e()},className:`inline-flex items-center gap-2 rounded-sm py-1.5 px-3 text-sm/6 font-semibold text-white shadow-inner shadow-white/10 focus:outline-none ${g}`,children:o})]}):A.jsx(qc,{type:"button",onClick:e,className:`inline-flex items-center gap-2 rounded-sm py-1.5 px-3 text-sm/6 font-semibold text-white shadow-inner shadow-white/10 focus:outline-none ${g}`,children:"OK"})})]})})]})},T8r=({url:t,className:e})=>A.jsx("div",{className:`flex h-full w-full items-center justify-center ${e}`,children:A.jsx("audio",{src:t,controls:!0,className:"w-full max-w-md"})}),B8r=({file:t,url:e,className:n})=>A.jsx("div",{className:`flex h-full w-full items-center justify-center ${n}`,children:A.jsx("img",{src:e,alt:t.name,className:"max-h-full max-w-full object-contain"})}),sRt=({url:t,className:e})=>{const[n,r]=T.useState(""),[i,o]=T.useState(!0),[l,u]=T.useState(null);return T.useEffect(()=>{const d=new AbortController;return t&&(async()=>{o(!0),u(null);try{const m=await fetch(t,{signal:d.signal});if(!m.ok)throw new Error(`Failed to load markdown: ${m.status} ${m.statusText}`);const g=await m.text();d.signal.aborted||(r(g),o(!1))}catch(m){d.signal.aborted||(console.error("Failed to load markdown content:",m),u("Failed to load content"),o(!1))}})(),()=>{d.abort()}},[t]),i?A.jsx("div",{className:"text-neutral-400 p-6",children:"Loading markdown..."}):l?A.jsx("div",{className:"text-red-400 p-6",children:l}):A.jsx("div",{className:`h-full w-full overflow-auto bg-white dark:bg-neutral-800 p-6 rounded-md ${e}`,children:A.jsx(If,{content:n})})},D8r=({url:t,className:e})=>{const n=Un(l=>l.token),r=T.useRef(null),i=T.useRef(null),o=T.useRef(null);return T.useEffect(()=>!t||!r.current?void 0:((async()=>{try{let u=t;if(!t.startsWith("blob:")&&!t.startsWith("http://")&&!t.startsWith("https://")&&!t.startsWith("data:")){const d=await fetch(t,{headers:n?{Authorization:`Bearer ${n}`}:{}});if(!d.ok){console.error(`[PdfRenderer] Failed to load PDF: ${d.status} ${d.statusText}`);return}const p=await d.blob(),m=URL.createObjectURL(p);o.current=m,u=m}try{const g=(await(await(await Promise.resolve().then(()=>o1a)).getDocument(u).promise).getPage(1)).getViewport({scale:1}),h=g.width>g.height;console.log(`[PdfRenderer] PDF orientation: ${h?"landscape":"portrait"}`)}catch(d){console.warn("[PdfRenderer] Could not detect PDF orientation:",d)}r.current&&(r.current.src=u)}catch(u){console.error("[PdfRenderer] Error loading PDF:",u)}})(),()=>{o.current&&(URL.revokeObjectURL(o.current),o.current=null)}),[t,n]),A.jsx("div",{ref:i,className:`pdf-viewer-container h-full w-full overflow-auto ${e}`,children:A.jsx("iframe",{ref:r,className:"h-full w-full border-0",title:"PDF Preview",scrolling:"no"})})},N8r=({url:t,className:e})=>A.jsx("div",{className:`flex h-full w-full items-center justify-center ${e}`,children:A.jsx("video",{src:t,controls:!0,className:"max-h-full max-w-full"})});function R8r(){return A.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4 p-8",children:[A.jsx("div",{className:"animate-pulse rounded-lg bg-neutral-200/60 p-6 dark:bg-white/[0.06]",children:A.jsx("svg",{className:"h-16 w-16 text-neutral-300 dark:text-neutral-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909M3.75 21h16.5A2.25 2.25 0 0 0 22.5 18.75V5.25A2.25 2.25 0 0 0 20.25 3H3.75A2.25 2.25 0 0 0 1.5 5.25v13.5A2.25 2.25 0 0 0 3.75 21Z"})})}),A.jsx("div",{className:"h-2 w-32 animate-pulse rounded-full bg-neutral-200/60 dark:bg-white/[0.06]"})]})}const L8r=({isOpen:t,onClose:e,file:n})=>{const[r,i]=T.useState(null),[o,l]=T.useState(!1),[u,d]=T.useState(null);T.useEffect(()=>{if(t&&n){let h=!0;return(async()=>{l(!0),d(null);try{if(n.url&&(n.url.startsWith("blob:")||n.url.startsWith("data:"))){i(n.url),l(!1);return}const y=await(await ys.downloadRaw(n.id)).blob(),v=URL.createObjectURL(y);h?i(v):URL.revokeObjectURL(v)}catch(b){if(console.error(b),h){const y=b instanceof Error?b.message:"Failed to load file preview";d(y)}}finally{h&&l(!1)}})(),()=>{h=!1,r&&(URL.revokeObjectURL(r),i(null))}}else i(null)},[t,n]);const p=n?.type.toLowerCase()==="application/pdf",m=A.jsxs("div",{className:"flex items-center gap-1.5",children:[r&&A.jsx("a",{href:r,download:n?.name,className:"rounded-lg bg-black/40 p-2 text-white/80 backdrop-blur-md transition-colors hover:bg-black/60 hover:text-white",title:"Download",children:A.jsx(mR,{className:"h-4 w-4"})}),A.jsx("button",{onClick:e,className:"rounded-lg bg-black/40 p-2 text-white/80 backdrop-blur-md transition-colors hover:bg-black/60 hover:text-white",title:"Close",children:A.jsx(Yl,{className:"h-4 w-4"})})]}),g=()=>{if(o)return A.jsx(R8r,{});if(u)return A.jsx("div",{className:"flex h-full items-center justify-center p-8",children:A.jsx("div",{className:"text-[13px] text-red-500",children:u})});if(!n||!r)return null;const h=n.type.toLowerCase();return h.startsWith("image/")?A.jsx(B8r,{file:n,url:r}):h.startsWith("video/")?A.jsx(N8r,{file:n,url:r}):h.startsWith("audio/")?A.jsx(T8r,{file:n,url:r}):h==="application/pdf"?A.jsx(D8r,{file:n,url:r}):h==="text/markdown"||h==="text/plain"||n.name.endsWith(".md")||n.name.endsWith(".txt")?A.jsx(sRt,{file:n,url:r}):A.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 text-neutral-700 dark:text-neutral-300",children:[A.jsx("p",{className:"text-[13px]",children:"Preview not available for this file type."}),A.jsx("a",{href:r,download:n.name,className:"rounded-lg bg-indigo-500 px-4 py-2 text-[13px] font-semibold text-white hover:bg-indigo-600 dark:hover:bg-indigo-400",title:"Download",children:"Download File"})]})};return A.jsx(Gc,{isOpen:t,onClose:e,desktopClassName:"md:h-[85vh] md:max-w-5xl",children:A.jsxs("div",{className:"relative flex min-h-[60vh] flex-1 flex-col overflow-hidden md:min-h-0",children:[!p&&A.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-neutral-200/60 bg-black/85 px-4 py-3 text-white backdrop-blur-md md:hidden dark:border-neutral-800/60",children:[A.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-white/90",children:n?.name}),m]}),!p&&A.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 hidden items-center justify-between px-4 pt-4 md:flex",children:[A.jsx("span",{className:"pointer-events-auto max-w-[70%] truncate rounded-lg bg-black/40 px-3 py-1.5 text-xs font-medium text-white/90 backdrop-blur-md",children:n?.name}),A.jsx("div",{className:"pointer-events-auto",children:m})]}),A.jsx("div",{className:"relative flex min-h-0 flex-1 items-center justify-center overflow-hidden",children:g()})]})})},lRt={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",swift:"swift",sh:"shell",bash:"shell",zsh:"shell",json:"json",yaml:"yaml",yml:"yaml",toml:"ini",xml:"xml",html:"html",htm:"html",css:"css",scss:"scss",less:"less",md:"markdown",sql:"sql",dockerfile:"dockerfile",makefile:"plaintext",graphql:"graphql",prisma:"plaintext",env:"plaintext",txt:"plaintext"};function M8r(t){const e=t.toLowerCase();if(e==="dockerfile")return"dockerfile";if(e==="makefile")return"plaintext";const n=e.split(".").pop()??"";return lRt[n]??"plaintext"}const P8r=new Set(["application/json","application/xml","application/yaml","application/x-yaml","application/javascript","application/typescript","application/xhtml+xml","application/sql","application/graphql","application/toml"]);function cRt(t,e){const n=t.toLowerCase();return!!(n==="dockerfile"||n==="makefile"||(n.split(".").pop()??"")in lRt||e&&(e.startsWith("text/")||P8r.has(e)))}var sRe=new Map,lle=new WeakMap,uRt=0,O8r;function F8r(t){return t?(lle.has(t)||(uRt+=1,lle.set(t,uRt.toString())),lle.get(t)):"0"}function Q8r(t){return Object.keys(t).sort().filter(e=>t[e]!==void 0).map(e=>`${e}_${e==="root"?F8r(t.root):t[e]}`).toString()}function $8r(t){const e=Q8r(t);let n=sRe.get(e);if(!n){const r=new Map;let i;const o=new IntersectionObserver(l=>{l.forEach(u=>{var d;const p=u.isIntersecting&&i.some(m=>u.intersectionRatio>=m);t.trackVisibility&&typeof u.isVisible>"u"&&(u.isVisible=p),[...(d=r.get(u.target))!=null?d:[]].forEach(m=>{m(p,u)})})},t);i=o.thresholds||(Array.isArray(t.threshold)?t.threshold:[t.threshold||0]),n={id:e,observer:o,elements:r},sRe.set(e,n)}return n}function j8r(t,e,n={},r=O8r){if(typeof window.IntersectionObserver>"u"&&r!==void 0){const d=t.getBoundingClientRect();return e(r,{isIntersecting:r,target:t,intersectionRatio:typeof n.threshold=="number"?n.threshold:0,time:0,boundingClientRect:d,intersectionRect:d,rootBounds:d}),()=>{}}const{id:i,observer:o,elements:l}=$8r(n),u=l.get(t)||[];return l.has(t)||l.set(t,u),u.push(e),o.observe(t),function(){u.splice(u.indexOf(e),1),u.length===0&&(l.delete(t),o.unobserve(t)),l.size===0&&(o.disconnect(),sRe.delete(i))}}function cle({threshold:t,delay:e,trackVisibility:n,rootMargin:r,root:i,triggerOnce:o,skip:l,initialInView:u,fallbackInView:d,onChange:p}={}){var m;const[g,h]=ee.useState(null),f=ee.useRef(p),b=ee.useRef(u),[y,v]=ee.useState({inView:!!u,entry:void 0});f.current=p,ee.useEffect(()=>{if(b.current===void 0&&(b.current=u),l||!g)return;let k;return k=j8r(g,(C,E)=>{const S=b.current;b.current=C,!(S===void 0&&!C)&&(v({inView:C,entry:E}),f.current&&f.current(C,E),E.isIntersecting&&o&&k&&(k(),k=void 0))},{root:i,rootMargin:r,threshold:t,trackVisibility:n,delay:e},d),()=>{k&&k()}},[Array.isArray(t)?t.toString():t,g,i,r,o,l,n,d,e]);const _=(m=y.entry)==null?void 0:m.target,w=ee.useRef(void 0);!g&&_&&!o&&!l&&w.current!==_&&(w.current=_,v({inView:!!u,entry:void 0}),b.current=u);const x=[h,y.inView,y.entry];return x.ref=x[0],x.inView=x[1],x.entry=x[2],x}const z8r=({type:t,item:e,position:n,onClose:r,onRename:i,onDelete:o,onMove:l,onDownload:u,onEdit:d,onPreview:p,onOpen:m,onAddToKnowledgeSet:g,onRemoveFromKnowledgeSet:h,onRestore:f,onBulkDelete:b,onBulkMove:y,isInKnowledgeSetView:v=!1,isTrashView:_=!1,selectedCount:w=1})=>{const{t:x}=Cn(),k=T.useRef(null),[C,E]=T.useState(n);return T.useEffect(()=>{const S=I=>{k.current&&!k.current.contains(I.target)&&r()};return document.addEventListener("pointerdown",S),()=>{document.removeEventListener("pointerdown",S)}},[r]),T.useEffect(()=>{if(k.current){const S=k.current.getBoundingClientRect();let{x:I,y:B}=n;I+S.width>window.innerWidth&&(I=window.innerWidth-S.width-10),B+S.height>window.innerHeight&&(B=window.innerHeight-S.height-10),E({x:I,y:B})}},[n]),_?Qi.createPortal(A.jsx("div",{ref:k,className:"fixed z-50 min-w-40 rounded-lg border border-neutral-200 bg-white p-1.5 shadow-lg dark:border-neutral-800 dark:bg-neutral-900",style:{top:C.y,left:C.x},children:A.jsx("div",{className:"flex flex-col gap-0.5",children:w>1?A.jsxs(A.Fragment,{children:[f&&A.jsxs("button",{onClick:()=>{f(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(X0t,{className:"h-4 w-4"}),x("knowledge.contextMenu.restoreSelected",{count:w})]}),A.jsx("div",{className:"my-1 h-px bg-neutral-200 dark:bg-neutral-800"}),b&&A.jsxs("button",{onClick:()=>{b(),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20",children:[A.jsx(Rl,{className:"h-4 w-4"}),x("knowledge.contextMenu.deleteSelected",{count:w})]})]}):A.jsxs(A.Fragment,{children:[f&&A.jsxs("button",{onClick:()=>{f(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(X0t,{className:"h-4 w-4"}),x("knowledge.contextMenu.restore")]}),A.jsx("div",{className:"my-1 h-px bg-neutral-200 dark:bg-neutral-800"}),o&&A.jsxs("button",{onClick:()=>{o(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20",children:[A.jsx(Rl,{className:"h-4 w-4"}),x("knowledge.contextMenu.deleteForever")]})]})})}),document.body):w>1?Qi.createPortal(A.jsx("div",{ref:k,className:"fixed z-50 min-w-40 rounded-lg border border-neutral-200 bg-white p-1.5 shadow-lg dark:border-neutral-800 dark:bg-neutral-900",style:{top:C.y,left:C.x},children:A.jsxs("div",{className:"flex flex-col gap-0.5",children:[y&&A.jsxs("button",{onClick:()=>{y(),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(tyt,{className:"h-4 w-4"}),x("knowledge.contextMenu.moveSelected",{count:w})]}),A.jsx("div",{className:"my-1 h-px bg-neutral-200 dark:bg-neutral-800"}),b&&A.jsxs("button",{onClick:()=>{b(),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20",children:[A.jsx(Rl,{className:"h-4 w-4"}),x("knowledge.contextMenu.deleteSelected",{count:w})]})]})}),document.body):Qi.createPortal(A.jsx("div",{ref:k,className:"fixed z-50 min-w-40 rounded-lg border border-neutral-200 bg-white p-1.5 shadow-lg dark:border-neutral-800 dark:bg-neutral-900",style:{top:C.y,left:C.x},children:A.jsxs("div",{className:"flex flex-col gap-0.5",children:[t==="folder"&&m&&A.jsxs("button",{onClick:()=>{m(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(m2e,{className:"h-4 w-4"}),x("knowledge.contextMenu.open")]}),t==="file"&&p&&A.jsxs("button",{onClick:()=>{p(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(NI,{className:"h-4 w-4"}),x("knowledge.contextMenu.preview")]}),t==="file"&&d&&A.jsxs("button",{onClick:()=>{d(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(Wir,{className:"h-4 w-4"}),x("knowledge.contextMenu.edit")]}),t==="file"&&u&&A.jsxs("button",{onClick:()=>{u(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(mR,{className:"h-4 w-4"}),x("knowledge.contextMenu.download")]}),t==="folder"&&m||t==="file"&&(p||d||u)?A.jsx("div",{className:"my-1 h-px bg-neutral-200 dark:bg-neutral-800"}):null,i&&A.jsxs("button",{onClick:()=>{i(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(wf,{className:"h-4 w-4"}),x("knowledge.contextMenu.rename")]}),l&&A.jsxs("button",{onClick:()=>{l(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(tyt,{className:"h-4 w-4"}),x("knowledge.contextMenu.moveTo")]}),g&&!v&&A.jsxs("button",{onClick:()=>{g(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(Dd,{className:"h-4 w-4"}),x("knowledge.contextMenu.addToKnowledgeSet")]}),h&&v&&A.jsxs("button",{onClick:()=>{h(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(qor,{className:"h-4 w-4"}),x("knowledge.contextMenu.removeFromKnowledgeSet")]}),A.jsx("div",{className:"my-1 h-px bg-neutral-200 dark:bg-neutral-800"}),o&&A.jsxs("button",{onClick:()=>{o(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20",children:[A.jsx(Rl,{className:"h-4 w-4"}),x("knowledge.contextMenu.delete")]})]})}),document.body)};var U8r=(t,e,n,r,i,o,l,u)=>{let d=document.documentElement,p=["light","dark"];function m(f){(Array.isArray(t)?t:[t]).forEach(b=>{let y=b==="class",v=y&&o?i.map(_=>o[_]||_):i;y?(d.classList.remove(...v),d.classList.add(o&&o[f]?o[f]:f)):d.setAttribute(b,f)}),g(f)}function g(f){u&&p.includes(f)&&(d.style.colorScheme=f)}function h(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)m(r);else try{let f=localStorage.getItem(e)||n,b=l&&f==="system"?h():f;m(b)}catch{}},q8r=ee.createContext(void 0),G8r={setTheme:t=>{},themes:[]},ule=()=>{var t;return(t=ee.useContext(q8r))!=null?t:G8r};ee.memo(({forcedTheme:t,storageKey:e,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:o,value:l,themes:u,nonce:d,scriptProps:p})=>{let m=JSON.stringify([n,e,o,t,u,l,r,i]).slice(1,-1);return ee.createElement("script",{...p,suppressHydrationWarning:!0,nonce:typeof window>"u"?d:"",dangerouslySetInnerHTML:{__html:`(${U8r.toString()})(${m})`}})});const H8r=1500;function W8r({isOpen:t,onClose:e,file:n,onLoadContent:r,onSaveContent:i,readonly:o=!1}){const{t:l}=Cn(),{resolvedTheme:u}=ule(),d=T.useRef(null),p=T.useRef(null),[m,g]=T.useState(!0),[h,f]=T.useState(null),[b,y]=T.useState("idle"),v=T.useRef(""),_=T.useRef(null),w=T.useRef(null),x=M8r(n.name);T.useEffect(()=>()=>{_.current&&clearTimeout(_.current),w.current&&clearTimeout(w.current)},[]),T.useEffect(()=>{if(!t)return;let E=!1;return g(!0),f(null),y("idle"),r(n.id).then(S=>S.text()).then(S=>{E||(v.current=S,g(!1),p.current&&p.current.setValue(S))}).catch(S=>{E||(f(S instanceof Error?S.message:l("knowledge.fileEditor.loadError")),g(!1))}),()=>{E=!0}},[t,n.id]);const k=T.useCallback(async()=>{if(!p.current||o)return;const E=p.current.getValue();if(E!==v.current){y("saving"),w.current&&(clearTimeout(w.current),w.current=null);try{await i(n.id,E),v.current=E,y("saved"),w.current=setTimeout(()=>y("idle"),2e3)}catch{y("error"),w.current=setTimeout(()=>y("idle"),3e3)}}},[n.id,i,o]),C=T.useCallback(()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{k()},H8r)},[k]);return T.useEffect(()=>{if(!t||m||h||!d.current||p.current)return;const E=u==="light"?"vs":"vs-dark",S=g1.editor.create(d.current,{value:v.current,language:x,theme:E,automaticLayout:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",readOnly:o,fontSize:13,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",padding:{top:12,bottom:12},bracketPairColorization:{enabled:!0},folding:!0,wordWrap:"on",tabSize:2});return p.current=S,S.onDidChangeModelContent(()=>{o||C()}),S.addCommand(g1.KeyMod.CtrlCmd|g1.KeyCode.KeyS,()=>{o||(_.current&&clearTimeout(_.current),k())}),()=>{S.dispose(),p.current=null}},[t,m,h,x,o]),T.useEffect(()=>{if(p.current){const E=u==="light"?"vs":"vs-dark";g1.editor.setTheme(E)}},[u]),T.useEffect(()=>{if(!t&&p.current){if(_.current){clearTimeout(_.current),_.current=null;const E=p.current.getValue();E!==v.current&&(i(n.id,E).catch(()=>{}),v.current=E)}p.current.dispose(),p.current=null}},[t]),A.jsxs(Gc,{isOpen:t,onClose:e,size:"full",children:[A.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-neutral-200/60 px-5 pb-3 pt-5 dark:border-neutral-800/60",children:[A.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[A.jsx("h2",{className:"truncate text-lg font-semibold text-neutral-900 dark:text-white",children:n.name}),A.jsx("span",{className:"shrink-0 rounded bg-neutral-100/80 px-1.5 py-0.5 text-xs text-neutral-500 dark:bg-white/[0.06] dark:text-neutral-400",children:x})]}),A.jsxs("div",{className:"flex items-center gap-2.5",children:[!o&&A.jsx(Y8r,{status:b}),A.jsx("button",{onClick:e,className:"rounded-lg bg-neutral-100/80 px-4 py-2 text-[13px] font-semibold text-neutral-700 hover:bg-neutral-200/80 dark:bg-white/[0.06] dark:text-neutral-300 dark:hover:bg-white/[0.1]",children:l("common.close")})]})]}),A.jsxs("div",{className:"flex-1 overflow-hidden",children:[m&&A.jsx("div",{className:"flex h-full items-center justify-center text-[13px] text-neutral-400",children:"Loading..."}),h&&A.jsx("div",{className:"flex h-full items-center justify-center text-[13px] text-red-500",children:h}),!m&&!h&&A.jsx("div",{ref:d,className:"h-full w-full"})]})]})}function Y8r({status:t}){const{t:e}=Cn();return t==="idle"?null:A.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-neutral-400 dark:text-neutral-500",children:[t==="saving"&&A.jsxs(A.Fragment,{children:[A.jsx("svg",{className:"h-3.5 w-3.5 animate-spin",viewBox:"0 0 16 16",fill:"none",children:A.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:"28",strokeDashoffset:"8"})}),e("knowledge.fileEditor.saving")]}),t==="saved"&&A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"}),e("knowledge.fileEditor.autoSaved")]}),t==="error"&&A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),e("knowledge.fileEditor.saveError")]})]})}const V8r=t=>t.split(".").pop()?.toLowerCase()||"",Kq=({filename:t,mimeType:e,className:n="h-6 w-6"})=>{const r=V8r(t),i=(o,l)=>A.jsx("div",{className:`flex items-center justify-center rounded-lg ${n}`,children:A.jsx(o,{className:`h-full w-full ${l}`})});if(e.startsWith("image/")||["jpg","jpeg","png","gif","webp","svg"].includes(r))return i(Eyt,"text-purple-500");if(e.startsWith("audio/")||["mp3","wav","ogg","m4a"].includes(r))return i(alr,"text-pink-500");if(e.startsWith("video/")||["mp4","mov","avi","mkv"].includes(r))return i(Xsr,"text-rose-500");switch(r){case"pdf":return i(wyt,"text-red-500");case"doc":case"docx":return i(Ksr,"text-blue-500");case"xls":case"xlsx":case"csv":return i(hlr,"text-green-500");case"ppt":case"pptx":return i(ulr,"text-orange-500");case"txt":case"md":case"json":return i(wyt,"text-neutral-500");case"zip":case"rar":case"7z":case"tar":case"gz":return i(zsr,"text-yellow-500");case"js":case"ts":case"jsx":case"tsx":case"py":case"html":case"css":return i(Wsr,"text-slate-600");default:return i(olr,"text-neutral-400")}},K8r=({item:t,depth:e,isSelected:n,isDragging:r=!1,isDropTarget:i=!1,indentationWidth:o=$0t,isEditing:l=!1,onEditConfirm:u,onEditCancel:d,onCollapse:p,onClick:m,onDoubleClick:g,onContextMenu:h,registerRef:f})=>{const{attributes:b,listeners:y,setNodeRef:v}=g2t({id:t.id,disabled:l}),{setNodeRef:_}=f2t({id:t.id}),w=T.useRef(null),x=T.useRef(null),k=T.useRef(!1),C=T.useCallback(()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null),x.current=null},[]);T.useEffect(()=>C,[C]);const E=T.useCallback(B=>{if(l)return;k.current=!1;const N=B.touches[0];x.current={x:N.clientX,y:N.clientY},C();const{clientX:L,clientY:M}=N;w.current=window.setTimeout(()=>{k.current=!0,iRe(),h?.({preventDefault:()=>{},stopPropagation:()=>{},clientX:L,clientY:M})},550)},[l,C,h]),S=T.useCallback(B=>{const N=x.current;if(!N)return;const L=B.touches[0];Math.hypot(L.clientX-N.x,L.clientY-N.y)>10&&C()},[C]),I=T.useCallback(()=>{C()},[C]);return A.jsx("div",{ref:B=>{v(B),_(B),f?.(t.id,B)},style:{opacity:r?.4:1},...l?{}:b,...l?{}:y,onTouchStart:E,onTouchMove:S,onTouchEnd:I,onTouchCancel:I,onMouseDown:B=>{B.stopPropagation()},onClick:B=>{if(k.current){k.current=!1;return}l||(m?.(B,t.id),t.type==="folder"&&p?.(t.id))},onDoubleClick:()=>{l||g?.(t.id)},onContextMenu:l?void 0:h,children:A.jsx(dRt,{item:t,depth:e,isSelected:n,isDropTarget:i,indentationWidth:o,isEditing:l,onEditConfirm:u,onEditCancel:d})})},Z8r=({item:t,childCount:e})=>A.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-lg border border-neutral-200 bg-white px-2.5 py-1.5 shadow-lg dark:border-neutral-700 dark:bg-neutral-900 max-w-64 pointer-events-none",children:[A.jsx("span",{className:"shrink-0 text-yellow-400 dark:text-yellow-500",children:t.type==="folder"?A.jsx(Bke,{className:"h-4 w-4"}):A.jsx(Kq,{filename:t.name,mimeType:t.file?.content_type||"",className:"h-4 w-4"})}),A.jsx("span",{className:"truncate text-xs font-medium text-neutral-800 dark:text-neutral-200",children:t.name}),e&&e>1?A.jsx("span",{className:"ml-0.5 flex shrink-0 items-center justify-center rounded-full bg-indigo-500 px-1.5 text-[10px] font-semibold text-white min-w-5 h-5",children:e}):null]}),dRt=T.forwardRef(({item:t,depth:e,isSelected:n,isDropTarget:r=!1,indentationWidth:i=$0t,isEditing:o=!1,onEditConfirm:l,onEditCancel:u},d)=>{const{t:p}=Cn(),m=T.useRef(null);T.useEffect(()=>{o&&m.current&&(m.current.focus(),m.current.select())},[o]);const g=t.updatedAt,h=t.type==="file"?_ae(t.fileSize??0):"--",f=y=>{if(y.stopPropagation(),y.key==="Enter"){const v=y.target.value.trim();v?l?.(v):u?.()}else y.key==="Escape"&&u?.()},b=y=>{const v=y.target.value.trim();v?l?.(v):u?.()};return A.jsxs("div",{ref:d,className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-sm select-none cursor-default group transition-colors ${r?"ring-2 ring-indigo-400 bg-indigo-50 dark:bg-indigo-950/30 dark:ring-indigo-500":n?"bg-indigo-600 text-white":"hover:bg-neutral-100 dark:hover:bg-neutral-800"}`,style:{paddingLeft:e*i+8},children:[t.type==="folder"?A.jsx("span",{className:`shrink-0 ${n?"text-white":"text-yellow-400 dark:text-yellow-500"}`,children:t.collapsed?A.jsx(Bke,{className:"h-4 w-4"}):A.jsx(Cst,{className:"h-4 w-4"})}):A.jsx("span",{className:"shrink-0 ml-0.5",children:A.jsx(Kq,{filename:t.name,mimeType:t.file?.content_type||"",className:"h-3.5 w-3.5"})}),o?A.jsx("input",{ref:m,defaultValue:p("knowledge.toolbar.newFolderPlaceholder"),onKeyDown:f,onBlur:b,onClick:y=>y.stopPropagation(),onMouseDown:y=>y.stopPropagation(),className:"min-w-0 flex-1 truncate text-xs bg-white dark:bg-neutral-800 border border-indigo-400 dark:border-indigo-500 rounded px-1 py-0 outline-none focus:ring-1 focus:ring-indigo-400 text-neutral-900 dark:text-neutral-100"}):A.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:t.name}),!o&&A.jsx("span",{className:`shrink-0 ${j0t} text-right text-[10px] tabular-nums ${n?"text-indigo-200":"text-neutral-400 dark:text-neutral-500"}`,children:Nar(g)}),!o&&A.jsx("span",{className:`shrink-0 ${z0t} text-right text-[10px] tabular-nums ${n?"text-indigo-200":"text-neutral-400 dark:text-neutral-500"}`,children:h})]})});dRt.displayName="TreeItemContent";const X8r={keyframes({transform:t}){return[{opacity:1,transform:Qx.Transform.toString(t.initial)},{opacity:0,transform:Qx.Transform.toString({...t.final,x:t.final.x+5,y:t.final.y+5})}]},easing:"ease-out",sideEffects({active:t}){t.node.animate([{opacity:0},{opacity:1}],{duration:WBe.duration,easing:WBe.easing})}},dle="__new_folder__",pRt=T.forwardRef(({treeItems:t,selectedIds:e,itemRefs:n,onItemClick:r,onFileDoubleClick:i,onContextMenu:o,onDropOnFolder:l,onFolderCreated:u,onRefresh:d,isTrashView:p},m)=>{const[g,h]=T.useState([]),[f,b]=T.useState("name"),[y,v]=T.useState("asc"),[_,w]=T.useState(null),[x,k]=T.useState(null),[C,E]=T.useState(null),S=T.useRef(null);T.useEffect(()=>{const Z=Dar(t,f,y);h(ae=>{if(ae.length===0)return Z;const oe=new Map,X=q=>{for(const Y of q)Y.type==="folder"&&Y.collapsed!==void 0&&oe.set(Y.id,Y.collapsed),Y.children.length>0&&X(Y.children)};X(ae);const W=q=>q.map(Y=>({...Y,collapsed:Y.type==="folder"?oe.get(Y.id)??!0:Y.collapsed,children:Y.children.length>0?W(Y.children):Y.children}));return W(Z)})},[t,f,y]);const I=T.useCallback(Z=>{Z===f?(v(ae=>ae==="asc"?"desc":"asc"),h(ae=>bae(ae,Z,y==="asc"?"desc":"asc"))):(b(Z),v("asc"),h(ae=>bae(ae,Z,"asc")))},[f,y]),B=T.useCallback(Z=>{h(ae=>q0t(ae,Z,"collapsed",oe=>!oe))},[]),N=T.useMemo(()=>U0t(g),[g]),L=_?N.find(({id:Z})=>Z===_):null,M=T.useMemo(()=>{if(!_)return new Set;const Z=String(_);return e.has(Z)&&e.size>1?e:new Set([Z])},[_,e]),R=OSt(MBe(UBe,{activationConstraint:p?{distance:1/0}:{distance:8}})),D=T.useCallback(Z=>{const ae=N.find(oe=>oe.id===Z);return ae?.folder?{item:ae.folder,type:"folder"}:ae?.file?{item:ae.file,type:"file"}:null},[N]),P=T.useCallback((Z,ae)=>{const oe=N.find(Y=>Y.id===ae);if(!oe)return;const W=N.find(Y=>Y.id===Z)?.parentId??null;let q;return oe.type==="folder"&&oe.id!==Z?!oe.collapsed&&oe.id===W?q=oe.parentId:q=oe.id:q=oe.parentId,q===W?void 0:q},[N]),O=T.useMemo(()=>{if(!(!_||!x||_===x))return P(String(_),String(x))},[_,x,P]),F=T.useCallback(({active:Z})=>{w(Z.id),document.body.style.setProperty("cursor","grabbing")},[]),Q=T.useCallback(({over:Z})=>{k(Z?.id??null)},[]),j=T.useCallback(({active:Z,over:ae})=>{const oe=new Set(M);if(w(null),k(null),document.body.style.setProperty("cursor",""),!ae||Z.id===ae.id)return;const X=String(Z.id),W=String(ae.id),q=N.find(ge=>ge.id===W);if(!q)return;const K=N.find(ge=>ge.id===X)?.parentId??null;let ne;if(q.type==="folder"&&q.id!==X?!q.collapsed&&q.id===K?ne=q.parentId:ne=q.id:ne=q.parentId,ne!==null&&oe.has(ne))return;const ue=[],se={};for(const ge of oe){const ve=yae(g,ge);!ve||(N.find(We=>We.id===ge)?.parentId??null)===ne||ve.type==="folder"&&ne!==null&&yae(ve.children,ne)||(ue.push({id:ge,item:ve}),se[ge]=ve.type)}if(ue.length===0)return;let ce=g;for(const{id:ge}of ue)ce=vae(ce,ge);for(const{item:ge}of ue)ce=H0t(ce,{...ge,children:ge.children},ne,f,y);h(ce),l(ue.map(({id:ge})=>ge),ne,se),d&&setTimeout(()=>d(),500)},[g,N,M,f,y,l,d]),$=T.useCallback(()=>{w(null),k(null),document.body.style.setProperty("cursor","")},[]),z=T.useCallback((Z,ae)=>{ae?n.current.set(Z,ae):n.current.delete(Z)},[n]),U=T.useCallback(()=>{E(null),h(Z=>vae(Z,dle))},[]),H=T.useCallback(async Z=>{const ae=S.current;U(),u&&await u(Z,ae)},[u,U]),te=T.useCallback(()=>{U()},[U]);return T.useImperativeHandle(m,()=>({createFolder:Z=>{p||(h(ae=>{const oe=vae(ae,dle),X={id:dle,name:"",type:"folder",children:[],collapsed:!0,isEditing:!0};if(Z===null)return[X,...oe];const W=q=>q.map(Y=>Y.id===Z?{...Y,collapsed:!1,children:[X,...Y.children]}:Y.children.length>0?{...Y,children:W(Y.children)}:Y);return W(oe)}),S.current=Z,E(dle))}}),[p]),t.length===0&&g.length===0&&!C?null:A.jsxs("div",{className:"flex h-full flex-col",children:[A.jsxs("div",{className:"flex items-center border-b border-neutral-200 dark:border-neutral-700 text-[11px] font-medium text-neutral-500 dark:text-neutral-400 shrink-0 select-none",children:[A.jsxs("button",{onClick:()=>I("name"),className:`flex flex-1 items-center gap-0.5 px-3 py-1.5 text-left transition-colors hover:text-neutral-700 dark:hover:text-neutral-300 ${f==="name"?"text-neutral-700 dark:text-neutral-300":""}`,children:["Name",f==="name"&&(y==="asc"?A.jsx(Ste,{className:"h-3 w-3"}):A.jsx(mf,{className:"h-3 w-3"}))]}),A.jsxs("button",{onClick:()=>I("modified"),className:`flex ${j0t} shrink-0 items-center gap-0.5 px-2 py-1.5 text-left transition-colors hover:text-neutral-700 dark:hover:text-neutral-300 ${f==="modified"?"text-neutral-700 dark:text-neutral-300":""}`,children:["Date Modified",f==="modified"&&(y==="asc"?A.jsx(Ste,{className:"h-3 w-3"}):A.jsx(mf,{className:"h-3 w-3"}))]}),A.jsxs("button",{onClick:()=>I("size"),className:`flex ${z0t} shrink-0 items-center justify-end gap-0.5 px-2 py-1.5 text-right transition-colors hover:text-neutral-700 dark:hover:text-neutral-300 ${f==="size"?"text-neutral-700 dark:text-neutral-300":""}`,children:["Size",f==="size"&&(y==="asc"?A.jsx(Ste,{className:"h-3 w-3"}):A.jsx(mf,{className:"h-3 w-3"}))]})]}),A.jsx("div",{className:`flex-1 p-2 rounded-md transition-colors ${_&&O===null?"bg-indigo-50/50 dark:bg-indigo-950/20 ring-2 ring-inset ring-indigo-300 dark:ring-indigo-600":""}`,children:A.jsxs(Toe,{sensors:R,onDragStart:F,onDragOver:Q,onDragEnd:j,onDragCancel:$,children:[A.jsx(jr,{initial:!1,children:N.map(Z=>A.jsx(Ct.div,{layout:!_,initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{layout:{duration:.2,ease:"easeInOut"},opacity:{duration:.15},height:{duration:.2}},style:{overflow:"hidden"},children:A.jsx(K8r,{item:Z,depth:Z.depth,isSelected:e.has(Z.id),isDragging:M.has(Z.id),isDropTarget:O===Z.id,isEditing:C===Z.id,onEditConfirm:H,onEditCancel:te,onCollapse:Z.type==="folder"?B:void 0,onClick:r,onDoubleClick:ae=>{const oe=D(ae);oe?.type==="file"?i(oe.item):oe?.type==="folder"&&B(ae)},onContextMenu:ae=>{ae.preventDefault(),ae.stopPropagation();const oe=D(Z.id);oe&&o(ae,oe.item,oe.type)},registerRef:z})},Z.id))}),Qi.createPortal(A.jsx(YBe,{dropAnimation:X8r,children:_&&L?A.jsx(Z8r,{item:L,childCount:M.size>1?M.size:G0t(g,String(_))+1}):null}),document.body)]})})]})});pRt.displayName="SortableTree";const J8r=T.memo(pRt),AC="application/x-xyzen-drag",mRt=T.forwardRef(({treeItems:t,selectedIds:e,itemRefs:n,onItemClick:r,onFileDoubleClick:i,onContextMenu:o,onDropOnFolder:l,onFolderCreated:u,onRefresh:d,isTrashView:p},m)=>A.jsx(J8r,{ref:m,treeItems:t,selectedIds:e,itemRefs:n,onItemClick:r,onFileDoubleClick:i,onContextMenu:o,onDropOnFolder:l,onFolderCreated:u,onRefresh:d,isTrashView:p}));mRt.displayName="FileTreeView";const e6r=T.memo(mRt),t6r=({fileId:t,alt:e,className:n=""})=>{const[r,i]=T.useState(null),[o,l]=T.useState(!1),[u,d]=T.useState(!1),[p,m]=T.useState(!1),g=T.useRef(null);return T.useEffect(()=>{const h=g.current;if(!h)return;const f=new IntersectionObserver(b=>{b.forEach(y=>{y.isIntersecting&&(d(!0),f.unobserve(y.target))})},{root:null,rootMargin:"100px",threshold:.01});return f.observe(h),()=>{f.disconnect()}},[]),T.useEffect(()=>{if(!u||!t||p||r)return;let h=!0;const f=new AbortController;return(async()=>{try{const v=await(await ys.downloadRaw(t,{signal:f.signal})).blob(),_=URL.createObjectURL(v);h?i(_):URL.revokeObjectURL(_)}catch(y){h&&y.name!=="AbortError"&&(console.error("Failed to load thumbnail:",y),m(!0))}})(),()=>{h=!1,f.abort()}},[u,t,p,r]),T.useEffect(()=>()=>{r&&URL.revokeObjectURL(r)},[r]),A.jsxs("div",{ref:g,className:`relative overflow-hidden bg-neutral-100 dark:bg-neutral-800 ${n}`,children:[A.jsx("div",{className:`absolute inset-0 flex items-center justify-center transition-opacity duration-300 ${o&&!p?"opacity-0":"opacity-100"}`,children:A.jsx(Eyt,{className:"h-8 w-8 text-purple-400"})}),r&&!p&&A.jsx("img",{src:r,alt:e,onLoad:()=>l(!0),onError:()=>m(!0),className:`absolute inset-0 h-full w-full object-cover transition-opacity duration-300 ${o?"opacity-100":"opacity-0"}`})]})},n6r=({isOpen:t,onClose:e,onMove:n,title:r,itemId:i,itemType:o})=>{const{t:l}=Cn(),[u,d]=T.useState([]),[p,m]=T.useState(null),[g,h]=T.useState([]),[f,b]=T.useState(!1),[y,v]=T.useState(null),_=T.useCallback(async k=>{b(!0);try{const C=await pf.listFolders(k),E=o==="folder"?C.filter(S=>S.id!==i):C;if(d(E),k){const S=await pf.getFolderPath(k);h(S)}else h([])}catch(C){console.error("Failed to load folders",C)}finally{b(!1)}},[o,i]);T.useEffect(()=>{t&&(m(null),v(null),_(null))},[t,_]);const w=k=>{m(k),v(k),_(k)},x=async()=>{await n(y),e()};return t?A.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:A.jsxs("div",{className:"w-96 rounded-sm bg-white p-4 shadow-xl dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800",children:[A.jsx("h3",{className:"mb-4 text-sm font-semibold text-neutral-900 dark:text-white",children:r}),A.jsxs("div",{className:"mb-2 flex items-center gap-1 text-xs text-neutral-500 overflow-x-auto whitespace-nowrap pb-2",children:[A.jsx("button",{onClick:()=>w(null),className:`hover:text-indigo-600 ${p?"":"font-bold text-neutral-900 dark:text-white"}`,children:l("knowledge.moveModal.home")}),g.map(k=>A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx(fg,{className:"h-3 w-3"}),A.jsx("button",{onClick:()=>w(k.id),className:`hover:text-indigo-600 ${p===k.id?"font-bold text-neutral-900 dark:text-white":""}`,children:k.name})]},k.id))]}),A.jsx("div",{className:"mb-4 h-60 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50 dark:border-neutral-800 dark:bg-neutral-950",children:f?A.jsx("div",{className:"flex h-full items-center justify-center text-xs text-neutral-400",children:l("common.loading")}):u.length===0?A.jsx("div",{className:"flex h-full items-center justify-center text-xs text-neutral-400",children:l("knowledge.moveModal.noSubfolders")}):A.jsx("div",{className:"divide-y divide-neutral-200 dark:divide-neutral-800",children:u.map(k=>A.jsxs("div",{onClick:()=>v(k.id),onDoubleClick:()=>w(k.id),className:`flex cursor-pointer items-center justify-between px-3 py-2 text-sm ${y===k.id?"bg-indigo-100 dark:bg-indigo-900/30 text-indigo-900 dark:text-indigo-100":"hover:bg-neutral-100 dark:hover:bg-neutral-900 text-neutral-700 dark:text-neutral-300"}`,children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx(b2e,{className:"h-4 w-4 text-yellow-500"}),A.jsx("span",{className:"truncate max-w-45",children:k.name})]}),A.jsx("button",{onClick:C=>{C.stopPropagation(),w(k.id)},className:"text-neutral-400 hover:text-neutral-600",children:A.jsx(fg,{className:"h-4 w-4"})})]},k.id))})}),A.jsxs("div",{className:"flex justify-end gap-2 text-xs",children:[A.jsx("button",{onClick:e,className:"rounded-md px-3 py-2 text-neutral-600 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800",children:l("common.cancel")}),A.jsx("button",{onClick:x,className:"rounded-md bg-indigo-600 px-3 py-2 text-white hover:bg-indigo-500",children:l("knowledge.moveModal.moveHere")})]})]})}):null},r6r=t=>{if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/Math.pow(e,r)).toFixed(1))} ${n[r]}`},a6r=(t,e)=>{const n=e.split(".").pop()?.toLowerCase()||"";return t.startsWith("image/")||["jpg","jpeg","png","gif","webp","svg","bmp","ico"].includes(n)};function lRe(t,e){const n=[],r=[e];for(;r.length>0;){const i=r.shift();for(const o of t)o.parent_id===i&&(n.push(o.id),o.is_dir&&r.push(o.id))}return n}const Zq=T.memo(T.forwardRef(({filter:t,viewMode:e,refreshTrigger:n,onRefresh:r,onFileCountChange:i,onStatsUpdate:o,onLoadingChange:l,currentFolderId:u,onFolderChange:d,currentKnowledgeSetId:p,onCreateFolder:m,onUpload:g,treeItems:h=[],treeLoading:f=!1,onRefreshTree:b,removeTreeItems:y,renameTreeItem:v,readonly:_,onDeleteItem:w,onRenameItem:x,onMoveItem:k,onDownloadFile:C,onEditSave:E,onCreateSkillFolder:S},I)=>{const{t:B}=Cn(),[N,L]=T.useState([]),[M,R]=T.useState([]),[D,P]=T.useState(!1),O=t==="all"||t==="knowledge"||t==="trash"||t==="skill"||t==="images"||t==="documents",F=t==="skill",Q=T.useMemo(()=>{if(t!=="images"&&t!=="documents")return h;const Qt=t==="images"?new Set(["jpg","jpeg","png","gif","bmp","webp","svg","ico"]):new Set(["pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","md"]),wr=new Set;for(const ci of h)if(!ci.is_dir){const Eo=ci.name.split(".").pop()?.toLowerCase()||"";Qt.has(Eo)&&wr.add(ci.id)}const Ht=new Set(wr),Qr=new Map(h.map(ci=>[ci.id,ci]));for(const ci of wr){let Eo=Qr.get(ci);for(;Eo?.parent_id&&!Ht.has(Eo.parent_id);)Ht.add(Eo.parent_id),Eo=Qr.get(Eo.parent_id)}return h.filter(ci=>Ht.has(ci.id))},[t,h]),j=O?f:D;T.useEffect(()=>{l?.(j)},[j,l]);const $=T.useRef([]),z=T.useRef([]);T.useEffect(()=>{$.current=N},[N]),T.useEffect(()=>{z.current=M},[M]);const U=100,[H,te]=T.useState(!0),[Z,ae]=T.useState(!1),oe=T.useRef(0),X=T.useRef(!1),{ref:W,inView:q}=cle({threshold:0,rootMargin:"200px"}),Y=T.useRef(q);T.useEffect(()=>{Y.current=q},[q]);const[K,ne]=T.useState(null),[ue,se]=T.useState(!1),[ce,ge]=T.useState(null),[ve,Be]=T.useState(!1),[We,Le]=T.useState(new Set),[rt,mt]=T.useState(null),yt=T.useRef(null),xt=T.useRef(null),$e=T.useRef(new Map),ot=T.useRef(!1),Ce=T.useRef(null),et=5,Rt=T.useCallback((Ft,_n)=>{if(Ft.stopPropagation(),ma.current){ma.current=!1;return}if(ot.current){ot.current=!1;return}Ft.ctrlKey||Ft.metaKey?Le(Qt=>{const wr=new Set(Qt);return wr.has(_n)?wr.delete(_n):wr.add(_n),wr}):Le(new Set([_n]))},[]),pe=T.useMemo(()=>new Set(M.map(Ft=>Ft.id)),[M]),Ze=T.useRef(()=>{}),ie=T.useCallback(async(Ft,_n,Qt)=>{try{await Promise.all(Ft.map(wr=>(Qt?Qt[wr]==="folder":pe.has(wr))?F&&k?k(wr,!0,_n):pf.updateFolder(wr,{parent_id:_n}):F&&k?k(wr,!1,_n):ys.updateFile(wr,{parent_id:_n}))),Le(new Set),O&&b?b():Ze.current()}catch(wr){console.error("Drop move failed",wr)}},[pe,O,F,k,b]),Re=T.useCallback((Ft,_n)=>{const Qt=We.has(_n)?[...We]:[_n],wr={};for(const Qr of Qt)wr[Qr]=pe.has(Qr)?"folder":"file";const Ht={ids:Qt,types:wr};window.__xyzenDragContext=Ht,Ft.dataTransfer.setData(AC,JSON.stringify(Ht)),Ft.dataTransfer.effectAllowed="move"},[We,pe]),be=T.useCallback((Ft,_n)=>{!Ft.dataTransfer.types.includes(AC)||window.__xyzenDragContext?.ids?.includes(_n)||(Ft.preventDefault(),Ft.stopPropagation(),Ft.dataTransfer.dropEffect="move")},[]),Oe=T.useCallback((Ft,_n)=>{Ft.preventDefault(),Ft.stopPropagation();try{const Qt=JSON.parse(Ft.dataTransfer.getData(AC));Qt?.ids?.length>0&&ie(Qt.ids,_n)}catch{}},[ie]),[we,st]=T.useState(null),vt=T.useCallback(Ft=>{if(Ft.button!==0)return;const _n=yt.current;if(!_n)return;const Qt=_n.getBoundingClientRect(),wr=Ft.clientX-Qt.left+_n.scrollLeft,Ht=Ft.clientY-Qt.top+_n.scrollTop;Ce.current={startX:wr,startY:Ht,clientX:Ft.clientX,clientY:Ft.clientY,ctrlKey:Ft.ctrlKey,metaKey:Ft.metaKey}},[]),de=T.useCallback(Ft=>{const _n=yt.current;if(!_n)return;const Qt=_n.getBoundingClientRect(),wr=Ft.clientX-Qt.left+_n.scrollLeft,Ht=Ft.clientY-Qt.top+_n.scrollTop;if(Ce.current&&!rt){const Ta=Ft.clientX-Ce.current.clientX,Ho=Ft.clientY-Ce.current.clientY;Math.sqrt(Ta*Ta+Ho*Ho)>=et&&(mt({startX:Ce.current.startX,startY:Ce.current.startY,currentX:wr,currentY:Ht}),!Ce.current.ctrlKey&&!Ce.current.metaKey&&Le(new Set));return}if(!rt)return;mt(Ta=>Ta?{...Ta,currentX:wr,currentY:Ht}:null);const Qr=Math.min(rt.startX,wr),ci=Math.max(rt.startX,wr),Eo=Math.min(rt.startY,Ht),bl=Math.max(rt.startY,Ht),qs=new Set;$e.current.forEach((Ta,Ho)=>{const No=Ta.getBoundingClientRect(),hc=_n.getBoundingClientRect(),Zo=No.left-hc.left+_n.scrollLeft,Ob=No.right-hc.left+_n.scrollLeft,Oo=No.top-hc.top+_n.scrollTop,va=No.bottom-hc.top+_n.scrollTop;Zo<ci&&Ob>Qr&&Oo<bl&&va>Eo&&qs.add(Ho)}),Le(qs)},[rt]),nt=T.useCallback(()=>{rt&&(ot.current=!0),mt(null),Ce.current=null},[rt]),[ct,Ne]=T.useState(null),[fe,xe]=T.useState(null);T.useEffect(()=>{if(!fe)return;const Ft=()=>xe(null),_n=setTimeout(()=>document.addEventListener("mousedown",Ft),0);return()=>{clearTimeout(_n),document.removeEventListener("mousedown",Ft)}},[fe]);const[pt,tt]=T.useState(null),[Vt,an]=T.useState(null),[on,Xt]=T.useState([]),[Lt,Dt]=T.useState(null),[at,gn]=T.useState(null),[xn,Rn]=T.useState(null);T.useImperativeHandle(I,()=>({moveItems:(Ft,_n)=>{ie(Ft,_n)},createFolder:Ft=>{xt.current?.createFolder(Ft)},emptyTrash:async()=>{const Ft=h.length;Ft!==0&&Dt({isOpen:!0,title:B("knowledge.fileList.emptyTrash.title"),message:B("knowledge.fileList.emptyTrash.message",{count:Ft}),confirmLabel:B("knowledge.fileList.emptyTrash.confirm"),destructive:!0,onConfirm:async()=>{y&&y(h.map(_n=>_n.id)),L([]),R([]),i&&i(0);try{await ys.emptyTrash(),r&&r(),b&&b()}catch(_n){console.error("Failed to empty trash",_n),b&&b(),alert(B("knowledge.fileList.emptyTrash.failed"))}}})}}),[ie,i,r,b,y,B,h]),T.useEffect(()=>{(async()=>{try{const _n=await Sh.listKnowledgeSets(!1);Xt(_n)}catch(_n){console.error("Failed to load knowledge sets",_n)}})()},[n]);const Mt=T.useCallback(async(Ft=!1)=>{if(!O){if(Ft){if(X.current)return;ae(!0)}else $.current.length===0&&z.current.length===0&&P(!0),X.current=!0,oe.current=0,te(!0);try{if(t==="home"){Ft||R([]);const Ht=await ys.listFiles({limit:U,offset:oe.current,is_dir:!1}),Qr=Ht.filter(ci=>!ci.is_deleted);Ft?L(ci=>{const Eo=[...ci,...Qr];return i&&setTimeout(()=>i(Eo.length),0),Eo}):(L(Qr),i&&i(Qr.length)),oe.current+=Ht.length,te(Ht.length===U);return}const _n={include_deleted:!1,limit:U,offset:oe.current};["images","audio","documents"].includes(t)&&(_n.category=t);const Qt=await ys.listFiles(_n),wr=Qt.filter(Ht=>!Ht.is_deleted);Ft||R([]),Ft?L(Ht=>{const Qr=[...Ht,...wr];return i&&setTimeout(()=>i(Qr.length),0),Qr}):(L(wr),i&&i(wr.length)),oe.current+=Qt.length,te(Qt.length===U)}catch(_n){console.error("Failed to load files",_n)}finally{P(!1),ae(!1),X.current=!1}}},[t,u]);Ze.current=Mt;const Ln=T.useCallback(async(Ft,_n)=>{try{if(F&&S)await S(Ft,_n);else{const Qt=await pf.createFolder({name:Ft,parent_id:_n});t==="knowledge"&&p&&await Sh.linkFileToKnowledgeSet(p,Qt.id)}b&&b()}catch(Qt){console.error("Failed to create folder",Qt)}},[t,F,p,b,S]),En=T.useCallback(()=>{!Z&&H&&Mt(!0)},[Z,H,Mt]);T.useEffect(()=>{Mt()},[Mt,n]),T.useEffect(()=>{q&&H&&!Z&&!D&&En()},[q,H,Z,D,En]);const or=T.useRef(Z);T.useEffect(()=>{const Ft=or.current;if(or.current=Z,Ft&&!Z&&Y.current&&H&&!D){const _n=setTimeout(()=>{En()},50);return()=>clearTimeout(_n)}},[Z,H,D,En]);const gt=(Ft,_n,Qt)=>{Ft.preventDefault(),Ft.stopPropagation(),xe(null),Ne({type:Qt,item:_n,position:{x:Ft.clientX,y:Ft.clientY}}),We.has(_n.id)||Le(new Set([_n.id]))},pr=T.useRef(null),$r=T.useRef(null),ma=T.useRef(!1),Vn=T.useCallback(()=>{pr.current!==null&&(window.clearTimeout(pr.current),pr.current=null),$r.current=null},[]),un=T.useCallback((Ft,_n)=>({onPointerDown:ci=>{ci.pointerType==="touch"&&(ma.current=!1,$r.current={x:ci.clientX,y:ci.clientY},Vn(),pr.current=window.setTimeout(()=>{ma.current=!0,iRe(),Ne({type:_n,item:Ft,position:{x:ci.clientX,y:ci.clientY}}),Le(Eo=>Eo.has(Ft.id)?Eo:new Set([Ft.id]))},550))},onPointerMove:ci=>{if(ci.pointerType!=="touch")return;const Eo=$r.current;if(!Eo)return;const bl=ci.clientX-Eo.x,qs=ci.clientY-Eo.y;Math.hypot(bl,qs)>10&&Vn()},onPointerUp:()=>{Vn()},onPointerCancel:()=>{Vn()}}),[Vn]),ln=async(Ft,_n)=>{gn({isOpen:!0,item:Ft,type:_n})},Gn=async Ft=>{if(!at)return;const{item:_n,type:Qt}=at;if(Qt==="folder"){if(M.find(Ht=>Ht.name===Ft&&Ht.id!==_n.id)){Rn({isOpen:!0,title:B("knowledge.fileList.notifications.errorTitle"),message:B("knowledge.fileList.rename.duplicateName"),type:"warning"});return}}else if(N.find(Ht=>Ht.original_filename===Ft&&Ht.id!==_n.id)){Rn({isOpen:!0,title:B("knowledge.fileList.notifications.errorTitle"),message:B("knowledge.fileList.rename.duplicateName"),type:"warning"});return}try{v&&O&&v(_n.id,Ft),Qt==="folder"?F&&x?await x(_n.id,!0,Ft):await pf.updateFolder(_n.id,{name:Ft}):F&&x?await x(_n.id,!1,Ft):await ys.updateFile(_n.id,{original_filename:Ft}),O&&b?b():Mt()}catch(wr){console.error("Rename failed",wr),b&&b(),alert(B("knowledge.fileList.rename.failed"))}},Gr=async Ft=>{if(!pt)return;const{item:_n,type:Qt}=pt;try{Qt==="folder"?F&&k?await k(_n.id,!0,Ft):await pf.updateFolder(_n.id,{parent_id:Ft}):F&&k?await k(_n.id,!1,Ft):await ys.updateFile(_n.id,{parent_id:Ft}),O&&b?b():Mt(),tt(null)}catch(wr){console.error("Move failed",wr),alert(B("knowledge.fileList.move.failed"))}},Za=async(Ft,_n)=>{if(We.size>1&&We.has(Ft.id)){const Qr=[],ci=[];We.forEach(Ta=>{if(N.some(Ho=>Ho.id===Ta))Qr.push(Ta);else if(M.some(Ho=>Ho.id===Ta))ci.push(Ta);else{const Ho=h.find(No=>No.id===Ta);Ho&&(Ho.is_dir?ci.push(Ta):Qr.push(Ta))}});const Eo=Qr.length+ci.length,bl=t==="trash";let qs=0;for(const Ta of Qr){const Ho=N.find(No=>No.id===Ta);if(Ho)qs+=Ho.file_size;else{const No=h.find(hc=>hc.id===Ta);No&&(qs+=No.file_size)}}Dt({isOpen:!0,title:B(bl?"knowledge.fileList.actions.deleteForever":"knowledge.fileList.actions.delete"),message:B("knowledge.fileList.bulkDelete.message",{count:Eo}),confirmLabel:B("knowledge.fileList.actions.delete"),destructive:!0,onConfirm:async()=>{try{if(y&&O){const Ta=[...Qr,...ci];for(const Ho of ci)Ta.push(...lRe(h,Ho));y(Ta)}Qr.length>0&&await Promise.all(Qr.map(Ta=>F&&w?w(Ta,!1):ys.deleteFile(Ta,bl))),ci.length>0&&await Promise.all(ci.map(Ta=>F&&w?w(Ta,!0):pf.deleteFolder(Ta,bl))),bl&&o&&o(qs,Qr.length),Le(new Set),O&&b?b():Mt()}catch(Ta){console.error("Bulk delete failed",Ta),b&&b(),alert(B("knowledge.fileList.actions.deleteFailed"))}}});return}const wr=B(_n==="folder"?"knowledge.fileList.itemTypes.folder":"knowledge.fileList.itemTypes.file"),Ht=_n==="file"?Ft.file_size:0;Dt({isOpen:!0,title:B("knowledge.fileList.deleteItem.title",{itemType:wr}),message:B("knowledge.fileList.deleteItem.message",{itemType:wr}),confirmLabel:B("knowledge.fileList.actions.delete"),destructive:!0,onConfirm:async()=>{try{const Qr=t==="trash";if(y&&O){const ci=_n==="folder"?lRe(h,Ft.id):[];y([Ft.id,...ci])}_n==="folder"?F&&w?await w(Ft.id,!0):await pf.deleteFolder(Ft.id,Qr):F&&w?await w(Ft.id,!1):await ys.deleteFile(Ft.id,Qr),Qr&&_n==="file"&&o&&o(Ht,1),Le(new Set),O&&b?b():Mt()}catch(Qr){console.error("Delete failed",Qr),b&&b(),alert(B("knowledge.fileList.actions.deleteFailed"))}}})},to=async(Ft,_n)=>{try{if(y&&t==="trash"){const Qt=lRe(h,Ft);y([Ft,...Qt])}await ys.restoreFile(Ft),r&&r(),b&&b()}catch(Qt){console.error("Restore failed",Qt),b&&b(),alert(B("knowledge.fileList.actions.restoreFailed"))}},Ri=async(Ft,_n)=>{try{const wr=await(F&&C?await C(Ft):await ys.downloadRaw(Ft)).blob(),Ht=URL.createObjectURL(wr),Qr=document.createElement("a");Qr.href=Ht,Qr.download=_n,document.body.appendChild(Qr),Qr.click(),document.body.removeChild(Qr),URL.revokeObjectURL(Ht)}catch(Qt){console.error("Download failed",Qt),alert(B("knowledge.fileList.actions.downloadFailed"))}},Po=Ft=>{ne({id:Ft.id,name:Ft.original_filename,type:Ft.content_type||"",size:Ft.file_size}),se(!0)},Al=Ft=>{ge({id:Ft.id,name:Ft.original_filename,contentType:Ft.content_type||"",size:Ft.file_size}),Be(!0)},yn=Ft=>{cRt(Ft.original_filename,Ft.content_type)?Al(Ft):Po(Ft)},Fn=Ft=>{d&&d(Ft)},Qn=Ft=>{an({isOpen:!0,item:Ft})},An=async Ft=>{if(!p)return;const _n="original_filename"in Ft?Ft.original_filename:Ft.name;Dt({isOpen:!0,title:B("knowledge.fileList.knowledgeSet.remove.title"),message:B("knowledge.fileList.knowledgeSet.remove.message",{name:_n}),confirmLabel:B("knowledge.fileList.knowledgeSet.remove.confirm"),destructive:!0,onConfirm:async()=>{try{await Sh.unlinkFileFromKnowledgeSet(p,Ft.id),b&&b()}catch(Qt){console.error("Failed to remove file from knowledge set",Qt),alert(B("knowledge.fileList.knowledgeSet.remove.failed"))}}})},ar=async Ft=>{if(Vt)try{await Sh.linkFileToKnowledgeSet(Ft,Vt.item.id),an(null),r&&r(),Rn({isOpen:!0,title:B("knowledge.fileList.notifications.successTitle"),message:B("knowledge.fileList.knowledgeSet.added"),type:"success"})}catch(_n){console.error("Failed to link file to knowledge set",_n);const Qt=_n instanceof Error?_n.message:String(_n);Qt.toLowerCase().includes("already")||Qt.toLowerCase().includes("duplicate")?Rn({isOpen:!0,title:B("knowledge.fileList.notifications.noticeTitle"),message:B("knowledge.fileList.knowledgeSet.alreadyInSet"),type:"warning"}):Rn({isOpen:!0,title:B("knowledge.fileList.notifications.errorTitle"),message:B("knowledge.fileList.knowledgeSet.addFailed"),type:"error"})}};if(O){if(f&&Q.length===0)return null;if(!f&&Q.length===0)return A.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-sm text-neutral-400",children:[A.jsx(DI,{className:"h-8 w-8 opacity-50"}),A.jsx("span",{children:B(t==="trash"?"knowledge.fileList.empty.trash":"knowledge.fileList.empty.noItems")})]})}else{if(D&&N.length===0&&M.length===0)return null;if(!D&&N.length===0&&M.length===0)return A.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-sm text-neutral-400",children:[A.jsx(DI,{className:"h-8 w-8 opacity-50"}),A.jsx("span",{children:B("knowledge.fileList.empty.noItems")})]})}return A.jsxs("div",{ref:yt,className:"h-full w-full relative select-none",onClick:()=>{if(ma.current){ma.current=!1;return}if(ot.current){ot.current=!1;return}Le(new Set),xe(null)},onContextMenu:Ft=>{Ft.preventDefault(),Ne(null),xe({x:Ft.clientX,y:Ft.clientY})},onMouseDown:vt,onMouseMove:de,onMouseUp:nt,onMouseLeave:nt,children:[rt&&A.jsx("div",{className:"absolute border-2 border-indigo-500 bg-indigo-500/10 pointer-events-none z-40",style:{left:Math.min(rt.startX,rt.currentX),top:Math.min(rt.startY,rt.currentY),width:Math.abs(rt.currentX-rt.startX),height:Math.abs(rt.currentY-rt.startY)}}),O?A.jsx(e6r,{ref:xt,treeItems:Q,selectedIds:We,itemRefs:$e,onItemClick:Rt,onFileDoubleClick:yn,onContextMenu:gt,onDropOnFolder:ie,onFolderCreated:Ln,onRefresh:b,isTrashView:t==="trash"}):e==="list"?A.jsxs("div",{className:"min-w-full inline-block align-middle",children:[A.jsx("div",{className:"border-b border-neutral-200 dark:border-neutral-800",children:A.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-2 text-xs font-medium uppercase text-neutral-500 dark:text-neutral-400",children:[A.jsx("div",{className:"col-span-8 md:col-span-6",children:B("knowledge.fileList.columns.name")}),A.jsx("div",{className:"hidden md:block md:col-span-2",children:B("knowledge.fileList.columns.size")}),A.jsx("div",{className:"hidden md:block md:col-span-3",children:B("knowledge.fileList.columns.dateModified")}),A.jsx("div",{className:"col-span-4 md:col-span-1"})]})}),A.jsxs("div",{className:"divide-y divide-neutral-100 dark:divide-neutral-800/50",children:[M.map(Ft=>A.jsxs("div",{ref:_n=>{_n?$e.current.set(Ft.id,_n):$e.current.delete(Ft.id)},draggable:!0,onDragStart:_n=>Re(_n,Ft.id),onDragEnd:()=>{window.__xyzenDragContext=null},onDragOver:_n=>{be(_n,Ft.id),_n.defaultPrevented&&st(Ft.id)},onDragLeave:()=>st(_n=>_n===Ft.id?null:_n),onDrop:_n=>{st(null),Oe(_n,Ft.id)},onClick:_n=>Rt(_n,Ft.id),onDoubleClick:()=>Fn(Ft.id),onContextMenu:_n=>gt(_n,Ft,"folder"),...un(Ft,"folder"),className:`group grid grid-cols-12 gap-4 px-4 py-2 text-sm items-center cursor-default ${we===Ft.id?"ring-2 ring-indigo-500 bg-indigo-50 dark:bg-indigo-900/30 rounded":We.has(Ft.id)?"bg-indigo-600 text-white":"text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800"}`,children:[A.jsxs("div",{className:"col-span-8 md:col-span-6 flex items-center gap-3 overflow-hidden",children:[A.jsx("div",{className:"shrink-0",children:A.jsx(b2e,{className:"h-5 w-5 text-yellow-500"})}),A.jsx("span",{className:"truncate font-medium",children:Ft.name})]}),A.jsx("div",{className:"hidden md:block md:col-span-2 text-xs opacity-50",children:"-"}),A.jsx("div",{className:"hidden md:block md:col-span-3 text-xs opacity-50",children:qx(new Date(Ft.created_at),"MMM d, yyyy HH:mm")}),A.jsx("div",{className:"col-span-4 md:col-span-1 flex justify-end",children:A.jsx("div",{className:`flex gap-2 ${We.has(Ft.id)?"text-white":"text-neutral-400 opacity-0 group-hover:opacity-100"}`,children:A.jsx("button",{onClick:_n=>{_n.stopPropagation(),Za(Ft,"folder")},title:B("knowledge.fileList.actions.delete"),children:A.jsx(Rl,{className:`h-4 w-4 ${We.has(Ft.id)?"hover:text-red-200":"hover:text-red-500"}`})})})})]},`folder-${Ft.id}`)),N.map(Ft=>{const _n=We.has(Ft.id);return A.jsxs("div",{ref:Qt=>{Qt?$e.current.set(Ft.id,Qt):$e.current.delete(Ft.id)},draggable:!0,onDragStart:Qt=>Re(Qt,Ft.id),onDragEnd:()=>{window.__xyzenDragContext=null},onClick:Qt=>Rt(Qt,Ft.id),onDoubleClick:()=>yn(Ft),onContextMenu:Qt=>gt(Qt,Ft,"file"),...un(Ft,"file"),className:`group grid grid-cols-12 gap-4 px-4 py-2 text-sm items-center cursor-default ${_n?"bg-indigo-600 text-white":"text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800 odd:bg-white even:bg-neutral-50/50 dark:odd:bg-transparent dark:even:bg-white/5"}`,children:[A.jsxs("div",{className:"col-span-8 md:col-span-6 flex items-center gap-3 overflow-hidden",children:[A.jsx("div",{className:"shrink-0",children:A.jsx(Kq,{filename:Ft.original_filename,mimeType:Ft.content_type||"",className:"h-5 w-5"})}),A.jsx("span",{className:"truncate select-none",children:Ft.original_filename})]}),A.jsx("div",{className:`hidden md:block md:col-span-2 text-xs ${_n?"text-indigo-200":"text-neutral-500 dark:text-neutral-400"}`,children:r6r(Ft.file_size)}),A.jsx("div",{className:`hidden md:block md:col-span-3 text-xs ${_n?"text-indigo-200":"text-neutral-500 dark:text-neutral-400"}`,children:qx(new Date(Ft.created_at),"MMM d, yyyy HH:mm")}),A.jsx("div",{className:"col-span-4 md:col-span-1 flex justify-end",children:A.jsxs("div",{className:`flex gap-2 ${_n?"text-white":"text-neutral-400 opacity-0 group-hover:opacity-100"}`,children:[A.jsx("button",{onClick:Qt=>{Qt.stopPropagation(),Po(Ft)},title:B("knowledge.fileList.actions.preview"),children:A.jsx(NI,{className:`h-4 w-4 ${_n?"hover:text-white":"hover:text-indigo-600"}`})}),A.jsx("button",{onClick:Qt=>{Qt.stopPropagation(),Ri(Ft.id,Ft.original_filename)},title:B("knowledge.fileList.actions.download"),children:A.jsx(mR,{className:`h-4 w-4 ${_n?"hover:text-white":"hover:text-indigo-600"}`})}),A.jsx("button",{onClick:Qt=>{Qt.stopPropagation(),Za(Ft,"file")},title:B("knowledge.fileList.actions.moveToTrash"),children:A.jsx(Rl,{className:`h-4 w-4 ${_n?"hover:text-red-200":"hover:text-red-500"}`})})]})})]},Ft.id)})]})]}):A.jsxs("div",{className:"grid grid-cols-3 gap-4 p-4 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8",children:[M.map(Ft=>A.jsxs("div",{ref:_n=>{_n?$e.current.set(Ft.id,_n):$e.current.delete(Ft.id)},draggable:!0,onDragStart:_n=>Re(_n,Ft.id),onDragEnd:()=>{window.__xyzenDragContext=null},onDragOver:_n=>{be(_n,Ft.id),_n.defaultPrevented&&st(Ft.id)},onDragLeave:()=>st(_n=>_n===Ft.id?null:_n),onDrop:_n=>{st(null),Oe(_n,Ft.id)},onClick:_n=>Rt(_n,Ft.id),onDoubleClick:()=>Fn(Ft.id),onContextMenu:_n=>gt(_n,Ft,"folder"),...un(Ft,"folder"),className:`group flex flex-col items-center gap-2 rounded-md p-3 text-center cursor-default ${we===Ft.id?"ring-2 ring-indigo-500 bg-indigo-50 dark:bg-indigo-900/30":We.has(Ft.id)?"bg-indigo-100 ring-2 ring-indigo-500 dark:bg-indigo-900/50":"hover:bg-neutral-100 dark:hover:bg-neutral-800"}`,children:[A.jsx("div",{className:"flex h-12 w-12 items-center justify-center",children:A.jsx(b2e,{className:"h-10 w-10 text-yellow-500"})}),A.jsx("span",{className:`w-full truncate text-xs font-medium ${We.has(Ft.id)?"text-indigo-700 dark:text-indigo-300":"text-neutral-700 dark:text-neutral-300"}`,children:Ft.name})]},`folder-${Ft.id}`)),N.map(Ft=>{const _n=We.has(Ft.id),Qt=a6r(Ft.content_type||"",Ft.original_filename);return A.jsxs("div",{ref:wr=>{wr?$e.current.set(Ft.id,wr):$e.current.delete(Ft.id)},draggable:!0,onDragStart:wr=>Re(wr,Ft.id),onDragEnd:()=>{window.__xyzenDragContext=null},onClick:wr=>Rt(wr,Ft.id),onDoubleClick:()=>yn(Ft),onContextMenu:wr=>gt(wr,Ft,"file"),...un(Ft,"file"),className:`group flex flex-col items-center gap-2 rounded-md p-3 text-center cursor-default ${_n?"bg-indigo-100 ring-2 ring-indigo-500 dark:bg-indigo-900/50":"hover:bg-neutral-100 dark:hover:bg-neutral-800"}`,children:[Qt?A.jsx(t6r,{fileId:Ft.id,alt:Ft.original_filename,className:"h-12 w-12 rounded"}):A.jsx("div",{className:"flex h-12 w-12 items-center justify-center",children:A.jsx(Kq,{filename:Ft.original_filename,mimeType:Ft.content_type||"",className:"h-10 w-10"})}),A.jsx("span",{className:`w-full truncate text-xs font-medium ${_n?"text-indigo-700 dark:text-indigo-300":"text-neutral-700 dark:text-neutral-300"}`,children:Ft.original_filename})]},Ft.id)})]}),H&&A.jsx("div",{ref:W,className:"flex items-center justify-center py-4",children:Z&&A.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-neutral-300 border-t-neutral-600 dark:border-neutral-600 dark:border-t-neutral-300"})}),ct&&A.jsx(z8r,{type:ct.type,item:ct.item,position:ct.position,onClose:()=>Ne(null),onRename:_?void 0:ln,onDelete:_?void 0:Za,onMove:_?void 0:(Ft,_n)=>tt({isOpen:!0,item:Ft,type:_n}),onDownload:ct.type==="file"?Ft=>Ri(Ft.id,Ft.original_filename):void 0,onPreview:ct.type==="file"?Ft=>Po(Ft):void 0,onEdit:ct.type==="file"&&!_&&cRt(ct.item.original_filename,ct.item.content_type)?Ft=>Al(Ft):void 0,onOpen:ct.type==="folder"?Ft=>Fn(Ft.id):void 0,onAddToKnowledgeSet:F?void 0:Qn,onRemoveFromKnowledgeSet:F?void 0:An,onRestore:F?void 0:(Ft,_n)=>to(Ft.id),onBulkDelete:We.size>1?()=>Za(ct.item,ct.type):void 0,onBulkMove:We.size>1?()=>tt({isOpen:!0,item:ct.item,type:ct.type}):void 0,isInKnowledgeSetView:t==="knowledge",isTrashView:t==="trash",selectedCount:We.has(ct.item.id)?We.size:1}),fe&&Qi.createPortal(A.jsx("div",{className:"fixed z-50 min-w-40 rounded-lg border border-neutral-200 bg-white p-1.5 shadow-lg dark:border-neutral-800 dark:bg-neutral-900",style:{top:fe.y,left:fe.x},ref:Ft=>{if(!Ft)return;const _n=Ft.getBoundingClientRect();_n.right>window.innerWidth&&(Ft.style.left=`${window.innerWidth-_n.width-10}px`),_n.bottom>window.innerHeight&&(Ft.style.top=`${window.innerHeight-_n.height-10}px`)},onMouseDown:Ft=>Ft.stopPropagation(),children:A.jsxs("div",{className:"flex flex-col gap-0.5",children:[m&&(t==="all"||t==="knowledge")&&A.jsxs("button",{onClick:()=>{m(),xe(null)},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(yor,{className:"h-4 w-4"}),B("knowledge.toolbar.newFolder")]}),g&&t!=="trash"&&A.jsxs("button",{onClick:()=>{g(),xe(null)},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(s2e,{className:"h-4 w-4"}),B("knowledge.toolbar.uploadFile")]})]})}),document.body),pt&&A.jsx(n6r,{isOpen:pt.isOpen,onClose:()=>tt(null),onMove:Gr,title:B("knowledge.moveModal.title",{name:pt.type==="folder"?pt.item.name:pt.item.original_filename}),currentFolderId:u||null,itemId:pt.item.id,itemType:pt.type}),A.jsx(L8r,{isOpen:ue,onClose:()=>se(!1),file:K}),ce&&A.jsx(W8r,{isOpen:ve,onClose:()=>{Be(!1),ge(null)},file:ce,onLoadContent:Ft=>F&&C?C(Ft):ys.downloadRaw(Ft),onSaveContent:async(Ft,_n)=>{F&&E?await E(Ft,_n):await ys.updateFileContent(Ft,_n)},readonly:_}),Vt&&A.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:A.jsxs("div",{className:"w-full max-w-md rounded-lg border border-neutral-200 bg-white p-6 shadow-xl dark:border-neutral-800 dark:bg-neutral-900",children:[A.jsx("h3",{className:"mb-4 text-lg font-semibold text-neutral-900 dark:text-white",children:B("knowledge.fileList.knowledgeSet.add.title")}),A.jsx("p",{className:"mb-4 text-sm text-neutral-600 dark:text-neutral-400",children:B("knowledge.fileList.knowledgeSet.add.subtitle",{name:"original_filename"in Vt.item?Vt.item.original_filename:Vt.item.name})}),A.jsx("div",{className:"mb-4 max-h-64 space-y-2 overflow-y-auto",children:on.length===0?A.jsx("p",{className:"text-sm text-neutral-400 italic",children:B("knowledge.fileList.knowledgeSet.none")}):on.map(Ft=>A.jsxs("button",{onClick:()=>ar(Ft.id),className:"flex w-full items-center justify-between rounded-lg border border-neutral-200 p-3 text-left hover:bg-neutral-50 dark:border-neutral-800 dark:hover:bg-neutral-800",children:[A.jsxs("div",{className:"flex-1",children:[A.jsx("div",{className:"font-medium text-neutral-900 dark:text-white",children:Ft.name}),Ft.description&&A.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:Ft.description})]}),A.jsx("div",{className:"text-xs text-neutral-400",children:B("knowledge.fileList.knowledgeSet.fileCount",{count:Ft.file_count})})]},Ft.id))}),A.jsx("button",{onClick:()=>an(null),className:"w-full rounded-lg bg-neutral-100 px-4 py-2 text-sm font-medium text-neutral-900 hover:bg-neutral-200 dark:bg-neutral-800 dark:text-white dark:hover:bg-neutral-700",children:B("common.cancel")})]})}),Lt&&A.jsx(k_,{isOpen:Lt.isOpen,onClose:()=>Dt(null),onConfirm:Lt.onConfirm,title:Lt.title,message:Lt.message,confirmLabel:Lt.confirmLabel,destructive:Lt.destructive}),at&&A.jsx(I8r,{isOpen:at.isOpen,onClose:()=>gn(null),onConfirm:Gn,title:at.type==="folder"?B("knowledge.fileList.rename.titleFolder"):B("knowledge.fileList.rename.titleFile"),initialValue:at.type==="folder"?at.item.name:at.item.original_filename,placeholder:B("knowledge.fileList.rename.placeholder"),confirmLabel:B("knowledge.fileList.rename.confirm")}),xn&&A.jsx(oRt,{isOpen:xn.isOpen,onClose:()=>Rn(null),title:xn.title,message:xn.message,type:xn.type})]})}));Zq.displayName="FileList";const cRe=({onSearch:t,onUpload:e,onUploadFolder:n,onCreateFolder:r,onRefresh:i,onEmptyTrash:o,title:l,isTrash:u,showCreateFolder:d,breadcrumbs:p,onBreadcrumbClick:m,onDropOnBreadcrumb:g,onMenuClick:h,isLoading:f})=>{const{t:b}=Cn(),[y,v]=T.useState(!1),[_,w]=T.useState(void 0),x=T.useCallback((E,S)=>{if(!E.dataTransfer.types.includes(AC))return;const I=window.__xyzenDragContext;S!==null&&I?.ids?.includes(S)||(E.preventDefault(),E.dataTransfer.dropEffect="move",w(S))},[]),k=T.useCallback(()=>{w(void 0)},[]),C=T.useCallback((E,S)=>{E.preventDefault(),w(void 0);try{const I=JSON.parse(E.dataTransfer.getData(AC));I?.ids?.length>0&&g&&g(I.ids,S)}catch{}},[g]);return A.jsxs("div",{className:"relative flex h-14 items-center justify-between border-b border-white/20 dark:border-neutral-700/30 px-3 md:px-4",children:[y&&A.jsxs("div",{className:"absolute inset-0 z-10 flex items-center bg-white/80 dark:bg-neutral-900/80 backdrop-blur-xl px-3 rounded-t-2xl",children:[A.jsx(hy,{className:"mr-2 h-5 w-5 text-neutral-400"}),A.jsx("input",{type:"text",placeholder:b("knowledge.toolbar.searchFilesPlaceholder"),autoFocus:!0,onChange:E=>t(E.target.value),className:"flex-1 border-none bg-transparent text-sm text-neutral-900 placeholder-neutral-400 focus:ring-0 dark:text-white"}),A.jsx("button",{onClick:()=>{v(!1),t("")},className:"p-2 text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300 rounded-lg hover:bg-white/50 dark:hover:bg-white/10 transition-colors",children:A.jsx(Yl,{className:"h-5 w-5"})})]}),A.jsxs("div",{className:`flex items-center gap-2 md:gap-4 ${y?"invisible":""}`,children:[A.jsx("button",{onClick:h,className:"p-2 text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-200 md:hidden",children:A.jsx(myt,{className:"h-5 w-5"})}),p?A.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium text-neutral-600 dark:text-neutral-300",children:[A.jsxs("button",{onClick:()=>m&&m(null),onDragOver:E=>x(E,null),onDragLeave:k,onDrop:E=>C(E,null),className:`flex items-center gap-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded px-1.5 py-0.5 ${p.length===0?"text-neutral-900 font-semibold dark:text-white":""} ${_===null?"ring-2 ring-indigo-500 bg-indigo-50 dark:bg-indigo-900/30":""}`,children:[A.jsx(Bor,{className:"h-4 w-4"}),A.jsx("span",{children:b("knowledge.toolbar.home")})]}),p.map((E,S)=>{const I=S===p.length-1;return A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx(fg,{className:"h-3 w-3 text-neutral-400"}),A.jsx("button",{onClick:()=>!I&&m&&m(E.id),onDragOver:B=>x(B,E.id),onDragLeave:k,onDrop:B=>C(B,E.id),disabled:I,className:`truncate max-w-37.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded px-1.5 py-0.5 ${I?"text-neutral-900 font-semibold dark:text-white cursor-default":"cursor-pointer"} ${_===E.id?"ring-2 ring-indigo-500 bg-indigo-50 dark:bg-indigo-900/30":""}`,children:E.name})]},E.id)})]}):A.jsx("h1",{className:"text-sm font-semibold text-neutral-700 dark:text-neutral-200 capitalize",children:l})]}),A.jsxs("div",{className:`flex items-center gap-1 md:gap-3 ${y?"invisible":""}`,children:[A.jsx("button",{onClick:()=>v(!0),className:"p-1.5 text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 md:hidden",children:A.jsx(hy,{className:"h-5 w-5"})}),A.jsxs("div",{className:"relative hidden md:block",children:[A.jsx(hy,{className:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-neutral-400"}),A.jsx("input",{type:"text",placeholder:b("knowledge.toolbar.searchPlaceholder"),onChange:E=>t(E.target.value),className:"h-9 w-48 rounded-sm border border-white/20 dark:border-neutral-700/30 bg-white/50 dark:bg-neutral-800/50 pl-9 pr-4 text-xs text-neutral-900 placeholder-neutral-400 focus:ring-1 focus:ring-indigo-500/50 focus:border-indigo-500/50 dark:text-white transition-all"})]}),A.jsx("div",{className:"hidden h-6 w-px bg-neutral-300/50 dark:bg-neutral-600/30 md:block"}),d&&r&&A.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 rounded-sm bg-white/50 dark:bg-neutral-800/50 px-3 py-2 text-xs font-medium text-neutral-700 dark:text-neutral-200 border border-white/20 dark:border-neutral-700/30 hover:bg-white/80 dark:hover:bg-neutral-700/60 transition-all duration-200",title:b("knowledge.toolbar.newFolder"),children:[A.jsx(U1,{className:"h-4 w-4"}),A.jsx("span",{className:"hidden md:inline",children:b("knowledge.toolbar.newFolder")})]}),u&&o?A.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 rounded-sm bg-red-500/90 hover:bg-red-500 px-3 py-2 text-xs font-medium text-white shadow-sm transition-all duration-200",title:b("knowledge.toolbar.emptyTrash"),children:[A.jsx(Rl,{className:"h-4 w-4"}),A.jsx("span",{className:"hidden md:inline",children:b("knowledge.toolbar.empty")})]}):A.jsx(i6r,{onUploadFiles:e,onUploadFolder:n}),A.jsx("button",{onClick:i,className:"hidden rounded-sm p-2 text-neutral-500 hover:bg-white/50 dark:hover:bg-white/10 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-200 transition-all duration-200 md:block",title:b("knowledge.toolbar.refresh"),disabled:f,children:A.jsx(ao,{className:`h-4 w-4 transition-transform${f?" animate-spin":""}`})})]})]})},i6r=({onUploadFiles:t,onUploadFolder:e})=>{const{t:n}=Cn(),[r,i]=T.useState(!1),o=T.useRef(null);return T.useEffect(()=>{if(!r)return;const l=u=>{o.current&&!o.current.contains(u.target)&&i(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]),A.jsxs("div",{ref:o,className:"relative",children:[A.jsxs("button",{onClick:()=>i(l=>!l),className:"flex items-center gap-1.5 rounded-sm bg-indigo-500/90 hover:bg-indigo-500 px-3 py-2 text-xs font-medium text-white shadow-sm transition-all duration-200",title:n("knowledge.toolbar.upload"),children:[A.jsx(Dd,{className:"h-4 w-4"}),A.jsx("span",{className:"hidden md:inline",children:n("knowledge.toolbar.upload")})]}),r&&A.jsxs("div",{className:"absolute right-0 top-full z-50 mt-1 w-44 overflow-hidden rounded-md border border-neutral-200 bg-white shadow-lg dark:border-neutral-700 dark:bg-neutral-900",children:[A.jsxs("button",{className:"flex w-full items-center gap-2 px-3 py-2 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800 transition-colors",onClick:()=>{i(!1),t()},children:[A.jsx(DI,{className:"h-4 w-4 text-neutral-500"}),n("knowledge.toolbar.uploadFile")]}),e&&A.jsxs("button",{className:"flex w-full items-center gap-2 px-3 py-2 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800 transition-colors",onClick:()=>{i(!1),e()},children:[A.jsx(m2e,{className:"h-4 w-4 text-neutral-500"}),n("knowledge.toolbar.uploadFolder")]})]})]})},o6r=t=>{if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/Math.pow(e,r)).toFixed(1))} ${n[r]}`},s6r=t=>`${(t/1048576).toFixed(2)} MB`,uRe=({itemCount:t,stats:e})=>{const{t:n}=Cn(),r=e.availableBytes??Math.max(0,e.total-e.used),i=e.usagePercentage??(e.total>0?e.used/e.total*100:0),o=()=>i>=90?"text-red-600 dark:text-red-400":i>=75?"text-orange-600 dark:text-orange-400":"text-neutral-500",l=()=>i>=90?"bg-red-500":i>=75?"bg-orange-500":"bg-blue-500";return A.jsxs("div",{className:"flex h-10 select-none items-center justify-between border-t border-white/20 dark:border-neutral-700/30 px-4 text-xs font-medium text-neutral-500 dark:text-neutral-400",children:[A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsx("span",{children:n("knowledge.status.items",{count:t})}),A.jsx("span",{className:"h-3 w-px bg-neutral-300/50 dark:bg-neutral-600/50"}),A.jsx("span",{className:o(),children:n("knowledge.status.used",{used:s6r(e.used)})}),A.jsx("span",{className:"hidden sm:inline h-3 w-px bg-neutral-300/50 dark:bg-neutral-600/50"}),A.jsx("span",{className:"hidden sm:inline",children:n("knowledge.status.available",{available:o6r(r)})})]}),A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsx("div",{className:"w-20 sm:w-28 h-1.5 bg-neutral-200/50 dark:bg-neutral-700/50 rounded-full overflow-hidden",children:A.jsx("div",{className:`h-full transition-all duration-300 ${l()}`,style:{width:`${Math.min(i,100)}%`}})}),i>0&&A.jsxs("span",{className:o(),children:[i.toFixed(0),"%"]})]})]})},dRe=({uploads:t,onCancel:e,onDismiss:n,onDismissAll:r})=>{const{t:i}=Cn();if(t.length===0)return null;const o=t.filter(d=>d.status==="queued"||d.status==="uploading"),l=t.filter(d=>d.status==="uploading").length,u=t.filter(d=>d.status==="queued").length;return A.jsxs(Ct.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:20,scale:.95},className:"absolute bottom-4 right-4 z-50 w-80 rounded-sm border border-white/30 dark:border-neutral-700/50 bg-white/80 dark:bg-neutral-900/80 backdrop-blur-xl shadow-xl",children:[A.jsxs("div",{className:"flex items-center justify-between border-b border-white/20 dark:border-neutral-700/30 px-4 py-3",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("h3",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:o.length>0?l>0?i("knowledge.uploadProgress.uploading",{count:l})+(u>0?` (+${u})`:""):i("knowledge.uploadProgress.queued",{count:u}):i("knowledge.uploadProgress.complete")}),o.length>0&&A.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-indigo-500"})]}),A.jsx("button",{onClick:r,className:"rounded p-1 text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600 dark:hover:bg-neutral-800 dark:hover:text-neutral-300",title:i("common.close"),children:A.jsx(Yl,{className:"h-4 w-4"})})]}),A.jsx("div",{className:"max-h-64 overflow-y-auto",children:A.jsx(jr,{mode:"popLayout",children:t.map(d=>A.jsx(Ct.div,{layout:!0,initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"border-b border-white/10 dark:border-neutral-700/20 px-4 py-3 last:border-b-0",children:A.jsxs("div",{className:"flex items-start justify-between gap-2",children:[A.jsxs("div",{className:"min-w-0 flex-1",children:[A.jsx("p",{className:"truncate text-sm font-medium text-neutral-900 dark:text-neutral-100",children:d.fileName}),A.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[d.status==="queued"&&A.jsx("span",{className:"text-xs text-neutral-400 dark:text-neutral-500",children:i("knowledge.uploadProgress.waiting")}),d.status==="uploading"&&A.jsxs(A.Fragment,{children:[A.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-neutral-200 dark:bg-neutral-700",children:A.jsx(Ct.div,{className:"h-full bg-indigo-500",initial:{width:0},animate:{width:`${d.progress}%`},transition:{duration:.3}})}),A.jsxs("span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:[d.progress,"%"]})]}),d.status==="completed"&&A.jsx("span",{className:"text-xs text-green-600 dark:text-green-400",children:i("knowledge.uploadProgress.completed")}),d.status==="error"&&A.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:d.error||i("knowledge.uploadProgress.failed")}),d.status==="cancelled"&&A.jsx("span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:i("knowledge.uploadProgress.cancelled")})]})]}),A.jsx("div",{className:"flex shrink-0 items-center",children:d.status==="queued"||d.status==="uploading"?A.jsx("button",{onClick:()=>e(d.id),className:"rounded p-1 text-neutral-400 hover:bg-neutral-100 hover:text-red-500 dark:hover:bg-neutral-800",title:i("common.cancel"),children:A.jsx(Yl,{className:"h-4 w-4"})}):A.jsx("button",{onClick:()=>n(d.id),className:"rounded p-1 text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600 dark:hover:bg-neutral-800",title:i("common.dismiss"),children:A.jsx(Yl,{className:"h-4 w-4"})})})]})},d.id))})}),o.length>1&&A.jsx("div",{className:"border-t border-white/20 dark:border-neutral-700/30 px-4 py-2",children:A.jsx("button",{onClick:()=>o.forEach(d=>e(d.id)),className:"text-xs font-medium text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:i("knowledge.uploadProgress.cancelAll")})})]})},l6r=(t,e)=>{if(!e.includes(t))return t;const n=t.lastIndexOf("."),r=n>0?t.slice(0,n):t,i=n>0?t.slice(n):"";let o=1,l;do l=`${r} (${o})${i}`,o++;while(e.includes(l));return l};async function gRt(t,e=""){const n=e?`${e}/${t.name}`:t.name;if(t.isFile)return[{file:await new Promise((i,o)=>{t.file(i,o)}),relativePath:n}];if(t.isDirectory){const r=t.createReader(),i=[];let o;do{o=await new Promise((l,u)=>{r.readEntries(l,u)});for(const l of o){const u=await gRt(l,n);i.push(...u)}}while(o.length>0);return i}return[]}function hRt({knowledgeSetId:t,showToolbar:e=!0,showStatusBar:n=!0,enableUpload:r=!0,onMenuClick:i}){const{t:o}=Cn(),[l,u]=T.useState([]),[d,p]=T.useState(!1),[m,g]=T.useState(0),[h,f]=T.useState(null),[b]=T.useState("list"),[y,v]=T.useState([]),[_,w]=T.useState(null),[x,k]=T.useState(0),[C,E]=T.useState(!1),[S,I]=T.useState(0),[B,N]=T.useState({total:0,used:0,fileCount:0,usagePercentage:0,availableBytes:0,maxFileSize:100*1024*1024}),[L,M]=T.useState([]),R=T.useRef(new Map),[D,P]=T.useState(!1),O=T.useRef(0),F=T.useRef(null),Q=T.useRef(null),j=T.useRef(null);T.useEffect(()=>{if(!t){u([]);return}let rt=!1;return p(!0),pf.getTree(t).then(mt=>{rt||(u(mt),p(!1))}).catch(mt=>{console.error("Failed to fetch knowledge tree",mt),rt||p(!1)}),()=>{rt=!0}},[t,m]),T.useEffect(()=>{if(!t){w(null);return}let rt=!1;return Sh.getKnowledgeSet(t).then(mt=>{rt||w(mt.name)}).catch(mt=>{console.error("Failed to fetch knowledge set name",mt)}),()=>{rt=!0}},[t]),T.useEffect(()=>{if(!h){v([]);return}pf.getFolderPath(h).then(v).catch(rt=>console.error("Failed to fetch breadcrumbs",rt))},[h]),T.useEffect(()=>{if(!n&&!r)return;(async()=>{try{const mt=await ys.getStorageStats();N({used:mt.quota.storage.used_bytes,total:mt.quota.storage.limit_bytes,fileCount:mt.quota.file_count.used,usagePercentage:mt.quota.storage.usage_percentage,availableBytes:mt.quota.storage.available_bytes,maxFileSize:mt.quota.max_file_size.bytes})}catch(mt){console.error("Stats fetch failed",mt)}})()},[x,n,r]),T.useEffect(()=>{f(null)},[t]);const $=T.useCallback(rt=>{const mt=new Set(rt);u(yt=>yt.filter(xt=>!mt.has(xt.id)))},[]),z=T.useCallback((rt,mt)=>{u(yt=>yt.map(xt=>xt.id===rt?{...xt,name:mt}:xt))},[]),U=T.useCallback(()=>{g(rt=>rt+1)},[]),H=T.useCallback(()=>{k(rt=>rt+1),U()},[U]),te=T.useCallback((rt,mt)=>{N(yt=>{const xt=Math.max(0,yt.used-rt),$e=Math.max(0,yt.fileCount-mt),ot=yt.total-xt,Ce=yt.total>0?xt/yt.total*100:0;return{...yt,used:xt,fileCount:$e,availableBytes:ot,usagePercentage:Ce}})},[]),Z=T.useCallback(rt=>{f(rt)},[]),ae=T.useCallback(()=>{j.current&&j.current.createFolder(h)},[h]),oe=T.useCallback(async(rt,mt)=>{j.current&&j.current.moveItems(rt,mt)},[]),X=T.useCallback(async rt=>{if(rt.length===0)return;const mt=h||null;let yt=[];try{yt=(await ys.listFiles({parent_id:mt,filter_by_parent:!0,limit:1e3,offset:0})).map($e=>$e.original_filename)}catch{}for(const xt of rt){if(B.maxFileSize&&xt.size>B.maxFileSize){const pe=(B.maxFileSize/1048576).toFixed(0),Ze=(xt.size/(1024*1024)).toFixed(2);alert(o("knowledge.upload.errors.fileTooLarge",{name:xt.name,fileSizeMB:Ze,maxSizeMB:pe}));continue}if(B.availableBytes!==void 0&&xt.size>B.availableBytes){const pe=(B.availableBytes/1048576).toFixed(2),Ze=(xt.size/(1024*1024)).toFixed(2);alert(o("knowledge.upload.errors.notEnoughStorage",{fileSizeMB:Ze,availableMB:pe}));continue}const $e=l6r(xt.name,yt);yt.push($e);const ot=$e!==xt.name?new File([xt],$e,{type:xt.type}):xt,Ce=`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,et={id:Ce,fileName:$e,progress:0,status:"queued"};M(pe=>[...pe,et]);const Rt=nRt.enqueue(Ce,()=>M(pe=>pe.map(Ze=>Ze.id===Ce?{...Ze,status:"uploading"}:Ze)),()=>ys.uploadFileWithProgress(ot,"private",void 0,mt,t,pe=>{M(Ze=>Ze.map(ie=>ie.id===Ce?{...ie,progress:pe.percentage}:ie))}));R.current.set(Ce,Rt),Rt.promise.then(()=>{M(pe=>pe.map(Ze=>Ze.id===Ce?{...Ze,status:"completed",progress:100}:Ze)),R.current.delete(Ce),k(pe=>pe+1),U()}).catch(pe=>{pe.message==="Upload cancelled"?M(Ze=>Ze.map(ie=>ie.id===Ce?{...ie,status:"cancelled"}:ie)):M(Ze=>Ze.map(ie=>ie.id===Ce?{...ie,status:"error",error:pe.message}:ie)),R.current.delete(Ce)})}},[h,t,B,o,U]),W=T.useCallback(()=>{F.current?.click()},[]),q=T.useCallback(()=>{Q.current?.click()},[]),Y=async rt=>{if(rt.target.files&&rt.target.files.length>0){const mt=Array.from(rt.target.files);await X(mt),rt.target.value=""}},K=T.useCallback(async rt=>{if(rt.length===0)return;const mt=h||null,yt=new Set;for(const{relativePath:ot}of rt){const Ce=ot.split("/");for(let et=1;et<Ce.length;et++)yt.add(Ce.slice(0,et).join("/"))}const xt=Array.from(yt).sort((ot,Ce)=>ot.split("/").length-Ce.split("/").length),$e=new Map;for(const ot of xt){const Ce=ot.split("/"),et=Ce[Ce.length-1],Rt=Ce.length>1?Ce.slice(0,-1).join("/"):null,pe=Rt?$e.get(Rt)??null:mt;try{const Ze=await pf.createFolder({name:et,parent_id:pe});$e.set(ot,Ze.id)}catch(Ze){console.error(`Failed to create folder: ${ot}`,Ze)}}for(const{file:ot,relativePath:Ce}of rt){const et=Ce.split("/"),Rt=et.length>1?et.slice(0,-1).join("/"):null,pe=Rt?$e.get(Rt)??mt:mt;if(B.maxFileSize&&ot.size>B.maxFileSize||B.availableBytes!==void 0&&ot.size>B.availableBytes)continue;const Ze=et[et.length-1],ie=new File([ot],Ze,{type:ot.type}),Re=`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,be={id:Re,fileName:Ze,progress:0,status:"queued"};M(we=>[...we,be]);const Oe=nRt.enqueue(Re,()=>M(we=>we.map(st=>st.id===Re?{...st,status:"uploading"}:st)),()=>ys.uploadFileWithProgress(ie,"private",void 0,pe,t,we=>{M(st=>st.map(vt=>vt.id===Re?{...vt,progress:we.percentage}:vt))}));R.current.set(Re,Oe),Oe.promise.then(()=>{M(we=>we.map(st=>st.id===Re?{...st,status:"completed",progress:100}:st)),R.current.delete(Re),k(we=>we+1),U()}).catch(we=>{we.message==="Upload cancelled"?M(st=>st.map(vt=>vt.id===Re?{...vt,status:"cancelled"}:vt)):M(st=>st.map(vt=>vt.id===Re?{...vt,status:"error",error:we.message}:vt)),R.current.delete(Re)})}},[h,t,B,U]),ne=T.useCallback(async rt=>{if(!rt.target.files||rt.target.files.length===0)return;const mt=Array.from(rt.target.files);rt.target.value="";const yt=mt.map(xt=>{const $e=xt.webkitRelativePath;return $e?{file:xt,relativePath:$e}:null}).filter(Boolean);await K(yt)},[K]),ue=T.useCallback(rt=>{const mt=R.current.get(rt);mt&&mt.abort()},[]),se=T.useCallback(rt=>{M(mt=>mt.filter(yt=>yt.id!==rt))},[]),ce=T.useCallback(()=>{L.forEach(rt=>{if(rt.status==="uploading"||rt.status==="queued"){const mt=R.current.get(rt.id);mt&&mt.abort()}}),M([])},[L]),ge=T.useCallback(rt=>{rt.preventDefault(),rt.stopPropagation(),!rt.dataTransfer.types.includes(AC)&&(O.current++,rt.dataTransfer.types.includes("Files")&&P(!0))},[]),ve=T.useCallback(rt=>{rt.preventDefault(),rt.stopPropagation(),O.current--,O.current===0&&P(!1)},[]),Be=T.useCallback(rt=>{rt.preventDefault(),rt.stopPropagation()},[]),We=T.useCallback(async rt=>{rt.preventDefault(),rt.stopPropagation(),P(!1),O.current=0;const yt=Array.from(rt.dataTransfer.items).map($e=>$e.webkitGetAsEntry?.()).filter(Boolean);if(yt.some($e=>$e.isDirectory)){const $e=[];for(const ot of yt){const Ce=await gRt(ot);$e.push(...Ce)}$e.length>0&&await K($e)}else{const $e=Array.from(rt.dataTransfer.files);$e.length>0&&await X($e)}},[X,K]),Le=_||o("knowledge.titles.knowledgeBase");return A.jsxs("div",{className:"flex flex-1 flex-col min-w-0 overflow-hidden relative",onDragEnter:r?ge:void 0,onDragLeave:r?ve:void 0,onDragOver:r?Be:void 0,onDrop:r?We:void 0,children:[r&&D&&A.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-indigo-500/10 backdrop-blur-sm border-2 border-dashed border-indigo-500 rounded-lg m-2 pointer-events-none",children:A.jsxs("div",{className:"text-center",children:[A.jsx("div",{className:"text-4xl mb-2",children:"📁"}),A.jsx("div",{className:"text-lg font-medium text-indigo-600 dark:text-indigo-400",children:o("knowledge.upload.dropHere")}),A.jsx("div",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:_?o("knowledge.upload.dropToKnowledgeSet",{name:_}):o(h?"knowledge.upload.dropToFolder":"knowledge.upload.dropToUpload")})]})}),e&&A.jsx(cRe,{title:Le,onSearch:rt=>console.log("Search",rt),onUpload:W,onUploadFolder:q,onRefresh:H,isTrash:!1,showCreateFolder:!0,onCreateFolder:ae,breadcrumbs:h?y:void 0,onBreadcrumbClick:rt=>Z(rt),onDropOnBreadcrumb:oe,isLoading:C,onMenuClick:i}),A.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:A.jsx(Zq,{ref:j,filter:"knowledge",viewMode:b,refreshTrigger:x,onRefresh:H,onFileCountChange:I,onStatsUpdate:te,onLoadingChange:E,currentFolderId:h,currentKnowledgeSetId:t,onFolderChange:Z,onCreateFolder:ae,onUpload:r?W:void 0,treeItems:l,treeLoading:d,onRefreshTree:U,removeTreeItems:$,renameTreeItem:z})}),n&&A.jsx(uRe,{itemCount:h?S:B.fileCount,stats:{used:B.used,total:B.total,fileCount:B.fileCount}}),r&&A.jsxs(A.Fragment,{children:[A.jsx(jr,{children:L.length>0&&A.jsx(dRe,{uploads:L,onCancel:ue,onDismiss:se,onDismissAll:ce})}),A.jsx("input",{type:"file",ref:F,className:"hidden",multiple:!0,onChange:Y}),A.jsx("input",{type:"file",ref:Q,className:"hidden",webkitdirectory:"",onChange:ne})]})]})}function c6r(){const{t}=Cn(),{knowledge_set_id:e}=aI();return e?A.jsx(hRt,{knowledgeSetId:e,showToolbar:!1,showStatusBar:!1,enableUpload:!0}):A.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[A.jsx("p",{className:"text-sm font-medium text-neutral-500 dark:text-neutral-400",children:t("capsule.knowledge.noKnowledgeSet")}),A.jsx("p",{className:"text-xs text-neutral-400 dark:text-neutral-500",children:t("capsule.knowledge.noKnowledgeSetHint")})]})}function bC({...t}){return A.jsx(WYn,{"data-slot":"popover",...t})}function yC({...t}){return A.jsx(VYn,{"data-slot":"popover-trigger",...t})}function vC({className:t,align:e="center",sideOffset:n=4,...r}){return A.jsx(KYn,{children:A.jsx(ZYn,{"data-slot":"popover-content",align:e,sideOffset:n,className:Yt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...r})})}function u6r({...t}){return A.jsx(YYn,{"data-slot":"popover-anchor",...t})}function d6r({delayDuration:t=0,...e}){return A.jsx(PKn,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function fRt({...t}){return A.jsx(d6r,{children:A.jsx(OKn,{"data-slot":"tooltip",...t})})}function ARt({...t}){return A.jsx(FKn,{"data-slot":"tooltip-trigger",...t})}function p6r({className:t,sideOffset:e=0,children:n,...r}){return A.jsx(Nft,{children:A.jsxs(Rft,{"data-slot":"tooltip-content",sideOffset:e,className:Yt("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...r,children:[n,A.jsx(QKn,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const nF="https://storage.sciol.ac.cn/xyzen/releases/runner/latest",Xq=[{key:"darwin-arm64",label:"macOS Apple Silicon",binary:"xyzen-darwin-arm64",curlCmd:`sudo curl -fsSL ${nF}/xyzen-darwin-arm64 -o /usr/local/bin/xyzen && sudo chmod +x /usr/local/bin/xyzen`},{key:"darwin-amd64",label:"macOS Intel",binary:"xyzen-darwin-amd64",curlCmd:`sudo curl -fsSL ${nF}/xyzen-darwin-amd64 -o /usr/local/bin/xyzen && sudo chmod +x /usr/local/bin/xyzen`},{key:"linux-amd64",label:"Linux x86_64",binary:"xyzen-linux-amd64",curlCmd:`sudo curl -fsSL ${nF}/xyzen-linux-amd64 -o /usr/local/bin/xyzen && sudo chmod +x /usr/local/bin/xyzen`},{key:"linux-arm64",label:"Linux ARM64",binary:"xyzen-linux-arm64",curlCmd:`sudo curl -fsSL ${nF}/xyzen-linux-arm64 -o /usr/local/bin/xyzen && sudo chmod +x /usr/local/bin/xyzen`},{key:"windows-amd64",label:"Windows x86_64",binary:"xyzen-windows-amd64.exe",curlCmd:`curl -fSL ${nF}/xyzen-windows-amd64.exe -o xyzen.exe`}];function m6r(){const t=navigator.userAgent.toLowerCase(),e=navigator.platform?.toLowerCase()??"";return t.includes("mac")||e.includes("mac")?Xq[0]:t.includes("win")||e.includes("win")?Xq[4]:(t.includes("linux"),Xq[2])}function g6r({title:t,children:e,className:n=""}){return A.jsxs("div",{className:`border border-neutral-200 dark:border-[#30363d] bg-white dark:bg-[#0d1117] ${n}`,children:[A.jsxs("div",{className:"flex items-center gap-2 border-b border-neutral-200 dark:border-[#30363d] px-3 py-2",children:[A.jsxs("div",{className:"flex gap-1.5",children:[A.jsx("div",{className:"h-2.5 w-2.5 bg-red-400 dark:bg-[#ff5f57]"}),A.jsx("div",{className:"h-2.5 w-2.5 bg-amber-400 dark:bg-[#febc2e]"}),A.jsx("div",{className:"h-2.5 w-2.5 bg-green-400 dark:bg-[#28c840]"})]}),A.jsx("span",{className:"ml-1 font-mono text-[11px] text-neutral-500 dark:text-[#8b949e]",children:t})]}),A.jsx("div",{className:"p-3 font-mono text-[12px] leading-relaxed",children:e})]})}function bRt({lines:t,onCopy:e}){const[n,r]=T.useState(!1),i=T.useCallback(async()=>{e&&(await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3))},[e]);return A.jsxs("div",{className:"group relative border border-neutral-200 dark:border-[#30363d] bg-neutral-100 dark:bg-[#010409]",children:[A.jsx("div",{className:"custom-scrollbar overflow-x-auto p-3",children:A.jsx("table",{className:"w-full border-collapse",children:A.jsx("tbody",{children:t.map((o,l)=>A.jsxs("tr",{children:[A.jsx("td",{className:"w-8 select-none pr-3 text-right align-top font-mono text-[11px] text-neutral-400 dark:text-[#484f58]",children:l+1}),A.jsx("td",{className:`whitespace-pre font-mono text-[12px] ${o.color?"":"text-neutral-900 dark:text-[#e6edf3]"}`,style:o.color?{color:o.color}:void 0,children:o.text})]},l))})})}),e&&A.jsx("button",{onClick:i,className:"absolute right-2 top-2 border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] p-1 text-neutral-500 dark:text-[#8b949e] opacity-0 transition-opacity hover:bg-neutral-100 dark:hover:bg-[#1f242b] hover:text-neutral-900 dark:hover:text-neutral-900 dark:text-[#e6edf3] group-hover:opacity-100",children:n?A.jsx(Vo,{className:"h-3.5 w-3.5 text-green-600 dark:text-[#3fb950]"}):A.jsx(D5,{className:"h-3.5 w-3.5"})})]})}function yRt({variant:t="capsule"}){const{runners:e,runnersLoading:n,fetchRunners:r,deleteRunner:i,updateRunner:o,openTerminal:l,connectRunnerEvents:u}=Un(Wo(g=>({runners:g.runners,runnersLoading:g.runnersLoading,fetchRunners:g.fetchRunners,deleteRunner:g.deleteRunner,updateRunner:g.updateRunner,openTerminal:g.openTerminal,connectRunnerEvents:g.connectRunnerEvents}))),[d,p]=T.useState(!1);T.useEffect(()=>(r(),u()),[r,u]);const m=T.useCallback(()=>{p(!1)},[]);return t==="panel"?A.jsx(h6r,{runners:e,runnersLoading:n,showCreate:d,onShowCreate:()=>p(!0),onDoneCreate:m,onDelete:i,onToggle:o,onOpenTerminal:l}):!n&&e.length===0&&!d?A.jsx("div",{className:"flex-1 flex flex-col bg-white dark:bg-[#0d1117]",children:A.jsx("div",{className:"custom-scrollbar flex-1 overflow-y-auto",children:A.jsx(vRt,{onConnect:()=>p(!0)})})}):A.jsx("div",{className:"flex-1 flex flex-col overflow-hidden bg-white dark:bg-[#0d1117]",children:A.jsxs("div",{className:"custom-scrollbar flex-1 overflow-y-auto",children:[d&&A.jsx("div",{className:"p-3",children:A.jsx(_Rt,{onDone:m})}),e.map(g=>A.jsx("div",{className:"p-3",children:A.jsx(wRt,{runner:g,onDelete:i,onToggle:o,onOpenTerminal:l,onAddAnother:()=>p(!0)})},g.id)),n&&e.length===0&&!d&&A.jsx("div",{className:"px-3 py-4 text-center",children:A.jsx("p",{className:"font-mono text-xs text-neutral-400 dark:text-[#484f58]",children:"loading..."})}),e.length>0&&!d&&A.jsx("div",{className:"px-3 pb-3",children:A.jsxs("button",{onClick:()=>p(!0),className:"flex w-full items-center justify-center gap-1.5 border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] py-2 font-mono text-xs text-neutral-500 dark:text-[#8b949e] transition-colors hover:border-neutral-400 dark:hover:border-[#8b949e] hover:text-neutral-900 dark:hover:text-neutral-900 dark:text-[#e6edf3]",children:[A.jsx(Dd,{className:"h-3 w-3"}),"+ runner"]})})]})})}function h6r({runners:t,runnersLoading:e,showCreate:n,onShowCreate:r,onDoneCreate:i,onDelete:o,onToggle:l,onOpenTerminal:u}){return A.jsxs("div",{className:"flex flex-col sm:flex-row h-full gap-px bg-white dark:bg-[#0d1117]",children:[A.jsx("div",{className:"custom-scrollbar sm:w-1/2 shrink-0 overflow-y-auto border-b sm:border-b-0 sm:border-r border-neutral-200 dark:border-[#21262d]",children:A.jsx(vRt,{onConnect:r})}),A.jsxs("div",{className:"custom-scrollbar sm:w-1/2 flex-1 overflow-y-auto",children:[n&&A.jsx("div",{className:"p-4",children:A.jsx(_Rt,{onDone:i})}),t.map(d=>A.jsx("div",{className:"p-4",children:A.jsx(wRt,{runner:d,onDelete:o,onToggle:l,onOpenTerminal:u,onAddAnother:r})},d.id)),e&&t.length===0&&!n&&A.jsx("div",{className:"px-4 py-8 text-center",children:A.jsx("p",{className:"font-mono text-xs text-neutral-400 dark:text-[#484f58]",children:"loading..."})}),!e&&t.length===0&&!n&&A.jsxs("div",{className:"flex flex-col items-center justify-center px-4 py-16",children:[A.jsx("p",{className:"font-mono text-sm text-neutral-500 dark:text-[#8b949e]",children:"No runners connected"}),A.jsx("p",{className:"mt-1 font-mono text-xs text-neutral-400 dark:text-[#484f58]",children:"Follow the steps above to get started"})]}),t.length>0&&!n&&A.jsx("div",{className:"px-4 pb-4",children:A.jsxs("button",{onClick:r,className:"flex w-full items-center justify-center gap-1.5 border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] py-2 font-mono text-xs text-neutral-500 dark:text-[#8b949e] transition-colors hover:border-neutral-400 dark:hover:border-[#8b949e] hover:text-neutral-900 dark:hover:text-neutral-900 dark:text-[#e6edf3]",children:[A.jsx(Dd,{className:"h-3 w-3"}),"+ runner"]})})]})]})}function f6r({onConnect:t}){const{t:e}=Cn(),{createRunnerToken:n,fetchRunners:r}=Un(Wo(N=>({createRunnerToken:N.createRunnerToken,fetchRunners:N.fetchRunners}))),[i,o]=T.useState("Disconnected"),[l,u]=T.useState(!1),[d,p]=T.useState(null),[m,g]=T.useState(!0),[h,f]=T.useState(()=>({enabled:q7(),supported:!0})),[b,y]=T.useState(null),v=T.useRef(void 0),_=T.useCallback(async()=>{const N=await n(vte);if(!N)return null;const L={runnerId:N.runner.id,token:N.token,name:vte};return pst(L),L},[n]);T.useEffect(()=>{(async()=>{try{const L=await yke();o(L),u(L==="Connecting"||typeof L=="object"&&"Connected"in L)}catch{o("Disconnected"),u(!1)}})()},[]),T.useEffect(()=>{let N=!1;return(async()=>{try{const M=await dst();N||f(M)}catch{N||f({enabled:q7(),supported:!1})}finally{N||g(!1)}})(),()=>{N=!0}},[]),T.useEffect(()=>{let N=!1;const L=async()=>{try{const R=await vke();N||y(R)}catch(R){N||y({supported:!1,platform:"unknown",screen_capture_permission:"unknown",accessibility_permission:"unknown",reason:String(R)})}},M=()=>{document.visibilityState==="visible"&&L()};return L(),window.addEventListener("focus",L),document.addEventListener("visibilitychange",M),()=>{N=!0,window.removeEventListener("focus",L),document.removeEventListener("visibilitychange",M)}},[]),T.useEffect(()=>gst(N=>{f(L=>({...L,enabled:N}))}),[]),T.useEffect(()=>{if(!l)return;const N=async()=>{try{const L=await yke();o(L)}catch{}};return N(),v.current=setInterval(N,2e3),()=>clearInterval(v.current)},[l]);const w=typeof i=="object"&&"Connected"in i,x=typeof i=="object"&&"Error"in i,k=T.useCallback(async()=>{if(p(null),l)try{await Y8n(),u(!1),o("Disconnected"),await r()}catch(N){p(String(N))}else try{await r();let N=xte();if(N){const L=N.runnerId,M=Un.getState().runners.find(R=>R.id===L);(!M||!M.is_active)&&(U7(),N=null)}if(!N&&(N=await _(),!N)){p("Failed to create runner token");return}try{await _te(N.token,wte())}catch(L){if(!String(L).includes("already running")){if(U7(),N=await _(),!N){p("Failed to recreate runner token");return}await _te(N.token,wte())}}u(!0),await r()}catch(N){U7(),p(String(N))}},[l,_,r]),C=T.useCallback(async N=>{g(!0);try{const L=await _ke(N);f(L),mst(N)}catch(L){p(String(L))}finally{g(!1)}},[]),E=w?e("capsule.sandbox.runner.online"):i==="Connecting"?e("capsule.sandbox.runner.connecting","Connecting..."):x?e("capsule.sandbox.runner.error","Error"):e("capsule.sandbox.runner.offline"),S=w?"bg-green-500 dark:bg-[#3fb950]":i==="Connecting"?"bg-amber-500 dark:bg-[#d29922]":"bg-neutral-400 dark:bg-[#484f58]",I=cst(b),B=b?.supported?e("capsule.sandbox.runner.computerUseReady",{platform:b.platform}):I==="both"?e("capsule.sandbox.runner.computerUseRequiresMacPermissions","请在系统设置 -> 隐私与安全性中允许 Xyzen Desktop 的“屏幕录制”和“辅助功能”。"):I==="screen_capture"?e("capsule.sandbox.runner.computerUseRequiresScreenCapturePermission","请在系统设置 -> 隐私与安全性 -> 屏幕录制中允许 Xyzen Desktop。"):I==="accessibility"?e("capsule.sandbox.runner.computerUseRequiresAccessibilityPermission","请在系统设置 -> 隐私与安全性 -> 辅助功能中允许 Xyzen Desktop。"):b?.reason||e("capsule.sandbox.runner.computerUseUnavailable","Computer use is unavailable on this desktop host.");return A.jsxs("div",{className:"space-y-4 p-4",children:[A.jsxs("div",{children:[A.jsx("h3",{className:"font-mono text-sm font-bold text-neutral-900 dark:text-[#e6edf3]",children:e("capsule.sandbox.runner.connectTitle")}),A.jsx("p",{className:"mt-1 font-mono text-xs text-neutral-500 dark:text-[#8b949e]",children:e("capsule.sandbox.runner.desktopHint","Built-in runner — no installation needed.")})]}),A.jsxs("div",{className:"flex items-center gap-3 border border-neutral-200 dark:border-[#30363d] bg-white dark:bg-[#0d1117] px-3 py-2.5",children:[A.jsx("div",{className:`h-2 w-2 shrink-0 ${S}`,style:w?{boxShadow:"0 0 6px rgba(63,185,80,0.5)"}:void 0}),A.jsx("span",{className:"flex-1 font-mono text-[12px] text-neutral-900 dark:text-[#e6edf3]",children:e("capsule.sandbox.runner.title","Runner")}),A.jsx("span",{className:"font-mono text-[10px] text-neutral-500 dark:text-[#8b949e]",children:E})]}),d&&A.jsx("div",{className:"border border-red-400/40 dark:border-red-500/40 bg-red-50 dark:bg-red-500/10 p-2",children:A.jsx("p",{className:"font-mono text-[11px] text-red-600 dark:text-[#f85149]",children:d})}),A.jsxs("div",{className:"flex items-center gap-3 border border-neutral-200 dark:border-[#30363d] bg-white dark:bg-[#0d1117] px-3 py-2.5",children:[A.jsxs("div",{className:"flex-1",children:[A.jsx("p",{className:"font-mono text-[12px] text-neutral-900 dark:text-[#e6edf3]",children:e("capsule.sandbox.runner.preventSleep")}),A.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-neutral-500 dark:text-[#8b949e]",children:e("capsule.sandbox.runner.preventSleepHint")}),!m&&!h.supported&&A.jsx("p",{className:"mt-1 font-mono text-[10px] text-amber-600 dark:text-[#d29922]",children:e("capsule.sandbox.runner.preventSleepUnsupported")})]}),A.jsx(ZR,{checked:h.enabled,onChange:C,disabled:m||!m&&!h.supported})]}),b&&A.jsx("div",{className:"border border-neutral-200 dark:border-[#30363d] bg-white dark:bg-[#0d1117] px-3 py-2.5",children:A.jsxs("div",{className:"flex items-start justify-between gap-3",children:[A.jsxs("div",{children:[A.jsx("p",{className:"font-mono text-[12px] text-neutral-900 dark:text-[#e6edf3]",children:e("capsule.sandbox.runner.computerUseTitle","Computer Use")}),A.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-neutral-500 dark:text-[#8b949e]",children:B}),!b.supported&&A.jsxs("div",{className:"mt-2 space-y-1.5 font-mono text-[10px] text-neutral-500 dark:text-[#8b949e]",children:[A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsxs("p",{children:[e("capsule.sandbox.runner.computerUsePermissionScreenCapture","屏幕录制"),":"," ",b.screen_capture_permission==="granted"?e("capsule.sandbox.runner.computerUsePermissionGranted","已授权"):b.screen_capture_permission==="denied"?e("capsule.sandbox.runner.computerUsePermissionDenied","未授权"):e("capsule.sandbox.runner.computerUsePermissionUnknown","未知")]}),b.screen_capture_permission==="denied"&&A.jsx("button",{onClick:()=>{V8n()},className:"border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] px-1.5 py-0.5 font-mono text-[10px] text-blue-600 dark:text-[#58a6ff] transition-colors hover:border-blue-500 dark:hover:border-[#58a6ff]",children:e("capsule.sandbox.runner.computerUseOpenSettings","打开设置")})]}),A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsxs("p",{children:[e("capsule.sandbox.runner.computerUsePermissionAccessibility","辅助功能"),":"," ",b.accessibility_permission==="granted"?e("capsule.sandbox.runner.computerUsePermissionGranted","已授权"):b.accessibility_permission==="denied"?e("capsule.sandbox.runner.computerUsePermissionDenied","未授权"):e("capsule.sandbox.runner.computerUsePermissionUnknown","未知")]}),b.accessibility_permission==="denied"&&A.jsx("button",{onClick:()=>{K8n()},className:"border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] px-1.5 py-0.5 font-mono text-[10px] text-blue-600 dark:text-[#58a6ff] transition-colors hover:border-blue-500 dark:hover:border-[#58a6ff]",children:e("capsule.sandbox.runner.computerUseOpenSettings","打开设置")})]})]})]}),A.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-2",children:[A.jsx("span",{className:`font-mono text-[10px] ${b.supported?"text-green-600 dark:text-[#3fb950]":"text-amber-600 dark:text-[#d29922]"}`,children:b.supported?e("capsule.sandbox.runner.computerUseAvailable","AVAILABLE"):e("capsule.sandbox.runner.computerUseUnavailableBadge","UNAVAILABLE")}),A.jsx("button",{onClick:()=>{vke().then(y).catch(N=>{y({supported:!1,platform:"unknown",screen_capture_permission:"unknown",accessibility_permission:"unknown",reason:String(N)})})},className:"border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] px-2 py-1 font-mono text-[10px] text-neutral-500 dark:text-[#8b949e] transition-colors hover:text-neutral-900 dark:hover:text-[#e6edf3]",children:e("capsule.sandbox.runner.computerUseRefresh","重新检查")})]})]})}),A.jsx("button",{onClick:k,className:`w-full px-3 py-2 font-mono text-[12px] font-semibold text-white transition-colors ${l?"border border-red-500 dark:border-[#da3633] bg-red-600 dark:bg-[#da3633] hover:bg-red-700 dark:hover:bg-[#f85149]":"border border-green-500 dark:border-[#3fb950] bg-green-600 dark:bg-[#238636] hover:bg-green-700 dark:hover:bg-[#2ea043]"}`,children:l?e("capsule.sandbox.runner.stopRunner","Stop Runner"):e("capsule.sandbox.runner.startRunner","Start Runner")}),!l&&A.jsxs(A.Fragment,{children:[A.jsx("div",{className:"border-t border-neutral-200 dark:border-[#21262d]"}),A.jsx("button",{onClick:t,className:"w-full border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] px-3 py-2 font-mono text-[12px] text-neutral-500 dark:text-[#8b949e] transition-colors hover:border-neutral-400 dark:hover:border-[#8b949e] hover:text-neutral-900 dark:hover:text-[#e6edf3]",children:e("capsule.sandbox.runner.generateToken")})]})]})}function vRt({onConnect:t}){return Bc()?A.jsx(f6r,{onConnect:t}):A.jsx(y6r,{onConnect:t})}function A6r(t){return`Please help me download and install Xyzen Runner on my machine.
|
|
608
|
+
`,children:U})]}),w&&Qi.createPortal(A.jsx(oRe,{x:w.x,y:w.y,onEdit:()=>l?.(t),onDelete:()=>u?.(t),onClose:()=>x(null),isDefaultAgent:D,isMarketplacePublished:e}),document.body)]})},b8r=({agent:t,isSelected:e=!1,status:n="idle",role:r,isMarketplacePublished:i=!1,onClick:o,onEdit:l,onDelete:u,isDragging:d=!1,sortMode:p=!1,onLongPress:m,wholeDragProps:g,style:h,setNodeRef:f})=>{const[b,y]=T.useState(null),v=t.tags?.some(x=>x.startsWith("default_")),_=XNt(m,p),w=x=>{if(_.isTracking()||_.didFire.current){x.preventDefault();return}!l&&!u||(x.preventDefault(),x.stopPropagation(),y({x:x.clientX,y:x.clientY}))};return A.jsxs(A.Fragment,{children:[A.jsxs("div",{ref:f,style:h,"data-agent-id":t.id,role:"button",tabIndex:0,"aria-pressed":e,onClick:()=>{d||_.didFire.current||p||o?.(t)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),!d&&!p&&o?.(t))},onContextMenu:w,..._.handlers,...p?g?.attributes:{},...p?g?.listeners:{},className:`w-full flex items-center gap-3 p-2 rounded-sm transition-all duration-200 group ${e?"bg-white/80 dark:bg-white/20 shadow-sm":"hover:bg-white/40 dark:hover:bg-white/10"} ${d?"shadow-xl z-50 cursor-grabbing":"cursor-pointer"} ${p&&!d?"agent-jiggle":""} ${p?"touch-none":""}`,children:[A.jsx("div",{className:"relative",children:A.jsx("img",{src:t.avatar||"https://api.dicebear.com/7.x/avataaars/svg?seed=default",alt:t.name,className:"w-10 h-10 rounded-full border border-white/50 object-cover"})}),A.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[A.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[A.jsx("div",{className:"truncate text-sm font-semibold text-neutral-800 dark:text-neutral-200",children:t.name}),n==="busy"&&A.jsx(eF,{status:"running",size:"xs",showLabel:!1,className:"shrink-0"})]}),r&&A.jsx("div",{className:"truncate text-[10px] text-neutral-500",children:r})]})]}),b&&(l||u)&&Qi.createPortal(A.jsx(oRe,{x:b.x,y:b.y,onEdit:()=>l?.(t),onDelete:()=>u?.(t),onClose:()=>y(null),isDefaultAgent:v,isMarketplacePublished:i}),document.body)]})},tF=t=>t.variant==="detailed"?A.jsx(A8r,{...t}):A.jsx(b8r,{...t}),y8r={hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.08,delayChildren:.1}}},eRt=({agent:t,variant:e,sortMode:n,onLongPress:r,isMarketplacePublished:i,lastConversationTime:o,activeTopicCount:l,isRootAgent:u,isSelected:d,status:p,role:m,onClick:g,onEdit:h,onDelete:f,isLoading:b})=>{const{attributes:y,listeners:v,setNodeRef:_,transform:w,transition:x,isDragging:k}=d8r({id:t.id,disabled:!n}),C={transform:Qx.Transform.toString(w),transition:x,opacity:k&&!n?.5:1},E=n?{attributes:y,listeners:v??{}}:void 0;return e==="detailed"?A.jsx(tF,{agent:t,variant:"detailed",isMarketplacePublished:i,lastConversationTime:o,activeTopicCount:l,isRootAgent:u,onClick:g,onEdit:h,onDelete:f,isLoading:b,isDragging:k,sortMode:n,onLongPress:r,wholeDragProps:E,style:C,setNodeRef:_}):A.jsx(tF,{agent:t,variant:"compact",isSelected:d,status:p,role:m,isMarketplacePublished:i,onClick:g,onEdit:h,onDelete:f,isDragging:k,sortMode:n,onLongPress:r,wholeDragProps:E,style:C,setNodeRef:_})},tRt=t=>{const{agents:e,variant:n,onAgentClick:r,loadingAgentId:i,sortable:o=!1,onReorder:l,onSortModeChange:u,rootAgentId:d}=t,{t:p}=Cn(),[m,g]=T.useState(e),[h,f]=T.useState(null),[b,y]=T.useState(!1),v=t.sortModeControlled!==void 0,_=v?t.sortModeControlled:b,w=T.useRef(!1);T.useEffect(()=>{if(w.current)return;const $=new Set(e.map(H=>H.id)),z=new Set(m.map(H=>H.id));($.size!==z.size||![...$].every(H=>z.has(H)))&&g(e)},[e]);const x=o?m:e,k=h?x.find($=>$.id===h):null,C=OSt(MBe(UBe,{activationConstraint:{distance:5}}),MBe(n2t,{activationConstraint:{distance:5}})),E=T.useCallback($=>{w.current=!0,f($.active.id)},[]),S=T.useCallback($=>{const{active:z,over:U}=$;w.current=!1,f(null),U&&z.id!==U.id&&g(H=>{const te=H.findIndex(oe=>oe.id===z.id),Z=H.findIndex(oe=>oe.id===U.id),ae=aRe(H,te,Z);return setTimeout(()=>{l?.(ae.map(oe=>oe.id))},0),ae})},[l]),I=T.useCallback(()=>{w.current=!1,f(null)},[]),B=T.useCallback(()=>{!o||v||(y(!0),u?.(!0))},[o,v,u]),N=T.useCallback(()=>{v||(y(!1),u?.(!1))},[v,u]),L=()=>{if(!k||_)return null;if(n==="detailed"){const{publishedAgentIds:te,lastConversationTimeByAgent:Z}=t;return A.jsx(tF,{agent:k,variant:"detailed",isMarketplacePublished:te?.has(k.id),lastConversationTime:Z?.[k.id],activeTopicCount:t.activeTopicCountByAgent?.[k.id],isRootAgent:k.id===d,isDragging:!0})}const{selectedAgentId:$,getAgentStatus:z,getAgentRole:U,publishedAgentIds:H}=t;return A.jsx(tF,{agent:k,variant:"compact",isSelected:k.id===$,status:z?.(k)??"idle",role:U?.(k),isMarketplacePublished:H?.has(k.id),isDragging:!0})},M=_&&!v&&A.jsx("div",{className:"fixed top-3 right-4 z-50",children:A.jsx("button",{onClick:N,className:"rounded-full bg-neutral-800 px-5 py-1.5 text-sm font-medium text-white shadow-lg active:scale-95 transition-transform dark:bg-neutral-200 dark:text-neutral-900",children:p("common.done",{defaultValue:"Done"})})});if(n==="detailed"){const{publishedAgentIds:$,lastConversationTimeByAgent:z,activeTopicCountByAgent:U,onEdit:H,onDelete:te}=t,Z=A.jsx(Ct.div,{className:"divide-y divide-neutral-100 dark:divide-neutral-800",variants:y8r,initial:"hidden",animate:"visible",children:x.map(ae=>o?A.jsx(eRt,{agent:ae,variant:"detailed",sortMode:_,onLongPress:v?void 0:B,isMarketplacePublished:$?.has(ae.id),lastConversationTime:z?.[ae.id],activeTopicCount:U?.[ae.id],isRootAgent:ae.id===d,onClick:r,onEdit:H,onDelete:te,isLoading:i===ae.id},ae.id):A.jsx(tF,{agent:ae,variant:"detailed",isMarketplacePublished:$?.has(ae.id),lastConversationTime:z?.[ae.id],activeTopicCount:U?.[ae.id],isRootAgent:ae.id===d,onClick:r,onEdit:H,onDelete:te,isLoading:i===ae.id},ae.id))});return o?A.jsxs(Toe,{sensors:C,collisionDetection:QSt,onDragStart:E,onDragEnd:S,onDragCancel:I,children:[A.jsx(KNt,{items:x.map(ae=>ae.id),strategy:WNt,children:Z}),M,Qi.createPortal(A.jsx(YBe,{children:L()}),document.body)]}):Z}const{selectedAgentId:R,getAgentStatus:D,getAgentRole:P,publishedAgentIds:O,onEdit:F,onDelete:Q}=t,j=A.jsx("div",{className:"space-y-1",children:x.map($=>o?A.jsx(eRt,{agent:$,variant:"compact",sortMode:_,onLongPress:v?void 0:B,isSelected:$.id===R,status:D?.($)??"idle",role:P?.($),isMarketplacePublished:O?.has($.id),onClick:r,onEdit:F,onDelete:Q},$.id):A.jsx(tF,{agent:$,variant:"compact",isSelected:$.id===R,status:D?.($)??"idle",role:P?.($),isMarketplacePublished:O?.has($.id),onClick:r,onEdit:F,onDelete:Q},$.id))});return o?A.jsxs(Toe,{sensors:C,collisionDetection:QSt,onDragStart:E,onDragEnd:S,onDragCancel:I,children:[A.jsx(KNt,{items:x.map($=>$.id),strategy:WNt,children:j}),M,Qi.createPortal(A.jsx(YBe,{children:L()}),document.body)]}):j};function v8r(){const{capsuleOpen:t,capsuleActiveTab:e,setCapsuleOpen:n,setCapsuleActiveTab:r}=Un(Wo(u=>({capsuleOpen:u.capsuleOpen,capsuleActiveTab:u.capsuleActiveTab,setCapsuleOpen:u.setCapsuleOpen,setCapsuleActiveTab:u.setCapsuleActiveTab}))),i=T.useCallback(u=>{n(!0),u&&r(u)},[n,r]),o=T.useCallback(()=>{n(!1)},[n]),l=T.useCallback(u=>{t?n(!1):(n(!0),u&&r(u))},[t,n,r]);return{isOpen:t,activeTab:e,setActiveTab:r,open:i,close:o,toggle:l}}class _8r{maxConcurrency;active=new Map;queue=[];constructor(e){this.maxConcurrency=e}enqueue(e,n,r){let i,o;const l=new Promise((p,m)=>{i=p,o=m}),u={id:e,onStart:n,execute:r,resolve:i,reject:o};return this.queue.push(u),this.tryNext(),{promise:l.then(p=>p.promise),abort:()=>{const p=this.queue.findIndex(g=>g.id===e);if(p!==-1){this.queue.splice(p,1),o(new Error("Upload cancelled"));return}const m=this.active.get(e);m&&m.abort()}}}cancel(e){const n=this.queue.findIndex(i=>i.id===e);if(n!==-1){this.queue.splice(n,1)[0].reject(new Error("Upload cancelled"));return}const r=this.active.get(e);r&&r.abort()}cancelAll(){for(const e of this.queue)e.reject(new Error("Upload cancelled"));this.queue=[];for(const e of this.active.values())e.abort()}tryNext(){for(;this.active.size<this.maxConcurrency&&this.queue.length>0;){const e=this.queue.shift();e.onStart();const n=e.execute();this.active.set(e.id,n),e.resolve(n),n.promise.finally(()=>{this.active.delete(e.id),this.tryNext()})}}}const nRt=new _8r(3);function rRt({...t}){return A.jsx(Dne,{"data-slot":"dialog",...t})}function w8r({...t}){return A.jsx(Nne,{"data-slot":"dialog-portal",...t})}function x8r({className:t,...e}){return A.jsx(Rne,{"data-slot":"dialog-overlay",className:Yt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1100] bg-black/50",t),...e})}function aRt({className:t,children:e,showCloseButton:n=!0,...r}){return A.jsxs(w8r,{"data-slot":"dialog-portal",children:[A.jsx(x8r,{}),A.jsxs(Lne,{"data-slot":"dialog-content",className:Yt("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-[1100] grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",t),...r,children:[e,n&&A.jsxs(Mne,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[A.jsx(k1,{}),A.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function k8r({className:t,...e}){return A.jsx("div",{"data-slot":"dialog-header",className:Yt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function E8r({className:t,...e}){return A.jsx("div",{"data-slot":"dialog-footer",className:Yt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function iRt({className:t,...e}){return A.jsx(k1e,{"data-slot":"dialog-title",className:Yt("text-lg leading-none font-semibold",t),...e})}function C8r({className:t,...e}){return A.jsx(E1e,{"data-slot":"dialog-description",className:Yt("text-muted-foreground text-sm",t),...e})}function S8r({isOpen:t,onClose:e,onConfirm:n,title:r,message:i,initialValue:o="",placeholder:l="",confirmLabel:u="Confirm",cancelLabel:d="Cancel",className:p}){const[m,g]=T.useState(o);T.useEffect(()=>{t&&g(o)},[t,o]);const h=()=>{m.trim()&&(n(m.trim()),e())},f=b=>{b.key==="Enter"&&(b.preventDefault(),h())};return A.jsx(rRt,{open:t,onOpenChange:b=>!b&&e(),children:A.jsxs(aRt,{className:Yt("space-y-4 border border-neutral-200/20 bg-white/95 shadow-2xl shadow-black/20 backdrop-blur-xl dark:border-neutral-700/30 dark:bg-neutral-900/95 dark:shadow-black/40","p-6 sm:p-6 rounded-sm w-full max-w-md",p),children:[A.jsxs(k8r,{children:[A.jsx(iRt,{className:"text-lg font-bold text-neutral-900 dark:text-neutral-100",children:r}),i&&A.jsx(C8r,{className:"text-sm text-neutral-600 dark:text-neutral-400",children:i})]}),A.jsx("div",{className:"py-2",children:A.jsx(Hc,{type:"text",placeholder:l||"Input",value:m,onChange:b=>g(b.target.value),onKeyDown:f,autoFocus:!0})}),A.jsxs(E8r,{children:[A.jsx("button",{onClick:e,className:"inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-semibold text-neutral-900 hover:bg-neutral-100 dark:text-neutral-100 dark:hover:bg-neutral-800 transition-colors",children:d}),A.jsx("button",{onClick:h,className:"inline-flex items-center justify-center rounded-md bg-indigo-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 dark:bg-indigo-500 dark:hover:bg-indigo-400",children:u})]})]})})}const I8r=ee.memo(S8r),oRt=({isOpen:t,onClose:e,title:n,message:r,type:i="info",actionLabel:o,onAction:l})=>{const u=()=>{switch(i){case"warning":return{icon:Ag,bgColor:"bg-yellow-100",iconColor:"text-yellow-600",buttonColor:"bg-yellow-600 data-[hover]:bg-yellow-500 dark:bg-yellow-500 dark:data-[hover]:bg-yellow-400"};case"error":return{icon:tU,bgColor:"bg-red-100",iconColor:"text-red-600",buttonColor:"bg-red-600 data-[hover]:bg-red-500 dark:bg-red-500 dark:data-[hover]:bg-red-400"};case"success":return{icon:nc,bgColor:"bg-green-100",iconColor:"text-green-600",buttonColor:"bg-green-600 data-[hover]:bg-green-500 dark:bg-green-500 dark:data-[hover]:bg-green-400"};default:return{icon:pu,bgColor:"bg-blue-100",iconColor:"text-blue-600",buttonColor:"bg-blue-600 data-[hover]:bg-blue-500 dark:bg-blue-500 dark:data-[hover]:bg-blue-400"}}},{icon:d,bgColor:p,iconColor:m,buttonColor:g}=u();return A.jsxs(P0t,{open:t,onClose:e,className:`relative ${i_.max}`,children:[A.jsx(O0t,{className:"fixed inset-0 bg-black/50 backdrop-blur-sm"}),A.jsx("div",{className:"fixed inset-0 flex w-screen items-center justify-center p-4",children:A.jsxs(F0t,{from:"top",className:"w-full max-w-md space-y-4 rounded-sm border border-neutral-200/20 bg-white/95 p-8 shadow-2xl shadow-black/20 backdrop-blur-xl dark:border-neutral-700/30 dark:bg-neutral-900/95 dark:shadow-black/40",children:[A.jsx(Q0t,{className:"text-lg font-bold text-neutral-900 dark:text-neutral-100",children:n}),A.jsx("div",{className:"mt-4",children:A.jsxs("div",{className:"flex items-start",children:[A.jsx("div",{className:`mx-auto flex h-12 w-12 shrink-0 items-center justify-center rounded-full ${p} sm:mx-0 sm:h-10 sm:w-10`,children:A.jsx(d,{className:`h-6 w-6 ${m}`,"aria-hidden":"true"})}),A.jsx("div",{className:"mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left",children:A.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:r})})]})}),A.jsx("div",{className:"mt-6 flex justify-end gap-4",children:o&&l?A.jsxs(A.Fragment,{children:[A.jsx(qc,{type:"button",onClick:e,className:"inline-flex items-center gap-2 rounded-sm bg-neutral-100 py-1.5 px-3 text-sm/6 font-semibold text-neutral-700 shadow-sm focus:outline-none data-[hover]:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-200 dark:data-[hover]:bg-neutral-700",children:"Close"}),A.jsx(qc,{type:"button",onClick:()=>{l(),e()},className:`inline-flex items-center gap-2 rounded-sm py-1.5 px-3 text-sm/6 font-semibold text-white shadow-inner shadow-white/10 focus:outline-none ${g}`,children:o})]}):A.jsx(qc,{type:"button",onClick:e,className:`inline-flex items-center gap-2 rounded-sm py-1.5 px-3 text-sm/6 font-semibold text-white shadow-inner shadow-white/10 focus:outline-none ${g}`,children:"OK"})})]})})]})},T8r=({url:t,className:e})=>A.jsx("div",{className:`flex h-full w-full items-center justify-center ${e}`,children:A.jsx("audio",{src:t,controls:!0,className:"w-full max-w-md"})}),B8r=({file:t,url:e,className:n})=>A.jsx("div",{className:`flex h-full w-full items-center justify-center ${n}`,children:A.jsx("img",{src:e,alt:t.name,className:"max-h-full max-w-full object-contain"})}),sRt=({url:t,className:e})=>{const[n,r]=T.useState(""),[i,o]=T.useState(!0),[l,u]=T.useState(null);return T.useEffect(()=>{const d=new AbortController;return t&&(async()=>{o(!0),u(null);try{const m=await fetch(t,{signal:d.signal});if(!m.ok)throw new Error(`Failed to load markdown: ${m.status} ${m.statusText}`);const g=await m.text();d.signal.aborted||(r(g),o(!1))}catch(m){d.signal.aborted||(console.error("Failed to load markdown content:",m),u("Failed to load content"),o(!1))}})(),()=>{d.abort()}},[t]),i?A.jsx("div",{className:"text-neutral-400 p-6",children:"Loading markdown..."}):l?A.jsx("div",{className:"text-red-400 p-6",children:l}):A.jsx("div",{className:`h-full w-full overflow-auto bg-white dark:bg-neutral-800 p-6 rounded-md ${e}`,children:A.jsx(If,{content:n})})},D8r=({url:t,className:e})=>{const n=Un(l=>l.token),r=T.useRef(null),i=T.useRef(null),o=T.useRef(null);return T.useEffect(()=>!t||!r.current?void 0:((async()=>{try{let u=t;if(!t.startsWith("blob:")&&!t.startsWith("http://")&&!t.startsWith("https://")&&!t.startsWith("data:")){const d=await fetch(t,{headers:n?{Authorization:`Bearer ${n}`}:{}});if(!d.ok){console.error(`[PdfRenderer] Failed to load PDF: ${d.status} ${d.statusText}`);return}const p=await d.blob(),m=URL.createObjectURL(p);o.current=m,u=m}try{const g=(await(await(await Promise.resolve().then(()=>o1a)).getDocument(u).promise).getPage(1)).getViewport({scale:1}),h=g.width>g.height;console.log(`[PdfRenderer] PDF orientation: ${h?"landscape":"portrait"}`)}catch(d){console.warn("[PdfRenderer] Could not detect PDF orientation:",d)}r.current&&(r.current.src=u)}catch(u){console.error("[PdfRenderer] Error loading PDF:",u)}})(),()=>{o.current&&(URL.revokeObjectURL(o.current),o.current=null)}),[t,n]),A.jsx("div",{ref:i,className:`pdf-viewer-container h-full w-full overflow-auto ${e}`,children:A.jsx("iframe",{ref:r,className:"h-full w-full border-0",title:"PDF Preview",scrolling:"no"})})},N8r=({url:t,className:e})=>A.jsx("div",{className:`flex h-full w-full items-center justify-center ${e}`,children:A.jsx("video",{src:t,controls:!0,className:"max-h-full max-w-full"})});function R8r(){return A.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4 p-8",children:[A.jsx("div",{className:"animate-pulse rounded-lg bg-neutral-200/60 p-6 dark:bg-white/[0.06]",children:A.jsx("svg",{className:"h-16 w-16 text-neutral-300 dark:text-neutral-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909M3.75 21h16.5A2.25 2.25 0 0 0 22.5 18.75V5.25A2.25 2.25 0 0 0 20.25 3H3.75A2.25 2.25 0 0 0 1.5 5.25v13.5A2.25 2.25 0 0 0 3.75 21Z"})})}),A.jsx("div",{className:"h-2 w-32 animate-pulse rounded-full bg-neutral-200/60 dark:bg-white/[0.06]"})]})}const L8r=({isOpen:t,onClose:e,file:n})=>{const[r,i]=T.useState(null),[o,l]=T.useState(!1),[u,d]=T.useState(null);T.useEffect(()=>{if(t&&n){let h=!0;return(async()=>{l(!0),d(null);try{if(n.url&&(n.url.startsWith("blob:")||n.url.startsWith("data:"))){i(n.url),l(!1);return}const y=await(await ys.downloadRaw(n.id)).blob(),v=URL.createObjectURL(y);h?i(v):URL.revokeObjectURL(v)}catch(b){if(console.error(b),h){const y=b instanceof Error?b.message:"Failed to load file preview";d(y)}}finally{h&&l(!1)}})(),()=>{h=!1,r&&(URL.revokeObjectURL(r),i(null))}}else i(null)},[t,n]);const p=n?.type.toLowerCase()==="application/pdf",m=A.jsxs("div",{className:"flex items-center gap-1.5",children:[r&&A.jsx("a",{href:r,download:n?.name,className:"rounded-lg bg-black/40 p-2 text-white/80 backdrop-blur-md transition-colors hover:bg-black/60 hover:text-white",title:"Download",children:A.jsx(mR,{className:"h-4 w-4"})}),A.jsx("button",{onClick:e,className:"rounded-lg bg-black/40 p-2 text-white/80 backdrop-blur-md transition-colors hover:bg-black/60 hover:text-white",title:"Close",children:A.jsx(Yl,{className:"h-4 w-4"})})]}),g=()=>{if(o)return A.jsx(R8r,{});if(u)return A.jsx("div",{className:"flex h-full items-center justify-center p-8",children:A.jsx("div",{className:"text-[13px] text-red-500",children:u})});if(!n||!r)return null;const h=n.type.toLowerCase();return h.startsWith("image/")?A.jsx(B8r,{file:n,url:r}):h.startsWith("video/")?A.jsx(N8r,{file:n,url:r}):h.startsWith("audio/")?A.jsx(T8r,{file:n,url:r}):h==="application/pdf"?A.jsx(D8r,{file:n,url:r}):h==="text/markdown"||h==="text/plain"||n.name.endsWith(".md")||n.name.endsWith(".txt")?A.jsx(sRt,{file:n,url:r}):A.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 text-neutral-700 dark:text-neutral-300",children:[A.jsx("p",{className:"text-[13px]",children:"Preview not available for this file type."}),A.jsx("a",{href:r,download:n.name,className:"rounded-lg bg-indigo-500 px-4 py-2 text-[13px] font-semibold text-white hover:bg-indigo-600 dark:hover:bg-indigo-400",title:"Download",children:"Download File"})]})};return A.jsx(Gc,{isOpen:t,onClose:e,desktopClassName:"md:h-[85vh] md:max-w-5xl",children:A.jsxs("div",{className:"relative flex min-h-[60vh] flex-1 flex-col overflow-hidden md:min-h-0",children:[!p&&A.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-neutral-200/60 bg-black/85 px-4 py-3 text-white backdrop-blur-md md:hidden dark:border-neutral-800/60",children:[A.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-white/90",children:n?.name}),m]}),!p&&A.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 hidden items-center justify-between px-4 pt-4 md:flex",children:[A.jsx("span",{className:"pointer-events-auto max-w-[70%] truncate rounded-lg bg-black/40 px-3 py-1.5 text-xs font-medium text-white/90 backdrop-blur-md",children:n?.name}),A.jsx("div",{className:"pointer-events-auto",children:m})]}),A.jsx("div",{className:"relative flex min-h-0 flex-1 items-center justify-center overflow-hidden",children:g()})]})})},lRt={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",swift:"swift",sh:"shell",bash:"shell",zsh:"shell",json:"json",yaml:"yaml",yml:"yaml",toml:"ini",xml:"xml",html:"html",htm:"html",css:"css",scss:"scss",less:"less",md:"markdown",sql:"sql",dockerfile:"dockerfile",makefile:"plaintext",graphql:"graphql",prisma:"plaintext",env:"plaintext",txt:"plaintext"};function M8r(t){const e=t.toLowerCase();if(e==="dockerfile")return"dockerfile";if(e==="makefile")return"plaintext";const n=e.split(".").pop()??"";return lRt[n]??"plaintext"}const P8r=new Set(["application/json","application/xml","application/yaml","application/x-yaml","application/javascript","application/typescript","application/xhtml+xml","application/sql","application/graphql","application/toml"]);function cRt(t,e){const n=t.toLowerCase();return!!(n==="dockerfile"||n==="makefile"||(n.split(".").pop()??"")in lRt||e&&(e.startsWith("text/")||P8r.has(e)))}var sRe=new Map,lle=new WeakMap,uRt=0,O8r;function F8r(t){return t?(lle.has(t)||(uRt+=1,lle.set(t,uRt.toString())),lle.get(t)):"0"}function Q8r(t){return Object.keys(t).sort().filter(e=>t[e]!==void 0).map(e=>`${e}_${e==="root"?F8r(t.root):t[e]}`).toString()}function $8r(t){const e=Q8r(t);let n=sRe.get(e);if(!n){const r=new Map;let i;const o=new IntersectionObserver(l=>{l.forEach(u=>{var d;const p=u.isIntersecting&&i.some(m=>u.intersectionRatio>=m);t.trackVisibility&&typeof u.isVisible>"u"&&(u.isVisible=p),[...(d=r.get(u.target))!=null?d:[]].forEach(m=>{m(p,u)})})},t);i=o.thresholds||(Array.isArray(t.threshold)?t.threshold:[t.threshold||0]),n={id:e,observer:o,elements:r},sRe.set(e,n)}return n}function j8r(t,e,n={},r=O8r){if(typeof window.IntersectionObserver>"u"&&r!==void 0){const d=t.getBoundingClientRect();return e(r,{isIntersecting:r,target:t,intersectionRatio:typeof n.threshold=="number"?n.threshold:0,time:0,boundingClientRect:d,intersectionRect:d,rootBounds:d}),()=>{}}const{id:i,observer:o,elements:l}=$8r(n),u=l.get(t)||[];return l.has(t)||l.set(t,u),u.push(e),o.observe(t),function(){u.splice(u.indexOf(e),1),u.length===0&&(l.delete(t),o.unobserve(t)),l.size===0&&(o.disconnect(),sRe.delete(i))}}function cle({threshold:t,delay:e,trackVisibility:n,rootMargin:r,root:i,triggerOnce:o,skip:l,initialInView:u,fallbackInView:d,onChange:p}={}){var m;const[g,h]=ee.useState(null),f=ee.useRef(p),b=ee.useRef(u),[y,v]=ee.useState({inView:!!u,entry:void 0});f.current=p,ee.useEffect(()=>{if(b.current===void 0&&(b.current=u),l||!g)return;let k;return k=j8r(g,(C,E)=>{const S=b.current;b.current=C,!(S===void 0&&!C)&&(v({inView:C,entry:E}),f.current&&f.current(C,E),E.isIntersecting&&o&&k&&(k(),k=void 0))},{root:i,rootMargin:r,threshold:t,trackVisibility:n,delay:e},d),()=>{k&&k()}},[Array.isArray(t)?t.toString():t,g,i,r,o,l,n,d,e]);const _=(m=y.entry)==null?void 0:m.target,w=ee.useRef(void 0);!g&&_&&!o&&!l&&w.current!==_&&(w.current=_,v({inView:!!u,entry:void 0}),b.current=u);const x=[h,y.inView,y.entry];return x.ref=x[0],x.inView=x[1],x.entry=x[2],x}const z8r=({type:t,item:e,position:n,onClose:r,onRename:i,onDelete:o,onMove:l,onDownload:u,onEdit:d,onPreview:p,onOpen:m,onAddToKnowledgeSet:g,onRemoveFromKnowledgeSet:h,onRestore:f,onBulkDelete:b,onBulkMove:y,isInKnowledgeSetView:v=!1,isTrashView:_=!1,selectedCount:w=1})=>{const{t:x}=Cn(),k=T.useRef(null),[C,E]=T.useState(n);return T.useEffect(()=>{const S=I=>{k.current&&!k.current.contains(I.target)&&r()};return document.addEventListener("pointerdown",S),()=>{document.removeEventListener("pointerdown",S)}},[r]),T.useEffect(()=>{if(k.current){const S=k.current.getBoundingClientRect();let{x:I,y:B}=n;I+S.width>window.innerWidth&&(I=window.innerWidth-S.width-10),B+S.height>window.innerHeight&&(B=window.innerHeight-S.height-10),E({x:I,y:B})}},[n]),_?Qi.createPortal(A.jsx("div",{ref:k,className:"fixed z-50 min-w-40 rounded-lg border border-neutral-200 bg-white p-1.5 shadow-lg dark:border-neutral-800 dark:bg-neutral-900",style:{top:C.y,left:C.x},children:A.jsx("div",{className:"flex flex-col gap-0.5",children:w>1?A.jsxs(A.Fragment,{children:[f&&A.jsxs("button",{onClick:()=>{f(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(X0t,{className:"h-4 w-4"}),x("knowledge.contextMenu.restoreSelected",{count:w})]}),A.jsx("div",{className:"my-1 h-px bg-neutral-200 dark:bg-neutral-800"}),b&&A.jsxs("button",{onClick:()=>{b(),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20",children:[A.jsx(Rl,{className:"h-4 w-4"}),x("knowledge.contextMenu.deleteSelected",{count:w})]})]}):A.jsxs(A.Fragment,{children:[f&&A.jsxs("button",{onClick:()=>{f(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(X0t,{className:"h-4 w-4"}),x("knowledge.contextMenu.restore")]}),A.jsx("div",{className:"my-1 h-px bg-neutral-200 dark:bg-neutral-800"}),o&&A.jsxs("button",{onClick:()=>{o(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20",children:[A.jsx(Rl,{className:"h-4 w-4"}),x("knowledge.contextMenu.deleteForever")]})]})})}),document.body):w>1?Qi.createPortal(A.jsx("div",{ref:k,className:"fixed z-50 min-w-40 rounded-lg border border-neutral-200 bg-white p-1.5 shadow-lg dark:border-neutral-800 dark:bg-neutral-900",style:{top:C.y,left:C.x},children:A.jsxs("div",{className:"flex flex-col gap-0.5",children:[y&&A.jsxs("button",{onClick:()=>{y(),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(tyt,{className:"h-4 w-4"}),x("knowledge.contextMenu.moveSelected",{count:w})]}),A.jsx("div",{className:"my-1 h-px bg-neutral-200 dark:bg-neutral-800"}),b&&A.jsxs("button",{onClick:()=>{b(),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20",children:[A.jsx(Rl,{className:"h-4 w-4"}),x("knowledge.contextMenu.deleteSelected",{count:w})]})]})}),document.body):Qi.createPortal(A.jsx("div",{ref:k,className:"fixed z-50 min-w-40 rounded-lg border border-neutral-200 bg-white p-1.5 shadow-lg dark:border-neutral-800 dark:bg-neutral-900",style:{top:C.y,left:C.x},children:A.jsxs("div",{className:"flex flex-col gap-0.5",children:[t==="folder"&&m&&A.jsxs("button",{onClick:()=>{m(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(m2e,{className:"h-4 w-4"}),x("knowledge.contextMenu.open")]}),t==="file"&&p&&A.jsxs("button",{onClick:()=>{p(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(NI,{className:"h-4 w-4"}),x("knowledge.contextMenu.preview")]}),t==="file"&&d&&A.jsxs("button",{onClick:()=>{d(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(Wir,{className:"h-4 w-4"}),x("knowledge.contextMenu.edit")]}),t==="file"&&u&&A.jsxs("button",{onClick:()=>{u(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(mR,{className:"h-4 w-4"}),x("knowledge.contextMenu.download")]}),t==="folder"&&m||t==="file"&&(p||d||u)?A.jsx("div",{className:"my-1 h-px bg-neutral-200 dark:bg-neutral-800"}):null,i&&A.jsxs("button",{onClick:()=>{i(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(wf,{className:"h-4 w-4"}),x("knowledge.contextMenu.rename")]}),l&&A.jsxs("button",{onClick:()=>{l(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(tyt,{className:"h-4 w-4"}),x("knowledge.contextMenu.moveTo")]}),g&&!v&&A.jsxs("button",{onClick:()=>{g(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(Dd,{className:"h-4 w-4"}),x("knowledge.contextMenu.addToKnowledgeSet")]}),h&&v&&A.jsxs("button",{onClick:()=>{h(e),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(qor,{className:"h-4 w-4"}),x("knowledge.contextMenu.removeFromKnowledgeSet")]}),A.jsx("div",{className:"my-1 h-px bg-neutral-200 dark:bg-neutral-800"}),o&&A.jsxs("button",{onClick:()=>{o(e,t),r()},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20",children:[A.jsx(Rl,{className:"h-4 w-4"}),x("knowledge.contextMenu.delete")]})]})}),document.body)};var U8r=(t,e,n,r,i,o,l,u)=>{let d=document.documentElement,p=["light","dark"];function m(f){(Array.isArray(t)?t:[t]).forEach(b=>{let y=b==="class",v=y&&o?i.map(_=>o[_]||_):i;y?(d.classList.remove(...v),d.classList.add(o&&o[f]?o[f]:f)):d.setAttribute(b,f)}),g(f)}function g(f){u&&p.includes(f)&&(d.style.colorScheme=f)}function h(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)m(r);else try{let f=localStorage.getItem(e)||n,b=l&&f==="system"?h():f;m(b)}catch{}},q8r=ee.createContext(void 0),G8r={setTheme:t=>{},themes:[]},ule=()=>{var t;return(t=ee.useContext(q8r))!=null?t:G8r};ee.memo(({forcedTheme:t,storageKey:e,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:o,value:l,themes:u,nonce:d,scriptProps:p})=>{let m=JSON.stringify([n,e,o,t,u,l,r,i]).slice(1,-1);return ee.createElement("script",{...p,suppressHydrationWarning:!0,nonce:typeof window>"u"?d:"",dangerouslySetInnerHTML:{__html:`(${U8r.toString()})(${m})`}})});const H8r=1500;function W8r({isOpen:t,onClose:e,file:n,onLoadContent:r,onSaveContent:i,readonly:o=!1}){const{t:l}=Cn(),{resolvedTheme:u}=ule(),d=T.useRef(null),p=T.useRef(null),[m,g]=T.useState(!0),[h,f]=T.useState(null),[b,y]=T.useState("idle"),v=T.useRef(""),_=T.useRef(null),w=T.useRef(null),x=M8r(n.name);T.useEffect(()=>()=>{_.current&&clearTimeout(_.current),w.current&&clearTimeout(w.current)},[]),T.useEffect(()=>{if(!t)return;let E=!1;return g(!0),f(null),y("idle"),r(n.id).then(S=>S.text()).then(S=>{E||(v.current=S,g(!1),p.current&&p.current.setValue(S))}).catch(S=>{E||(f(S instanceof Error?S.message:l("knowledge.fileEditor.loadError")),g(!1))}),()=>{E=!0}},[t,n.id]);const k=T.useCallback(async()=>{if(!p.current||o)return;const E=p.current.getValue();if(E!==v.current){y("saving"),w.current&&(clearTimeout(w.current),w.current=null);try{await i(n.id,E),v.current=E,y("saved"),w.current=setTimeout(()=>y("idle"),2e3)}catch{y("error"),w.current=setTimeout(()=>y("idle"),3e3)}}},[n.id,i,o]),C=T.useCallback(()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{k()},H8r)},[k]);return T.useEffect(()=>{if(!t||m||h||!d.current||p.current)return;const E=u==="light"?"vs":"vs-dark",S=g1.editor.create(d.current,{value:v.current,language:x,theme:E,automaticLayout:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",readOnly:o,fontSize:13,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",padding:{top:12,bottom:12},bracketPairColorization:{enabled:!0},folding:!0,wordWrap:"on",tabSize:2});return p.current=S,S.onDidChangeModelContent(()=>{o||C()}),S.addCommand(g1.KeyMod.CtrlCmd|g1.KeyCode.KeyS,()=>{o||(_.current&&clearTimeout(_.current),k())}),()=>{S.dispose(),p.current=null}},[t,m,h,x,o]),T.useEffect(()=>{if(p.current){const E=u==="light"?"vs":"vs-dark";g1.editor.setTheme(E)}},[u]),T.useEffect(()=>{if(!t&&p.current){if(_.current){clearTimeout(_.current),_.current=null;const E=p.current.getValue();E!==v.current&&(i(n.id,E).catch(()=>{}),v.current=E)}p.current.dispose(),p.current=null}},[t]),A.jsxs(Gc,{isOpen:t,onClose:e,size:"full",children:[A.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-neutral-200/60 px-5 pb-3 pt-5 dark:border-neutral-800/60",children:[A.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[A.jsx("h2",{className:"truncate text-lg font-semibold text-neutral-900 dark:text-white",children:n.name}),A.jsx("span",{className:"shrink-0 rounded bg-neutral-100/80 px-1.5 py-0.5 text-xs text-neutral-500 dark:bg-white/[0.06] dark:text-neutral-400",children:x})]}),A.jsxs("div",{className:"flex items-center gap-2.5",children:[!o&&A.jsx(Y8r,{status:b}),A.jsx("button",{onClick:e,className:"rounded-lg bg-neutral-100/80 px-4 py-2 text-[13px] font-semibold text-neutral-700 hover:bg-neutral-200/80 dark:bg-white/[0.06] dark:text-neutral-300 dark:hover:bg-white/[0.1]",children:l("common.close")})]})]}),A.jsxs("div",{className:"flex-1 overflow-hidden",children:[m&&A.jsx("div",{className:"flex h-full items-center justify-center text-[13px] text-neutral-400",children:"Loading..."}),h&&A.jsx("div",{className:"flex h-full items-center justify-center text-[13px] text-red-500",children:h}),!m&&!h&&A.jsx("div",{ref:d,className:"h-full w-full"})]})]})}function Y8r({status:t}){const{t:e}=Cn();return t==="idle"?null:A.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-neutral-400 dark:text-neutral-500",children:[t==="saving"&&A.jsxs(A.Fragment,{children:[A.jsx("svg",{className:"h-3.5 w-3.5 animate-spin",viewBox:"0 0 16 16",fill:"none",children:A.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:"28",strokeDashoffset:"8"})}),e("knowledge.fileEditor.saving")]}),t==="saved"&&A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"}),e("knowledge.fileEditor.autoSaved")]}),t==="error"&&A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),e("knowledge.fileEditor.saveError")]})]})}const V8r=t=>t.split(".").pop()?.toLowerCase()||"",Kq=({filename:t,mimeType:e,className:n="h-6 w-6"})=>{const r=V8r(t),i=(o,l)=>A.jsx("div",{className:`flex items-center justify-center rounded-lg ${n}`,children:A.jsx(o,{className:`h-full w-full ${l}`})});if(e.startsWith("image/")||["jpg","jpeg","png","gif","webp","svg"].includes(r))return i(Eyt,"text-purple-500");if(e.startsWith("audio/")||["mp3","wav","ogg","m4a"].includes(r))return i(alr,"text-pink-500");if(e.startsWith("video/")||["mp4","mov","avi","mkv"].includes(r))return i(Xsr,"text-rose-500");switch(r){case"pdf":return i(wyt,"text-red-500");case"doc":case"docx":return i(Ksr,"text-blue-500");case"xls":case"xlsx":case"csv":return i(hlr,"text-green-500");case"ppt":case"pptx":return i(ulr,"text-orange-500");case"txt":case"md":case"json":return i(wyt,"text-neutral-500");case"zip":case"rar":case"7z":case"tar":case"gz":return i(zsr,"text-yellow-500");case"js":case"ts":case"jsx":case"tsx":case"py":case"html":case"css":return i(Wsr,"text-slate-600");default:return i(olr,"text-neutral-400")}},K8r=({item:t,depth:e,isSelected:n,isDragging:r=!1,isDropTarget:i=!1,indentationWidth:o=$0t,isEditing:l=!1,onEditConfirm:u,onEditCancel:d,onCollapse:p,onClick:m,onDoubleClick:g,onContextMenu:h,registerRef:f})=>{const{attributes:b,listeners:y,setNodeRef:v}=g2t({id:t.id,disabled:l}),{setNodeRef:_}=f2t({id:t.id}),w=T.useRef(null),x=T.useRef(null),k=T.useRef(!1),C=T.useCallback(()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null),x.current=null},[]);T.useEffect(()=>C,[C]);const E=T.useCallback(B=>{if(l)return;k.current=!1;const N=B.touches[0];x.current={x:N.clientX,y:N.clientY},C();const{clientX:L,clientY:M}=N;w.current=window.setTimeout(()=>{k.current=!0,iRe(),h?.({preventDefault:()=>{},stopPropagation:()=>{},clientX:L,clientY:M})},550)},[l,C,h]),S=T.useCallback(B=>{const N=x.current;if(!N)return;const L=B.touches[0];Math.hypot(L.clientX-N.x,L.clientY-N.y)>10&&C()},[C]),I=T.useCallback(()=>{C()},[C]);return A.jsx("div",{ref:B=>{v(B),_(B),f?.(t.id,B)},style:{opacity:r?.4:1},...l?{}:b,...l?{}:y,onTouchStart:E,onTouchMove:S,onTouchEnd:I,onTouchCancel:I,onMouseDown:B=>{B.stopPropagation()},onClick:B=>{if(k.current){k.current=!1;return}l||(m?.(B,t.id),t.type==="folder"&&p?.(t.id))},onDoubleClick:()=>{l||g?.(t.id)},onContextMenu:l?void 0:h,children:A.jsx(dRt,{item:t,depth:e,isSelected:n,isDropTarget:i,indentationWidth:o,isEditing:l,onEditConfirm:u,onEditCancel:d})})},Z8r=({item:t,childCount:e})=>A.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-lg border border-neutral-200 bg-white px-2.5 py-1.5 shadow-lg dark:border-neutral-700 dark:bg-neutral-900 max-w-64 pointer-events-none",children:[A.jsx("span",{className:"shrink-0 text-yellow-400 dark:text-yellow-500",children:t.type==="folder"?A.jsx(Bke,{className:"h-4 w-4"}):A.jsx(Kq,{filename:t.name,mimeType:t.file?.content_type||"",className:"h-4 w-4"})}),A.jsx("span",{className:"truncate text-xs font-medium text-neutral-800 dark:text-neutral-200",children:t.name}),e&&e>1?A.jsx("span",{className:"ml-0.5 flex shrink-0 items-center justify-center rounded-full bg-indigo-500 px-1.5 text-[10px] font-semibold text-white min-w-5 h-5",children:e}):null]}),dRt=T.forwardRef(({item:t,depth:e,isSelected:n,isDropTarget:r=!1,indentationWidth:i=$0t,isEditing:o=!1,onEditConfirm:l,onEditCancel:u},d)=>{const{t:p}=Cn(),m=T.useRef(null);T.useEffect(()=>{o&&m.current&&(m.current.focus(),m.current.select())},[o]);const g=t.updatedAt,h=t.type==="file"?_ae(t.fileSize??0):"--",f=y=>{if(y.stopPropagation(),y.key==="Enter"){const v=y.target.value.trim();v?l?.(v):u?.()}else y.key==="Escape"&&u?.()},b=y=>{const v=y.target.value.trim();v?l?.(v):u?.()};return A.jsxs("div",{ref:d,className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-sm select-none cursor-default group transition-colors ${r?"ring-2 ring-indigo-400 bg-indigo-50 dark:bg-indigo-950/30 dark:ring-indigo-500":n?"bg-indigo-600 text-white":"hover:bg-neutral-100 dark:hover:bg-neutral-800"}`,style:{paddingLeft:e*i+8},children:[t.type==="folder"?A.jsx("span",{className:`shrink-0 ${n?"text-white":"text-yellow-400 dark:text-yellow-500"}`,children:t.collapsed?A.jsx(Bke,{className:"h-4 w-4"}):A.jsx(Cst,{className:"h-4 w-4"})}):A.jsx("span",{className:"shrink-0 ml-0.5",children:A.jsx(Kq,{filename:t.name,mimeType:t.file?.content_type||"",className:"h-3.5 w-3.5"})}),o?A.jsx("input",{ref:m,defaultValue:p("knowledge.toolbar.newFolderPlaceholder"),onKeyDown:f,onBlur:b,onClick:y=>y.stopPropagation(),onMouseDown:y=>y.stopPropagation(),className:"min-w-0 flex-1 truncate text-xs bg-white dark:bg-neutral-800 border border-indigo-400 dark:border-indigo-500 rounded px-1 py-0 outline-none focus:ring-1 focus:ring-indigo-400 text-neutral-900 dark:text-neutral-100"}):A.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:t.name}),!o&&A.jsx("span",{className:`shrink-0 ${j0t} text-right text-[10px] tabular-nums ${n?"text-indigo-200":"text-neutral-400 dark:text-neutral-500"}`,children:Nar(g)}),!o&&A.jsx("span",{className:`shrink-0 ${z0t} text-right text-[10px] tabular-nums ${n?"text-indigo-200":"text-neutral-400 dark:text-neutral-500"}`,children:h})]})});dRt.displayName="TreeItemContent";const X8r={keyframes({transform:t}){return[{opacity:1,transform:Qx.Transform.toString(t.initial)},{opacity:0,transform:Qx.Transform.toString({...t.final,x:t.final.x+5,y:t.final.y+5})}]},easing:"ease-out",sideEffects({active:t}){t.node.animate([{opacity:0},{opacity:1}],{duration:WBe.duration,easing:WBe.easing})}},dle="__new_folder__",pRt=T.forwardRef(({treeItems:t,selectedIds:e,itemRefs:n,onItemClick:r,onFileDoubleClick:i,onContextMenu:o,onDropOnFolder:l,onFolderCreated:u,onRefresh:d,isTrashView:p},m)=>{const[g,h]=T.useState([]),[f,b]=T.useState("name"),[y,v]=T.useState("asc"),[_,w]=T.useState(null),[x,k]=T.useState(null),[C,E]=T.useState(null),S=T.useRef(null);T.useEffect(()=>{const Z=Dar(t,f,y);h(ae=>{if(ae.length===0)return Z;const oe=new Map,X=q=>{for(const Y of q)Y.type==="folder"&&Y.collapsed!==void 0&&oe.set(Y.id,Y.collapsed),Y.children.length>0&&X(Y.children)};X(ae);const W=q=>q.map(Y=>({...Y,collapsed:Y.type==="folder"?oe.get(Y.id)??!0:Y.collapsed,children:Y.children.length>0?W(Y.children):Y.children}));return W(Z)})},[t,f,y]);const I=T.useCallback(Z=>{Z===f?(v(ae=>ae==="asc"?"desc":"asc"),h(ae=>bae(ae,Z,y==="asc"?"desc":"asc"))):(b(Z),v("asc"),h(ae=>bae(ae,Z,"asc")))},[f,y]),B=T.useCallback(Z=>{h(ae=>q0t(ae,Z,"collapsed",oe=>!oe))},[]),N=T.useMemo(()=>U0t(g),[g]),L=_?N.find(({id:Z})=>Z===_):null,M=T.useMemo(()=>{if(!_)return new Set;const Z=String(_);return e.has(Z)&&e.size>1?e:new Set([Z])},[_,e]),R=OSt(MBe(UBe,{activationConstraint:p?{distance:1/0}:{distance:8}})),D=T.useCallback(Z=>{const ae=N.find(oe=>oe.id===Z);return ae?.folder?{item:ae.folder,type:"folder"}:ae?.file?{item:ae.file,type:"file"}:null},[N]),P=T.useCallback((Z,ae)=>{const oe=N.find(Y=>Y.id===ae);if(!oe)return;const W=N.find(Y=>Y.id===Z)?.parentId??null;let q;return oe.type==="folder"&&oe.id!==Z?!oe.collapsed&&oe.id===W?q=oe.parentId:q=oe.id:q=oe.parentId,q===W?void 0:q},[N]),O=T.useMemo(()=>{if(!(!_||!x||_===x))return P(String(_),String(x))},[_,x,P]),F=T.useCallback(({active:Z})=>{w(Z.id),document.body.style.setProperty("cursor","grabbing")},[]),Q=T.useCallback(({over:Z})=>{k(Z?.id??null)},[]),j=T.useCallback(({active:Z,over:ae})=>{const oe=new Set(M);if(w(null),k(null),document.body.style.setProperty("cursor",""),!ae||Z.id===ae.id)return;const X=String(Z.id),W=String(ae.id),q=N.find(ge=>ge.id===W);if(!q)return;const K=N.find(ge=>ge.id===X)?.parentId??null;let ne;if(q.type==="folder"&&q.id!==X?!q.collapsed&&q.id===K?ne=q.parentId:ne=q.id:ne=q.parentId,ne!==null&&oe.has(ne))return;const ue=[],se={};for(const ge of oe){const ve=yae(g,ge);!ve||(N.find(We=>We.id===ge)?.parentId??null)===ne||ve.type==="folder"&&ne!==null&&yae(ve.children,ne)||(ue.push({id:ge,item:ve}),se[ge]=ve.type)}if(ue.length===0)return;let ce=g;for(const{id:ge}of ue)ce=vae(ce,ge);for(const{item:ge}of ue)ce=H0t(ce,{...ge,children:ge.children},ne,f,y);h(ce),l(ue.map(({id:ge})=>ge),ne,se),d&&setTimeout(()=>d(),500)},[g,N,M,f,y,l,d]),$=T.useCallback(()=>{w(null),k(null),document.body.style.setProperty("cursor","")},[]),z=T.useCallback((Z,ae)=>{ae?n.current.set(Z,ae):n.current.delete(Z)},[n]),U=T.useCallback(()=>{E(null),h(Z=>vae(Z,dle))},[]),H=T.useCallback(async Z=>{const ae=S.current;U(),u&&await u(Z,ae)},[u,U]),te=T.useCallback(()=>{U()},[U]);return T.useImperativeHandle(m,()=>({createFolder:Z=>{p||(h(ae=>{const oe=vae(ae,dle),X={id:dle,name:"",type:"folder",children:[],collapsed:!0,isEditing:!0};if(Z===null)return[X,...oe];const W=q=>q.map(Y=>Y.id===Z?{...Y,collapsed:!1,children:[X,...Y.children]}:Y.children.length>0?{...Y,children:W(Y.children)}:Y);return W(oe)}),S.current=Z,E(dle))}}),[p]),t.length===0&&g.length===0&&!C?null:A.jsxs("div",{className:"flex h-full flex-col",children:[A.jsxs("div",{className:"flex items-center border-b border-neutral-200 dark:border-neutral-700 text-[11px] font-medium text-neutral-500 dark:text-neutral-400 shrink-0 select-none",children:[A.jsxs("button",{onClick:()=>I("name"),className:`flex flex-1 items-center gap-0.5 px-3 py-1.5 text-left transition-colors hover:text-neutral-700 dark:hover:text-neutral-300 ${f==="name"?"text-neutral-700 dark:text-neutral-300":""}`,children:["Name",f==="name"&&(y==="asc"?A.jsx(Ste,{className:"h-3 w-3"}):A.jsx(mf,{className:"h-3 w-3"}))]}),A.jsxs("button",{onClick:()=>I("modified"),className:`flex ${j0t} shrink-0 items-center gap-0.5 px-2 py-1.5 text-left transition-colors hover:text-neutral-700 dark:hover:text-neutral-300 ${f==="modified"?"text-neutral-700 dark:text-neutral-300":""}`,children:["Date Modified",f==="modified"&&(y==="asc"?A.jsx(Ste,{className:"h-3 w-3"}):A.jsx(mf,{className:"h-3 w-3"}))]}),A.jsxs("button",{onClick:()=>I("size"),className:`flex ${z0t} shrink-0 items-center justify-end gap-0.5 px-2 py-1.5 text-right transition-colors hover:text-neutral-700 dark:hover:text-neutral-300 ${f==="size"?"text-neutral-700 dark:text-neutral-300":""}`,children:["Size",f==="size"&&(y==="asc"?A.jsx(Ste,{className:"h-3 w-3"}):A.jsx(mf,{className:"h-3 w-3"}))]})]}),A.jsx("div",{className:`flex-1 p-2 rounded-md transition-colors ${_&&O===null?"bg-indigo-50/50 dark:bg-indigo-950/20 ring-2 ring-inset ring-indigo-300 dark:ring-indigo-600":""}`,children:A.jsxs(Toe,{sensors:R,onDragStart:F,onDragOver:Q,onDragEnd:j,onDragCancel:$,children:[A.jsx(jr,{initial:!1,children:N.map(Z=>A.jsx(Ct.div,{layout:!_,initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{layout:{duration:.2,ease:"easeInOut"},opacity:{duration:.15},height:{duration:.2}},style:{overflow:"hidden"},children:A.jsx(K8r,{item:Z,depth:Z.depth,isSelected:e.has(Z.id),isDragging:M.has(Z.id),isDropTarget:O===Z.id,isEditing:C===Z.id,onEditConfirm:H,onEditCancel:te,onCollapse:Z.type==="folder"?B:void 0,onClick:r,onDoubleClick:ae=>{const oe=D(ae);oe?.type==="file"?i(oe.item):oe?.type==="folder"&&B(ae)},onContextMenu:ae=>{ae.preventDefault(),ae.stopPropagation();const oe=D(Z.id);oe&&o(ae,oe.item,oe.type)},registerRef:z})},Z.id))}),Qi.createPortal(A.jsx(YBe,{dropAnimation:X8r,children:_&&L?A.jsx(Z8r,{item:L,childCount:M.size>1?M.size:G0t(g,String(_))+1}):null}),document.body)]})})]})});pRt.displayName="SortableTree";const J8r=T.memo(pRt),AC="application/x-xyzen-drag",mRt=T.forwardRef(({treeItems:t,selectedIds:e,itemRefs:n,onItemClick:r,onFileDoubleClick:i,onContextMenu:o,onDropOnFolder:l,onFolderCreated:u,onRefresh:d,isTrashView:p},m)=>A.jsx(J8r,{ref:m,treeItems:t,selectedIds:e,itemRefs:n,onItemClick:r,onFileDoubleClick:i,onContextMenu:o,onDropOnFolder:l,onFolderCreated:u,onRefresh:d,isTrashView:p}));mRt.displayName="FileTreeView";const e6r=T.memo(mRt),t6r=({fileId:t,alt:e,className:n=""})=>{const[r,i]=T.useState(null),[o,l]=T.useState(!1),[u,d]=T.useState(!1),[p,m]=T.useState(!1),g=T.useRef(null);return T.useEffect(()=>{const h=g.current;if(!h)return;const f=new IntersectionObserver(b=>{b.forEach(y=>{y.isIntersecting&&(d(!0),f.unobserve(y.target))})},{root:null,rootMargin:"100px",threshold:.01});return f.observe(h),()=>{f.disconnect()}},[]),T.useEffect(()=>{if(!u||!t||p||r)return;let h=!0;const f=new AbortController;return(async()=>{try{const v=await(await ys.downloadRaw(t,{signal:f.signal})).blob(),_=URL.createObjectURL(v);h?i(_):URL.revokeObjectURL(_)}catch(y){h&&y.name!=="AbortError"&&(console.error("Failed to load thumbnail:",y),m(!0))}})(),()=>{h=!1,f.abort()}},[u,t,p,r]),T.useEffect(()=>()=>{r&&URL.revokeObjectURL(r)},[r]),A.jsxs("div",{ref:g,className:`relative overflow-hidden bg-neutral-100 dark:bg-neutral-800 ${n}`,children:[A.jsx("div",{className:`absolute inset-0 flex items-center justify-center transition-opacity duration-300 ${o&&!p?"opacity-0":"opacity-100"}`,children:A.jsx(Eyt,{className:"h-8 w-8 text-purple-400"})}),r&&!p&&A.jsx("img",{src:r,alt:e,onLoad:()=>l(!0),onError:()=>m(!0),className:`absolute inset-0 h-full w-full object-cover transition-opacity duration-300 ${o?"opacity-100":"opacity-0"}`})]})},n6r=({isOpen:t,onClose:e,onMove:n,title:r,itemId:i,itemType:o})=>{const{t:l}=Cn(),[u,d]=T.useState([]),[p,m]=T.useState(null),[g,h]=T.useState([]),[f,b]=T.useState(!1),[y,v]=T.useState(null),_=T.useCallback(async k=>{b(!0);try{const C=await pf.listFolders(k),E=o==="folder"?C.filter(S=>S.id!==i):C;if(d(E),k){const S=await pf.getFolderPath(k);h(S)}else h([])}catch(C){console.error("Failed to load folders",C)}finally{b(!1)}},[o,i]);T.useEffect(()=>{t&&(m(null),v(null),_(null))},[t,_]);const w=k=>{m(k),v(k),_(k)},x=async()=>{await n(y),e()};return t?A.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:A.jsxs("div",{className:"w-96 rounded-sm bg-white p-4 shadow-xl dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800",children:[A.jsx("h3",{className:"mb-4 text-sm font-semibold text-neutral-900 dark:text-white",children:r}),A.jsxs("div",{className:"mb-2 flex items-center gap-1 text-xs text-neutral-500 overflow-x-auto whitespace-nowrap pb-2",children:[A.jsx("button",{onClick:()=>w(null),className:`hover:text-indigo-600 ${p?"":"font-bold text-neutral-900 dark:text-white"}`,children:l("knowledge.moveModal.home")}),g.map(k=>A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx(fg,{className:"h-3 w-3"}),A.jsx("button",{onClick:()=>w(k.id),className:`hover:text-indigo-600 ${p===k.id?"font-bold text-neutral-900 dark:text-white":""}`,children:k.name})]},k.id))]}),A.jsx("div",{className:"mb-4 h-60 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50 dark:border-neutral-800 dark:bg-neutral-950",children:f?A.jsx("div",{className:"flex h-full items-center justify-center text-xs text-neutral-400",children:l("common.loading")}):u.length===0?A.jsx("div",{className:"flex h-full items-center justify-center text-xs text-neutral-400",children:l("knowledge.moveModal.noSubfolders")}):A.jsx("div",{className:"divide-y divide-neutral-200 dark:divide-neutral-800",children:u.map(k=>A.jsxs("div",{onClick:()=>v(k.id),onDoubleClick:()=>w(k.id),className:`flex cursor-pointer items-center justify-between px-3 py-2 text-sm ${y===k.id?"bg-indigo-100 dark:bg-indigo-900/30 text-indigo-900 dark:text-indigo-100":"hover:bg-neutral-100 dark:hover:bg-neutral-900 text-neutral-700 dark:text-neutral-300"}`,children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx(b2e,{className:"h-4 w-4 text-yellow-500"}),A.jsx("span",{className:"truncate max-w-45",children:k.name})]}),A.jsx("button",{onClick:C=>{C.stopPropagation(),w(k.id)},className:"text-neutral-400 hover:text-neutral-600",children:A.jsx(fg,{className:"h-4 w-4"})})]},k.id))})}),A.jsxs("div",{className:"flex justify-end gap-2 text-xs",children:[A.jsx("button",{onClick:e,className:"rounded-md px-3 py-2 text-neutral-600 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800",children:l("common.cancel")}),A.jsx("button",{onClick:x,className:"rounded-md bg-indigo-600 px-3 py-2 text-white hover:bg-indigo-500",children:l("knowledge.moveModal.moveHere")})]})]})}):null},r6r=t=>{if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/Math.pow(e,r)).toFixed(1))} ${n[r]}`},a6r=(t,e)=>{const n=e.split(".").pop()?.toLowerCase()||"";return t.startsWith("image/")||["jpg","jpeg","png","gif","webp","svg","bmp","ico"].includes(n)};function lRe(t,e){const n=[],r=[e];for(;r.length>0;){const i=r.shift();for(const o of t)o.parent_id===i&&(n.push(o.id),o.is_dir&&r.push(o.id))}return n}const Zq=T.memo(T.forwardRef(({filter:t,viewMode:e,refreshTrigger:n,onRefresh:r,onFileCountChange:i,onStatsUpdate:o,onLoadingChange:l,currentFolderId:u,onFolderChange:d,currentKnowledgeSetId:p,onCreateFolder:m,onUpload:g,treeItems:h=[],treeLoading:f=!1,onRefreshTree:b,removeTreeItems:y,renameTreeItem:v,readonly:_,onDeleteItem:w,onRenameItem:x,onMoveItem:k,onDownloadFile:C,onEditSave:E,onCreateSkillFolder:S},I)=>{const{t:B}=Cn(),[N,L]=T.useState([]),[M,R]=T.useState([]),[D,P]=T.useState(!1),O=t==="all"||t==="knowledge"||t==="trash"||t==="skill"||t==="images"||t==="documents",F=t==="skill",Q=T.useMemo(()=>{if(t!=="images"&&t!=="documents")return h;const Qt=t==="images"?new Set(["jpg","jpeg","png","gif","bmp","webp","svg","ico"]):new Set(["pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","md"]),wr=new Set;for(const ci of h)if(!ci.is_dir){const Eo=ci.name.split(".").pop()?.toLowerCase()||"";Qt.has(Eo)&&wr.add(ci.id)}const Ht=new Set(wr),Qr=new Map(h.map(ci=>[ci.id,ci]));for(const ci of wr){let Eo=Qr.get(ci);for(;Eo?.parent_id&&!Ht.has(Eo.parent_id);)Ht.add(Eo.parent_id),Eo=Qr.get(Eo.parent_id)}return h.filter(ci=>Ht.has(ci.id))},[t,h]),j=O?f:D;T.useEffect(()=>{l?.(j)},[j,l]);const $=T.useRef([]),z=T.useRef([]);T.useEffect(()=>{$.current=N},[N]),T.useEffect(()=>{z.current=M},[M]);const U=100,[H,te]=T.useState(!0),[Z,ae]=T.useState(!1),oe=T.useRef(0),X=T.useRef(!1),{ref:W,inView:q}=cle({threshold:0,rootMargin:"200px"}),Y=T.useRef(q);T.useEffect(()=>{Y.current=q},[q]);const[K,ne]=T.useState(null),[ue,se]=T.useState(!1),[ce,ge]=T.useState(null),[ve,Be]=T.useState(!1),[We,Le]=T.useState(new Set),[rt,mt]=T.useState(null),yt=T.useRef(null),xt=T.useRef(null),$e=T.useRef(new Map),ot=T.useRef(!1),Ce=T.useRef(null),et=5,Rt=T.useCallback((Ft,_n)=>{if(Ft.stopPropagation(),ma.current){ma.current=!1;return}if(ot.current){ot.current=!1;return}Ft.ctrlKey||Ft.metaKey?Le(Qt=>{const wr=new Set(Qt);return wr.has(_n)?wr.delete(_n):wr.add(_n),wr}):Le(new Set([_n]))},[]),pe=T.useMemo(()=>new Set(M.map(Ft=>Ft.id)),[M]),Ze=T.useRef(()=>{}),ie=T.useCallback(async(Ft,_n,Qt)=>{try{await Promise.all(Ft.map(wr=>(Qt?Qt[wr]==="folder":pe.has(wr))?F&&k?k(wr,!0,_n):pf.updateFolder(wr,{parent_id:_n}):F&&k?k(wr,!1,_n):ys.updateFile(wr,{parent_id:_n}))),Le(new Set),O&&b?b():Ze.current()}catch(wr){console.error("Drop move failed",wr)}},[pe,O,F,k,b]),Re=T.useCallback((Ft,_n)=>{const Qt=We.has(_n)?[...We]:[_n],wr={};for(const Qr of Qt)wr[Qr]=pe.has(Qr)?"folder":"file";const Ht={ids:Qt,types:wr};window.__xyzenDragContext=Ht,Ft.dataTransfer.setData(AC,JSON.stringify(Ht)),Ft.dataTransfer.effectAllowed="move"},[We,pe]),be=T.useCallback((Ft,_n)=>{!Ft.dataTransfer.types.includes(AC)||window.__xyzenDragContext?.ids?.includes(_n)||(Ft.preventDefault(),Ft.stopPropagation(),Ft.dataTransfer.dropEffect="move")},[]),Oe=T.useCallback((Ft,_n)=>{Ft.preventDefault(),Ft.stopPropagation();try{const Qt=JSON.parse(Ft.dataTransfer.getData(AC));Qt?.ids?.length>0&&ie(Qt.ids,_n)}catch{}},[ie]),[we,st]=T.useState(null),vt=T.useCallback(Ft=>{if(Ft.button!==0)return;const _n=yt.current;if(!_n)return;const Qt=_n.getBoundingClientRect(),wr=Ft.clientX-Qt.left+_n.scrollLeft,Ht=Ft.clientY-Qt.top+_n.scrollTop;Ce.current={startX:wr,startY:Ht,clientX:Ft.clientX,clientY:Ft.clientY,ctrlKey:Ft.ctrlKey,metaKey:Ft.metaKey}},[]),de=T.useCallback(Ft=>{const _n=yt.current;if(!_n)return;const Qt=_n.getBoundingClientRect(),wr=Ft.clientX-Qt.left+_n.scrollLeft,Ht=Ft.clientY-Qt.top+_n.scrollTop;if(Ce.current&&!rt){const Ta=Ft.clientX-Ce.current.clientX,Ho=Ft.clientY-Ce.current.clientY;Math.sqrt(Ta*Ta+Ho*Ho)>=et&&(mt({startX:Ce.current.startX,startY:Ce.current.startY,currentX:wr,currentY:Ht}),!Ce.current.ctrlKey&&!Ce.current.metaKey&&Le(new Set));return}if(!rt)return;mt(Ta=>Ta?{...Ta,currentX:wr,currentY:Ht}:null);const Qr=Math.min(rt.startX,wr),ci=Math.max(rt.startX,wr),Eo=Math.min(rt.startY,Ht),bl=Math.max(rt.startY,Ht),qs=new Set;$e.current.forEach((Ta,Ho)=>{const No=Ta.getBoundingClientRect(),hc=_n.getBoundingClientRect(),Zo=No.left-hc.left+_n.scrollLeft,Ob=No.right-hc.left+_n.scrollLeft,Oo=No.top-hc.top+_n.scrollTop,va=No.bottom-hc.top+_n.scrollTop;Zo<ci&&Ob>Qr&&Oo<bl&&va>Eo&&qs.add(Ho)}),Le(qs)},[rt]),nt=T.useCallback(()=>{rt&&(ot.current=!0),mt(null),Ce.current=null},[rt]),[ct,Ne]=T.useState(null),[fe,xe]=T.useState(null);T.useEffect(()=>{if(!fe)return;const Ft=()=>xe(null),_n=setTimeout(()=>document.addEventListener("mousedown",Ft),0);return()=>{clearTimeout(_n),document.removeEventListener("mousedown",Ft)}},[fe]);const[pt,tt]=T.useState(null),[Vt,an]=T.useState(null),[on,Xt]=T.useState([]),[Lt,Dt]=T.useState(null),[at,gn]=T.useState(null),[xn,Rn]=T.useState(null);T.useImperativeHandle(I,()=>({moveItems:(Ft,_n)=>{ie(Ft,_n)},createFolder:Ft=>{xt.current?.createFolder(Ft)},emptyTrash:async()=>{const Ft=h.length;Ft!==0&&Dt({isOpen:!0,title:B("knowledge.fileList.emptyTrash.title"),message:B("knowledge.fileList.emptyTrash.message",{count:Ft}),confirmLabel:B("knowledge.fileList.emptyTrash.confirm"),destructive:!0,onConfirm:async()=>{y&&y(h.map(_n=>_n.id)),L([]),R([]),i&&i(0);try{await ys.emptyTrash(),r&&r(),b&&b()}catch(_n){console.error("Failed to empty trash",_n),b&&b(),alert(B("knowledge.fileList.emptyTrash.failed"))}}})}}),[ie,i,r,b,y,B,h]),T.useEffect(()=>{(async()=>{try{const _n=await Sh.listKnowledgeSets(!1);Xt(_n)}catch(_n){console.error("Failed to load knowledge sets",_n)}})()},[n]);const Mt=T.useCallback(async(Ft=!1)=>{if(!O){if(Ft){if(X.current)return;ae(!0)}else $.current.length===0&&z.current.length===0&&P(!0),X.current=!0,oe.current=0,te(!0);try{if(t==="home"){Ft||R([]);const Ht=await ys.listFiles({limit:U,offset:oe.current,is_dir:!1}),Qr=Ht.filter(ci=>!ci.is_deleted);Ft?L(ci=>{const Eo=[...ci,...Qr];return i&&setTimeout(()=>i(Eo.length),0),Eo}):(L(Qr),i&&i(Qr.length)),oe.current+=Ht.length,te(Ht.length===U);return}const _n={include_deleted:!1,limit:U,offset:oe.current};["images","audio","documents"].includes(t)&&(_n.category=t);const Qt=await ys.listFiles(_n),wr=Qt.filter(Ht=>!Ht.is_deleted);Ft||R([]),Ft?L(Ht=>{const Qr=[...Ht,...wr];return i&&setTimeout(()=>i(Qr.length),0),Qr}):(L(wr),i&&i(wr.length)),oe.current+=Qt.length,te(Qt.length===U)}catch(_n){console.error("Failed to load files",_n)}finally{P(!1),ae(!1),X.current=!1}}},[t,u]);Ze.current=Mt;const Ln=T.useCallback(async(Ft,_n)=>{try{if(F&&S)await S(Ft,_n);else{const Qt=await pf.createFolder({name:Ft,parent_id:_n});t==="knowledge"&&p&&await Sh.linkFileToKnowledgeSet(p,Qt.id)}b&&b()}catch(Qt){console.error("Failed to create folder",Qt)}},[t,F,p,b,S]),En=T.useCallback(()=>{!Z&&H&&Mt(!0)},[Z,H,Mt]);T.useEffect(()=>{Mt()},[Mt,n]),T.useEffect(()=>{q&&H&&!Z&&!D&&En()},[q,H,Z,D,En]);const or=T.useRef(Z);T.useEffect(()=>{const Ft=or.current;if(or.current=Z,Ft&&!Z&&Y.current&&H&&!D){const _n=setTimeout(()=>{En()},50);return()=>clearTimeout(_n)}},[Z,H,D,En]);const gt=(Ft,_n,Qt)=>{Ft.preventDefault(),Ft.stopPropagation(),xe(null),Ne({type:Qt,item:_n,position:{x:Ft.clientX,y:Ft.clientY}}),We.has(_n.id)||Le(new Set([_n.id]))},pr=T.useRef(null),$r=T.useRef(null),ma=T.useRef(!1),Vn=T.useCallback(()=>{pr.current!==null&&(window.clearTimeout(pr.current),pr.current=null),$r.current=null},[]),un=T.useCallback((Ft,_n)=>({onPointerDown:ci=>{ci.pointerType==="touch"&&(ma.current=!1,$r.current={x:ci.clientX,y:ci.clientY},Vn(),pr.current=window.setTimeout(()=>{ma.current=!0,iRe(),Ne({type:_n,item:Ft,position:{x:ci.clientX,y:ci.clientY}}),Le(Eo=>Eo.has(Ft.id)?Eo:new Set([Ft.id]))},550))},onPointerMove:ci=>{if(ci.pointerType!=="touch")return;const Eo=$r.current;if(!Eo)return;const bl=ci.clientX-Eo.x,qs=ci.clientY-Eo.y;Math.hypot(bl,qs)>10&&Vn()},onPointerUp:()=>{Vn()},onPointerCancel:()=>{Vn()}}),[Vn]),ln=async(Ft,_n)=>{gn({isOpen:!0,item:Ft,type:_n})},Gn=async Ft=>{if(!at)return;const{item:_n,type:Qt}=at;if(Qt==="folder"){if(M.find(Ht=>Ht.name===Ft&&Ht.id!==_n.id)){Rn({isOpen:!0,title:B("knowledge.fileList.notifications.errorTitle"),message:B("knowledge.fileList.rename.duplicateName"),type:"warning"});return}}else if(N.find(Ht=>Ht.original_filename===Ft&&Ht.id!==_n.id)){Rn({isOpen:!0,title:B("knowledge.fileList.notifications.errorTitle"),message:B("knowledge.fileList.rename.duplicateName"),type:"warning"});return}try{v&&O&&v(_n.id,Ft),Qt==="folder"?F&&x?await x(_n.id,!0,Ft):await pf.updateFolder(_n.id,{name:Ft}):F&&x?await x(_n.id,!1,Ft):await ys.updateFile(_n.id,{original_filename:Ft}),O&&b?b():Mt()}catch(wr){console.error("Rename failed",wr),b&&b(),alert(B("knowledge.fileList.rename.failed"))}},Gr=async Ft=>{if(!pt)return;const{item:_n,type:Qt}=pt;try{Qt==="folder"?F&&k?await k(_n.id,!0,Ft):await pf.updateFolder(_n.id,{parent_id:Ft}):F&&k?await k(_n.id,!1,Ft):await ys.updateFile(_n.id,{parent_id:Ft}),O&&b?b():Mt(),tt(null)}catch(wr){console.error("Move failed",wr),alert(B("knowledge.fileList.move.failed"))}},Za=async(Ft,_n)=>{if(We.size>1&&We.has(Ft.id)){const Qr=[],ci=[];We.forEach(Ta=>{if(N.some(Ho=>Ho.id===Ta))Qr.push(Ta);else if(M.some(Ho=>Ho.id===Ta))ci.push(Ta);else{const Ho=h.find(No=>No.id===Ta);Ho&&(Ho.is_dir?ci.push(Ta):Qr.push(Ta))}});const Eo=Qr.length+ci.length,bl=t==="trash";let qs=0;for(const Ta of Qr){const Ho=N.find(No=>No.id===Ta);if(Ho)qs+=Ho.file_size;else{const No=h.find(hc=>hc.id===Ta);No&&(qs+=No.file_size)}}Dt({isOpen:!0,title:B(bl?"knowledge.fileList.actions.deleteForever":"knowledge.fileList.actions.delete"),message:B("knowledge.fileList.bulkDelete.message",{count:Eo}),confirmLabel:B("knowledge.fileList.actions.delete"),destructive:!0,onConfirm:async()=>{try{if(y&&O){const Ta=[...Qr,...ci];for(const Ho of ci)Ta.push(...lRe(h,Ho));y(Ta)}Qr.length>0&&await Promise.all(Qr.map(Ta=>F&&w?w(Ta,!1):ys.deleteFile(Ta,bl))),ci.length>0&&await Promise.all(ci.map(Ta=>F&&w?w(Ta,!0):pf.deleteFolder(Ta,bl))),bl&&o&&o(qs,Qr.length),Le(new Set),O&&b?b():Mt()}catch(Ta){console.error("Bulk delete failed",Ta),b&&b(),alert(B("knowledge.fileList.actions.deleteFailed"))}}});return}const wr=B(_n==="folder"?"knowledge.fileList.itemTypes.folder":"knowledge.fileList.itemTypes.file"),Ht=_n==="file"?Ft.file_size:0;Dt({isOpen:!0,title:B("knowledge.fileList.deleteItem.title",{itemType:wr}),message:B("knowledge.fileList.deleteItem.message",{itemType:wr}),confirmLabel:B("knowledge.fileList.actions.delete"),destructive:!0,onConfirm:async()=>{try{const Qr=t==="trash";if(y&&O){const ci=_n==="folder"?lRe(h,Ft.id):[];y([Ft.id,...ci])}_n==="folder"?F&&w?await w(Ft.id,!0):await pf.deleteFolder(Ft.id,Qr):F&&w?await w(Ft.id,!1):await ys.deleteFile(Ft.id,Qr),Qr&&_n==="file"&&o&&o(Ht,1),Le(new Set),O&&b?b():Mt()}catch(Qr){console.error("Delete failed",Qr),b&&b(),alert(B("knowledge.fileList.actions.deleteFailed"))}}})},to=async(Ft,_n)=>{try{if(y&&t==="trash"){const Qt=lRe(h,Ft);y([Ft,...Qt])}await ys.restoreFile(Ft),r&&r(),b&&b()}catch(Qt){console.error("Restore failed",Qt),b&&b(),alert(B("knowledge.fileList.actions.restoreFailed"))}},Ri=async(Ft,_n)=>{try{const wr=await(F&&C?await C(Ft):await ys.downloadRaw(Ft)).blob(),Ht=URL.createObjectURL(wr),Qr=document.createElement("a");Qr.href=Ht,Qr.download=_n,document.body.appendChild(Qr),Qr.click(),document.body.removeChild(Qr),URL.revokeObjectURL(Ht)}catch(Qt){console.error("Download failed",Qt),alert(B("knowledge.fileList.actions.downloadFailed"))}},Po=Ft=>{ne({id:Ft.id,name:Ft.original_filename,type:Ft.content_type||"",size:Ft.file_size}),se(!0)},Al=Ft=>{ge({id:Ft.id,name:Ft.original_filename,contentType:Ft.content_type||"",size:Ft.file_size}),Be(!0)},yn=Ft=>{cRt(Ft.original_filename,Ft.content_type)?Al(Ft):Po(Ft)},Fn=Ft=>{d&&d(Ft)},Qn=Ft=>{an({isOpen:!0,item:Ft})},An=async Ft=>{if(!p)return;const _n="original_filename"in Ft?Ft.original_filename:Ft.name;Dt({isOpen:!0,title:B("knowledge.fileList.knowledgeSet.remove.title"),message:B("knowledge.fileList.knowledgeSet.remove.message",{name:_n}),confirmLabel:B("knowledge.fileList.knowledgeSet.remove.confirm"),destructive:!0,onConfirm:async()=>{try{await Sh.unlinkFileFromKnowledgeSet(p,Ft.id),b&&b()}catch(Qt){console.error("Failed to remove file from knowledge set",Qt),alert(B("knowledge.fileList.knowledgeSet.remove.failed"))}}})},ar=async Ft=>{if(Vt)try{await Sh.linkFileToKnowledgeSet(Ft,Vt.item.id),an(null),r&&r(),Rn({isOpen:!0,title:B("knowledge.fileList.notifications.successTitle"),message:B("knowledge.fileList.knowledgeSet.added"),type:"success"})}catch(_n){console.error("Failed to link file to knowledge set",_n);const Qt=_n instanceof Error?_n.message:String(_n);Qt.toLowerCase().includes("already")||Qt.toLowerCase().includes("duplicate")?Rn({isOpen:!0,title:B("knowledge.fileList.notifications.noticeTitle"),message:B("knowledge.fileList.knowledgeSet.alreadyInSet"),type:"warning"}):Rn({isOpen:!0,title:B("knowledge.fileList.notifications.errorTitle"),message:B("knowledge.fileList.knowledgeSet.addFailed"),type:"error"})}};if(O){if(f&&Q.length===0)return null;if(!f&&Q.length===0)return A.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-sm text-neutral-400",children:[A.jsx(DI,{className:"h-8 w-8 opacity-50"}),A.jsx("span",{children:B(t==="trash"?"knowledge.fileList.empty.trash":"knowledge.fileList.empty.noItems")})]})}else{if(D&&N.length===0&&M.length===0)return null;if(!D&&N.length===0&&M.length===0)return A.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-sm text-neutral-400",children:[A.jsx(DI,{className:"h-8 w-8 opacity-50"}),A.jsx("span",{children:B("knowledge.fileList.empty.noItems")})]})}return A.jsxs("div",{ref:yt,className:"h-full w-full relative select-none",onClick:()=>{if(ma.current){ma.current=!1;return}if(ot.current){ot.current=!1;return}Le(new Set),xe(null)},onContextMenu:Ft=>{Ft.preventDefault(),Ne(null),xe({x:Ft.clientX,y:Ft.clientY})},onMouseDown:vt,onMouseMove:de,onMouseUp:nt,onMouseLeave:nt,children:[rt&&A.jsx("div",{className:"absolute border-2 border-indigo-500 bg-indigo-500/10 pointer-events-none z-40",style:{left:Math.min(rt.startX,rt.currentX),top:Math.min(rt.startY,rt.currentY),width:Math.abs(rt.currentX-rt.startX),height:Math.abs(rt.currentY-rt.startY)}}),O?A.jsx(e6r,{ref:xt,treeItems:Q,selectedIds:We,itemRefs:$e,onItemClick:Rt,onFileDoubleClick:yn,onContextMenu:gt,onDropOnFolder:ie,onFolderCreated:Ln,onRefresh:b,isTrashView:t==="trash"}):e==="list"?A.jsxs("div",{className:"min-w-full inline-block align-middle",children:[A.jsx("div",{className:"border-b border-neutral-200 dark:border-neutral-800",children:A.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-2 text-xs font-medium uppercase text-neutral-500 dark:text-neutral-400",children:[A.jsx("div",{className:"col-span-8 md:col-span-6",children:B("knowledge.fileList.columns.name")}),A.jsx("div",{className:"hidden md:block md:col-span-2",children:B("knowledge.fileList.columns.size")}),A.jsx("div",{className:"hidden md:block md:col-span-3",children:B("knowledge.fileList.columns.dateModified")}),A.jsx("div",{className:"col-span-4 md:col-span-1"})]})}),A.jsxs("div",{className:"divide-y divide-neutral-100 dark:divide-neutral-800/50",children:[M.map(Ft=>A.jsxs("div",{ref:_n=>{_n?$e.current.set(Ft.id,_n):$e.current.delete(Ft.id)},draggable:!0,onDragStart:_n=>Re(_n,Ft.id),onDragEnd:()=>{window.__xyzenDragContext=null},onDragOver:_n=>{be(_n,Ft.id),_n.defaultPrevented&&st(Ft.id)},onDragLeave:()=>st(_n=>_n===Ft.id?null:_n),onDrop:_n=>{st(null),Oe(_n,Ft.id)},onClick:_n=>Rt(_n,Ft.id),onDoubleClick:()=>Fn(Ft.id),onContextMenu:_n=>gt(_n,Ft,"folder"),...un(Ft,"folder"),className:`group grid grid-cols-12 gap-4 px-4 py-2 text-sm items-center cursor-default ${we===Ft.id?"ring-2 ring-indigo-500 bg-indigo-50 dark:bg-indigo-900/30 rounded":We.has(Ft.id)?"bg-indigo-600 text-white":"text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800"}`,children:[A.jsxs("div",{className:"col-span-8 md:col-span-6 flex items-center gap-3 overflow-hidden",children:[A.jsx("div",{className:"shrink-0",children:A.jsx(b2e,{className:"h-5 w-5 text-yellow-500"})}),A.jsx("span",{className:"truncate font-medium",children:Ft.name})]}),A.jsx("div",{className:"hidden md:block md:col-span-2 text-xs opacity-50",children:"-"}),A.jsx("div",{className:"hidden md:block md:col-span-3 text-xs opacity-50",children:qx(new Date(Ft.created_at),"MMM d, yyyy HH:mm")}),A.jsx("div",{className:"col-span-4 md:col-span-1 flex justify-end",children:A.jsx("div",{className:`flex gap-2 ${We.has(Ft.id)?"text-white":"text-neutral-400 opacity-0 group-hover:opacity-100"}`,children:A.jsx("button",{onClick:_n=>{_n.stopPropagation(),Za(Ft,"folder")},title:B("knowledge.fileList.actions.delete"),children:A.jsx(Rl,{className:`h-4 w-4 ${We.has(Ft.id)?"hover:text-red-200":"hover:text-red-500"}`})})})})]},`folder-${Ft.id}`)),N.map(Ft=>{const _n=We.has(Ft.id);return A.jsxs("div",{ref:Qt=>{Qt?$e.current.set(Ft.id,Qt):$e.current.delete(Ft.id)},draggable:!0,onDragStart:Qt=>Re(Qt,Ft.id),onDragEnd:()=>{window.__xyzenDragContext=null},onClick:Qt=>Rt(Qt,Ft.id),onDoubleClick:()=>yn(Ft),onContextMenu:Qt=>gt(Qt,Ft,"file"),...un(Ft,"file"),className:`group grid grid-cols-12 gap-4 px-4 py-2 text-sm items-center cursor-default ${_n?"bg-indigo-600 text-white":"text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800 odd:bg-white even:bg-neutral-50/50 dark:odd:bg-transparent dark:even:bg-white/5"}`,children:[A.jsxs("div",{className:"col-span-8 md:col-span-6 flex items-center gap-3 overflow-hidden",children:[A.jsx("div",{className:"shrink-0",children:A.jsx(Kq,{filename:Ft.original_filename,mimeType:Ft.content_type||"",className:"h-5 w-5"})}),A.jsx("span",{className:"truncate select-none",children:Ft.original_filename})]}),A.jsx("div",{className:`hidden md:block md:col-span-2 text-xs ${_n?"text-indigo-200":"text-neutral-500 dark:text-neutral-400"}`,children:r6r(Ft.file_size)}),A.jsx("div",{className:`hidden md:block md:col-span-3 text-xs ${_n?"text-indigo-200":"text-neutral-500 dark:text-neutral-400"}`,children:qx(new Date(Ft.created_at),"MMM d, yyyy HH:mm")}),A.jsx("div",{className:"col-span-4 md:col-span-1 flex justify-end",children:A.jsxs("div",{className:`flex gap-2 ${_n?"text-white":"text-neutral-400 opacity-0 group-hover:opacity-100"}`,children:[A.jsx("button",{onClick:Qt=>{Qt.stopPropagation(),Po(Ft)},title:B("knowledge.fileList.actions.preview"),children:A.jsx(NI,{className:`h-4 w-4 ${_n?"hover:text-white":"hover:text-indigo-600"}`})}),A.jsx("button",{onClick:Qt=>{Qt.stopPropagation(),Ri(Ft.id,Ft.original_filename)},title:B("knowledge.fileList.actions.download"),children:A.jsx(mR,{className:`h-4 w-4 ${_n?"hover:text-white":"hover:text-indigo-600"}`})}),A.jsx("button",{onClick:Qt=>{Qt.stopPropagation(),Za(Ft,"file")},title:B("knowledge.fileList.actions.moveToTrash"),children:A.jsx(Rl,{className:`h-4 w-4 ${_n?"hover:text-red-200":"hover:text-red-500"}`})})]})})]},Ft.id)})]})]}):A.jsxs("div",{className:"grid grid-cols-3 gap-4 p-4 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8",children:[M.map(Ft=>A.jsxs("div",{ref:_n=>{_n?$e.current.set(Ft.id,_n):$e.current.delete(Ft.id)},draggable:!0,onDragStart:_n=>Re(_n,Ft.id),onDragEnd:()=>{window.__xyzenDragContext=null},onDragOver:_n=>{be(_n,Ft.id),_n.defaultPrevented&&st(Ft.id)},onDragLeave:()=>st(_n=>_n===Ft.id?null:_n),onDrop:_n=>{st(null),Oe(_n,Ft.id)},onClick:_n=>Rt(_n,Ft.id),onDoubleClick:()=>Fn(Ft.id),onContextMenu:_n=>gt(_n,Ft,"folder"),...un(Ft,"folder"),className:`group flex flex-col items-center gap-2 rounded-md p-3 text-center cursor-default ${we===Ft.id?"ring-2 ring-indigo-500 bg-indigo-50 dark:bg-indigo-900/30":We.has(Ft.id)?"bg-indigo-100 ring-2 ring-indigo-500 dark:bg-indigo-900/50":"hover:bg-neutral-100 dark:hover:bg-neutral-800"}`,children:[A.jsx("div",{className:"flex h-12 w-12 items-center justify-center",children:A.jsx(b2e,{className:"h-10 w-10 text-yellow-500"})}),A.jsx("span",{className:`w-full truncate text-xs font-medium ${We.has(Ft.id)?"text-indigo-700 dark:text-indigo-300":"text-neutral-700 dark:text-neutral-300"}`,children:Ft.name})]},`folder-${Ft.id}`)),N.map(Ft=>{const _n=We.has(Ft.id),Qt=a6r(Ft.content_type||"",Ft.original_filename);return A.jsxs("div",{ref:wr=>{wr?$e.current.set(Ft.id,wr):$e.current.delete(Ft.id)},draggable:!0,onDragStart:wr=>Re(wr,Ft.id),onDragEnd:()=>{window.__xyzenDragContext=null},onClick:wr=>Rt(wr,Ft.id),onDoubleClick:()=>yn(Ft),onContextMenu:wr=>gt(wr,Ft,"file"),...un(Ft,"file"),className:`group flex flex-col items-center gap-2 rounded-md p-3 text-center cursor-default ${_n?"bg-indigo-100 ring-2 ring-indigo-500 dark:bg-indigo-900/50":"hover:bg-neutral-100 dark:hover:bg-neutral-800"}`,children:[Qt?A.jsx(t6r,{fileId:Ft.id,alt:Ft.original_filename,className:"h-12 w-12 rounded"}):A.jsx("div",{className:"flex h-12 w-12 items-center justify-center",children:A.jsx(Kq,{filename:Ft.original_filename,mimeType:Ft.content_type||"",className:"h-10 w-10"})}),A.jsx("span",{className:`w-full truncate text-xs font-medium ${_n?"text-indigo-700 dark:text-indigo-300":"text-neutral-700 dark:text-neutral-300"}`,children:Ft.original_filename})]},Ft.id)})]}),H&&A.jsx("div",{ref:W,className:"flex items-center justify-center py-4",children:Z&&A.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-neutral-300 border-t-neutral-600 dark:border-neutral-600 dark:border-t-neutral-300"})}),ct&&A.jsx(z8r,{type:ct.type,item:ct.item,position:ct.position,onClose:()=>Ne(null),onRename:_?void 0:ln,onDelete:_?void 0:Za,onMove:_?void 0:(Ft,_n)=>tt({isOpen:!0,item:Ft,type:_n}),onDownload:ct.type==="file"?Ft=>Ri(Ft.id,Ft.original_filename):void 0,onPreview:ct.type==="file"?Ft=>Po(Ft):void 0,onEdit:ct.type==="file"&&!_&&cRt(ct.item.original_filename,ct.item.content_type)?Ft=>Al(Ft):void 0,onOpen:ct.type==="folder"?Ft=>Fn(Ft.id):void 0,onAddToKnowledgeSet:F?void 0:Qn,onRemoveFromKnowledgeSet:F?void 0:An,onRestore:F?void 0:(Ft,_n)=>to(Ft.id),onBulkDelete:We.size>1?()=>Za(ct.item,ct.type):void 0,onBulkMove:We.size>1?()=>tt({isOpen:!0,item:ct.item,type:ct.type}):void 0,isInKnowledgeSetView:t==="knowledge",isTrashView:t==="trash",selectedCount:We.has(ct.item.id)?We.size:1}),fe&&Qi.createPortal(A.jsx("div",{className:"fixed z-50 min-w-40 rounded-lg border border-neutral-200 bg-white p-1.5 shadow-lg dark:border-neutral-800 dark:bg-neutral-900",style:{top:fe.y,left:fe.x},ref:Ft=>{if(!Ft)return;const _n=Ft.getBoundingClientRect();_n.right>window.innerWidth&&(Ft.style.left=`${window.innerWidth-_n.width-10}px`),_n.bottom>window.innerHeight&&(Ft.style.top=`${window.innerHeight-_n.height-10}px`)},onMouseDown:Ft=>Ft.stopPropagation(),children:A.jsxs("div",{className:"flex flex-col gap-0.5",children:[m&&(t==="all"||t==="knowledge")&&A.jsxs("button",{onClick:()=>{m(),xe(null)},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(yor,{className:"h-4 w-4"}),B("knowledge.toolbar.newFolder")]}),g&&t!=="trash"&&A.jsxs("button",{onClick:()=>{g(),xe(null)},className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800",children:[A.jsx(s2e,{className:"h-4 w-4"}),B("knowledge.toolbar.uploadFile")]})]})}),document.body),pt&&A.jsx(n6r,{isOpen:pt.isOpen,onClose:()=>tt(null),onMove:Gr,title:B("knowledge.moveModal.title",{name:pt.type==="folder"?pt.item.name:pt.item.original_filename}),currentFolderId:u||null,itemId:pt.item.id,itemType:pt.type}),A.jsx(L8r,{isOpen:ue,onClose:()=>se(!1),file:K}),ce&&A.jsx(W8r,{isOpen:ve,onClose:()=>{Be(!1),ge(null)},file:ce,onLoadContent:Ft=>F&&C?C(Ft):ys.downloadRaw(Ft),onSaveContent:async(Ft,_n)=>{F&&E?await E(Ft,_n):await ys.updateFileContent(Ft,_n)},readonly:_}),Vt&&A.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:A.jsxs("div",{className:"w-full max-w-md rounded-lg border border-neutral-200 bg-white p-6 shadow-xl dark:border-neutral-800 dark:bg-neutral-900",children:[A.jsx("h3",{className:"mb-4 text-lg font-semibold text-neutral-900 dark:text-white",children:B("knowledge.fileList.knowledgeSet.add.title")}),A.jsx("p",{className:"mb-4 text-sm text-neutral-600 dark:text-neutral-400",children:B("knowledge.fileList.knowledgeSet.add.subtitle",{name:"original_filename"in Vt.item?Vt.item.original_filename:Vt.item.name})}),A.jsx("div",{className:"mb-4 max-h-64 space-y-2 overflow-y-auto",children:on.length===0?A.jsx("p",{className:"text-sm text-neutral-400 italic",children:B("knowledge.fileList.knowledgeSet.none")}):on.map(Ft=>A.jsxs("button",{onClick:()=>ar(Ft.id),className:"flex w-full items-center justify-between rounded-lg border border-neutral-200 p-3 text-left hover:bg-neutral-50 dark:border-neutral-800 dark:hover:bg-neutral-800",children:[A.jsxs("div",{className:"flex-1",children:[A.jsx("div",{className:"font-medium text-neutral-900 dark:text-white",children:Ft.name}),Ft.description&&A.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:Ft.description})]}),A.jsx("div",{className:"text-xs text-neutral-400",children:B("knowledge.fileList.knowledgeSet.fileCount",{count:Ft.file_count})})]},Ft.id))}),A.jsx("button",{onClick:()=>an(null),className:"w-full rounded-lg bg-neutral-100 px-4 py-2 text-sm font-medium text-neutral-900 hover:bg-neutral-200 dark:bg-neutral-800 dark:text-white dark:hover:bg-neutral-700",children:B("common.cancel")})]})}),Lt&&A.jsx(k_,{isOpen:Lt.isOpen,onClose:()=>Dt(null),onConfirm:Lt.onConfirm,title:Lt.title,message:Lt.message,confirmLabel:Lt.confirmLabel,destructive:Lt.destructive}),at&&A.jsx(I8r,{isOpen:at.isOpen,onClose:()=>gn(null),onConfirm:Gn,title:at.type==="folder"?B("knowledge.fileList.rename.titleFolder"):B("knowledge.fileList.rename.titleFile"),initialValue:at.type==="folder"?at.item.name:at.item.original_filename,placeholder:B("knowledge.fileList.rename.placeholder"),confirmLabel:B("knowledge.fileList.rename.confirm")}),xn&&A.jsx(oRt,{isOpen:xn.isOpen,onClose:()=>Rn(null),title:xn.title,message:xn.message,type:xn.type})]})}));Zq.displayName="FileList";const cRe=({onSearch:t,onUpload:e,onUploadFolder:n,onCreateFolder:r,onRefresh:i,onEmptyTrash:o,title:l,isTrash:u,showCreateFolder:d,breadcrumbs:p,onBreadcrumbClick:m,onDropOnBreadcrumb:g,onMenuClick:h,isLoading:f})=>{const{t:b}=Cn(),[y,v]=T.useState(!1),[_,w]=T.useState(void 0),x=T.useCallback((E,S)=>{if(!E.dataTransfer.types.includes(AC))return;const I=window.__xyzenDragContext;S!==null&&I?.ids?.includes(S)||(E.preventDefault(),E.dataTransfer.dropEffect="move",w(S))},[]),k=T.useCallback(()=>{w(void 0)},[]),C=T.useCallback((E,S)=>{E.preventDefault(),w(void 0);try{const I=JSON.parse(E.dataTransfer.getData(AC));I?.ids?.length>0&&g&&g(I.ids,S)}catch{}},[g]);return A.jsxs("div",{className:"relative flex h-14 items-center justify-between border-b border-white/20 dark:border-neutral-700/30 px-3 md:px-4",children:[y&&A.jsxs("div",{className:"absolute inset-0 z-10 flex items-center bg-white/80 dark:bg-neutral-900/80 backdrop-blur-xl px-3 rounded-t-2xl",children:[A.jsx(hy,{className:"mr-2 h-5 w-5 text-neutral-400"}),A.jsx("input",{type:"text",placeholder:b("knowledge.toolbar.searchFilesPlaceholder"),autoFocus:!0,onChange:E=>t(E.target.value),className:"flex-1 border-none bg-transparent text-sm text-neutral-900 placeholder-neutral-400 focus:ring-0 dark:text-white"}),A.jsx("button",{onClick:()=>{v(!1),t("")},className:"p-2 text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300 rounded-lg hover:bg-white/50 dark:hover:bg-white/10 transition-colors",children:A.jsx(Yl,{className:"h-5 w-5"})})]}),A.jsxs("div",{className:`flex items-center gap-2 md:gap-4 ${y?"invisible":""}`,children:[A.jsx("button",{onClick:h,className:"p-2 text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-200 md:hidden",children:A.jsx(myt,{className:"h-5 w-5"})}),p?A.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium text-neutral-600 dark:text-neutral-300",children:[A.jsxs("button",{onClick:()=>m&&m(null),onDragOver:E=>x(E,null),onDragLeave:k,onDrop:E=>C(E,null),className:`flex items-center gap-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded px-1.5 py-0.5 ${p.length===0?"text-neutral-900 font-semibold dark:text-white":""} ${_===null?"ring-2 ring-indigo-500 bg-indigo-50 dark:bg-indigo-900/30":""}`,children:[A.jsx(Bor,{className:"h-4 w-4"}),A.jsx("span",{children:b("knowledge.toolbar.home")})]}),p.map((E,S)=>{const I=S===p.length-1;return A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx(fg,{className:"h-3 w-3 text-neutral-400"}),A.jsx("button",{onClick:()=>!I&&m&&m(E.id),onDragOver:B=>x(B,E.id),onDragLeave:k,onDrop:B=>C(B,E.id),disabled:I,className:`truncate max-w-37.5 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded px-1.5 py-0.5 ${I?"text-neutral-900 font-semibold dark:text-white cursor-default":"cursor-pointer"} ${_===E.id?"ring-2 ring-indigo-500 bg-indigo-50 dark:bg-indigo-900/30":""}`,children:E.name})]},E.id)})]}):A.jsx("h1",{className:"text-sm font-semibold text-neutral-700 dark:text-neutral-200 capitalize",children:l})]}),A.jsxs("div",{className:`flex items-center gap-1 md:gap-3 ${y?"invisible":""}`,children:[A.jsx("button",{onClick:()=>v(!0),className:"p-1.5 text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 md:hidden",children:A.jsx(hy,{className:"h-5 w-5"})}),A.jsxs("div",{className:"relative hidden md:block",children:[A.jsx(hy,{className:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-neutral-400"}),A.jsx("input",{type:"text",placeholder:b("knowledge.toolbar.searchPlaceholder"),onChange:E=>t(E.target.value),className:"h-9 w-48 rounded-sm border border-white/20 dark:border-neutral-700/30 bg-white/50 dark:bg-neutral-800/50 pl-9 pr-4 text-xs text-neutral-900 placeholder-neutral-400 focus:ring-1 focus:ring-indigo-500/50 focus:border-indigo-500/50 dark:text-white transition-all"})]}),A.jsx("div",{className:"hidden h-6 w-px bg-neutral-300/50 dark:bg-neutral-600/30 md:block"}),d&&r&&A.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 rounded-sm bg-white/50 dark:bg-neutral-800/50 px-3 py-2 text-xs font-medium text-neutral-700 dark:text-neutral-200 border border-white/20 dark:border-neutral-700/30 hover:bg-white/80 dark:hover:bg-neutral-700/60 transition-all duration-200",title:b("knowledge.toolbar.newFolder"),children:[A.jsx(U1,{className:"h-4 w-4"}),A.jsx("span",{className:"hidden md:inline",children:b("knowledge.toolbar.newFolder")})]}),u&&o?A.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 rounded-sm bg-red-500/90 hover:bg-red-500 px-3 py-2 text-xs font-medium text-white shadow-sm transition-all duration-200",title:b("knowledge.toolbar.emptyTrash"),children:[A.jsx(Rl,{className:"h-4 w-4"}),A.jsx("span",{className:"hidden md:inline",children:b("knowledge.toolbar.empty")})]}):A.jsx(i6r,{onUploadFiles:e,onUploadFolder:n}),A.jsx("button",{onClick:i,className:"hidden rounded-sm p-2 text-neutral-500 hover:bg-white/50 dark:hover:bg-white/10 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-200 transition-all duration-200 md:block",title:b("knowledge.toolbar.refresh"),disabled:f,children:A.jsx(ao,{className:`h-4 w-4 transition-transform${f?" animate-spin":""}`})})]})]})},i6r=({onUploadFiles:t,onUploadFolder:e})=>{const{t:n}=Cn(),[r,i]=T.useState(!1),o=T.useRef(null);return T.useEffect(()=>{if(!r)return;const l=u=>{o.current&&!o.current.contains(u.target)&&i(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]),A.jsxs("div",{ref:o,className:"relative",children:[A.jsxs("button",{onClick:()=>i(l=>!l),className:"flex items-center gap-1.5 rounded-sm bg-indigo-500/90 hover:bg-indigo-500 px-3 py-2 text-xs font-medium text-white shadow-sm transition-all duration-200",title:n("knowledge.toolbar.upload"),children:[A.jsx(Dd,{className:"h-4 w-4"}),A.jsx("span",{className:"hidden md:inline",children:n("knowledge.toolbar.upload")})]}),r&&A.jsxs("div",{className:"absolute right-0 top-full z-50 mt-1 w-44 overflow-hidden rounded-md border border-neutral-200 bg-white shadow-lg dark:border-neutral-700 dark:bg-neutral-900",children:[A.jsxs("button",{className:"flex w-full items-center gap-2 px-3 py-2 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800 transition-colors",onClick:()=>{i(!1),t()},children:[A.jsx(DI,{className:"h-4 w-4 text-neutral-500"}),n("knowledge.toolbar.uploadFile")]}),e&&A.jsxs("button",{className:"flex w-full items-center gap-2 px-3 py-2 text-xs text-neutral-700 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800 transition-colors",onClick:()=>{i(!1),e()},children:[A.jsx(m2e,{className:"h-4 w-4 text-neutral-500"}),n("knowledge.toolbar.uploadFolder")]})]})]})},o6r=t=>{if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/Math.pow(e,r)).toFixed(1))} ${n[r]}`},s6r=t=>`${(t/1048576).toFixed(2)} MB`,uRe=({itemCount:t,stats:e})=>{const{t:n}=Cn(),r=e.availableBytes??Math.max(0,e.total-e.used),i=e.usagePercentage??(e.total>0?e.used/e.total*100:0),o=()=>i>=90?"text-red-600 dark:text-red-400":i>=75?"text-orange-600 dark:text-orange-400":"text-neutral-500",l=()=>i>=90?"bg-red-500":i>=75?"bg-orange-500":"bg-blue-500";return A.jsxs("div",{className:"flex h-10 select-none items-center justify-between border-t border-white/20 dark:border-neutral-700/30 px-4 text-xs font-medium text-neutral-500 dark:text-neutral-400",children:[A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsx("span",{children:n("knowledge.status.items",{count:t})}),A.jsx("span",{className:"h-3 w-px bg-neutral-300/50 dark:bg-neutral-600/50"}),A.jsx("span",{className:o(),children:n("knowledge.status.used",{used:s6r(e.used)})}),A.jsx("span",{className:"hidden sm:inline h-3 w-px bg-neutral-300/50 dark:bg-neutral-600/50"}),A.jsx("span",{className:"hidden sm:inline",children:n("knowledge.status.available",{available:o6r(r)})})]}),A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsx("div",{className:"w-20 sm:w-28 h-1.5 bg-neutral-200/50 dark:bg-neutral-700/50 rounded-full overflow-hidden",children:A.jsx("div",{className:`h-full transition-all duration-300 ${l()}`,style:{width:`${Math.min(i,100)}%`}})}),i>0&&A.jsxs("span",{className:o(),children:[i.toFixed(0),"%"]})]})]})},dRe=({uploads:t,onCancel:e,onDismiss:n,onDismissAll:r})=>{const{t:i}=Cn();if(t.length===0)return null;const o=t.filter(d=>d.status==="queued"||d.status==="uploading"),l=t.filter(d=>d.status==="uploading").length,u=t.filter(d=>d.status==="queued").length;return A.jsxs(Ct.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:20,scale:.95},className:"absolute bottom-4 right-4 z-50 w-80 rounded-sm border border-white/30 dark:border-neutral-700/50 bg-white/80 dark:bg-neutral-900/80 backdrop-blur-xl shadow-xl",children:[A.jsxs("div",{className:"flex items-center justify-between border-b border-white/20 dark:border-neutral-700/30 px-4 py-3",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("h3",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:o.length>0?l>0?i("knowledge.uploadProgress.uploading",{count:l})+(u>0?` (+${u})`:""):i("knowledge.uploadProgress.queued",{count:u}):i("knowledge.uploadProgress.complete")}),o.length>0&&A.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-indigo-500"})]}),A.jsx("button",{onClick:r,className:"rounded p-1 text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600 dark:hover:bg-neutral-800 dark:hover:text-neutral-300",title:i("common.close"),children:A.jsx(Yl,{className:"h-4 w-4"})})]}),A.jsx("div",{className:"max-h-64 overflow-y-auto",children:A.jsx(jr,{mode:"popLayout",children:t.map(d=>A.jsx(Ct.div,{layout:!0,initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"border-b border-white/10 dark:border-neutral-700/20 px-4 py-3 last:border-b-0",children:A.jsxs("div",{className:"flex items-start justify-between gap-2",children:[A.jsxs("div",{className:"min-w-0 flex-1",children:[A.jsx("p",{className:"truncate text-sm font-medium text-neutral-900 dark:text-neutral-100",children:d.fileName}),A.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[d.status==="queued"&&A.jsx("span",{className:"text-xs text-neutral-400 dark:text-neutral-500",children:i("knowledge.uploadProgress.waiting")}),d.status==="uploading"&&A.jsxs(A.Fragment,{children:[A.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-neutral-200 dark:bg-neutral-700",children:A.jsx(Ct.div,{className:"h-full bg-indigo-500",initial:{width:0},animate:{width:`${d.progress}%`},transition:{duration:.3}})}),A.jsxs("span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:[d.progress,"%"]})]}),d.status==="completed"&&A.jsx("span",{className:"text-xs text-green-600 dark:text-green-400",children:i("knowledge.uploadProgress.completed")}),d.status==="error"&&A.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:d.error||i("knowledge.uploadProgress.failed")}),d.status==="cancelled"&&A.jsx("span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:i("knowledge.uploadProgress.cancelled")})]})]}),A.jsx("div",{className:"flex shrink-0 items-center",children:d.status==="queued"||d.status==="uploading"?A.jsx("button",{onClick:()=>e(d.id),className:"rounded p-1 text-neutral-400 hover:bg-neutral-100 hover:text-red-500 dark:hover:bg-neutral-800",title:i("common.cancel"),children:A.jsx(Yl,{className:"h-4 w-4"})}):A.jsx("button",{onClick:()=>n(d.id),className:"rounded p-1 text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600 dark:hover:bg-neutral-800",title:i("common.dismiss"),children:A.jsx(Yl,{className:"h-4 w-4"})})})]})},d.id))})}),o.length>1&&A.jsx("div",{className:"border-t border-white/20 dark:border-neutral-700/30 px-4 py-2",children:A.jsx("button",{onClick:()=>o.forEach(d=>e(d.id)),className:"text-xs font-medium text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:i("knowledge.uploadProgress.cancelAll")})})]})},l6r=(t,e)=>{if(!e.includes(t))return t;const n=t.lastIndexOf("."),r=n>0?t.slice(0,n):t,i=n>0?t.slice(n):"";let o=1,l;do l=`${r} (${o})${i}`,o++;while(e.includes(l));return l};async function gRt(t,e=""){const n=e?`${e}/${t.name}`:t.name;if(t.isFile)return[{file:await new Promise((i,o)=>{t.file(i,o)}),relativePath:n}];if(t.isDirectory){const r=t.createReader(),i=[];let o;do{o=await new Promise((l,u)=>{r.readEntries(l,u)});for(const l of o){const u=await gRt(l,n);i.push(...u)}}while(o.length>0);return i}return[]}function hRt({knowledgeSetId:t,showToolbar:e=!0,showStatusBar:n=!0,enableUpload:r=!0,onMenuClick:i}){const{t:o}=Cn(),[l,u]=T.useState([]),[d,p]=T.useState(!1),[m,g]=T.useState(0),[h,f]=T.useState(null),[b]=T.useState("list"),[y,v]=T.useState([]),[_,w]=T.useState(null),[x,k]=T.useState(0),[C,E]=T.useState(!1),[S,I]=T.useState(0),[B,N]=T.useState({total:0,used:0,fileCount:0,usagePercentage:0,availableBytes:0,maxFileSize:100*1024*1024}),[L,M]=T.useState([]),R=T.useRef(new Map),[D,P]=T.useState(!1),O=T.useRef(0),F=T.useRef(null),Q=T.useRef(null),j=T.useRef(null);T.useEffect(()=>{if(!t){u([]);return}let rt=!1;return p(!0),pf.getTree(t).then(mt=>{rt||(u(mt),p(!1))}).catch(mt=>{console.error("Failed to fetch knowledge tree",mt),rt||p(!1)}),()=>{rt=!0}},[t,m]),T.useEffect(()=>{if(!t){w(null);return}let rt=!1;return Sh.getKnowledgeSet(t).then(mt=>{rt||w(mt.name)}).catch(mt=>{console.error("Failed to fetch knowledge set name",mt)}),()=>{rt=!0}},[t]),T.useEffect(()=>{if(!h){v([]);return}pf.getFolderPath(h).then(v).catch(rt=>console.error("Failed to fetch breadcrumbs",rt))},[h]),T.useEffect(()=>{if(!n&&!r)return;(async()=>{try{const mt=await ys.getStorageStats();N({used:mt.quota.storage.used_bytes,total:mt.quota.storage.limit_bytes,fileCount:mt.quota.file_count.used,usagePercentage:mt.quota.storage.usage_percentage,availableBytes:mt.quota.storage.available_bytes,maxFileSize:mt.quota.max_file_size.bytes})}catch(mt){console.error("Stats fetch failed",mt)}})()},[x,n,r]),T.useEffect(()=>{f(null)},[t]);const $=T.useCallback(rt=>{const mt=new Set(rt);u(yt=>yt.filter(xt=>!mt.has(xt.id)))},[]),z=T.useCallback((rt,mt)=>{u(yt=>yt.map(xt=>xt.id===rt?{...xt,name:mt}:xt))},[]),U=T.useCallback(()=>{g(rt=>rt+1)},[]),H=T.useCallback(()=>{k(rt=>rt+1),U()},[U]),te=T.useCallback((rt,mt)=>{N(yt=>{const xt=Math.max(0,yt.used-rt),$e=Math.max(0,yt.fileCount-mt),ot=yt.total-xt,Ce=yt.total>0?xt/yt.total*100:0;return{...yt,used:xt,fileCount:$e,availableBytes:ot,usagePercentage:Ce}})},[]),Z=T.useCallback(rt=>{f(rt)},[]),ae=T.useCallback(()=>{j.current&&j.current.createFolder(h)},[h]),oe=T.useCallback(async(rt,mt)=>{j.current&&j.current.moveItems(rt,mt)},[]),X=T.useCallback(async rt=>{if(rt.length===0)return;const mt=h||null;let yt=[];try{yt=(await ys.listFiles({parent_id:mt,filter_by_parent:!0,limit:1e3,offset:0})).map($e=>$e.original_filename)}catch{}for(const xt of rt){if(B.maxFileSize&&xt.size>B.maxFileSize){const pe=(B.maxFileSize/1048576).toFixed(0),Ze=(xt.size/(1024*1024)).toFixed(2);alert(o("knowledge.upload.errors.fileTooLarge",{name:xt.name,fileSizeMB:Ze,maxSizeMB:pe}));continue}if(B.availableBytes!==void 0&&xt.size>B.availableBytes){const pe=(B.availableBytes/1048576).toFixed(2),Ze=(xt.size/(1024*1024)).toFixed(2);alert(o("knowledge.upload.errors.notEnoughStorage",{fileSizeMB:Ze,availableMB:pe}));continue}const $e=l6r(xt.name,yt);yt.push($e);const ot=$e!==xt.name?new File([xt],$e,{type:xt.type}):xt,Ce=`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,et={id:Ce,fileName:$e,progress:0,status:"queued"};M(pe=>[...pe,et]);const Rt=nRt.enqueue(Ce,()=>M(pe=>pe.map(Ze=>Ze.id===Ce?{...Ze,status:"uploading"}:Ze)),()=>ys.uploadFileWithProgress(ot,"private",void 0,mt,t,pe=>{M(Ze=>Ze.map(ie=>ie.id===Ce?{...ie,progress:pe.percentage}:ie))}));R.current.set(Ce,Rt),Rt.promise.then(()=>{M(pe=>pe.map(Ze=>Ze.id===Ce?{...Ze,status:"completed",progress:100}:Ze)),R.current.delete(Ce),k(pe=>pe+1),U()}).catch(pe=>{pe.message==="Upload cancelled"?M(Ze=>Ze.map(ie=>ie.id===Ce?{...ie,status:"cancelled"}:ie)):M(Ze=>Ze.map(ie=>ie.id===Ce?{...ie,status:"error",error:pe.message}:ie)),R.current.delete(Ce)})}},[h,t,B,o,U]),W=T.useCallback(()=>{F.current?.click()},[]),q=T.useCallback(()=>{Q.current?.click()},[]),Y=async rt=>{if(rt.target.files&&rt.target.files.length>0){const mt=Array.from(rt.target.files);await X(mt),rt.target.value=""}},K=T.useCallback(async rt=>{if(rt.length===0)return;const mt=h||null,yt=new Set;for(const{relativePath:ot}of rt){const Ce=ot.split("/");for(let et=1;et<Ce.length;et++)yt.add(Ce.slice(0,et).join("/"))}const xt=Array.from(yt).sort((ot,Ce)=>ot.split("/").length-Ce.split("/").length),$e=new Map;for(const ot of xt){const Ce=ot.split("/"),et=Ce[Ce.length-1],Rt=Ce.length>1?Ce.slice(0,-1).join("/"):null,pe=Rt?$e.get(Rt)??null:mt;try{const Ze=await pf.createFolder({name:et,parent_id:pe});$e.set(ot,Ze.id)}catch(Ze){console.error(`Failed to create folder: ${ot}`,Ze)}}for(const{file:ot,relativePath:Ce}of rt){const et=Ce.split("/"),Rt=et.length>1?et.slice(0,-1).join("/"):null,pe=Rt?$e.get(Rt)??mt:mt;if(B.maxFileSize&&ot.size>B.maxFileSize||B.availableBytes!==void 0&&ot.size>B.availableBytes)continue;const Ze=et[et.length-1],ie=new File([ot],Ze,{type:ot.type}),Re=`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,be={id:Re,fileName:Ze,progress:0,status:"queued"};M(we=>[...we,be]);const Oe=nRt.enqueue(Re,()=>M(we=>we.map(st=>st.id===Re?{...st,status:"uploading"}:st)),()=>ys.uploadFileWithProgress(ie,"private",void 0,pe,t,we=>{M(st=>st.map(vt=>vt.id===Re?{...vt,progress:we.percentage}:vt))}));R.current.set(Re,Oe),Oe.promise.then(()=>{M(we=>we.map(st=>st.id===Re?{...st,status:"completed",progress:100}:st)),R.current.delete(Re),k(we=>we+1),U()}).catch(we=>{we.message==="Upload cancelled"?M(st=>st.map(vt=>vt.id===Re?{...vt,status:"cancelled"}:vt)):M(st=>st.map(vt=>vt.id===Re?{...vt,status:"error",error:we.message}:vt)),R.current.delete(Re)})}},[h,t,B,U]),ne=T.useCallback(async rt=>{if(!rt.target.files||rt.target.files.length===0)return;const mt=Array.from(rt.target.files);rt.target.value="";const yt=mt.map(xt=>{const $e=xt.webkitRelativePath;return $e?{file:xt,relativePath:$e}:null}).filter(Boolean);await K(yt)},[K]),ue=T.useCallback(rt=>{const mt=R.current.get(rt);mt&&mt.abort()},[]),se=T.useCallback(rt=>{M(mt=>mt.filter(yt=>yt.id!==rt))},[]),ce=T.useCallback(()=>{L.forEach(rt=>{if(rt.status==="uploading"||rt.status==="queued"){const mt=R.current.get(rt.id);mt&&mt.abort()}}),M([])},[L]),ge=T.useCallback(rt=>{rt.preventDefault(),rt.stopPropagation(),!rt.dataTransfer.types.includes(AC)&&(O.current++,rt.dataTransfer.types.includes("Files")&&P(!0))},[]),ve=T.useCallback(rt=>{rt.preventDefault(),rt.stopPropagation(),O.current--,O.current===0&&P(!1)},[]),Be=T.useCallback(rt=>{rt.preventDefault(),rt.stopPropagation()},[]),We=T.useCallback(async rt=>{rt.preventDefault(),rt.stopPropagation(),P(!1),O.current=0;const yt=Array.from(rt.dataTransfer.items).map($e=>$e.webkitGetAsEntry?.()).filter(Boolean);if(yt.some($e=>$e.isDirectory)){const $e=[];for(const ot of yt){const Ce=await gRt(ot);$e.push(...Ce)}$e.length>0&&await K($e)}else{const $e=Array.from(rt.dataTransfer.files);$e.length>0&&await X($e)}},[X,K]),Le=_||o("knowledge.titles.knowledgeBase");return A.jsxs("div",{className:"flex flex-1 flex-col min-w-0 overflow-hidden relative",onDragEnter:r?ge:void 0,onDragLeave:r?ve:void 0,onDragOver:r?Be:void 0,onDrop:r?We:void 0,children:[r&&D&&A.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-indigo-500/10 backdrop-blur-sm border-2 border-dashed border-indigo-500 rounded-lg m-2 pointer-events-none",children:A.jsxs("div",{className:"text-center",children:[A.jsx("div",{className:"text-4xl mb-2",children:"📁"}),A.jsx("div",{className:"text-lg font-medium text-indigo-600 dark:text-indigo-400",children:o("knowledge.upload.dropHere")}),A.jsx("div",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:_?o("knowledge.upload.dropToKnowledgeSet",{name:_}):o(h?"knowledge.upload.dropToFolder":"knowledge.upload.dropToUpload")})]})}),e&&A.jsx(cRe,{title:Le,onSearch:rt=>console.log("Search",rt),onUpload:W,onUploadFolder:q,onRefresh:H,isTrash:!1,showCreateFolder:!0,onCreateFolder:ae,breadcrumbs:h?y:void 0,onBreadcrumbClick:rt=>Z(rt),onDropOnBreadcrumb:oe,isLoading:C,onMenuClick:i}),A.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:A.jsx(Zq,{ref:j,filter:"knowledge",viewMode:b,refreshTrigger:x,onRefresh:H,onFileCountChange:I,onStatsUpdate:te,onLoadingChange:E,currentFolderId:h,currentKnowledgeSetId:t,onFolderChange:Z,onCreateFolder:ae,onUpload:r?W:void 0,treeItems:l,treeLoading:d,onRefreshTree:U,removeTreeItems:$,renameTreeItem:z})}),n&&A.jsx(uRe,{itemCount:h?S:B.fileCount,stats:{used:B.used,total:B.total,fileCount:B.fileCount}}),r&&A.jsxs(A.Fragment,{children:[A.jsx(jr,{children:L.length>0&&A.jsx(dRe,{uploads:L,onCancel:ue,onDismiss:se,onDismissAll:ce})}),A.jsx("input",{type:"file",ref:F,className:"hidden",multiple:!0,onChange:Y}),A.jsx("input",{type:"file",ref:Q,className:"hidden",webkitdirectory:"",onChange:ne})]})]})}function c6r(){const{t}=Cn(),{knowledge_set_id:e}=aI();return e?A.jsx(hRt,{knowledgeSetId:e,showToolbar:!1,showStatusBar:!1,enableUpload:!0}):A.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[A.jsx("p",{className:"text-sm font-medium text-neutral-500 dark:text-neutral-400",children:t("capsule.knowledge.noKnowledgeSet")}),A.jsx("p",{className:"text-xs text-neutral-400 dark:text-neutral-500",children:t("capsule.knowledge.noKnowledgeSetHint")})]})}function bC({...t}){return A.jsx(WYn,{"data-slot":"popover",...t})}function yC({...t}){return A.jsx(VYn,{"data-slot":"popover-trigger",...t})}function vC({className:t,align:e="center",sideOffset:n=4,...r}){return A.jsx(KYn,{children:A.jsx(ZYn,{"data-slot":"popover-content",align:e,sideOffset:n,className:Yt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...r})})}function u6r({...t}){return A.jsx(YYn,{"data-slot":"popover-anchor",...t})}function d6r({delayDuration:t=0,...e}){return A.jsx(PKn,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function fRt({...t}){return A.jsx(d6r,{children:A.jsx(OKn,{"data-slot":"tooltip",...t})})}function ARt({...t}){return A.jsx(FKn,{"data-slot":"tooltip-trigger",...t})}function p6r({className:t,sideOffset:e=0,children:n,...r}){return A.jsx(Nft,{children:A.jsxs(Rft,{"data-slot":"tooltip-content",sideOffset:e,className:Yt("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...r,children:[n,A.jsx(QKn,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const nF="https://storage.sciol.ac.cn/xyzen/releases/runner/latest",Xq=[{key:"darwin-arm64",label:"macOS Apple Silicon",binary:"xyzen-darwin-arm64",curlCmd:`sudo curl -fsSL ${nF}/xyzen-darwin-arm64 -o /usr/local/bin/xyzen && sudo chmod +x /usr/local/bin/xyzen`},{key:"darwin-amd64",label:"macOS Intel",binary:"xyzen-darwin-amd64",curlCmd:`sudo curl -fsSL ${nF}/xyzen-darwin-amd64 -o /usr/local/bin/xyzen && sudo chmod +x /usr/local/bin/xyzen`},{key:"linux-amd64",label:"Linux x86_64",binary:"xyzen-linux-amd64",curlCmd:`sudo curl -fsSL ${nF}/xyzen-linux-amd64 -o /usr/local/bin/xyzen && sudo chmod +x /usr/local/bin/xyzen`},{key:"linux-arm64",label:"Linux ARM64",binary:"xyzen-linux-arm64",curlCmd:`sudo curl -fsSL ${nF}/xyzen-linux-arm64 -o /usr/local/bin/xyzen && sudo chmod +x /usr/local/bin/xyzen`},{key:"windows-amd64",label:"Windows x86_64",binary:"xyzen-windows-amd64.exe",curlCmd:`curl -fSL ${nF}/xyzen-windows-amd64.exe -o xyzen.exe`}];function m6r(){const t=navigator.userAgent.toLowerCase(),e=navigator.platform?.toLowerCase()??"";return t.includes("mac")||e.includes("mac")?Xq[0]:t.includes("win")||e.includes("win")?Xq[4]:(t.includes("linux"),Xq[2])}function g6r({title:t,children:e,className:n=""}){return A.jsxs("div",{className:`border border-neutral-200 dark:border-[#30363d] bg-white dark:bg-[#0d1117] ${n}`,children:[A.jsxs("div",{className:"flex items-center gap-2 border-b border-neutral-200 dark:border-[#30363d] px-3 py-2",children:[A.jsxs("div",{className:"flex gap-1.5",children:[A.jsx("div",{className:"h-2.5 w-2.5 bg-red-400 dark:bg-[#ff5f57]"}),A.jsx("div",{className:"h-2.5 w-2.5 bg-amber-400 dark:bg-[#febc2e]"}),A.jsx("div",{className:"h-2.5 w-2.5 bg-green-400 dark:bg-[#28c840]"})]}),A.jsx("span",{className:"ml-1 font-mono text-[11px] text-neutral-500 dark:text-[#8b949e]",children:t})]}),A.jsx("div",{className:"p-3 font-mono text-[12px] leading-relaxed",children:e})]})}function bRt({lines:t,onCopy:e}){const[n,r]=T.useState(!1),i=T.useCallback(async()=>{e&&(await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3))},[e]);return A.jsxs("div",{className:"group relative border border-neutral-200 dark:border-[#30363d] bg-neutral-100 dark:bg-[#010409]",children:[A.jsx("div",{className:"custom-scrollbar overflow-x-auto p-3",children:A.jsx("table",{className:"w-full border-collapse",children:A.jsx("tbody",{children:t.map((o,l)=>A.jsxs("tr",{children:[A.jsx("td",{className:"w-8 select-none pr-3 text-right align-top font-mono text-[11px] text-neutral-400 dark:text-[#484f58]",children:l+1}),A.jsx("td",{className:`whitespace-pre font-mono text-[12px] ${o.color?"":"text-neutral-900 dark:text-[#e6edf3]"}`,style:o.color?{color:o.color}:void 0,children:o.text})]},l))})})}),e&&A.jsx("button",{onClick:i,className:"absolute right-2 top-2 border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] p-1 text-neutral-500 dark:text-[#8b949e] opacity-0 transition-opacity hover:bg-neutral-100 dark:hover:bg-[#1f242b] hover:text-neutral-900 dark:hover:text-neutral-900 dark:text-[#e6edf3] group-hover:opacity-100",children:n?A.jsx(Vo,{className:"h-3.5 w-3.5 text-green-600 dark:text-[#3fb950]"}):A.jsx(D5,{className:"h-3.5 w-3.5"})})]})}function yRt({variant:t="capsule"}){const{runners:e,runnersLoading:n,fetchRunners:r,deleteRunner:i,updateRunner:o,openTerminal:l,connectRunnerEvents:u}=Un(Wo(g=>({runners:g.runners,runnersLoading:g.runnersLoading,fetchRunners:g.fetchRunners,deleteRunner:g.deleteRunner,updateRunner:g.updateRunner,openTerminal:g.openTerminal,connectRunnerEvents:g.connectRunnerEvents}))),[d,p]=T.useState(!1);T.useEffect(()=>(r(),u()),[r,u]);const m=T.useCallback(()=>{p(!1)},[]);return t==="panel"?A.jsx(h6r,{runners:e,runnersLoading:n,showCreate:d,onShowCreate:()=>p(!0),onDoneCreate:m,onDelete:i,onToggle:o,onOpenTerminal:l}):!n&&e.length===0&&!d?A.jsx("div",{className:"flex-1 flex flex-col bg-white dark:bg-[#0d1117]",children:A.jsx("div",{className:"custom-scrollbar flex-1 overflow-y-auto",children:A.jsx(vRt,{onConnect:()=>p(!0)})})}):A.jsx("div",{className:"flex-1 flex flex-col overflow-hidden bg-white dark:bg-[#0d1117]",children:A.jsxs("div",{className:"custom-scrollbar flex-1 overflow-y-auto",children:[d&&A.jsx("div",{className:"p-3",children:A.jsx(_Rt,{onDone:m})}),e.map(g=>A.jsx("div",{className:"p-3",children:A.jsx(wRt,{runner:g,onDelete:i,onToggle:o,onOpenTerminal:l,onAddAnother:()=>p(!0)})},g.id)),n&&e.length===0&&!d&&A.jsx("div",{className:"px-3 py-4 text-center",children:A.jsx("p",{className:"font-mono text-xs text-neutral-400 dark:text-[#484f58]",children:"loading..."})}),e.length>0&&!d&&A.jsx("div",{className:"px-3 pb-3",children:A.jsxs("button",{onClick:()=>p(!0),className:"flex w-full items-center justify-center gap-1.5 border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] py-2 font-mono text-xs text-neutral-500 dark:text-[#8b949e] transition-colors hover:border-neutral-400 dark:hover:border-[#8b949e] hover:text-neutral-900 dark:hover:text-neutral-900 dark:text-[#e6edf3]",children:[A.jsx(Dd,{className:"h-3 w-3"}),"+ runner"]})})]})})}function h6r({runners:t,runnersLoading:e,showCreate:n,onShowCreate:r,onDoneCreate:i,onDelete:o,onToggle:l,onOpenTerminal:u}){return A.jsxs("div",{className:"flex flex-col sm:flex-row h-full gap-px bg-white dark:bg-[#0d1117]",children:[A.jsx("div",{className:"custom-scrollbar sm:w-1/2 shrink-0 overflow-y-auto border-b sm:border-b-0 sm:border-r border-neutral-200 dark:border-[#21262d]",children:A.jsx(vRt,{onConnect:r})}),A.jsxs("div",{className:"custom-scrollbar sm:w-1/2 flex-1 overflow-y-auto",children:[n&&A.jsx("div",{className:"p-4",children:A.jsx(_Rt,{onDone:i})}),t.map(d=>A.jsx("div",{className:"p-4",children:A.jsx(wRt,{runner:d,onDelete:o,onToggle:l,onOpenTerminal:u,onAddAnother:r})},d.id)),e&&t.length===0&&!n&&A.jsx("div",{className:"px-4 py-8 text-center",children:A.jsx("p",{className:"font-mono text-xs text-neutral-400 dark:text-[#484f58]",children:"loading..."})}),!e&&t.length===0&&!n&&A.jsxs("div",{className:"flex flex-col items-center justify-center px-4 py-16",children:[A.jsx("p",{className:"font-mono text-sm text-neutral-500 dark:text-[#8b949e]",children:"No runners connected"}),A.jsx("p",{className:"mt-1 font-mono text-xs text-neutral-400 dark:text-[#484f58]",children:"Follow the steps above to get started"})]}),t.length>0&&!n&&A.jsx("div",{className:"px-4 pb-4",children:A.jsxs("button",{onClick:r,className:"flex w-full items-center justify-center gap-1.5 border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] py-2 font-mono text-xs text-neutral-500 dark:text-[#8b949e] transition-colors hover:border-neutral-400 dark:hover:border-[#8b949e] hover:text-neutral-900 dark:hover:text-neutral-900 dark:text-[#e6edf3]",children:[A.jsx(Dd,{className:"h-3 w-3"}),"+ runner"]})})]})]})}function f6r({onConnect:t}){const{t:e}=Cn(),{createRunnerToken:n,fetchRunners:r}=Un(Wo(N=>({createRunnerToken:N.createRunnerToken,fetchRunners:N.fetchRunners}))),[i,o]=T.useState("Disconnected"),[l,u]=T.useState(!1),[d,p]=T.useState(null),[m,g]=T.useState(!0),[h,f]=T.useState(()=>({enabled:q7(),supported:!0})),[b,y]=T.useState(null),v=T.useRef(void 0),_=T.useCallback(async()=>{const N=await n(vte);if(!N)return null;const L={runnerId:N.runner.id,token:N.token,name:vte};return pst(L),L},[n]);T.useEffect(()=>{(async()=>{try{const L=await yke();o(L),u(L==="Connecting"||typeof L=="object"&&"Connected"in L)}catch{o("Disconnected"),u(!1)}})()},[]),T.useEffect(()=>{let N=!1;return(async()=>{try{const M=await dst();N||f(M)}catch{N||f({enabled:q7(),supported:!1})}finally{N||g(!1)}})(),()=>{N=!0}},[]),T.useEffect(()=>{let N=!1;const L=async()=>{try{const R=await vke();N||y(R)}catch(R){N||y({supported:!1,platform:"unknown",screen_capture_permission:"unknown",accessibility_permission:"unknown",reason:String(R)})}},M=()=>{document.visibilityState==="visible"&&L()};return L(),window.addEventListener("focus",L),document.addEventListener("visibilitychange",M),()=>{N=!0,window.removeEventListener("focus",L),document.removeEventListener("visibilitychange",M)}},[]),T.useEffect(()=>gst(N=>{f(L=>({...L,enabled:N}))}),[]),T.useEffect(()=>{if(!l)return;const N=async()=>{try{const L=await yke();o(L)}catch{}};return N(),v.current=setInterval(N,2e3),()=>clearInterval(v.current)},[l]);const w=typeof i=="object"&&"Connected"in i,x=typeof i=="object"&&"Error"in i,k=T.useCallback(async()=>{if(p(null),l)try{await Y8n(),u(!1),o("Disconnected"),await r()}catch(N){p(String(N))}else try{await r();let N=xte();if(N){const L=N.runnerId,M=Un.getState().runners.find(R=>R.id===L);(!M||!M.is_active)&&(U7(),N=null)}if(!N&&(N=await _(),!N)){p("Failed to create runner token");return}try{await _te(N.token,wte())}catch(L){if(!String(L).includes("already running")){if(U7(),N=await _(),!N){p("Failed to recreate runner token");return}await _te(N.token,wte())}}u(!0),await r()}catch(N){U7(),p(String(N))}},[l,_,r]),C=T.useCallback(async N=>{g(!0);try{const L=await _ke(N);f(L),mst(N)}catch(L){p(String(L))}finally{g(!1)}},[]),E=w?e("capsule.sandbox.runner.online"):i==="Connecting"?e("capsule.sandbox.runner.connecting","Connecting..."):x?e("capsule.sandbox.runner.error","Error"):e("capsule.sandbox.runner.offline"),S=w?"bg-green-500 dark:bg-[#3fb950]":i==="Connecting"?"bg-amber-500 dark:bg-[#d29922]":"bg-neutral-400 dark:bg-[#484f58]",I=cst(b),B=b?.supported?e("capsule.sandbox.runner.computerUseReady",{platform:b.platform}):I==="both"?e("capsule.sandbox.runner.computerUseRequiresMacPermissions","请在系统设置 -> 隐私与安全性中允许 Xyzen Desktop 的“屏幕录制”和“辅助功能”。"):I==="screen_capture"?e("capsule.sandbox.runner.computerUseRequiresScreenCapturePermission","请在系统设置 -> 隐私与安全性 -> 屏幕录制中允许 Xyzen Desktop。"):I==="accessibility"?e("capsule.sandbox.runner.computerUseRequiresAccessibilityPermission","请在系统设置 -> 隐私与安全性 -> 辅助功能中允许 Xyzen Desktop。"):b?.reason||e("capsule.sandbox.runner.computerUseUnavailable","Computer use is unavailable on this desktop host.");return A.jsxs("div",{className:"space-y-4 p-4",children:[A.jsxs("div",{children:[A.jsx("h3",{className:"font-mono text-sm font-bold text-neutral-900 dark:text-[#e6edf3]",children:e("capsule.sandbox.runner.connectTitle")}),A.jsx("p",{className:"mt-1 font-mono text-xs text-neutral-500 dark:text-[#8b949e]",children:e("capsule.sandbox.runner.desktopHint","Built-in runner — no installation needed.")})]}),A.jsxs("div",{className:"flex items-center gap-3 border border-neutral-200 dark:border-[#30363d] bg-white dark:bg-[#0d1117] px-3 py-2.5",children:[A.jsx("div",{className:`h-2 w-2 shrink-0 ${S}`,style:w?{boxShadow:"0 0 6px rgba(63,185,80,0.5)"}:void 0}),A.jsx("span",{className:"flex-1 font-mono text-[12px] text-neutral-900 dark:text-[#e6edf3]",children:e("capsule.sandbox.runner.title","Runner")}),A.jsx("span",{className:"font-mono text-[10px] text-neutral-500 dark:text-[#8b949e]",children:E})]}),d&&A.jsx("div",{className:"border border-red-400/40 dark:border-red-500/40 bg-red-50 dark:bg-red-500/10 p-2",children:A.jsx("p",{className:"font-mono text-[11px] text-red-600 dark:text-[#f85149]",children:d})}),A.jsxs("div",{className:"flex items-center gap-3 border border-neutral-200 dark:border-[#30363d] bg-white dark:bg-[#0d1117] px-3 py-2.5",children:[A.jsxs("div",{className:"flex-1",children:[A.jsx("p",{className:"font-mono text-[12px] text-neutral-900 dark:text-[#e6edf3]",children:e("capsule.sandbox.runner.preventSleep")}),A.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-neutral-500 dark:text-[#8b949e]",children:e("capsule.sandbox.runner.preventSleepHint")}),!m&&!h.supported&&A.jsx("p",{className:"mt-1 font-mono text-[10px] text-amber-600 dark:text-[#d29922]",children:e("capsule.sandbox.runner.preventSleepUnsupported")})]}),A.jsx(ZR,{checked:h.enabled,onChange:C,disabled:m||!m&&!h.supported})]}),b&&A.jsx("div",{className:"border border-neutral-200 dark:border-[#30363d] bg-white dark:bg-[#0d1117] px-3 py-2.5",children:A.jsxs("div",{className:"flex items-start justify-between gap-3",children:[A.jsxs("div",{children:[A.jsx("p",{className:"font-mono text-[12px] text-neutral-900 dark:text-[#e6edf3]",children:e("capsule.sandbox.runner.computerUseTitle","Computer Use")}),A.jsx("p",{className:"mt-0.5 font-mono text-[10px] text-neutral-500 dark:text-[#8b949e]",children:B}),!b.supported&&A.jsxs("div",{className:"mt-2 space-y-1 font-mono text-[10px] text-neutral-500 dark:text-[#8b949e]",children:[A.jsxs("p",{children:[e("capsule.sandbox.runner.computerUsePermissionScreenCapture","屏幕录制"),":"," ",b.screen_capture_permission==="granted"?e("capsule.sandbox.runner.computerUsePermissionGranted","已授权"):b.screen_capture_permission==="denied"?e("capsule.sandbox.runner.computerUsePermissionDenied","未授权"):e("capsule.sandbox.runner.computerUsePermissionUnknown","未知")]}),A.jsxs("p",{children:[e("capsule.sandbox.runner.computerUsePermissionAccessibility","辅助功能"),":"," ",b.accessibility_permission==="granted"?e("capsule.sandbox.runner.computerUsePermissionGranted","已授权"):b.accessibility_permission==="denied"?e("capsule.sandbox.runner.computerUsePermissionDenied","未授权"):e("capsule.sandbox.runner.computerUsePermissionUnknown","未知")]})]})]}),A.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-2",children:[A.jsx("span",{className:`font-mono text-[10px] ${b.supported?"text-green-600 dark:text-[#3fb950]":"text-amber-600 dark:text-[#d29922]"}`,children:b.supported?e("capsule.sandbox.runner.computerUseAvailable","AVAILABLE"):e("capsule.sandbox.runner.computerUseUnavailableBadge","UNAVAILABLE")}),I&&A.jsx("button",{onClick:()=>{I==="accessibility"?K8n():V8n()},className:"border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] px-2 py-1 font-mono text-[10px] text-blue-600 dark:text-[#58a6ff] transition-colors hover:border-blue-500 dark:hover:border-[#58a6ff]",children:e("capsule.sandbox.runner.computerUseOpenSettings","打开设置")}),A.jsx("button",{onClick:()=>{vke().then(y).catch(N=>{y({supported:!1,platform:"unknown",screen_capture_permission:"unknown",accessibility_permission:"unknown",reason:String(N)})})},className:"border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] px-2 py-1 font-mono text-[10px] text-neutral-500 dark:text-[#8b949e] transition-colors hover:text-neutral-900 dark:hover:text-[#e6edf3]",children:e("capsule.sandbox.runner.computerUseRefresh","重新检查")})]})]})}),A.jsx("button",{onClick:k,className:`w-full px-3 py-2 font-mono text-[12px] font-semibold text-white transition-colors ${l?"border border-red-500 dark:border-[#da3633] bg-red-600 dark:bg-[#da3633] hover:bg-red-700 dark:hover:bg-[#f85149]":"border border-green-500 dark:border-[#3fb950] bg-green-600 dark:bg-[#238636] hover:bg-green-700 dark:hover:bg-[#2ea043]"}`,children:l?e("capsule.sandbox.runner.stopRunner","Stop Runner"):e("capsule.sandbox.runner.startRunner","Start Runner")}),!l&&A.jsxs(A.Fragment,{children:[A.jsx("div",{className:"border-t border-neutral-200 dark:border-[#21262d]"}),A.jsx("button",{onClick:t,className:"w-full border border-neutral-200 dark:border-[#30363d] bg-neutral-50 dark:bg-[#161b22] px-3 py-2 font-mono text-[12px] text-neutral-500 dark:text-[#8b949e] transition-colors hover:border-neutral-400 dark:hover:border-[#8b949e] hover:text-neutral-900 dark:hover:text-[#e6edf3]",children:e("capsule.sandbox.runner.generateToken")})]})]})}function vRt({onConnect:t}){return Bc()?A.jsx(f6r,{onConnect:t}):A.jsx(y6r,{onConnect:t})}function A6r(t){return`Please help me download and install Xyzen Runner on my machine.
|
|
609
609
|
|
|
610
610
|
Run the following command in the terminal:
|
|
611
611
|
|