groove-dev 0.27.188 → 0.27.190

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.
@@ -41,7 +41,7 @@ ${typeof C.result=="string"?C.result.slice(0,500):JSON.stringify(C.result).slice
41
41
 
42
42
  `:" ";P[P.length-1]={...T,text:T.text+R+C,timestamp:Date.now()}}else P.push({from:"agent",text:C,timestamp:Date.now()});U[b]=P.slice(-100),t({chatHistory:U}),$A(U)}const M=s().conversations.find(R=>R.agentId===b);if(M){const R={...s().conversationMessages};R[M.id]||(R[M.id]=[]);const Y=[...R[M.id]],W=Y[Y.length-1],ee=W&&W.from==="assistant"&&Date.now()-W.timestamp<8e3;if(!(ee&&(W.text===C||W.text.endsWith(C)))){if(ee){const _=v.subtype==="assistant"?`
43
43
 
44
- `:" ";Y[Y.length-1]={...W,text:W.text+_+C,timestamp:Date.now()}}else Y.push({from:"assistant",text:C,timestamp:Date.now()});R[M.id]=Y.slice(-200),t({conversationMessages:R,streamingConversationId:M.id}),ft("groove:conversationMessages",R)}}}if(S&&S.trim()){const C={...s().activityLog};C[b]||(C[b]=[]),C[b]=[...C[b].slice(-200),{timestamp:Date.now(),text:S.trim(),type:v.type,subtype:"tool"}],t({activityLog:C}),ft("groove:activityLog",C)}if(s().workspaceMode&&Array.isArray(v.data)){const C=new Set(["Write","Edit","write_file","edit_file","create_file"]);for(const U of v.data){if(U.type!=="tool_use"||!C.has(U.name))continue;const P=((l=U.input)==null?void 0:l.file_path)||((c=U.input)==null?void 0:c.path);if(P&&b===s().workspaceAgentId){const T=P.replace(/^\/[^/]+.*?\/groove\//,"");s().editorActiveFile?t(F=>({editorOpenTabs:F.editorOpenTabs.includes(T)?F.editorOpenTabs:[...F.editorOpenTabs,T]})):s().openFile(T)}}}break}case"agent:exit":{if(r.status==="waiting_for_input"){const C=s().agents.find(U=>U.id===r.agentId);s().addToast("info",`${(C==null?void 0:C.name)||r.agentId.slice(0,8)} needs your input`,"Check the question popup below");break}const b=s().agents.find(C=>C.id===r.agentId),v=(b==null?void 0:b.name)||r.agentId,y=r.status==="killed"||r.code===143||r.code===137,S=r.status==="completed"?`${v} completed`:y?`${v} stopped`:`${v} crashed (exit ${r.code})`,j=r.status==="completed"?"success":y?"info":"warning";s().addToast(j,S,r.error?r.error.slice(0,200):void 0),s().thinkingAgents.has(r.agentId)&&t(C=>{const U=new Set(C.thinkingAgents);return U.delete(r.agentId),{thinkingAgents:U}});const N=s().conversations.find(C=>C.agentId===r.agentId);if(N&&s().streamingConversationId===N.id&&t({sendingMessage:!1,streamingConversationId:null}),r.error&&r.agentId&&s().addChatMessage(r.agentId,"system",`Crashed: ${r.error}`),s().workspaceAgentId===r.agentId){const C=s().agents.filter(P=>P.id!==r.agentId&&P.teamId===s().activeTeamId),U=C.find(P=>P.status==="running")||C[0];t({workspaceAgentId:(U==null?void 0:U.id)||null})}(b==null?void 0:b.role)==="planner"&&r.status==="completed"&&setTimeout(()=>s().checkRecommendedTeam(),1e3);break}case"innerchat:turn":{const{thread:b,turn:v}=r.data;if(v.status==="failed"){s().addToast("error",`InnerChat to ${v.to.name} failed`,v.error);break}t(y=>{const S={...y.chatHistory},j=(P,T)=>({from:"innerchat",text:v.text,timestamp:v.timestamp,isQuery:!1,innerchat:{turnId:v.id,threadId:b.id,kind:v.kind,peer:P,direction:T}}),N=(P,T)=>{S[P]=[...S[P]||[],T].slice(-100)};v.kind==="ask"&&N(v.from.id,j(v.to,"out")),N(v.to.id,j(v.from,"in")),$A(S);const C={...y.innerchatAnswers};v.kind==="answer"&&(C[v.from.id]={...C[v.from.id]||{},[v.text.trim()]:{peer:v.to,threadId:b.id}});const U={...y.innerchatThreads,[b.id]:b};return ft("groove:innerchatThreads",U),{chatHistory:S,innerchatThreads:U,innerchatAnswers:C}});break}case"recommended-team:ready":s().recommendedTeam||s().checkRecommendedTeam();break;case"phase2:spawned":s().addToast("info",`QC agent ${r.name} auto-spawned`,"Auditing phase 1 work");break;case"preview:ready":{const b=r.teamId?`/api/preview/${r.teamId}/proxy/`:r.url;t(v=>({teamPreviews:{...v.teamPreviews,[r.teamId]:{url:b,kind:r.kind,active:!0}}})),s().addToast("success","Project ready to preview",r.url,{label:"Open Preview",onClick:()=>s().openPreview(b,r.teamId,r.kind)},{persistent:!0,actions:[{label:"View in Browser",url:r.url}]});break}case"preview:failed":{const b=r.kind||"";b!=="no_preview"&&b!=="cli"&&b!=="none"&&s().addToast("warning","Preview could not launch",r.reason?String(r.reason).slice(0,200):"Unknown error");break}case"preview:stopped":{const b=s().teamPreviews[r.teamId];b&&t(v=>({teamPreviews:{...v.teamPreviews,[r.teamId]:{...b,active:!1}}}));break}case"agent:stalled":{const b=r.agentName||r.agentId,v=Math.round((r.silentMs||0)/1e3);s().addToast("warning",`${b} may be stalled`,`No output for ${v}s — API stream may be hung`);break}case"knock:denied":{const b=r.agentName||r.agentId;s().addToast("warning",`${b} blocked`,`${r.toolName} on ${r.target} — ${r.reason||"scope conflict"}`);break}case"phase2:failed":s().addToast("error","QC agent failed to spawn",r.error||"Unknown error");break;case"agent:message_queued":s().addChatMessage(r.agentId,"system","Agent is working — message will be delivered when it finishes.");break;case"agent:question":t(b=>({pendingQuestions:[...b.pendingQuestions,r.data]}));break;case"agent:question:resolved":t(b=>({pendingQuestions:b.pendingQuestions.filter(v=>v.agentId!==r.agentId)}));break;case"ollama:pull:progress":t({ollamaPullProgress:{...s().ollamaPullProgress,[r.model]:{status:"pulling",progress:r.progress}}});break;case"ollama:pull:complete":{const b={...s().ollamaPullProgress};delete b[r.model],t({ollamaPullProgress:b}),s().fetchOllamaStatus();break}case"ollama:pull:error":{const b={...s().ollamaPullProgress};delete b[r.model],t({ollamaPullProgress:b}),s().addToast("error",`Model pull failed: ${r.error}`);break}case"ollama:model:loaded":s().fetchOllamaStatus();break;case"ollama:model:unloaded":s().fetchOllamaStatus();break;case"ollama:model:imported":s().fetchOllamaStatus();break;case"lab:runtime:added":case"lab:runtime:updated":case"lab:runtime:removed":case"lab:runtime:started":case"lab:runtime:stopped":case"llama:server:stopped":s().fetchLabRuntimes();break;case"lab:preset:created":case"lab:preset:updated":case"lab:preset:deleted":break;case"rotation:start":break;case"rotation:complete":{const b=r.agentId,v=r.oldAgentId;if(!b||!v)break;t(y=>{var F,M,R;const S={...y.chatHistory},j={...y.tokenTimeline},N={...y.activityLog},C={...y.chatInputs};(F=S[v])!=null&&F.length&&(S[b]=[...S[v]],delete S[v]),(M=j[v])!=null&&M.length&&(j[b]=[...j[v]],delete j[v]),(R=N[v])!=null&&R.length&&(N[b]=[...N[v]],delete N[v]),C[v]&&(C[b]=C[v],delete C[v]);const U=y.detailPanel;let P=U,T=y.teamDetailPanels;if((U==null?void 0:U.type)==="agent"&&U.agentId===v){const Y={type:"agent",agentId:b};P=Y;const W=s().activeTeamId;T={...y.teamDetailPanels,[W]:Y}}let B=y.fleetSelectedAgents;(B[0]===v||B[1]===v)&&(B=[B[0]===v?b:B[0],B[1]===v?b:B[1]]);try{localStorage.setItem("groove:chatHistory",JSON.stringify(S))}catch{}return{chatHistory:S,tokenTimeline:j,activityLog:N,chatInputs:C,detailPanel:P,teamDetailPanels:T,fleetSelectedAgents:B}});break}case"rotation:failed":s().addToast("error","Rotation failed",r.error);break;case"file:changed":{const b=s().editorRecentSaves[r.path];if(b&&Date.now()-b<2e3)break;if(s().workspaceMode&&r.path&&!s().workspaceSnapshots[r.path]){const v=s().editorFiles[r.path];v!=null&&v.content&&s().captureSnapshot(r.path,v.content)}s().editorFiles[r.path]&&s().reloadFile(r.path);break}case"file:tree-changed":{s().fetchTreeDir(r.path||"");break}case"team:created":case"team:deleted":case"team:updated":s().fetchTeams();break;case"teams:reordered":r.teams&&t({teams:r.teams});break;case"approval:request":t(b=>({pendingApprovals:[...b.pendingApprovals,r.data]}));break;case"approval:resolved":{const b=r.data;t(v=>({pendingApprovals:v.pendingApprovals.filter(y=>y.id!==b.id),resolvedApprovals:[b,...v.resolvedApprovals].slice(0,200)}));break}case"conflict:detected":s().addToast("error",`Scope conflict: ${r.agentName||"agent"}`,r.filePath?`File: ${r.filePath}`:void 0);break;case"qc:activated":s().addToast("info","QC agent activated",`${r.agentCount||"4+"} agents running`);break;case"journalist:cycle":t({journalistStatus:r.data||null});break;case"schedule:execute":s().addToast("info",`Scheduled agent spawned: ${r.name||r.role||"agent"}`),s().fetchAutomations();break;case"schedule:created":case"schedule:updated":case"schedule:deleted":s().fetchAutomations();break;case"auto-agent:created":case"auto-agent:updated":case"auto-agent:deleted":case"auto-agent:paused":case"auto-agent:resumed":case"auto-agent:cycle-complete":case"auto-agent:auto-paused":case"auto-agent:state-updated":case"auto-agent:iteration-started":s().fetchAutoAgents();break;case"gateway:status":t({gateways:r.data||[]});break;case"provider:status-changed":t({_providerRefreshTick:Date.now()});break;case"federation:whitelist":t(b=>({federation:{...b.federation,whitelist:r.data||[]}}));break;case"federation:connection":t(b=>{const v=[...b.federation.connections],y=v.findIndex(S=>{var j;return S.ip===((j=r.data)==null?void 0:j.ip)});return y>=0?v[y]={...v[y],...r.data}:v.push(r.data),{federation:{...b.federation,connections:v}}});break;case"federation:pouch":case"federation:pouch-log":t(b=>({federation:{...b.federation,pouchLog:[...b.federation.pouchLog,r.data].slice(-200)}}));break;case"project-dir:changed":t({projectDir:(A=r.data)==null?void 0:A.projectDir,showProjectPicker:!1});break;case"tunnel.connected":s().fetchTunnels(),t({tunnelConnectStep:null});break;case"tunnel.status":{t({tunnelConnectStep:r.data});break}case"tunnel.disconnected":s().fetchTunnels();break;case"tunnel.health":{const b=s().savedTunnels.map(v=>{var y;return v.id===((y=r.data)==null?void 0:y.id)?{...v,latencyMs:r.data.latencyMs,healthy:r.data.healthy}:v});t({savedTunnels:b});break}case"tunnel.version-info":{const b=s().savedTunnels.map(v=>v.id===r.data.id?{...v,localVersion:r.data.localVersion,remoteVersion:r.data.remoteVersion,versionMatch:r.data.match}:v);t({savedTunnels:b});break}case"tunnel.version-mismatch":{const b=s().savedTunnels.map(v=>v.id===r.data.id?{...v,localVersion:r.data.localVersion,remoteVersion:r.data.remoteVersion,versionMatch:!1}:v);t({savedTunnels:b}),s().addToast("warning","Version mismatch",`Remote v${r.data.remoteVersion} — local v${r.data.localVersion}. ${r.data.message||""}`);break}case"tunnel.upgrade-failed":{s().addToast("error","Remote upgrade failed",r.data.error||"Unknown error");break}case"subscription:updated":{const b={subscription:r.data};((f=r.data)==null?void 0:f.active)===!0&&!s().marketplaceAuthenticated&&(b.marketplaceAuthenticated=!0),t(b),G.get("/edition").then(v=>{t({edition:v.edition||"community",subscription:{plan:v.plan||"community",status:v.status||(v.subscriptionActive?"active":"none"),active:v.subscriptionActive===!0,features:v.features||[],seats:v.seats||1,periodEnd:v.periodEnd||null,cancelAtPeriodEnd:v.cancelAtPeriodEnd||!1}})}).catch(()=>{}),s().fetchTunnels();break}case"auth:expired":t({marketplaceAuthenticated:!1,marketplaceUser:null}),s().addToast("warning","Session expired","Please sign in again");break;case"network:node:status":{const{__proto__:b,constructor:v,prototype:y,...S}=r.data||{};t({networkNode:{...s().networkNode,...S}});break}case"network:node:event":{const b=r.data||{};t(v=>({networkEvents:[...v.networkEvents,{...b,timestamp:b.timestamp||Date.now()}].slice(-100)}));break}case"signal_connected":{const b=r.data||{};t(v=>({networkEvents:[...v.networkEvents,{level:"connected",msg:String(b.msg||b.message||"Connected to signal").slice(0,500),detail:b.detail||b.url||void 0,timestamp:b.timestamp||Date.now()}].slice(-100)}));break}case"matched":{const b=r.data||{};t(v=>({networkEvents:[...v.networkEvents,{level:"session",msg:String(b.msg||b.message||"Session matched").slice(0,500),detail:b.detail||b.peer||b.nodeId||void 0,timestamp:b.timestamp||Date.now()}].slice(-100)}));break}case"network:status":{const b=r.data||{},v={networkStatus:{...s().networkStatus,...b}};if(b.compute){const P=b.compute;v.networkCompute={totalRamMb:P.totalRamMb??P.total_ram_mb??0,totalVramMb:P.totalVramMb??P.total_vram_mb??0,totalCpuCores:P.totalCpuCores??P.total_cpu_cores??0,totalBandwidthMbps:P.totalBandwidthMbps??P.total_bandwidth_mbps??0,activeNodes:P.activeNodes??P.active_nodes??0,totalNodes:P.totalNodes??P.total_nodes??0,avgLoad:P.avgLoad??P.avg_load??0}}else if(Array.isArray(b.nodes)&&b.nodes.length>0){const P=b.nodes,T=P.filter(B=>B.status==="active");v.networkCompute={totalRamMb:P.reduce((B,F)=>B+(F.ram_mb||0),0),totalVramMb:P.reduce((B,F)=>B+(F.vram_mb||0),0),totalCpuCores:P.reduce((B,F)=>B+(F.cpu_cores||0),0),totalBandwidthMbps:P.reduce((B,F)=>B+(F.bandwidth_mbps||0),0),activeNodes:T.length,totalNodes:P.length,avgLoad:T.length>0?T.reduce((B,F)=>B+(F.load||0),0)/T.length:0}}t(v);const y=b.nodes||[],S=s().networkNode.nodeId,j=S?y.find(P=>(P.node_id||P.nodeId)===S):null,N=y.filter(P=>P.status==="active"),C={t:Date.now(),globalSessions:b.activeSessions||0,mySessions:(j==null?void 0:j.active_sessions)??(j==null?void 0:j.sessions)??0,nodeCount:N.length,avgLoad:N.length>0?N.reduce((P,T)=>P+(T.load||0),0)/N.length:0,myLoad:(j==null?void 0:j.load)??0,totalVramMb:y.reduce((P,T)=>P+(T.vram_mb||0),0),totalRamMb:y.reduce((P,T)=>P+(T.ram_mb||0),0)};let U=[...s().networkSnapshots,C];U.length>100&&(U=U.slice(-100)),t({networkSnapshots:U});break}case"network:install:progress":{const{step:b,message:v,percent:y}=r.data||{};b==="done"?(t({networkInstalled:!0,networkInstallProgress:{installing:!1,step:null,message:null,percent:0,error:null}}),s().addToast("success","Network package installed")):t(b==="error"?{networkInstallProgress:{installing:!1,step:"error",message:v||"Install failed",percent:0,error:v||"Install failed"}}:{networkInstallProgress:{installing:!0,step:b||"progress",message:v||"",percent:Number.isFinite(y)?Math.max(0,Math.min(100,y)):s().networkInstallProgress.percent,error:null}});break}case"network:update:available":{const{installed:b,latest:v,updateAvailable:y}=r.data||{};t({networkVersion:{installed:b??s().networkVersion.installed,latest:v??s().networkVersion.latest,updateAvailable:!!y}});break}case"network:update:progress":{const{step:b,message:v,percent:y,version:S,error:j}=r.data||{};b==="done"?(t({networkUpdateProgress:{updating:!1,step:null,message:null,percent:0,error:null},networkVersion:{...s().networkVersion,installed:S||s().networkVersion.latest||s().networkVersion.installed,updateAvailable:!1}}),s().addToast("success","Network package updated")):b==="error"?(t({networkUpdateProgress:{updating:!1,step:"error",message:v||j||"Update failed",percent:0,error:v||j||"Update failed"}}),s().addToast("error","Network update failed",v||j)):t({networkUpdateProgress:{updating:!0,step:b||"progress",message:v||"",percent:Number.isFinite(y)?Math.max(0,Math.min(100,y)):s().networkUpdateProgress.percent,error:null}});break}case"training:status":{const b={trainingOptIn:((x=r.data)==null?void 0:x.optedIn)??!1,trainingStats:r.data};(h=r.data)!=null&&h.optedIn&&(b.dataSharingModalOpen=!1),t(b);break}case"config:updated":s().fetchBetaStatus(),s().fetchNetworkInstallStatus();break;case"conversation:created":{const b=r.data;b&&t(v=>({conversations:[b,...v.conversations.filter(y=>y.id!==b.id)]}));break}case"conversation:updated":{const b=r.data;b&&t(v=>({conversations:v.conversations.map(y=>y.id===b.id?{...y,...b}:y)}));break}case"conversation:deleted":{const b=((g=r.data)==null?void 0:g.id)||r.id;b&&t(v=>{const y=v.conversations.filter(N=>N.id!==b),S={...v.conversationMessages};delete S[b];const j=v.activeConversationId===b?null:v.activeConversationId;return j!==v.activeConversationId&&localStorage.setItem("groove:activeConversationId",""),{conversations:y,conversationMessages:S,activeConversationId:j}});break}case"conversation:tool":{const{conversationId:b,name:v,summary:y}=r.data||r;if(!b)break;t(S=>{const j={...S.conversationActiveTools};return j[b]={name:v||"Tool",summary:y||null,timestamp:Date.now()},{conversationActiveTools:j}});break}case"conversation:chunk":{const{conversationId:b,text:v}=r.data||r;if(!b||!v)break;t(y=>{const S={...y.conversationMessages};S[b]||(S[b]=[]);const j=[...S[b]],N=j[j.length-1];N&&N.from==="assistant"&&Date.now()-N.timestamp<3e4?j[j.length-1]={...N,text:N.text+v,timestamp:Date.now()}:j.push({from:"assistant",text:v,timestamp:Date.now()}),S[b]=j.slice(-200);const C={...y.conversationActiveTools};return delete C[b],{conversationMessages:S,streamingConversationId:b,conversationActiveTools:C}});break}case"conversation:complete":{const{conversationId:b}=r.data||r;if(b&&s().streamingConversationId===b){const v={...s().conversationActiveTools};delete v[b],t({sendingMessage:!1,streamingConversationId:null,conversationActiveTools:v})}b&&ft("groove:conversationMessages",s().conversationMessages);break}case"conversation:image":{const{conversationId:b,prompt:v,url:y,b64_json:S,mimeType:j,model:N,provider:C}=r.data||r;if(!b)break;const U=y||(S?`data:${j||"image/png"};base64,${S}`:null);t(P=>{const T={...P.conversationMessages};T[b]||(T[b]=[]);const B=[...T[b]],F=B.findLastIndex(R=>R.type==="image-loading"&&R.prompt===v);F>=0?B[F]={from:"assistant",type:"image",imageUrl:U,prompt:v,model:N,provider:C,timestamp:Date.now()}:B.push({from:"assistant",type:"image",imageUrl:U,prompt:v,model:N,provider:C,timestamp:Date.now()}),T[b]=B.slice(-200),ft("groove:conversationMessages",T);const M=P.streamingConversationId===b;return{conversationMessages:T,sendingMessage:M?!1:P.sendingMessage,streamingConversationId:M?null:P.streamingConversationId}});break}case"conversation:image-progress":{const{conversationId:b,status:v,prompt:y,error:S}=r.data||r;if(!b)break;v==="generating"?t(j=>{const N={...j.conversationMessages};return N[b]||(N[b]=[]),N[b]=[...N[b],{from:"assistant",type:"image-loading",prompt:y,timestamp:Date.now()}],{conversationMessages:N,streamingConversationId:b}}):v==="error"&&t(j=>{const N={...j.conversationMessages};N[b]||(N[b]=[]);const C=[...N[b]],U=C.findLastIndex(T=>T.type==="image-loading");U>=0&&C.splice(U,1),C.push({from:"system",text:`Image generation failed: ${S||"Unknown error"}`,timestamp:Date.now()}),N[b]=C,ft("groove:conversationMessages",N);const P=j.streamingConversationId===b;return{conversationMessages:N,sendingMessage:P?!1:j.sendingMessage,streamingConversationId:P?null:j.streamingConversationId}});break}case"conversation:error":{const{conversationId:b,error:v}=r.data||r;b&&t(y=>{const S={...y.conversationMessages};S[b]||(S[b]=[]),S[b]=[...S[b],{from:"system",text:`Error: ${v||"Unknown error"}`,timestamp:Date.now()}],ft("groove:conversationMessages",S);const j=y.streamingConversationId===b;return{conversationMessages:S,sendingMessage:j?!1:y.sendingMessage,streamingConversationId:j?null:y.streamingConversationId}});break}case"network:token:timing":{const{__proto__:b,constructor:v,prototype:y,...S}=r.data||{},j={networkTokenTiming:S,networkPerfSnapshots:[...s().networkPerfSnapshots,{t:Date.now(),tps:S.tps||0}].slice(-100)};if(Array.isArray(S.stages)){const N={...s().networkNodeTelemetry},C=new Set(["__proto__","constructor","prototype"]);for(const U of S.stages){const P=(O=U.node_telemetry)==null?void 0:O.node_id;P&&typeof P=="string"&&!C.has(P)&&(N[P]={...U.node_telemetry,forward_ms:U.forward_ms,updatedAt:Date.now()})}j.networkNodeTelemetry=N}t(j);break}case"network:timing:summary":{const{__proto__:b,constructor:v,prototype:y,...S}=r.data||{};t(j=>({networkBenchmarks:[...j.networkBenchmarks,S].slice(-100)}));break}case"keeper:saved":case"keeper:updated":case"keeper:deleted":s().fetchKeeperItems();break}},n.onclose=()=>{za&&(clearInterval(za),za=null),t({connected:!1,hydrated:!1,ws:null,daemonHost:null,tunneled:!1,remoteHomedir:null}),setTimeout(()=>s().connect(),2e3)},n.onerror=()=>n.close()}}));function pN(t){p.useEffect(()=>{function s(n){for(const a of t){const r=a.meta?n.metaKey||n.ctrlKey:!0,l=a.shift?n.shiftKey:!n.shiftKey;if(n.key.toLowerCase()===a.key.toLowerCase()&&r&&l){n.preventDefault(),a.handler();return}}}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t])}function cd(){return!!(window.groove||navigator.userAgent.includes("Electron"))}function gN(){var t;return((t=window.groove)==null?void 0:t.platform)||"browser"}function sO(t){window.groove?window.groove.openExternal(t):window.open(t,"_blank")}async function wE(t={}){var s,n;return(n=(s=window.groove)==null?void 0:s.folders)!=null&&n.select?window.groove.folders.select(t):null}async function ON(t){var s,n;if((n=(s=window.groove)==null?void 0:s.integrations)!=null&&n.oauthStart)return window.groove.integrations.oauthStart(t);window.open(t,"_blank","noopener")}function bN(t){var s,n,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(s=0;s<r;s++)t[s]&&(n=bN(t[s]))&&(a&&(a+=" "),a+=n)}else for(n in t)t[n]&&(a&&(a+=" "),a+=n);return a}function jE(){for(var t,s,n=0,a="",r=arguments.length;n<r;n++)(t=arguments[n])&&(s=bN(t))&&(a&&(a+=" "),a+=s);return a}const QE=(t,s)=>{const n=new Array(t.length+s.length);for(let a=0;a<t.length;a++)n[a]=t[a];for(let a=0;a<s.length;a++)n[t.length+a]=s[a];return n},NE=(t,s)=>({classGroupId:t,validator:s}),vN=(t=new Map,s=null,n)=>({nextPart:t,validators:s,classGroupId:n}),ex="-",Dw=[],SE="arbitrary..",CE=t=>{const s=kE(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return BE(c);const A=c.split(ex),f=A[0]===""&&A.length>1?1:0;return yN(A,f,s)},getConflictingClassGroupIds:(c,A)=>{if(A){const f=a[c],x=n[c];return f?x?QE(x,f):f:x||Dw}return n[c]||Dw}}},yN=(t,s,n)=>{if(t.length-s===0)return n.classGroupId;const r=t[s],l=n.nextPart.get(r);if(l){const x=yN(t,s+1,l);if(x)return x}const c=n.validators;if(c===null)return;const A=s===0?t.join(ex):t.slice(s).join(ex),f=c.length;for(let x=0;x<f;x++){const h=c[x];if(h.validator(A))return h.classGroupId}},BE=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const s=t.slice(1,-1),n=s.indexOf(":"),a=s.slice(0,n);return a?SE+a:void 0})(),kE=t=>{const{theme:s,classGroups:n}=t;return TE(n,s)},TE=(t,s)=>{const n=vN();for(const a in t){const r=t[a];fb(r,n,a,s)}return n},fb=(t,s,n,a)=>{const r=t.length;for(let l=0;l<r;l++){const c=t[l];UE(c,s,n,a)}},UE=(t,s,n,a)=>{if(typeof t=="string"){EE(t,s,n);return}if(typeof t=="function"){PE(t,s,n,a);return}FE(t,s,n,a)},EE=(t,s,n)=>{const a=t===""?s:wN(s,t);a.classGroupId=n},PE=(t,s,n,a)=>{if($E(t)){fb(t(a),s,n,a);return}s.validators===null&&(s.validators=[]),s.validators.push(NE(n,t))},FE=(t,s,n,a)=>{const r=Object.entries(t),l=r.length;for(let c=0;c<l;c++){const[A,f]=r[c];fb(f,wN(s,A),n,a)}},wN=(t,s)=>{let n=t;const a=s.split(ex),r=a.length;for(let l=0;l<r;l++){const c=a[l];let A=n.nextPart.get(c);A||(A=vN(),n.nextPart.set(c,A)),n=A}return n},$E=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,RE=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,n=Object.create(null),a=Object.create(null);const r=(l,c)=>{n[l]=c,s++,s>t&&(s=0,a=n,n=Object.create(null))};return{get(l){let c=n[l];if(c!==void 0)return c;if((c=a[l])!==void 0)return r(l,c),c},set(l,c){l in n?n[l]=c:r(l,c)}}},nO="!",Lw=":",ME=[],Hw=(t,s,n,a,r)=>({modifiers:t,hasImportantModifier:s,baseClassName:n,maybePostfixModifierPosition:a,isExternal:r}),IE=t=>{const{prefix:s,experimentalParseClassName:n}=t;let a=r=>{const l=[];let c=0,A=0,f=0,x;const h=r.length;for(let y=0;y<h;y++){const S=r[y];if(c===0&&A===0){if(S===Lw){l.push(r.slice(f,y)),f=y+1;continue}if(S==="/"){x=y;continue}}S==="["?c++:S==="]"?c--:S==="("?A++:S===")"&&A--}const g=l.length===0?r:r.slice(f);let O=g,b=!1;g.endsWith(nO)?(O=g.slice(0,-1),b=!0):g.startsWith(nO)&&(O=g.slice(1),b=!0);const v=x&&x>f?x-f:void 0;return Hw(l,b,O,v)};if(s){const r=s+Lw,l=a;a=c=>c.startsWith(r)?l(c.slice(r.length)):Hw(ME,!1,c,void 0,!0)}if(n){const r=a;a=l=>n({className:l,parseClassName:r})}return a},zE=t=>{const s=new Map;return t.orderSensitiveModifiers.forEach((n,a)=>{s.set(n,1e6+a)}),n=>{const a=[];let r=[];for(let l=0;l<n.length;l++){const c=n[l],A=c[0]==="[",f=s.has(c);A||f?(r.length>0&&(r.sort(),a.push(...r),r=[]),a.push(c)):r.push(c)}return r.length>0&&(r.sort(),a.push(...r)),a}},_E=t=>({cache:RE(t.cacheSize),parseClassName:IE(t),sortModifiers:zE(t),...CE(t)}),DE=/\s+/,LE=(t,s)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:r,sortModifiers:l}=s,c=[],A=t.trim().split(DE);let f="";for(let x=A.length-1;x>=0;x-=1){const h=A[x],{isExternal:g,modifiers:O,hasImportantModifier:b,baseClassName:v,maybePostfixModifierPosition:y}=n(h);if(g){f=h+(f.length>0?" "+f:f);continue}let S=!!y,j=a(S?v.substring(0,y):v);if(!j){if(!S){f=h+(f.length>0?" "+f:f);continue}if(j=a(v),!j){f=h+(f.length>0?" "+f:f);continue}S=!1}const N=O.length===0?"":O.length===1?O[0]:l(O).join(":"),C=b?N+nO:N,U=C+j;if(c.indexOf(U)>-1)continue;c.push(U);const P=r(j,S);for(let T=0;T<P.length;++T){const B=P[T];c.push(C+B)}f=h+(f.length>0?" "+f:f)}return f},HE=(...t)=>{let s=0,n,a,r="";for(;s<t.length;)(n=t[s++])&&(a=jN(n))&&(r&&(r+=" "),r+=a);return r},jN=t=>{if(typeof t=="string")return t;let s,n="";for(let a=0;a<t.length;a++)t[a]&&(s=jN(t[a]))&&(n&&(n+=" "),n+=s);return n},XE=(t,...s)=>{let n,a,r,l;const c=f=>{const x=s.reduce((h,g)=>g(h),t());return n=_E(x),a=n.cache.get,r=n.cache.set,l=A,A(f)},A=f=>{const x=a(f);if(x)return x;const h=LE(f,n);return r(f,h),h};return l=c,(...f)=>l(HE(...f))},GE=[],js=t=>{const s=n=>n[t]||GE;return s.isThemeGetter=!0,s},QN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,NN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ZE=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,VE=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,KE=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,qE=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,WE=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,YE=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xo=t=>ZE.test(t),at=t=>!!t&&!Number.isNaN(Number(t)),mo=t=>!!t&&Number.isInteger(Number(t)),Mp=t=>t.endsWith("%")&&at(t.slice(0,-1)),Sr=t=>VE.test(t),SN=()=>!0,JE=t=>KE.test(t)&&!qE.test(t),xb=()=>!1,eP=t=>WE.test(t),tP=t=>YE.test(t),sP=t=>!Me(t)&&!Ie(t),nP=t=>Do(t,kN,xb),Me=t=>QN.test(t),mi=t=>Do(t,TN,JE),Xw=t=>Do(t,dP,at),aP=t=>Do(t,EN,SN),rP=t=>Do(t,UN,xb),Gw=t=>Do(t,CN,xb),oP=t=>Do(t,BN,tP),Mu=t=>Do(t,PN,eP),Ie=t=>NN.test(t),fA=t=>_i(t,TN),iP=t=>_i(t,UN),Zw=t=>_i(t,CN),lP=t=>_i(t,kN),cP=t=>_i(t,BN),Iu=t=>_i(t,PN,!0),AP=t=>_i(t,EN,!0),Do=(t,s,n)=>{const a=QN.exec(t);return a?a[1]?s(a[1]):n(a[2]):!1},_i=(t,s,n=!1)=>{const a=NN.exec(t);return a?a[1]?s(a[1]):n:!1},CN=t=>t==="position"||t==="percentage",BN=t=>t==="image"||t==="url",kN=t=>t==="length"||t==="size"||t==="bg-size",TN=t=>t==="length",dP=t=>t==="number",UN=t=>t==="family-name",EN=t=>t==="number"||t==="weight",PN=t=>t==="shadow",uP=()=>{const t=js("color"),s=js("font"),n=js("text"),a=js("font-weight"),r=js("tracking"),l=js("leading"),c=js("breakpoint"),A=js("container"),f=js("spacing"),x=js("radius"),h=js("shadow"),g=js("inset-shadow"),O=js("text-shadow"),b=js("drop-shadow"),v=js("blur"),y=js("perspective"),S=js("aspect"),j=js("ease"),N=js("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],U=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...U(),Ie,Me],T=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto","contain","none"],F=()=>[Ie,Me,f],M=()=>[xo,"full","auto",...F()],R=()=>[mo,"none","subgrid",Ie,Me],Y=()=>["auto",{span:["full",mo,Ie,Me]},mo,Ie,Me],W=()=>[mo,"auto",Ie,Me],ee=()=>["auto","min","max","fr",Ie,Me],K=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],_=()=>["start","end","center","stretch","center-safe","end-safe"],E=()=>["auto",...F()],q=()=>[xo,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...F()],H=()=>[xo,"screen","full","dvw","lvw","svw","min","max","fit",...F()],I=()=>[xo,"screen","full","lh","dvh","lvh","svh","min","max","fit",...F()],L=()=>[t,Ie,Me],J=()=>[...U(),Zw,Gw,{position:[Ie,Me]}],D=()=>["no-repeat",{repeat:["","x","y","space","round"]}],se=()=>["auto","cover","contain",lP,nP,{size:[Ie,Me]}],le=()=>[Mp,fA,mi],V=()=>["","none","full",x,Ie,Me],te=()=>["",at,fA,mi],ae=()=>["solid","dashed","dotted","double"],be=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],z=()=>[at,Mp,Zw,Gw],oe=()=>["","none",v,Ie,Me],ue=()=>["none",at,Ie,Me],ve=()=>["none",at,Ie,Me],Ce=()=>[at,Ie,Me],Ne=()=>[xo,"full",...F()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Sr],breakpoint:[Sr],color:[SN],container:[Sr],"drop-shadow":[Sr],ease:["in","out","in-out"],font:[sP],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Sr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Sr],shadow:[Sr],spacing:["px",at],text:[Sr],"text-shadow":[Sr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",xo,Me,Ie,S]}],container:["container"],columns:[{columns:[at,Me,Ie,A]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{"inset-s":M(),start:M()}],end:[{"inset-e":M(),end:M()}],"inset-bs":[{"inset-bs":M()}],"inset-be":[{"inset-be":M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[mo,"auto",Ie,Me]}],basis:[{basis:[xo,"full","auto",A,...F()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[at,xo,"auto","initial","none",Me]}],grow:[{grow:["",at,Ie,Me]}],shrink:[{shrink:["",at,Ie,Me]}],order:[{order:[mo,"first","last","none",Ie,Me]}],"grid-cols":[{"grid-cols":R()}],"col-start-end":[{col:Y()}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":R()}],"row-start-end":[{row:Y()}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ee()}],"auto-rows":[{"auto-rows":ee()}],gap:[{gap:F()}],"gap-x":[{"gap-x":F()}],"gap-y":[{"gap-y":F()}],"justify-content":[{justify:[...K(),"normal"]}],"justify-items":[{"justify-items":[..._(),"normal"]}],"justify-self":[{"justify-self":["auto",..._()]}],"align-content":[{content:["normal",...K()]}],"align-items":[{items:[..._(),{baseline:["","last"]}]}],"align-self":[{self:["auto",..._(),{baseline:["","last"]}]}],"place-content":[{"place-content":K()}],"place-items":[{"place-items":[..._(),"baseline"]}],"place-self":[{"place-self":["auto",..._()]}],p:[{p:F()}],px:[{px:F()}],py:[{py:F()}],ps:[{ps:F()}],pe:[{pe:F()}],pbs:[{pbs:F()}],pbe:[{pbe:F()}],pt:[{pt:F()}],pr:[{pr:F()}],pb:[{pb:F()}],pl:[{pl:F()}],m:[{m:E()}],mx:[{mx:E()}],my:[{my:E()}],ms:[{ms:E()}],me:[{me:E()}],mbs:[{mbs:E()}],mbe:[{mbe:E()}],mt:[{mt:E()}],mr:[{mr:E()}],mb:[{mb:E()}],ml:[{ml:E()}],"space-x":[{"space-x":F()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":F()}],"space-y-reverse":["space-y-reverse"],size:[{size:q()}],"inline-size":[{inline:["auto",...H()]}],"min-inline-size":[{"min-inline":["auto",...H()]}],"max-inline-size":[{"max-inline":["none",...H()]}],"block-size":[{block:["auto",...I()]}],"min-block-size":[{"min-block":["auto",...I()]}],"max-block-size":[{"max-block":["none",...I()]}],w:[{w:[A,"screen",...q()]}],"min-w":[{"min-w":[A,"screen","none",...q()]}],"max-w":[{"max-w":[A,"screen","none","prose",{screen:[c]},...q()]}],h:[{h:["screen","lh",...q()]}],"min-h":[{"min-h":["screen","lh","none",...q()]}],"max-h":[{"max-h":["screen","lh",...q()]}],"font-size":[{text:["base",n,fA,mi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,AP,aP]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Mp,Me]}],"font-family":[{font:[iP,rP,s]}],"font-features":[{"font-features":[Me]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,Ie,Me]}],"line-clamp":[{"line-clamp":[at,"none",Ie,Xw]}],leading:[{leading:[l,...F()]}],"list-image":[{"list-image":["none",Ie,Me]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ie,Me]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:L()}],"text-color":[{text:L()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ae(),"wavy"]}],"text-decoration-thickness":[{decoration:[at,"from-font","auto",Ie,mi]}],"text-decoration-color":[{decoration:L()}],"underline-offset":[{"underline-offset":[at,"auto",Ie,Me]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ie,Me]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ie,Me]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:J()}],"bg-repeat":[{bg:D()}],"bg-size":[{bg:se()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},mo,Ie,Me],radial:["",Ie,Me],conic:[mo,Ie,Me]},cP,oP]}],"bg-color":[{bg:L()}],"gradient-from-pos":[{from:le()}],"gradient-via-pos":[{via:le()}],"gradient-to-pos":[{to:le()}],"gradient-from":[{from:L()}],"gradient-via":[{via:L()}],"gradient-to":[{to:L()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:te()}],"border-w-x":[{"border-x":te()}],"border-w-y":[{"border-y":te()}],"border-w-s":[{"border-s":te()}],"border-w-e":[{"border-e":te()}],"border-w-bs":[{"border-bs":te()}],"border-w-be":[{"border-be":te()}],"border-w-t":[{"border-t":te()}],"border-w-r":[{"border-r":te()}],"border-w-b":[{"border-b":te()}],"border-w-l":[{"border-l":te()}],"divide-x":[{"divide-x":te()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":te()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ae(),"hidden","none"]}],"divide-style":[{divide:[...ae(),"hidden","none"]}],"border-color":[{border:L()}],"border-color-x":[{"border-x":L()}],"border-color-y":[{"border-y":L()}],"border-color-s":[{"border-s":L()}],"border-color-e":[{"border-e":L()}],"border-color-bs":[{"border-bs":L()}],"border-color-be":[{"border-be":L()}],"border-color-t":[{"border-t":L()}],"border-color-r":[{"border-r":L()}],"border-color-b":[{"border-b":L()}],"border-color-l":[{"border-l":L()}],"divide-color":[{divide:L()}],"outline-style":[{outline:[...ae(),"none","hidden"]}],"outline-offset":[{"outline-offset":[at,Ie,Me]}],"outline-w":[{outline:["",at,fA,mi]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",h,Iu,Mu]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",g,Iu,Mu]}],"inset-shadow-color":[{"inset-shadow":L()}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:L()}],"ring-offset-w":[{"ring-offset":[at,mi]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":te()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",O,Iu,Mu]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[at,Ie,Me]}],"mix-blend":[{"mix-blend":[...be(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":be()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[at]}],"mask-image-linear-from-pos":[{"mask-linear-from":z()}],"mask-image-linear-to-pos":[{"mask-linear-to":z()}],"mask-image-linear-from-color":[{"mask-linear-from":L()}],"mask-image-linear-to-color":[{"mask-linear-to":L()}],"mask-image-t-from-pos":[{"mask-t-from":z()}],"mask-image-t-to-pos":[{"mask-t-to":z()}],"mask-image-t-from-color":[{"mask-t-from":L()}],"mask-image-t-to-color":[{"mask-t-to":L()}],"mask-image-r-from-pos":[{"mask-r-from":z()}],"mask-image-r-to-pos":[{"mask-r-to":z()}],"mask-image-r-from-color":[{"mask-r-from":L()}],"mask-image-r-to-color":[{"mask-r-to":L()}],"mask-image-b-from-pos":[{"mask-b-from":z()}],"mask-image-b-to-pos":[{"mask-b-to":z()}],"mask-image-b-from-color":[{"mask-b-from":L()}],"mask-image-b-to-color":[{"mask-b-to":L()}],"mask-image-l-from-pos":[{"mask-l-from":z()}],"mask-image-l-to-pos":[{"mask-l-to":z()}],"mask-image-l-from-color":[{"mask-l-from":L()}],"mask-image-l-to-color":[{"mask-l-to":L()}],"mask-image-x-from-pos":[{"mask-x-from":z()}],"mask-image-x-to-pos":[{"mask-x-to":z()}],"mask-image-x-from-color":[{"mask-x-from":L()}],"mask-image-x-to-color":[{"mask-x-to":L()}],"mask-image-y-from-pos":[{"mask-y-from":z()}],"mask-image-y-to-pos":[{"mask-y-to":z()}],"mask-image-y-from-color":[{"mask-y-from":L()}],"mask-image-y-to-color":[{"mask-y-to":L()}],"mask-image-radial":[{"mask-radial":[Ie,Me]}],"mask-image-radial-from-pos":[{"mask-radial-from":z()}],"mask-image-radial-to-pos":[{"mask-radial-to":z()}],"mask-image-radial-from-color":[{"mask-radial-from":L()}],"mask-image-radial-to-color":[{"mask-radial-to":L()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":U()}],"mask-image-conic-pos":[{"mask-conic":[at]}],"mask-image-conic-from-pos":[{"mask-conic-from":z()}],"mask-image-conic-to-pos":[{"mask-conic-to":z()}],"mask-image-conic-from-color":[{"mask-conic-from":L()}],"mask-image-conic-to-color":[{"mask-conic-to":L()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:J()}],"mask-repeat":[{mask:D()}],"mask-size":[{mask:se()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ie,Me]}],filter:[{filter:["","none",Ie,Me]}],blur:[{blur:oe()}],brightness:[{brightness:[at,Ie,Me]}],contrast:[{contrast:[at,Ie,Me]}],"drop-shadow":[{"drop-shadow":["","none",b,Iu,Mu]}],"drop-shadow-color":[{"drop-shadow":L()}],grayscale:[{grayscale:["",at,Ie,Me]}],"hue-rotate":[{"hue-rotate":[at,Ie,Me]}],invert:[{invert:["",at,Ie,Me]}],saturate:[{saturate:[at,Ie,Me]}],sepia:[{sepia:["",at,Ie,Me]}],"backdrop-filter":[{"backdrop-filter":["","none",Ie,Me]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[at,Ie,Me]}],"backdrop-contrast":[{"backdrop-contrast":[at,Ie,Me]}],"backdrop-grayscale":[{"backdrop-grayscale":["",at,Ie,Me]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[at,Ie,Me]}],"backdrop-invert":[{"backdrop-invert":["",at,Ie,Me]}],"backdrop-opacity":[{"backdrop-opacity":[at,Ie,Me]}],"backdrop-saturate":[{"backdrop-saturate":[at,Ie,Me]}],"backdrop-sepia":[{"backdrop-sepia":["",at,Ie,Me]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":F()}],"border-spacing-x":[{"border-spacing-x":F()}],"border-spacing-y":[{"border-spacing-y":F()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ie,Me]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[at,"initial",Ie,Me]}],ease:[{ease:["linear","initial",j,Ie,Me]}],delay:[{delay:[at,Ie,Me]}],animate:[{animate:["none",N,Ie,Me]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[y,Ie,Me]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:ue()}],"rotate-x":[{"rotate-x":ue()}],"rotate-y":[{"rotate-y":ue()}],"rotate-z":[{"rotate-z":ue()}],scale:[{scale:ve()}],"scale-x":[{"scale-x":ve()}],"scale-y":[{"scale-y":ve()}],"scale-z":[{"scale-z":ve()}],"scale-3d":["scale-3d"],skew:[{skew:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[Ie,Me,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ne()}],"translate-x":[{"translate-x":Ne()}],"translate-y":[{"translate-y":Ne()}],"translate-z":[{"translate-z":Ne()}],"translate-none":["translate-none"],accent:[{accent:L()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:L()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ie,Me]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mbs":[{"scroll-mbs":F()}],"scroll-mbe":[{"scroll-mbe":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pbs":[{"scroll-pbs":F()}],"scroll-pbe":[{"scroll-pbe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ie,Me]}],fill:[{fill:["none",...L()]}],"stroke-w":[{stroke:[at,fA,mi,Xw]}],stroke:[{stroke:["none",...L()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},fP=XE(uP);function Z(...t){return fP(jE(t))}function Ue(t,s,{checkForDefaultPrevented:n=!0}={}){return function(r){if(t==null||t(r),n===!1||!r.defaultPrevented)return s==null?void 0:s(r)}}function Vw(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function mb(...t){return s=>{let n=!1;const a=t.map(r=>{const l=Vw(r,s);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let r=0;r<a.length;r++){const l=a[r];typeof l=="function"?l():Vw(t[r],null)}}}}function mt(...t){return p.useCallback(mb(...t),t)}function xP(t,s){const n=p.createContext(s),a=l=>{const{children:c,...A}=l,f=p.useMemo(()=>A,Object.values(A));return e.jsx(n.Provider,{value:f,children:c})};a.displayName=t+"Provider";function r(l){const c=p.useContext(n);if(c)return c;if(s!==void 0)return s;throw new Error(`\`${l}\` must be used within \`${t}\``)}return[a,r]}function Ya(t,s=[]){let n=[];function a(l,c){const A=p.createContext(c),f=n.length;n=[...n,c];const x=g=>{var j;const{scope:O,children:b,...v}=g,y=((j=O==null?void 0:O[t])==null?void 0:j[f])||A,S=p.useMemo(()=>v,Object.values(v));return e.jsx(y.Provider,{value:S,children:b})};x.displayName=l+"Provider";function h(g,O){var y;const b=((y=O==null?void 0:O[t])==null?void 0:y[f])||A,v=p.useContext(b);if(v)return v;if(c!==void 0)return c;throw new Error(`\`${g}\` must be used within \`${l}\``)}return[x,h]}const r=()=>{const l=n.map(c=>p.createContext(c));return function(A){const f=(A==null?void 0:A[t])||l;return p.useMemo(()=>({[`__scope${t}`]:{...A,[t]:f}}),[A,f])}};return r.scopeName=t,[a,mP(r,...s)]}function mP(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const a=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(l){const c=a.reduce((A,{useScope:f,scopeName:x})=>{const g=f(l)[`__scope${x}`];return{...A,...g}},{});return p.useMemo(()=>({[`__scope${s.scopeName}`]:c}),[c])}};return n.scopeName=s.scopeName,n}function ec(t){const s=hP(t),n=p.forwardRef((a,r)=>{const{children:l,...c}=a,A=p.Children.toArray(l),f=A.find(gP);if(f){const x=f.props.children,h=A.map(g=>g===f?p.Children.count(x)>1?p.Children.only(null):p.isValidElement(x)?x.props.children:null:g);return e.jsx(s,{...c,ref:r,children:p.isValidElement(x)?p.cloneElement(x,void 0,h):null})}return e.jsx(s,{...c,ref:r,children:l})});return n.displayName=`${t}.Slot`,n}function hP(t){const s=p.forwardRef((n,a)=>{const{children:r,...l}=n;if(p.isValidElement(r)){const c=bP(r),A=OP(l,r.props);return r.type!==p.Fragment&&(A.ref=a?mb(a,c):c),p.cloneElement(r,A)}return p.Children.count(r)>1?p.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var FN=Symbol("radix.slottable");function pP(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=FN,s}function gP(t){return p.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===FN}function OP(t,s){const n={...s};for(const a in s){const r=t[a],l=s[a];/^on[A-Z]/.test(a)?r&&l?n[a]=(...A)=>{const f=l(...A);return r(...A),f}:r&&(n[a]=r):a==="style"?n[a]={...r,...l}:a==="className"&&(n[a]=[r,l].filter(Boolean).join(" "))}return{...t,...n}}function bP(t){var a,r;let s=(a=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(r=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var vP=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],et=vP.reduce((t,s)=>{const n=ec(`Primitive.${s}`),a=p.forwardRef((r,l)=>{const{asChild:c,...A}=r,f=c?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(f,{...A,ref:l})});return a.displayName=`Primitive.${s}`,{...t,[s]:a}},{});function $N(t,s){t&&Px.flushSync(()=>t.dispatchEvent(s))}function Us(t){const s=p.useRef(t);return p.useEffect(()=>{s.current=t}),p.useMemo(()=>(...n)=>{var a;return(a=s.current)==null?void 0:a.call(s,...n)},[])}function yP(t,s=globalThis==null?void 0:globalThis.document){const n=Us(t);p.useEffect(()=>{const a=r=>{r.key==="Escape"&&n(r)};return s.addEventListener("keydown",a,{capture:!0}),()=>s.removeEventListener("keydown",a,{capture:!0})},[n,s])}var wP="DismissableLayer",aO="dismissableLayer.update",jP="dismissableLayer.pointerDownOutside",QP="dismissableLayer.focusOutside",Kw,RN=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ad=p.forwardRef((t,s)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:a,onPointerDownOutside:r,onFocusOutside:l,onInteractOutside:c,onDismiss:A,...f}=t,x=p.useContext(RN),[h,g]=p.useState(null),O=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=p.useState({}),v=mt(s,B=>g(B)),y=Array.from(x.layers),[S]=[...x.layersWithOutsidePointerEventsDisabled].slice(-1),j=y.indexOf(S),N=h?y.indexOf(h):-1,C=x.layersWithOutsidePointerEventsDisabled.size>0,U=N>=j,P=CP(B=>{const F=B.target,M=[...x.branches].some(R=>R.contains(F));!U||M||(r==null||r(B),c==null||c(B),B.defaultPrevented||A==null||A())},O),T=BP(B=>{const F=B.target;[...x.branches].some(R=>R.contains(F))||(l==null||l(B),c==null||c(B),B.defaultPrevented||A==null||A())},O);return yP(B=>{N===x.layers.size-1&&(a==null||a(B),!B.defaultPrevented&&A&&(B.preventDefault(),A()))},O),p.useEffect(()=>{if(h)return n&&(x.layersWithOutsidePointerEventsDisabled.size===0&&(Kw=O.body.style.pointerEvents,O.body.style.pointerEvents="none"),x.layersWithOutsidePointerEventsDisabled.add(h)),x.layers.add(h),qw(),()=>{n&&x.layersWithOutsidePointerEventsDisabled.size===1&&(O.body.style.pointerEvents=Kw)}},[h,O,n,x]),p.useEffect(()=>()=>{h&&(x.layers.delete(h),x.layersWithOutsidePointerEventsDisabled.delete(h),qw())},[h,x]),p.useEffect(()=>{const B=()=>b({});return document.addEventListener(aO,B),()=>document.removeEventListener(aO,B)},[]),e.jsx(et.div,{...f,ref:v,style:{pointerEvents:C?U?"auto":"none":void 0,...t.style},onFocusCapture:Ue(t.onFocusCapture,T.onFocusCapture),onBlurCapture:Ue(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Ue(t.onPointerDownCapture,P.onPointerDownCapture)})});Ad.displayName=wP;var NP="DismissableLayerBranch",SP=p.forwardRef((t,s)=>{const n=p.useContext(RN),a=p.useRef(null),r=mt(s,a);return p.useEffect(()=>{const l=a.current;if(l)return n.branches.add(l),()=>{n.branches.delete(l)}},[n.branches]),e.jsx(et.div,{...t,ref:r})});SP.displayName=NP;function CP(t,s=globalThis==null?void 0:globalThis.document){const n=Us(t),a=p.useRef(!1),r=p.useRef(()=>{});return p.useEffect(()=>{const l=A=>{if(A.target&&!a.current){let f=function(){MN(jP,n,x,{discrete:!0})};const x={originalEvent:A};A.pointerType==="touch"?(s.removeEventListener("click",r.current),r.current=f,s.addEventListener("click",r.current,{once:!0})):f()}else s.removeEventListener("click",r.current);a.current=!1},c=window.setTimeout(()=>{s.addEventListener("pointerdown",l)},0);return()=>{window.clearTimeout(c),s.removeEventListener("pointerdown",l),s.removeEventListener("click",r.current)}},[s,n]),{onPointerDownCapture:()=>a.current=!0}}function BP(t,s=globalThis==null?void 0:globalThis.document){const n=Us(t),a=p.useRef(!1);return p.useEffect(()=>{const r=l=>{l.target&&!a.current&&MN(QP,n,{originalEvent:l},{discrete:!1})};return s.addEventListener("focusin",r),()=>s.removeEventListener("focusin",r)},[s,n]),{onFocusCapture:()=>a.current=!0,onBlurCapture:()=>a.current=!1}}function qw(){const t=new CustomEvent(aO);document.dispatchEvent(t)}function MN(t,s,n,{discrete:a}){const r=n.originalEvent.target,l=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});s&&r.addEventListener(t,s,{once:!0}),a?$N(r,l):r.dispatchEvent(l)}var Ds=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},kP=oN[" useId ".trim().toString()]||(()=>{}),TP=0;function $r(t){const[s,n]=p.useState(kP());return Ds(()=>{n(a=>a??String(TP++))},[t]),s?`radix-${s}`:""}const UP=["top","right","bottom","left"],Fo=Math.min,$n=Math.max,tx=Math.round,zu=Math.floor,Xa=t=>({x:t,y:t}),EP={left:"right",right:"left",bottom:"top",top:"bottom"};function rO(t,s,n){return $n(t,Fo(s,n))}function Ir(t,s){return typeof t=="function"?t(s):t}function zr(t){return t.split("-")[0]}function xc(t){return t.split("-")[1]}function hb(t){return t==="x"?"y":"x"}function pb(t){return t==="y"?"height":"width"}function La(t){const s=t[0];return s==="t"||s==="b"?"y":"x"}function gb(t){return hb(La(t))}function PP(t,s,n){n===void 0&&(n=!1);const a=xc(t),r=gb(t),l=pb(r);let c=r==="x"?a===(n?"end":"start")?"right":"left":a==="start"?"bottom":"top";return s.reference[l]>s.floating[l]&&(c=sx(c)),[c,sx(c)]}function FP(t){const s=sx(t);return[oO(t),s,oO(s)]}function oO(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const Ww=["left","right"],Yw=["right","left"],$P=["top","bottom"],RP=["bottom","top"];function MP(t,s,n){switch(t){case"top":case"bottom":return n?s?Yw:Ww:s?Ww:Yw;case"left":case"right":return s?$P:RP;default:return[]}}function IP(t,s,n,a){const r=xc(t);let l=MP(zr(t),n==="start",a);return r&&(l=l.map(c=>c+"-"+r),s&&(l=l.concat(l.map(oO)))),l}function sx(t){const s=zr(t);return EP[s]+t.slice(s.length)}function zP(t){return{top:0,right:0,bottom:0,left:0,...t}}function IN(t){return typeof t!="number"?zP(t):{top:t,right:t,bottom:t,left:t}}function nx(t){const{x:s,y:n,width:a,height:r}=t;return{width:a,height:r,top:n,left:s,right:s+a,bottom:n+r,x:s,y:n}}function Jw(t,s,n){let{reference:a,floating:r}=t;const l=La(s),c=gb(s),A=pb(c),f=zr(s),x=l==="y",h=a.x+a.width/2-r.width/2,g=a.y+a.height/2-r.height/2,O=a[A]/2-r[A]/2;let b;switch(f){case"top":b={x:h,y:a.y-r.height};break;case"bottom":b={x:h,y:a.y+a.height};break;case"right":b={x:a.x+a.width,y:g};break;case"left":b={x:a.x-r.width,y:g};break;default:b={x:a.x,y:a.y}}switch(xc(s)){case"start":b[c]-=O*(n&&x?-1:1);break;case"end":b[c]+=O*(n&&x?-1:1);break}return b}async function _P(t,s){var n;s===void 0&&(s={});const{x:a,y:r,platform:l,rects:c,elements:A,strategy:f}=t,{boundary:x="clippingAncestors",rootBoundary:h="viewport",elementContext:g="floating",altBoundary:O=!1,padding:b=0}=Ir(s,t),v=IN(b),S=A[O?g==="floating"?"reference":"floating":g],j=nx(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(S)))==null||n?S:S.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(A.floating)),boundary:x,rootBoundary:h,strategy:f})),N=g==="floating"?{x:a,y:r,width:c.floating.width,height:c.floating.height}:c.reference,C=await(l.getOffsetParent==null?void 0:l.getOffsetParent(A.floating)),U=await(l.isElement==null?void 0:l.isElement(C))?await(l.getScale==null?void 0:l.getScale(C))||{x:1,y:1}:{x:1,y:1},P=nx(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:A,rect:N,offsetParent:C,strategy:f}):N);return{top:(j.top-P.top+v.top)/U.y,bottom:(P.bottom-j.bottom+v.bottom)/U.y,left:(j.left-P.left+v.left)/U.x,right:(P.right-j.right+v.right)/U.x}}const DP=50,LP=async(t,s,n)=>{const{placement:a="bottom",strategy:r="absolute",middleware:l=[],platform:c}=n,A=c.detectOverflow?c:{...c,detectOverflow:_P},f=await(c.isRTL==null?void 0:c.isRTL(s));let x=await c.getElementRects({reference:t,floating:s,strategy:r}),{x:h,y:g}=Jw(x,a,f),O=a,b=0;const v={};for(let y=0;y<l.length;y++){const S=l[y];if(!S)continue;const{name:j,fn:N}=S,{x:C,y:U,data:P,reset:T}=await N({x:h,y:g,initialPlacement:a,placement:O,strategy:r,middlewareData:v,rects:x,platform:A,elements:{reference:t,floating:s}});h=C??h,g=U??g,v[j]={...v[j],...P},T&&b<DP&&(b++,typeof T=="object"&&(T.placement&&(O=T.placement),T.rects&&(x=T.rects===!0?await c.getElementRects({reference:t,floating:s,strategy:r}):T.rects),{x:h,y:g}=Jw(x,O,f)),y=-1)}return{x:h,y:g,placement:O,strategy:r,middlewareData:v}},HP=t=>({name:"arrow",options:t,async fn(s){const{x:n,y:a,placement:r,rects:l,platform:c,elements:A,middlewareData:f}=s,{element:x,padding:h=0}=Ir(t,s)||{};if(x==null)return{};const g=IN(h),O={x:n,y:a},b=gb(r),v=pb(b),y=await c.getDimensions(x),S=b==="y",j=S?"top":"left",N=S?"bottom":"right",C=S?"clientHeight":"clientWidth",U=l.reference[v]+l.reference[b]-O[b]-l.floating[v],P=O[b]-l.reference[b],T=await(c.getOffsetParent==null?void 0:c.getOffsetParent(x));let B=T?T[C]:0;(!B||!await(c.isElement==null?void 0:c.isElement(T)))&&(B=A.floating[C]||l.floating[v]);const F=U/2-P/2,M=B/2-y[v]/2-1,R=Fo(g[j],M),Y=Fo(g[N],M),W=R,ee=B-y[v]-Y,K=B/2-y[v]/2+F,_=rO(W,K,ee),E=!f.arrow&&xc(r)!=null&&K!==_&&l.reference[v]/2-(K<W?R:Y)-y[v]/2<0,q=E?K<W?K-W:K-ee:0;return{[b]:O[b]+q,data:{[b]:_,centerOffset:K-_-q,...E&&{alignmentOffset:q}},reset:E}}}),XP=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(s){var n,a;const{placement:r,middlewareData:l,rects:c,initialPlacement:A,platform:f,elements:x}=s,{mainAxis:h=!0,crossAxis:g=!0,fallbackPlacements:O,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:y=!0,...S}=Ir(t,s);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const j=zr(r),N=La(A),C=zr(A)===A,U=await(f.isRTL==null?void 0:f.isRTL(x.floating)),P=O||(C||!y?[sx(A)]:FP(A)),T=v!=="none";!O&&T&&P.push(...IP(A,y,v,U));const B=[A,...P],F=await f.detectOverflow(s,S),M=[];let R=((a=l.flip)==null?void 0:a.overflows)||[];if(h&&M.push(F[j]),g){const K=PP(r,c,U);M.push(F[K[0]],F[K[1]])}if(R=[...R,{placement:r,overflows:M}],!M.every(K=>K<=0)){var Y,W;const K=(((Y=l.flip)==null?void 0:Y.index)||0)+1,_=B[K];if(_&&(!(g==="alignment"?N!==La(_):!1)||R.every(H=>La(H.placement)===N?H.overflows[0]>0:!0)))return{data:{index:K,overflows:R},reset:{placement:_}};let E=(W=R.filter(q=>q.overflows[0]<=0).sort((q,H)=>q.overflows[1]-H.overflows[1])[0])==null?void 0:W.placement;if(!E)switch(b){case"bestFit":{var ee;const q=(ee=R.filter(H=>{if(T){const I=La(H.placement);return I===N||I==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(I=>I>0).reduce((I,L)=>I+L,0)]).sort((H,I)=>H[1]-I[1])[0])==null?void 0:ee[0];q&&(E=q);break}case"initialPlacement":E=A;break}if(r!==E)return{reset:{placement:E}}}return{}}}};function ej(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function tj(t){return UP.some(s=>t[s]>=0)}const GP=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:n,platform:a}=s,{strategy:r="referenceHidden",...l}=Ir(t,s);switch(r){case"referenceHidden":{const c=await a.detectOverflow(s,{...l,elementContext:"reference"}),A=ej(c,n.reference);return{data:{referenceHiddenOffsets:A,referenceHidden:tj(A)}}}case"escaped":{const c=await a.detectOverflow(s,{...l,altBoundary:!0}),A=ej(c,n.floating);return{data:{escapedOffsets:A,escaped:tj(A)}}}default:return{}}}}},zN=new Set(["left","top"]);async function ZP(t,s){const{placement:n,platform:a,elements:r}=t,l=await(a.isRTL==null?void 0:a.isRTL(r.floating)),c=zr(n),A=xc(n),f=La(n)==="y",x=zN.has(c)?-1:1,h=l&&f?-1:1,g=Ir(s,t);let{mainAxis:O,crossAxis:b,alignmentAxis:v}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return A&&typeof v=="number"&&(b=A==="end"?v*-1:v),f?{x:b*h,y:O*x}:{x:O*x,y:b*h}}const VP=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var n,a;const{x:r,y:l,placement:c,middlewareData:A}=s,f=await ZP(s,t);return c===((n=A.offset)==null?void 0:n.placement)&&(a=A.arrow)!=null&&a.alignmentOffset?{}:{x:r+f.x,y:l+f.y,data:{...f,placement:c}}}}},KP=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:n,y:a,placement:r,platform:l}=s,{mainAxis:c=!0,crossAxis:A=!1,limiter:f={fn:j=>{let{x:N,y:C}=j;return{x:N,y:C}}},...x}=Ir(t,s),h={x:n,y:a},g=await l.detectOverflow(s,x),O=La(zr(r)),b=hb(O);let v=h[b],y=h[O];if(c){const j=b==="y"?"top":"left",N=b==="y"?"bottom":"right",C=v+g[j],U=v-g[N];v=rO(C,v,U)}if(A){const j=O==="y"?"top":"left",N=O==="y"?"bottom":"right",C=y+g[j],U=y-g[N];y=rO(C,y,U)}const S=f.fn({...s,[b]:v,[O]:y});return{...S,data:{x:S.x-n,y:S.y-a,enabled:{[b]:c,[O]:A}}}}}},qP=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:n,y:a,placement:r,rects:l,middlewareData:c}=s,{offset:A=0,mainAxis:f=!0,crossAxis:x=!0}=Ir(t,s),h={x:n,y:a},g=La(r),O=hb(g);let b=h[O],v=h[g];const y=Ir(A,s),S=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(f){const C=O==="y"?"height":"width",U=l.reference[O]-l.floating[C]+S.mainAxis,P=l.reference[O]+l.reference[C]-S.mainAxis;b<U?b=U:b>P&&(b=P)}if(x){var j,N;const C=O==="y"?"width":"height",U=zN.has(zr(r)),P=l.reference[g]-l.floating[C]+(U&&((j=c.offset)==null?void 0:j[g])||0)+(U?0:S.crossAxis),T=l.reference[g]+l.reference[C]+(U?0:((N=c.offset)==null?void 0:N[g])||0)-(U?S.crossAxis:0);v<P?v=P:v>T&&(v=T)}return{[O]:b,[g]:v}}}},WP=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var n,a;const{placement:r,rects:l,platform:c,elements:A}=s,{apply:f=()=>{},...x}=Ir(t,s),h=await c.detectOverflow(s,x),g=zr(r),O=xc(r),b=La(r)==="y",{width:v,height:y}=l.floating;let S,j;g==="top"||g==="bottom"?(S=g,j=O===(await(c.isRTL==null?void 0:c.isRTL(A.floating))?"start":"end")?"left":"right"):(j=g,S=O==="end"?"top":"bottom");const N=y-h.top-h.bottom,C=v-h.left-h.right,U=Fo(y-h[S],N),P=Fo(v-h[j],C),T=!s.middlewareData.shift;let B=U,F=P;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&(F=C),(a=s.middlewareData.shift)!=null&&a.enabled.y&&(B=N),T&&!O){const R=$n(h.left,0),Y=$n(h.right,0),W=$n(h.top,0),ee=$n(h.bottom,0);b?F=v-2*(R!==0||Y!==0?R+Y:$n(h.left,h.right)):B=y-2*(W!==0||ee!==0?W+ee:$n(h.top,h.bottom))}await f({...s,availableWidth:F,availableHeight:B});const M=await c.getDimensions(A.floating);return v!==M.width||y!==M.height?{reset:{rects:!0}}:{}}}};function Rx(){return typeof window<"u"}function mc(t){return _N(t)?(t.nodeName||"").toLowerCase():"#document"}function zn(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function Ja(t){var s;return(s=(_N(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function _N(t){return Rx()?t instanceof Node||t instanceof zn(t).Node:!1}function Sa(t){return Rx()?t instanceof Element||t instanceof zn(t).Element:!1}function Lr(t){return Rx()?t instanceof HTMLElement||t instanceof zn(t).HTMLElement:!1}function sj(t){return!Rx()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof zn(t).ShadowRoot}function dd(t){const{overflow:s,overflowX:n,overflowY:a,display:r}=Ca(t);return/auto|scroll|overlay|hidden|clip/.test(s+a+n)&&r!=="inline"&&r!=="contents"}function YP(t){return/^(table|td|th)$/.test(mc(t))}function Mx(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const JP=/transform|translate|scale|rotate|perspective|filter/,eF=/paint|layout|strict|content/,hi=t=>!!t&&t!=="none";let Ip;function Ob(t){const s=Sa(t)?Ca(t):t;return hi(s.transform)||hi(s.translate)||hi(s.scale)||hi(s.rotate)||hi(s.perspective)||!bb()&&(hi(s.backdropFilter)||hi(s.filter))||JP.test(s.willChange||"")||eF.test(s.contain||"")}function tF(t){let s=$o(t);for(;Lr(s)&&!tc(s);){if(Ob(s))return s;if(Mx(s))return null;s=$o(s)}return null}function bb(){return Ip==null&&(Ip=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ip}function tc(t){return/^(html|body|#document)$/.test(mc(t))}function Ca(t){return zn(t).getComputedStyle(t)}function Ix(t){return Sa(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function $o(t){if(mc(t)==="html")return t;const s=t.assignedSlot||t.parentNode||sj(t)&&t.host||Ja(t);return sj(s)?s.host:s}function DN(t){const s=$o(t);return tc(s)?t.ownerDocument?t.ownerDocument.body:t.body:Lr(s)&&dd(s)?s:DN(s)}function ZA(t,s,n){var a;s===void 0&&(s=[]),n===void 0&&(n=!0);const r=DN(t),l=r===((a=t.ownerDocument)==null?void 0:a.body),c=zn(r);if(l){const A=iO(c);return s.concat(c,c.visualViewport||[],dd(r)?r:[],A&&n?ZA(A):[])}else return s.concat(r,ZA(r,[],n))}function iO(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function LN(t){const s=Ca(t);let n=parseFloat(s.width)||0,a=parseFloat(s.height)||0;const r=Lr(t),l=r?t.offsetWidth:n,c=r?t.offsetHeight:a,A=tx(n)!==l||tx(a)!==c;return A&&(n=l,a=c),{width:n,height:a,$:A}}function vb(t){return Sa(t)?t:t.contextElement}function Zl(t){const s=vb(t);if(!Lr(s))return Xa(1);const n=s.getBoundingClientRect(),{width:a,height:r,$:l}=LN(s);let c=(l?tx(n.width):n.width)/a,A=(l?tx(n.height):n.height)/r;return(!c||!Number.isFinite(c))&&(c=1),(!A||!Number.isFinite(A))&&(A=1),{x:c,y:A}}const sF=Xa(0);function HN(t){const s=zn(t);return!bb()||!s.visualViewport?sF:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function nF(t,s,n){return s===void 0&&(s=!1),!n||s&&n!==zn(t)?!1:s}function Ci(t,s,n,a){s===void 0&&(s=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),l=vb(t);let c=Xa(1);s&&(a?Sa(a)&&(c=Zl(a)):c=Zl(t));const A=nF(l,n,a)?HN(l):Xa(0);let f=(r.left+A.x)/c.x,x=(r.top+A.y)/c.y,h=r.width/c.x,g=r.height/c.y;if(l){const O=zn(l),b=a&&Sa(a)?zn(a):a;let v=O,y=iO(v);for(;y&&a&&b!==v;){const S=Zl(y),j=y.getBoundingClientRect(),N=Ca(y),C=j.left+(y.clientLeft+parseFloat(N.paddingLeft))*S.x,U=j.top+(y.clientTop+parseFloat(N.paddingTop))*S.y;f*=S.x,x*=S.y,h*=S.x,g*=S.y,f+=C,x+=U,v=zn(y),y=iO(v)}}return nx({width:h,height:g,x:f,y:x})}function zx(t,s){const n=Ix(t).scrollLeft;return s?s.left+n:Ci(Ja(t)).left+n}function XN(t,s){const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-zx(t,n),r=n.top+s.scrollTop;return{x:a,y:r}}function aF(t){let{elements:s,rect:n,offsetParent:a,strategy:r}=t;const l=r==="fixed",c=Ja(a),A=s?Mx(s.floating):!1;if(a===c||A&&l)return n;let f={scrollLeft:0,scrollTop:0},x=Xa(1);const h=Xa(0),g=Lr(a);if((g||!g&&!l)&&((mc(a)!=="body"||dd(c))&&(f=Ix(a)),g)){const b=Ci(a);x=Zl(a),h.x=b.x+a.clientLeft,h.y=b.y+a.clientTop}const O=c&&!g&&!l?XN(c,f):Xa(0);return{width:n.width*x.x,height:n.height*x.y,x:n.x*x.x-f.scrollLeft*x.x+h.x+O.x,y:n.y*x.y-f.scrollTop*x.y+h.y+O.y}}function rF(t){return Array.from(t.getClientRects())}function oF(t){const s=Ja(t),n=Ix(t),a=t.ownerDocument.body,r=$n(s.scrollWidth,s.clientWidth,a.scrollWidth,a.clientWidth),l=$n(s.scrollHeight,s.clientHeight,a.scrollHeight,a.clientHeight);let c=-n.scrollLeft+zx(t);const A=-n.scrollTop;return Ca(a).direction==="rtl"&&(c+=$n(s.clientWidth,a.clientWidth)-r),{width:r,height:l,x:c,y:A}}const nj=25;function iF(t,s){const n=zn(t),a=Ja(t),r=n.visualViewport;let l=a.clientWidth,c=a.clientHeight,A=0,f=0;if(r){l=r.width,c=r.height;const h=bb();(!h||h&&s==="fixed")&&(A=r.offsetLeft,f=r.offsetTop)}const x=zx(a);if(x<=0){const h=a.ownerDocument,g=h.body,O=getComputedStyle(g),b=h.compatMode==="CSS1Compat"&&parseFloat(O.marginLeft)+parseFloat(O.marginRight)||0,v=Math.abs(a.clientWidth-g.clientWidth-b);v<=nj&&(l-=v)}else x<=nj&&(l+=x);return{width:l,height:c,x:A,y:f}}function lF(t,s){const n=Ci(t,!0,s==="fixed"),a=n.top+t.clientTop,r=n.left+t.clientLeft,l=Lr(t)?Zl(t):Xa(1),c=t.clientWidth*l.x,A=t.clientHeight*l.y,f=r*l.x,x=a*l.y;return{width:c,height:A,x:f,y:x}}function aj(t,s,n){let a;if(s==="viewport")a=iF(t,n);else if(s==="document")a=oF(Ja(t));else if(Sa(s))a=lF(s,n);else{const r=HN(t);a={x:s.x-r.x,y:s.y-r.y,width:s.width,height:s.height}}return nx(a)}function GN(t,s){const n=$o(t);return n===s||!Sa(n)||tc(n)?!1:Ca(n).position==="fixed"||GN(n,s)}function cF(t,s){const n=s.get(t);if(n)return n;let a=ZA(t,[],!1).filter(A=>Sa(A)&&mc(A)!=="body"),r=null;const l=Ca(t).position==="fixed";let c=l?$o(t):t;for(;Sa(c)&&!tc(c);){const A=Ca(c),f=Ob(c);!f&&A.position==="fixed"&&(r=null),(l?!f&&!r:!f&&A.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||dd(c)&&!f&&GN(t,c))?a=a.filter(h=>h!==c):r=A,c=$o(c)}return s.set(t,a),a}function AF(t){let{element:s,boundary:n,rootBoundary:a,strategy:r}=t;const c=[...n==="clippingAncestors"?Mx(s)?[]:cF(s,this._c):[].concat(n),a],A=aj(s,c[0],r);let f=A.top,x=A.right,h=A.bottom,g=A.left;for(let O=1;O<c.length;O++){const b=aj(s,c[O],r);f=$n(b.top,f),x=Fo(b.right,x),h=Fo(b.bottom,h),g=$n(b.left,g)}return{width:x-g,height:h-f,x:g,y:f}}function dF(t){const{width:s,height:n}=LN(t);return{width:s,height:n}}function uF(t,s,n){const a=Lr(s),r=Ja(s),l=n==="fixed",c=Ci(t,!0,l,s);let A={scrollLeft:0,scrollTop:0};const f=Xa(0);function x(){f.x=zx(r)}if(a||!a&&!l)if((mc(s)!=="body"||dd(r))&&(A=Ix(s)),a){const b=Ci(s,!0,l,s);f.x=b.x+s.clientLeft,f.y=b.y+s.clientTop}else r&&x();l&&!a&&r&&x();const h=r&&!a&&!l?XN(r,A):Xa(0),g=c.left+A.scrollLeft-f.x-h.x,O=c.top+A.scrollTop-f.y-h.y;return{x:g,y:O,width:c.width,height:c.height}}function zp(t){return Ca(t).position==="static"}function rj(t,s){if(!Lr(t)||Ca(t).position==="fixed")return null;if(s)return s(t);let n=t.offsetParent;return Ja(t)===n&&(n=n.ownerDocument.body),n}function ZN(t,s){const n=zn(t);if(Mx(t))return n;if(!Lr(t)){let r=$o(t);for(;r&&!tc(r);){if(Sa(r)&&!zp(r))return r;r=$o(r)}return n}let a=rj(t,s);for(;a&&YP(a)&&zp(a);)a=rj(a,s);return a&&tc(a)&&zp(a)&&!Ob(a)?n:a||tF(t)||n}const fF=async function(t){const s=this.getOffsetParent||ZN,n=this.getDimensions,a=await n(t.floating);return{reference:uF(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}};function xF(t){return Ca(t).direction==="rtl"}const mF={convertOffsetParentRelativeRectToViewportRelativeRect:aF,getDocumentElement:Ja,getClippingRect:AF,getOffsetParent:ZN,getElementRects:fF,getClientRects:rF,getDimensions:dF,getScale:Zl,isElement:Sa,isRTL:xF};function VN(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function hF(t,s){let n=null,a;const r=Ja(t);function l(){var A;clearTimeout(a),(A=n)==null||A.disconnect(),n=null}function c(A,f){A===void 0&&(A=!1),f===void 0&&(f=1),l();const x=t.getBoundingClientRect(),{left:h,top:g,width:O,height:b}=x;if(A||s(),!O||!b)return;const v=zu(g),y=zu(r.clientWidth-(h+O)),S=zu(r.clientHeight-(g+b)),j=zu(h),C={rootMargin:-v+"px "+-y+"px "+-S+"px "+-j+"px",threshold:$n(0,Fo(1,f))||1};let U=!0;function P(T){const B=T[0].intersectionRatio;if(B!==f){if(!U)return c();B?c(!1,B):a=setTimeout(()=>{c(!1,1e-7)},1e3)}B===1&&!VN(x,t.getBoundingClientRect())&&c(),U=!1}try{n=new IntersectionObserver(P,{...C,root:r.ownerDocument})}catch{n=new IntersectionObserver(P,C)}n.observe(t)}return c(!0),l}function pF(t,s,n,a){a===void 0&&(a={});const{ancestorScroll:r=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:A=typeof IntersectionObserver=="function",animationFrame:f=!1}=a,x=vb(t),h=r||l?[...x?ZA(x):[],...s?ZA(s):[]]:[];h.forEach(j=>{r&&j.addEventListener("scroll",n,{passive:!0}),l&&j.addEventListener("resize",n)});const g=x&&A?hF(x,n):null;let O=-1,b=null;c&&(b=new ResizeObserver(j=>{let[N]=j;N&&N.target===x&&b&&s&&(b.unobserve(s),cancelAnimationFrame(O),O=requestAnimationFrame(()=>{var C;(C=b)==null||C.observe(s)})),n()}),x&&!f&&b.observe(x),s&&b.observe(s));let v,y=f?Ci(t):null;f&&S();function S(){const j=Ci(t);y&&!VN(y,j)&&n(),y=j,v=requestAnimationFrame(S)}return n(),()=>{var j;h.forEach(N=>{r&&N.removeEventListener("scroll",n),l&&N.removeEventListener("resize",n)}),g==null||g(),(j=b)==null||j.disconnect(),b=null,f&&cancelAnimationFrame(v)}}const gF=VP,OF=KP,bF=XP,vF=WP,yF=GP,oj=HP,wF=qP,jF=(t,s,n)=>{const a=new Map,r={platform:mF,...n},l={...r.platform,_c:a};return LP(t,s,{...r,platform:l})};var QF=typeof document<"u",NF=function(){},Rf=QF?p.useLayoutEffect:NF;function ax(t,s){if(t===s)return!0;if(typeof t!=typeof s)return!1;if(typeof t=="function"&&t.toString()===s.toString())return!0;let n,a,r;if(t&&s&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==s.length)return!1;for(a=n;a--!==0;)if(!ax(t[a],s[a]))return!1;return!0}if(r=Object.keys(t),n=r.length,n!==Object.keys(s).length)return!1;for(a=n;a--!==0;)if(!{}.hasOwnProperty.call(s,r[a]))return!1;for(a=n;a--!==0;){const l=r[a];if(!(l==="_owner"&&t.$$typeof)&&!ax(t[l],s[l]))return!1}return!0}return t!==t&&s!==s}function KN(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function ij(t,s){const n=KN(t);return Math.round(s*n)/n}function _p(t){const s=p.useRef(t);return Rf(()=>{s.current=t}),s}function SF(t){t===void 0&&(t={});const{placement:s="bottom",strategy:n="absolute",middleware:a=[],platform:r,elements:{reference:l,floating:c}={},transform:A=!0,whileElementsMounted:f,open:x}=t,[h,g]=p.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[O,b]=p.useState(a);ax(O,a)||b(a);const[v,y]=p.useState(null),[S,j]=p.useState(null),N=p.useCallback(H=>{H!==T.current&&(T.current=H,y(H))},[]),C=p.useCallback(H=>{H!==B.current&&(B.current=H,j(H))},[]),U=l||v,P=c||S,T=p.useRef(null),B=p.useRef(null),F=p.useRef(h),M=f!=null,R=_p(f),Y=_p(r),W=_p(x),ee=p.useCallback(()=>{if(!T.current||!B.current)return;const H={placement:s,strategy:n,middleware:O};Y.current&&(H.platform=Y.current),jF(T.current,B.current,H).then(I=>{const L={...I,isPositioned:W.current!==!1};K.current&&!ax(F.current,L)&&(F.current=L,Px.flushSync(()=>{g(L)}))})},[O,s,n,Y,W]);Rf(()=>{x===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,g(H=>({...H,isPositioned:!1})))},[x]);const K=p.useRef(!1);Rf(()=>(K.current=!0,()=>{K.current=!1}),[]),Rf(()=>{if(U&&(T.current=U),P&&(B.current=P),U&&P){if(R.current)return R.current(U,P,ee);ee()}},[U,P,ee,R,M]);const _=p.useMemo(()=>({reference:T,floating:B,setReference:N,setFloating:C}),[N,C]),E=p.useMemo(()=>({reference:U,floating:P}),[U,P]),q=p.useMemo(()=>{const H={position:n,left:0,top:0};if(!E.floating)return H;const I=ij(E.floating,h.x),L=ij(E.floating,h.y);return A?{...H,transform:"translate("+I+"px, "+L+"px)",...KN(E.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:L}},[n,A,E.floating,h.x,h.y]);return p.useMemo(()=>({...h,update:ee,refs:_,elements:E,floatingStyles:q}),[h,ee,_,E,q])}const CF=t=>{function s(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:a,padding:r}=typeof t=="function"?t(n):t;return a&&s(a)?a.current!=null?oj({element:a.current,padding:r}).fn(n):{}:a?oj({element:a,padding:r}).fn(n):{}}}},BF=(t,s)=>{const n=gF(t);return{name:n.name,fn:n.fn,options:[t,s]}},kF=(t,s)=>{const n=OF(t);return{name:n.name,fn:n.fn,options:[t,s]}},TF=(t,s)=>({fn:wF(t).fn,options:[t,s]}),UF=(t,s)=>{const n=bF(t);return{name:n.name,fn:n.fn,options:[t,s]}},EF=(t,s)=>{const n=vF(t);return{name:n.name,fn:n.fn,options:[t,s]}},PF=(t,s)=>{const n=yF(t);return{name:n.name,fn:n.fn,options:[t,s]}},FF=(t,s)=>{const n=CF(t);return{name:n.name,fn:n.fn,options:[t,s]}};var $F="Arrow",qN=p.forwardRef((t,s)=>{const{children:n,width:a=10,height:r=5,...l}=t;return e.jsx(et.svg,{...l,ref:s,width:a,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:e.jsx("polygon",{points:"0,0 30,0 15,10"})})});qN.displayName=$F;var RF=qN;function MF(t){const[s,n]=p.useState(void 0);return Ds(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const a=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const l=r[0];let c,A;if("borderBoxSize"in l){const f=l.borderBoxSize,x=Array.isArray(f)?f[0]:f;c=x.inlineSize,A=x.blockSize}else c=t.offsetWidth,A=t.offsetHeight;n({width:c,height:A})});return a.observe(t,{box:"border-box"}),()=>a.unobserve(t)}else n(void 0)},[t]),s}var yb="Popper",[WN,hc]=Ya(yb),[IF,YN]=WN(yb),JN=t=>{const{__scopePopper:s,children:n}=t,[a,r]=p.useState(null);return e.jsx(IF,{scope:s,anchor:a,onAnchorChange:r,children:n})};JN.displayName=yb;var eS="PopperAnchor",tS=p.forwardRef((t,s)=>{const{__scopePopper:n,virtualRef:a,...r}=t,l=YN(eS,n),c=p.useRef(null),A=mt(s,c),f=p.useRef(null);return p.useEffect(()=>{const x=f.current;f.current=(a==null?void 0:a.current)||c.current,x!==f.current&&l.onAnchorChange(f.current)}),a?null:e.jsx(et.div,{...r,ref:A})});tS.displayName=eS;var wb="PopperContent",[zF,_F]=WN(wb),sS=p.forwardRef((t,s)=>{var ae,be,z,oe,ue,ve;const{__scopePopper:n,side:a="bottom",sideOffset:r=0,align:l="center",alignOffset:c=0,arrowPadding:A=0,avoidCollisions:f=!0,collisionBoundary:x=[],collisionPadding:h=0,sticky:g="partial",hideWhenDetached:O=!1,updatePositionStrategy:b="optimized",onPlaced:v,...y}=t,S=YN(wb,n),[j,N]=p.useState(null),C=mt(s,Ce=>N(Ce)),[U,P]=p.useState(null),T=MF(U),B=(T==null?void 0:T.width)??0,F=(T==null?void 0:T.height)??0,M=a+(l!=="center"?"-"+l:""),R=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},Y=Array.isArray(x)?x:[x],W=Y.length>0,ee={padding:R,boundary:Y.filter(LF),altBoundary:W},{refs:K,floatingStyles:_,placement:E,isPositioned:q,middlewareData:H}=SF({strategy:"fixed",placement:M,whileElementsMounted:(...Ce)=>pF(...Ce,{animationFrame:b==="always"}),elements:{reference:S.anchor},middleware:[BF({mainAxis:r+F,alignmentAxis:c}),f&&kF({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?TF():void 0,...ee}),f&&UF({...ee}),EF({...ee,apply:({elements:Ce,rects:Ne,availableWidth:Xe,availableHeight:Fe})=>{const{width:Ae,height:ke}=Ne.reference,Re=Ce.floating.style;Re.setProperty("--radix-popper-available-width",`${Xe}px`),Re.setProperty("--radix-popper-available-height",`${Fe}px`),Re.setProperty("--radix-popper-anchor-width",`${Ae}px`),Re.setProperty("--radix-popper-anchor-height",`${ke}px`)}}),U&&FF({element:U,padding:A}),HF({arrowWidth:B,arrowHeight:F}),O&&PF({strategy:"referenceHidden",...ee})]}),[I,L]=rS(E),J=Us(v);Ds(()=>{q&&(J==null||J())},[q,J]);const D=(ae=H.arrow)==null?void 0:ae.x,se=(be=H.arrow)==null?void 0:be.y,le=((z=H.arrow)==null?void 0:z.centerOffset)!==0,[V,te]=p.useState();return Ds(()=>{j&&te(window.getComputedStyle(j).zIndex)},[j]),e.jsx("div",{ref:K.setFloating,"data-radix-popper-content-wrapper":"",style:{..._,transform:q?_.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[(oe=H.transformOrigin)==null?void 0:oe.x,(ue=H.transformOrigin)==null?void 0:ue.y].join(" "),...((ve=H.hide)==null?void 0:ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(zF,{scope:n,placedSide:I,onArrowChange:P,arrowX:D,arrowY:se,shouldHideArrow:le,children:e.jsx(et.div,{"data-side":I,"data-align":L,...y,ref:C,style:{...y.style,animation:q?void 0:"none"}})})})});sS.displayName=wb;var nS="PopperArrow",DF={top:"bottom",right:"left",bottom:"top",left:"right"},aS=p.forwardRef(function(s,n){const{__scopePopper:a,...r}=s,l=_F(nS,a),c=DF[l.placedSide];return e.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:e.jsx(RF,{...r,ref:n,style:{...r.style,display:"block"}})})});aS.displayName=nS;function LF(t){return t!==null}var HF=t=>({name:"transformOrigin",options:t,fn(s){var S,j,N;const{placement:n,rects:a,middlewareData:r}=s,c=((S=r.arrow)==null?void 0:S.centerOffset)!==0,A=c?0:t.arrowWidth,f=c?0:t.arrowHeight,[x,h]=rS(n),g={start:"0%",center:"50%",end:"100%"}[h],O=(((j=r.arrow)==null?void 0:j.x)??0)+A/2,b=(((N=r.arrow)==null?void 0:N.y)??0)+f/2;let v="",y="";return x==="bottom"?(v=c?g:`${O}px`,y=`${-f}px`):x==="top"?(v=c?g:`${O}px`,y=`${a.floating.height+f}px`):x==="right"?(v=`${-f}px`,y=c?g:`${b}px`):x==="left"&&(v=`${a.floating.width+f}px`,y=c?g:`${b}px`),{data:{x:v,y}}}});function rS(t){const[s,n="center"]=t.split("-");return[s,n]}var jb=JN,Qb=tS,Nb=sS,Sb=aS,XF="Portal",ud=p.forwardRef((t,s)=>{var A;const{container:n,...a}=t,[r,l]=p.useState(!1);Ds(()=>l(!0),[]);const c=n||r&&((A=globalThis==null?void 0:globalThis.document)==null?void 0:A.body);return c?SU.createPortal(e.jsx(et.div,{...a,ref:s}),c):null});ud.displayName=XF;function GF(t,s){return p.useReducer((n,a)=>s[n][a]??n,t)}var ln=t=>{const{present:s,children:n}=t,a=ZF(s),r=typeof n=="function"?n({present:a.isPresent}):p.Children.only(n),l=mt(a.ref,VF(r));return typeof n=="function"||a.isPresent?p.cloneElement(r,{ref:l}):null};ln.displayName="Presence";function ZF(t){const[s,n]=p.useState(),a=p.useRef(null),r=p.useRef(t),l=p.useRef("none"),c=t?"mounted":"unmounted",[A,f]=GF(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const x=_u(a.current);l.current=A==="mounted"?x:"none"},[A]),Ds(()=>{const x=a.current,h=r.current;if(h!==t){const O=l.current,b=_u(x);t?f("MOUNT"):b==="none"||(x==null?void 0:x.display)==="none"?f("UNMOUNT"):f(h&&O!==b?"ANIMATION_OUT":"UNMOUNT"),r.current=t}},[t,f]),Ds(()=>{if(s){let x;const h=s.ownerDocument.defaultView??window,g=b=>{const y=_u(a.current).includes(CSS.escape(b.animationName));if(b.target===s&&y&&(f("ANIMATION_END"),!r.current)){const S=s.style.animationFillMode;s.style.animationFillMode="forwards",x=h.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=S)})}},O=b=>{b.target===s&&(l.current=_u(a.current))};return s.addEventListener("animationstart",O),s.addEventListener("animationcancel",g),s.addEventListener("animationend",g),()=>{h.clearTimeout(x),s.removeEventListener("animationstart",O),s.removeEventListener("animationcancel",g),s.removeEventListener("animationend",g)}}else f("ANIMATION_END")},[s,f]),{isPresent:["mounted","unmountSuspended"].includes(A),ref:p.useCallback(x=>{a.current=x?getComputedStyle(x):null,n(x)},[])}}function _u(t){return(t==null?void 0:t.animationName)||"none"}function VF(t){var a,r;let s=(a=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(r=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var KF=oN[" useInsertionEffect ".trim().toString()]||Ds;function sc({prop:t,defaultProp:s,onChange:n=()=>{},caller:a}){const[r,l,c]=qF({defaultProp:s,onChange:n}),A=t!==void 0,f=A?t:r;{const h=p.useRef(t!==void 0);p.useEffect(()=>{const g=h.current;g!==A&&console.warn(`${a} is changing from ${g?"controlled":"uncontrolled"} to ${A?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=A},[A,a])}const x=p.useCallback(h=>{var g;if(A){const O=WF(h)?h(t):h;O!==t&&((g=c.current)==null||g.call(c,O))}else l(h)},[A,t,l,c]);return[f,x]}function qF({defaultProp:t,onChange:s}){const[n,a]=p.useState(t),r=p.useRef(n),l=p.useRef(s);return KF(()=>{l.current=s},[s]),p.useEffect(()=>{var c;r.current!==n&&((c=l.current)==null||c.call(l,n),r.current=n)},[n,r]),[n,a,l]}function WF(t){return typeof t=="function"}var oS=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),YF="VisuallyHidden",iS=p.forwardRef((t,s)=>e.jsx(et.span,{...t,ref:s,style:{...oS,...t.style}}));iS.displayName=YF;var JF=iS,[_x]=Ya("Tooltip",[hc]),Dx=hc(),lS="TooltipProvider",e$=700,lO="tooltip.open",[t$,Cb]=_x(lS),cS=t=>{const{__scopeTooltip:s,delayDuration:n=e$,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:l}=t,c=p.useRef(!0),A=p.useRef(!1),f=p.useRef(0);return p.useEffect(()=>{const x=f.current;return()=>window.clearTimeout(x)},[]),e.jsx(t$,{scope:s,isOpenDelayedRef:c,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(f.current),c.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>c.current=!0,a)},[a]),isPointerInTransitRef:A,onPointerInTransitChange:p.useCallback(x=>{A.current=x},[]),disableHoverableContent:r,children:l})};cS.displayName=lS;var VA="Tooltip",[s$,fd]=_x(VA),AS=t=>{const{__scopeTooltip:s,children:n,open:a,defaultOpen:r,onOpenChange:l,disableHoverableContent:c,delayDuration:A}=t,f=Cb(VA,t.__scopeTooltip),x=Dx(s),[h,g]=p.useState(null),O=$r(),b=p.useRef(0),v=c??f.disableHoverableContent,y=A??f.delayDuration,S=p.useRef(!1),[j,N]=sc({prop:a,defaultProp:r??!1,onChange:B=>{B?(f.onOpen(),document.dispatchEvent(new CustomEvent(lO))):f.onClose(),l==null||l(B)},caller:VA}),C=p.useMemo(()=>j?S.current?"delayed-open":"instant-open":"closed",[j]),U=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,S.current=!1,N(!0)},[N]),P=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,N(!1)},[N]),T=p.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{S.current=!0,N(!0),b.current=0},y)},[y,N]);return p.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),e.jsx(jb,{...x,children:e.jsx(s$,{scope:s,contentId:O,open:j,stateAttribute:C,trigger:h,onTriggerChange:g,onTriggerEnter:p.useCallback(()=>{f.isOpenDelayedRef.current?T():U()},[f.isOpenDelayedRef,T,U]),onTriggerLeave:p.useCallback(()=>{v?P():(window.clearTimeout(b.current),b.current=0)},[P,v]),onOpen:U,onClose:P,disableHoverableContent:v,children:n})})};AS.displayName=VA;var cO="TooltipTrigger",dS=p.forwardRef((t,s)=>{const{__scopeTooltip:n,...a}=t,r=fd(cO,n),l=Cb(cO,n),c=Dx(n),A=p.useRef(null),f=mt(s,A,r.onTriggerChange),x=p.useRef(!1),h=p.useRef(!1),g=p.useCallback(()=>x.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),e.jsx(Qb,{asChild:!0,...c,children:e.jsx(et.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:f,onPointerMove:Ue(t.onPointerMove,O=>{O.pointerType!=="touch"&&!h.current&&!l.isPointerInTransitRef.current&&(r.onTriggerEnter(),h.current=!0)}),onPointerLeave:Ue(t.onPointerLeave,()=>{r.onTriggerLeave(),h.current=!1}),onPointerDown:Ue(t.onPointerDown,()=>{r.open&&r.onClose(),x.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:Ue(t.onFocus,()=>{x.current||r.onOpen()}),onBlur:Ue(t.onBlur,r.onClose),onClick:Ue(t.onClick,r.onClose)})})});dS.displayName=cO;var Bb="TooltipPortal",[n$,a$]=_x(Bb,{forceMount:void 0}),uS=t=>{const{__scopeTooltip:s,forceMount:n,children:a,container:r}=t,l=fd(Bb,s);return e.jsx(n$,{scope:s,forceMount:n,children:e.jsx(ln,{present:n||l.open,children:e.jsx(ud,{asChild:!0,container:r,children:a})})})};uS.displayName=Bb;var nc="TooltipContent",fS=p.forwardRef((t,s)=>{const n=a$(nc,t.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...l}=t,c=fd(nc,t.__scopeTooltip);return e.jsx(ln,{present:a||c.open,children:c.disableHoverableContent?e.jsx(xS,{side:r,...l,ref:s}):e.jsx(r$,{side:r,...l,ref:s})})}),r$=p.forwardRef((t,s)=>{const n=fd(nc,t.__scopeTooltip),a=Cb(nc,t.__scopeTooltip),r=p.useRef(null),l=mt(s,r),[c,A]=p.useState(null),{trigger:f,onClose:x}=n,h=r.current,{onPointerInTransitChange:g}=a,O=p.useCallback(()=>{A(null),g(!1)},[g]),b=p.useCallback((v,y)=>{const S=v.currentTarget,j={x:v.clientX,y:v.clientY},N=c$(j,S.getBoundingClientRect()),C=A$(j,N),U=d$(y.getBoundingClientRect()),P=f$([...C,...U]);A(P),g(!0)},[g]);return p.useEffect(()=>()=>O(),[O]),p.useEffect(()=>{if(f&&h){const v=S=>b(S,h),y=S=>b(S,f);return f.addEventListener("pointerleave",v),h.addEventListener("pointerleave",y),()=>{f.removeEventListener("pointerleave",v),h.removeEventListener("pointerleave",y)}}},[f,h,b,O]),p.useEffect(()=>{if(c){const v=y=>{const S=y.target,j={x:y.clientX,y:y.clientY},N=(f==null?void 0:f.contains(S))||(h==null?void 0:h.contains(S)),C=!u$(j,c);N?O():C&&(O(),x())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[f,h,c,x,O]),e.jsx(xS,{...t,ref:l})}),[o$,i$]=_x(VA,{isInside:!1}),l$=pP("TooltipContent"),xS=p.forwardRef((t,s)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:l,onPointerDownOutside:c,...A}=t,f=fd(nc,n),x=Dx(n),{onClose:h}=f;return p.useEffect(()=>(document.addEventListener(lO,h),()=>document.removeEventListener(lO,h)),[h]),p.useEffect(()=>{if(f.trigger){const g=O=>{const b=O.target;b!=null&&b.contains(f.trigger)&&h()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[f.trigger,h]),e.jsx(Ad,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:e.jsxs(Nb,{"data-state":f.stateAttribute,...x,...A,ref:s,style:{...A.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(l$,{children:a}),e.jsx(o$,{scope:n,isInside:!0,children:e.jsx(JF,{id:f.contentId,role:"tooltip",children:r||a})})]})})});fS.displayName=nc;var mS="TooltipArrow",hS=p.forwardRef((t,s)=>{const{__scopeTooltip:n,...a}=t,r=Dx(n);return i$(mS,n).isInside?null:e.jsx(Sb,{...r,...a,ref:s})});hS.displayName=mS;function c$(t,s){const n=Math.abs(s.top-t.y),a=Math.abs(s.bottom-t.y),r=Math.abs(s.right-t.x),l=Math.abs(s.left-t.x);switch(Math.min(n,a,r,l)){case l:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function A$(t,s,n=5){const a=[];switch(s){case"top":a.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":a.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":a.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":a.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return a}function d$(t){const{top:s,right:n,bottom:a,left:r}=t;return[{x:r,y:s},{x:n,y:s},{x:n,y:a},{x:r,y:a}]}function u$(t,s){const{x:n,y:a}=t;let r=!1;for(let l=0,c=s.length-1;l<s.length;c=l++){const A=s[l],f=s[c],x=A.x,h=A.y,g=f.x,O=f.y;h>a!=O>a&&n<(g-x)*(a-h)/(O-h)+x&&(r=!r)}return r}function f$(t){const s=t.slice();return s.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),x$(s)}function x$(t){if(t.length<=1)return t.slice();const s=[];for(let a=0;a<t.length;a++){const r=t[a];for(;s.length>=2;){const l=s[s.length-1],c=s[s.length-2];if((l.x-c.x)*(r.y-c.y)>=(l.y-c.y)*(r.x-c.x))s.pop();else break}s.push(r)}s.pop();const n=[];for(let a=t.length-1;a>=0;a--){const r=t[a];for(;n.length>=2;){const l=n[n.length-1],c=n[n.length-2];if((l.x-c.x)*(r.y-c.y)>=(l.y-c.y)*(r.x-c.x))n.pop();else break}n.push(r)}return n.pop(),s.length===1&&n.length===1&&s[0].x===n[0].x&&s[0].y===n[0].y?s:s.concat(n)}var m$=cS,h$=AS,p$=dS,g$=uS,O$=fS,b$=hS;function v$({children:t}){return e.jsx(m$,{delayDuration:300,children:t})}function dt({children:t,content:s,side:n="top",className:a}){return s?e.jsxs(h$,{children:[e.jsx(p$,{asChild:!0,children:t}),e.jsx(g$,{children:e.jsxs(O$,{side:n,sideOffset:6,className:Z("z-50 px-2.5 py-1.5 text-xs font-sans","bg-surface-4 text-text-0 border border-border rounded-md shadow-lg","animate-in fade-in-0 zoom-in-95",a),children:[s,e.jsx(b$,{className:"fill-surface-4"})]})})]}):t}/**
44
+ `:" ";Y[Y.length-1]={...W,text:W.text+_+C,timestamp:Date.now()}}else Y.push({from:"assistant",text:C,timestamp:Date.now()});R[M.id]=Y.slice(-200),t({conversationMessages:R,streamingConversationId:M.id}),ft("groove:conversationMessages",R)}}}if(S&&S.trim()){const C={...s().activityLog};C[b]||(C[b]=[]),C[b]=[...C[b].slice(-200),{timestamp:Date.now(),text:S.trim(),type:v.type,subtype:"tool"}],t({activityLog:C}),ft("groove:activityLog",C)}if(s().workspaceMode&&Array.isArray(v.data)){const C=new Set(["Write","Edit","write_file","edit_file","create_file"]);for(const U of v.data){if(U.type!=="tool_use"||!C.has(U.name))continue;const P=((l=U.input)==null?void 0:l.file_path)||((c=U.input)==null?void 0:c.path);if(P&&b===s().workspaceAgentId){const T=P.replace(/^\/[^/]+.*?\/groove\//,"");s().editorActiveFile?t(F=>({editorOpenTabs:F.editorOpenTabs.includes(T)?F.editorOpenTabs:[...F.editorOpenTabs,T]})):s().openFile(T)}}}break}case"agent:exit":{if(r.status==="waiting_for_input"){const C=s().agents.find(U=>U.id===r.agentId);s().addToast("info",`${(C==null?void 0:C.name)||r.agentId.slice(0,8)} needs your input`,"Check the question popup below");break}const b=s().agents.find(C=>C.id===r.agentId),v=(b==null?void 0:b.name)||r.agentId,y=r.status==="killed"||r.code===143||r.code===137,S=r.status==="completed"?`${v} completed`:y?`${v} stopped`:`${v} crashed (exit ${r.code})`,j=r.status==="completed"?"success":y?"info":"warning";s().addToast(j,S,r.error?r.error.slice(0,200):void 0),s().thinkingAgents.has(r.agentId)&&t(C=>{const U=new Set(C.thinkingAgents);return U.delete(r.agentId),{thinkingAgents:U}});const N=s().conversations.find(C=>C.agentId===r.agentId);if(N&&s().streamingConversationId===N.id&&t({sendingMessage:!1,streamingConversationId:null}),r.error&&r.agentId&&s().addChatMessage(r.agentId,"system",`Crashed: ${r.error}`),s().workspaceAgentId===r.agentId){const C=s().agents.filter(P=>P.id!==r.agentId&&P.teamId===s().activeTeamId),U=C.find(P=>P.status==="running")||C[0];t({workspaceAgentId:(U==null?void 0:U.id)||null})}(b==null?void 0:b.role)==="planner"&&r.status==="completed"&&setTimeout(()=>s().checkRecommendedTeam(),1e3);break}case"innerchat:turn":{const{thread:b,turn:v}=r.data;if(v.status==="failed"){s().addToast("error",`InnerChat to ${v.to.name} failed`,v.error);break}t(y=>{const S={...y.chatHistory},j=(P,T)=>({from:"innerchat",text:v.text,timestamp:v.timestamp,isQuery:!1,innerchat:{turnId:v.id,threadId:b.id,kind:v.kind,peer:P,direction:T}}),N=(P,T)=>{S[P]=[...S[P]||[],T].slice(-100)};v.kind==="ask"&&N(v.from.id,j(v.to,"out")),N(v.to.id,j(v.from,"in")),$A(S);const C={...y.innerchatAnswers};v.kind==="answer"&&(C[v.from.id]={...C[v.from.id]||{},[v.text.trim()]:{peer:v.to,threadId:b.id}});const U={...y.innerchatThreads,[b.id]:b};return ft("groove:innerchatThreads",U),{chatHistory:S,innerchatThreads:U,innerchatAnswers:C}});break}case"recommended-team:ready":s().recommendedTeam||s().checkRecommendedTeam();break;case"phase2:spawned":s().addToast("info",`QC agent ${r.name} auto-spawned`,"Auditing phase 1 work");break;case"preview:ready":{const b=r.teamId?`/api/preview/${r.teamId}/proxy/`:r.url;t(v=>({teamPreviews:{...v.teamPreviews,[r.teamId]:{url:b,kind:r.kind,active:!0}}})),s().addToast("success","Project ready to preview",r.url,{label:"Open Preview",onClick:()=>s().openPreview(b,r.teamId,r.kind)},{persistent:!0,actions:[{label:"View in Browser",url:r.url}]});break}case"preview:failed":{const b=r.kind||"";b!=="no_preview"&&b!=="cli"&&b!=="none"&&s().addToast("warning","Preview could not launch",r.reason?String(r.reason).slice(0,200):"Unknown error");break}case"preview:stopped":{const b=s().teamPreviews[r.teamId];b&&t(v=>({teamPreviews:{...v.teamPreviews,[r.teamId]:{...b,active:!1}}}));break}case"agent:stalled":{const b=r.agentName||r.agentId,v=Math.round((r.silentMs||0)/1e3);s().addToast("warning",`${b} may be stalled`,`No output for ${v}s — API stream may be hung`);break}case"knock:denied":{const b=r.agentName||r.agentId;s().addToast("warning",`${b} blocked`,`${r.toolName} on ${r.target} — ${r.reason||"scope conflict"}`);break}case"phase2:failed":s().addToast("error","QC agent failed to spawn",r.error||"Unknown error");break;case"agent:message_queued":s().addChatMessage(r.agentId,"system","Agent is working — message will be delivered when it finishes.");break;case"agent:question":t(b=>({pendingQuestions:[...b.pendingQuestions,r.data]}));break;case"agent:question:resolved":t(b=>({pendingQuestions:b.pendingQuestions.filter(v=>v.agentId!==r.agentId)}));break;case"ollama:pull:progress":t({ollamaPullProgress:{...s().ollamaPullProgress,[r.model]:{status:"pulling",progress:r.progress}}});break;case"ollama:pull:complete":{const b={...s().ollamaPullProgress};delete b[r.model],t({ollamaPullProgress:b}),s().fetchOllamaStatus();break}case"ollama:pull:error":{const b={...s().ollamaPullProgress};delete b[r.model],t({ollamaPullProgress:b}),s().addToast("error",`Model pull failed: ${r.error}`);break}case"ollama:model:loaded":s().fetchOllamaStatus();break;case"ollama:model:unloaded":s().fetchOllamaStatus();break;case"ollama:model:imported":s().fetchOllamaStatus();break;case"lab:runtime:added":case"lab:runtime:updated":case"lab:runtime:removed":case"lab:runtime:started":case"lab:runtime:stopped":case"llama:server:stopped":s().fetchLabRuntimes();break;case"lab:preset:created":case"lab:preset:updated":case"lab:preset:deleted":break;case"rotation:start":break;case"rotation:complete":{const b=r.agentId,v=r.oldAgentId;if(!b||!v)break;t(y=>{var F,M,R;const S={...y.chatHistory},j={...y.tokenTimeline},N={...y.activityLog},C={...y.chatInputs};(F=S[v])!=null&&F.length&&(S[b]=[...S[v]],delete S[v]),(M=j[v])!=null&&M.length&&(j[b]=[...j[v]],delete j[v]),(R=N[v])!=null&&R.length&&(N[b]=[...N[v]],delete N[v]),C[v]&&(C[b]=C[v],delete C[v]);const U=y.detailPanel;let P=U,T=y.teamDetailPanels;if((U==null?void 0:U.type)==="agent"&&U.agentId===v){const Y={type:"agent",agentId:b};P=Y;const W=s().activeTeamId;T={...y.teamDetailPanels,[W]:Y}}let B=y.fleetSelectedAgents;(B[0]===v||B[1]===v)&&(B=[B[0]===v?b:B[0],B[1]===v?b:B[1]]);try{localStorage.setItem("groove:chatHistory",JSON.stringify(S))}catch{}return{chatHistory:S,tokenTimeline:j,activityLog:N,chatInputs:C,detailPanel:P,teamDetailPanels:T,fleetSelectedAgents:B}});break}case"rotation:failed":s().addToast("error","Rotation failed",r.error);break;case"file:changed":{const b=s().editorRecentSaves[r.path];if(b&&Date.now()-b<2e3)break;if(s().workspaceMode&&r.path&&!s().workspaceSnapshots[r.path]){const v=s().editorFiles[r.path];v!=null&&v.content&&s().captureSnapshot(r.path,v.content)}s().editorFiles[r.path]&&s().reloadFile(r.path);break}case"file:tree-changed":{s().fetchTreeDir(r.path||"");break}case"team:created":case"team:deleted":case"team:updated":s().fetchTeams();break;case"teams:reordered":r.teams&&t({teams:r.teams});break;case"approval:request":t(b=>({pendingApprovals:[...b.pendingApprovals,r.data]}));break;case"approval:resolved":{const b=r.data;t(v=>({pendingApprovals:v.pendingApprovals.filter(y=>y.id!==b.id),resolvedApprovals:[b,...v.resolvedApprovals].slice(0,200)}));break}case"conflict:detected":s().addToast("error",`Scope conflict: ${r.agentName||"agent"}`,r.filePath?`File: ${r.filePath}`:void 0);break;case"qc:activated":s().addToast("info","QC agent activated",`${r.agentCount||"4+"} agents running`);break;case"journalist:cycle":t({journalistStatus:r.data||null});break;case"schedule:execute":s().addToast("info",`Scheduled agent spawned: ${r.name||r.role||"agent"}`),s().fetchAutomations();break;case"schedule:created":case"schedule:updated":case"schedule:deleted":s().fetchAutomations();break;case"auto-agent:created":case"auto-agent:updated":case"auto-agent:deleted":case"auto-agent:paused":case"auto-agent:resumed":case"auto-agent:cycle-complete":case"auto-agent:auto-paused":case"auto-agent:state-updated":case"auto-agent:iteration-started":s().fetchAutoAgents();break;case"gateway:status":t({gateways:r.data||[]});break;case"provider:status-changed":t({_providerRefreshTick:Date.now()});break;case"federation:whitelist":t(b=>({federation:{...b.federation,whitelist:r.data||[]}}));break;case"federation:connection":t(b=>{const v=[...b.federation.connections],y=v.findIndex(S=>{var j;return S.ip===((j=r.data)==null?void 0:j.ip)});return y>=0?v[y]={...v[y],...r.data}:v.push(r.data),{federation:{...b.federation,connections:v}}});break;case"federation:pouch":case"federation:pouch-log":t(b=>({federation:{...b.federation,pouchLog:[...b.federation.pouchLog,r.data].slice(-200)}}));break;case"project-dir:changed":t({projectDir:(A=r.data)==null?void 0:A.projectDir,showProjectPicker:!1});break;case"tunnel.connected":s().fetchTunnels(),t({tunnelConnectStep:null});break;case"tunnel.status":{t({tunnelConnectStep:r.data});break}case"tunnel.disconnected":s().fetchTunnels();break;case"tunnel.health":{const b=s().savedTunnels.map(v=>{var y;return v.id===((y=r.data)==null?void 0:y.id)?{...v,latencyMs:r.data.latencyMs,healthy:r.data.healthy}:v});t({savedTunnels:b});break}case"tunnel.version-info":{const b=s().savedTunnels.map(v=>v.id===r.data.id?{...v,localVersion:r.data.localVersion,remoteVersion:r.data.remoteVersion,versionMatch:r.data.match}:v);t({savedTunnels:b});break}case"tunnel.version-mismatch":{const b=s().savedTunnels.map(v=>v.id===r.data.id?{...v,localVersion:r.data.localVersion,remoteVersion:r.data.remoteVersion,versionMatch:!1}:v);t({savedTunnels:b}),s().addToast("warning","Version mismatch",`Remote v${r.data.remoteVersion} — local v${r.data.localVersion}. ${r.data.message||""}`);break}case"tunnel.upgrade-failed":{s().addToast("error","Remote upgrade failed",r.data.error||"Unknown error");break}case"subscription:updated":{const b={subscription:r.data};((f=r.data)==null?void 0:f.active)===!0&&!s().marketplaceAuthenticated&&(b.marketplaceAuthenticated=!0),t(b),G.get("/edition").then(v=>{t({edition:v.edition||"community",subscription:{plan:v.plan||"community",status:v.status||(v.subscriptionActive?"active":"none"),active:v.subscriptionActive===!0,features:v.features||[],seats:v.seats||1,periodEnd:v.periodEnd||null,cancelAtPeriodEnd:v.cancelAtPeriodEnd||!1}})}).catch(()=>{}),s().fetchTunnels();break}case"auth:expired":t({marketplaceAuthenticated:!1,marketplaceUser:null});break;case"network:node:status":{const{__proto__:b,constructor:v,prototype:y,...S}=r.data||{};t({networkNode:{...s().networkNode,...S}});break}case"network:node:event":{const b=r.data||{};t(v=>({networkEvents:[...v.networkEvents,{...b,timestamp:b.timestamp||Date.now()}].slice(-100)}));break}case"signal_connected":{const b=r.data||{};t(v=>({networkEvents:[...v.networkEvents,{level:"connected",msg:String(b.msg||b.message||"Connected to signal").slice(0,500),detail:b.detail||b.url||void 0,timestamp:b.timestamp||Date.now()}].slice(-100)}));break}case"matched":{const b=r.data||{};t(v=>({networkEvents:[...v.networkEvents,{level:"session",msg:String(b.msg||b.message||"Session matched").slice(0,500),detail:b.detail||b.peer||b.nodeId||void 0,timestamp:b.timestamp||Date.now()}].slice(-100)}));break}case"network:status":{const b=r.data||{},v={networkStatus:{...s().networkStatus,...b}};if(b.compute){const P=b.compute;v.networkCompute={totalRamMb:P.totalRamMb??P.total_ram_mb??0,totalVramMb:P.totalVramMb??P.total_vram_mb??0,totalCpuCores:P.totalCpuCores??P.total_cpu_cores??0,totalBandwidthMbps:P.totalBandwidthMbps??P.total_bandwidth_mbps??0,activeNodes:P.activeNodes??P.active_nodes??0,totalNodes:P.totalNodes??P.total_nodes??0,avgLoad:P.avgLoad??P.avg_load??0}}else if(Array.isArray(b.nodes)&&b.nodes.length>0){const P=b.nodes,T=P.filter(B=>B.status==="active");v.networkCompute={totalRamMb:P.reduce((B,F)=>B+(F.ram_mb||0),0),totalVramMb:P.reduce((B,F)=>B+(F.vram_mb||0),0),totalCpuCores:P.reduce((B,F)=>B+(F.cpu_cores||0),0),totalBandwidthMbps:P.reduce((B,F)=>B+(F.bandwidth_mbps||0),0),activeNodes:T.length,totalNodes:P.length,avgLoad:T.length>0?T.reduce((B,F)=>B+(F.load||0),0)/T.length:0}}t(v);const y=b.nodes||[],S=s().networkNode.nodeId,j=S?y.find(P=>(P.node_id||P.nodeId)===S):null,N=y.filter(P=>P.status==="active"),C={t:Date.now(),globalSessions:b.activeSessions||0,mySessions:(j==null?void 0:j.active_sessions)??(j==null?void 0:j.sessions)??0,nodeCount:N.length,avgLoad:N.length>0?N.reduce((P,T)=>P+(T.load||0),0)/N.length:0,myLoad:(j==null?void 0:j.load)??0,totalVramMb:y.reduce((P,T)=>P+(T.vram_mb||0),0),totalRamMb:y.reduce((P,T)=>P+(T.ram_mb||0),0)};let U=[...s().networkSnapshots,C];U.length>100&&(U=U.slice(-100)),t({networkSnapshots:U});break}case"network:install:progress":{const{step:b,message:v,percent:y}=r.data||{};b==="done"?(t({networkInstalled:!0,networkInstallProgress:{installing:!1,step:null,message:null,percent:0,error:null}}),s().addToast("success","Network package installed")):t(b==="error"?{networkInstallProgress:{installing:!1,step:"error",message:v||"Install failed",percent:0,error:v||"Install failed"}}:{networkInstallProgress:{installing:!0,step:b||"progress",message:v||"",percent:Number.isFinite(y)?Math.max(0,Math.min(100,y)):s().networkInstallProgress.percent,error:null}});break}case"network:update:available":{const{installed:b,latest:v,updateAvailable:y}=r.data||{};t({networkVersion:{installed:b??s().networkVersion.installed,latest:v??s().networkVersion.latest,updateAvailable:!!y}});break}case"network:update:progress":{const{step:b,message:v,percent:y,version:S,error:j}=r.data||{};b==="done"?(t({networkUpdateProgress:{updating:!1,step:null,message:null,percent:0,error:null},networkVersion:{...s().networkVersion,installed:S||s().networkVersion.latest||s().networkVersion.installed,updateAvailable:!1}}),s().addToast("success","Network package updated")):b==="error"?(t({networkUpdateProgress:{updating:!1,step:"error",message:v||j||"Update failed",percent:0,error:v||j||"Update failed"}}),s().addToast("error","Network update failed",v||j)):t({networkUpdateProgress:{updating:!0,step:b||"progress",message:v||"",percent:Number.isFinite(y)?Math.max(0,Math.min(100,y)):s().networkUpdateProgress.percent,error:null}});break}case"training:status":{const b={trainingOptIn:((x=r.data)==null?void 0:x.optedIn)??!1,trainingStats:r.data};(h=r.data)!=null&&h.optedIn&&(b.dataSharingModalOpen=!1),t(b);break}case"config:updated":s().fetchBetaStatus(),s().fetchNetworkInstallStatus();break;case"conversation:created":{const b=r.data;b&&t(v=>({conversations:[b,...v.conversations.filter(y=>y.id!==b.id)]}));break}case"conversation:updated":{const b=r.data;b&&t(v=>({conversations:v.conversations.map(y=>y.id===b.id?{...y,...b}:y)}));break}case"conversation:deleted":{const b=((g=r.data)==null?void 0:g.id)||r.id;b&&t(v=>{const y=v.conversations.filter(N=>N.id!==b),S={...v.conversationMessages};delete S[b];const j=v.activeConversationId===b?null:v.activeConversationId;return j!==v.activeConversationId&&localStorage.setItem("groove:activeConversationId",""),{conversations:y,conversationMessages:S,activeConversationId:j}});break}case"conversation:tool":{const{conversationId:b,name:v,summary:y}=r.data||r;if(!b)break;t(S=>{const j={...S.conversationActiveTools};return j[b]={name:v||"Tool",summary:y||null,timestamp:Date.now()},{conversationActiveTools:j}});break}case"conversation:chunk":{const{conversationId:b,text:v}=r.data||r;if(!b||!v)break;t(y=>{const S={...y.conversationMessages};S[b]||(S[b]=[]);const j=[...S[b]],N=j[j.length-1];N&&N.from==="assistant"&&Date.now()-N.timestamp<3e4?j[j.length-1]={...N,text:N.text+v,timestamp:Date.now()}:j.push({from:"assistant",text:v,timestamp:Date.now()}),S[b]=j.slice(-200);const C={...y.conversationActiveTools};return delete C[b],{conversationMessages:S,streamingConversationId:b,conversationActiveTools:C}});break}case"conversation:complete":{const{conversationId:b}=r.data||r;if(b&&s().streamingConversationId===b){const v={...s().conversationActiveTools};delete v[b],t({sendingMessage:!1,streamingConversationId:null,conversationActiveTools:v})}b&&ft("groove:conversationMessages",s().conversationMessages);break}case"conversation:image":{const{conversationId:b,prompt:v,url:y,b64_json:S,mimeType:j,model:N,provider:C}=r.data||r;if(!b)break;const U=y||(S?`data:${j||"image/png"};base64,${S}`:null);t(P=>{const T={...P.conversationMessages};T[b]||(T[b]=[]);const B=[...T[b]],F=B.findLastIndex(R=>R.type==="image-loading"&&R.prompt===v);F>=0?B[F]={from:"assistant",type:"image",imageUrl:U,prompt:v,model:N,provider:C,timestamp:Date.now()}:B.push({from:"assistant",type:"image",imageUrl:U,prompt:v,model:N,provider:C,timestamp:Date.now()}),T[b]=B.slice(-200),ft("groove:conversationMessages",T);const M=P.streamingConversationId===b;return{conversationMessages:T,sendingMessage:M?!1:P.sendingMessage,streamingConversationId:M?null:P.streamingConversationId}});break}case"conversation:image-progress":{const{conversationId:b,status:v,prompt:y,error:S}=r.data||r;if(!b)break;v==="generating"?t(j=>{const N={...j.conversationMessages};return N[b]||(N[b]=[]),N[b]=[...N[b],{from:"assistant",type:"image-loading",prompt:y,timestamp:Date.now()}],{conversationMessages:N,streamingConversationId:b}}):v==="error"&&t(j=>{const N={...j.conversationMessages};N[b]||(N[b]=[]);const C=[...N[b]],U=C.findLastIndex(T=>T.type==="image-loading");U>=0&&C.splice(U,1),C.push({from:"system",text:`Image generation failed: ${S||"Unknown error"}`,timestamp:Date.now()}),N[b]=C,ft("groove:conversationMessages",N);const P=j.streamingConversationId===b;return{conversationMessages:N,sendingMessage:P?!1:j.sendingMessage,streamingConversationId:P?null:j.streamingConversationId}});break}case"conversation:error":{const{conversationId:b,error:v}=r.data||r;b&&t(y=>{const S={...y.conversationMessages};S[b]||(S[b]=[]),S[b]=[...S[b],{from:"system",text:`Error: ${v||"Unknown error"}`,timestamp:Date.now()}],ft("groove:conversationMessages",S);const j=y.streamingConversationId===b;return{conversationMessages:S,sendingMessage:j?!1:y.sendingMessage,streamingConversationId:j?null:y.streamingConversationId}});break}case"network:token:timing":{const{__proto__:b,constructor:v,prototype:y,...S}=r.data||{},j={networkTokenTiming:S,networkPerfSnapshots:[...s().networkPerfSnapshots,{t:Date.now(),tps:S.tps||0}].slice(-100)};if(Array.isArray(S.stages)){const N={...s().networkNodeTelemetry},C=new Set(["__proto__","constructor","prototype"]);for(const U of S.stages){const P=(O=U.node_telemetry)==null?void 0:O.node_id;P&&typeof P=="string"&&!C.has(P)&&(N[P]={...U.node_telemetry,forward_ms:U.forward_ms,updatedAt:Date.now()})}j.networkNodeTelemetry=N}t(j);break}case"network:timing:summary":{const{__proto__:b,constructor:v,prototype:y,...S}=r.data||{};t(j=>({networkBenchmarks:[...j.networkBenchmarks,S].slice(-100)}));break}case"keeper:saved":case"keeper:updated":case"keeper:deleted":s().fetchKeeperItems();break}},n.onclose=()=>{za&&(clearInterval(za),za=null),t({connected:!1,hydrated:!1,ws:null,daemonHost:null,tunneled:!1,remoteHomedir:null}),setTimeout(()=>s().connect(),2e3)},n.onerror=()=>n.close()}}));if(typeof window<"u"){const t=()=>{const s=k.getState();s.ws||s.connect()};window.addEventListener("online",t),window.addEventListener("focus",t),document.addEventListener("visibilitychange",()=>{document.hidden||t()})}function pN(t){p.useEffect(()=>{function s(n){for(const a of t){const r=a.meta?n.metaKey||n.ctrlKey:!0,l=a.shift?n.shiftKey:!n.shiftKey;if(n.key.toLowerCase()===a.key.toLowerCase()&&r&&l){n.preventDefault(),a.handler();return}}}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t])}function cd(){return!!(window.groove||navigator.userAgent.includes("Electron"))}function gN(){var t;return((t=window.groove)==null?void 0:t.platform)||"browser"}function sO(t){window.groove?window.groove.openExternal(t):window.open(t,"_blank")}async function wE(t={}){var s,n;return(n=(s=window.groove)==null?void 0:s.folders)!=null&&n.select?window.groove.folders.select(t):null}async function ON(t){var s,n;if((n=(s=window.groove)==null?void 0:s.integrations)!=null&&n.oauthStart)return window.groove.integrations.oauthStart(t);window.open(t,"_blank","noopener")}function bN(t){var s,n,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(s=0;s<r;s++)t[s]&&(n=bN(t[s]))&&(a&&(a+=" "),a+=n)}else for(n in t)t[n]&&(a&&(a+=" "),a+=n);return a}function jE(){for(var t,s,n=0,a="",r=arguments.length;n<r;n++)(t=arguments[n])&&(s=bN(t))&&(a&&(a+=" "),a+=s);return a}const QE=(t,s)=>{const n=new Array(t.length+s.length);for(let a=0;a<t.length;a++)n[a]=t[a];for(let a=0;a<s.length;a++)n[t.length+a]=s[a];return n},NE=(t,s)=>({classGroupId:t,validator:s}),vN=(t=new Map,s=null,n)=>({nextPart:t,validators:s,classGroupId:n}),ex="-",Dw=[],SE="arbitrary..",CE=t=>{const s=kE(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return BE(c);const A=c.split(ex),f=A[0]===""&&A.length>1?1:0;return yN(A,f,s)},getConflictingClassGroupIds:(c,A)=>{if(A){const f=a[c],x=n[c];return f?x?QE(x,f):f:x||Dw}return n[c]||Dw}}},yN=(t,s,n)=>{if(t.length-s===0)return n.classGroupId;const r=t[s],l=n.nextPart.get(r);if(l){const x=yN(t,s+1,l);if(x)return x}const c=n.validators;if(c===null)return;const A=s===0?t.join(ex):t.slice(s).join(ex),f=c.length;for(let x=0;x<f;x++){const h=c[x];if(h.validator(A))return h.classGroupId}},BE=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const s=t.slice(1,-1),n=s.indexOf(":"),a=s.slice(0,n);return a?SE+a:void 0})(),kE=t=>{const{theme:s,classGroups:n}=t;return TE(n,s)},TE=(t,s)=>{const n=vN();for(const a in t){const r=t[a];fb(r,n,a,s)}return n},fb=(t,s,n,a)=>{const r=t.length;for(let l=0;l<r;l++){const c=t[l];UE(c,s,n,a)}},UE=(t,s,n,a)=>{if(typeof t=="string"){EE(t,s,n);return}if(typeof t=="function"){PE(t,s,n,a);return}FE(t,s,n,a)},EE=(t,s,n)=>{const a=t===""?s:wN(s,t);a.classGroupId=n},PE=(t,s,n,a)=>{if($E(t)){fb(t(a),s,n,a);return}s.validators===null&&(s.validators=[]),s.validators.push(NE(n,t))},FE=(t,s,n,a)=>{const r=Object.entries(t),l=r.length;for(let c=0;c<l;c++){const[A,f]=r[c];fb(f,wN(s,A),n,a)}},wN=(t,s)=>{let n=t;const a=s.split(ex),r=a.length;for(let l=0;l<r;l++){const c=a[l];let A=n.nextPart.get(c);A||(A=vN(),n.nextPart.set(c,A)),n=A}return n},$E=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,RE=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,n=Object.create(null),a=Object.create(null);const r=(l,c)=>{n[l]=c,s++,s>t&&(s=0,a=n,n=Object.create(null))};return{get(l){let c=n[l];if(c!==void 0)return c;if((c=a[l])!==void 0)return r(l,c),c},set(l,c){l in n?n[l]=c:r(l,c)}}},nO="!",Lw=":",ME=[],Hw=(t,s,n,a,r)=>({modifiers:t,hasImportantModifier:s,baseClassName:n,maybePostfixModifierPosition:a,isExternal:r}),IE=t=>{const{prefix:s,experimentalParseClassName:n}=t;let a=r=>{const l=[];let c=0,A=0,f=0,x;const h=r.length;for(let y=0;y<h;y++){const S=r[y];if(c===0&&A===0){if(S===Lw){l.push(r.slice(f,y)),f=y+1;continue}if(S==="/"){x=y;continue}}S==="["?c++:S==="]"?c--:S==="("?A++:S===")"&&A--}const g=l.length===0?r:r.slice(f);let O=g,b=!1;g.endsWith(nO)?(O=g.slice(0,-1),b=!0):g.startsWith(nO)&&(O=g.slice(1),b=!0);const v=x&&x>f?x-f:void 0;return Hw(l,b,O,v)};if(s){const r=s+Lw,l=a;a=c=>c.startsWith(r)?l(c.slice(r.length)):Hw(ME,!1,c,void 0,!0)}if(n){const r=a;a=l=>n({className:l,parseClassName:r})}return a},zE=t=>{const s=new Map;return t.orderSensitiveModifiers.forEach((n,a)=>{s.set(n,1e6+a)}),n=>{const a=[];let r=[];for(let l=0;l<n.length;l++){const c=n[l],A=c[0]==="[",f=s.has(c);A||f?(r.length>0&&(r.sort(),a.push(...r),r=[]),a.push(c)):r.push(c)}return r.length>0&&(r.sort(),a.push(...r)),a}},_E=t=>({cache:RE(t.cacheSize),parseClassName:IE(t),sortModifiers:zE(t),...CE(t)}),DE=/\s+/,LE=(t,s)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:r,sortModifiers:l}=s,c=[],A=t.trim().split(DE);let f="";for(let x=A.length-1;x>=0;x-=1){const h=A[x],{isExternal:g,modifiers:O,hasImportantModifier:b,baseClassName:v,maybePostfixModifierPosition:y}=n(h);if(g){f=h+(f.length>0?" "+f:f);continue}let S=!!y,j=a(S?v.substring(0,y):v);if(!j){if(!S){f=h+(f.length>0?" "+f:f);continue}if(j=a(v),!j){f=h+(f.length>0?" "+f:f);continue}S=!1}const N=O.length===0?"":O.length===1?O[0]:l(O).join(":"),C=b?N+nO:N,U=C+j;if(c.indexOf(U)>-1)continue;c.push(U);const P=r(j,S);for(let T=0;T<P.length;++T){const B=P[T];c.push(C+B)}f=h+(f.length>0?" "+f:f)}return f},HE=(...t)=>{let s=0,n,a,r="";for(;s<t.length;)(n=t[s++])&&(a=jN(n))&&(r&&(r+=" "),r+=a);return r},jN=t=>{if(typeof t=="string")return t;let s,n="";for(let a=0;a<t.length;a++)t[a]&&(s=jN(t[a]))&&(n&&(n+=" "),n+=s);return n},XE=(t,...s)=>{let n,a,r,l;const c=f=>{const x=s.reduce((h,g)=>g(h),t());return n=_E(x),a=n.cache.get,r=n.cache.set,l=A,A(f)},A=f=>{const x=a(f);if(x)return x;const h=LE(f,n);return r(f,h),h};return l=c,(...f)=>l(HE(...f))},GE=[],js=t=>{const s=n=>n[t]||GE;return s.isThemeGetter=!0,s},QN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,NN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ZE=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,VE=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,KE=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,qE=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,WE=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,YE=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xo=t=>ZE.test(t),at=t=>!!t&&!Number.isNaN(Number(t)),mo=t=>!!t&&Number.isInteger(Number(t)),Mp=t=>t.endsWith("%")&&at(t.slice(0,-1)),Sr=t=>VE.test(t),SN=()=>!0,JE=t=>KE.test(t)&&!qE.test(t),xb=()=>!1,eP=t=>WE.test(t),tP=t=>YE.test(t),sP=t=>!Me(t)&&!Ie(t),nP=t=>Do(t,kN,xb),Me=t=>QN.test(t),mi=t=>Do(t,TN,JE),Xw=t=>Do(t,dP,at),aP=t=>Do(t,EN,SN),rP=t=>Do(t,UN,xb),Gw=t=>Do(t,CN,xb),oP=t=>Do(t,BN,tP),Mu=t=>Do(t,PN,eP),Ie=t=>NN.test(t),fA=t=>_i(t,TN),iP=t=>_i(t,UN),Zw=t=>_i(t,CN),lP=t=>_i(t,kN),cP=t=>_i(t,BN),Iu=t=>_i(t,PN,!0),AP=t=>_i(t,EN,!0),Do=(t,s,n)=>{const a=QN.exec(t);return a?a[1]?s(a[1]):n(a[2]):!1},_i=(t,s,n=!1)=>{const a=NN.exec(t);return a?a[1]?s(a[1]):n:!1},CN=t=>t==="position"||t==="percentage",BN=t=>t==="image"||t==="url",kN=t=>t==="length"||t==="size"||t==="bg-size",TN=t=>t==="length",dP=t=>t==="number",UN=t=>t==="family-name",EN=t=>t==="number"||t==="weight",PN=t=>t==="shadow",uP=()=>{const t=js("color"),s=js("font"),n=js("text"),a=js("font-weight"),r=js("tracking"),l=js("leading"),c=js("breakpoint"),A=js("container"),f=js("spacing"),x=js("radius"),h=js("shadow"),g=js("inset-shadow"),O=js("text-shadow"),b=js("drop-shadow"),v=js("blur"),y=js("perspective"),S=js("aspect"),j=js("ease"),N=js("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],U=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...U(),Ie,Me],T=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto","contain","none"],F=()=>[Ie,Me,f],M=()=>[xo,"full","auto",...F()],R=()=>[mo,"none","subgrid",Ie,Me],Y=()=>["auto",{span:["full",mo,Ie,Me]},mo,Ie,Me],W=()=>[mo,"auto",Ie,Me],ee=()=>["auto","min","max","fr",Ie,Me],K=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],_=()=>["start","end","center","stretch","center-safe","end-safe"],E=()=>["auto",...F()],q=()=>[xo,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...F()],H=()=>[xo,"screen","full","dvw","lvw","svw","min","max","fit",...F()],I=()=>[xo,"screen","full","lh","dvh","lvh","svh","min","max","fit",...F()],L=()=>[t,Ie,Me],J=()=>[...U(),Zw,Gw,{position:[Ie,Me]}],D=()=>["no-repeat",{repeat:["","x","y","space","round"]}],se=()=>["auto","cover","contain",lP,nP,{size:[Ie,Me]}],le=()=>[Mp,fA,mi],V=()=>["","none","full",x,Ie,Me],te=()=>["",at,fA,mi],ae=()=>["solid","dashed","dotted","double"],be=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],z=()=>[at,Mp,Zw,Gw],oe=()=>["","none",v,Ie,Me],ue=()=>["none",at,Ie,Me],ve=()=>["none",at,Ie,Me],Ce=()=>[at,Ie,Me],Ne=()=>[xo,"full",...F()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Sr],breakpoint:[Sr],color:[SN],container:[Sr],"drop-shadow":[Sr],ease:["in","out","in-out"],font:[sP],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Sr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Sr],shadow:[Sr],spacing:["px",at],text:[Sr],"text-shadow":[Sr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",xo,Me,Ie,S]}],container:["container"],columns:[{columns:[at,Me,Ie,A]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{"inset-s":M(),start:M()}],end:[{"inset-e":M(),end:M()}],"inset-bs":[{"inset-bs":M()}],"inset-be":[{"inset-be":M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[mo,"auto",Ie,Me]}],basis:[{basis:[xo,"full","auto",A,...F()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[at,xo,"auto","initial","none",Me]}],grow:[{grow:["",at,Ie,Me]}],shrink:[{shrink:["",at,Ie,Me]}],order:[{order:[mo,"first","last","none",Ie,Me]}],"grid-cols":[{"grid-cols":R()}],"col-start-end":[{col:Y()}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":R()}],"row-start-end":[{row:Y()}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ee()}],"auto-rows":[{"auto-rows":ee()}],gap:[{gap:F()}],"gap-x":[{"gap-x":F()}],"gap-y":[{"gap-y":F()}],"justify-content":[{justify:[...K(),"normal"]}],"justify-items":[{"justify-items":[..._(),"normal"]}],"justify-self":[{"justify-self":["auto",..._()]}],"align-content":[{content:["normal",...K()]}],"align-items":[{items:[..._(),{baseline:["","last"]}]}],"align-self":[{self:["auto",..._(),{baseline:["","last"]}]}],"place-content":[{"place-content":K()}],"place-items":[{"place-items":[..._(),"baseline"]}],"place-self":[{"place-self":["auto",..._()]}],p:[{p:F()}],px:[{px:F()}],py:[{py:F()}],ps:[{ps:F()}],pe:[{pe:F()}],pbs:[{pbs:F()}],pbe:[{pbe:F()}],pt:[{pt:F()}],pr:[{pr:F()}],pb:[{pb:F()}],pl:[{pl:F()}],m:[{m:E()}],mx:[{mx:E()}],my:[{my:E()}],ms:[{ms:E()}],me:[{me:E()}],mbs:[{mbs:E()}],mbe:[{mbe:E()}],mt:[{mt:E()}],mr:[{mr:E()}],mb:[{mb:E()}],ml:[{ml:E()}],"space-x":[{"space-x":F()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":F()}],"space-y-reverse":["space-y-reverse"],size:[{size:q()}],"inline-size":[{inline:["auto",...H()]}],"min-inline-size":[{"min-inline":["auto",...H()]}],"max-inline-size":[{"max-inline":["none",...H()]}],"block-size":[{block:["auto",...I()]}],"min-block-size":[{"min-block":["auto",...I()]}],"max-block-size":[{"max-block":["none",...I()]}],w:[{w:[A,"screen",...q()]}],"min-w":[{"min-w":[A,"screen","none",...q()]}],"max-w":[{"max-w":[A,"screen","none","prose",{screen:[c]},...q()]}],h:[{h:["screen","lh",...q()]}],"min-h":[{"min-h":["screen","lh","none",...q()]}],"max-h":[{"max-h":["screen","lh",...q()]}],"font-size":[{text:["base",n,fA,mi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,AP,aP]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Mp,Me]}],"font-family":[{font:[iP,rP,s]}],"font-features":[{"font-features":[Me]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,Ie,Me]}],"line-clamp":[{"line-clamp":[at,"none",Ie,Xw]}],leading:[{leading:[l,...F()]}],"list-image":[{"list-image":["none",Ie,Me]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ie,Me]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:L()}],"text-color":[{text:L()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ae(),"wavy"]}],"text-decoration-thickness":[{decoration:[at,"from-font","auto",Ie,mi]}],"text-decoration-color":[{decoration:L()}],"underline-offset":[{"underline-offset":[at,"auto",Ie,Me]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ie,Me]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ie,Me]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:J()}],"bg-repeat":[{bg:D()}],"bg-size":[{bg:se()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},mo,Ie,Me],radial:["",Ie,Me],conic:[mo,Ie,Me]},cP,oP]}],"bg-color":[{bg:L()}],"gradient-from-pos":[{from:le()}],"gradient-via-pos":[{via:le()}],"gradient-to-pos":[{to:le()}],"gradient-from":[{from:L()}],"gradient-via":[{via:L()}],"gradient-to":[{to:L()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:te()}],"border-w-x":[{"border-x":te()}],"border-w-y":[{"border-y":te()}],"border-w-s":[{"border-s":te()}],"border-w-e":[{"border-e":te()}],"border-w-bs":[{"border-bs":te()}],"border-w-be":[{"border-be":te()}],"border-w-t":[{"border-t":te()}],"border-w-r":[{"border-r":te()}],"border-w-b":[{"border-b":te()}],"border-w-l":[{"border-l":te()}],"divide-x":[{"divide-x":te()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":te()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ae(),"hidden","none"]}],"divide-style":[{divide:[...ae(),"hidden","none"]}],"border-color":[{border:L()}],"border-color-x":[{"border-x":L()}],"border-color-y":[{"border-y":L()}],"border-color-s":[{"border-s":L()}],"border-color-e":[{"border-e":L()}],"border-color-bs":[{"border-bs":L()}],"border-color-be":[{"border-be":L()}],"border-color-t":[{"border-t":L()}],"border-color-r":[{"border-r":L()}],"border-color-b":[{"border-b":L()}],"border-color-l":[{"border-l":L()}],"divide-color":[{divide:L()}],"outline-style":[{outline:[...ae(),"none","hidden"]}],"outline-offset":[{"outline-offset":[at,Ie,Me]}],"outline-w":[{outline:["",at,fA,mi]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",h,Iu,Mu]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",g,Iu,Mu]}],"inset-shadow-color":[{"inset-shadow":L()}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:L()}],"ring-offset-w":[{"ring-offset":[at,mi]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":te()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",O,Iu,Mu]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[at,Ie,Me]}],"mix-blend":[{"mix-blend":[...be(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":be()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[at]}],"mask-image-linear-from-pos":[{"mask-linear-from":z()}],"mask-image-linear-to-pos":[{"mask-linear-to":z()}],"mask-image-linear-from-color":[{"mask-linear-from":L()}],"mask-image-linear-to-color":[{"mask-linear-to":L()}],"mask-image-t-from-pos":[{"mask-t-from":z()}],"mask-image-t-to-pos":[{"mask-t-to":z()}],"mask-image-t-from-color":[{"mask-t-from":L()}],"mask-image-t-to-color":[{"mask-t-to":L()}],"mask-image-r-from-pos":[{"mask-r-from":z()}],"mask-image-r-to-pos":[{"mask-r-to":z()}],"mask-image-r-from-color":[{"mask-r-from":L()}],"mask-image-r-to-color":[{"mask-r-to":L()}],"mask-image-b-from-pos":[{"mask-b-from":z()}],"mask-image-b-to-pos":[{"mask-b-to":z()}],"mask-image-b-from-color":[{"mask-b-from":L()}],"mask-image-b-to-color":[{"mask-b-to":L()}],"mask-image-l-from-pos":[{"mask-l-from":z()}],"mask-image-l-to-pos":[{"mask-l-to":z()}],"mask-image-l-from-color":[{"mask-l-from":L()}],"mask-image-l-to-color":[{"mask-l-to":L()}],"mask-image-x-from-pos":[{"mask-x-from":z()}],"mask-image-x-to-pos":[{"mask-x-to":z()}],"mask-image-x-from-color":[{"mask-x-from":L()}],"mask-image-x-to-color":[{"mask-x-to":L()}],"mask-image-y-from-pos":[{"mask-y-from":z()}],"mask-image-y-to-pos":[{"mask-y-to":z()}],"mask-image-y-from-color":[{"mask-y-from":L()}],"mask-image-y-to-color":[{"mask-y-to":L()}],"mask-image-radial":[{"mask-radial":[Ie,Me]}],"mask-image-radial-from-pos":[{"mask-radial-from":z()}],"mask-image-radial-to-pos":[{"mask-radial-to":z()}],"mask-image-radial-from-color":[{"mask-radial-from":L()}],"mask-image-radial-to-color":[{"mask-radial-to":L()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":U()}],"mask-image-conic-pos":[{"mask-conic":[at]}],"mask-image-conic-from-pos":[{"mask-conic-from":z()}],"mask-image-conic-to-pos":[{"mask-conic-to":z()}],"mask-image-conic-from-color":[{"mask-conic-from":L()}],"mask-image-conic-to-color":[{"mask-conic-to":L()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:J()}],"mask-repeat":[{mask:D()}],"mask-size":[{mask:se()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ie,Me]}],filter:[{filter:["","none",Ie,Me]}],blur:[{blur:oe()}],brightness:[{brightness:[at,Ie,Me]}],contrast:[{contrast:[at,Ie,Me]}],"drop-shadow":[{"drop-shadow":["","none",b,Iu,Mu]}],"drop-shadow-color":[{"drop-shadow":L()}],grayscale:[{grayscale:["",at,Ie,Me]}],"hue-rotate":[{"hue-rotate":[at,Ie,Me]}],invert:[{invert:["",at,Ie,Me]}],saturate:[{saturate:[at,Ie,Me]}],sepia:[{sepia:["",at,Ie,Me]}],"backdrop-filter":[{"backdrop-filter":["","none",Ie,Me]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[at,Ie,Me]}],"backdrop-contrast":[{"backdrop-contrast":[at,Ie,Me]}],"backdrop-grayscale":[{"backdrop-grayscale":["",at,Ie,Me]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[at,Ie,Me]}],"backdrop-invert":[{"backdrop-invert":["",at,Ie,Me]}],"backdrop-opacity":[{"backdrop-opacity":[at,Ie,Me]}],"backdrop-saturate":[{"backdrop-saturate":[at,Ie,Me]}],"backdrop-sepia":[{"backdrop-sepia":["",at,Ie,Me]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":F()}],"border-spacing-x":[{"border-spacing-x":F()}],"border-spacing-y":[{"border-spacing-y":F()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ie,Me]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[at,"initial",Ie,Me]}],ease:[{ease:["linear","initial",j,Ie,Me]}],delay:[{delay:[at,Ie,Me]}],animate:[{animate:["none",N,Ie,Me]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[y,Ie,Me]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:ue()}],"rotate-x":[{"rotate-x":ue()}],"rotate-y":[{"rotate-y":ue()}],"rotate-z":[{"rotate-z":ue()}],scale:[{scale:ve()}],"scale-x":[{"scale-x":ve()}],"scale-y":[{"scale-y":ve()}],"scale-z":[{"scale-z":ve()}],"scale-3d":["scale-3d"],skew:[{skew:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[Ie,Me,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ne()}],"translate-x":[{"translate-x":Ne()}],"translate-y":[{"translate-y":Ne()}],"translate-z":[{"translate-z":Ne()}],"translate-none":["translate-none"],accent:[{accent:L()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:L()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ie,Me]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mbs":[{"scroll-mbs":F()}],"scroll-mbe":[{"scroll-mbe":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pbs":[{"scroll-pbs":F()}],"scroll-pbe":[{"scroll-pbe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ie,Me]}],fill:[{fill:["none",...L()]}],"stroke-w":[{stroke:[at,fA,mi,Xw]}],stroke:[{stroke:["none",...L()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},fP=XE(uP);function Z(...t){return fP(jE(t))}function Ue(t,s,{checkForDefaultPrevented:n=!0}={}){return function(r){if(t==null||t(r),n===!1||!r.defaultPrevented)return s==null?void 0:s(r)}}function Vw(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function mb(...t){return s=>{let n=!1;const a=t.map(r=>{const l=Vw(r,s);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let r=0;r<a.length;r++){const l=a[r];typeof l=="function"?l():Vw(t[r],null)}}}}function mt(...t){return p.useCallback(mb(...t),t)}function xP(t,s){const n=p.createContext(s),a=l=>{const{children:c,...A}=l,f=p.useMemo(()=>A,Object.values(A));return e.jsx(n.Provider,{value:f,children:c})};a.displayName=t+"Provider";function r(l){const c=p.useContext(n);if(c)return c;if(s!==void 0)return s;throw new Error(`\`${l}\` must be used within \`${t}\``)}return[a,r]}function Ya(t,s=[]){let n=[];function a(l,c){const A=p.createContext(c),f=n.length;n=[...n,c];const x=g=>{var j;const{scope:O,children:b,...v}=g,y=((j=O==null?void 0:O[t])==null?void 0:j[f])||A,S=p.useMemo(()=>v,Object.values(v));return e.jsx(y.Provider,{value:S,children:b})};x.displayName=l+"Provider";function h(g,O){var y;const b=((y=O==null?void 0:O[t])==null?void 0:y[f])||A,v=p.useContext(b);if(v)return v;if(c!==void 0)return c;throw new Error(`\`${g}\` must be used within \`${l}\``)}return[x,h]}const r=()=>{const l=n.map(c=>p.createContext(c));return function(A){const f=(A==null?void 0:A[t])||l;return p.useMemo(()=>({[`__scope${t}`]:{...A,[t]:f}}),[A,f])}};return r.scopeName=t,[a,mP(r,...s)]}function mP(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const a=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(l){const c=a.reduce((A,{useScope:f,scopeName:x})=>{const g=f(l)[`__scope${x}`];return{...A,...g}},{});return p.useMemo(()=>({[`__scope${s.scopeName}`]:c}),[c])}};return n.scopeName=s.scopeName,n}function ec(t){const s=hP(t),n=p.forwardRef((a,r)=>{const{children:l,...c}=a,A=p.Children.toArray(l),f=A.find(gP);if(f){const x=f.props.children,h=A.map(g=>g===f?p.Children.count(x)>1?p.Children.only(null):p.isValidElement(x)?x.props.children:null:g);return e.jsx(s,{...c,ref:r,children:p.isValidElement(x)?p.cloneElement(x,void 0,h):null})}return e.jsx(s,{...c,ref:r,children:l})});return n.displayName=`${t}.Slot`,n}function hP(t){const s=p.forwardRef((n,a)=>{const{children:r,...l}=n;if(p.isValidElement(r)){const c=bP(r),A=OP(l,r.props);return r.type!==p.Fragment&&(A.ref=a?mb(a,c):c),p.cloneElement(r,A)}return p.Children.count(r)>1?p.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var FN=Symbol("radix.slottable");function pP(t){const s=({children:n})=>e.jsx(e.Fragment,{children:n});return s.displayName=`${t}.Slottable`,s.__radixId=FN,s}function gP(t){return p.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===FN}function OP(t,s){const n={...s};for(const a in s){const r=t[a],l=s[a];/^on[A-Z]/.test(a)?r&&l?n[a]=(...A)=>{const f=l(...A);return r(...A),f}:r&&(n[a]=r):a==="style"?n[a]={...r,...l}:a==="className"&&(n[a]=[r,l].filter(Boolean).join(" "))}return{...t,...n}}function bP(t){var a,r;let s=(a=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(r=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var vP=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],et=vP.reduce((t,s)=>{const n=ec(`Primitive.${s}`),a=p.forwardRef((r,l)=>{const{asChild:c,...A}=r,f=c?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(f,{...A,ref:l})});return a.displayName=`Primitive.${s}`,{...t,[s]:a}},{});function $N(t,s){t&&Px.flushSync(()=>t.dispatchEvent(s))}function Us(t){const s=p.useRef(t);return p.useEffect(()=>{s.current=t}),p.useMemo(()=>(...n)=>{var a;return(a=s.current)==null?void 0:a.call(s,...n)},[])}function yP(t,s=globalThis==null?void 0:globalThis.document){const n=Us(t);p.useEffect(()=>{const a=r=>{r.key==="Escape"&&n(r)};return s.addEventListener("keydown",a,{capture:!0}),()=>s.removeEventListener("keydown",a,{capture:!0})},[n,s])}var wP="DismissableLayer",aO="dismissableLayer.update",jP="dismissableLayer.pointerDownOutside",QP="dismissableLayer.focusOutside",Kw,RN=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ad=p.forwardRef((t,s)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:a,onPointerDownOutside:r,onFocusOutside:l,onInteractOutside:c,onDismiss:A,...f}=t,x=p.useContext(RN),[h,g]=p.useState(null),O=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=p.useState({}),v=mt(s,B=>g(B)),y=Array.from(x.layers),[S]=[...x.layersWithOutsidePointerEventsDisabled].slice(-1),j=y.indexOf(S),N=h?y.indexOf(h):-1,C=x.layersWithOutsidePointerEventsDisabled.size>0,U=N>=j,P=CP(B=>{const F=B.target,M=[...x.branches].some(R=>R.contains(F));!U||M||(r==null||r(B),c==null||c(B),B.defaultPrevented||A==null||A())},O),T=BP(B=>{const F=B.target;[...x.branches].some(R=>R.contains(F))||(l==null||l(B),c==null||c(B),B.defaultPrevented||A==null||A())},O);return yP(B=>{N===x.layers.size-1&&(a==null||a(B),!B.defaultPrevented&&A&&(B.preventDefault(),A()))},O),p.useEffect(()=>{if(h)return n&&(x.layersWithOutsidePointerEventsDisabled.size===0&&(Kw=O.body.style.pointerEvents,O.body.style.pointerEvents="none"),x.layersWithOutsidePointerEventsDisabled.add(h)),x.layers.add(h),qw(),()=>{n&&x.layersWithOutsidePointerEventsDisabled.size===1&&(O.body.style.pointerEvents=Kw)}},[h,O,n,x]),p.useEffect(()=>()=>{h&&(x.layers.delete(h),x.layersWithOutsidePointerEventsDisabled.delete(h),qw())},[h,x]),p.useEffect(()=>{const B=()=>b({});return document.addEventListener(aO,B),()=>document.removeEventListener(aO,B)},[]),e.jsx(et.div,{...f,ref:v,style:{pointerEvents:C?U?"auto":"none":void 0,...t.style},onFocusCapture:Ue(t.onFocusCapture,T.onFocusCapture),onBlurCapture:Ue(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Ue(t.onPointerDownCapture,P.onPointerDownCapture)})});Ad.displayName=wP;var NP="DismissableLayerBranch",SP=p.forwardRef((t,s)=>{const n=p.useContext(RN),a=p.useRef(null),r=mt(s,a);return p.useEffect(()=>{const l=a.current;if(l)return n.branches.add(l),()=>{n.branches.delete(l)}},[n.branches]),e.jsx(et.div,{...t,ref:r})});SP.displayName=NP;function CP(t,s=globalThis==null?void 0:globalThis.document){const n=Us(t),a=p.useRef(!1),r=p.useRef(()=>{});return p.useEffect(()=>{const l=A=>{if(A.target&&!a.current){let f=function(){MN(jP,n,x,{discrete:!0})};const x={originalEvent:A};A.pointerType==="touch"?(s.removeEventListener("click",r.current),r.current=f,s.addEventListener("click",r.current,{once:!0})):f()}else s.removeEventListener("click",r.current);a.current=!1},c=window.setTimeout(()=>{s.addEventListener("pointerdown",l)},0);return()=>{window.clearTimeout(c),s.removeEventListener("pointerdown",l),s.removeEventListener("click",r.current)}},[s,n]),{onPointerDownCapture:()=>a.current=!0}}function BP(t,s=globalThis==null?void 0:globalThis.document){const n=Us(t),a=p.useRef(!1);return p.useEffect(()=>{const r=l=>{l.target&&!a.current&&MN(QP,n,{originalEvent:l},{discrete:!1})};return s.addEventListener("focusin",r),()=>s.removeEventListener("focusin",r)},[s,n]),{onFocusCapture:()=>a.current=!0,onBlurCapture:()=>a.current=!1}}function qw(){const t=new CustomEvent(aO);document.dispatchEvent(t)}function MN(t,s,n,{discrete:a}){const r=n.originalEvent.target,l=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});s&&r.addEventListener(t,s,{once:!0}),a?$N(r,l):r.dispatchEvent(l)}var Ds=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},kP=oN[" useId ".trim().toString()]||(()=>{}),TP=0;function $r(t){const[s,n]=p.useState(kP());return Ds(()=>{n(a=>a??String(TP++))},[t]),s?`radix-${s}`:""}const UP=["top","right","bottom","left"],Fo=Math.min,$n=Math.max,tx=Math.round,zu=Math.floor,Xa=t=>({x:t,y:t}),EP={left:"right",right:"left",bottom:"top",top:"bottom"};function rO(t,s,n){return $n(t,Fo(s,n))}function Ir(t,s){return typeof t=="function"?t(s):t}function zr(t){return t.split("-")[0]}function xc(t){return t.split("-")[1]}function hb(t){return t==="x"?"y":"x"}function pb(t){return t==="y"?"height":"width"}function La(t){const s=t[0];return s==="t"||s==="b"?"y":"x"}function gb(t){return hb(La(t))}function PP(t,s,n){n===void 0&&(n=!1);const a=xc(t),r=gb(t),l=pb(r);let c=r==="x"?a===(n?"end":"start")?"right":"left":a==="start"?"bottom":"top";return s.reference[l]>s.floating[l]&&(c=sx(c)),[c,sx(c)]}function FP(t){const s=sx(t);return[oO(t),s,oO(s)]}function oO(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const Ww=["left","right"],Yw=["right","left"],$P=["top","bottom"],RP=["bottom","top"];function MP(t,s,n){switch(t){case"top":case"bottom":return n?s?Yw:Ww:s?Ww:Yw;case"left":case"right":return s?$P:RP;default:return[]}}function IP(t,s,n,a){const r=xc(t);let l=MP(zr(t),n==="start",a);return r&&(l=l.map(c=>c+"-"+r),s&&(l=l.concat(l.map(oO)))),l}function sx(t){const s=zr(t);return EP[s]+t.slice(s.length)}function zP(t){return{top:0,right:0,bottom:0,left:0,...t}}function IN(t){return typeof t!="number"?zP(t):{top:t,right:t,bottom:t,left:t}}function nx(t){const{x:s,y:n,width:a,height:r}=t;return{width:a,height:r,top:n,left:s,right:s+a,bottom:n+r,x:s,y:n}}function Jw(t,s,n){let{reference:a,floating:r}=t;const l=La(s),c=gb(s),A=pb(c),f=zr(s),x=l==="y",h=a.x+a.width/2-r.width/2,g=a.y+a.height/2-r.height/2,O=a[A]/2-r[A]/2;let b;switch(f){case"top":b={x:h,y:a.y-r.height};break;case"bottom":b={x:h,y:a.y+a.height};break;case"right":b={x:a.x+a.width,y:g};break;case"left":b={x:a.x-r.width,y:g};break;default:b={x:a.x,y:a.y}}switch(xc(s)){case"start":b[c]-=O*(n&&x?-1:1);break;case"end":b[c]+=O*(n&&x?-1:1);break}return b}async function _P(t,s){var n;s===void 0&&(s={});const{x:a,y:r,platform:l,rects:c,elements:A,strategy:f}=t,{boundary:x="clippingAncestors",rootBoundary:h="viewport",elementContext:g="floating",altBoundary:O=!1,padding:b=0}=Ir(s,t),v=IN(b),S=A[O?g==="floating"?"reference":"floating":g],j=nx(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(S)))==null||n?S:S.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(A.floating)),boundary:x,rootBoundary:h,strategy:f})),N=g==="floating"?{x:a,y:r,width:c.floating.width,height:c.floating.height}:c.reference,C=await(l.getOffsetParent==null?void 0:l.getOffsetParent(A.floating)),U=await(l.isElement==null?void 0:l.isElement(C))?await(l.getScale==null?void 0:l.getScale(C))||{x:1,y:1}:{x:1,y:1},P=nx(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:A,rect:N,offsetParent:C,strategy:f}):N);return{top:(j.top-P.top+v.top)/U.y,bottom:(P.bottom-j.bottom+v.bottom)/U.y,left:(j.left-P.left+v.left)/U.x,right:(P.right-j.right+v.right)/U.x}}const DP=50,LP=async(t,s,n)=>{const{placement:a="bottom",strategy:r="absolute",middleware:l=[],platform:c}=n,A=c.detectOverflow?c:{...c,detectOverflow:_P},f=await(c.isRTL==null?void 0:c.isRTL(s));let x=await c.getElementRects({reference:t,floating:s,strategy:r}),{x:h,y:g}=Jw(x,a,f),O=a,b=0;const v={};for(let y=0;y<l.length;y++){const S=l[y];if(!S)continue;const{name:j,fn:N}=S,{x:C,y:U,data:P,reset:T}=await N({x:h,y:g,initialPlacement:a,placement:O,strategy:r,middlewareData:v,rects:x,platform:A,elements:{reference:t,floating:s}});h=C??h,g=U??g,v[j]={...v[j],...P},T&&b<DP&&(b++,typeof T=="object"&&(T.placement&&(O=T.placement),T.rects&&(x=T.rects===!0?await c.getElementRects({reference:t,floating:s,strategy:r}):T.rects),{x:h,y:g}=Jw(x,O,f)),y=-1)}return{x:h,y:g,placement:O,strategy:r,middlewareData:v}},HP=t=>({name:"arrow",options:t,async fn(s){const{x:n,y:a,placement:r,rects:l,platform:c,elements:A,middlewareData:f}=s,{element:x,padding:h=0}=Ir(t,s)||{};if(x==null)return{};const g=IN(h),O={x:n,y:a},b=gb(r),v=pb(b),y=await c.getDimensions(x),S=b==="y",j=S?"top":"left",N=S?"bottom":"right",C=S?"clientHeight":"clientWidth",U=l.reference[v]+l.reference[b]-O[b]-l.floating[v],P=O[b]-l.reference[b],T=await(c.getOffsetParent==null?void 0:c.getOffsetParent(x));let B=T?T[C]:0;(!B||!await(c.isElement==null?void 0:c.isElement(T)))&&(B=A.floating[C]||l.floating[v]);const F=U/2-P/2,M=B/2-y[v]/2-1,R=Fo(g[j],M),Y=Fo(g[N],M),W=R,ee=B-y[v]-Y,K=B/2-y[v]/2+F,_=rO(W,K,ee),E=!f.arrow&&xc(r)!=null&&K!==_&&l.reference[v]/2-(K<W?R:Y)-y[v]/2<0,q=E?K<W?K-W:K-ee:0;return{[b]:O[b]+q,data:{[b]:_,centerOffset:K-_-q,...E&&{alignmentOffset:q}},reset:E}}}),XP=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(s){var n,a;const{placement:r,middlewareData:l,rects:c,initialPlacement:A,platform:f,elements:x}=s,{mainAxis:h=!0,crossAxis:g=!0,fallbackPlacements:O,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:y=!0,...S}=Ir(t,s);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const j=zr(r),N=La(A),C=zr(A)===A,U=await(f.isRTL==null?void 0:f.isRTL(x.floating)),P=O||(C||!y?[sx(A)]:FP(A)),T=v!=="none";!O&&T&&P.push(...IP(A,y,v,U));const B=[A,...P],F=await f.detectOverflow(s,S),M=[];let R=((a=l.flip)==null?void 0:a.overflows)||[];if(h&&M.push(F[j]),g){const K=PP(r,c,U);M.push(F[K[0]],F[K[1]])}if(R=[...R,{placement:r,overflows:M}],!M.every(K=>K<=0)){var Y,W;const K=(((Y=l.flip)==null?void 0:Y.index)||0)+1,_=B[K];if(_&&(!(g==="alignment"?N!==La(_):!1)||R.every(H=>La(H.placement)===N?H.overflows[0]>0:!0)))return{data:{index:K,overflows:R},reset:{placement:_}};let E=(W=R.filter(q=>q.overflows[0]<=0).sort((q,H)=>q.overflows[1]-H.overflows[1])[0])==null?void 0:W.placement;if(!E)switch(b){case"bestFit":{var ee;const q=(ee=R.filter(H=>{if(T){const I=La(H.placement);return I===N||I==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(I=>I>0).reduce((I,L)=>I+L,0)]).sort((H,I)=>H[1]-I[1])[0])==null?void 0:ee[0];q&&(E=q);break}case"initialPlacement":E=A;break}if(r!==E)return{reset:{placement:E}}}return{}}}};function ej(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function tj(t){return UP.some(s=>t[s]>=0)}const GP=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:n,platform:a}=s,{strategy:r="referenceHidden",...l}=Ir(t,s);switch(r){case"referenceHidden":{const c=await a.detectOverflow(s,{...l,elementContext:"reference"}),A=ej(c,n.reference);return{data:{referenceHiddenOffsets:A,referenceHidden:tj(A)}}}case"escaped":{const c=await a.detectOverflow(s,{...l,altBoundary:!0}),A=ej(c,n.floating);return{data:{escapedOffsets:A,escaped:tj(A)}}}default:return{}}}}},zN=new Set(["left","top"]);async function ZP(t,s){const{placement:n,platform:a,elements:r}=t,l=await(a.isRTL==null?void 0:a.isRTL(r.floating)),c=zr(n),A=xc(n),f=La(n)==="y",x=zN.has(c)?-1:1,h=l&&f?-1:1,g=Ir(s,t);let{mainAxis:O,crossAxis:b,alignmentAxis:v}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return A&&typeof v=="number"&&(b=A==="end"?v*-1:v),f?{x:b*h,y:O*x}:{x:O*x,y:b*h}}const VP=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var n,a;const{x:r,y:l,placement:c,middlewareData:A}=s,f=await ZP(s,t);return c===((n=A.offset)==null?void 0:n.placement)&&(a=A.arrow)!=null&&a.alignmentOffset?{}:{x:r+f.x,y:l+f.y,data:{...f,placement:c}}}}},KP=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:n,y:a,placement:r,platform:l}=s,{mainAxis:c=!0,crossAxis:A=!1,limiter:f={fn:j=>{let{x:N,y:C}=j;return{x:N,y:C}}},...x}=Ir(t,s),h={x:n,y:a},g=await l.detectOverflow(s,x),O=La(zr(r)),b=hb(O);let v=h[b],y=h[O];if(c){const j=b==="y"?"top":"left",N=b==="y"?"bottom":"right",C=v+g[j],U=v-g[N];v=rO(C,v,U)}if(A){const j=O==="y"?"top":"left",N=O==="y"?"bottom":"right",C=y+g[j],U=y-g[N];y=rO(C,y,U)}const S=f.fn({...s,[b]:v,[O]:y});return{...S,data:{x:S.x-n,y:S.y-a,enabled:{[b]:c,[O]:A}}}}}},qP=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:n,y:a,placement:r,rects:l,middlewareData:c}=s,{offset:A=0,mainAxis:f=!0,crossAxis:x=!0}=Ir(t,s),h={x:n,y:a},g=La(r),O=hb(g);let b=h[O],v=h[g];const y=Ir(A,s),S=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(f){const C=O==="y"?"height":"width",U=l.reference[O]-l.floating[C]+S.mainAxis,P=l.reference[O]+l.reference[C]-S.mainAxis;b<U?b=U:b>P&&(b=P)}if(x){var j,N;const C=O==="y"?"width":"height",U=zN.has(zr(r)),P=l.reference[g]-l.floating[C]+(U&&((j=c.offset)==null?void 0:j[g])||0)+(U?0:S.crossAxis),T=l.reference[g]+l.reference[C]+(U?0:((N=c.offset)==null?void 0:N[g])||0)-(U?S.crossAxis:0);v<P?v=P:v>T&&(v=T)}return{[O]:b,[g]:v}}}},WP=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var n,a;const{placement:r,rects:l,platform:c,elements:A}=s,{apply:f=()=>{},...x}=Ir(t,s),h=await c.detectOverflow(s,x),g=zr(r),O=xc(r),b=La(r)==="y",{width:v,height:y}=l.floating;let S,j;g==="top"||g==="bottom"?(S=g,j=O===(await(c.isRTL==null?void 0:c.isRTL(A.floating))?"start":"end")?"left":"right"):(j=g,S=O==="end"?"top":"bottom");const N=y-h.top-h.bottom,C=v-h.left-h.right,U=Fo(y-h[S],N),P=Fo(v-h[j],C),T=!s.middlewareData.shift;let B=U,F=P;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&(F=C),(a=s.middlewareData.shift)!=null&&a.enabled.y&&(B=N),T&&!O){const R=$n(h.left,0),Y=$n(h.right,0),W=$n(h.top,0),ee=$n(h.bottom,0);b?F=v-2*(R!==0||Y!==0?R+Y:$n(h.left,h.right)):B=y-2*(W!==0||ee!==0?W+ee:$n(h.top,h.bottom))}await f({...s,availableWidth:F,availableHeight:B});const M=await c.getDimensions(A.floating);return v!==M.width||y!==M.height?{reset:{rects:!0}}:{}}}};function Rx(){return typeof window<"u"}function mc(t){return _N(t)?(t.nodeName||"").toLowerCase():"#document"}function zn(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function Ja(t){var s;return(s=(_N(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function _N(t){return Rx()?t instanceof Node||t instanceof zn(t).Node:!1}function Sa(t){return Rx()?t instanceof Element||t instanceof zn(t).Element:!1}function Lr(t){return Rx()?t instanceof HTMLElement||t instanceof zn(t).HTMLElement:!1}function sj(t){return!Rx()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof zn(t).ShadowRoot}function dd(t){const{overflow:s,overflowX:n,overflowY:a,display:r}=Ca(t);return/auto|scroll|overlay|hidden|clip/.test(s+a+n)&&r!=="inline"&&r!=="contents"}function YP(t){return/^(table|td|th)$/.test(mc(t))}function Mx(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const JP=/transform|translate|scale|rotate|perspective|filter/,eF=/paint|layout|strict|content/,hi=t=>!!t&&t!=="none";let Ip;function Ob(t){const s=Sa(t)?Ca(t):t;return hi(s.transform)||hi(s.translate)||hi(s.scale)||hi(s.rotate)||hi(s.perspective)||!bb()&&(hi(s.backdropFilter)||hi(s.filter))||JP.test(s.willChange||"")||eF.test(s.contain||"")}function tF(t){let s=$o(t);for(;Lr(s)&&!tc(s);){if(Ob(s))return s;if(Mx(s))return null;s=$o(s)}return null}function bb(){return Ip==null&&(Ip=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ip}function tc(t){return/^(html|body|#document)$/.test(mc(t))}function Ca(t){return zn(t).getComputedStyle(t)}function Ix(t){return Sa(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function $o(t){if(mc(t)==="html")return t;const s=t.assignedSlot||t.parentNode||sj(t)&&t.host||Ja(t);return sj(s)?s.host:s}function DN(t){const s=$o(t);return tc(s)?t.ownerDocument?t.ownerDocument.body:t.body:Lr(s)&&dd(s)?s:DN(s)}function ZA(t,s,n){var a;s===void 0&&(s=[]),n===void 0&&(n=!0);const r=DN(t),l=r===((a=t.ownerDocument)==null?void 0:a.body),c=zn(r);if(l){const A=iO(c);return s.concat(c,c.visualViewport||[],dd(r)?r:[],A&&n?ZA(A):[])}else return s.concat(r,ZA(r,[],n))}function iO(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function LN(t){const s=Ca(t);let n=parseFloat(s.width)||0,a=parseFloat(s.height)||0;const r=Lr(t),l=r?t.offsetWidth:n,c=r?t.offsetHeight:a,A=tx(n)!==l||tx(a)!==c;return A&&(n=l,a=c),{width:n,height:a,$:A}}function vb(t){return Sa(t)?t:t.contextElement}function Zl(t){const s=vb(t);if(!Lr(s))return Xa(1);const n=s.getBoundingClientRect(),{width:a,height:r,$:l}=LN(s);let c=(l?tx(n.width):n.width)/a,A=(l?tx(n.height):n.height)/r;return(!c||!Number.isFinite(c))&&(c=1),(!A||!Number.isFinite(A))&&(A=1),{x:c,y:A}}const sF=Xa(0);function HN(t){const s=zn(t);return!bb()||!s.visualViewport?sF:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function nF(t,s,n){return s===void 0&&(s=!1),!n||s&&n!==zn(t)?!1:s}function Ci(t,s,n,a){s===void 0&&(s=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),l=vb(t);let c=Xa(1);s&&(a?Sa(a)&&(c=Zl(a)):c=Zl(t));const A=nF(l,n,a)?HN(l):Xa(0);let f=(r.left+A.x)/c.x,x=(r.top+A.y)/c.y,h=r.width/c.x,g=r.height/c.y;if(l){const O=zn(l),b=a&&Sa(a)?zn(a):a;let v=O,y=iO(v);for(;y&&a&&b!==v;){const S=Zl(y),j=y.getBoundingClientRect(),N=Ca(y),C=j.left+(y.clientLeft+parseFloat(N.paddingLeft))*S.x,U=j.top+(y.clientTop+parseFloat(N.paddingTop))*S.y;f*=S.x,x*=S.y,h*=S.x,g*=S.y,f+=C,x+=U,v=zn(y),y=iO(v)}}return nx({width:h,height:g,x:f,y:x})}function zx(t,s){const n=Ix(t).scrollLeft;return s?s.left+n:Ci(Ja(t)).left+n}function XN(t,s){const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-zx(t,n),r=n.top+s.scrollTop;return{x:a,y:r}}function aF(t){let{elements:s,rect:n,offsetParent:a,strategy:r}=t;const l=r==="fixed",c=Ja(a),A=s?Mx(s.floating):!1;if(a===c||A&&l)return n;let f={scrollLeft:0,scrollTop:0},x=Xa(1);const h=Xa(0),g=Lr(a);if((g||!g&&!l)&&((mc(a)!=="body"||dd(c))&&(f=Ix(a)),g)){const b=Ci(a);x=Zl(a),h.x=b.x+a.clientLeft,h.y=b.y+a.clientTop}const O=c&&!g&&!l?XN(c,f):Xa(0);return{width:n.width*x.x,height:n.height*x.y,x:n.x*x.x-f.scrollLeft*x.x+h.x+O.x,y:n.y*x.y-f.scrollTop*x.y+h.y+O.y}}function rF(t){return Array.from(t.getClientRects())}function oF(t){const s=Ja(t),n=Ix(t),a=t.ownerDocument.body,r=$n(s.scrollWidth,s.clientWidth,a.scrollWidth,a.clientWidth),l=$n(s.scrollHeight,s.clientHeight,a.scrollHeight,a.clientHeight);let c=-n.scrollLeft+zx(t);const A=-n.scrollTop;return Ca(a).direction==="rtl"&&(c+=$n(s.clientWidth,a.clientWidth)-r),{width:r,height:l,x:c,y:A}}const nj=25;function iF(t,s){const n=zn(t),a=Ja(t),r=n.visualViewport;let l=a.clientWidth,c=a.clientHeight,A=0,f=0;if(r){l=r.width,c=r.height;const h=bb();(!h||h&&s==="fixed")&&(A=r.offsetLeft,f=r.offsetTop)}const x=zx(a);if(x<=0){const h=a.ownerDocument,g=h.body,O=getComputedStyle(g),b=h.compatMode==="CSS1Compat"&&parseFloat(O.marginLeft)+parseFloat(O.marginRight)||0,v=Math.abs(a.clientWidth-g.clientWidth-b);v<=nj&&(l-=v)}else x<=nj&&(l+=x);return{width:l,height:c,x:A,y:f}}function lF(t,s){const n=Ci(t,!0,s==="fixed"),a=n.top+t.clientTop,r=n.left+t.clientLeft,l=Lr(t)?Zl(t):Xa(1),c=t.clientWidth*l.x,A=t.clientHeight*l.y,f=r*l.x,x=a*l.y;return{width:c,height:A,x:f,y:x}}function aj(t,s,n){let a;if(s==="viewport")a=iF(t,n);else if(s==="document")a=oF(Ja(t));else if(Sa(s))a=lF(s,n);else{const r=HN(t);a={x:s.x-r.x,y:s.y-r.y,width:s.width,height:s.height}}return nx(a)}function GN(t,s){const n=$o(t);return n===s||!Sa(n)||tc(n)?!1:Ca(n).position==="fixed"||GN(n,s)}function cF(t,s){const n=s.get(t);if(n)return n;let a=ZA(t,[],!1).filter(A=>Sa(A)&&mc(A)!=="body"),r=null;const l=Ca(t).position==="fixed";let c=l?$o(t):t;for(;Sa(c)&&!tc(c);){const A=Ca(c),f=Ob(c);!f&&A.position==="fixed"&&(r=null),(l?!f&&!r:!f&&A.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||dd(c)&&!f&&GN(t,c))?a=a.filter(h=>h!==c):r=A,c=$o(c)}return s.set(t,a),a}function AF(t){let{element:s,boundary:n,rootBoundary:a,strategy:r}=t;const c=[...n==="clippingAncestors"?Mx(s)?[]:cF(s,this._c):[].concat(n),a],A=aj(s,c[0],r);let f=A.top,x=A.right,h=A.bottom,g=A.left;for(let O=1;O<c.length;O++){const b=aj(s,c[O],r);f=$n(b.top,f),x=Fo(b.right,x),h=Fo(b.bottom,h),g=$n(b.left,g)}return{width:x-g,height:h-f,x:g,y:f}}function dF(t){const{width:s,height:n}=LN(t);return{width:s,height:n}}function uF(t,s,n){const a=Lr(s),r=Ja(s),l=n==="fixed",c=Ci(t,!0,l,s);let A={scrollLeft:0,scrollTop:0};const f=Xa(0);function x(){f.x=zx(r)}if(a||!a&&!l)if((mc(s)!=="body"||dd(r))&&(A=Ix(s)),a){const b=Ci(s,!0,l,s);f.x=b.x+s.clientLeft,f.y=b.y+s.clientTop}else r&&x();l&&!a&&r&&x();const h=r&&!a&&!l?XN(r,A):Xa(0),g=c.left+A.scrollLeft-f.x-h.x,O=c.top+A.scrollTop-f.y-h.y;return{x:g,y:O,width:c.width,height:c.height}}function zp(t){return Ca(t).position==="static"}function rj(t,s){if(!Lr(t)||Ca(t).position==="fixed")return null;if(s)return s(t);let n=t.offsetParent;return Ja(t)===n&&(n=n.ownerDocument.body),n}function ZN(t,s){const n=zn(t);if(Mx(t))return n;if(!Lr(t)){let r=$o(t);for(;r&&!tc(r);){if(Sa(r)&&!zp(r))return r;r=$o(r)}return n}let a=rj(t,s);for(;a&&YP(a)&&zp(a);)a=rj(a,s);return a&&tc(a)&&zp(a)&&!Ob(a)?n:a||tF(t)||n}const fF=async function(t){const s=this.getOffsetParent||ZN,n=this.getDimensions,a=await n(t.floating);return{reference:uF(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}};function xF(t){return Ca(t).direction==="rtl"}const mF={convertOffsetParentRelativeRectToViewportRelativeRect:aF,getDocumentElement:Ja,getClippingRect:AF,getOffsetParent:ZN,getElementRects:fF,getClientRects:rF,getDimensions:dF,getScale:Zl,isElement:Sa,isRTL:xF};function VN(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function hF(t,s){let n=null,a;const r=Ja(t);function l(){var A;clearTimeout(a),(A=n)==null||A.disconnect(),n=null}function c(A,f){A===void 0&&(A=!1),f===void 0&&(f=1),l();const x=t.getBoundingClientRect(),{left:h,top:g,width:O,height:b}=x;if(A||s(),!O||!b)return;const v=zu(g),y=zu(r.clientWidth-(h+O)),S=zu(r.clientHeight-(g+b)),j=zu(h),C={rootMargin:-v+"px "+-y+"px "+-S+"px "+-j+"px",threshold:$n(0,Fo(1,f))||1};let U=!0;function P(T){const B=T[0].intersectionRatio;if(B!==f){if(!U)return c();B?c(!1,B):a=setTimeout(()=>{c(!1,1e-7)},1e3)}B===1&&!VN(x,t.getBoundingClientRect())&&c(),U=!1}try{n=new IntersectionObserver(P,{...C,root:r.ownerDocument})}catch{n=new IntersectionObserver(P,C)}n.observe(t)}return c(!0),l}function pF(t,s,n,a){a===void 0&&(a={});const{ancestorScroll:r=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:A=typeof IntersectionObserver=="function",animationFrame:f=!1}=a,x=vb(t),h=r||l?[...x?ZA(x):[],...s?ZA(s):[]]:[];h.forEach(j=>{r&&j.addEventListener("scroll",n,{passive:!0}),l&&j.addEventListener("resize",n)});const g=x&&A?hF(x,n):null;let O=-1,b=null;c&&(b=new ResizeObserver(j=>{let[N]=j;N&&N.target===x&&b&&s&&(b.unobserve(s),cancelAnimationFrame(O),O=requestAnimationFrame(()=>{var C;(C=b)==null||C.observe(s)})),n()}),x&&!f&&b.observe(x),s&&b.observe(s));let v,y=f?Ci(t):null;f&&S();function S(){const j=Ci(t);y&&!VN(y,j)&&n(),y=j,v=requestAnimationFrame(S)}return n(),()=>{var j;h.forEach(N=>{r&&N.removeEventListener("scroll",n),l&&N.removeEventListener("resize",n)}),g==null||g(),(j=b)==null||j.disconnect(),b=null,f&&cancelAnimationFrame(v)}}const gF=VP,OF=KP,bF=XP,vF=WP,yF=GP,oj=HP,wF=qP,jF=(t,s,n)=>{const a=new Map,r={platform:mF,...n},l={...r.platform,_c:a};return LP(t,s,{...r,platform:l})};var QF=typeof document<"u",NF=function(){},Rf=QF?p.useLayoutEffect:NF;function ax(t,s){if(t===s)return!0;if(typeof t!=typeof s)return!1;if(typeof t=="function"&&t.toString()===s.toString())return!0;let n,a,r;if(t&&s&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==s.length)return!1;for(a=n;a--!==0;)if(!ax(t[a],s[a]))return!1;return!0}if(r=Object.keys(t),n=r.length,n!==Object.keys(s).length)return!1;for(a=n;a--!==0;)if(!{}.hasOwnProperty.call(s,r[a]))return!1;for(a=n;a--!==0;){const l=r[a];if(!(l==="_owner"&&t.$$typeof)&&!ax(t[l],s[l]))return!1}return!0}return t!==t&&s!==s}function KN(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function ij(t,s){const n=KN(t);return Math.round(s*n)/n}function _p(t){const s=p.useRef(t);return Rf(()=>{s.current=t}),s}function SF(t){t===void 0&&(t={});const{placement:s="bottom",strategy:n="absolute",middleware:a=[],platform:r,elements:{reference:l,floating:c}={},transform:A=!0,whileElementsMounted:f,open:x}=t,[h,g]=p.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[O,b]=p.useState(a);ax(O,a)||b(a);const[v,y]=p.useState(null),[S,j]=p.useState(null),N=p.useCallback(H=>{H!==T.current&&(T.current=H,y(H))},[]),C=p.useCallback(H=>{H!==B.current&&(B.current=H,j(H))},[]),U=l||v,P=c||S,T=p.useRef(null),B=p.useRef(null),F=p.useRef(h),M=f!=null,R=_p(f),Y=_p(r),W=_p(x),ee=p.useCallback(()=>{if(!T.current||!B.current)return;const H={placement:s,strategy:n,middleware:O};Y.current&&(H.platform=Y.current),jF(T.current,B.current,H).then(I=>{const L={...I,isPositioned:W.current!==!1};K.current&&!ax(F.current,L)&&(F.current=L,Px.flushSync(()=>{g(L)}))})},[O,s,n,Y,W]);Rf(()=>{x===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,g(H=>({...H,isPositioned:!1})))},[x]);const K=p.useRef(!1);Rf(()=>(K.current=!0,()=>{K.current=!1}),[]),Rf(()=>{if(U&&(T.current=U),P&&(B.current=P),U&&P){if(R.current)return R.current(U,P,ee);ee()}},[U,P,ee,R,M]);const _=p.useMemo(()=>({reference:T,floating:B,setReference:N,setFloating:C}),[N,C]),E=p.useMemo(()=>({reference:U,floating:P}),[U,P]),q=p.useMemo(()=>{const H={position:n,left:0,top:0};if(!E.floating)return H;const I=ij(E.floating,h.x),L=ij(E.floating,h.y);return A?{...H,transform:"translate("+I+"px, "+L+"px)",...KN(E.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:L}},[n,A,E.floating,h.x,h.y]);return p.useMemo(()=>({...h,update:ee,refs:_,elements:E,floatingStyles:q}),[h,ee,_,E,q])}const CF=t=>{function s(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:a,padding:r}=typeof t=="function"?t(n):t;return a&&s(a)?a.current!=null?oj({element:a.current,padding:r}).fn(n):{}:a?oj({element:a,padding:r}).fn(n):{}}}},BF=(t,s)=>{const n=gF(t);return{name:n.name,fn:n.fn,options:[t,s]}},kF=(t,s)=>{const n=OF(t);return{name:n.name,fn:n.fn,options:[t,s]}},TF=(t,s)=>({fn:wF(t).fn,options:[t,s]}),UF=(t,s)=>{const n=bF(t);return{name:n.name,fn:n.fn,options:[t,s]}},EF=(t,s)=>{const n=vF(t);return{name:n.name,fn:n.fn,options:[t,s]}},PF=(t,s)=>{const n=yF(t);return{name:n.name,fn:n.fn,options:[t,s]}},FF=(t,s)=>{const n=CF(t);return{name:n.name,fn:n.fn,options:[t,s]}};var $F="Arrow",qN=p.forwardRef((t,s)=>{const{children:n,width:a=10,height:r=5,...l}=t;return e.jsx(et.svg,{...l,ref:s,width:a,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:e.jsx("polygon",{points:"0,0 30,0 15,10"})})});qN.displayName=$F;var RF=qN;function MF(t){const[s,n]=p.useState(void 0);return Ds(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const a=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const l=r[0];let c,A;if("borderBoxSize"in l){const f=l.borderBoxSize,x=Array.isArray(f)?f[0]:f;c=x.inlineSize,A=x.blockSize}else c=t.offsetWidth,A=t.offsetHeight;n({width:c,height:A})});return a.observe(t,{box:"border-box"}),()=>a.unobserve(t)}else n(void 0)},[t]),s}var yb="Popper",[WN,hc]=Ya(yb),[IF,YN]=WN(yb),JN=t=>{const{__scopePopper:s,children:n}=t,[a,r]=p.useState(null);return e.jsx(IF,{scope:s,anchor:a,onAnchorChange:r,children:n})};JN.displayName=yb;var eS="PopperAnchor",tS=p.forwardRef((t,s)=>{const{__scopePopper:n,virtualRef:a,...r}=t,l=YN(eS,n),c=p.useRef(null),A=mt(s,c),f=p.useRef(null);return p.useEffect(()=>{const x=f.current;f.current=(a==null?void 0:a.current)||c.current,x!==f.current&&l.onAnchorChange(f.current)}),a?null:e.jsx(et.div,{...r,ref:A})});tS.displayName=eS;var wb="PopperContent",[zF,_F]=WN(wb),sS=p.forwardRef((t,s)=>{var ae,be,z,oe,ue,ve;const{__scopePopper:n,side:a="bottom",sideOffset:r=0,align:l="center",alignOffset:c=0,arrowPadding:A=0,avoidCollisions:f=!0,collisionBoundary:x=[],collisionPadding:h=0,sticky:g="partial",hideWhenDetached:O=!1,updatePositionStrategy:b="optimized",onPlaced:v,...y}=t,S=YN(wb,n),[j,N]=p.useState(null),C=mt(s,Ce=>N(Ce)),[U,P]=p.useState(null),T=MF(U),B=(T==null?void 0:T.width)??0,F=(T==null?void 0:T.height)??0,M=a+(l!=="center"?"-"+l:""),R=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},Y=Array.isArray(x)?x:[x],W=Y.length>0,ee={padding:R,boundary:Y.filter(LF),altBoundary:W},{refs:K,floatingStyles:_,placement:E,isPositioned:q,middlewareData:H}=SF({strategy:"fixed",placement:M,whileElementsMounted:(...Ce)=>pF(...Ce,{animationFrame:b==="always"}),elements:{reference:S.anchor},middleware:[BF({mainAxis:r+F,alignmentAxis:c}),f&&kF({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?TF():void 0,...ee}),f&&UF({...ee}),EF({...ee,apply:({elements:Ce,rects:Ne,availableWidth:Xe,availableHeight:Fe})=>{const{width:Ae,height:ke}=Ne.reference,Re=Ce.floating.style;Re.setProperty("--radix-popper-available-width",`${Xe}px`),Re.setProperty("--radix-popper-available-height",`${Fe}px`),Re.setProperty("--radix-popper-anchor-width",`${Ae}px`),Re.setProperty("--radix-popper-anchor-height",`${ke}px`)}}),U&&FF({element:U,padding:A}),HF({arrowWidth:B,arrowHeight:F}),O&&PF({strategy:"referenceHidden",...ee})]}),[I,L]=rS(E),J=Us(v);Ds(()=>{q&&(J==null||J())},[q,J]);const D=(ae=H.arrow)==null?void 0:ae.x,se=(be=H.arrow)==null?void 0:be.y,le=((z=H.arrow)==null?void 0:z.centerOffset)!==0,[V,te]=p.useState();return Ds(()=>{j&&te(window.getComputedStyle(j).zIndex)},[j]),e.jsx("div",{ref:K.setFloating,"data-radix-popper-content-wrapper":"",style:{..._,transform:q?_.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[(oe=H.transformOrigin)==null?void 0:oe.x,(ue=H.transformOrigin)==null?void 0:ue.y].join(" "),...((ve=H.hide)==null?void 0:ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(zF,{scope:n,placedSide:I,onArrowChange:P,arrowX:D,arrowY:se,shouldHideArrow:le,children:e.jsx(et.div,{"data-side":I,"data-align":L,...y,ref:C,style:{...y.style,animation:q?void 0:"none"}})})})});sS.displayName=wb;var nS="PopperArrow",DF={top:"bottom",right:"left",bottom:"top",left:"right"},aS=p.forwardRef(function(s,n){const{__scopePopper:a,...r}=s,l=_F(nS,a),c=DF[l.placedSide];return e.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:e.jsx(RF,{...r,ref:n,style:{...r.style,display:"block"}})})});aS.displayName=nS;function LF(t){return t!==null}var HF=t=>({name:"transformOrigin",options:t,fn(s){var S,j,N;const{placement:n,rects:a,middlewareData:r}=s,c=((S=r.arrow)==null?void 0:S.centerOffset)!==0,A=c?0:t.arrowWidth,f=c?0:t.arrowHeight,[x,h]=rS(n),g={start:"0%",center:"50%",end:"100%"}[h],O=(((j=r.arrow)==null?void 0:j.x)??0)+A/2,b=(((N=r.arrow)==null?void 0:N.y)??0)+f/2;let v="",y="";return x==="bottom"?(v=c?g:`${O}px`,y=`${-f}px`):x==="top"?(v=c?g:`${O}px`,y=`${a.floating.height+f}px`):x==="right"?(v=`${-f}px`,y=c?g:`${b}px`):x==="left"&&(v=`${a.floating.width+f}px`,y=c?g:`${b}px`),{data:{x:v,y}}}});function rS(t){const[s,n="center"]=t.split("-");return[s,n]}var jb=JN,Qb=tS,Nb=sS,Sb=aS,XF="Portal",ud=p.forwardRef((t,s)=>{var A;const{container:n,...a}=t,[r,l]=p.useState(!1);Ds(()=>l(!0),[]);const c=n||r&&((A=globalThis==null?void 0:globalThis.document)==null?void 0:A.body);return c?SU.createPortal(e.jsx(et.div,{...a,ref:s}),c):null});ud.displayName=XF;function GF(t,s){return p.useReducer((n,a)=>s[n][a]??n,t)}var ln=t=>{const{present:s,children:n}=t,a=ZF(s),r=typeof n=="function"?n({present:a.isPresent}):p.Children.only(n),l=mt(a.ref,VF(r));return typeof n=="function"||a.isPresent?p.cloneElement(r,{ref:l}):null};ln.displayName="Presence";function ZF(t){const[s,n]=p.useState(),a=p.useRef(null),r=p.useRef(t),l=p.useRef("none"),c=t?"mounted":"unmounted",[A,f]=GF(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const x=_u(a.current);l.current=A==="mounted"?x:"none"},[A]),Ds(()=>{const x=a.current,h=r.current;if(h!==t){const O=l.current,b=_u(x);t?f("MOUNT"):b==="none"||(x==null?void 0:x.display)==="none"?f("UNMOUNT"):f(h&&O!==b?"ANIMATION_OUT":"UNMOUNT"),r.current=t}},[t,f]),Ds(()=>{if(s){let x;const h=s.ownerDocument.defaultView??window,g=b=>{const y=_u(a.current).includes(CSS.escape(b.animationName));if(b.target===s&&y&&(f("ANIMATION_END"),!r.current)){const S=s.style.animationFillMode;s.style.animationFillMode="forwards",x=h.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=S)})}},O=b=>{b.target===s&&(l.current=_u(a.current))};return s.addEventListener("animationstart",O),s.addEventListener("animationcancel",g),s.addEventListener("animationend",g),()=>{h.clearTimeout(x),s.removeEventListener("animationstart",O),s.removeEventListener("animationcancel",g),s.removeEventListener("animationend",g)}}else f("ANIMATION_END")},[s,f]),{isPresent:["mounted","unmountSuspended"].includes(A),ref:p.useCallback(x=>{a.current=x?getComputedStyle(x):null,n(x)},[])}}function _u(t){return(t==null?void 0:t.animationName)||"none"}function VF(t){var a,r;let s=(a=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(r=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var KF=oN[" useInsertionEffect ".trim().toString()]||Ds;function sc({prop:t,defaultProp:s,onChange:n=()=>{},caller:a}){const[r,l,c]=qF({defaultProp:s,onChange:n}),A=t!==void 0,f=A?t:r;{const h=p.useRef(t!==void 0);p.useEffect(()=>{const g=h.current;g!==A&&console.warn(`${a} is changing from ${g?"controlled":"uncontrolled"} to ${A?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=A},[A,a])}const x=p.useCallback(h=>{var g;if(A){const O=WF(h)?h(t):h;O!==t&&((g=c.current)==null||g.call(c,O))}else l(h)},[A,t,l,c]);return[f,x]}function qF({defaultProp:t,onChange:s}){const[n,a]=p.useState(t),r=p.useRef(n),l=p.useRef(s);return KF(()=>{l.current=s},[s]),p.useEffect(()=>{var c;r.current!==n&&((c=l.current)==null||c.call(l,n),r.current=n)},[n,r]),[n,a,l]}function WF(t){return typeof t=="function"}var oS=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),YF="VisuallyHidden",iS=p.forwardRef((t,s)=>e.jsx(et.span,{...t,ref:s,style:{...oS,...t.style}}));iS.displayName=YF;var JF=iS,[_x]=Ya("Tooltip",[hc]),Dx=hc(),lS="TooltipProvider",e$=700,lO="tooltip.open",[t$,Cb]=_x(lS),cS=t=>{const{__scopeTooltip:s,delayDuration:n=e$,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:l}=t,c=p.useRef(!0),A=p.useRef(!1),f=p.useRef(0);return p.useEffect(()=>{const x=f.current;return()=>window.clearTimeout(x)},[]),e.jsx(t$,{scope:s,isOpenDelayedRef:c,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(f.current),c.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>c.current=!0,a)},[a]),isPointerInTransitRef:A,onPointerInTransitChange:p.useCallback(x=>{A.current=x},[]),disableHoverableContent:r,children:l})};cS.displayName=lS;var VA="Tooltip",[s$,fd]=_x(VA),AS=t=>{const{__scopeTooltip:s,children:n,open:a,defaultOpen:r,onOpenChange:l,disableHoverableContent:c,delayDuration:A}=t,f=Cb(VA,t.__scopeTooltip),x=Dx(s),[h,g]=p.useState(null),O=$r(),b=p.useRef(0),v=c??f.disableHoverableContent,y=A??f.delayDuration,S=p.useRef(!1),[j,N]=sc({prop:a,defaultProp:r??!1,onChange:B=>{B?(f.onOpen(),document.dispatchEvent(new CustomEvent(lO))):f.onClose(),l==null||l(B)},caller:VA}),C=p.useMemo(()=>j?S.current?"delayed-open":"instant-open":"closed",[j]),U=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,S.current=!1,N(!0)},[N]),P=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,N(!1)},[N]),T=p.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{S.current=!0,N(!0),b.current=0},y)},[y,N]);return p.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),e.jsx(jb,{...x,children:e.jsx(s$,{scope:s,contentId:O,open:j,stateAttribute:C,trigger:h,onTriggerChange:g,onTriggerEnter:p.useCallback(()=>{f.isOpenDelayedRef.current?T():U()},[f.isOpenDelayedRef,T,U]),onTriggerLeave:p.useCallback(()=>{v?P():(window.clearTimeout(b.current),b.current=0)},[P,v]),onOpen:U,onClose:P,disableHoverableContent:v,children:n})})};AS.displayName=VA;var cO="TooltipTrigger",dS=p.forwardRef((t,s)=>{const{__scopeTooltip:n,...a}=t,r=fd(cO,n),l=Cb(cO,n),c=Dx(n),A=p.useRef(null),f=mt(s,A,r.onTriggerChange),x=p.useRef(!1),h=p.useRef(!1),g=p.useCallback(()=>x.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),e.jsx(Qb,{asChild:!0,...c,children:e.jsx(et.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:f,onPointerMove:Ue(t.onPointerMove,O=>{O.pointerType!=="touch"&&!h.current&&!l.isPointerInTransitRef.current&&(r.onTriggerEnter(),h.current=!0)}),onPointerLeave:Ue(t.onPointerLeave,()=>{r.onTriggerLeave(),h.current=!1}),onPointerDown:Ue(t.onPointerDown,()=>{r.open&&r.onClose(),x.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:Ue(t.onFocus,()=>{x.current||r.onOpen()}),onBlur:Ue(t.onBlur,r.onClose),onClick:Ue(t.onClick,r.onClose)})})});dS.displayName=cO;var Bb="TooltipPortal",[n$,a$]=_x(Bb,{forceMount:void 0}),uS=t=>{const{__scopeTooltip:s,forceMount:n,children:a,container:r}=t,l=fd(Bb,s);return e.jsx(n$,{scope:s,forceMount:n,children:e.jsx(ln,{present:n||l.open,children:e.jsx(ud,{asChild:!0,container:r,children:a})})})};uS.displayName=Bb;var nc="TooltipContent",fS=p.forwardRef((t,s)=>{const n=a$(nc,t.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...l}=t,c=fd(nc,t.__scopeTooltip);return e.jsx(ln,{present:a||c.open,children:c.disableHoverableContent?e.jsx(xS,{side:r,...l,ref:s}):e.jsx(r$,{side:r,...l,ref:s})})}),r$=p.forwardRef((t,s)=>{const n=fd(nc,t.__scopeTooltip),a=Cb(nc,t.__scopeTooltip),r=p.useRef(null),l=mt(s,r),[c,A]=p.useState(null),{trigger:f,onClose:x}=n,h=r.current,{onPointerInTransitChange:g}=a,O=p.useCallback(()=>{A(null),g(!1)},[g]),b=p.useCallback((v,y)=>{const S=v.currentTarget,j={x:v.clientX,y:v.clientY},N=c$(j,S.getBoundingClientRect()),C=A$(j,N),U=d$(y.getBoundingClientRect()),P=f$([...C,...U]);A(P),g(!0)},[g]);return p.useEffect(()=>()=>O(),[O]),p.useEffect(()=>{if(f&&h){const v=S=>b(S,h),y=S=>b(S,f);return f.addEventListener("pointerleave",v),h.addEventListener("pointerleave",y),()=>{f.removeEventListener("pointerleave",v),h.removeEventListener("pointerleave",y)}}},[f,h,b,O]),p.useEffect(()=>{if(c){const v=y=>{const S=y.target,j={x:y.clientX,y:y.clientY},N=(f==null?void 0:f.contains(S))||(h==null?void 0:h.contains(S)),C=!u$(j,c);N?O():C&&(O(),x())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[f,h,c,x,O]),e.jsx(xS,{...t,ref:l})}),[o$,i$]=_x(VA,{isInside:!1}),l$=pP("TooltipContent"),xS=p.forwardRef((t,s)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:l,onPointerDownOutside:c,...A}=t,f=fd(nc,n),x=Dx(n),{onClose:h}=f;return p.useEffect(()=>(document.addEventListener(lO,h),()=>document.removeEventListener(lO,h)),[h]),p.useEffect(()=>{if(f.trigger){const g=O=>{const b=O.target;b!=null&&b.contains(f.trigger)&&h()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[f.trigger,h]),e.jsx(Ad,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:e.jsxs(Nb,{"data-state":f.stateAttribute,...x,...A,ref:s,style:{...A.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(l$,{children:a}),e.jsx(o$,{scope:n,isInside:!0,children:e.jsx(JF,{id:f.contentId,role:"tooltip",children:r||a})})]})})});fS.displayName=nc;var mS="TooltipArrow",hS=p.forwardRef((t,s)=>{const{__scopeTooltip:n,...a}=t,r=Dx(n);return i$(mS,n).isInside?null:e.jsx(Sb,{...r,...a,ref:s})});hS.displayName=mS;function c$(t,s){const n=Math.abs(s.top-t.y),a=Math.abs(s.bottom-t.y),r=Math.abs(s.right-t.x),l=Math.abs(s.left-t.x);switch(Math.min(n,a,r,l)){case l:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function A$(t,s,n=5){const a=[];switch(s){case"top":a.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":a.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":a.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":a.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return a}function d$(t){const{top:s,right:n,bottom:a,left:r}=t;return[{x:r,y:s},{x:n,y:s},{x:n,y:a},{x:r,y:a}]}function u$(t,s){const{x:n,y:a}=t;let r=!1;for(let l=0,c=s.length-1;l<s.length;c=l++){const A=s[l],f=s[c],x=A.x,h=A.y,g=f.x,O=f.y;h>a!=O>a&&n<(g-x)*(a-h)/(O-h)+x&&(r=!r)}return r}function f$(t){const s=t.slice();return s.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),x$(s)}function x$(t){if(t.length<=1)return t.slice();const s=[];for(let a=0;a<t.length;a++){const r=t[a];for(;s.length>=2;){const l=s[s.length-1],c=s[s.length-2];if((l.x-c.x)*(r.y-c.y)>=(l.y-c.y)*(r.x-c.x))s.pop();else break}s.push(r)}s.pop();const n=[];for(let a=t.length-1;a>=0;a--){const r=t[a];for(;n.length>=2;){const l=n[n.length-1],c=n[n.length-2];if((l.x-c.x)*(r.y-c.y)>=(l.y-c.y)*(r.x-c.x))n.pop();else break}n.push(r)}return n.pop(),s.length===1&&n.length===1&&s[0].x===n[0].x&&s[0].y===n[0].y?s:s.concat(n)}var m$=cS,h$=AS,p$=dS,g$=uS,O$=fS,b$=hS;function v$({children:t}){return e.jsx(m$,{delayDuration:300,children:t})}function dt({children:t,content:s,side:n="top",className:a}){return s?e.jsxs(h$,{children:[e.jsx(p$,{asChild:!0,children:t}),e.jsx(g$,{children:e.jsxs(O$,{side:n,sideOffset:6,className:Z("z-50 px-2.5 py-1.5 text-xs font-sans","bg-surface-4 text-text-0 border border-border rounded-md shadow-lg","animate-in fade-in-0 zoom-in-95",a),children:[s,e.jsx(b$,{className:"fill-surface-4"})]})})]}):t}/**
45
45
  * @license lucide-react v1.11.0 - ISC
46
46
  *
47
47
  * This source code is licensed under the ISC license.
@@ -1067,4 +1067,4 @@ Make the prompt comprehensive — include identity, philosophy, available tools,
1067
1067
  Make the roadmap have 2-4 stages with clear graduation criteria.
1068
1068
  Keep the conversation friendly and efficient. Ask one question at a time.`;function woe({msg:t}){const s=t.role==="user";return e.jsxs("div",{className:Z("flex gap-2",s?"justify-end":"justify-start"),children:[!s&&e.jsx("div",{className:"w-6 h-6 rounded-full bg-accent/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Js,{size:12,className:"text-accent"})}),e.jsx("div",{className:Z("max-w-[85%] rounded-lg px-3 py-2 text-xs font-sans",s?"bg-accent text-surface-0 rounded-br-sm":"bg-surface-2 text-text-1 rounded-bl-sm"),children:e.jsx("p",{className:"whitespace-pre-wrap",children:t.content})})]})}function joe({config:t,onDeploy:s,onEdit:n,deploying:a}){var c,A;const[r,l]=p.useState(!1);return e.jsxs("div",{className:"rounded-lg border border-accent/30 bg-accent/5 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qa,{size:16,className:"text-accent"}),e.jsx("span",{className:"text-sm font-semibold text-text-0 font-sans",children:"Ready to Deploy"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs font-sans",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-text-4 text-2xs",children:"Name"}),e.jsx("p",{className:"text-text-0",children:t.name})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-text-4 text-2xs",children:"Cadence"}),e.jsx("p",{className:"text-text-0",children:((c=voe.find(f=>f.value===t.cadence))==null?void 0:c.label)||t.cadence})]})]}),t.description&&e.jsx("p",{className:"text-xs text-text-2 font-sans",children:t.description}),((A=t.guardrails)==null?void 0:A.length)>0&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-2xs text-text-4 font-sans flex items-center gap-1",children:[e.jsx(vn,{size:10})," Guardrails"]}),e.jsx("ul",{className:"text-2xs text-text-2 font-sans mt-1 space-y-0.5",children:t.guardrails.map((f,x)=>e.jsxs("li",{children:["• ",f]},x))})]}),e.jsxs("button",{onClick:()=>l(!r),className:"text-2xs text-accent font-sans flex items-center gap-1 cursor-pointer hover:underline",children:[r?e.jsx(Hx,{size:10}):e.jsx(xt,{size:10}),r?"Hide":"Show"," full config"]}),r&&e.jsx("pre",{className:"text-2xs font-mono text-text-3 bg-surface-0 rounded p-2 overflow-x-auto max-h-48 overflow-y-auto border border-border-subtle",children:JSON.stringify(t,null,2)}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(pe,{variant:"primary",size:"sm",onClick:s,disabled:a,className:"flex-1 gap-1.5",children:a?"Deploying...":e.jsxs(e.Fragment,{children:[e.jsx(Je,{size:12})," Deploy Agent"]})}),e.jsxs(pe,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(RS,{size:12})," Edit"]})]})]})}function nN(){const t=k(C=>C.autoAgentWizardOpen),s=k(C=>C.closeAutoAgentWizard),n=k(C=>C.createAutoAgent),a=k(C=>C.setActiveView),[r,l]=p.useState([]),[c,A]=p.useState(""),[f,x]=p.useState(!1),[h,g]=p.useState(null),[O,b]=p.useState(!1),v=p.useRef(null),y=p.useRef(null);p.useEffect(()=>{t&&r.length===0&&(l([{role:"assistant",content:"Hey! I'll help you set up an autonomous agent. What task do you want it to handle? Tell me what you're trying to accomplish and I'll help configure everything."}]),g(null))},[t]),p.useEffect(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)},[r]);const S=p.useCallback(async()=>{if(!c.trim()||f)return;const C={role:"user",content:c.trim()},U=[...r,C];l(U),A(""),x(!0);try{const P=U.map(F=>({role:F.role,content:F.content})),T=await G.post("/auto-agents/setup-chat",{messages:P,systemPrompt:yoe}),B={role:"assistant",content:T.response};l(F=>[...F,B]),T.config&&g(T.config)}catch(P){l(T=>[...T,{role:"assistant",content:`Sorry, I hit an error: ${P.message}. Let me try again — could you rephrase that?`}])}finally{x(!1)}},[c,r,f]),j=p.useCallback(async()=>{if(h){b(!0);try{await n(h)&&a("auto-agents")}finally{b(!1)}}},[h]),N=()=>{s(),l([]),g(null),A("")};return e.jsx(_v,{open:t,onOpenChange:C=>{C||N()},children:e.jsx(Dv,{title:"New Auto Agent",width:520,onClose:N,children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{ref:v,className:"flex-1 overflow-y-auto px-4 py-4 space-y-3",children:[r.map((C,U)=>e.jsx(woe,{msg:C},U)),f&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-accent/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Js,{size:12,className:"text-accent animate-pulse"})}),e.jsx("div",{className:"bg-surface-2 rounded-lg px-3 py-2 rounded-bl-sm",children:e.jsx("span",{className:"text-xs text-text-3 font-sans animate-pulse",children:"Thinking..."})})]}),h&&e.jsx(joe,{config:h,onDeploy:j,onEdit:()=>g(null),deploying:O})]}),e.jsxs("div",{className:"border-t border-border-subtle px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{ref:y,type:"text",value:c,onChange:C=>A(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),S())},placeholder:h?"Ask to adjust the config...":"Describe what you want the agent to do...",className:"flex-1 bg-surface-0 border border-border-subtle rounded-md px-3 py-2 text-xs text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:border-accent",disabled:f}),e.jsx(pe,{variant:"primary",size:"icon-sm",onClick:S,disabled:!c.trim()||f,children:e.jsx(Ln,{size:14})})]}),!h&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:["ML training pipeline","Content generation","Data monitoring","Code review"].map(C=>e.jsx("button",{onClick:()=>{var U;A(C),(U=y.current)==null||U.focus()},className:"px-2 py-0.5 text-2xs font-sans text-text-3 bg-surface-2 rounded-full hover:bg-surface-3 cursor-pointer transition-colors",children:C},C))})]})]})})})}function Qoe(){const t=k(l=>l.autoAgents),s=k(l=>l.fetchAutoAgents),n=k(l=>l.openAutoAgentWizard),a=k(l=>l.selectedAutoAgentId),r=k(l=>l.selectAutoAgent);return p.useEffect(()=>{s();const l=setInterval(s,1e4);return()=>clearInterval(l)},[]),a?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(boe,{agentId:a,onBack:()=>r(null)}),e.jsx(nN,{})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle bg-surface-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-0 font-sans uppercase tracking-wide",children:"Auto Agents"}),e.jsxs(pe,{variant:"primary",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(it,{size:12})," New Auto Agent"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:t.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center space-y-3 py-20",children:[e.jsx(qa,{size:28,className:"mx-auto text-text-4"}),e.jsx("p",{className:"text-xs font-sans text-text-3",children:"No auto agents yet"}),e.jsx("p",{className:"text-2xs font-sans text-text-4 max-w-xs mx-auto",children:"Auto agents run autonomously on a schedule — iterating, learning, and making progress on complex tasks 24/7."}),e.jsxs(pe,{variant:"primary",size:"sm",onClick:n,className:"gap-1.5 mt-2",children:[e.jsx(it,{size:12})," Create Auto Agent"]})]})}):e.jsx("div",{className:"p-4 space-y-3",children:t.map(l=>e.jsx(moe,{agent:l},l.id))})}),e.jsx(nN,{})]})}const Noe={code:"Code",general:"General"},Soe={light:"text-success",medium:"text-accent",heavy:"text-warning"};function Coe(t){return t<1?`${Math.round(t*1024)} MB`:`${t} GB`}function uT({hardware:t}){if(!t)return null;const{totalRamGb:s,gpu:n,isAppleSilicon:a}=t;return e.jsxs("div",{className:"flex items-center gap-3 bg-surface-0 rounded-lg border border-border-subtle px-3 py-2.5",children:[e.jsx(md,{size:14,className:"text-text-3 flex-shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs font-sans",children:[e.jsxs("span",{className:"text-text-0 font-semibold",children:[s," GB RAM"]}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-text-4",children:"·"}),e.jsx("span",{className:"text-text-2",children:n.name})]}),a&&e.jsx(Te,{variant:"accent",className:"text-2xs",children:"Unified Memory"})]})})]})}function Boe({onRecheck:t}){const[s,n]=p.useState(null),[a,r]=p.useState(!1),[l,c]=p.useState(!1),[A,f]=p.useState(!1),x=k(U=>U.addToast);p.useEffect(()=>{G.post("/providers/ollama/check").then(n).catch(()=>{})},[]);async function h(){r(!0);try{const U=await G.post("/providers/ollama/check");n(U),U.installed&&U.serverRunning?(x("success","Ollama is ready!"),t()):U.installed?x("info","Ollama installed — server needs to start"):x("info","Ollama not found — install and try again")}catch{}r(!1)}async function g(){c(!0);try{if((await G.post("/providers/ollama/serve")).ok){x("success","Ollama server started!");let P=!1;for(let T=0;T<5;T++){await new Promise(F=>setTimeout(F,2e3));const B=await G.post("/providers/ollama/check");if(n(B),B.serverRunning){P=!0;break}}P&&t()}}catch(U){x("error","Could not start server",U.message)}c(!1)}function O(U){navigator.clipboard.writeText(U),f(!0),setTimeout(()=>f(!1),2e3)}if(!s)return e.jsx("div",{className:"py-4 text-center text-xs text-text-4 font-sans",children:"Loading..."});const{hardware:b,install:v,requirements:y,installed:S,serverRunning:j}=s,N=b.totalRamGb>=y.minRAM,C=b.recommended;return e.jsxs("div",{className:"space-y-3 p-3",children:[e.jsx(uT,{hardware:b}),N?e.jsxs("div",{className:"flex items-start gap-2 bg-success/8 border border-success/20 rounded-lg px-3 py-2.5",children:[e.jsx(Je,{size:14,className:"text-success flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs font-sans",children:[e.jsx("span",{className:"text-success font-semibold",children:"Your system is ready."}),e.jsx("span",{className:"text-text-2 ml-1",children:C.code?`Recommended: ${C.code}`:`${b.totalRamGb} GB RAM available`})]})]}):e.jsxs("div",{className:"flex items-start gap-2 bg-warning/8 border border-warning/20 rounded-lg px-3 py-2.5",children:[e.jsx(Ks,{size:14,className:"text-warning flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs font-sans text-text-2",children:[e.jsxs("span",{className:"text-warning font-semibold",children:[b.totalRamGb," GB RAM detected."]})," ","Minimum ",y.minRAM," GB needed. Smallest models may still work."]})]}),S&&!j&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2 bg-warning/8 border border-warning/20 rounded-lg px-3 py-2.5",children:[e.jsx(Ks,{size:14,className:"text-warning flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs font-sans text-text-2",children:[e.jsx("span",{className:"text-warning font-semibold",children:"Ollama installed but server not running."})," ","The server needs to be running to pull and use models."]})]}),e.jsxs(pe,{variant:"primary",size:"md",onClick:g,disabled:l,className:"w-full gap-1.5",children:[e.jsx(qt,{size:12}),l?"Starting...":"Start Ollama Server"]})]}),!S&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs font-semibold text-text-1 font-sans",children:"Install Ollama"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 bg-surface-0 border border-border-subtle rounded-md px-3 py-2 text-xs font-mono text-text-1 truncate",children:v.command}),e.jsxs(pe,{variant:"secondary",size:"sm",onClick:()=>O(v.command),className:"h-8 px-2.5 gap-1 flex-shrink-0",children:[A?e.jsx(Je,{size:12}):e.jsx(Ba,{size:12}),A?"Copied":"Copy"]})]}),v.alt&&e.jsx("p",{className:"text-2xs text-text-4 font-sans",children:v.alt})]}),e.jsxs(pe,{variant:"secondary",size:"md",onClick:h,disabled:a,className:"w-full gap-1.5",children:[e.jsx(Ls,{size:12,className:a?"animate-spin":""}),a?"Checking...":S?"Check again":"I installed it — check again"]})]})}function koe({model:t,isInstalled:s,isRecommended:n,canRun:a,onPull:r,onDelete:l,pulling:c}){const A=c===t.id;return e.jsxs("div",{className:Z("flex items-center gap-2 px-3 py-2 border-t border-border-subtle transition-colors",!a&&"opacity-40"),children:[s?e.jsx(Je,{size:12,className:"text-success flex-shrink-0"}):e.jsx("div",{className:"w-3"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-mono text-text-1 truncate",children:t.name}),n&&e.jsx(Lb,{size:10,className:"text-warning flex-shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:Z("text-2xs font-semibold font-sans",Soe[t.tier]),children:t.tier}),e.jsx("span",{className:"text-2xs text-text-4 font-sans",children:Coe(t.sizeGb)}),e.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:["· ",t.ramGb," GB RAM"]})]})]}),s?e.jsx("button",{onClick:()=>l(t.id),className:"p-1.5 text-text-4 hover:text-danger rounded transition-colors cursor-pointer",title:"Remove model",children:e.jsx(Ft,{size:12})}):a?e.jsx(pe,{variant:"secondary",size:"sm",onClick:()=>r(t.id),disabled:!!c,className:"h-7 px-2 text-2xs gap-1",children:A?e.jsxs(e.Fragment,{children:[e.jsx(Ls,{size:10,className:"animate-spin"})," Pulling..."]}):e.jsxs(e.Fragment,{children:[e.jsx(qs,{size:10})," Pull"]})}):e.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:["Needs ",t.ramGb," GB"]})]})}function Toe({onStopped:t}){const[s,n]=p.useState(null),a=k(c=>c.addToast);async function r(){n("stopping");try{(await G.post("/providers/ollama/stop")).ok?(a("info","Ollama server stopped"),t&&t()):a("error","Could not stop server")}catch(c){a("error","Stop failed",c.message)}n(null)}async function l(){n("restarting");try{(await G.post("/providers/ollama/restart")).ok?a("success","Ollama server restarted"):a("error","Restart failed")}catch(c){a("error","Restart failed",c.message)}n(null)}return e.jsxs("div",{className:"flex items-center gap-2 bg-success/8 border border-success/20 rounded-lg px-3 py-2",children:[e.jsxs("span",{className:"relative flex-shrink-0 w-[6px] h-[6px]",children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-success"}),e.jsx("span",{className:"absolute inset-[-2px] rounded-full bg-success opacity-20 animate-pulse"})]}),e.jsx("span",{className:"text-xs font-sans text-success font-semibold",children:"Server Running"}),e.jsx("span",{className:"text-2xs font-mono text-text-4",children:":11434"}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{onClick:l,disabled:!!s,className:"flex items-center gap-1 text-2xs font-sans text-text-3 hover:text-accent cursor-pointer transition-colors disabled:opacity-40",children:[e.jsx(Ls,{size:10,className:s==="restarting"?"animate-spin":""}),s==="restarting"?"Restarting...":"Restart"]}),e.jsxs("button",{onClick:r,disabled:!!s,className:"flex items-center gap-1 text-2xs font-sans text-text-3 hover:text-danger cursor-pointer transition-colors disabled:opacity-40",children:[e.jsx(Ks,{size:10}),s==="stopping"?"Stopping...":"Stop"]})]})}function Uoe({onModelChange:t}){var F,M;const[s,n]=p.useState(null),[a,r]=p.useState(null),[l,c]=p.useState("code"),[A,f]=p.useState(!1),[x,h]=p.useState(!1),g=k(R=>R.addToast),O=p.useRef(!1);function b(){G.get("/providers/ollama/models").then(R=>{var Y;n(R),!O.current&&((Y=R.installed)==null?void 0:Y.length)===0&&(O.current=!0,setTimeout(b,2e3))}).catch(()=>{})}p.useEffect(()=>{b()},[]);async function v(R){r(R);try{await G.post("/providers/ollama/pull",{model:R}),g("success",`Pulled ${R}`),b(),t&&t()}catch(Y){g("error",`Pull failed: ${Y.message}`)}r(null)}async function y(R){try{await G.delete(`/providers/ollama/models/${encodeURIComponent(R)}`),g("info",`Removed ${R}`),b(),t&&t()}catch(Y){g("error",`Delete failed: ${Y.message}`)}}if(!s)return e.jsx("div",{className:"py-4 text-center text-xs text-text-4 font-sans",children:"Loading..."});const{installed:S,catalog:j,hardware:N}=s,C=new Set(S.map(R=>R.id)),U=N.totalRamGb,P=[(F=N.recommended)==null?void 0:F.code,(M=N.recommended)==null?void 0:M.general].filter(Boolean),T=j.filter(R=>R.category===l),B=A?T:T.filter(R=>R.ramGb<=U);return x?e.jsxs("div",{className:"space-y-3 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-warning/8 border border-warning/20 rounded-lg px-3 py-2.5",children:[e.jsx(Ks,{size:14,className:"text-warning flex-shrink-0"}),e.jsxs("span",{className:"text-xs font-sans text-text-2",children:[e.jsx("span",{className:"text-warning font-semibold",children:"Ollama server stopped."})," ","Start it again to pull and use models."]})]}),e.jsxs(pe,{variant:"primary",size:"md",onClick:async()=>{try{(await G.post("/providers/ollama/serve")).ok&&(g("success","Ollama server started!"),h(!1),O.current=!1,setTimeout(b,2e3))}catch(R){g("error","Could not start server",R.message)}},className:"w-full gap-1.5",children:[e.jsx(qt,{size:12}),"Start Ollama Server"]})]}):e.jsxs("div",{className:"space-y-2 p-3",children:[e.jsx(Toe,{onStopped:()=>h(!0)}),e.jsx(uT,{hardware:N}),S.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-sans text-text-2",children:[e.jsx(xd,{size:12,className:"text-text-3"}),e.jsx("span",{className:"font-semibold",children:S.length})," model",S.length!==1?"s":""," installed"]}),e.jsx("div",{className:"flex bg-surface-0 rounded-lg p-0.5 border border-border-subtle",children:Object.entries(Noe).map(([R,Y])=>e.jsx("button",{onClick:()=>c(R),className:Z("flex-1 px-3 py-1.5 text-2xs font-semibold font-sans rounded-md transition-all cursor-pointer",l===R?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:Y},R))}),e.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-0 overflow-hidden",children:[B.map(R=>e.jsx(koe,{model:R,isInstalled:C.has(R.id),isRecommended:P.includes(R.id),canRun:R.ramGb<=U,onPull:v,onDelete:y,pulling:a},R.id)),B.length===0&&e.jsxs("div",{className:"px-3 py-4 text-center text-xs text-text-4 font-sans",children:["No ",l," models available for your hardware"]})]}),!A&&T.length>B.length&&e.jsxs("button",{onClick:()=>f(!0),className:"flex items-center gap-1 text-2xs text-text-3 hover:text-accent font-sans cursor-pointer transition-colors",children:[e.jsx(xt,{size:10}),"Show ",T.length-B.length," more (exceed your RAM)"]})]})}function Eoe({isInstalled:t,onModelChange:s}){const[n,a]=p.useState(!1),[r,l]=p.useState(!1);return p.useEffect(()=>{t?G.post("/providers/ollama/check").then(c=>{a(c.installed&&c.serverRunning),l(!0)}).catch(()=>l(!0)):l(!0)},[t]),r?n?e.jsx(Uoe,{onModelChange:s}):e.jsx(Boe,{onRecheck:()=>{a(!0),s&&s()}}):e.jsx("div",{className:"py-4 text-center text-xs text-text-4 font-sans",children:"Checking Ollama..."})}function Ef({options:t,value:s,onChange:n}){return e.jsx("div",{className:"flex bg-surface-0 rounded-lg p-0.5 border border-border-subtle",children:t.map(a=>e.jsx("button",{onClick:()=>n(a.value),className:Z("flex-1 px-3 py-1.5 text-2xs font-semibold font-sans rounded-md transition-all cursor-pointer",s===a.value?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:a.label},a.value))})}function aa({label:t,icon:s,children:n,description:a}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-semibold text-text-1 font-sans",children:[s&&e.jsx(s,{size:13,className:"text-text-3"}),t]}),a&&e.jsx("p",{className:"text-2xs text-text-4 font-sans mt-0.5",children:a})]}),n]})}function Poe({agent:t}){const s=k(v=>v.killAgent),n=k(v=>v.rotateAgent),a=k(v=>v.spawnAgent),r=k(v=>v.closeDetail),l=k(v=>v.addToast),[c,A]=p.useState(null),[f,x]=p.useState(!1),h=t.status==="running"||t.status==="starting";async function g(){A("rotate");try{await n(t.id)}catch{}A(null)}async function O(){if(!f){x(!0),setTimeout(()=>x(!1),3e3);return}A("kill");try{await s(t.id,!h),r()}catch{}A(null),x(!1)}async function b(){A("clone");try{await a({role:t.role,provider:t.provider,model:t.model,name:`${t.name}-clone`,scope:t.scope,workingDir:t.workingDir}),l("success",`Cloned ${t.name}`)}catch{}A(null)}return h?e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs(pe,{variant:"primary",size:"md",onClick:g,disabled:c==="rotate",className:"gap-1.5",children:[e.jsx(hd,{size:12,className:c==="rotate"?"animate-spin":""}),"Rotate"]}),e.jsxs(pe,{variant:"info",size:"md",onClick:b,disabled:!!c,className:"gap-1.5",children:[e.jsx(Ba,{size:12})," Clone"]}),e.jsxs(pe,{variant:"danger",size:"md",onClick:O,disabled:c==="kill",className:"gap-1.5",children:[e.jsx(Db,{size:12}),f?"Confirm":"Kill"]})]})}):e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(pe,{variant:"info",size:"md",onClick:b,disabled:!!c,className:"gap-1.5",children:[e.jsx(Ba,{size:12})," Clone"]}),e.jsxs(pe,{variant:"danger",size:"md",onClick:O,disabled:c==="kill",className:"gap-1.5",children:[e.jsx(Ft,{size:12}),f?"Confirm":"Remove"]})]})}function Foe({agent:t}){var Fe;const s=k(Ae=>Ae.addToast),n=k(Ae=>Ae.remoteHomedir),[a,r]=p.useState([]),[l,c]=p.useState(t.model||""),[A,f]=p.useState(""),[x,h]=p.useState(t.effort||"default"),[g,O]=p.useState(!1),[b,v]=p.useState(""),[y,S]=p.useState(null),[j,N]=p.useState(!1),[C,U]=p.useState(null),[P,T]=p.useState(t.routingMode||"auto"),[B,F]=p.useState([]),[M,R]=p.useState(""),[Y,W]=p.useState(!1),[ee,K]=p.useState([]),[_,E]=p.useState(!1),[q,H]=p.useState([]),[I,L]=p.useState(null),[J,D]=p.useState(t.authMode||"subscription"),[se,le]=p.useState(!1),V=t.status==="running"||t.status==="starting";p.useEffect(()=>{te(),G.get("/integrations/installed").then(ke=>H(Array.isArray(ke)?ke:[])).catch(()=>{}),G.get("/repos/imported").then(ke=>F((Array.isArray(ke)?ke:[]).filter(Re=>Re.status==="active"))).catch(()=>{}),t.provider==="claude-code"&&(G.get("/providers/claude-code/auth").then(ke=>L(ke)).catch(()=>L(null)),G.get("/credentials").then(ke=>le(Array.isArray(ke)&&ke.some(Re=>Re.provider==="claude-code"))).catch(()=>le(!1)));function Ae(){te()}return window.addEventListener("groove:providers-changed",Ae),()=>window.removeEventListener("groove:providers-changed",Ae)},[]);function te(){G.get("/providers").then(Ae=>r(Array.isArray(Ae)?Ae:[])).catch(()=>{})}p.useEffect(()=>{D(t.authMode||"subscription")},[t.id,t.authMode]),p.useEffect(()=>{c(t.model||""),G.get(`/agents/${t.id}/routing/recommend`).then(Ae=>{T((Ae==null?void 0:Ae.mode)||"fixed")}).catch(()=>{})},[t.id,t.model]),p.useEffect(()=>{W(!1),t.personality?G.get(`/personalities/${t.name}`).then(Ae=>{R((Ae==null?void 0:Ae.content)||""),W(!0)}).catch(()=>{R(""),W(!0)}):(R(""),W(!0)),G.get("/personalities").then(Ae=>{K(Array.isArray(Ae)?Ae:Ae.personalities||[])}).catch(()=>{})},[t.id,t.name]);const ae=a.find(Ae=>Ae.id===t.provider);async function be(Ae){const ke=J;D(Ae);try{await G.patch(`/agents/${t.id}`,{authMode:Ae}),s("success",`Billing → ${Ae==="usage"?"usage credits":"subscription"}`)}catch(Re){D(ke),s("error","Failed to change billing mode",Re.message)}}async function z(Ae,ke){c(ke);try{const Re={model:ke};Ae&&Ae!==t.provider&&(Re.provider=Ae),await G.patch(`/agents/${t.id}`,Re),s("success",`Model → ${ke}${Re.provider?` (${Ae})`:""}`)}catch(Re){s("error","Model swap failed",Re.message)}}async function oe(Ae){try{await G.patch(`/agents/${t.id}`,{workingDir:Ae}),s("success",`Working dir → ${Ae.split("/").pop()||Ae}`)}catch(ke){s("error","Update failed",ke.message)}}async function ue(Ae){h(Ae);try{await G.patch(`/agents/${t.id}`,{effort:Ae}),s("success",`Effort → ${Ae}`)}catch(ke){s("error","Update failed",ke.message)}}async function ve(Ae){if(!Ae.trim())return;const ke=[...t.scope||[],Ae.trim()];try{await G.patch(`/agents/${t.id}`,{scope:ke}),f("")}catch(Re){s("error","Scope update failed",Re.message)}}async function Ce(Ae){const ke=(t.scope||[]).filter((Re,Nt)=>Nt!==Ae);try{await G.patch(`/agents/${t.id}`,{scope:ke})}catch(Re){s("error","Scope update failed",Re.message)}}async function Ne(Ae){if(b.trim())try{await G.post(`/credentials/${Ae}`,{key:b.trim()}),s("success",`API key set for ${Ae}`),v(""),S(null),te(),window.dispatchEvent(new CustomEvent("groove:providers-changed"))}catch(ke){s("error","Failed to set key",ke.message)}}const Xe=t.spawnedAt||t.createdAt;return e.jsxs("div",{className:"px-5 py-5 space-y-6 overflow-y-auto h-full",children:[e.jsx(aa,{label:"Active Model",icon:ka,children:e.jsxs("div",{className:"bg-surface-0 rounded-lg border border-border-subtle px-3.5 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-bold font-mono text-text-0",children:t.model||"auto"}),e.jsx("div",{className:"text-2xs text-text-3 font-sans mt-0.5",children:(ae==null?void 0:ae.name)||t.provider})]}),(ae==null?void 0:ae.canHotSwap)&&V&&e.jsxs(Te,{variant:"accent",className:"text-2xs gap-1",children:[e.jsx(qt,{size:8})," Hot-swap"]})]}),((Fe=ae==null?void 0:ae.models)==null?void 0:Fe.length)>1&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3 pt-3 border-t border-border-subtle",children:ae.models.filter(Ae=>!Ae.disabled).map(Ae=>{const ke=Ae.id===t.model;return e.jsx("button",{onClick:()=>z(t.provider,Ae.id),disabled:!1,className:Z("px-2.5 py-1 rounded-md text-xs font-mono transition-all","cursor-pointer",ke?"bg-accent/15 text-accent font-semibold":"bg-surface-4 text-text-2 hover:bg-surface-5 hover:text-text-0"),children:Ae.name||Ae.id},Ae.id)})}),t.provider==="claude-code"&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-border-subtle",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-2xs font-medium text-text-2 font-sans",children:"Billing"}),e.jsx("div",{className:"flex gap-1 p-0.5 rounded-md bg-surface-3",children:[{id:"subscription",label:"Subscription"},{id:"usage",label:"Usage credits"}].map(Ae=>e.jsx("button",{onClick:()=>be(Ae.id),disabled:Ae.id==="usage"&&!se,className:Z("px-2 py-1 rounded text-2xs font-semibold font-sans transition-colors",Ae.id==="usage"&&!se&&"opacity-40 cursor-not-allowed",J===Ae.id?"bg-accent text-white":"text-text-2 hover:text-text-0"),children:Ae.label},Ae.id))})]}),e.jsx("p",{className:"text-2xs text-text-3 font-sans mt-1.5",children:se?"Applies on next rotation or restart — the running process keeps its current billing.":"Add an Anthropic API key in Settings → Providers to enable usage credits."})]})]})}),e.jsx(Poe,{agent:t}),e.jsxs(aa,{label:"Providers",icon:rc,description:"Click a provider to see its models and connection status.",children:[e.jsx("div",{className:"space-y-1.5",children:a.map(Ae=>{var ar;const ke=Ae.id===t.provider,Re=Ae.authType==="subscription"?Ae.installed||((ar=Ae.authStatus)==null?void 0:ar.authenticated):Ae.authType==="local"?Ae.installed:Ae.installed&&Ae.hasKey,Nt=C===Ae.id,Ss=Ae.models||[];return e.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-0 overflow-hidden",children:[e.jsxs("button",{onClick:()=>U(Nt?null:Ae.id),className:"w-full flex items-center gap-2.5 px-3 py-2 cursor-pointer hover:bg-surface-4/50 transition-colors",children:[e.jsx("div",{className:Z("w-2 h-2 rounded-full flex-shrink-0",Re?"bg-success":"bg-text-4")}),e.jsx("span",{className:Z("text-xs font-semibold font-sans flex-1 text-left",Re?"text-text-0":"text-text-3"),children:Ae.name||Ae.id}),ke&&e.jsx(Te,{variant:"accent",className:"text-2xs",children:"Active"}),!Re&&e.jsx("span",{className:"text-2xs text-text-4 font-sans",children:Ae.installed?"No key":"Not installed"}),e.jsx(xt,{size:12,className:Z("text-text-4 transition-transform",Nt&&"rotate-180")})]}),Nt&&Ae.authType==="local"&&e.jsx("div",{className:"border-t border-border-subtle",children:e.jsx(Eoe,{isInstalled:Re,onModelChange:te})}),Nt&&Ae.authType!=="local"&&e.jsxs("div",{className:"border-t border-border-subtle",children:[(!Re||Ae.hasKey)&&e.jsx("div",{className:"px-3 py-2 bg-surface-1/50",children:y===Ae.id?e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx("input",{value:b,onChange:ts=>v(ts.target.value),onKeyDown:ts=>ts.key==="Enter"&&Ne(Ae.id),type:j?"text":"password",placeholder:`${Ae.name||Ae.id} API key...`,className:"w-full h-7 px-2.5 pr-7 text-2xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),e.jsx("button",{onClick:()=>N(!j),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:j?e.jsx(To,{size:10}):e.jsx(Vs,{size:10})})]}),e.jsx(pe,{variant:"primary",size:"sm",onClick:()=>Ne(Ae.id),disabled:!b.trim(),className:"h-7 px-2 text-2xs",children:"Save"}),e.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>{S(null),v("")},className:"h-7 px-2 text-2xs",children:"Cancel"})]}):e.jsxs("button",{onClick:()=>{S(Ae.id),v(""),N(!1)},className:"flex items-center gap-1.5 text-2xs text-text-3 hover:text-accent font-sans cursor-pointer transition-colors",children:[e.jsx(Ti,{size:10}),Re?"Update API key":"Add API key to enable"]})}),Re&&Ss.filter(ts=>!ts.disabled).length>0&&Ss.filter(ts=>!ts.disabled).map(ts=>{const is=Ae.id===t.provider&&ts.id===t.model;return e.jsxs("button",{onClick:()=>z(Ae.id,ts.id),disabled:!1,className:Z("w-full flex items-center gap-2 px-3 py-2 text-left text-xs font-sans transition-colors","border-t border-border-subtle","cursor-pointer hover:bg-surface-4/50",is?"text-accent":"text-text-2"),children:[is?e.jsx(Je,{size:11,className:"text-accent flex-shrink-0"}):e.jsx("div",{className:"w-[11px]"}),e.jsx("span",{className:"font-mono flex-1 truncate",children:ts.name||ts.id}),e.jsx(Te,{variant:is?"accent":"default",className:"text-2xs",children:ts.tier})]},ts.id)})]})]},Ae.id)})}),V&&e.jsxs("div",{className:"flex items-center gap-1.5 text-2xs text-text-3 font-sans mt-1.5",children:[e.jsx(Ks,{size:10}),e.jsx("span",{children:"Model changes apply on next rotation or respawn."})]})]}),t.provider==="claude-code"&&I&&!I.authenticated&&e.jsxs("div",{className:"rounded-lg border border-warning/30 bg-warning/5 px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ks,{size:13,className:"text-warning flex-shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-text-0 font-sans",children:"Claude Code is not signed in"})]}),e.jsxs("p",{className:"text-2xs text-text-2 font-sans",children:["Open the terminal and run: ",e.jsx("code",{className:"font-mono text-accent bg-surface-4 px-1.5 py-0.5 rounded text-2xs",children:"claude"})]})]}),t.provider==="claude-code"&&(I==null?void 0:I.authenticated)&&e.jsxs("div",{className:"flex items-center gap-2 text-2xs text-text-2 font-sans",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-success flex-shrink-0"}),"Signed in as ",I.email||"Claude user"," (",I.subscriptionType||"subscription",")"]}),e.jsx(aa,{label:"Working Directory",icon:Ys,description:"The root directory this agent operates in.",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1 bg-surface-0 rounded-lg px-3 py-2.5 text-sm font-mono text-text-1 border border-border-subtle truncate min-w-0",children:t.workingDir||"Project root"}),e.jsxs(pe,{variant:"secondary",size:"md",onClick:()=>O(!0),className:"gap-1.5 flex-shrink-0",children:[e.jsx(Rb,{size:14})," Browse"]})]})}),e.jsx(aa,{label:"Permission Mode",icon:vn,description:"Full Send = no approvals. Agent Approve = Fullstack Manager reviews risky operations.",children:e.jsx(Ef,{options:[{value:"full",label:"Full Send"},{value:"auto",label:"Agent Approve"}],value:t.permission||"full",onChange:async Ae=>{try{await G.patch(`/agents/${t.id}`,{permission:Ae}),s("success",`Permission → ${Ae==="full"?"Full Send":"Agent Approve"}`)}catch(ke){s("error","Update failed",ke.message)}}})}),e.jsxs(aa,{label:"Model Routing",icon:Ro,description:"How Groove selects models for this agent's tasks.",children:[e.jsx(Ef,{options:[{value:"fixed",label:"Fixed"},{value:"auto",label:"Auto"},{value:"auto-floor",label:"Auto + Floor"}],value:P,onChange:async Ae=>{T(Ae);try{await G.post(`/agents/${t.id}/routing`,{mode:Ae}),s("success",`Routing → ${Ae}`)}catch(ke){s("error","Update failed",ke.message)}}}),e.jsxs("div",{className:"text-2xs text-text-4 font-sans mt-1",children:[P==="fixed"&&"Uses the selected model for all tasks.",P==="auto"&&"Groove picks Opus/Sonnet/Haiku based on task complexity.",P==="auto-floor"&&"Auto-routes but never drops below Sonnet."]})]}),e.jsx(aa,{label:"File Scope",icon:vn,description:"Restrict which files this agent can access. Empty = unrestricted.",children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[(t.scope||[]).map((Ae,ke)=>e.jsxs(Te,{variant:"default",className:"font-mono text-xs gap-1.5 px-2.5 py-1",children:[Ae,e.jsx("button",{onClick:()=>Ce(ke),className:"hover:text-danger cursor-pointer",children:e.jsx(qe,{size:10})})]},ke)),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{value:A,onChange:Ae=>f(Ae.target.value),onKeyDown:Ae=>Ae.key==="Enter"&&ve(A),placeholder:"e.g. src/**",className:"w-28 h-7 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{onClick:()=>ve(A),disabled:!A.trim(),className:"w-7 h-7 flex items-center justify-center rounded-md bg-surface-4 border border-border-subtle text-text-3 hover:text-accent cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:e.jsx(it,{size:12})})]})]})}),e.jsx(aa,{label:"Effort Level",icon:SS,description:"Controls how deep the agent reasons. Higher = more tokens but better results.",children:e.jsx(Ef,{options:[{value:"min",label:"Min"},{value:"low",label:"Low"},{value:"default",label:"Default"},{value:"high",label:"High"},{value:"max",label:"Max"},{value:"ultra",label:"Ultra"}],value:x,onChange:ue})}),e.jsx(aa,{label:"Agent Details",icon:rc,children:e.jsxs("div",{className:"bg-surface-0 rounded-lg border border-border-subtle divide-y divide-border-subtle",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"ID"}),e.jsx("span",{className:"text-xs text-text-1 font-mono",children:t.id})]}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Role"}),e.jsx("span",{className:"text-xs text-text-1 font-sans capitalize",children:t.role})]}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Provider"}),e.jsx("span",{className:"text-xs text-text-1 font-mono",children:t.provider})]}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Model"}),e.jsx("span",{className:"text-xs text-text-1 font-mono",children:t.model||"auto"})]}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Status"}),e.jsx("span",{className:"text-xs text-text-1 font-sans capitalize",children:t.status})]}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Spawned"}),e.jsx("span",{className:"text-xs text-text-1 font-sans",children:Xe?$t(Xe):"—"})]}),t.sessionId&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"text-xs text-text-3 font-sans",children:"Session"}),e.jsxs("span",{className:"text-xs text-text-1 font-mono",children:[t.sessionId.slice(0,16),"..."]})]})]})}),e.jsxs(aa,{label:"Integrations",icon:on,description:"Attach MCP integrations for external services.",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[(t.integrations||[]).map(Ae=>{const ke=Ni[Ae],Re=q.find(Nt=>Nt.id===Ae);return e.jsxs(Te,{variant:"accent",className:"font-mono text-xs gap-1.5 px-2.5 py-1",children:[ke?e.jsx("img",{src:ke,alt:"",className:"w-2.5 h-2.5"}):e.jsx(on,{size:9}),(Re==null?void 0:Re.name)||Ae,e.jsx("button",{onClick:async()=>{try{await G.delete(`/agents/${t.id}/integrations/${Ae}`),s("success",`Detached ${(Re==null?void 0:Re.name)||Ae}`)}catch(Nt){s("error","Detach failed",Nt.message)}},className:"hover:text-danger cursor-pointer",children:e.jsx(qe,{size:10})})]},Ae)}),q.filter(Ae=>Ae.configured!==!1&&!(t.integrations||[]).includes(Ae.id)).length>0&&e.jsxs("div",{className:"relative group",children:[e.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded-md bg-surface-4 border border-border-subtle text-text-3 hover:text-accent cursor-pointer transition-colors",children:e.jsx(it,{size:12})}),e.jsx("div",{className:"absolute top-full left-0 mt-1 z-20 hidden group-hover:block bg-surface-2 border border-border-subtle rounded-lg shadow-xl py-1 min-w-[200px]",children:q.filter(Ae=>Ae.configured!==!1&&!(t.integrations||[]).includes(Ae.id)).map(Ae=>{const ke=Ni[Ae.id];return e.jsxs("button",{onClick:async()=>{try{await G.post(`/agents/${t.id}/integrations/${Ae.id}`),s("success",`Attached ${Ae.name||Ae.id}`)}catch(Re){s("error","Attach failed",Re.message)}},className:"w-full flex items-center gap-2 text-left px-3 py-1.5 text-xs font-sans text-text-1 hover:bg-surface-4 cursor-pointer transition-colors",children:[ke?e.jsx("img",{src:ke,alt:"",className:"w-3.5 h-3.5 flex-shrink-0"}):e.jsx(on,{size:12,className:"text-text-3 flex-shrink-0"}),Ae.name||Ae.id]},Ae.id)})})]}),(t.integrations||[]).length===0&&q.length===0&&e.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"No integrations installed — browse the Marketplace"})]}),(t.integrations||[]).length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"text-2xs font-medium text-text-3 font-sans block mb-1.5",children:"Integration Approvals"}),e.jsx(Ef,{options:[{value:"auto",label:"Auto"},{value:"manual",label:"Manual"}],value:t.integrationApproval||"manual",onChange:async Ae=>{try{await G.patch(`/agents/${t.id}`,{integrationApproval:Ae}),s("success",`Integration approvals → ${Ae==="auto"?"Auto":"Manual"}`)}catch(ke){s("error","Update failed",ke.message)}}})]})]}),B.length>0&&e.jsx(aa,{label:"Repos",icon:Kl,description:"Attach imported repos so this agent knows where they are.",children:e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[(t.repos||[]).map(Ae=>{const ke=B.find(Re=>Re.id===Ae);return e.jsxs(Te,{variant:"accent",className:"font-mono text-xs gap-1.5 px-2.5 py-1",children:[(ke==null?void 0:ke.name)||Ae,e.jsx("button",{onClick:async()=>{try{await G.delete(`/agents/${t.id}/repos/${Ae}`),s("success",`Detached ${(ke==null?void 0:ke.name)||Ae}`)}catch(Re){s("error","Detach failed",Re.message)}},className:"hover:text-danger cursor-pointer",children:e.jsx(qe,{size:10})})]},Ae)}),B.filter(Ae=>!(t.repos||[]).includes(Ae.id)).length>0&&e.jsxs("div",{className:"relative group",children:[e.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded-md bg-surface-4 border border-border-subtle text-text-3 hover:text-accent cursor-pointer transition-colors",children:e.jsx(it,{size:12})}),e.jsx("div",{className:"absolute top-full left-0 mt-1 z-20 hidden group-hover:block bg-surface-2 border border-border-subtle rounded-lg shadow-xl py-1 min-w-[200px]",children:B.filter(Ae=>!(t.repos||[]).includes(Ae.id)).map(Ae=>e.jsxs("button",{onClick:async()=>{try{await G.post(`/agents/${t.id}/repos/${Ae.id}`),s("success",`Attached ${Ae.name||Ae.id}`)}catch(ke){s("error","Attach failed",ke.message)}},className:"w-full text-left px-3 py-1.5 text-xs font-sans text-text-1 hover:bg-surface-4 cursor-pointer transition-colors",children:[e.jsx("div",{className:"font-semibold",children:Ae.name||Ae.repo}),e.jsx("div",{className:"text-2xs text-text-4 font-mono truncate",children:Ae.clonedTo})]},Ae.id))})]}),(t.repos||[]).length===0&&e.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"No repos attached — import one from the Marketplace"})]})}),e.jsxs(aa,{label:"Personality",icon:Ho,description:"Injected into every prompt. Changes apply on next spawn or rotation.",children:[e.jsx("textarea",{value:M,onChange:Ae=>R(Ae.target.value),placeholder:Y?"Describe this agent's personality, tone, and behavior...":"Loading...",rows:4,className:"w-full min-h-[4rem] max-h-[10rem] resize-y bg-surface-0 border border-border-subtle rounded-md p-2 text-xs font-mono text-text-1 placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(pe,{variant:"primary",size:"sm",disabled:_,onClick:async()=>{E(!0);try{await G.put(`/personalities/${t.name}`,{content:M}),s("success","Personality saved")}catch(Ae){s("error","Save failed",Ae.message)}E(!1)},className:"h-7 px-3 text-2xs gap-1",children:[e.jsx(_r,{size:10}),_?"Saving...":"Save"]}),ee.length>0&&e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:"",onChange:Ae=>{if(!Ae.target.value)return;const ke=ee.find(Re=>(Re.name||Re)===Ae.target.value);ke&&G.get(`/personalities/${ke.name||ke}`).then(Re=>{Re!=null&&Re.content&&R(Re.content)}).catch(()=>{})},className:"h-7 px-2 pr-7 text-2xs rounded-md bg-surface-1 border border-border-subtle text-text-2 font-sans appearance-none cursor-pointer focus:outline-none focus:ring-1 focus:ring-accent",children:[e.jsx("option",{value:"",children:"Clone from..."}),ee.filter(Ae=>(Ae.name||Ae)!==t.name).map(Ae=>e.jsx("option",{value:Ae.name||Ae,children:Ae.name||Ae},Ae.name||Ae))]}),e.jsx(xt,{size:10,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-4 pointer-events-none"})]})]})]}),t.prompt&&e.jsx(aa,{label:"Original Prompt",icon:Ro,children:e.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle px-3 py-3 text-xs text-text-2 font-sans leading-relaxed max-h-40 overflow-y-auto",children:t.prompt})}),e.jsx(gc,{open:g,onOpenChange:O,currentPath:t.workingDir||n||"/",homePath:n,onSelect:oe})]})}const aN=[];function $oe({data:t,isAlive:s,height:n=48}){const a=p.useRef(null);return p.useEffect(()=>{const r=a.current;if(!r||!t.length)return;const l=r.getContext("2d"),c=window.devicePixelRatio||1,A=r.clientWidth,f=r.clientHeight;r.width=A*c,r.height=f*c,l.scale(c,c),l.clearRect(0,0,A,f);const x=t.map(v=>v.v),h=Math.min(...x),O=Math.max(...x,1)-h||1;l.beginPath(),l.moveTo(0,f),t.forEach((v,y)=>{const S=y/(t.length-1)*A,j=f-(v.v-h)/O*(f-4)-2;l.lineTo(S,j)}),l.lineTo(A,f),l.closePath();const b=l.createLinearGradient(0,0,0,f);if(b.addColorStop(0,s?"rgba(51,175,188,0.15)":"rgba(110,118,129,0.08)"),b.addColorStop(1,"rgba(0,0,0,0)"),l.fillStyle=b,l.fill(),l.beginPath(),l.strokeStyle=s?ce.accent:ce.text3,l.lineWidth=1.5,t.forEach((v,y)=>{const S=y/(t.length-1)*A,j=f-(v.v-h)/O*(f-4)-2;y===0?l.moveTo(S,j):l.lineTo(S,j)}),l.stroke(),t.length>1&&s){const v=t[t.length-1],y=A-1,S=f-(v.v-h)/O*(f-4)-2;l.beginPath(),l.arc(y,S,5,0,Math.PI*2),l.fillStyle="rgba(51,175,188,0.3)",l.fill(),l.beginPath(),l.arc(y,S,2.5,0,Math.PI*2),l.fillStyle=ce.accent,l.fill()}},[t,s]),e.jsx("div",{className:"w-full rounded-lg bg-surface-0 overflow-hidden border border-border-subtle",style:{height:n},children:e.jsx("canvas",{ref:a,className:"w-full h-full"})})}function Pf({icon:t,label:s,value:n,color:a,sub:r}){return e.jsxs("div",{className:"bg-surface-0 rounded-lg px-3 py-2.5 border border-border-subtle",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(t,{size:12,className:a||"text-text-3"}),e.jsx("span",{className:"text-2xs text-text-4 font-sans uppercase tracking-wider",children:s})]}),e.jsx("div",{className:Z("text-lg font-bold font-mono tabular-nums",a||"text-text-0"),children:n}),r&&e.jsx("div",{className:"text-2xs text-text-4 font-sans mt-0.5",children:r})]})}function Roe({score:t}){const s=Math.min(Math.max(t,0),100);let n=ce.success,a="Healthy";return s<40?(n=ce.danger,a="Degraded"):s<70&&(n=ce.warning,a="Fair"),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("span",{className:"text-2xs text-text-3 font-sans flex items-center gap-1.5",children:[e.jsx(fM,{size:11}),"Session Health"]}),e.jsxs("span",{className:"text-xs font-bold font-mono",style:{color:n},children:[s,"/100"]})]}),e.jsx("div",{className:"h-2 bg-surface-0 rounded-full overflow-hidden border border-border-subtle",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${s}%`,background:n}})}),e.jsx("span",{className:"text-2xs font-sans mt-1 block",style:{color:n},children:a})]})}function Moe(t){const s=(t||"").toLowerCase();return s.includes("edit")||s.includes("writ")?{icon:KA,color:"text-warning"}:s.includes("read")||s.includes("view")?{icon:Vs,color:"text-info"}:s.includes("search")||s.includes("grep")||s.includes("glob")?{icon:As,color:"text-purple"}:s.includes("bash")||s.includes("command")||s.includes("terminal")?{icon:Wa,color:"text-orange"}:s.includes("error")||s.includes("fail")?{icon:Ks,color:"text-danger"}:s.includes("spawn")||s.includes("start")?{icon:qt,color:"text-success"}:s.includes("complet")||s.includes("done")?{icon:rx,color:"text-success"}:{icon:Dn,color:"text-text-4"}}function Ioe({agent:t}){const s=k(c=>c.tokenTimeline[t.id])||aN,n=k(c=>c.activityLog[t.id])||aN,a=t.status==="running"||t.status==="starting",r=p.useMemo(()=>{if(s.length<2)return 0;const c=s.slice(-10),A=(c[c.length-1].t-c[0].t)/6e4,f=c[c.length-1].v-c[0].v;return A>0?Math.round(f/A):0},[s]),l=p.useMemo(()=>{const c=t.contextUsage||0;let A=100;return c>90?A-=50:c>70?A-=25:c>50&&(A-=10),r>5e3?A-=15:r>3e3&&(A-=8),t.status==="crashed"&&(A=10),t.status==="completed"&&(A=95),Math.max(0,Math.min(100,A))},[t.contextUsage,t.status,r]);return e.jsxs("div",{className:"px-5 py-5 space-y-5 overflow-y-auto h-full",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Token Burn"}),a&&e.jsx("span",{className:"text-2xs text-accent font-mono animate-pulse",children:"LIVE"})]}),e.jsx($oe,{data:s,isAlive:a,height:56})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Pf,{icon:ZR,label:"Burn Rate",value:r>0?`${jt(r)}/m`:"—",color:r>5e3?"text-danger":r>2e3?"text-warning":"text-text-0"}),e.jsx(Pf,{icon:jS,label:"Cost",value:er(t.costUsd||0),color:"text-text-0"}),e.jsx(Pf,{icon:hd,label:"Rotations",value:t.rotations||"0",color:"text-text-0"}),e.jsx(Pf,{icon:qt,label:"Turns",value:t.turns||"0",color:"text-text-0"})]}),e.jsx(Roe,{score:l}),t.prompt&&e.jsxs("div",{children:[e.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider block mb-1.5",children:"Task"}),e.jsx("div",{className:"bg-surface-0 rounded-lg px-3 py-2.5 text-xs text-text-2 font-sans leading-relaxed max-h-28 overflow-y-auto border border-border-subtle",children:t.prompt})]}),n.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider block mb-2",children:"Activity"}),e.jsxs("div",{className:"space-y-0 relative",children:[e.jsx("div",{className:"absolute left-[9px] top-2 bottom-2 w-px bg-border-subtle"}),n.slice(-12).reverse().map((c,A)=>{const f=Moe(c.text),x=f.icon;return e.jsxs("div",{className:"flex items-start gap-3 py-1.5 relative",children:[e.jsx("div",{className:Z("w-[18px] h-[18px] rounded-full flex items-center justify-center flex-shrink-0 z-10","bg-surface-1 border border-border-subtle"),children:e.jsx(x,{size:9,className:f.color})}),e.jsx("span",{className:"text-2xs text-text-2 font-sans flex-1 line-clamp-1 pt-0.5",children:c.text}),e.jsx("span",{className:"text-2xs text-text-4 font-mono flex-shrink-0 pt-0.5",children:$t(c.timestamp)})]},A)})]})]})]})}function zoe({agent:t}){const s=k(B=>B.addToast),[n,a]=p.useState([]),[r,l]=p.useState(""),[c,A]=p.useState(null),[f,x]=p.useState(""),[h,g]=p.useState(""),[O,b]=p.useState(!1),[v,y]=p.useState(!1),[S,j]=p.useState("");async function N(){try{const B=await G.get(`/agents/${t.id}/mdfiles`);a(B.files||[]),l(B.workingDir||"")}catch{}}p.useEffect(()=>{N()},[t.id]);async function C(B){try{const F=await G.get(`/agents/${t.id}/mdfiles/read?path=${encodeURIComponent(B)}`);x(F.content||""),g(F.content||""),A(B)}catch(F){s("error","Failed to read file",F.message)}}async function U(){if(c){b(!0);try{await G.put(`/agents/${t.id}/mdfiles/write`,{path:c,content:f}),g(f),s("success",`Saved ${c}`)}catch(B){s("error","Save failed",B.message)}b(!1)}}async function P(){const B=S.trim();if(B)try{await G.post(`/agents/${t.id}/mdfiles/create`,{name:B}),j(""),y(!1),s("success",`Created ${B}.md`),N()}catch(F){s("error","Create failed",F.message)}}const T=f!==h;return c?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border-subtle",children:[e.jsx("button",{onClick:()=>{A(null),x(""),g("")},className:"p-1 text-text-3 hover:text-text-0 cursor-pointer",children:e.jsx(Di,{size:14})}),e.jsx(On,{size:12,className:"text-accent"}),e.jsx("span",{className:"text-xs text-text-0 font-sans font-medium flex-1 truncate",children:c}),T&&e.jsx("span",{className:"text-[10px] text-warning font-sans",children:"unsaved"}),e.jsxs("button",{onClick:U,disabled:!T||O,className:Z("flex items-center gap-1 px-2.5 py-1 rounded text-2xs font-sans font-medium cursor-pointer transition-colors",T?"bg-accent/15 text-accent hover:bg-accent/25":"text-text-4 opacity-50 cursor-not-allowed"),children:[e.jsx(_r,{size:10}),O?"Saving...":"Save"]})]}),e.jsx("textarea",{value:f,onChange:B=>x(B.target.value),className:"flex-1 w-full px-4 py-3 bg-surface-0 text-[12px] font-mono text-text-1 leading-relaxed resize-none focus:outline-none",spellCheck:!1})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border-subtle",children:[e.jsx(On,{size:12,className:"text-text-3"}),e.jsx("span",{className:"text-2xs font-semibold text-text-2 font-sans uppercase tracking-wider flex-1",children:"Markdown Files"}),e.jsx("button",{onClick:()=>y(!0),className:"p-1 text-text-4 hover:text-accent cursor-pointer",title:"Create file",children:e.jsx(it,{size:12})}),e.jsx("button",{onClick:N,className:"p-1 text-text-4 hover:text-text-1 cursor-pointer",children:e.jsx(Ls,{size:11})})]}),r&&e.jsx("div",{className:"px-4 py-1.5 text-[10px] text-text-4 font-mono truncate border-b border-border-subtle/50",children:r}),v&&e.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-2 border-b border-border-subtle bg-surface-0",children:[e.jsx(On,{size:11,className:"text-accent flex-shrink-0"}),e.jsx("input",{autoFocus:!0,value:S,onChange:B=>j(B.target.value),onKeyDown:B=>{B.key==="Enter"&&P(),B.key==="Escape"&&(y(!1),j(""))},placeholder:"filename",className:"flex-1 bg-transparent text-xs text-text-0 font-mono outline-none placeholder:text-text-4"}),e.jsx("span",{className:"text-[10px] text-text-4 font-mono",children:".md"}),e.jsx("button",{onClick:P,className:"p-0.5 text-accent hover:text-accent/80 cursor-pointer",children:e.jsx(_r,{size:11})}),e.jsx("button",{onClick:()=>{y(!1),j("")},className:"p-0.5 text-text-4 hover:text-text-1 cursor-pointer",children:e.jsx(qe,{size:11})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:n.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-4",children:[e.jsx(On,{size:20,className:"text-text-4 mb-2"}),e.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No markdown files found"}),e.jsx("p",{className:"text-[10px] text-text-4 font-sans mt-1",children:"MD files in the agent's working directory will appear here"})]}):e.jsx("div",{className:"py-1",children:n.map(B=>e.jsxs("button",{onClick:()=>C(B.path),className:"w-full flex items-center gap-2.5 px-4 py-2 text-left hover:bg-surface-5 transition-colors cursor-pointer",children:[e.jsx(On,{size:13,className:"text-accent flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-xs text-text-0 font-sans block truncate",children:B.name}),e.jsx("span",{className:"text-[10px] text-text-4 font-mono",children:B.path})]}),e.jsx("span",{className:"text-[10px] text-text-4 font-mono flex-shrink-0",children:B.size>1024?`${(B.size/1024).toFixed(1)}K`:`${B.size}B`}),B.source==="personality"&&e.jsx("span",{className:"text-[9px] font-mono text-purple bg-purple/10 px-1 py-px rounded flex-shrink-0",children:"personality"}),B.source==="user"&&e.jsx("span",{className:"text-[9px] font-mono text-accent bg-accent/10 px-1 py-px rounded flex-shrink-0",children:"custom"})]},B.path))})})]})}const _oe={running:"bg-accent",starting:"bg-warning",completed:"bg-info",crashed:"bg-danger",stopped:"bg-text-4",killed:"bg-text-4",rotating:"bg-accent"},Doe={running:"success",starting:"warning",stopped:"default",crashed:"danger",completed:"accent",killed:"default",rotating:"purple"},Loe={running:"Running",starting:"Starting",stopped:"Stopped",crashed:"Crashed",completed:"Done",killed:"Killed",rotating:"Rotating"},Hoe=[{id:"command",label:"Chat",icon:fa},{id:"config",label:"Config",icon:oc},{id:"telemetry",label:"Monitor",icon:Ro},{id:"mdfiles",label:"Files",icon:On}];function Xoe({agent:t}){const s=k(j=>j.addToast),n=k(j=>j.agents),a=k(j=>j.teams),r=k(j=>j.switchAgentPanel),[l,c]=p.useState(!1),[A,f]=p.useState(t.name),[x,h]=p.useState(!1),[g,O]=p.useState(""),b=p.useRef(null);p.useEffect(()=>{if(!x)return;const j=C=>{b.current&&!b.current.contains(C.target)&&h(!1)},N=C=>{C.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",j),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",N)}},[x]);const v=p.useMemo(()=>{const j=g.trim().toLowerCase(),N=new Map;for(const C of n){if(j&&!C.name.toLowerCase().includes(j)&&!C.role.toLowerCase().includes(j))continue;const U=C.teamId||"_none";N.has(U)||N.set(U,[]),N.get(U).push(C)}return Array.from(N.entries()).map(([C,U])=>{var P;return{teamId:C,name:((P=a.find(T=>T.id===C))==null?void 0:P.name)||"No team",agents:U.sort((T,B)=>T.name.localeCompare(B.name))}}).sort((C,U)=>C.name.localeCompare(U.name))},[n,a,g]);async function y(){const j=A.trim();if(!j||j===t.name){c(!1);return}try{await G.patch(`/agents/${t.id}`,{name:j.replace(/\s+/g,"-")}),s("success",`Renamed → ${j}`)}catch(N){s("error","Rename failed",N.message),f(t.name)}c(!1)}function S(j){h(!1),O(""),j!==t.id&&r(j)}return l?e.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[e.jsx("input",{value:A,onChange:j=>f(j.target.value),onKeyDown:j=>{j.key==="Enter"&&y(),j.key==="Escape"&&(f(t.name),c(!1))},className:"flex-1 min-w-0 h-6 px-1.5 text-sm font-bold bg-surface-0 border border-accent/30 rounded text-text-0 font-sans focus:outline-none focus:ring-1 focus:ring-accent/40",autoFocus:!0}),e.jsx("button",{onClick:y,className:"p-0.5 text-accent hover:text-accent/80 cursor-pointer",children:e.jsx(Je,{size:12})}),e.jsx("button",{onClick:()=>{f(t.name),c(!1)},className:"p-0.5 text-text-4 hover:text-text-1 cursor-pointer",children:e.jsx(qe,{size:12})})]}):e.jsxs("div",{ref:b,className:"relative flex items-center gap-1.5 flex-1 min-w-0 group",children:[e.jsxs("button",{onClick:()=>h(j=>!j),className:"flex items-center gap-1 min-w-0 cursor-pointer rounded px-1 -mx-1 py-0.5 hover:bg-surface-3 transition-colors",title:"Switch agent",children:[e.jsx("h2",{className:"text-sm font-bold text-text-0 font-sans truncate",children:t.name}),e.jsx(xt,{size:13,className:Z("text-text-4 flex-shrink-0 transition-transform",x&&"rotate-180")})]}),e.jsx("button",{onClick:()=>{f(t.name),c(!0)},className:"p-0.5 text-text-4 opacity-0 group-hover:opacity-100 hover:text-text-1 cursor-pointer transition-opacity flex-shrink-0",title:"Rename agent",children:e.jsx(Ua,{size:10})}),x&&e.jsxs("div",{className:"absolute top-full left-0 mt-1.5 w-72 max-h-[70vh] flex flex-col bg-surface-1 border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-2 border-b border-border-subtle",children:[e.jsx(As,{size:12,className:"text-text-4 flex-shrink-0"}),e.jsx("input",{value:g,onChange:j=>O(j.target.value),placeholder:"Switch to agent…",autoFocus:!0,className:"flex-1 min-w-0 bg-transparent text-xs text-text-0 font-sans placeholder:text-text-4 focus:outline-none"})]}),e.jsxs("div",{className:"overflow-y-auto py-1",children:[v.length===0&&e.jsx("div",{className:"px-3 py-3 text-xs text-text-4 font-sans text-center",children:"No agents match"}),v.map(j=>e.jsxs("div",{children:[e.jsx("div",{className:"px-2.5 pt-1.5 pb-0.5 text-2xs font-semibold text-text-4 font-sans uppercase tracking-wide",children:j.name}),j.agents.map(N=>e.jsxs("button",{onClick:()=>S(N.id),className:Z("w-full flex items-center gap-2 px-2.5 py-1.5 text-left cursor-pointer transition-colors",N.id===t.id?"bg-accent/10":"hover:bg-surface-3"),children:[e.jsx("span",{className:Z("w-1.5 h-1.5 rounded-full flex-shrink-0",_oe[N.status]||"bg-text-4")}),e.jsx("span",{className:Z("text-xs font-sans truncate",N.id===t.id?"text-accent font-medium":"text-text-1"),children:N.name}),e.jsx("span",{className:"text-2xs text-text-4 font-sans ml-auto flex-shrink-0 capitalize",children:N.role})]},N.id))]},j.teamId))]})]})]})}function Goe(){const t=k(v=>v.detailPanel),s=k(v=>v.agents),n=k(v=>v.activeTeamId),a=k(v=>v.activeView);k(v=>v.addToast);const[r,l]=p.useState("command"),c=p.useRef(null),A=(t==null?void 0:t.type)==="agent"?t.agentId:null,f=A?s.find(v=>v.id===A):null;f?c.current=f:c.current&&A&&c.current.id!==A&&(c.current=null);const x=f||c.current,h=(f==null?void 0:f.status)==="running"||(f==null?void 0:f.status)==="starting";if(!x||a!=="fleet"&&n&&x.teamId&&x.teamId!==n)return null;const g=Math.round((x.contextUsage||0)*100),O=x.spawnedAt||x.createdAt,b=O?Math.floor((Date.now()-new Date(O).getTime())/1e3):0;return Ha(x.role),e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"pl-4 pr-10 pt-3 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xoe,{agent:x}),e.jsx(Te,{variant:Doe[x.status]||"default",dot:h?"pulse":void 0,className:"text-2xs flex-shrink-0",children:Loe[x.status]||x.status})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-2xs text-text-3 font-mono",children:[e.jsx("span",{className:"capitalize",children:x.role}),e.jsx("span",{className:"text-text-4",children:"·"}),e.jsxs("span",{children:[x.provider,":",x.model||"auto"]}),e.jsx("span",{className:"text-text-4",children:"·"}),e.jsxs("span",{children:[jt(x.tokensUsed||0)," tok"]}),g>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-text-4",children:"·"}),e.jsxs("span",{className:Z(g>80?"text-danger":g>60?"text-warning":"text-text-3"),children:[g,"% ctx"]})]}),e.jsx("span",{className:"text-text-4",children:"·"}),e.jsx("span",{children:Xo(b)})]})]}),e.jsx("div",{className:"flex items-center px-4 border-b border-border-subtle",children:Hoe.map(v=>{const y=v.icon,S=r===v.id;return e.jsxs("button",{onClick:()=>l(v.id),className:Z("flex items-center gap-1.5 px-3 py-2 text-2xs font-semibold font-sans transition-all cursor-pointer select-none border-b-2 -mb-px",S?"border-accent text-text-0":"border-transparent text-text-3 hover:text-text-1"),children:[e.jsx(y,{size:11}),v.label]},v.id)})})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[r==="command"&&e.jsx(dT,{agent:x}),r==="config"&&e.jsx(Foe,{agent:x}),r==="telemetry"&&e.jsx(Ioe,{agent:x}),r==="mdfiles"&&e.jsx(zoe,{agent:x})]})]})}const Zoe=[{id:"chat",label:"Chat",desc:"Companion, assistant, conversation",icon:Ho,tier:"Medium"},{id:"planner",label:"Planner",desc:"Plans the team and tasks",icon:Ei,tier:"Heavy"},{id:"backend",label:"Backend",desc:"APIs, services, databases",icon:Ns,tier:"Medium"},{id:"frontend",label:"Frontend",desc:"UI, components, styling",icon:md,tier:"Medium"},{id:"fullstack",label:"Fullstack",desc:"End-to-end implementation",icon:bn,tier:"Heavy"},{id:"testing",label:"Testing",desc:"Tests, coverage, QA",icon:Wx,tier:"Medium"},{id:"devops",label:"DevOps",desc:"CI/CD, infra, deployment",icon:Eb,tier:"Medium"},{id:"docs",label:"Docs",desc:"Documentation, guides",icon:On,tier:"Light"},{id:"security",label:"Security",desc:"Audits, vulnerabilities",icon:vn,tier:"Medium"},{id:"database",label:"Database",desc:"Schema, migrations, queries",icon:Pb,tier:"Medium"},{id:"cmo",label:"CMO",desc:"Marketing, content, growth",icon:Ib,tier:"Medium"},{id:"cfo",label:"CFO",desc:"Finance, metrics, forecasting",icon:bS,tier:"Medium"},{id:"ea",label:"EA",desc:"Executive assistant, scheduling",icon:LS,tier:"Light"},{id:"support",label:"Support",desc:"Customer support, FAQs",icon:kS,tier:"Medium"},{id:"analyst",label:"Analyst",desc:"Data analysis, insights",icon:Lx,tier:"Medium"},{id:"creative",label:"Writer",desc:"Copy, articles, proposals",icon:MS,tier:"Heavy",skillHint:!0},{id:"slides",label:"Slides",desc:"Pitch decks, presentations",icon:zS,tier:"Heavy",skillHint:!0},{id:"ambassador",label:"Ambassador",desc:"Bridge to federated server",icon:ua,tier:"Light"}];function rN(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",className:"text-accent flex-shrink-0",children:[e.jsx("circle",{cx:"7",cy:"7",r:"6",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1"}),e.jsx("path",{d:"M4.5 7 L6.5 9 L9.5 5.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Voe(){var Qd;const t=k(re=>re.detailPanel),s=k(re=>re.closeDetail),n=k(re=>re.spawnAgent),a=Hn(),r=k(re=>re.fetchProviders),l=k(re=>re.teams),c=k(re=>re.activeTeamId),A=k(re=>re.createTeam),f=(t==null?void 0:t.type)==="spawn",[x,h]=p.useState(""),[g,O]=p.useState(""),[b,v]=p.useState(""),[y,S]=p.useState(""),[j,N]=p.useState(""),[C,U]=p.useState(""),[P,T]=p.useState([]),[B,F]=p.useState([]),[M,R]=p.useState([]),[Y,W]=p.useState(!1),[ee,K]=p.useState(""),[_,E]=p.useState("manual"),[q,H]=p.useState([]),[I,L]=p.useState([]),[J,D]=p.useState(!1),[se,le]=p.useState(""),[V,te]=p.useState([]),[ae,be]=p.useState(""),[z,oe]=p.useState(!1),[ue,ve]=p.useState(!1),[Ce,Ne]=p.useState(""),[Xe,Fe]=p.useState([]),[Ae,ke]=p.useState(null),[Re,Nt]=p.useState([]),[Ss,ar]=p.useState(!1),[ts,is]=p.useState(!1),[rr,Vo]=p.useState("subscription"),[Ko,or]=p.useState(!1),[Es,ir]=p.useState("new"),[ha,wn]=p.useState(""),[en,vs]=p.useState(""),Xn=k(re=>re.federation),Ot=k(re=>re.ollamaRunningModels),de=x||g,He=P.find(re=>re.id===y),Se=(He==null?void 0:He.models)||[],Ge=P.filter(re=>re.authType==="api-key"?re.installed&&re.hasKey:re.installed),ss=!!(t!=null&&t.presetProvider||t!=null&&t.presetModel),ys=(t==null?void 0:t.presetTeamId)||null,tn=!ys&&(ss||!c);p.useEffect(()=>{if(f){const re=(t==null?void 0:t.presetProvider)||"",Be=(t==null?void 0:t.presetModel)||"";r().then(Ve=>{const Ke=Array.isArray(Ve)?Ve:Ve.providers||[];T(Ke);const Fa=Ke.filter(sn=>sn.authType==="api-key"?sn.installed&&sn.hasKey:sn.installed);if(Fa.length>0&&!re){const lr=["claude-code","gemini","codex","ollama"].find(Gi=>Fa.some(An=>An.id===Gi))||Fa[0].id;S(lr)}if(re&&S(re),Be){const sn=Ke.find(An=>An.id===(re||y)),lr=(sn==null?void 0:sn.models)||[];if(lr.find(An=>An.id===Be))N(Be);else{const An=Be.split(":"),Zi=An.length>=3?An.slice(2).join(":"):An[An.length-1],Vi=lr.find(jn=>jn.id===Be||jn.id===`gguf:${Zi}`||jn.id.endsWith(`:${Zi}`)||jn.name===Zi);N((Vi==null?void 0:Vi.id)||Be)}}}).catch(()=>{}),G.get("/integrations/installed").then(Ve=>{F(Array.isArray(Ve)?Ve:[])}).catch(()=>{}),G.get("/repos/imported").then(Ve=>{H((Array.isArray(Ve)?Ve:[]).filter(Ke=>Ke.status==="active"))}).catch(()=>{}),G.get("/personalities").then(Ve=>{te(Array.isArray(Ve)?Ve:Ve.personalities||[])}).catch(()=>{}),h(""),O(""),v(""),S(re),N(Be),is(!1),Vo("subscription"),ir("new"),vs(""),wn(Be?Be.split(":").pop().replace(/[-_]/g," "):""),U(""),R([]),E("manual"),L([]),be(""),Ne(""),oe(!1),Fe([]),ke(null)}},[f,r]),p.useEffect(()=>{if(!de||!f){Fe([]);return}G.get(`/roles/integrations?role=${encodeURIComponent(de)}`).then(re=>{const Be=Array.isArray(re)?re:(re==null?void 0:re.recommendations)||[];Fe(Be);const Ve=Be.filter(Ke=>Ke.installed&&Ke.configured&&Ke.authenticated).map(Ke=>Ke.id);Ve.length>0&&R(Ke=>[...new Set([...Ke,...Ve])])}).catch(()=>Fe([]))},[de,f]),p.useEffect(()=>{f&&G.get("/credentials").then(re=>or(Array.isArray(re)&&re.some(Be=>Be.provider==="claude-code"))).catch(()=>or(!1))},[f]),p.useEffect(()=>{if(!f||y!=="ollama"){Nt([]);return}G.get("/providers/ollama/models").then(re=>{Nt(re.installed||[])}).catch(()=>Nt([])),G.post("/providers/ollama/check").then(re=>{ar(re.serverRunning)}).catch(()=>ar(!1))},[f,y]);async function qo(){ve(!0);try{let re;if(ys)re=ys;else if(!tn)re=c;else if(Es==="new"){const Ve=ha.trim()||de||"New Team";re=(await A(Ve)).id}else Es==="existing"&&en&&(re=en);const Be={role:de,...b&&{name:b.replace(/\s+/g,"-")},...y&&{provider:y},...j&&{model:j},...C&&{prompt:C},...M.length>0&&{integrations:M},...M.length>0&&{integrationApproval:_},...I.length>0&&{repos:I},...ts&&{fast:!0},...y==="claude-code"&&{authMode:rr},...ae&&{personality:ae},...de==="ambassador"&&Ce&&{peerId:Ce},...re&&{teamId:re}};await n(Be),s()}catch{}ve(!1)}async function Wo(){var re;if(de){if(y==="claude-code"&&rr==="usage"&&!Ko){a.error("Add an Anthropic API key in Settings → Providers to spawn with usage credits.");return}try{const Be=await G.post("/agents/preflight",{role:de,integrations:M});if(((re=Be==null?void 0:Be.issues)==null?void 0:re.length)>0){ke(Be.issues);return}}catch{}qo()}}return e.jsxs(_v,{open:f,onOpenChange:re=>{re||s()},children:[e.jsx(Dv,{title:"Spawn Agent",width:480,onClose:()=>s(),children:e.jsxs("div",{className:"flex flex-col h-[calc(100%-57px)]",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-text-2 font-sans uppercase tracking-wider block mb-3",children:"Choose Role"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Zoe.map(re=>{const Be=Ha(re.id),Ve=x===re.id;return e.jsxs("button",{onClick:()=>{h(re.id),O("")},className:Z("flex items-center gap-2.5 p-3 rounded-md border text-left transition-all cursor-pointer",Ve?"border-accent bg-accent/5":"border-border-subtle bg-surface-1 hover:border-border hover:bg-surface-2"),children:[e.jsx("div",{className:"w-8 h-8 rounded-md flex items-center justify-center flex-shrink-0",style:{background:Be.bg},children:e.jsx(re.icon,{size:16,style:{color:Be.text}})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-semibold text-text-0 font-sans",children:re.label}),re.skillHint&&e.jsx("span",{className:"text-2xs font-mono text-warning/70 bg-warning/8 px-1 py-px rounded",children:"skill"})]}),e.jsx("div",{className:"text-2xs text-text-3 font-sans truncate",children:re.desc})]})]},re.id)})}),e.jsx("div",{className:"mt-3",children:e.jsx(rs,{placeholder:"or type a custom role (e.g. chat-agent)...",value:g,onChange:re=>{O(re.target.value.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9_-]/g,"").slice(0,50)),h("")},className:"text-xs"})})]}),de&&Xe.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-text-2 font-sans uppercase tracking-wider block mb-2",children:"Recommended Integrations"}),e.jsx("div",{className:"space-y-1.5",children:Xe.map(re=>{const Be=Ni[re.id];return re.installed&&re.configured&&re.authenticated?e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-md bg-success/5 border border-success/20",children:[e.jsx(Je,{size:13,className:"text-success flex-shrink-0"}),Be?e.jsx("img",{src:Be,alt:"",className:"w-3.5 h-3.5 flex-shrink-0"}):e.jsx(on,{size:12,className:"text-text-3 flex-shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-text-0 font-sans",children:re.name||re.id}),e.jsx(Te,{variant:"success",className:"text-2xs ml-auto",children:"Ready"})]},re.id):re.installed?e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-md bg-warning/5 border border-warning/20",children:[e.jsx(Aa,{size:13,className:"text-warning flex-shrink-0"}),Be?e.jsx("img",{src:Be,alt:"",className:"w-3.5 h-3.5 flex-shrink-0"}):e.jsx(on,{size:12,className:"text-text-3 flex-shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-text-0 font-sans",children:re.name||re.id}),e.jsx(pe,{variant:"ghost",size:"sm",className:"ml-auto text-2xs text-warning h-6 px-2",onClick:()=>{s(),k.getState().setActiveView("marketplace")},children:"Configure"})]},re.id):e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-md bg-surface-1 border border-border-subtle",children:[Be?e.jsx("img",{src:Be,alt:"",className:"w-3.5 h-3.5 flex-shrink-0 opacity-40"}):e.jsx(on,{size:12,className:"text-text-4 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-text-3 font-sans",children:re.name||re.id}),e.jsx("button",{onClick:()=>{s(),k.getState().setActiveView("marketplace")},className:"ml-auto text-2xs text-accent hover:underline font-sans cursor-pointer",children:"Install in Marketplace"})]},re.id)})})]}),de==="ambassador"&&(()=>{const re=Xn.whitelist.filter(Be=>typeof Be=="object"&&(Be.status==="mutual"||Be.status==="connected"));return re.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border-subtle bg-surface-1/50 px-4 py-4 text-center",children:[e.jsx(ua,{size:18,className:"text-text-4 mx-auto mb-1.5"}),e.jsx("p",{className:"text-2xs text-text-3 font-sans mb-2",children:"No federated servers connected. Add one in the Federation view."}),e.jsx(pe,{variant:"ghost",size:"sm",className:"text-2xs text-accent",onClick:()=>{s(),k.getState().setActiveView("federation")},children:"Go to Federation"})]}):e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-text-2 font-sans uppercase tracking-wider block mb-2",children:"Target Server"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:Ce,onChange:Be=>Ne(Be.target.value),className:"w-full h-8 px-3 pr-8 text-sm rounded-md bg-surface-1 border border-border text-text-0 font-sans appearance-none cursor-pointer focus:outline-none focus:ring-1 focus:ring-accent",children:[e.jsx("option",{value:"",children:"Select a server..."}),re.map(Be=>e.jsx("option",{value:Be.ip,children:Be.name||`${Be.ip}:${Be.port||31415}`},Be.ip))]}),e.jsx(xt,{size:14,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-3 pointer-events-none"})]})]})})(),de&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("label",{className:"text-xs font-semibold text-text-2 font-sans uppercase tracking-wider block",children:"Configuration"}),e.jsx(rs,{label:"Name (optional)",value:b,onChange:re=>v(re.target.value),placeholder:`${de}-1`}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:"Provider"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:y,onChange:re=>{S(re.target.value),N("")},className:"w-full h-8 px-3 pr-8 text-sm rounded-md bg-surface-1 border border-border text-text-0 font-sans appearance-none cursor-pointer focus:outline-none focus:ring-1 focus:ring-accent",children:[e.jsx("option",{value:"",children:"Auto"}),P.map(re=>e.jsxs("option",{value:re.id,disabled:re.authType==="api-key"?!(re.installed&&re.hasKey):!re.installed,children:[re.name,re.installed?re.authType==="api-key"&&!re.hasKey?" (No API key)":"":" (Not installed)"]},re.id))]}),e.jsx(xt,{size:14,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-3 pointer-events-none"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:"Model"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:j,onChange:re=>N(re.target.value),disabled:!y,className:"w-full h-8 px-3 pr-8 text-sm rounded-md bg-surface-1 border border-border text-text-0 font-sans appearance-none cursor-pointer focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-40",children:[e.jsx("option",{value:"",children:"Auto"}),y==="ollama"&&Re.length>0?e.jsxs(e.Fragment,{children:[e.jsx("optgroup",{label:"Installed Models",children:Re.map(re=>{const Be=Ot.some(Ve=>Ve.name===re.id);return e.jsxs("option",{value:re.id,children:[re.name||re.id," (",re.size,")",Be?" ● Running":""]},re.id)})}),e.jsx("optgroup",{label:"Catalog",children:Se.filter(re=>!Re.some(Be=>Be.id===re.id)).map(re=>e.jsxs("option",{value:re.id,children:[re.name," (not installed)"]},re.id))})]}):y==="local"?(()=>{const re=Se.filter(Ke=>Ke.source==="runtime"),Be=Se.filter(Ke=>Ke.source==="gguf"),Ve=Se.filter(Ke=>Ke.source==="ollama"||!Ke.source);return e.jsxs(e.Fragment,{children:[re.length>0&&e.jsx("optgroup",{label:"Lab Runtimes",children:re.map(Ke=>e.jsxs("option",{value:Ke.id,children:[Ke.name,Ke.runtimeType?` (${Ke.runtimeType})`:""]},Ke.id))}),Be.length>0&&e.jsx("optgroup",{label:"GGUF Models",children:Be.map(Ke=>e.jsxs("option",{value:Ke.id,children:[Ke.name,Ke.hasRuntime?"":" (no runtime)"]},Ke.id))}),Ve.length>0&&e.jsx("optgroup",{label:"Ollama",children:Ve.map(Ke=>e.jsx("option",{value:Ke.id,children:Ke.name},Ke.id))})]})})():Se.map(re=>e.jsx("option",{value:re.id,children:re.name},re.id))]}),e.jsx(xt,{size:14,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-3 pointer-events-none"})]})]})]}),y&&He&&e.jsx("div",{className:"text-2xs text-text-3 font-sans flex items-center gap-2 flex-wrap",children:He.authType==="local"?e.jsx(Te,{variant:"success",children:"Local"}):He.authType==="subscription"?e.jsx(Te,{variant:"accent",children:"Subscription"}):He.hasKey?e.jsx(Te,{variant:"success",children:"API key set"}):e.jsxs(Te,{variant:"warning",children:["No API key — set with: groove set-key ",y," YOUR_KEY"]})}),y==="claude-code"&&j&&j.includes("opus")&&e.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":ts,onClick:()=>is(!ts),className:Z("relative w-8 h-[18px] rounded-full transition-colors flex-shrink-0",ts?"bg-accent":"bg-surface-5"),children:e.jsx("span",{className:Z("absolute top-[2px] left-[2px] w-[14px] h-[14px] rounded-full bg-white transition-transform",ts&&"translate-x-[14px]")})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-text-0 font-sans",children:"Fast mode"}),e.jsx("span",{className:"text-2xs text-text-3 font-sans ml-1.5",children:"Faster output, same model"})]})]}),y==="claude-code"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:"Billing"}),e.jsx("div",{className:"flex gap-1 p-0.5 rounded-md bg-surface-3 w-fit",children:[{id:"subscription",label:"Subscription"},{id:"usage",label:"Usage credits"}].map(re=>e.jsx("button",{type:"button",onClick:()=>Vo(re.id),className:Z("px-2.5 py-1 rounded text-2xs font-semibold font-sans transition-colors",rr===re.id?"bg-accent text-white":"text-text-2 hover:text-text-0"),children:re.label},re.id))}),rr==="usage"&&!Ko&&e.jsx("p",{className:"text-2xs text-warning font-sans",children:"No Anthropic API key stored — add one in Settings → Providers before spawning."}),rr==="subscription"&&e.jsx("p",{className:"text-2xs text-text-3 font-sans",children:"Uses your Claude Code login (Pro/Max)."})]}),y==="ollama"&&j&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-2xs font-sans",children:[Ot.some(re=>re.name===j)?e.jsxs(Te,{variant:"success",className:"text-2xs gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-success"}),"Ready — running in memory"]}):Re.some(re=>re.id===j)?e.jsx(Te,{variant:"subtle",className:"text-2xs",children:"Will auto-start when agent spawns"}):e.jsx(Te,{variant:"warning",className:"text-2xs",children:"Not installed — will pull first"}),!Ss&&e.jsx("span",{className:"text-warning",children:"Server not running — will auto-start"})]}),tn&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:"Team"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs("button",{onClick:()=>ir("new"),className:Z("flex-1 flex items-center gap-2 px-3 py-2 rounded-md border text-left transition-all cursor-pointer",Es==="new"?"border-accent bg-accent/5":"border-border-subtle bg-surface-1 hover:border-border"),children:[e.jsx(it,{size:13,className:Es==="new"?"text-accent":"text-text-3"}),e.jsx("div",{children:e.jsx("div",{className:"text-2xs font-semibold text-text-0 font-sans",children:"New Team"})})]}),e.jsxs("button",{onClick:()=>ir("existing"),className:Z("flex-1 flex items-center gap-2 px-3 py-2 rounded-md border text-left transition-all cursor-pointer",Es==="existing"?"border-accent bg-accent/5":"border-border-subtle bg-surface-1 hover:border-border"),children:[e.jsx(yn,{size:13,className:Es==="existing"?"text-accent":"text-text-3"}),e.jsx("div",{children:e.jsx("div",{className:"text-2xs font-semibold text-text-0 font-sans",children:"Existing"})})]})]}),Es==="new"&&e.jsx(rs,{value:ha,onChange:re=>wn(re.target.value),placeholder:"Team name...",className:"text-xs"}),Es==="existing"&&e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:en,onChange:re=>vs(re.target.value),className:"w-full h-8 px-3 pr-8 text-sm rounded-md bg-surface-1 border border-border text-text-0 font-sans appearance-none cursor-pointer focus:outline-none focus:ring-1 focus:ring-accent",children:[e.jsx("option",{value:"",children:"Select team..."}),l.filter(re=>!re.archived).map(re=>e.jsx("option",{value:re.id,children:re.name},re.id))]}),e.jsx(xt,{size:14,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-3 pointer-events-none"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:"Integrations"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[M.map(re=>{const Be=B.find(Ke=>Ke.id===re),Ve=Ni[re];return e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded bg-accent/12 text-accent border border-accent/25 text-2xs font-sans",children:[Ve?e.jsx("img",{src:Ve,alt:"",className:"w-2.5 h-2.5"}):e.jsx(on,{size:9}),(Be==null?void 0:Be.name)||re,e.jsx("button",{onClick:()=>R(Ke=>Ke.filter(Fa=>Fa!==re)),className:"ml-0.5 hover:text-text-0 cursor-pointer",children:e.jsx(qe,{size:9})})]},re)}),e.jsxs("button",{onClick:()=>{W(!0),K("")},className:Z("inline-flex items-center gap-1.5 px-2.5 py-1 rounded text-2xs font-sans transition-colors cursor-pointer","bg-surface-0 text-text-2 border border-border-subtle hover:border-border hover:text-text-0"),children:[e.jsx(on,{size:10}),M.length>0?"Add integration":"Attach integration"]})]})]}),e.jsx(Vt,{open:Y,onOpenChange:W,children:e.jsx(Kt,{title:"Select Integration",className:"max-w-sm",children:e.jsxs("div",{className:"space-y-3 p-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(As,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-text-4"}),e.jsx("input",{value:ee,onChange:re=>K(re.target.value),placeholder:"Search integrations...",autoFocus:!0,className:"w-full h-8 pl-8 pr-3 text-xs rounded-md bg-surface-0 border border-border text-text-0 font-sans focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsxs("div",{className:"max-h-64 overflow-y-auto space-y-1",children:[B.filter(re=>{if(!ee)return!0;const Be=ee.toLowerCase();return(re.name||re.id).toLowerCase().includes(Be)||(re.description||"").toLowerCase().includes(Be)}).map(re=>{const Be=M.includes(re.id),Ve=re.configured!==!1,Ke=Ni[re.id],Fa=de&&Array.isArray(re.roles)&&re.roles.includes(de);return e.jsxs("button",{onClick:()=>{Ve&&R(sn=>Be?sn.filter(lr=>lr!==re.id):[...sn,re.id])},disabled:!Ve,className:Z("w-full flex items-center gap-2.5 px-3 py-2 rounded-md text-left transition-colors",Ve?"cursor-pointer":"opacity-40 cursor-not-allowed",Be?"bg-accent/10 border border-accent/25":Ve?"hover:bg-surface-3 border border-transparent":"border border-transparent"),children:[Ke?e.jsx("img",{src:Ke,alt:"",className:"w-4 h-4 flex-shrink-0"}):e.jsx(on,{size:12,className:Be?"text-accent":"text-text-3"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-semibold text-text-0 font-sans truncate",children:re.name||re.id}),!Ve&&e.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"(not configured)"}),Ve&&Fa&&e.jsx("span",{className:"text-2xs font-mono text-accent/70 bg-accent/8 px-1 py-px rounded",children:"rec"})]}),re.description&&e.jsx("div",{className:"text-2xs text-text-3 font-sans truncate",children:re.description}),!Ve&&e.jsx("div",{className:"text-2xs text-text-4 font-sans",children:"Configure in Marketplace"})]}),Be&&e.jsx(rN,{})]},re.id)}),B.length===0&&e.jsx("div",{className:"text-center py-6 text-xs text-text-3 font-sans",children:"No integrations installed. Visit the Marketplace to install integrations."})]})]})})}),M.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:"Integration Approvals"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs("button",{onClick:()=>E("manual"),className:Z("flex-1 flex items-center gap-2 px-3 py-2 rounded-md border text-left transition-all cursor-pointer",_==="manual"?"border-accent bg-accent/5":"border-border-subtle bg-surface-1 hover:border-border"),children:[e.jsx(vn,{size:13,className:_==="manual"?"text-accent":"text-text-3"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xs font-semibold text-text-0 font-sans",children:"Manual"}),e.jsx("div",{className:"text-2xs text-text-3 font-sans",children:"You approve each action"})]})]}),e.jsxs("button",{onClick:()=>E("auto"),className:Z("flex-1 flex items-center gap-2 px-3 py-2 rounded-md border text-left transition-all cursor-pointer",_==="auto"?"border-warning bg-warning/5":"border-border-subtle bg-surface-1 hover:border-border"),children:[e.jsx(Js,{size:13,className:_==="auto"?"text-warning":"text-text-3"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xs font-semibold text-text-0 font-sans",children:"Auto"}),e.jsx("div",{className:"text-2xs text-text-3 font-sans",children:"Agent acts without asking"})]})]})]})]}),q.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:"Repos"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[I.map(re=>{const Be=q.find(Ve=>Ve.id===re);return e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded bg-accent/12 text-accent border border-accent/25 text-2xs font-sans",children:[e.jsx(Kl,{size:9}),(Be==null?void 0:Be.name)||re,e.jsx("button",{onClick:()=>L(Ve=>Ve.filter(Ke=>Ke!==re)),className:"ml-0.5 hover:text-text-0 cursor-pointer",children:e.jsx(qe,{size:9})})]},re)}),e.jsxs("button",{onClick:()=>{D(!0),le("")},className:Z("inline-flex items-center gap-1.5 px-2.5 py-1 rounded text-2xs font-sans transition-colors cursor-pointer","bg-surface-0 text-text-2 border border-border-subtle hover:border-border hover:text-text-0"),children:[e.jsx(Kl,{size:10}),I.length>0?"Add repo":"Attach repo"]})]})]}),e.jsx(Vt,{open:J,onOpenChange:D,children:e.jsx(Kt,{title:"Select Repository",className:"max-w-sm",children:e.jsxs("div",{className:"space-y-3 p-4",children:[q.length>1&&e.jsxs("div",{className:"relative",children:[e.jsx(As,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-text-4"}),e.jsx("input",{value:se,onChange:re=>le(re.target.value),placeholder:"Search repos...",autoFocus:!0,className:"w-full h-8 pl-8 pr-3 text-xs rounded-md bg-surface-0 border border-border text-text-0 font-sans focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:q.filter(re=>{if(!se)return!0;const Be=se.toLowerCase();return(re.name||re.repo||re.id).toLowerCase().includes(Be)}).map(re=>{const Be=I.includes(re.id);return e.jsxs("button",{onClick:()=>{L(Ve=>Be?Ve.filter(Ke=>Ke!==re.id):[...Ve,re.id])},className:Z("w-full flex items-center gap-2.5 px-3 py-2 rounded-md text-left transition-colors cursor-pointer",Be?"bg-accent/10 border border-accent/25":"hover:bg-surface-3 border border-transparent"),children:[e.jsx(Kl,{size:12,className:Be?"text-accent":"text-text-3"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-text-0 font-sans truncate",children:re.name||re.repo}),e.jsx("div",{className:"text-2xs text-text-4 font-mono truncate",children:re.clonedTo})]}),Be&&e.jsx(rN,{})]},re.id)})})]})})}),(x==="chat"||z)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:"Personality"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:ae,onChange:re=>be(re.target.value),className:"w-full h-8 px-3 pr-8 text-sm rounded-md bg-surface-1 border border-border text-text-0 font-sans appearance-none cursor-pointer focus:outline-none focus:ring-1 focus:ring-accent",children:[e.jsx("option",{value:"",children:"None (blank)"}),V.map(re=>e.jsx("option",{value:re.name||re,children:re.name||re},re.name||re))]}),e.jsx(xt,{size:14,className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-3 pointer-events-none"})]}),e.jsx("p",{className:"text-2xs text-text-4 font-sans",children:"Personality is injected into every prompt for this agent."})]}),x!=="chat"&&!z&&e.jsx("button",{onClick:()=>oe(!0),className:"text-2xs text-text-3 hover:text-accent font-sans transition-colors cursor-pointer",children:"+ Advanced options"})]})]}),e.jsxs("div",{className:"border-t border-border-subtle px-5 py-4 bg-surface-1",children:[Ge.length===0&&P.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 px-3 py-2 rounded-md bg-warning/8 border border-warning/20",children:[e.jsx(Aa,{size:13,className:"text-warning flex-shrink-0"}),e.jsx("span",{className:"text-2xs font-sans text-text-2",children:"No AI providers installed. Install Claude Code, Gemini CLI, Codex, or Ollama to spawn agents."})]}),de&&Ge.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-xs text-text-3 font-sans flex-wrap",children:[e.jsx("span",{children:"Spawning"}),e.jsx(Te,{variant:"accent",children:de}),y&&e.jsxs("span",{children:["on ",(He==null?void 0:He.name)||y]}),b&&e.jsxs("span",{children:["as ",b.replace(/\s+/g,"-")]}),Es==="new"&&e.jsxs("span",{children:["in new team",ha?` "${ha}"`:""]}),Es==="existing"&&en&&e.jsxs("span",{children:["in ",((Qd=l.find(re=>re.id===en))==null?void 0:Qd.name)||"team"]})]}),e.jsx(pe,{variant:"primary",size:"lg",onClick:Wo,disabled:!de||ue||Ge.length===0||Es==="existing"&&!en,className:"w-full",children:ue?"Spawning...":"Spawn Agent"})]})]})}),e.jsx(Vt,{open:!!Ae,onOpenChange:re=>{re||ke(null)},children:e.jsx(Kt,{title:"Integration Warning",className:"max-w-sm",children:e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx("div",{className:"space-y-2",children:(Ae||[]).map((re,Be)=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-text-1 font-sans",children:[e.jsx(Aa,{size:13,className:"text-warning flex-shrink-0 mt-0.5"}),e.jsx("span",{children:re.name?`${re.name}: ${re.problem==="not_installed"?"not installed":re.problem==="not_configured"?"not configured":"not authenticated"}`:re.message||String(re)})]},Be))}),e.jsx("p",{className:"text-2xs text-text-3 font-sans",children:"Continue anyway?"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(pe,{variant:"ghost",size:"md",onClick:()=>ke(null),className:"flex-1",children:"Cancel"}),e.jsx(pe,{variant:"warning",size:"md",onClick:()=>{ke(null),qo()},className:"flex-1",children:"Spawn Anyway"})]})]})})})]})}function Koe(){const t=k(g=>g.journalistStatus),s=k(g=>g.fetchJournalist),n=k(g=>g.triggerJournalistCycle),[a,r]=p.useState(!0),[l,c]=p.useState(!1);p.useEffect(()=>{s().then(()=>r(!1));const g=setInterval(s,1e4);return()=>clearInterval(g)},[s]);async function A(){c(!0);try{await n()}catch{}c(!1)}if(a)return e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsx(ia,{className:"h-6 w-32 rounded"}),e.jsx(ia,{className:"h-20 rounded-md"}),e.jsx(ia,{className:"h-20 rounded-md"})]});const f=t||{},x=f.lastSynthesis,h=f.history||[];return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"pl-5 pr-10 py-4 border-b border-border-subtle flex items-center gap-2",children:[e.jsx(ox,{size:16,className:"text-accent"}),e.jsx("h3",{className:"text-sm font-semibold text-text-0 font-sans flex-1",children:"Journalist"}),e.jsxs(pe,{variant:"secondary",size:"sm",onClick:A,disabled:l,className:"gap-1.5 text-2xs",children:[e.jsx(Ls,{size:11,className:l?"animate-spin":""}),l?"Running...":"Run Synthesis"]})]}),e.jsx(Qt,{className:"flex-1",children:e.jsxs("div",{className:"px-5 py-4 space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-3 text-2xs text-text-3 font-sans",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ro,{size:10}),e.jsxs("span",{children:[f.cycleCount||0," cycles"]})]}),f.lastCycleTime&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Dn,{size:10}),e.jsxs("span",{children:["Last: ",$t(f.lastCycleTime)]})]}),e.jsx(Te,{variant:f.cycleCount>0?"success":"default",className:"text-2xs",children:f.cycleCount>0?"Active":"Idle"})]}),(x==null?void 0:x.summary)&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-xs font-semibold text-text-1 font-sans flex items-center gap-1.5",children:[e.jsx(On,{size:12,className:"text-text-3"}),"Latest Summary"]}),e.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle px-3.5 py-3 text-xs text-text-2 font-sans leading-relaxed",children:x.summary})]}),(x==null?void 0:x.projectMap)&&e.jsx(Ex,{title:"Project Map",icon:$M,children:e.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle px-3.5 py-3 text-xs text-text-2 font-mono leading-relaxed max-h-64 overflow-y-auto whitespace-pre-wrap",children:x.projectMap})}),(x==null?void 0:x.decisions)&&e.jsx(Ex,{title:"Decisions Log",icon:On,children:e.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle px-3.5 py-3 text-xs text-text-2 font-mono leading-relaxed max-h-64 overflow-y-auto whitespace-pre-wrap",children:x.decisions})}),h.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-xs font-semibold text-text-1 font-sans flex items-center gap-1.5",children:[e.jsx(Dn,{size:12,className:"text-text-3"}),"History (",h.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:h.slice().reverse().slice(0,20).map((g,O)=>e.jsxs("div",{className:"bg-surface-0 rounded-md border border-border-subtle px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-2xs",children:[e.jsxs(Te,{variant:"default",className:"text-2xs",children:["Cycle ",g.cycle]}),e.jsxs("span",{className:"text-text-4 font-sans",children:[g.agentCount," agent",g.agentCount!==1?"s":""]}),e.jsx("span",{className:"text-text-4 font-sans ml-auto",children:$t(g.timestamp)})]}),g.summary&&e.jsx("p",{className:"text-xs text-text-2 font-sans mt-1 leading-relaxed",children:g.summary})]},O))})]}),!x&&h.length===0&&e.jsxs("div",{className:"text-center py-8 text-text-4 font-sans",children:[e.jsx(ox,{size:28,className:"mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"No synthesis data yet"}),e.jsx("p",{className:"text-2xs mt-1",children:"The journalist runs automatically when agents are active, or trigger manually above"})]})]})})]})}const qoe=[{cmd:"save",args:"#tag",desc:"Save the message and send it to the agent"},{cmd:"append",args:"#tag",desc:"Add to an existing memory and send to agent"},{cmd:"update",args:"#tag",desc:"Open the editor to modify a memory in place"},{cmd:"delete",args:"#tag",desc:"Remove a memory permanently"},{cmd:"view",args:"#tag",desc:"Read a memory in the viewer"},{cmd:"read",args:"#tag1 #tag2 ...",desc:"Send memory content to the agent — chat stays clean"},{cmd:"doc",args:"#tag",desc:"AI synthesizes the full conversation into a document"},{cmd:"link",args:"#tag path/to/doc",desc:"Link a memory to a NORTHSTAR or external document"},{cmd:"[instruct]",args:"",desc:"Show this command reference"}];function Woe(){var j;const t=k(N=>N.keeperEditing),s=k(N=>N.setKeeperEditing),n=k(N=>N.saveKeeperItem),a=k(N=>N.updateKeeperItem),r=k(N=>N.activeView),[l,c]=p.useState(""),[A,f]=p.useState(""),x=p.useRef(null),h=!!t&&r!=="memory";p.useEffect(()=>{t&&(c(t.tag||""),f(t.content||""))},[t]),p.useEffect(()=>{h&&x.current&&setTimeout(()=>{var N;return(N=x.current)==null?void 0:N.focus()},100)},[h]);const g=N=>{N||s(null)},O=async()=>{!l.trim()||t!=null&&t.readOnly||(t!=null&&t.isNew?await n(l.trim(),A):await a(l.trim(),A),s(null))},b=N=>{N.key==="s"&&(N.metaKey||N.ctrlKey)&&(N.preventDefault(),O())};if(!t)return null;const v=t.readOnly,y=t.isNew,S=v?`#${t.tag}`:y?"New Memory":`Edit #${t.tag}`;return e.jsx(Vt,{open:h,onOpenChange:g,children:e.jsx(Kt,{title:S,description:"Memory content",className:"max-w-2xl",children:e.jsxs("div",{className:"p-5 space-y-4",onKeyDown:b,children:[y&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-text-2 mb-1.5",children:"Tag"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-sm text-text-3",children:"#"}),e.jsx("input",{type:"text",value:l,onChange:N=>c(N.target.value.replace(/[^a-zA-Z0-9/_-]/g,"").toLowerCase()),placeholder:"project/feature-name",className:"flex-1 px-2 py-1.5 text-sm font-mono rounded-md bg-surface-0 border border-border text-text-0 placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"})]})]}),e.jsx("textarea",{ref:x,value:A,onChange:N=>!v&&f(N.target.value),readOnly:v,rows:16,className:"w-full px-3 py-2 text-sm font-mono leading-relaxed rounded-md bg-surface-0 border border-border text-text-0 placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent resize-y",placeholder:"Write your thoughts, ideas, context..."}),e.jsxs("div",{className:"flex items-center justify-between pt-1",children:[v?e.jsx("p",{className:"text-2xs text-text-4",children:"Read-only view"}):e.jsxs("p",{className:"text-2xs text-text-4",children:[(j=navigator.platform)!=null&&j.includes("Mac")?"Cmd":"Ctrl","+S to save"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>s(null),children:v?"Close":"Cancel"}),!v&&e.jsxs(pe,{variant:"primary",size:"sm",onClick:O,disabled:!l.trim(),children:[e.jsx(_r,{size:14})," Save"]})]})]})]})})})}function Yoe(){const t=k(n=>n.keeperInstructOpen);return k(n=>n.activeView)==="memory"?null:e.jsx(Vt,{open:t,onOpenChange:n=>k.setState({keeperInstructOpen:n}),children:e.jsx(Kt,{title:"Keeper Commands",description:"Memory system command reference",className:"max-w-lg",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsx("p",{className:"text-xs text-text-2 leading-relaxed",children:"Type these commands in any agent chat to manage your tagged memories. Commands are intercepted by Keeper — the agent never sees them."}),e.jsx("div",{className:"space-y-1.5",children:qoe.map(n=>e.jsxs("div",{className:"flex items-start gap-3 py-1.5 border-b border-border-subtle last:border-0",children:[e.jsxs("div",{className:"flex-shrink-0 flex items-center gap-1",children:[e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-accent/15 text-accent font-mono text-xs font-semibold",children:n.cmd}),n.args&&e.jsx("span",{className:"text-xs text-text-3 font-mono",children:n.args})]}),e.jsx("span",{className:"text-xs text-text-3 pt-0.5",children:n.desc})]},n.cmd))}),e.jsxs("div",{className:"pt-2 space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-text-1",children:"Tag Hierarchy"}),e.jsxs("p",{className:"text-xs text-text-3 leading-relaxed",children:["Use ",e.jsx("span",{className:"font-mono text-accent",children:"/"})," for nesting: ",e.jsx("span",{className:"font-mono text-accent",children:"#groove/memory-system"}),". Pull a parent to get all children."]}),e.jsx("h3",{className:"text-xs font-semibold text-text-1",children:"Memory Types"}),e.jsxs("p",{className:"text-xs text-text-3 leading-relaxed",children:[e.jsx("span",{className:"font-semibold",children:"Manual"})," — you write via [save]/[append]/[update]. ",e.jsx("span",{className:"font-semibold",children:"Doc"})," — AI writes via [doc]. Both editable."]})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>k.setState({keeperInstructOpen:!1}),children:"Close"})})]})})})}function Joe(){return e.jsxs(e.Fragment,{children:[e.jsx(Woe,{}),e.jsx(Yoe,{})]})}function eie({onSelect:t,onClose:s}){const n=p.useRef(null),a=k(f=>f.agents),r=k(f=>f.teams);p.useEffect(()=>{function f(h){n.current&&!n.current.contains(h.target)&&s()}function x(h){h.key==="Escape"&&s()}return document.addEventListener("mousedown",f),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",x)}},[s]);const l=a.filter(f=>f.status==="running"||f.status==="starting"),c=a.filter(f=>f.status!=="running"&&f.status!=="starting");function A(f){const x=r.find(h=>h.id===f);return(x==null?void 0:x.name)||"Default"}return e.jsxs("div",{ref:n,className:"absolute bottom-full right-0 mb-1 z-50 min-w-[220px] max-h-[300px] overflow-y-auto py-1 bg-surface-2 border border-border rounded-lg shadow-xl",children:[l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-1 text-2xs text-text-4 font-sans font-medium uppercase tracking-wider",children:"Active"}),l.map(f=>e.jsxs("button",{onClick:()=>t(f.id),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs font-sans text-text-1 hover:bg-surface-5 cursor-pointer transition-colors text-left",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-success flex-shrink-0"}),e.jsx("span",{className:"truncate flex-1",children:f.name}),e.jsx("span",{className:"text-2xs text-text-4",children:A(f.teamId)})]},f.id))]}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-1 text-2xs text-text-4 font-sans font-medium uppercase tracking-wider",children:l.length>0?"Other":"Agents"}),c.slice(0,10).map(f=>e.jsxs("button",{onClick:()=>t(f.id),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs font-sans text-text-2 hover:bg-surface-5 cursor-pointer transition-colors text-left",children:[e.jsx("span",{className:Z("w-1.5 h-1.5 rounded-full flex-shrink-0",f.status==="completed"?"bg-accent":f.status==="crashed"?"bg-danger":"bg-text-4")}),e.jsx("span",{className:"truncate flex-1",children:f.name}),e.jsx("span",{className:"text-2xs text-text-4",children:A(f.teamId)})]},f.id))]}),a.length===0&&e.jsx("div",{className:"px-3 py-3 text-xs text-text-4 font-sans text-center",children:"No agents available"})]})}function tie({children:t,height:s,onHeightChange:n,visible:a,fullHeight:r,tabs:l,activeTab:c,onSelectTab:A,onAddTab:f,onCloseTab:x,onToggleFullHeight:h,onMinimize:g,onClose:O,onRenameTab:b,selectedText:v}){const y=p.useRef(!1),[S,j]=p.useState(null),[N,C]=p.useState(""),[U,P]=p.useState(!1),T=p.useRef(0),B=p.useRef(0),F=k(I=>I.detailPanel),M=k(I=>I.workspaceAgentId),R=(F==null?void 0:F.type)==="agent"?F.agentId:M||null,Y=k(I=>I.agents),W=k(I=>I.attachSnippet),ee=Y.find(I=>I.id===R),K=v&&v.trim().length>0,_=p.useCallback(I=>{if(r)return;I.preventDefault(),y.current=!0,T.current=I.clientY,B.current=s;function L(D){if(!y.current)return;const se=T.current-D.clientY,le=Math.min(Math.max(B.current+se,120),600);n(le)}function J(){y.current=!1,document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",J)}document.addEventListener("mousemove",L),document.addEventListener("mouseup",J)},[s,n,r]);function E(I){!I||!(v!=null&&v.trim())||(P(!1),W({type:"terminal",code:v.trim()}),k.getState().selectAgent(I))}function q(){R?E(R):P(!0)}const H=l||[{id:"default",label:"Terminal"}];return e.jsxs("div",{className:Z("flex flex-col border-t border-border bg-surface-0 relative",!a&&"hidden"),style:a?r?{flex:1,minHeight:0}:{height:s,flexShrink:0}:{height:0},children:[!r&&e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 cursor-row-resize hover:bg-accent/30 transition-colors z-10",onMouseDown:_}),e.jsxs("div",{className:"flex items-center h-9 bg-surface-1 border-b border-border flex-shrink-0 pl-0 pr-3",children:[e.jsxs("div",{className:"flex items-center gap-0 flex-1 min-w-0 overflow-x-auto scrollbar-none h-full",children:[H.map(I=>e.jsxs("button",{onClick:()=>A==null?void 0:A(I.id),onDoubleClick:()=>{j(I.id),C(I.label)},className:Z("inline-flex items-center gap-1.5 px-3 h-full text-[11px] font-medium font-sans cursor-pointer select-none transition-colors duration-100 flex-shrink-0",I.id===c?"text-text-0 bg-surface-3":"text-text-2 hover:text-text-0 hover:bg-surface-5/50"),children:[e.jsx(Wa,{size:11}),S===I.id?e.jsx("input",{className:"bg-transparent border border-border rounded px-1 text-[11px] text-text-0 outline-none w-20 font-sans",value:N,onChange:L=>C(L.target.value),onBlur:()=>{N.trim()&&(b==null||b(I.id,N.trim())),j(null)},onKeyDown:L=>{L.key==="Enter"&&(N.trim()&&(b==null||b(I.id,N.trim())),j(null)),L.key==="Escape"&&j(null)},autoFocus:!0,onClick:L=>L.stopPropagation()}):e.jsx("span",{className:"truncate max-w-[100px]",children:I.label}),H.length>1&&e.jsx("button",{onClick:L=>{L.stopPropagation(),x==null||x(I.id)},className:"ml-1 p-0.5 rounded hover:bg-surface-5 text-text-4 hover:text-text-1 cursor-pointer",children:e.jsx(qe,{size:9})})]},I.id)),e.jsx("button",{onClick:f,className:"flex items-center justify-center w-6 h-6 text-text-3 hover:text-text-0 hover:bg-surface-5/50 rounded cursor-pointer transition-colors flex-shrink-0 ml-1",title:"New terminal",children:e.jsx(it,{size:11})})]}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0 ml-2",children:[K&&e.jsxs("div",{className:"relative flex items-center",children:[e.jsx(dt,{content:R?`Send to ${(ee==null?void 0:ee.name)||"agent"}`:"Send to agent",side:"top",children:e.jsx("button",{onClick:q,className:Z("flex items-center gap-1.5 px-2 py-1 rounded text-xs font-sans cursor-pointer transition-colors mr-1","bg-accent/15 text-accent hover:bg-accent/25 disabled:opacity-50"),children:R?e.jsxs(e.Fragment,{children:[e.jsx(Ln,{size:11}),e.jsx("span",{className:"text-2xs max-w-[80px] truncate",children:(ee==null?void 0:ee.name)||"Agent"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Js,{size:11}),e.jsx("span",{className:"text-2xs",children:"Agent"}),e.jsx(xt,{size:9})]})})}),!R&&K&&e.jsx(dt,{content:"Pick agent",side:"top",children:e.jsx("button",{onClick:()=>P(!U),className:"p-1 rounded text-text-3 hover:text-accent hover:bg-accent/10 cursor-pointer transition-colors mr-1",children:e.jsx(xt,{size:10})})}),U&&e.jsx(eie,{onSelect:I=>E(I),onClose:()=>P(!1)})]}),r?e.jsx("button",{onClick:g,className:"p-1.5 rounded text-text-3 hover:text-text-0 hover:bg-surface-5 cursor-pointer transition-colors",title:"Restore",children:e.jsx(HM,{size:12})}):e.jsx("button",{onClick:h,className:"p-1.5 rounded text-text-3 hover:text-text-0 hover:bg-surface-5 cursor-pointer transition-colors",title:"Maximize",children:e.jsx(Mb,{size:12})}),e.jsx("button",{onClick:O,className:"p-1.5 rounded text-text-3 hover:text-text-0 hover:bg-surface-5 cursor-pointer transition-colors",title:"Close terminal",children:e.jsx(qe,{size:12})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 pl-2 pt-1",children:t})]})}const sie={background:"#1a1e25",foreground:"#c8ccd4",cursor:"#33afbc",cursorAccent:"#1a1e25",selectionBackground:"rgba(51, 175, 188, 0.3)",selectionForeground:"#ffffff",black:"#1a1e25",red:"#e06c75",green:"#4ae168",yellow:"#e5c07b",blue:"#61afef",magenta:"#c678dd",cyan:"#33afbc",white:"#abb2bf",brightBlack:"#5c6370",brightRed:"#f07178",brightGreen:"#4ae168",brightYellow:"#e5c07b",brightBlue:"#61afef",brightMagenta:"#c678dd",brightCyan:"#56b6c2",brightWhite:"#ffffff"};let eO=0,nie=0;function aie({tabId:t,visible:s,registerKill:n,onSelectionChange:a}){const r=p.useRef(null),l=p.useRef(null),c=p.useRef(null),A=p.useRef(null),f=p.useRef(null),x=p.useRef(!1),h=p.useRef(s),g=p.useRef({cols:0,rows:0}),O=p.useRef(!1);p.useEffect(()=>{n==null||n(t,()=>{const v=k.getState().ws;(v==null?void 0:v.readyState)===WebSocket.OPEN&&A.current&&v.send(JSON.stringify({type:"terminal:kill",id:A.current}))})},[t,n]);const b=k(v=>v.terminalPendingCommand);return p.useEffect(()=>{if(!b||!s)return;let v=0,y=null;const S=()=>{const j=k.getState().ws;if((j==null?void 0:j.readyState)===WebSocket.OPEN&&A.current&&O.current){j.send(JSON.stringify({type:"terminal:input",id:A.current,data:b.command+"\r"})),k.getState().clearTerminalPendingCommand();return}v++<40&&(y=setTimeout(S,150))};return S(),()=>clearTimeout(y)},[b,s]),p.useEffect(()=>{if(!r.current||x.current)return;x.current=!0;const v=new JU({theme:sie,fontFamily:"'SF Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace",fontSize:12,lineHeight:1.1,letterSpacing:0,cursorBlink:!0,cursorStyle:"bar",cursorWidth:1,scrollback:1e4,allowProposedApi:!0,minimumContrastRatio:1,drawBoldTextInBrightColors:!0,fontWeight:"400",fontWeightBold:"600",overviewRulerWidth:0}),y=new eE;v.loadAddon(y),v.loadAddon(new tE),v.open(r.current),l.current=v,c.current=y,v.onSelectionChange(()=>{const F=v.getSelection();a==null||a(F||"")});let S=0,j=!1;function N(){S++;const F=k.getState().ws;if(!F||F.readyState!==WebSocket.OPEN){S<20&&setTimeout(N,500);return}const M=`spawn-${++nie}`;F.send(JSON.stringify({type:"terminal:spawn",cols:v.cols,rows:v.rows,requestId:M}));function R(W){let ee;try{ee=JSON.parse(W.data)}catch{return}ee.type==="terminal:spawned"&&ee.requestId===M&&!A.current?(A.current=ee.id,setTimeout(()=>{try{y.fit()}catch{}const K=v.cols,_=v.rows;if(K>1&&_>1&&A.current){const q=k.getState().ws;(q==null?void 0:q.readyState)===WebSocket.OPEN&&(q.send(JSON.stringify({type:"terminal:resize",id:A.current,rows:_,cols:K})),g.current={cols:K,rows:_})}v.reset(),j=!0,O.current=!0;const E=k.getState().ws;(E==null?void 0:E.readyState)===WebSocket.OPEN&&A.current&&E.send(JSON.stringify({type:"terminal:input",id:A.current,data:"\f"}))},300)):ee.type==="terminal:output"&&ee.id===A.current?j&&v.write(ee.data):ee.type==="terminal:exit"&&ee.id===A.current&&(j=!0,O.current=!1,v.write(`\r
1069
1069
  \x1B[90m[session ended]\x1B[0m\r
1070
- `),A.current=null)}F.addEventListener("message",R),f.current={ws:F,handler:R},v.onData(W=>{const ee=k.getState().ws;(ee==null?void 0:ee.readyState)===WebSocket.OPEN&&A.current&&ee.send(JSON.stringify({type:"terminal:input",id:A.current,data:W}))});let Y=null;v.onResize(({cols:W,rows:ee})=>{W===g.current.cols&&ee===g.current.rows||W<2||ee<2||(g.current={cols:W,rows:ee},clearTimeout(Y),Y=setTimeout(()=>{const{cols:K,rows:_}=g.current,E=k.getState().ws;(E==null?void 0:E.readyState)===WebSocket.OPEN&&A.current&&E.send(JSON.stringify({type:"terminal:resize",id:A.current,rows:_,cols:K}))},150))})}let C=!1,U=null;function P(){if(C)return;const F=r.current;if(!F||F.offsetWidth<200||F.offsetHeight<50){clearTimeout(U),U=null;return}U||(U=setTimeout(()=>{if(C)return;const M=r.current;if(!M||M.offsetWidth<200||M.offsetHeight<50){U=null;return}C=!0;try{y.fit()}catch{}N()},200))}requestAnimationFrame(P);const T=setTimeout(()=>{if(!C){C=!0;try{y.fit()}catch{}N()}},5e3),B=new ResizeObserver(()=>{h.current&&requestAnimationFrame(()=>{if(!C)P();else try{y.fit()}catch{}})});return B.observe(r.current),()=>{clearTimeout(U),clearTimeout(T),B.disconnect(),f.current&&f.current.ws.removeEventListener("message",f.current.handler),v.dispose(),c.current=null,l.current=null,x.current=!1}},[]),p.useEffect(()=>{h.current=s,s&&c.current&&requestAnimationFrame(()=>{try{c.current.fit()}catch{}})},[s]),e.jsx("div",{ref:r,className:"w-full h-full overflow-hidden",style:{display:s?"block":"none"}})}function rie(){const t=k(j=>j.terminalVisible),s=k(j=>j.terminalHeight),n=k(j=>j.setTerminalVisible),a=k(j=>j.setTerminalHeight),r=k(j=>j.terminalFullHeight),l=k(j=>j.setTerminalFullHeight),[c,A]=p.useState([{id:"term-0",label:"Terminal"}]),[f,x]=p.useState("term-0"),[h,g]=p.useState(""),O=p.useRef({}),b=p.useCallback((j,N)=>{O.current[j]=N},[]),v=p.useCallback(()=>{eO++;const j=`term-${eO}`;A(N=>[...N,{id:j,label:`Terminal ${eO+1}`}]),x(j)},[]),y=p.useCallback((j,N)=>{A(C=>C.map(U=>U.id===j?{...U,label:N}:U))},[]),S=p.useCallback(j=>{var N,C;(C=(N=O.current)[j])==null||C.call(N),delete O.current[j],A(U=>{const P=U.filter(T=>T.id!==j);if(P.length===0)return n(!1),U;if(f===j){const T=U.findIndex(F=>F.id===j),B=P[Math.min(T,P.length-1)];x(B.id)}return P})},[f,n]);return e.jsx(tie,{visible:t,height:s,onHeightChange:a,fullHeight:r,tabs:c,activeTab:f,onSelectTab:x,onAddTab:v,onCloseTab:S,onRenameTab:y,onToggleFullHeight:()=>l(!0),onMinimize:()=>l(!1),onClose:()=>n(!1),selectedText:h,children:c.map(j=>e.jsx(aie,{tabId:j.id,visible:j.id===f,registerKill:b,onSelectionChange:j.id===f?g:void 0},j.id))})}class Ff extends go.Component{constructor(s){super(s),this.state={error:null}}static getDerivedStateFromError(s){return{error:s}}render(){return this.state.error?e.jsxs("div",{className:"h-screen bg-surface-0 p-10 font-sans",children:[e.jsx("h2",{className:"text-lg font-semibold text-text-0 mb-4",children:"Groove — Render Error"}),e.jsx("pre",{className:"text-sm text-danger whitespace-pre-wrap mb-4",children:this.state.error.message}),e.jsx("pre",{className:"text-xs text-text-3 whitespace-pre-wrap",children:this.state.error.stack}),e.jsx("button",{onClick:()=>this.setState({error:null}),className:"mt-6 px-4 py-2 bg-accent text-surface-0 rounded-md font-medium text-sm cursor-pointer",children:"Try Again"})]}):this.props.children}}function oie(){const t=k(l=>l.activeView),s=k(l=>l.detailPanel);k(l=>l.agents);const n=k(l=>l.networkUnlocked);let a;switch(t){case"agents":a=e.jsx(Dg,{});break;case"editor":a=e.jsx(ite,{});break;case"dashboard":a=e.jsx(Dte,{});break;case"marketplace":a=e.jsx(fse,{});break;case"teams":a=e.jsx(Ese,{});break;case"auto-agents":a=e.jsx(Qoe,{});break;case"models":a=e.jsx(tne,{});break;case"model-lab":a=e.jsx(lae,{});break;case"federation":a=e.jsx(bne,{});break;case"settings":a=e.jsx(Kse,{});break;case"chat":a=e.jsx(Sre,{});break;case"fleet":a=e.jsx(foe,{});break;case"memory":a=e.jsx(Pre,{});break;case"network":a=n?e.jsx(sre,{}):e.jsx(Dg,{});break;default:a=e.jsx(Dg,{})}let r=null;if(s)switch(s.type){case"agent":{r=e.jsx(Goe,{});break}case"journalist":r=e.jsx(Koe,{});break;case"spawn":r=null;break}return e.jsxs(Bee,{detailContent:r,terminalContent:e.jsx(rie,{}),children:[a,e.jsx(Voe,{})]})}function iie(){const t=k(n=>n.remoteHomedir),s=k(n=>n.setProjectDir);return e.jsxs("div",{className:"fixed inset-0 z-40 bg-surface-0 flex flex-col items-center justify-center gap-3",children:[e.jsx("img",{src:"/favicon.png",alt:"",className:"w-10 h-10 opacity-60"}),e.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Connected — choose a project directory to continue"}),e.jsx(gc,{open:!0,onOpenChange:()=>{},currentPath:t||"/home",homePath:t,onSelect:n=>s(n),mandatory:!0})]})}function lie(){return e.jsxs("div",{className:"h-screen bg-surface-0 flex flex-col items-center justify-center gap-4",children:[e.jsx("img",{src:"/favicon.png",alt:"",className:"w-10 h-10 opacity-60 animate-pulse"}),e.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Connecting..."})]})}function cie(){const t=k(c=>c.connect),s=k(c=>c.hydrated),n=k(c=>c.tunneled),a=k(c=>c.onboardingComplete),r=k(c=>c.showProjectPicker);p.useEffect(()=>{t()},[t]),p.useEffect(()=>{async function c(){var x;if((x=window.groove)!=null&&x.getInstanceInfo){const h=await window.groove.getInstanceInfo();if(h!=null&&h.name){document.title=`${h.name} — Groove`;return}}const f=new URLSearchParams(window.location.search).get("instance");if(f){const h=f.replace(/[\x00-\x1F]/g,"").slice(0,50);document.title=`${h} — Groove`}else n?document.title="Remote — Groove":document.title="Groove"}c()},[n]);const l=p.useMemo(()=>{var c;return(c=window.groove)!=null&&c.openFolder?[{key:"o",meta:!0,handler:()=>window.groove.openFolder()}]:[]},[]);return pN(l),s?a?r&&n?e.jsx(Ff,{children:e.jsx(iie,{})}):r?e.jsxs(Ff,{children:[e.jsx(Hee,{}),e.jsx(SQ,{})]}):e.jsxs(Ff,{children:[e.jsx(oie,{}),e.jsx(SQ,{}),e.jsx(Lee,{}),e.jsx(Joe,{})]}):e.jsx(Ff,{children:e.jsx(_ee,{})}):e.jsx(lie,{})}oE.createRoot(document.getElementById("root")).render(e.jsx(p.StrictMode,{children:e.jsx(cie,{})}));
1070
+ `),A.current=null)}F.addEventListener("message",R),f.current={ws:F,handler:R},v.onData(W=>{const ee=k.getState().ws;(ee==null?void 0:ee.readyState)===WebSocket.OPEN&&A.current&&ee.send(JSON.stringify({type:"terminal:input",id:A.current,data:W}))});let Y=null;v.onResize(({cols:W,rows:ee})=>{W===g.current.cols&&ee===g.current.rows||W<2||ee<2||(g.current={cols:W,rows:ee},clearTimeout(Y),Y=setTimeout(()=>{const{cols:K,rows:_}=g.current,E=k.getState().ws;(E==null?void 0:E.readyState)===WebSocket.OPEN&&A.current&&E.send(JSON.stringify({type:"terminal:resize",id:A.current,rows:_,cols:K}))},150))})}let C=!1,U=null;function P(){if(C)return;const F=r.current;if(!F||F.offsetWidth<200||F.offsetHeight<50){clearTimeout(U),U=null;return}U||(U=setTimeout(()=>{if(C)return;const M=r.current;if(!M||M.offsetWidth<200||M.offsetHeight<50){U=null;return}C=!0;try{y.fit()}catch{}N()},200))}requestAnimationFrame(P);const T=setTimeout(()=>{if(!C){C=!0;try{y.fit()}catch{}N()}},5e3),B=new ResizeObserver(()=>{h.current&&requestAnimationFrame(()=>{if(!C)P();else try{y.fit()}catch{}})});return B.observe(r.current),()=>{clearTimeout(U),clearTimeout(T),B.disconnect(),f.current&&f.current.ws.removeEventListener("message",f.current.handler),v.dispose(),c.current=null,l.current=null,x.current=!1}},[]),p.useEffect(()=>{h.current=s,s&&c.current&&requestAnimationFrame(()=>{try{c.current.fit()}catch{}})},[s]),e.jsx("div",{ref:r,className:"w-full h-full overflow-hidden",style:{display:s?"block":"none"}})}function rie(){const t=k(j=>j.terminalVisible),s=k(j=>j.terminalHeight),n=k(j=>j.setTerminalVisible),a=k(j=>j.setTerminalHeight),r=k(j=>j.terminalFullHeight),l=k(j=>j.setTerminalFullHeight),[c,A]=p.useState([{id:"term-0",label:"Terminal"}]),[f,x]=p.useState("term-0"),[h,g]=p.useState(""),O=p.useRef({}),b=p.useCallback((j,N)=>{O.current[j]=N},[]),v=p.useCallback(()=>{eO++;const j=`term-${eO}`;A(N=>[...N,{id:j,label:`Terminal ${eO+1}`}]),x(j)},[]),y=p.useCallback((j,N)=>{A(C=>C.map(U=>U.id===j?{...U,label:N}:U))},[]),S=p.useCallback(j=>{var N,C;(C=(N=O.current)[j])==null||C.call(N),delete O.current[j],A(U=>{const P=U.filter(T=>T.id!==j);if(P.length===0)return n(!1),U;if(f===j){const T=U.findIndex(F=>F.id===j),B=P[Math.min(T,P.length-1)];x(B.id)}return P})},[f,n]);return e.jsx(tie,{visible:t,height:s,onHeightChange:a,fullHeight:r,tabs:c,activeTab:f,onSelectTab:x,onAddTab:v,onCloseTab:S,onRenameTab:y,onToggleFullHeight:()=>l(!0),onMinimize:()=>l(!1),onClose:()=>n(!1),selectedText:h,children:c.map(j=>e.jsx(aie,{tabId:j.id,visible:j.id===f,registerKill:b,onSelectionChange:j.id===f?g:void 0},j.id))})}class Ff extends go.Component{constructor(s){super(s),this.state={error:null}}static getDerivedStateFromError(s){return{error:s}}render(){return this.state.error?e.jsxs("div",{className:"h-screen bg-surface-0 p-10 font-sans",children:[e.jsx("h2",{className:"text-lg font-semibold text-text-0 mb-4",children:"Groove — Render Error"}),e.jsx("pre",{className:"text-sm text-danger whitespace-pre-wrap mb-4",children:this.state.error.message}),e.jsx("pre",{className:"text-xs text-text-3 whitespace-pre-wrap",children:this.state.error.stack}),e.jsx("button",{onClick:()=>this.setState({error:null}),className:"mt-6 px-4 py-2 bg-accent text-surface-0 rounded-md font-medium text-sm cursor-pointer",children:"Try Again"})]}):this.props.children}}function oie(){const t=k(l=>l.activeView),s=k(l=>l.detailPanel);k(l=>l.agents);const n=k(l=>l.networkUnlocked);let a;switch(t){case"agents":a=e.jsx(Dg,{});break;case"editor":a=e.jsx(ite,{});break;case"dashboard":a=e.jsx(Dte,{});break;case"marketplace":a=e.jsx(fse,{});break;case"teams":a=e.jsx(Ese,{});break;case"auto-agents":a=e.jsx(Qoe,{});break;case"models":a=e.jsx(tne,{});break;case"model-lab":a=e.jsx(lae,{});break;case"federation":a=e.jsx(bne,{});break;case"settings":a=e.jsx(Kse,{});break;case"chat":a=e.jsx(Sre,{});break;case"fleet":a=e.jsx(foe,{});break;case"memory":a=e.jsx(Pre,{});break;case"network":a=n?e.jsx(sre,{}):e.jsx(Dg,{});break;default:a=e.jsx(Dg,{})}let r=null;if(s)switch(s.type){case"agent":{r=e.jsx(Goe,{});break}case"journalist":r=e.jsx(Koe,{});break;case"spawn":r=null;break}return e.jsxs(Bee,{detailContent:r,terminalContent:e.jsx(rie,{}),children:[a,e.jsx(Voe,{})]})}function iie(){const t=k(n=>n.remoteHomedir),s=k(n=>n.setProjectDir);return e.jsxs("div",{className:"fixed inset-0 z-40 bg-surface-0 flex flex-col items-center justify-center gap-3",children:[e.jsx("img",{src:"/favicon.png",alt:"",className:"w-10 h-10 opacity-60"}),e.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Connected — choose a project directory to continue"}),e.jsx(gc,{open:!0,onOpenChange:()=>{},currentPath:t||"/home",homePath:t,onSelect:n=>s(n),mandatory:!0})]})}function lie(){const t=k(c=>c.connected),[s,n]=p.useState(!1),[a,r]=p.useState(!1);p.useEffect(()=>{const c=setTimeout(()=>n(!0),12e3);return()=>clearTimeout(c)},[]);async function l(){var c;if((c=window.groove)!=null&&c.reconnect){r(!0);try{await window.groove.reconnect()}catch{}r(!1)}window.location.reload()}return e.jsxs("div",{className:"h-screen bg-surface-0 flex flex-col items-center justify-center gap-4",children:[e.jsx("img",{src:"/favicon.png",alt:"",className:"w-10 h-10 opacity-60 animate-pulse"}),e.jsx("p",{className:"text-sm text-text-3 font-sans",children:a?"Re-establishing connection…":t?"Loading…":"Connecting to daemon…"}),s&&e.jsxs("div",{className:"flex flex-col items-center gap-2 mt-1",children:[e.jsx("p",{className:"text-xs text-text-4 font-sans max-w-xs text-center",children:"Still trying to reach the daemon. If you just woke your machine, the connection is re-establishing."}),e.jsx("button",{onClick:l,disabled:a,className:"px-3 py-1.5 rounded-md text-xs font-medium font-sans border border-accent/40 bg-accent/10 text-accent hover:bg-accent/20 disabled:opacity-50 transition-colors cursor-pointer",children:a?"Reconnecting…":"Reconnect"})]})]})}function cie(){const t=k(c=>c.connect),s=k(c=>c.hydrated),n=k(c=>c.tunneled),a=k(c=>c.onboardingComplete),r=k(c=>c.showProjectPicker);p.useEffect(()=>{t()},[t]),p.useEffect(()=>{async function c(){var x;if((x=window.groove)!=null&&x.getInstanceInfo){const h=await window.groove.getInstanceInfo();if(h!=null&&h.name){document.title=`${h.name} — Groove`;return}}const f=new URLSearchParams(window.location.search).get("instance");if(f){const h=f.replace(/[\x00-\x1F]/g,"").slice(0,50);document.title=`${h} — Groove`}else n?document.title="Remote — Groove":document.title="Groove"}c()},[n]);const l=p.useMemo(()=>{var c;return(c=window.groove)!=null&&c.openFolder?[{key:"o",meta:!0,handler:()=>window.groove.openFolder()}]:[]},[]);return pN(l),s?a?r&&n?e.jsx(Ff,{children:e.jsx(iie,{})}):r?e.jsxs(Ff,{children:[e.jsx(Hee,{}),e.jsx(SQ,{})]}):e.jsxs(Ff,{children:[e.jsx(oie,{}),e.jsx(SQ,{}),e.jsx(Lee,{}),e.jsx(Joe,{})]}):e.jsx(Ff,{children:e.jsx(_ee,{})}):e.jsx(lie,{})}oE.createRoot(document.getElementById("root")).render(e.jsx(p.StrictMode,{children:e.jsx(cie,{})}));