@polderlabs/bizar 5.4.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bizar-dash/dist/assets/{EnvVarsSection-DqvB8ZcJ.js → EnvVarsSection-DhLHZ5ua.js} +1 -1
- package/bizar-dash/dist/assets/{EnvVarsSection-DqvB8ZcJ.js.map → EnvVarsSection-DhLHZ5ua.js.map} +1 -1
- package/bizar-dash/dist/assets/{MobileChat-DRXP2ERQ.js → MobileChat-9UpvDP6-.js} +1 -1
- package/bizar-dash/dist/assets/{MobileChat-DRXP2ERQ.js.map → MobileChat-9UpvDP6-.js.map} +1 -1
- package/bizar-dash/dist/assets/{MobileSettings-CVW9VhEo.js → MobileSettings-BFmN9ZWR.js} +1 -1
- package/bizar-dash/dist/assets/{MobileSettings-CVW9VhEo.js.map → MobileSettings-BFmN9ZWR.js.map} +1 -1
- package/bizar-dash/dist/assets/{Toast-CcZVVN4i.js → Toast-BlcKl_dN.js} +1 -1
- package/bizar-dash/dist/assets/{Toast-CcZVVN4i.js.map → Toast-BlcKl_dN.js.map} +1 -1
- package/bizar-dash/dist/assets/{icons-OMEGx5KA.js → icons-CMPxNV8t.js} +124 -129
- package/bizar-dash/dist/assets/icons-CMPxNV8t.js.map +1 -0
- package/bizar-dash/dist/assets/{main-CMAGZouj.js → main-Dhrvp9Gt.js} +1 -1
- package/bizar-dash/dist/assets/{main-CMAGZouj.js.map → main-Dhrvp9Gt.js.map} +1 -1
- package/bizar-dash/dist/assets/mobile-DDY1lquG.js +1 -0
- package/bizar-dash/dist/assets/{mobile-XN2P7YfM.js.map → mobile-DDY1lquG.js.map} +1 -1
- package/bizar-dash/dist/assets/mobile-layout-BjkoHh1W.js +2 -0
- package/bizar-dash/dist/assets/mobile-layout-BjkoHh1W.js.map +1 -0
- package/bizar-dash/dist/assets/{mobile-layout-D6V-7WnA.css → mobile-layout-CJnZNLy3.css} +1 -1
- package/bizar-dash/dist/assets/{useSlashCommands-iyoW95UB.js → useSlashCommands-eFCiWHVt.js} +2 -2
- package/bizar-dash/dist/assets/{useSlashCommands-iyoW95UB.js.map → useSlashCommands-eFCiWHVt.js.map} +1 -1
- package/bizar-dash/dist/index.html +7 -7
- package/bizar-dash/dist/mobile.html +4 -4
- package/bizar-dash/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/bizar-dash/src/web/MobileApp.tsx +1 -10
- package/bizar-dash/src/web/styles/mobile-layout.css +7 -5
- package/bizar-dash/src/web/styles/settings.css +46 -0
- package/bizar-dash/tests/mobile-layout.test.tsx +36 -0
- package/package.json +1 -1
- package/bizar-dash/dist/assets/icons-OMEGx5KA.js.map +0 -1
- package/bizar-dash/dist/assets/mobile-XN2P7YfM.js +0 -1
- package/bizar-dash/dist/assets/mobile-layout-DqTxvXZp.js +0 -2
- package/bizar-dash/dist/assets/mobile-layout-DqTxvXZp.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ba=Object.defineProperty;var Ua=(s,t,a)=>t in s?Ba(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a;var ks=(s,t,a)=>Ua(s,typeof t!="symbol"?t+"":t,a);import{a as T,c as V,f as Ce,b as _e,S as oe,t as Zt,e as _a,p as Wa,d as xs,g as Ts,_ as qa,W as ea,A as Va,M as Ha}from"./mobile-layout-DqTxvXZp.js";import{r,j as e,a as sa,R as Oe,b as Ga}from"./react-vendor-Dn4wqh4Z.js";import{X as Ne,A as bt,R as de,F as Ka,H as Ya,a as Xa,C as ta,b as Fe,c as Ja,d as We,e as Xe,L as aa,M as Xs,B as Ye,f as Hs,S as Rs,g as De,h as Qa,i as He,j as Pe,P as ts,k as na,l as as,m as $s,n as Nt,o as Qe,p as ia,q as kt,r as ye,s as Za,t as ze,u as ra,v as Pt,T as ns,w as en,x as _s,G as sn,y as la,z as tn,D as gs,E as Te,I as qe,J as wt,K as ys,N as be,O as is,Q as Gs,U as rs,V as fs,W as pt,Y as an,Z as ke,_ as St,$ as Ct,a0 as ps,a1 as nn,a2 as Js,a3 as js,a4 as rn,a5 as Es,a6 as ls,a7 as oa,a8 as ca,a9 as As,aa as ln,ab as Ls,ac as on,ad as cn,ae as dn,af as Qs,ag as mn,ah as un,ai as hn,aj as xn,ak as pn,al as gn,am as Ft,an as da,ao as zt,ap as fn,aq as jn,ar as ma,as as vn,at as yn,au as bn,av as Nn,aw as kn,ax as wn,ay as Sn,az as gt,aA as Tt,aB as Rt,aC as os,aD as ua,aE as vs,aF as Cn,aG as zn,aH as Ks,aI as Tn,aJ as Ms,aK as Rn,aL as $n,aM as ha,aN as xa,aO as Is,aP as ft,aQ as $t,aR as pa,aS as xe,aT as An,aU as Mn,aV as ga,aW as In,aX as En,aY as Ln,aZ as fa,a_ as et,a$ as ja,b0 as At,b1 as Dn,b2 as Pn,b3 as Fn,b4 as va,b5 as On,b6 as Bn,b7 as Un,b8 as _n,b9 as ya}from"./icons-OMEGx5KA.js";import{B as $,C as G,a as te,b as ne,A as Wn,U as qn,G as Vn,E as Hn,T as Gn,S as Kn,H as Yn,c as Xn}from"./EnvVarsSection-DqvB8ZcJ.js";import{u as re,T as Jn}from"./Toast-CcZVVN4i.js";import{V as Mt,C as Qn,u as Zn,a as ei,b as si,c as ti}from"./useSlashCommands-iyoW95UB.js";import{M as ba,r as Na}from"./markdown-C6mXtQxD.js";import"./vendor-CeHGtduv.js";const ka=r.createContext(null),ai=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function $e(){const s=r.useContext(ka);return s||{open:()=>"",close:()=>{},isModalOpen:!1}}function ni({children:s}){const[t,a]=r.useState([]),i=r.useCallback(c=>{a(o=>{if(!c)return o.slice(0,-1);const l=o.findIndex(x=>x.id===c);return l===-1||l!==o.length-1?o:o.slice(0,-1)})},[]),n=r.useCallback(c=>{const o=`m${Math.random().toString(36).slice(2,9)}`;return a(l=>[...l,{...c,id:o}]),o},[]);return r.useEffect(()=>{if(t.length===0)return;const c=o=>{o.key==="Escape"&&(o.stopPropagation(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t.length,i]),e.jsxs(ka.Provider,{value:{open:n,close:i,isModalOpen:t.length>0},children:[s,typeof document<"u"&&sa.createPortal(e.jsx("div",{className:"modal-stack","aria-hidden":t.length===0,children:t.map((c,o)=>e.jsx(ii,{modal:c,onClose:()=>{var l;(l=c.onClose)==null||l.call(c),i(c.id)},depth:o},c.id))}),document.body)]})}function ii({modal:s,onClose:t,depth:a}){const i=r.useRef(null),n=r.useRef(null),c=r.useId(),o=()=>{const l=i.current;return l?Array.from(l.querySelectorAll(ai)).filter(x=>!x.hasAttribute("disabled")&&x.tabIndex!==-1):[]};return r.useEffect(()=>{var p;n.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(p=o()[0]??i.current)==null||p.focus();const x=u=>{var j,k,z;if(u.key!=="Tab")return;const d=o();if(d.length===0){u.preventDefault(),(j=i.current)==null||j.focus();return}const m=d[0],h=d[d.length-1],g=document.activeElement instanceof HTMLElement?document.activeElement:null;if(u.shiftKey){(!g||g===m||!((k=i.current)!=null&&k.contains(g)))&&(u.preventDefault(),h.focus());return}(!g||g===h||!((z=i.current)!=null&&z.contains(g)))&&(u.preventDefault(),m.focus())};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x);const u=n.current;u&&u.isConnected&&u.focus()}},[]),e.jsx("div",{className:"modal-backdrop",onClick:l=>{l.stopPropagation(),l.target===l.currentTarget&&t()},style:a>0?{background:"rgba(0,0,0,0.4)"}:void 0,children:e.jsxs("div",{ref:i,className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":s.title?c:void 0,tabIndex:-1,onClick:l=>l.stopPropagation(),style:s.width?{maxWidth:s.width}:void 0,children:[s.title&&e.jsxs("header",{className:"modal-header",children:[e.jsx("h2",{id:c,className:"modal-title",children:s.title}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:e.jsx(Ne,{size:16})})]}),e.jsx("div",{className:"modal-body",children:s.children}),s.footer&&e.jsx("footer",{className:"modal-footer",children:s.footer})]})})}const ri=200,li=5*60*1e3,ss=new Map;function oi(s){const t=ss.get(s);return t?Date.now()-t.ts>li?(ss.delete(s),null):t.data:null}function st(s,t){ss.size>=ri&&[...ss.entries()].sort((i,n)=>i[1].ts-n[1].ts).slice(0,50).map(([i])=>i).forEach(i=>ss.delete(i)),ss.set(s,{data:t,ts:Date.now()})}function ci(s){if(!s||s==="/")return[{label:"/",path:"/"}];const t=s.split("/").filter(Boolean),a=[];let i="";for(let n=0;n<t.length;n++)i+="/"+t[n],a.push({label:t[n],path:i});return a}function di(s){return[...s].sort((t,a)=>t.isDir!==a.isDir?t.isDir?-1:1:t.name.localeCompare(a.name,void 0,{sensitivity:"base"}))}function mi(s){const t=s.trim();return t?t!==s?{ok:!1,reason:"Name cannot have leading or trailing whitespace."}:t==="."?{ok:!1,reason:"Name cannot be '.'."}:t===".."?{ok:!1,reason:"Name cannot be '..'."}:t.startsWith("-")?{ok:!1,reason:"Name cannot start with '-'."}:t.length>255?{ok:!1,reason:"Name cannot be longer than 255 characters."}:/[/\0:*?"<>|]/.test(t)?{ok:!1,reason:'Name cannot contain / \\ : * ? " < > |'}:{ok:!0}:{ok:!1,reason:"Name cannot be empty."}}function wa({value:s,onChange:t,initialPath:a,projectsDirectory:i,rootLabel:n="Home",height:c=360}){const[o,l]=r.useState(a??i??""),[x,p]=r.useState(new Set),[u,d]=r.useState(-1),[m,h]=r.useState(null),[g,j]=r.useState({}),[k,z]=r.useState(!1),[N,S]=r.useState(null),[E,v]=r.useState(!1),[b,w]=r.useState(""),[f,L]=r.useState(null),[R,y]=r.useState(!1),A=r.useRef(null),P=r.useCallback(async I=>{try{const Q=oi(I);if(Q)return Q;const U=await T.get("/fs?path="+encodeURIComponent(I));return st(I,U),U}catch{return null}},[]),C=r.useCallback(async I=>{var Q;z(!0),S(null);try{const U=await T.get("/fs?path="+encodeURIComponent(I));st(I,U),h(U),d(-1)}catch(U){const le=((Q=U.data)==null?void 0:Q.message)??U.message??"Failed to load directory";S(le)}finally{z(!1)}},[]);r.useEffect(()=>{o?C(o):T.get("/fs").then(I=>{st("",I),h(I),l(I.path),I.path!==s&&t(I.path)}).catch(()=>{S("Could not determine home directory."),z(!1)})},[o]),r.useEffect(()=>{s&&s!==o&&l(s)},[s]);const D=m?di(m.entries):[],Y=D.filter(I=>I.isDir),O=D,J=I=>{I.isDir&&(l(I.path),t(I.path))},ae=()=>{m!=null&&m.parent&&(l(m.parent),t(m.parent))},ee=I=>{I!==o&&(l(I),t(I))},F=async()=>{const I=await P("");I&&(l(I.path),t(I.path))},H=async()=>{if(!i)return;const I=await P(i);I&&(l(I.path),t(I.path))},K=()=>{v(!0),w(""),L(null),setTimeout(()=>{var I;return(I=A.current)==null?void 0:I.focus()},0)},B=()=>{v(!1),w(""),L(null)},Z=async()=>{var Q;const I=mi(b);if(!I.ok){L(I.reason);return}y(!0),L(null);try{const U=await T.post("/fs/mkdir",{parent:o,name:b.trim()});ss.delete(o),await C(o),t(U.path),v(!1),w("")}catch(U){const le=U;le.status===409?L(`A folder named "${b.trim()}" already exists.`):L(((Q=le.data)==null?void 0:Q.message)??U.message??"Failed to create folder.")}finally{y(!1)}},he=I=>{I.key==="Enter"?(I.preventDefault(),Z()):I.key==="Escape"&&(I.preventDefault(),B())},we=I=>{p(Q=>{const U=new Set(Q);return U.has(I)?U.delete(I):U.add(I),U}),g[I]||P(I).then(Q=>{Q&&j(U=>({...U,[I]:Q.entries.filter(le=>le.isDir)}))})},W=I=>{if(!m)return;const Q=O.filter(q=>q.isDir),U=O.filter(q=>!q.isDir),le=[...Q,...U];if(I.key==="ArrowDown")I.preventDefault(),d(q=>Math.min(q+1,le.length-1));else if(I.key==="ArrowUp")I.preventDefault(),d(q=>Math.max(q-1,0));else if(I.key==="Enter"||I.key===" "){I.preventDefault();const q=le[u];q&&(I.key==="Enter"&&q.isDir?J(q):q.isDir&&t(q.path))}else I.key==="Backspace"&&(I.preventDefault(),ae())},se=ci((m==null?void 0:m.path)??o??"/"),ie=m==null?void 0:m.parent,me=ie!=null,_=o.split("/").filter(Boolean).at(-1)??"/";return e.jsxs("div",{className:"file-browser",onKeyDown:W,tabIndex:-1,children:[e.jsx("div",{className:"file-browser-breadcrumb",role:"navigation","aria-label":"Path breadcrumb",children:se.map((I,Q)=>e.jsxs("span",{className:"file-browser-breadcrumb-item",children:[Q>0&&e.jsx("span",{className:"file-browser-breadcrumb-sep","aria-hidden":!0,children:"/"}),e.jsx("button",{type:"button",className:"file-browser-breadcrumb-btn",onClick:()=>ee(I.path),title:I.path,children:Q===0?I.path==="/"?"/":n:I.label})]},I.path))}),e.jsxs("div",{className:"file-browser-toolbar",children:[e.jsxs("div",{className:"file-browser-toolbar-left",children:[e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:ae,disabled:!me,title:"Go up (Backspace)","aria-label":"Go up one level",children:e.jsx(bt,{size:13})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:()=>C(o),disabled:k,title:"Refresh","aria-label":"Refresh",children:e.jsx(de,{size:13,className:k?"spin":""})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:K,title:"New folder","aria-label":"Create new folder",children:e.jsx(Ka,{size:13})}),e.jsxs("div",{className:"file-browser-chips",children:[e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:F,children:[e.jsx(Ya,{size:11})," ",n]}),i&&e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:H,title:i,children:[e.jsx(Xa,{size:11})," ",i.split("/").filter(Boolean).at(-1)??"Projects"]})]})]}),E?e.jsxs("div",{className:"file-browser-mkdir",children:[e.jsx("input",{ref:A,type:"text",className:"file-browser-mkdir-input",placeholder:"Folder name",value:b,onChange:I=>{w(I.target.value),L(null)},onKeyDown:he,"aria-label":"New folder name","aria-invalid":f?"true":void 0,"aria-describedby":f?"mkdir-error":void 0,disabled:R,maxLength:255}),f?e.jsx("span",{id:"mkdir-error",className:"file-browser-mkdir-error",role:"alert",children:f}):e.jsx("span",{className:"file-browser-mkdir-hint",children:"Enter to create, Esc to cancel"})]}):e.jsx("span",{className:"file-browser-count-hint",children:k?"…":`${D.length} in ${_}`})]}),N&&e.jsxs("div",{className:"file-browser-error",children:[e.jsx(ta,{size:13}),e.jsx("span",{children:N}),e.jsx("button",{type:"button",className:"file-browser-retry",onClick:()=>C(o),children:"Retry"})]}),e.jsxs("div",{className:"file-browser-body",style:{height:c},children:[e.jsx("div",{className:"file-browser-pane file-browser-tree","aria-label":"Folder tree",children:k&&!m?e.jsx(ui,{}):e.jsx(Sa,{path:o,entries:Y,expanded:x,childrenMap:g,onToggle:we,onNavigate:J,level:0})}),e.jsxs("div",{className:"file-browser-pane file-browser-flat","aria-label":"Directory contents",children:[e.jsxs("div",{className:"file-browser-flat-header",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Type"})]}),k&&!m?e.jsx(hi,{}):e.jsxs(e.Fragment,{children:[(m==null?void 0:m.truncated)&&e.jsxs("div",{className:"file-browser-truncated-banner",role:"status",children:["Showing first 500 of ",m.totalEntries," entries. Navigate into a subfolder to see more."]}),O.length===0?e.jsx("div",{className:"file-browser-empty",children:"This folder is empty"}):e.jsx("div",{className:"file-browser-flat-list",children:O.map((I,Q)=>{const U=I.isDir,le=Q===u,q=I.path===s;return e.jsxs("div",{role:"option","aria-selected":q,className:["file-browser-row",U?"file-browser-row--dir":"file-browser-row--file",le&&"file-browser-row--selected",q&&U&&"file-browser-row--active",!U&&"file-browser-row--disabled"].filter(Boolean).join(" "),onClick:()=>{U&&(d(Q),t(I.path))},onDoubleClick:()=>{U&&J(I)},title:I.path,children:[e.jsx("span",{className:"file-browser-row-icon",children:U?e.jsx(Fe,{size:13}):e.jsx(Ja,{size:13})}),e.jsx("span",{className:"file-browser-row-name",children:I.name}),e.jsx("span",{className:"file-browser-row-type",children:U?"Folder":""})]},I.path)})})]})]})]}),e.jsxs("div",{className:"file-browser-footer-hint",children:["Select a folder, then click Add. Use ",e.jsx("kbd",{children:"↑"})," ",e.jsx("kbd",{children:"↓"})," to navigate, ",e.jsx("kbd",{children:"Enter"})," to confirm."]})]})}function Sa({path:s,entries:t,expanded:a,childrenMap:i,onToggle:n,onNavigate:c,level:o}){return e.jsx("ul",{className:"file-browser-tree-list",role:"group",children:t.map(l=>{const x=a.has(l.path),p=i[l.path]??[];return e.jsxs("li",{className:"file-browser-tree-node",children:[e.jsxs("div",{className:["file-browser-tree-row",x&&"file-browser-tree-row--expanded"].filter(Boolean).join(" "),style:{paddingLeft:`${o*16+8}px`},children:[e.jsx("button",{type:"button",className:"file-browser-tree-toggle",onClick:u=>{u.stopPropagation(),n(l.path)},"aria-label":x?"Collapse":"Expand",children:(p.length>0,x?e.jsx(We,{size:11}):e.jsx(Xe,{size:11}))}),e.jsxs("button",{type:"button",className:"file-browser-tree-name",onClick:()=>c(l),title:l.path,children:[e.jsx(Fe,{size:12}),e.jsx("span",{children:l.name})]})]}),x&&p.length>0&&e.jsx(Sa,{path:l.path,entries:p,expanded:a,childrenMap:i,onToggle:n,onNavigate:c,level:o+1})]},l.path)})})}function ui(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[80,60,90,55,70].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}function hi(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[60,90,70,50,80,65].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}const jt=[{id:"overview",label:"Overview",icon:aa},{id:"chat",label:"Chat",icon:Xs},{id:"agents",label:"Agents",icon:Ye},{id:"artifacts",label:"Glyphs",icon:Hs},{id:"tasks",label:"Tasks",icon:Rs},{id:"activity",label:"Activity",icon:De},{id:"background",label:"Active",icon:Qa},{id:"skills",label:"Skills",icon:He},{id:"memory",label:"Memory",icon:Pe},{id:"mods",label:"Mods",icon:ts},{id:"marketplace",label:"Marketplace",icon:na},{id:"schedules",label:"Schedules",icon:as},{id:"plugins",label:"Plugins",icon:ts},{id:"history",label:"History",icon:$s},{id:"minimax",label:"Usage",icon:Nt},{id:"eval",label:"Eval",icon:Qe},{id:"doctor",label:"Doctor",icon:ia},{id:"settings",label:"Settings",icon:kt}];function xi({activeTab:s,onTabChange:t,wsStatus:a,version:i,activeProject:n,projects:c,onProjectChange:o,onProjectsRefresh:l,onOpenSearch:x,settings:p,rightSlot:u,notificationsSlot:d,showTabs:m=!0,extraTabs:h}){return e.jsxs("header",{className:"topbar",children:[e.jsxs("div",{className:"topbar-row",children:[e.jsxs("div",{className:"brand",children:[e.jsx("span",{className:"brand-logo","aria-hidden":"true",children:"ᛒ"}),e.jsx("span",{className:"brand-title",children:"Bizar"}),e.jsx("span",{className:"brand-version",children:i})]}),e.jsx(pi,{activeProject:n,projects:c,onChange:o,onRefresh:l,settings:p??null}),e.jsxs("button",{type:"button",className:"topbar-search",onClick:x,title:"Search (Ctrl/Cmd+K)","aria-label":"Open search",children:[e.jsx(ye,{size:14}),e.jsx("span",{className:"muted",children:"Search…"}),e.jsx("kbd",{children:"⌘K"})]}),e.jsx("div",{className:"topbar-spacer"}),e.jsxs("div",{className:"topbar-right",children:[d,u,e.jsxs("div",{className:V("ws-status",`ws-${a}`),title:`WebSocket: ${a}`,children:[e.jsx("span",{className:"ws-dot"}),e.jsx("span",{className:"ws-label",children:a})]})]})]}),m&&e.jsxs("nav",{className:"tabs-row",role:"tablist","aria-label":"Primary tabs",children:[jt.map(g=>{const j=g.icon,k=g.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":k,className:V("tab",k&&"tab-active"),onClick:()=>t(g.id),title:g.label,children:[e.jsx(j,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:g.label}),g.id==="settings"&&k&&e.jsx("span",{className:"settings-mode-indicator",title:"Settings mode active",children:e.jsx(Za,{size:12})})]},g.id)}),h&&h.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tab-separator","aria-hidden":"true"}),h.map(g=>{const j=g.icon,k=g.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":k,className:V("tab","tab-mod",k&&"tab-active"),onClick:()=>t(g.id),title:`${g.label} (mod)`,children:[e.jsx(j,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:g.label}),e.jsx("span",{className:"tab-badge",children:"mod"})]},g.id)})]})]})]})}function pi({activeProject:s,projects:t,onChange:a,onRefresh:i,settings:n}){const[c,o]=r.useState(!1),l=$e();r.useEffect(()=>{if(!c)return;const p=()=>o(!1);return document.addEventListener("click",p),()=>document.removeEventListener("click",p)},[c]);const x=()=>{l.open({title:"Add project",children:e.jsx(gi,{settings:n,onAdd:async(p,u)=>{try{await T.post("/projects",{path:p,name:u}),i(),o(!1),l.close()}catch(d){alert(`Add failed: ${d.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx($,{variant:"ghost",onClick:()=>l.close(),children:"Cancel"})})})};return e.jsxs("div",{className:"project-selector",onClick:p=>p.stopPropagation(),children:[e.jsxs("button",{type:"button",className:"project-selector-btn",onClick:()=>o(p=>!p),title:"Switch active project","aria-haspopup":"menu","aria-expanded":c,children:[e.jsx(Fe,{size:14}),e.jsx("span",{className:"project-selector-name",children:(s==null?void 0:s.name)||"(no project)"}),e.jsx(We,{size:12})]}),c&&e.jsxs("div",{className:"project-selector-menu",children:[e.jsxs("div",{className:"project-selector-menu-head",children:[e.jsxs("span",{className:"muted",children:[t.length," project",t.length===1?"":"s"]}),e.jsxs("div",{className:"project-selector-menu-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:i,title:"Refresh","aria-label":"Refresh projects",children:e.jsx(de,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:x,title:"Add project","aria-label":"Add project",children:e.jsx(ze,{size:12})})]})]}),e.jsxs("ul",{className:"project-selector-list",children:[t.length===0&&e.jsx("li",{className:"muted project-selector-empty",children:"No projects. Add one to start."}),t.map(p=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:V("project-selector-item",(s==null?void 0:s.id)===p.id&&"active"),onClick:()=>{a(p.id),o(!1)},children:[e.jsx("span",{className:"project-selector-item-name",children:p.name}),e.jsx("span",{className:"project-selector-item-status",children:p.status})]})},p.id))]})]})]})}function gi({settings:s,onAdd:t}){var d,m;const[a,i]=r.useState(((d=s==null?void 0:s.dashboard)==null?void 0:d.projectsDirectory)??""),[n,c]=r.useState(""),[o,l]=r.useState(!1),[x,p]=r.useState(null),u=async()=>{var h;if(a){l(!0),p(null);try{await T.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(g){const j=g;j.status===404?p("That folder no longer exists. Pick another."):p(((h=j.data)==null?void 0:h.message)??g.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(wa,{value:a,onChange:h=>{i(h),p(null)},projectsDirectory:(m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory,height:320}),x&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:x}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"topbar-add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"topbar-add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:h=>c(h.target.value)})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs($,{variant:"primary",onClick:u,disabled:!a||o,children:[o?e.jsx("span",{className:"btn-spinner"}):null,o?"Checking…":"Add"]})})]})}const fi=[{label:"General",sections:[{id:"theme",label:"Theme",icon:ra},{id:"layout",label:"Layout",icon:Pt},{id:"general",label:"General",icon:Pt}]},{label:"Core",sections:[{id:"env-vars",label:"Env Vars",icon:ns},{id:"providers",label:"Providers",icon:en},{id:"memory",label:"Memory",icon:Pe},{id:"system-llm",label:"System LLM",icon:_s}]},{label:"Experience",sections:[{id:"updates",label:"Updates",icon:de},{id:"skills",label:"Skills",icon:He},{id:"headroom",label:"Headroom",icon:sn}]},{label:"Data",sections:[{id:"backup",label:"Backup",icon:la}]}];function ji({activeSection:s,onSectionChange:t,onExitSettings:a}){return e.jsxs("div",{className:"settings-nav-root","aria-label":"Settings sections",children:[e.jsxs("button",{type:"button",className:"settings-nav-back",onClick:a,"aria-label":"Exit settings",children:[e.jsx(bt,{size:14}),e.jsx("span",{children:"Back"})]}),e.jsx("div",{className:"settings-nav-divider","aria-hidden":"true"}),fi.map(i=>e.jsxs("div",{className:"settings-nav-group",children:[e.jsx("div",{className:"settings-nav-group-label",children:i.label}),i.sections.map(n=>{const c=n.icon,o=s===n.id;return e.jsxs("button",{type:"button",className:V("settings-nav-item",o&&"settings-nav-item-active"),onClick:()=>t(o?null:n.id),"aria-current":o?"page":void 0,children:[c&&e.jsx(c,{size:14,className:"settings-nav-item-icon","aria-hidden":!0}),e.jsx("span",{className:"settings-nav-item-label",children:n.label}),o&&e.jsx(Xe,{size:12,className:"settings-nav-item-chevron","aria-hidden":!0})]},n.id)})]},i.label))]})}function vi({tabs:s,activeTab:t,onTabChange:a,settingsMode:i,settingsActiveSection:n,onSettingsSectionChange:c,onExitSettings:o}){if(i)return e.jsx("aside",{className:"sidebar sidebar-settings-mode","aria-label":"Settings navigation",children:e.jsx(ji,{activeSection:n??null,onSectionChange:c??(()=>{}),onExitSettings:o??(()=>{})})});const l=s.filter(p=>!p.isMod),x=s.filter(p=>p.isMod);return e.jsx("aside",{className:"sidebar","aria-label":"Primary navigation",children:e.jsxs("nav",{className:"sidebar-nav",role:"tablist",children:[l.map(p=>{const u=p.icon,d=p.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:V("sidebar-tab",d&&"sidebar-tab-active"),onClick:()=>a(p.id),title:p.label,children:[e.jsx(u,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:p.label})]},p.id)}),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sidebar-section-divider","aria-hidden":"true"}),e.jsx("div",{className:"sidebar-section-label",children:"Mods"}),x.map(p=>{const u=p.icon,d=p.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:V("sidebar-tab","sidebar-tab-mod",d&&"sidebar-tab-active"),onClick:()=>a(p.id),title:`${p.label} (mod)`,children:[e.jsx(u,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:p.label})]},p.id)})]})]})})}const tt=[{id:"all",label:"All"},{id:"projects",label:"Projects"},{id:"agents",label:"Agents"},{id:"tasks",label:"Tasks"},{id:"mods",label:"Mods"},{id:"schedules",label:"Schedules"},{id:"commands",label:"Commands"},{id:"settings",label:"Settings"}],Ot={all:null,projects:"project",agents:"agent",tasks:"task",mods:"mod",schedules:"schedule",commands:"command",settings:"setting"};function yi({open:s,onClose:t,onSelect:a}){const i=re(),[n,c]=r.useState(""),[o,l]=r.useState("all"),[x,p]=r.useState([]),[u,d]=r.useState(!1),[m,h]=r.useState(0),g=r.useRef(null),j=r.useRef(null);if(r.useEffect(()=>{let S;return s&&(j.current=document.activeElement instanceof HTMLElement?document.activeElement:null,c(""),p([]),h(0),S=window.setTimeout(()=>{var E;return(E=g.current)==null?void 0:E.focus()},30)),()=>{if(S&&window.clearTimeout(S),!s)return;const E=j.current;E&&E.isConnected&&E.focus()}},[s]),r.useEffect(()=>{if(!s)return;if(!n.trim()){p([]),h(0);return}let S=!1;d(!0);const E=setTimeout(()=>{T.get(`/search?q=${encodeURIComponent(n)}&scope=${o}`).then(v=>{S||(p(v.results||[]),h(0))}).catch(v=>{S||i.error(`Search failed: ${v.message}`)}).finally(()=>!S&&d(!1))},150);return()=>{S=!0,clearTimeout(E)}},[n,o,s,i]),!s)return null;const k={};for(const S of x){const E=S.type.toLowerCase();k[E]=k[E]||[],k[E].push(S)}const z=[];for(const S of tt.map(E=>E.id)){const E=Ot[S];E&&k[E]&&z.push(...k[E])}const N=S=>{if(S.key==="Escape")t();else if(S.key==="ArrowDown"){if(S.preventDefault(),z.length===0)return;h(E=>Math.min(E+1,z.length-1))}else if(S.key==="ArrowUp"){if(S.preventDefault(),z.length===0)return;h(E=>Math.max(E-1,0))}else S.key==="Enter"&&z[m]&&(S.preventDefault(),a(z[m]),t())};return e.jsx("div",{className:"search-modal-backdrop",onClick:t,children:e.jsxs("div",{className:"search-modal",role:"dialog","aria-modal":"true","aria-labelledby":"search-modal-title",onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{className:"search-modal-head",role:"search",children:[e.jsx(ye,{size:14,"aria-hidden":!0}),e.jsx("span",{id:"search-modal-title",className:"sr-only",children:"Search"}),e.jsx("input",{ref:g,className:"search-modal-input",placeholder:"Search tasks, agents, settings, projects…",value:n,onChange:S=>c(S.target.value),onKeyDown:N,"aria-label":"Search"}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:e.jsx(Ne,{size:14})})]}),e.jsx("div",{className:"search-modal-scopes",role:"tablist","aria-label":"Search scope",children:tt.map(S=>e.jsx("button",{type:"button",role:"tab","aria-selected":o===S.id,className:V("search-scope",o===S.id&&"search-scope-active"),onClick:()=>l(S.id),children:S.label},S.id))}),e.jsxs("div",{className:"search-modal-body",children:[u&&e.jsx("div",{className:"muted",children:"Searching…"}),!u&&n&&z.length===0&&e.jsx("div",{className:"muted",children:"No results."}),!u&&!n&&e.jsx("div",{className:"muted",children:"Type to search…"}),tt.map(S=>{const E=Ot[S.id];if(!E)return null;const v=k[E];return!v||v.length===0?null:e.jsxs("div",{className:"search-group",children:[e.jsx("div",{className:"search-group-head",children:S.label}),v.map(b=>{const w=z.indexOf(b);return e.jsxs("button",{type:"button",className:V("search-result",w===m&&"search-result-active"),onMouseEnter:()=>h(w),onClick:()=>{a(b),t()},children:[e.jsx("span",{className:"search-result-type",children:b.type}),e.jsx("span",{className:"search-result-label",children:bi(b)})]},`${b.type}-${w}`)})]},S.id)})]}),e.jsx("div",{className:"search-modal-foot",children:e.jsx("span",{className:"muted",children:"↑↓ navigate · ↵ open · esc close"})})]})})}function bi(s){const t=s.item||{};if(s.type==="project")return`${t.name} — ${t.path}`;if(s.type==="agent")return`${t.name} — ${t.description||t.model||""}`;if(s.type==="task")return`${t.title} — ${t.status||""}`;if(s.type==="mod")return`${t.name} v${t.version} — ${t.description||""}`;if(s.type==="schedule")return`${t.name} (${t.type}: ${t.schedule})`;if(s.type==="command")return`${t.name} — ${t.description||""}`;if(s.type==="setting"){const a=t.value===null||t.value===void 0?"":typeof t.value=="string"?` = ${t.value}`:` = ${JSON.stringify(t.value)}`;return`${t.label}${a} — ${t.desc||""}`.trim()}return JSON.stringify(t).slice(0,80)}const Ni={info:wt,success:qe,warning:Te,error:ta};function ki({onCountChange:s,wsSubscribe:t}){const a=re(),[i,n]=r.useState(!1),[c,o]=r.useState([]),[l,x]=r.useState(null),[p,u]=r.useState(!1),d=r.useRef(null),m=r.useRef(0),h=async()=>{var N;try{u(!0);const S=await T.get("/notifications?limit=200");o(S.notifications||[]),x(S.stats||null),m.current=((N=S.stats)==null?void 0:N.unread)||0,s==null||s(m.current)}catch(S){console.warn("[notifications] reload failed:",S.message)}finally{u(!1)}};r.useEffect(()=>{h()},[]),r.useEffect(()=>t?t(S=>{if(S.type==="notification:new"){const E=S.notification;o(v=>[E,...v.filter(b=>b.id!==E.id)]),E.read||(m.current+=1,x(v=>v?{...v,unread:(v.unread||0)+1}:{total:1,unread:1,lastTs:E.ts,counts:{[E.severity||"info"]:1}}),s==null||s(m.current))}else S.type==="notifications:change"&&h()}):void 0,[t]),r.useEffect(()=>{if(!i)return;const N=E=>{d.current&&(d.current.contains(E.target)||n(!1))},S=E=>{E.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",N),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",S)}},[i]);const g=async()=>{try{await T.post("/notifications/read-all",{}),o(N=>N.map(S=>({...S,read:!0}))),x(N=>N&&{...N,unread:0}),m.current=0,s==null||s(0),a.success("All notifications marked as read.",1500)}catch(N){a.error(`Failed: ${N.message}`)}},j=async N=>{try{await T.post(`/notifications/${encodeURIComponent(N)}/read`,{}),o(S=>S.map(E=>E.id===N?{...E,read:!0}:E)),x(S=>S&&{...S,unread:Math.max(0,(S.unread||1)-1)}),m.current=Math.max(0,m.current-1),s==null||s(m.current)}catch(S){a.error(`Failed: ${S.message}`)}},k=async N=>{try{await T.del(`/notifications/${encodeURIComponent(N)}`),o(S=>{const E=S.find(v=>v.id===N);return E&&!E.read&&(m.current=Math.max(0,m.current-1),x(v=>v&&{...v,unread:Math.max(0,v.unread-1)}),s==null||s(m.current)),S.filter(v=>v.id!==N)})}catch(S){a.error(`Failed: ${S.message}`)}},z=(l==null?void 0:l.unread)||0;return e.jsxs("div",{className:"notifications-root",ref:d,children:[e.jsxs("button",{type:"button",className:V("topbar-icon-btn notifications-bell",i&&"is-open"),onClick:()=>n(N=>!N),title:"Notifications","aria-label":"Notifications","aria-haspopup":"true","aria-expanded":i,children:[e.jsx(tn,{size:16}),z>0&&e.jsx("span",{className:"notifications-badge",children:z>99?"99+":z})]}),i&&e.jsxs("div",{className:"notifications-panel",role:"dialog","aria-label":"Notifications",children:[e.jsxs("header",{className:"notifications-panel-head",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Notifications"}),z>0&&e.jsxs("span",{className:"muted text-sm",children:[" · ",z," unread"]})]}),e.jsxs("div",{className:"notifications-panel-head-actions",children:[e.jsxs($,{size:"sm",variant:"ghost",onClick:g,disabled:z===0,children:[e.jsx(gs,{size:12})," Mark all read"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>n(!1),"aria-label":"Close",title:"Close",children:e.jsx(Ne,{size:14})})]})]}),e.jsx("div",{className:"notifications-list",children:p&&c.length===0?e.jsx("div",{className:"notifications-empty muted",children:"Loading…"}):c.length===0?e.jsx("div",{className:"notifications-empty muted",children:"No notifications yet."}):c.map(N=>{const S=Ni[N.severity]||wt;return e.jsxs("div",{className:V("notification-item",!N.read&&"is-unread",`severity-${N.severity}`),children:[e.jsx(S,{size:14,className:`notification-icon severity-${N.severity}`}),e.jsxs("div",{className:"notification-body",children:[N.title&&e.jsx("div",{className:"notification-title",children:N.title}),e.jsx("div",{className:"notification-msg",children:N.message}),e.jsxs("div",{className:"notification-meta muted",children:[e.jsx("span",{className:"mono",children:N.source}),e.jsx("span",{children:"·"}),e.jsx("span",{children:Ce(N.ts)})]})]}),e.jsxs("div",{className:"notification-actions",children:[!N.read&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>j(N.id),title:"Mark as read","aria-label":"Mark as read",children:e.jsx(gs,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",onClick:()=>k(N.id),title:"Remove","aria-label":"Remove",children:e.jsx(Ne,{size:12})})]})]},N.id)})}),e.jsx("footer",{className:"notifications-panel-foot",children:e.jsx("span",{className:"muted text-sm",children:l?`${l.total} total · last ${Ce(l.lastTs||new Date().toISOString())}`:""})})]})]})}function wi({data:s,onClose:t}){const a=s==null?void 0:s.enabled;s==null||s.previousEnabled;const i=s==null?void 0:s.mode,n=s==null?void 0:s.defaultTemplate,c=s==null?void 0:s.lastUsedSlug,o=i==="toggle";return e.jsxs("div",{children:[o?e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Visual plan mode has been ",e.jsx("strong",{children:a?"enabled":"disabled"}),".",a?" The agent will create a plan and wait for your feedback on complex tasks.":" The agent will work without a visual plan canvas."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:8,fontWeight:600},children:["Visual Plan: ",e.jsx("span",{style:{color:a?"var(--color-success)":"var(--color-muted)"},children:a?"ON":"OFF"})]}),e.jsx("p",{style:{lineHeight:1.6,color:"var(--color-muted)",fontSize:13},children:"When enabled, the agent creates a visual plan and waits for your feedback before proceeding with complex tasks."}),n&&e.jsxs("p",{style:{marginTop:8,fontSize:13,color:"var(--color-muted)"},children:["Default template: ",e.jsx("code",{children:n})]}),c&&e.jsxs("p",{style:{fontSize:13,color:"var(--color-muted)"},children:["Last used plan: ",e.jsx("code",{children:c})]}),e.jsxs("p",{style:{marginTop:12,fontSize:13,color:"var(--color-muted)"},children:["Use ",e.jsx("code",{children:"/visual-plan on"})," or ",e.jsx("code",{children:"/visual-plan off"})," to toggle."]})]}),e.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:e.jsx($,{variant:"ghost",onClick:t,children:"Close"})})]})}const Si=["blank","feature-design","bug-investigation","decision-record","horizontal","vertical"];function Ci({data:s,onClose:t}){const a=(s==null?void 0:s.templates)??Si,i=(s==null?void 0:s.defaultTemplate)??"blank",[n,c]=r.useState(""),[o,l]=r.useState(i),[x,p]=r.useState(!1),[u,d]=r.useState(null),m=async()=>{if(!n.trim()){d("Slug is required.");return}if(!/^[a-z0-9][a-z0-9-]{0,63}$/.test(n)){d("Invalid slug. Use lowercase letters, numbers, and hyphens. Must start with an alphanumeric character.");return}p(!0),d(null);try{await T.post("/artifacts",{slug:n,template:o}),t()}catch(h){d(h.message),p(!1)}};return e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:["Create a new visual plan. Plans are stored in ",e.jsx("code",{children:"artifacts/"})," in your worktree."]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-slug",children:"Plan slug"}),e.jsx("input",{id:"plan-slug",className:"input",type:"text",placeholder:"e.g. my-feature",value:n,onChange:h=>{c(h.target.value),d(null)},autoFocus:!0})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-template",children:"Template"}),e.jsx("select",{id:"plan-template",className:"select",value:o,onChange:h=>l(h.target.value),children:a.map(h=>e.jsx("option",{value:h,children:h},h))})]}),u&&e.jsx("p",{style:{marginBottom:12,color:"var(--color-danger)",fontSize:13},children:u}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx($,{variant:"ghost",onClick:t,disabled:x,children:"Cancel"}),e.jsx($,{variant:"primary",onClick:m,disabled:x||!n.trim(),children:x?"Creating…":"Create"})]})]})}function zi({data:s,onClose:t}){const a=(s==null?void 0:s.plans)??[],i=(s==null?void 0:s.count)??a.length,n=c=>{window.open(`/artifacts/${c}/`,"_blank")};return e.jsxs("div",{children:[a.length===0?e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:["No plans found in this worktree. Use ",e.jsx("code",{children:"/artifact new <slug>"})," to create one."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:12,fontSize:13,color:"var(--color-muted)"},children:[i," plan",i!==1?"s":""," in this worktree:"]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0},children:a.map(c=>e.jsxs("li",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 0",borderBottom:"1px solid var(--color-border)"},children:[e.jsx("code",{style:{fontSize:13},children:c}),e.jsx($,{variant:"ghost",size:"sm",onClick:()=>n(c),children:"Open"})]},c))})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx($,{variant:"ghost",onClick:t,children:"Close"})})]})}function Ti({data:s,onClose:t}){const a=(s==null?void 0:s.commands)??[],i=(s==null?void 0:s.templates)??[],n=(s==null?void 0:s.statuses)??[];return e.jsxs("div",{children:[a.length>0?e.jsx("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:16,fontSize:13},children:e.jsx("tbody",{children:a.map(c=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e.jsx("td",{style:{padding:"5px 8px 5px 0",whiteSpace:"nowrap"},children:e.jsx("code",{style:{fontSize:12},children:c.cmd})}),e.jsx("td",{style:{padding:"5px 0",color:"var(--color-muted)"},children:c.desc})]},c.cmd))})}):e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:"No commands available."}),i.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available templates:"}),e.jsx("p",{style:{fontSize:13},children:i.join(", ")})]}),n.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available statuses:"}),e.jsx("p",{style:{fontSize:13},children:n.join(", ")})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx($,{variant:"ghost",onClick:t,children:"Close"})})]})}function Ri({data:s,onClose:t}){const[a,i]=r.useState(!1),[n,c]=r.useState(null),o=async()=>{i(!0),c(null);try{const l=await T.post("/chat/audit",{});c(l)}catch(l){c({ok:!1,findings:[],error:l.message})}finally{i(!1)}};return e.jsx("div",{children:n===null?e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:"Run a security audit of your Bizar agent configuration. The audit checks for common misconfigurations, exposed secrets, and insecure defaults."}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx($,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx($,{variant:"primary",onClick:o,disabled:a,children:a?"Running…":"Run Audit"})]})]}):e.jsxs(e.Fragment,{children:[n.ok?e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:12,fontWeight:600,color:"var(--color-success)"},children:"Audit passed — no issues found."}),n.findings.length>0&&e.jsx("ul",{style:{marginBottom:16,paddingLeft:20},children:n.findings.map((l,x)=>e.jsx("li",{style:{marginBottom:4,fontSize:13},children:l},x))})]}):e.jsxs("p",{style:{marginBottom:16,color:"var(--color-danger)"},children:["Audit failed: ",n.error??"unknown error"]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx($,{variant:"ghost",onClick:t,children:"Close"})})]})})}function $i({dialog:s,onClose:t}){if(!s.data)return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:`Command: ${s.command}`}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]});const{message:a,detail:i,url:n}=s.data;return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:a??`Command: ${s.command}`}),i&&e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:i}),n&&e.jsx("p",{style:{marginBottom:16},children:e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:n})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]})}function Ai({dialog:s,onClose:t}){switch(s.component){case"visual-artifact":return e.jsx(wi,{data:s.data,onClose:t});case"artifact-create":return e.jsx(Ci,{data:s.data,onClose:t});case"artifact-list":return e.jsx(zi,{data:s.data,onClose:t});case"help":return e.jsx(Ti,{data:s.data,onClose:t});case"audit":return e.jsx(Ri,{data:s.data,onClose:t});default:return e.jsx($i,{dialog:s,onClose:t})}}function Mi({setActiveTab:s,refreshKey:t=0}){var p;const[a,i]=r.useState(null),[n,c]=r.useState(!0),o=async()=>{c(!0);try{const[u,d,m]=await Promise.all([T.get("/memory/status").catch(()=>null),T.get("/memory/health").catch(()=>null),T.get("/memory/lightrag/stats").catch(()=>null)]);i({initialized:!!(u!=null&&u.initialized),mode:u==null?void 0:u.mode,projectId:u==null?void 0:u.projectId,vaultRoot:u==null?void 0:u.vaultRoot,branch:u==null?void 0:u.branch,gitClean:u==null?void 0:u.gitClean,noteCount:(u==null?void 0:u.noteCount)||0,healthScore:d==null?void 0:d.score,healthStatus:d==null?void 0:d.status,lightrag:m?{running:m.running,indexedApprox:m.indexedApprox}:void 0})}catch{i({initialized:!1})}finally{c(!1)}};r.useEffect(()=>{o()},[t]);const l=()=>s("memory"),x=(a==null?void 0:a.healthStatus)==="healthy"?"var(--success)":(a==null?void 0:a.healthStatus)==="degraded"?"var(--warning)":(a==null?void 0:a.healthStatus)==="unhealthy"?"var(--error)":"var(--text-dim)";return e.jsxs(G,{className:"memory-overview-card",children:[e.jsxs(te,{children:[e.jsx(Pe,{size:14})," Memory",e.jsxs($,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:l,children:["Open Memory ",e.jsx(ys,{size:12})]}),e.jsx($,{variant:"ghost",size:"sm",onClick:o,"aria-label":"Refresh",title:"Refresh",children:e.jsx(de,{size:12})})]}),e.jsx(ne,{children:"LightRAG + Obsidian vault + git sync — opens the dedicated Memory tab."}),a!=null&&a.initialized?e.jsxs("div",{className:"memory-status-card-grid",children:[e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(De,{size:11})," Health"]}),e.jsx("div",{className:"memory-status-card-value",style:{color:x},children:a.healthScore!==void 0?`${a.healthScore}/100`:"—"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.healthStatus||"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(Pe,{size:11})," LightRAG"]}),e.jsx("div",{className:"memory-status-card-value",children:(p=a.lightrag)!=null&&p.running?"running":"stopped"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.lightrag?`${a.lightrag.indexedApprox} chunks`:"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(be,{size:11})," Vault"]}),e.jsxs("div",{className:"memory-status-card-value",children:[a.noteCount," notes"]}),e.jsx("div",{className:"memory-status-card-sub muted ellipsis",title:a.vaultRoot||"",children:a.vaultRoot?a.vaultRoot.split("/").slice(-2).join("/"):"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(is,{size:11})," Git"]}),e.jsx("div",{className:"memory-status-card-value",children:a.gitClean===null?a.mode==="local-only"?"local-only":"—":a.gitClean?"clean":"dirty"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.branch?`branch ${a.branch}`:_e(a.branch||"")||"—"})]})]}):e.jsxs("div",{className:"muted",children:["Memory not initialised. Click ",e.jsx("strong",{children:"Open Memory"})," to set it up."]}),n&&!a&&e.jsx("div",{className:"muted text-sm",children:"Loading…"})]})}function pe({icon:s,title:t,message:a,action:i,className:n}){return e.jsxs("div",{className:V("empty-state",n),children:[e.jsx("div",{className:"empty-icon",children:s??e.jsx(Gs,{size:32})}),e.jsx("div",{className:"empty-title",children:t}),a&&e.jsx("div",{className:"empty-message",children:a}),i&&e.jsx("div",{className:"empty-action",children:i})]})}function Ii({snapshot:s,settings:t,setActiveTab:a,refreshSnapshot:i}){var J,ae,ee;const n=re(),c=$e(),o=r.useRef(null),[l,x]=r.useState(s.overview??null),[p,u]=r.useState(!s.overview),[d,m]=r.useState(s.projects||[]),[h,g]=r.useState(((J=s.activeProject)==null?void 0:J.id)||null),[j,k]=r.useState(s.mods||[]),[z,N]=r.useState(!1),[S,E]=r.useState(((ae=s.overview)==null?void 0:ae.recentActivity)??[]),[v,b]=r.useState(!1),[w,f]=r.useState(new Set);r.useEffect(()=>{let F=!1;return(async()=>{try{const H=await T.get("/activity/hidden");F||f(new Set(H.hidden||[]))}catch{}})(),()=>{F=!0}},[]);const L=(F,H)=>{const K=`${F.kind||""}|${F.ts||""}|${F.slug||F.title||""}|${H}`;let B=0;for(let Z=0;Z<K.length;Z++)B=(B<<5)-B+K.charCodeAt(Z)|0;return Math.abs(B).toString(16).padStart(8,"0").slice(0,16)},R=async F=>{const H=new Set(w);H.add(F),f(H);try{await T.post("/activity/hide",{keys:[F]})}catch(K){const B=new Set(w);f(B),n.error(`Hide failed: ${K.message}`)}},y=async()=>{if(!confirm("Hide every recent activity item from the overview? The full log stays in Settings → Activity Log."))return;const F=S.map((K,B)=>L(K,B)),H=new Set(w);F.forEach(K=>H.add(K)),f(H);try{await T.post("/activity/hide",{keys:F}),n.success(`Hidden ${F.length} item(s). Restore them in Settings → Activity Log.`)}catch(K){n.error(`Clear failed: ${K.message}`)}},A=async()=>{f(new Set);try{await T.del("/activity/hide"),n.success("All hidden activity restored to the overview.")}catch(F){n.error(`Restore failed: ${F.message}`)}};r.useEffect(()=>{var F;s.overview&&(x(s.overview),E(s.overview.recentActivity??[]),u(!1)),m(s.projects||[]),g(((F=s.activeProject)==null?void 0:F.id)||null),k(s.mods||[])},[s.overview,s.projects,s.activeProject,s.mods]),r.useEffect(()=>{let F;try{const H=T.getToken(),K=H?`/api/activity/stream?token=${encodeURIComponent(H)}`:"/api/activity/stream";F=new EventSource(K),F.addEventListener("snapshot",B=>{try{const Z=JSON.parse(B.data);E(Array.isArray(Z.events)?Z.events.slice(0,50):[])}catch{}}),F.addEventListener("activity",B=>{try{const Z=JSON.parse(B.data);E(he=>[Z,...he].slice(0,50))}catch{}})}catch{}return()=>{try{F==null||F.close()}catch{}}},[]);const P=async()=>{n.info("Refreshing…",1500),await i();try{const F=await T.get("/projects");m(F.projects||[]),g(F.active||null)}catch{}},C=()=>{c.open({title:"Add project",children:e.jsx(Ei,{settings:t,onAdd:async(F,H)=>{try{const K=await T.post("/projects",{path:F,name:H});m(B=>[...B.filter(Z=>Z.id!==K.id),K]),n.success("Project added."),c.close()}catch(K){n.error(`Add failed: ${K.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx($,{variant:"ghost",onClick:()=>c.close(),children:"Cancel"})})})},D=async()=>{var F;try{const H=await T.post("/projects/auto-detect");m(H.projects||[]),g(H.active||null);const K=(F=H.projects)==null?void 0:F.find(B=>B.id===H.active);n.success(K?`Active: ${K.name}`:"Projects refreshed."),await i()}catch(H){n.error(`Auto-detect failed: ${H.message}`)}},Y=async F=>{try{await T.post(`/projects/${encodeURIComponent(F)}/activate`),g(F),n.success("Project activated."),await i()}catch(H){n.error(`Activate failed: ${H.message}`)}},O=async F=>{if(confirm(`Remove project "${F}" from the registry?`))try{await T.del(`/projects/${encodeURIComponent(F)}`),m(H=>H.filter(K=>K.id!==F)),h===F&&g(null),n.success("Project removed.")}catch(H){n.error(`Remove failed: ${H.message}`)}};return p||!l?e.jsxs("div",{className:"view-loading",children:[e.jsx(oe,{size:"lg"}),e.jsx("p",{children:"Loading overview…"})]}):e.jsxs("div",{className:"view view-overview",children:[e.jsxs("div",{className:"overview-hero-noframe",children:[e.jsx("h1",{children:"What do you want to do?"}),e.jsx("p",{className:"overview-hero-subtitle",children:"Describe what you want — Odin will split it into tasks, create a plan, delegate to background agents, and track progress in real time."}),e.jsxs("form",{className:"overview-hero-form-noframe",onSubmit:async F=>{var K,B;F.preventDefault();const H=(((K=o.current)==null?void 0:K.value)||"").trim();if(H){N(!0);try{const Z=await T.post("/tasks/submit",{title:H});n.success(`Odin split it into ${((B=Z.subtasks)==null?void 0:B.length)||1} task(s)`),o.current&&(o.current.value=""),await i()}catch(Z){n.error(`Failed: ${Z.message}`)}finally{N(!1)}}},children:[e.jsx("label",{htmlFor:"overview-hero-input",className:"sr-only",children:"Describe what you want Odin to do"}),e.jsx("textarea",{id:"overview-hero-input",ref:o,className:"overview-input-hero",placeholder:"e.g. Implement user authentication with email + password, including registration, login, password reset, and integration tests. Use Bcrypt, JWT tokens, and the existing API style.",disabled:z,"aria-label":"Describe what you want Odin to do"}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-2)",alignItems:"center",flexWrap:"wrap"},children:[e.jsxs($,{type:"submit",variant:"primary",size:"lg",disabled:z,children:[z?e.jsx(oe,{size:"sm"}):e.jsx(rs,{size:16}),"Submit to Odin"]}),e.jsxs("span",{className:"muted",style:{fontSize:12},children:[e.jsx(He,{size:12,style:{display:"inline",verticalAlign:-2,color:"var(--accent)"}})," ","Odin + 12 specialist agents available"]})]})]}),e.jsx("div",{className:"overview-quick-actions-row",children:["Implement feature","Fix bug","Refactor","Investigate","Add tests","Document","Optimize","Deploy"].map(F=>e.jsx("button",{type:"button",className:"overview-quick-chip",onClick:()=>{o.current&&(o.current.value=F,o.current.focus())},children:F},F))})]}),e.jsxs("div",{className:"overview-feed",children:[e.jsxs("div",{className:"overview-feed-head",children:[e.jsx("h2",{children:"Recent activity"}),e.jsxs("div",{className:"overview-feed-head-actions",children:[w.size>0&&e.jsxs($,{variant:"ghost",size:"sm",onClick:A,title:"Restore hidden items to this overview",children:[e.jsx(fs,{size:12})," Show ",w.size," hidden"]}),S.length>8&&e.jsx($,{variant:"ghost",size:"sm",onClick:()=>b(F=>!F),children:v?"Show less":"Show all"}),S.length>0&&e.jsxs($,{variant:"ghost",size:"sm",onClick:y,title:"Hide every item from the overview (full log kept)",children:[e.jsx(pt,{size:12})," Hide all"]})]})]}),w.size>0&&e.jsxs("div",{className:"activity-hidden-banner",role:"status",children:[e.jsxs("span",{children:[e.jsx(pt,{size:12,style:{verticalAlign:-2,marginRight:6}}),w.size," item",w.size===1?"":"s"," hidden from the overview."]}),e.jsxs($,{variant:"ghost",size:"sm",onClick:A,children:[e.jsx(fs,{size:12})," Show them again"]})]}),S.length===0?e.jsx("div",{className:"muted",style:{padding:"24px 0",fontSize:13},children:"No activity yet. Use the chat above or invoke a Bizar command to start a feed."}):e.jsxs("div",{className:V("activity-feed-list-wrap",!v&&"activity-feed-list-wrap-collapsed"),"aria-live":"polite","aria-relevant":"additions",children:[e.jsx(Mt,{items:S.slice(0,30).filter((F,H)=>!w.has(L(F,H))),itemHeight:60,height:Math.min(S.filter((F,H)=>!w.has(L(F,H))).length*60,480),className:"activity-feed-list",renderItem:(F,H)=>{const K=S.slice(0,30).findIndex(B=>B===F);return e.jsx(Wi,{item:F,activityKey:L(F,K),onNavigate:a,onHide:R})}}),!v&&S.length>8&&e.jsx("div",{className:"activity-feed-fade","aria-hidden":"true"})]})]}),e.jsxs(G,{className:"project-picker",children:[e.jsxs(te,{children:[e.jsx(Fe,{size:14})," Projects",e.jsxs($,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:C,children:[e.jsx(ze,{size:12})," Add"]}),e.jsxs($,{variant:"ghost",size:"sm",onClick:D,title:"Use the server's working directory",children:[e.jsx(ze,{size:12})," Auto-detect"]}),((ee=t==null?void 0:t.dashboard)==null?void 0:ee.projectsDirectory)&&e.jsxs($,{variant:"ghost",size:"sm",title:`Scan ${t.dashboard.projectsDirectory} for projects`,onClick:async()=>{try{const F=await T.post("/projects/scan");F.error?n.error(F.error):n.success(`Added ${F.added.length}, skipped ${F.skipped}.`),await i();const H=await T.get("/projects");m(H.projects||[]),g(H.active||null)}catch(F){n.error(`Scan failed: ${F.message}`)}},children:[e.jsx(an,{size:12})," Scan"]}),e.jsx($,{variant:"ghost",size:"sm",onClick:P,title:"Refresh",children:e.jsx(de,{size:12})})]}),e.jsxs(ne,{children:[d.length," project",d.length===1?"":"s"," ·"," ",l.counts.agents," agents ·"," ",l.counts.sessions," session",l.counts.sessions===1?"":"s"]}),d.length===0?e.jsx(pe,{icon:e.jsx(Fe,{size:32}),title:"No projects yet",message:"Add a project to start tracking its tasks, plans, and schedules.",action:e.jsxs("div",{className:"empty-state-actions",children:[e.jsxs($,{variant:"primary",onClick:D,children:[e.jsx(ze,{size:14})," Use current directory"]}),e.jsx($,{variant:"secondary",onClick:C,children:"Add by path…"})]})}):e.jsx("div",{className:"project-grid",children:d.map(F=>e.jsx(Li,{project:F,active:h===F.id,onOpen:()=>Y(F.id),onRemove:()=>O(F.id)},F.id))})]}),e.jsx(Mi,{setActiveTab:a}),e.jsxs("div",{className:"overview-cols",children:[e.jsxs(G,{children:[e.jsx(te,{children:"Mods"}),e.jsxs(ne,{children:["Extensions installed under ",e.jsx("code",{children:"~/.config/bizar/mods/"})]}),j.length===0?e.jsx("div",{className:"muted",children:"No mods installed."}):e.jsx("ul",{className:"mod-mini-list",children:j.map(F=>e.jsxs("li",{className:"mod-mini",children:[e.jsx("span",{className:"mod-mini-name",children:F.name}),e.jsxs("span",{className:"mod-mini-meta",children:["v",F.version," · ",F.type]}),e.jsx("span",{className:`mod-mini-pill ${F.enabled?"mod-mini-pill-on":"mod-mini-pill-off"}`,children:F.enabled?"on":"off"})]},F.id))})]}),e.jsxs(G,{children:[e.jsx(te,{children:"Environment"}),e.jsx(ne,{children:"Runtime + paths"}),e.jsxs("dl",{className:"env-table",children:[e.jsx("dt",{children:"Node"}),e.jsx("dd",{className:"mono",children:l.versions.node}),e.jsx("dt",{children:"Platform"}),e.jsx("dd",{className:"mono",children:l.versions.platform}),e.jsx("dt",{children:"Project root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.projectRoot,children:l.versions.projectRoot}),e.jsx("dt",{children:"Bizar root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.bizarRoot,children:l.versions.bizarRoot}),e.jsx("dt",{children:"Generated"}),e.jsx("dd",{className:"mono tabular-nums",children:_e(l.generatedAt)})]})]})]})]})}function Ei({settings:s,onAdd:t}){var d,m;const[a,i]=r.useState(((d=s==null?void 0:s.dashboard)==null?void 0:d.projectsDirectory)??""),[n,c]=r.useState(""),[o,l]=r.useState(!1),[x,p]=r.useState(null),u=async()=>{var h;if(a){l(!0),p(null);try{await T.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(g){const j=g;j.status===404?p("That folder no longer exists. Pick another."):p(((h=j.data)==null?void 0:h.message)??g.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(wa,{value:a,onChange:h=>{i(h),p(null)},projectsDirectory:(m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory,height:320}),x&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:x}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:h=>c(h.target.value)}),e.jsx("p",{className:"field-help",style:{marginTop:4},children:"Display name for this project. Defaults to the folder name."})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs($,{variant:"primary",onClick:u,disabled:!a||o,children:[o?e.jsx("span",{className:"btn-spinner"}):null,o?"Checking…":"Add"]})})]})}function Li({project:s,active:t,onOpen:a,onRemove:i}){const n={active:"status-on",inactive:"status-neutral",error:"status-error"}[s.status]||"status-neutral";return e.jsxs("div",{className:`project-card ${t?"project-card-active":""}`,children:[e.jsxs("div",{className:"project-card-head",children:[e.jsx("span",{className:`project-card-status ${n}`,children:s.status}),e.jsx("div",{className:"project-card-name",children:s.name}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Remove project",title:"Remove",onClick:c=>{c.stopPropagation(),i()},children:e.jsx(ke,{size:12})})]}),e.jsx("div",{className:"project-card-path mono ellipsis",title:s.path,children:s.path}),e.jsx("div",{className:"project-card-meta",children:s.lastAccessed&&e.jsxs("span",{className:"muted",children:["Last opened ",Ce(s.lastAccessed)]})}),e.jsx("div",{className:"project-card-actions",children:e.jsx($,{variant:t?"ghost":"primary",size:"sm",onClick:a,children:t?e.jsxs(e.Fragment,{children:[e.jsx(St,{size:12})," Active"]}):e.jsx(e.Fragment,{children:"Open"})})})]})}function Di(s){return s&&s.charAt(0).toUpperCase()+s.slice(1)}function Pi(s){const t=s.trim().toLowerCase().replace(/[:_]/g,"."),[a,i="updated"]=t.split("."),n={settings:"Settings",task:"Task",tasks:"Task",agent:"Agent",agents:"Agent",plan:"Plan",plans:"Plan",bg:"Background job",background:"Background job",session:"Session",mod:"Mod",mods:"Mod",provider:"Provider",providers:"Provider"},c={create:"created",created:"created",add:"added",added:"added",update:"updated",updated:"updated",delegate:"delegated",delegated:"delegated",invoke:"invoked",invoked:"invoked",restart:"restarted",restarted:"restarted",delete:"deleted",deleted:"deleted",remove:"removed",removed:"removed",archive:"archived",archived:"archived",restore:"restored",restored:"restored",complete:"completed",completed:"completed",fail:"failed",failed:"failed",error:"errored",stuck:"marked stuck"},o=n[a]||Di(a.replace(/-/g," ")),l=c[i]||i.replace(/-/g," ");return`${o} ${l}`.trim()}function Fs(s,t){for(const a of t){const i=s[a];if(typeof i=="string"&&i.trim())return i.trim()}return""}function Fi(s){const t=Fs(s,["message","text","prompt","title","name"]);if(t)return t;const a=[],i=Fs(s,["slug"]),n=Fs(s,["agent","author"]),c=Fs(s,["status"]);return i&&a.push(`Plan ${i}`),n&&a.push(n),c&&a.push(c),a.length?a.join(" · "):"No additional details."}function Oi(s){return Ce(s)}function Bi(s){const t=(s.kind||"").toLowerCase(),a=(s.status||"").toLowerCase();return t.includes("error")||a==="error"||a==="failure"?"error":t.includes("warn")||a==="blocked"?"warning":t.includes("done")||t.includes("success")||a==="done"?"success":"info"}function Ui(s){const t=s.toLowerCase();return t==="task"?Rs:t==="agent"?Ye:t==="plan"?Hs:t.includes("bg")||t.includes("background")||t.includes("job")?Ct:t==="mod"?ts:t==="skill"?He:t.includes("error")||t.includes("failure")?ps:t.includes("warn")?Te:De}function _i(s){const t=s.toLowerCase();return t==="task"?"tasks":t==="agent"?"agents":t==="plan"?"artifacts":t.includes("bg")||t.includes("background")?"activity":t==="mod"?"mods":t==="skill"?"skills":null}function Wi({item:s,activityKey:t,onNavigate:a,onHide:i}){const n=Bi(s),c=Ui(s.kind||""),o=Pi(s.kind||"activity"),l=Fi(s),x=_i(s.kind||""),p=n==="error"?"var(--error)":n==="warning"?"var(--warning)":n==="success"?"var(--success)":"var(--accent)";return e.jsxs("div",{className:V("activity-feed-row",`activity-feed-row-${n}`),children:[e.jsxs("button",{type:"button",className:"activity-feed-row-main",onClick:()=>{x&&a(x)},title:x?`Open ${x}`:o,children:[e.jsx("div",{className:"activity-feed-icon",style:{color:p},children:e.jsx(c,{size:14})}),e.jsxs("div",{className:"activity-feed-body",children:[e.jsxs("div",{className:"activity-feed-title-row",children:[e.jsx("div",{className:"activity-feed-title",children:o}),e.jsx("div",{className:"activity-feed-time text-xs muted tabular-nums",children:Oi(s.ts)})]}),e.jsx("div",{className:"activity-feed-summary text-sm",children:l})]})]}),e.jsx("button",{type:"button",className:"activity-feed-hide-btn",onClick:()=>i(t),title:"Hide this from the overview (kept in Settings → Activity Log)","aria-label":"Hide from overview",children:e.jsx(Ne,{size:12})})]})}const qi=Oe.memo(Ii);function Vi({icon:s,title:t,message:a,action:i}){return e.jsxs("div",{className:"chat-empty-state",children:[s&&e.jsx("div",{className:"chat-empty-state-icon",children:s}),e.jsx("h2",{className:"chat-empty-state-title",children:t}),e.jsx("p",{className:"chat-empty-state-message",children:a}),i&&e.jsx("div",{className:"chat-empty-state-action",children:i})]})}function Hi({session:s,mode:t,anchor:a,renameDraft:i,setRenameDraft:n,onEdit:c,onDeleteRequest:o,onConfirmDelete:l,onConfirmRename:x,onClose:p}){const u=r.useRef(null),d=Math.round(a.rect.bottom+2),m=Math.max(8,Math.round(window.innerWidth-a.rect.right));r.useEffect(()=>{const g=z=>{const N=z.target;!u.current||!N||u.current.contains(N)||p()},j=z=>{z.key==="Escape"&&p()},k=window.setTimeout(()=>{document.addEventListener("mousedown",g),document.addEventListener("keydown",j)},0);return()=>{window.clearTimeout(k),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",j)}},[p]),r.useEffect(()=>{if(t!=="rename")return;const g=window.setTimeout(()=>{var k;const j=(k=u.current)==null?void 0:k.querySelector("input.session-row-menu-input");j==null||j.focus(),j==null||j.select()},0);return()=>window.clearTimeout(g)},[t]);const h=e.jsxs("div",{ref:u,className:"session-row-menu",role:"menu","aria-label":`Options for ${s.title}`,style:{position:"fixed",top:d,right:m},onClick:g=>g.stopPropagation(),children:[t==="main"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"session-row-menu-item",role:"menuitem",onClick:g=>{g.stopPropagation(),c()},children:[e.jsx(nn,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Rename"}),e.jsx("kbd",{children:"R"})]}),e.jsxs("button",{type:"button",className:"session-row-menu-item session-row-menu-item-danger",role:"menuitem",onClick:g=>{g.stopPropagation(),o()},children:[e.jsx(ke,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Delete"}),e.jsx("kbd",{children:"⌫"})]})]}),t==="rename"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Rename session"}),e.jsx("input",{type:"text",className:"session-row-menu-input",value:i,onChange:g=>n(g.target.value),onKeyDown:g=>{g.key==="Enter"?(g.preventDefault(),x()):g.key==="Escape"&&(g.preventDefault(),p())},onClick:g=>g.stopPropagation(),"aria-label":"New session name"}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:g=>{g.stopPropagation(),p()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:g=>{g.stopPropagation(),x()},children:"Save"})]})]}),t==="confirm-delete"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Delete this session?"}),e.jsxs("div",{className:"session-row-menu-inline-message",children:['"',s.title,'" and its sub-agents will be removed.']}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:g=>{g.stopPropagation(),p()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:g=>{g.stopPropagation(),l()},children:"Delete"})]})]})]});return sa.createPortal(h,document.body)}function vt({node:s,depth:t=0,collapsible:a=!1,isLast:i=!0,open:n,onToggle:c}){var h;const[o,l]=r.useState(a),x=n!==void 0,p=x?n:o,u=g=>{x||l(g),c==null||c(g)},d=(((h=s.children)==null?void 0:h.length)??0)>0,m=e.jsxs(e.Fragment,{children:[a&&e.jsx("span",{className:`agent-node-chevron ${p?"open":""}`,"aria-hidden":!0,children:"›"}),e.jsx("span",{className:`agent-node-dot status-${s.status}`,"aria-hidden":!0}),e.jsx("span",{className:"agent-node-name",children:s.name}),s.role&&e.jsx("span",{className:"agent-node-role chat-mono",children:s.role}),e.jsx("span",{className:`agent-node-pill status-${s.status}`,children:s.status})]});return e.jsxs("div",{className:["agent-node",`depth-${t}`,`status-${s.status}`,p?"open":"closed",i?"last":""].filter(Boolean).join(" "),children:[a?e.jsx("button",{type:"button",className:`agent-node-head status-${s.status} collapsible`,onClick:g=>{g.stopPropagation(),u(!p)},"aria-expanded":p,children:m}):e.jsx("div",{className:`agent-node-head status-${s.status}`,children:m}),p&&e.jsxs(e.Fragment,{children:[s.summary&&e.jsx("div",{className:"agent-node-summary",children:s.summary}),d&&e.jsx("div",{className:"agent-node-children",children:s.children.map((g,j)=>e.jsx(vt,{node:g,depth:t+1,collapsible:!1,isLast:j===s.children.length-1},g.id))})]})]})}function Gi(s){return s.tree!==void 0}function Ki(s){const t=s.open??!0;if(Gi(s))return e.jsx("div",{className:`agent-tree variant-${s.variant??"full"}`,children:e.jsx(vt,{node:s.tree.root,depth:0,open:t})});const a=s.children??[];return e.jsx("div",{className:`agent-tree variant-${s.variant} agent-tree-children-only`,children:e.jsx("div",{className:"agent-tree-children-body",children:a.map((i,n)=>e.jsx(r.Fragment,{children:e.jsx(vt,{node:i,depth:0,collapsible:!1,open:t,isLast:n===a.length-1})},i.id))})})}function Yi({children:s,variant:t="rail",open:a=!0}){return a?e.jsx(Ki,{variant:t,open:a,children:s}):null}const Xi=["Today","Yesterday","This week","Earlier"];function Bt(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function Ji(s,t){const a=s.getTime()-t.getTime();return Math.floor(a/(1e3*60*60*24))}function Qi(s){const t=new Date,a=new Date(t);a.setDate(a.getDate()-1);const i=new Date(t);i.setDate(i.getDate()-7);const n={Today:[],Yesterday:[],"This week":[],Earlier:[]};for(const c of s){const o=new Date(Number(c.mtime)||Date.now());Bt(o,t)?n.Today.push(c):Bt(o,a)?n.Yesterday.push(c):Ji(t,o)<7?n["This week"].push(c):n.Earlier.push(c)}return n}function Zi(s){return new Date(Number(s)||Date.now()).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function er({state:s,agent:t}){return s==="streaming"?e.jsx("span",{className:"session-state session-state-streaming",title:`${t||"Odin"} is typing…`}):s==="awaiting"?e.jsx("span",{className:"session-state session-state-awaiting",title:"Awaiting your reply","aria-hidden":!0}):s==="idle"?e.jsx("span",{className:"session-state session-state-idle","aria-hidden":!0}):null}function sr({sessions:s,opencodeSessions:t=[],activeSessionId:a,activeOpencodeSessionId:i,activeProject:n,creating:c,onCreateSession:o,onSelectSession:l,onSelectOpencodeSession:x,onRenameSession:p,onDeleteSession:u,groupBy:d}){var O;const m=r.useMemo(()=>[...s,...t],[s,t]),h=r.useMemo(()=>[...m].sort((J,ae)=>Number(ae.mtime??0)-Number(J.mtime??0)),[m]),g=r.useMemo(()=>d?d(h):Qi(h),[d,h]),[j,k]=r.useState({}),z=J=>j[J]===!0,[N,S]=r.useState(null),[E,v]=r.useState("main"),[b,w]=r.useState(""),[f,L]=r.useState(null),R=r.useRef({}),y=(J,ae="main")=>{const ee=R.current[J];if(!ee)return;const F=ae==="main"?ee:ee.querySelector(".chat-rail-item-menu-trigger")??ee;if(L({id:J,rect:F.getBoundingClientRect()}),S(J),v(ae),ae==="rename"){const H=[...s,...t].find(K=>K.id===J);w((H==null?void 0:H.title)??(H==null?void 0:H.id)??"")}},A=()=>{S(null),v("main"),w(""),L(null)},P=J=>{if(J.source==="opencode"){x(J);return}l(J.id)},C=()=>{if(!f)return;const J=f.id,ae=b.trim();if(!ae){A();return}p==null||p(J,ae),A()},D=()=>{f&&(u==null||u(f.id),A())},Y=d?Object.entries(g):Xi.filter(J=>{var ae;return(ae=g[J])==null?void 0:ae.length}).map(J=>[J,g[J]]);return e.jsxs("aside",{className:"chat-rail",children:[e.jsx("div",{className:"chat-rail-head",children:e.jsxs("button",{type:"button",className:"chat-new-btn",onClick:o,disabled:c||!n,title:n?"Create new session":"Pick a project first","aria-label":"Create new session",children:[e.jsx(ze,{size:14,"aria-hidden":!0}),e.jsx("span",{children:c?"Creating…":"New session"})]})}),h.length===0?e.jsx("div",{className:"chat-sessions-empty",children:e.jsx(Vi,{icon:e.jsx(ze,{size:20,"aria-hidden":!0}),title:n?"No sessions yet":"No project",message:n?"Create your first session to start chatting.":"Pick a project in Overview to scope chat sessions."})}):e.jsx("div",{className:"chat-rail-list",children:Y.map(([J,ae])=>e.jsxs("div",{className:"chat-rail-group",children:[e.jsx("div",{className:"chat-rail-group-label",children:J}),ae.map(ee=>{var he,we;const F=ee.source==="opencode",H=F?i===ee.id:a===ee.id,K=ee.tree,B=!!((he=K==null?void 0:K.root)!=null&&he.children&&K.root.children.length>0),Z=z(ee.id);return e.jsxs(r.Fragment,{children:[e.jsxs("div",{ref:W=>{R.current[ee.id]=W},role:"button",tabIndex:0,className:`chat-rail-item state-${ee.state??"idle"}${H?" active":""}`,onClick:()=>P(ee),onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),P(ee))},"aria-current":H?"true":void 0,children:[e.jsx(er,{state:ee.state??"idle",agent:ee.agent}),e.jsxs("div",{className:"chat-rail-item-title",children:[ee.pinned&&e.jsx("span",{className:"chat-rail-pin","aria-hidden":!0,children:"★"}),F&&e.jsx(ys,{size:11,style:{color:"var(--text-muted)",flexShrink:0},"aria-hidden":!0}),e.jsx("span",{className:"chat-ellipsis",children:ee.title||ee.id})]}),e.jsxs("div",{className:"chat-rail-item-meta",children:[e.jsx("span",{className:"chat-rail-item-meta-time",children:ee.time??Zi(ee.mtime)}),(ee.unread??0)>0&&e.jsx("span",{className:"chat-rail-badge",children:ee.unread})]}),e.jsx("button",{type:"button",className:`chat-rail-item-menu-trigger${N===ee.id?" open":""}`,"aria-label":`Session options for ${ee.title||ee.id}`,"aria-haspopup":"menu","aria-expanded":N===ee.id,onClick:W=>{W.stopPropagation(),N===ee.id?A():y(ee.id,"main")},children:e.jsxs("svg",{viewBox:"0 0 14 14","aria-hidden":!0,children:[e.jsx("circle",{cx:"3",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"7",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"11",cy:"7",r:"1.2",fill:"currentColor"})]})}),H&&B&&e.jsx("button",{type:"button",className:`chat-rail-tree-chevron${Z?" open":""}`,"aria-label":Z?"Collapse sub-agents":"Expand sub-agents","aria-expanded":Z,onClick:W=>{W.stopPropagation(),k(se=>({...se,[ee.id]:!se[ee.id]}))},children:e.jsx("svg",{viewBox:"0 0 10 10","aria-hidden":!0,children:e.jsx("polyline",{points:"3,1.5 7,5 3,8.5"})})})]}),H&&B&&Z&&((we=K==null?void 0:K.root)==null?void 0:we.children)&&e.jsx(Yi,{children:K.root.children,variant:"rail",open:!0})]},F?`oc-${ee.id}`:ee.id)})]},J))}),N&&f&&e.jsx(Hi,{session:{id:f.id,title:((O=[...s,...t].find(J=>J.id===f.id))==null?void 0:O.title)??f.id},mode:E,anchor:f,renameDraft:b,setRenameDraft:w,onEdit:()=>y(N,"rename"),onDeleteRequest:()=>y(N,"confirm-delete"),onConfirmDelete:D,onConfirmRename:C,onClose:A})]})}function tr(s){const{text:t,sending:a,onSend:i,activeSource:n}=s,[c,o]=r.useState(!1),l=()=>{!t.trim()||a||(o(!0),i(),window.setTimeout(()=>o(!1),320))};return e.jsxs("div",{className:`chat-composer-wrap chat-composer-source-${n??"none"}`,children:[e.jsx("div",{className:`chat-composer-pill${c?" takeoff":""}`,children:e.jsx(Qn,{...s,onSend:l})}),e.jsxs("div",{className:"chat-composer-hint chat-muted",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"⏎"})," send"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"⇧⏎"})," newline"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"/"})," commands"]}),n==="opencode"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ opencode"}),n==="bizar"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ bizar chat"}),a&&e.jsx("span",{className:"chat-composer-source-hint",children:"sending…"})]})]})}function at(s){return s.toLocaleString()}function ar(s){return!s||!s.includes("/")?"":s.split("/")[0]}function nr(s){if(!s)return 0;const t=s.toLowerCase();return t.includes("opus")?15:t.includes("sonnet")?3:t.includes("haiku")?.8:t.includes("gpt-4o")?5:t.includes("gpt-4")?10:t.includes("deepseek")?.27:t.includes("minimax")?.3:t.includes("llama-3.3-70b")?.59:1}function ir({sessionId:s,messages:t,pinned:a,agent:i,model:n,agents:c,mcps:o,allCommands:l,activeSource:x="bizar",onRename:p,onDelete:u,onExport:d,busy:m,error:h,onRetry:g}){const[j,k]=r.useState(null);r.useEffect(()=>{let y=!1;return(async()=>{try{const A=await fetch("/api/usage?range=24h",{headers:{Accept:"application/json"}});if(!A.ok)return;const P=await A.json();y||k(P)}catch{}})(),()=>{y=!0}},[s]);const z=(t==null?void 0:t.length)??0,N=(a==null?void 0:a.size)??0,S=t.reduce((y,A)=>y+(A.content||A.message||"").length,0),E=Math.round(S/4),v=nr(n),b=E/1e6*v,w=(j==null?void 0:j.totalTokens)??E,f=(j==null?void 0:j.costUsd)??b,L=128e3,R=ar(n);return e.jsxs("aside",{className:"chat-info",children:[h&&e.jsxs("div",{className:"chat-info-section chat-info-error",role:"alert","aria-live":"polite",children:[e.jsxs("h4",{children:[e.jsx(Te,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Couldn't load session"]}),e.jsx("p",{className:"chat-info-value chat-ellipsis",title:h.message,children:h.message}),e.jsxs("div",{className:"chat-info-mono",children:["code · ",h.code]}),h.suggestion?e.jsx("p",{className:"chat-info-suggestion",children:h.suggestion}):null,h.canRetry!==!1&&g?e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm chat-info-retry",onClick:g,title:"Retry loading the session",children:[e.jsx(Js,{size:12,"aria-hidden":!0})," Retry"]}):null]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("div",{className:"chat-info-section-head",children:[e.jsxs("h4",{children:[e.jsx(Xs,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Session"]}),e.jsx("span",{className:`chat-source-badge chat-source-${x??"none"}`,style:{marginLeft:"auto"},children:x==="opencode"?"opencode":"bizar chat"})]}),e.jsx("div",{className:"chat-info-mono chat-ellipsis",title:s,children:s||"Live"}),e.jsxs("div",{className:"chat-info-mono",children:[at(z)," message",z===1?"":"s",N>0&&` · ${N} pinned`]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Ye,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Agent"]}),e.jsx("div",{className:"chat-info-value",children:i||"—"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(js,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Model"]}),e.jsx("div",{className:"chat-mono chat-ellipsis",title:n,children:n||"—"}),R&&e.jsxs("div",{className:"chat-info-mono",children:["provider · ",R]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Tokens"}),e.jsxs("div",{className:"chat-mono",children:[at(w)," / ",at(L)]}),e.jsx("div",{className:"chat-info-bar","aria-hidden":!0,children:e.jsx("div",{className:"chat-info-bar-fill",style:{width:`${Math.min(100,w/Math.max(1,L)*100)}%`}})})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(rn,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Cost"]}),e.jsxs("div",{className:"chat-mono",children:["$",f.toFixed(4)]}),!j&&e.jsx("div",{className:"chat-info-mono",children:"approx · live from MiniMax"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Ye,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Attached agents"]}),c!=null&&c.length?e.jsx("div",{className:"chat-info-agents",children:c.map(y=>e.jsx("span",{className:"chat-info-agent",children:y.name},y.name))}):e.jsx("div",{className:"chat-info-mono",children:"None attached"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(js,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","MCPs"]}),o!=null&&o.length?e.jsx("div",{className:"chat-info-agents",children:o.map(y=>e.jsx("span",{className:"chat-info-agent",children:y.id},y.id))}):e.jsx("div",{className:"chat-info-mono",children:"No MCPs configured"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(ns,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Slash commands"]}),e.jsxs("div",{className:"chat-info-mono",children:[(l==null?void 0:l.length)??0," available"]})]}),(p||u||d)&&e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Actions"}),e.jsxs("div",{className:"chat-info-actions",children:[p&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:p,disabled:m==null?void 0:m.rename,title:"Rename session",children:[e.jsx(Es,{size:12,"aria-hidden":!0})," Rename"]}),d&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:d,title:"Export transcript",children:[e.jsx(ls,{size:12,"aria-hidden":!0})," Export"]}),u&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm btn-danger",onClick:u,disabled:m==null?void 0:m.delete,title:"Delete session",children:[e.jsx(ke,{size:12,"aria-hidden":!0})," Delete"]})]})]})]})}function rr({streaming:s,newMessageCount:t,onClick:a,streamingLabel:i="Odin is replying"}){return e.jsx("button",{type:"button",className:`jump-to-latest${s?" is-streaming":""}`,onClick:a,"aria-label":"Jump to latest message",title:"Jump to latest (⌘/Ctrl+End)",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"jump-dots","aria-hidden":!0,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("span",{children:i}),t>0&&e.jsx("span",{className:"jump-badge jump-badge-live",children:"live"})]}):e.jsxs(e.Fragment,{children:[e.jsx(oa,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Jump to latest"}),t>0&&e.jsxs("span",{className:"jump-badge",children:[t," new"]})]})})}function lr({snapshot:s,settings:t,setActiveTab:a,initialTaskId:i,onClearTaskId:n}){const c=re(),o=$e(),l=Zn(s,t,i??"");r.useEffect(()=>{l.setToast({error:O=>c.error(O),success:O=>c.success(O),info:O=>c.info(O),warning:O=>c.warning(O)})},[l,c]);const[x,p]=r.useState(""),[u,d]=r.useState(t.defaultAgent||"odin"),[m,h]=r.useState(t.defaultModel||""),[g,j]=r.useState([]),k=r.useRef(null),{allCommands:z,suggestions:N,setQuery:S}=ei(s);r.useEffect(()=>{S(x)},[x,S]);const E=()=>{var O;return(O=k.current)==null?void 0:O.click()},v=O=>{const J=O.target.files;if(!J)return;const ae=[];for(let ee=0;ee<J.length;ee++)ae.push(J[ee].name);j(ee=>{const F=ae.filter(H=>!ee.includes(H));return[...ee,...F]}),k.current&&(k.current.value="")},b=async()=>{const O=x.trim();if(!O)return;p(""),S(""),(await l.onSend(O,u,m,g)).ok&&l.jumpToLatest()},w=async()=>{l.busy.create||await l.onCreateSession()},f=O=>{o.open({title:"Delete message?",children:e.jsx("p",{style:{margin:0},children:"This action cannot be undone."}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx($,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx($,{variant:"danger",size:"sm",onClick:()=>{o.close(),l.deleteMessage(O)},children:"Delete"})]})})},L=(O,J)=>{let ae="";o.open({title:"Rename session",children:e.jsx("input",{id:"rename-session-input",autoFocus:!0,defaultValue:J,"aria-label":"Session title",onChange:ee=>{ae=ee.target.value},onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),o.close(),l.renameSession(O,ae).then(F=>{F&&c.success("Renamed.")}))},style:{width:"100%",padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text)",font:"13px/1.4 var(--font-sans)",marginTop:6}}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx($,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx($,{variant:"primary",size:"sm",onClick:()=>{o.close(),l.renameSession(O,ae)},children:"Save"})]})})},R=(O,J)=>{o.open({title:"Delete session?",children:e.jsxs("p",{style:{margin:0},children:["Delete ",e.jsx("strong",{children:J}),"? Messages on the opencode serve will be removed. This cannot be undone."]}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx($,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx($,{variant:"danger",size:"sm",onClick:async()=>{o.close(),await l.deleteSession(O)},children:"Delete"})]})})},y=()=>{const O=l.activeSource==="opencode"?l.activeOpencodeSessionId:l.sessionId;if(!O)return;const ae=(l.activeSource==="opencode"?l.opencodeMessages:l.bizarMessages).map(K=>{const B=K.ts??"",Z=(K.role||"unknown").toUpperCase(),he=K.content||K.message||"";return`[${B}] ${Z}: ${he}`}).join(`
|
|
1
|
+
var Ba=Object.defineProperty;var Ua=(s,t,a)=>t in s?Ba(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a;var ks=(s,t,a)=>Ua(s,typeof t!="symbol"?t+"":t,a);import{a as T,c as V,f as Ce,b as _e,S as oe,t as Zt,e as _a,p as Wa,d as xs,g as Ts,_ as qa,W as ea,A as Va,M as Ha}from"./mobile-layout-BjkoHh1W.js";import{r,j as e,a as sa,R as Oe,b as Ga}from"./react-vendor-Dn4wqh4Z.js";import{X as Ne,A as bt,R as de,F as Ka,H as Ya,a as Xa,C as ta,b as Fe,c as Ja,d as We,e as Xe,L as aa,M as Xs,B as Ye,f as Hs,S as Rs,g as De,h as Qa,i as He,j as Pe,P as ts,k as na,l as as,m as $s,n as Nt,o as Qe,p as ia,q as kt,r as ye,s as Za,t as ze,u as ra,v as Pt,T as ns,w as en,x as _s,G as sn,y as la,z as tn,D as gs,E as Te,I as qe,J as wt,K as ys,N as be,O as is,Q as Gs,U as rs,V as fs,W as pt,Y as an,Z as ke,_ as St,$ as Ct,a0 as ps,a1 as nn,a2 as Js,a3 as js,a4 as rn,a5 as Es,a6 as ls,a7 as oa,a8 as ca,a9 as As,aa as ln,ab as Ls,ac as on,ad as cn,ae as dn,af as Qs,ag as mn,ah as un,ai as hn,aj as xn,ak as pn,al as gn,am as Ft,an as da,ao as zt,ap as fn,aq as jn,ar as ma,as as vn,at as yn,au as bn,av as Nn,aw as kn,ax as wn,ay as Sn,az as gt,aA as Tt,aB as Rt,aC as os,aD as ua,aE as vs,aF as Cn,aG as zn,aH as Ks,aI as Tn,aJ as Ms,aK as Rn,aL as $n,aM as ha,aN as xa,aO as Is,aP as ft,aQ as $t,aR as pa,aS as xe,aT as An,aU as Mn,aV as ga,aW as In,aX as En,aY as Ln,aZ as fa,a_ as et,a$ as ja,b0 as At,b1 as Dn,b2 as Pn,b3 as Fn,b4 as va,b5 as On,b6 as Bn,b7 as Un,b8 as _n,b9 as ya}from"./icons-CMPxNV8t.js";import{B as $,C as G,a as te,b as ne,A as Wn,U as qn,G as Vn,E as Hn,T as Gn,S as Kn,H as Yn,c as Xn}from"./EnvVarsSection-DhLHZ5ua.js";import{u as re,T as Jn}from"./Toast-BlcKl_dN.js";import{V as Mt,C as Qn,u as Zn,a as ei,b as si,c as ti}from"./useSlashCommands-eFCiWHVt.js";import{M as ba,r as Na}from"./markdown-C6mXtQxD.js";import"./vendor-CeHGtduv.js";const ka=r.createContext(null),ai=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function $e(){const s=r.useContext(ka);return s||{open:()=>"",close:()=>{},isModalOpen:!1}}function ni({children:s}){const[t,a]=r.useState([]),i=r.useCallback(c=>{a(o=>{if(!c)return o.slice(0,-1);const l=o.findIndex(x=>x.id===c);return l===-1||l!==o.length-1?o:o.slice(0,-1)})},[]),n=r.useCallback(c=>{const o=`m${Math.random().toString(36).slice(2,9)}`;return a(l=>[...l,{...c,id:o}]),o},[]);return r.useEffect(()=>{if(t.length===0)return;const c=o=>{o.key==="Escape"&&(o.stopPropagation(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t.length,i]),e.jsxs(ka.Provider,{value:{open:n,close:i,isModalOpen:t.length>0},children:[s,typeof document<"u"&&sa.createPortal(e.jsx("div",{className:"modal-stack","aria-hidden":t.length===0,children:t.map((c,o)=>e.jsx(ii,{modal:c,onClose:()=>{var l;(l=c.onClose)==null||l.call(c),i(c.id)},depth:o},c.id))}),document.body)]})}function ii({modal:s,onClose:t,depth:a}){const i=r.useRef(null),n=r.useRef(null),c=r.useId(),o=()=>{const l=i.current;return l?Array.from(l.querySelectorAll(ai)).filter(x=>!x.hasAttribute("disabled")&&x.tabIndex!==-1):[]};return r.useEffect(()=>{var p;n.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(p=o()[0]??i.current)==null||p.focus();const x=u=>{var j,k,z;if(u.key!=="Tab")return;const d=o();if(d.length===0){u.preventDefault(),(j=i.current)==null||j.focus();return}const m=d[0],h=d[d.length-1],g=document.activeElement instanceof HTMLElement?document.activeElement:null;if(u.shiftKey){(!g||g===m||!((k=i.current)!=null&&k.contains(g)))&&(u.preventDefault(),h.focus());return}(!g||g===h||!((z=i.current)!=null&&z.contains(g)))&&(u.preventDefault(),m.focus())};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x);const u=n.current;u&&u.isConnected&&u.focus()}},[]),e.jsx("div",{className:"modal-backdrop",onClick:l=>{l.stopPropagation(),l.target===l.currentTarget&&t()},style:a>0?{background:"rgba(0,0,0,0.4)"}:void 0,children:e.jsxs("div",{ref:i,className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":s.title?c:void 0,tabIndex:-1,onClick:l=>l.stopPropagation(),style:s.width?{maxWidth:s.width}:void 0,children:[s.title&&e.jsxs("header",{className:"modal-header",children:[e.jsx("h2",{id:c,className:"modal-title",children:s.title}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:e.jsx(Ne,{size:16})})]}),e.jsx("div",{className:"modal-body",children:s.children}),s.footer&&e.jsx("footer",{className:"modal-footer",children:s.footer})]})})}const ri=200,li=5*60*1e3,ss=new Map;function oi(s){const t=ss.get(s);return t?Date.now()-t.ts>li?(ss.delete(s),null):t.data:null}function st(s,t){ss.size>=ri&&[...ss.entries()].sort((i,n)=>i[1].ts-n[1].ts).slice(0,50).map(([i])=>i).forEach(i=>ss.delete(i)),ss.set(s,{data:t,ts:Date.now()})}function ci(s){if(!s||s==="/")return[{label:"/",path:"/"}];const t=s.split("/").filter(Boolean),a=[];let i="";for(let n=0;n<t.length;n++)i+="/"+t[n],a.push({label:t[n],path:i});return a}function di(s){return[...s].sort((t,a)=>t.isDir!==a.isDir?t.isDir?-1:1:t.name.localeCompare(a.name,void 0,{sensitivity:"base"}))}function mi(s){const t=s.trim();return t?t!==s?{ok:!1,reason:"Name cannot have leading or trailing whitespace."}:t==="."?{ok:!1,reason:"Name cannot be '.'."}:t===".."?{ok:!1,reason:"Name cannot be '..'."}:t.startsWith("-")?{ok:!1,reason:"Name cannot start with '-'."}:t.length>255?{ok:!1,reason:"Name cannot be longer than 255 characters."}:/[/\0:*?"<>|]/.test(t)?{ok:!1,reason:'Name cannot contain / \\ : * ? " < > |'}:{ok:!0}:{ok:!1,reason:"Name cannot be empty."}}function wa({value:s,onChange:t,initialPath:a,projectsDirectory:i,rootLabel:n="Home",height:c=360}){const[o,l]=r.useState(a??i??""),[x,p]=r.useState(new Set),[u,d]=r.useState(-1),[m,h]=r.useState(null),[g,j]=r.useState({}),[k,z]=r.useState(!1),[N,S]=r.useState(null),[E,v]=r.useState(!1),[b,w]=r.useState(""),[f,L]=r.useState(null),[R,y]=r.useState(!1),A=r.useRef(null),P=r.useCallback(async I=>{try{const Q=oi(I);if(Q)return Q;const U=await T.get("/fs?path="+encodeURIComponent(I));return st(I,U),U}catch{return null}},[]),C=r.useCallback(async I=>{var Q;z(!0),S(null);try{const U=await T.get("/fs?path="+encodeURIComponent(I));st(I,U),h(U),d(-1)}catch(U){const le=((Q=U.data)==null?void 0:Q.message)??U.message??"Failed to load directory";S(le)}finally{z(!1)}},[]);r.useEffect(()=>{o?C(o):T.get("/fs").then(I=>{st("",I),h(I),l(I.path),I.path!==s&&t(I.path)}).catch(()=>{S("Could not determine home directory."),z(!1)})},[o]),r.useEffect(()=>{s&&s!==o&&l(s)},[s]);const D=m?di(m.entries):[],Y=D.filter(I=>I.isDir),O=D,J=I=>{I.isDir&&(l(I.path),t(I.path))},ae=()=>{m!=null&&m.parent&&(l(m.parent),t(m.parent))},ee=I=>{I!==o&&(l(I),t(I))},F=async()=>{const I=await P("");I&&(l(I.path),t(I.path))},H=async()=>{if(!i)return;const I=await P(i);I&&(l(I.path),t(I.path))},K=()=>{v(!0),w(""),L(null),setTimeout(()=>{var I;return(I=A.current)==null?void 0:I.focus()},0)},B=()=>{v(!1),w(""),L(null)},Z=async()=>{var Q;const I=mi(b);if(!I.ok){L(I.reason);return}y(!0),L(null);try{const U=await T.post("/fs/mkdir",{parent:o,name:b.trim()});ss.delete(o),await C(o),t(U.path),v(!1),w("")}catch(U){const le=U;le.status===409?L(`A folder named "${b.trim()}" already exists.`):L(((Q=le.data)==null?void 0:Q.message)??U.message??"Failed to create folder.")}finally{y(!1)}},he=I=>{I.key==="Enter"?(I.preventDefault(),Z()):I.key==="Escape"&&(I.preventDefault(),B())},we=I=>{p(Q=>{const U=new Set(Q);return U.has(I)?U.delete(I):U.add(I),U}),g[I]||P(I).then(Q=>{Q&&j(U=>({...U,[I]:Q.entries.filter(le=>le.isDir)}))})},W=I=>{if(!m)return;const Q=O.filter(q=>q.isDir),U=O.filter(q=>!q.isDir),le=[...Q,...U];if(I.key==="ArrowDown")I.preventDefault(),d(q=>Math.min(q+1,le.length-1));else if(I.key==="ArrowUp")I.preventDefault(),d(q=>Math.max(q-1,0));else if(I.key==="Enter"||I.key===" "){I.preventDefault();const q=le[u];q&&(I.key==="Enter"&&q.isDir?J(q):q.isDir&&t(q.path))}else I.key==="Backspace"&&(I.preventDefault(),ae())},se=ci((m==null?void 0:m.path)??o??"/"),ie=m==null?void 0:m.parent,me=ie!=null,_=o.split("/").filter(Boolean).at(-1)??"/";return e.jsxs("div",{className:"file-browser",onKeyDown:W,tabIndex:-1,children:[e.jsx("div",{className:"file-browser-breadcrumb",role:"navigation","aria-label":"Path breadcrumb",children:se.map((I,Q)=>e.jsxs("span",{className:"file-browser-breadcrumb-item",children:[Q>0&&e.jsx("span",{className:"file-browser-breadcrumb-sep","aria-hidden":!0,children:"/"}),e.jsx("button",{type:"button",className:"file-browser-breadcrumb-btn",onClick:()=>ee(I.path),title:I.path,children:Q===0?I.path==="/"?"/":n:I.label})]},I.path))}),e.jsxs("div",{className:"file-browser-toolbar",children:[e.jsxs("div",{className:"file-browser-toolbar-left",children:[e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:ae,disabled:!me,title:"Go up (Backspace)","aria-label":"Go up one level",children:e.jsx(bt,{size:13})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:()=>C(o),disabled:k,title:"Refresh","aria-label":"Refresh",children:e.jsx(de,{size:13,className:k?"spin":""})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:K,title:"New folder","aria-label":"Create new folder",children:e.jsx(Ka,{size:13})}),e.jsxs("div",{className:"file-browser-chips",children:[e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:F,children:[e.jsx(Ya,{size:11})," ",n]}),i&&e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:H,title:i,children:[e.jsx(Xa,{size:11})," ",i.split("/").filter(Boolean).at(-1)??"Projects"]})]})]}),E?e.jsxs("div",{className:"file-browser-mkdir",children:[e.jsx("input",{ref:A,type:"text",className:"file-browser-mkdir-input",placeholder:"Folder name",value:b,onChange:I=>{w(I.target.value),L(null)},onKeyDown:he,"aria-label":"New folder name","aria-invalid":f?"true":void 0,"aria-describedby":f?"mkdir-error":void 0,disabled:R,maxLength:255}),f?e.jsx("span",{id:"mkdir-error",className:"file-browser-mkdir-error",role:"alert",children:f}):e.jsx("span",{className:"file-browser-mkdir-hint",children:"Enter to create, Esc to cancel"})]}):e.jsx("span",{className:"file-browser-count-hint",children:k?"…":`${D.length} in ${_}`})]}),N&&e.jsxs("div",{className:"file-browser-error",children:[e.jsx(ta,{size:13}),e.jsx("span",{children:N}),e.jsx("button",{type:"button",className:"file-browser-retry",onClick:()=>C(o),children:"Retry"})]}),e.jsxs("div",{className:"file-browser-body",style:{height:c},children:[e.jsx("div",{className:"file-browser-pane file-browser-tree","aria-label":"Folder tree",children:k&&!m?e.jsx(ui,{}):e.jsx(Sa,{path:o,entries:Y,expanded:x,childrenMap:g,onToggle:we,onNavigate:J,level:0})}),e.jsxs("div",{className:"file-browser-pane file-browser-flat","aria-label":"Directory contents",children:[e.jsxs("div",{className:"file-browser-flat-header",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Type"})]}),k&&!m?e.jsx(hi,{}):e.jsxs(e.Fragment,{children:[(m==null?void 0:m.truncated)&&e.jsxs("div",{className:"file-browser-truncated-banner",role:"status",children:["Showing first 500 of ",m.totalEntries," entries. Navigate into a subfolder to see more."]}),O.length===0?e.jsx("div",{className:"file-browser-empty",children:"This folder is empty"}):e.jsx("div",{className:"file-browser-flat-list",children:O.map((I,Q)=>{const U=I.isDir,le=Q===u,q=I.path===s;return e.jsxs("div",{role:"option","aria-selected":q,className:["file-browser-row",U?"file-browser-row--dir":"file-browser-row--file",le&&"file-browser-row--selected",q&&U&&"file-browser-row--active",!U&&"file-browser-row--disabled"].filter(Boolean).join(" "),onClick:()=>{U&&(d(Q),t(I.path))},onDoubleClick:()=>{U&&J(I)},title:I.path,children:[e.jsx("span",{className:"file-browser-row-icon",children:U?e.jsx(Fe,{size:13}):e.jsx(Ja,{size:13})}),e.jsx("span",{className:"file-browser-row-name",children:I.name}),e.jsx("span",{className:"file-browser-row-type",children:U?"Folder":""})]},I.path)})})]})]})]}),e.jsxs("div",{className:"file-browser-footer-hint",children:["Select a folder, then click Add. Use ",e.jsx("kbd",{children:"↑"})," ",e.jsx("kbd",{children:"↓"})," to navigate, ",e.jsx("kbd",{children:"Enter"})," to confirm."]})]})}function Sa({path:s,entries:t,expanded:a,childrenMap:i,onToggle:n,onNavigate:c,level:o}){return e.jsx("ul",{className:"file-browser-tree-list",role:"group",children:t.map(l=>{const x=a.has(l.path),p=i[l.path]??[];return e.jsxs("li",{className:"file-browser-tree-node",children:[e.jsxs("div",{className:["file-browser-tree-row",x&&"file-browser-tree-row--expanded"].filter(Boolean).join(" "),style:{paddingLeft:`${o*16+8}px`},children:[e.jsx("button",{type:"button",className:"file-browser-tree-toggle",onClick:u=>{u.stopPropagation(),n(l.path)},"aria-label":x?"Collapse":"Expand",children:(p.length>0,x?e.jsx(We,{size:11}):e.jsx(Xe,{size:11}))}),e.jsxs("button",{type:"button",className:"file-browser-tree-name",onClick:()=>c(l),title:l.path,children:[e.jsx(Fe,{size:12}),e.jsx("span",{children:l.name})]})]}),x&&p.length>0&&e.jsx(Sa,{path:l.path,entries:p,expanded:a,childrenMap:i,onToggle:n,onNavigate:c,level:o+1})]},l.path)})})}function ui(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[80,60,90,55,70].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}function hi(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[60,90,70,50,80,65].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}const jt=[{id:"overview",label:"Overview",icon:aa},{id:"chat",label:"Chat",icon:Xs},{id:"agents",label:"Agents",icon:Ye},{id:"artifacts",label:"Glyphs",icon:Hs},{id:"tasks",label:"Tasks",icon:Rs},{id:"activity",label:"Activity",icon:De},{id:"background",label:"Active",icon:Qa},{id:"skills",label:"Skills",icon:He},{id:"memory",label:"Memory",icon:Pe},{id:"mods",label:"Mods",icon:ts},{id:"marketplace",label:"Marketplace",icon:na},{id:"schedules",label:"Schedules",icon:as},{id:"plugins",label:"Plugins",icon:ts},{id:"history",label:"History",icon:$s},{id:"minimax",label:"Usage",icon:Nt},{id:"eval",label:"Eval",icon:Qe},{id:"doctor",label:"Doctor",icon:ia},{id:"settings",label:"Settings",icon:kt}];function xi({activeTab:s,onTabChange:t,wsStatus:a,version:i,activeProject:n,projects:c,onProjectChange:o,onProjectsRefresh:l,onOpenSearch:x,settings:p,rightSlot:u,notificationsSlot:d,showTabs:m=!0,extraTabs:h}){return e.jsxs("header",{className:"topbar",children:[e.jsxs("div",{className:"topbar-row",children:[e.jsxs("div",{className:"brand",children:[e.jsx("span",{className:"brand-logo","aria-hidden":"true",children:"ᛒ"}),e.jsx("span",{className:"brand-title",children:"Bizar"}),e.jsx("span",{className:"brand-version",children:i})]}),e.jsx(pi,{activeProject:n,projects:c,onChange:o,onRefresh:l,settings:p??null}),e.jsxs("button",{type:"button",className:"topbar-search",onClick:x,title:"Search (Ctrl/Cmd+K)","aria-label":"Open search",children:[e.jsx(ye,{size:14}),e.jsx("span",{className:"muted",children:"Search…"}),e.jsx("kbd",{children:"⌘K"})]}),e.jsx("div",{className:"topbar-spacer"}),e.jsxs("div",{className:"topbar-right",children:[d,u,e.jsxs("div",{className:V("ws-status",`ws-${a}`),title:`WebSocket: ${a}`,children:[e.jsx("span",{className:"ws-dot"}),e.jsx("span",{className:"ws-label",children:a})]})]})]}),m&&e.jsxs("nav",{className:"tabs-row",role:"tablist","aria-label":"Primary tabs",children:[jt.map(g=>{const j=g.icon,k=g.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":k,className:V("tab",k&&"tab-active"),onClick:()=>t(g.id),title:g.label,children:[e.jsx(j,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:g.label}),g.id==="settings"&&k&&e.jsx("span",{className:"settings-mode-indicator",title:"Settings mode active",children:e.jsx(Za,{size:12})})]},g.id)}),h&&h.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tab-separator","aria-hidden":"true"}),h.map(g=>{const j=g.icon,k=g.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":k,className:V("tab","tab-mod",k&&"tab-active"),onClick:()=>t(g.id),title:`${g.label} (mod)`,children:[e.jsx(j,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:g.label}),e.jsx("span",{className:"tab-badge",children:"mod"})]},g.id)})]})]})]})}function pi({activeProject:s,projects:t,onChange:a,onRefresh:i,settings:n}){const[c,o]=r.useState(!1),l=$e();r.useEffect(()=>{if(!c)return;const p=()=>o(!1);return document.addEventListener("click",p),()=>document.removeEventListener("click",p)},[c]);const x=()=>{l.open({title:"Add project",children:e.jsx(gi,{settings:n,onAdd:async(p,u)=>{try{await T.post("/projects",{path:p,name:u}),i(),o(!1),l.close()}catch(d){alert(`Add failed: ${d.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx($,{variant:"ghost",onClick:()=>l.close(),children:"Cancel"})})})};return e.jsxs("div",{className:"project-selector",onClick:p=>p.stopPropagation(),children:[e.jsxs("button",{type:"button",className:"project-selector-btn",onClick:()=>o(p=>!p),title:"Switch active project","aria-haspopup":"menu","aria-expanded":c,children:[e.jsx(Fe,{size:14}),e.jsx("span",{className:"project-selector-name",children:(s==null?void 0:s.name)||"(no project)"}),e.jsx(We,{size:12})]}),c&&e.jsxs("div",{className:"project-selector-menu",children:[e.jsxs("div",{className:"project-selector-menu-head",children:[e.jsxs("span",{className:"muted",children:[t.length," project",t.length===1?"":"s"]}),e.jsxs("div",{className:"project-selector-menu-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:i,title:"Refresh","aria-label":"Refresh projects",children:e.jsx(de,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:x,title:"Add project","aria-label":"Add project",children:e.jsx(ze,{size:12})})]})]}),e.jsxs("ul",{className:"project-selector-list",children:[t.length===0&&e.jsx("li",{className:"muted project-selector-empty",children:"No projects. Add one to start."}),t.map(p=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:V("project-selector-item",(s==null?void 0:s.id)===p.id&&"active"),onClick:()=>{a(p.id),o(!1)},children:[e.jsx("span",{className:"project-selector-item-name",children:p.name}),e.jsx("span",{className:"project-selector-item-status",children:p.status})]})},p.id))]})]})]})}function gi({settings:s,onAdd:t}){var d,m;const[a,i]=r.useState(((d=s==null?void 0:s.dashboard)==null?void 0:d.projectsDirectory)??""),[n,c]=r.useState(""),[o,l]=r.useState(!1),[x,p]=r.useState(null),u=async()=>{var h;if(a){l(!0),p(null);try{await T.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(g){const j=g;j.status===404?p("That folder no longer exists. Pick another."):p(((h=j.data)==null?void 0:h.message)??g.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(wa,{value:a,onChange:h=>{i(h),p(null)},projectsDirectory:(m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory,height:320}),x&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:x}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"topbar-add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"topbar-add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:h=>c(h.target.value)})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs($,{variant:"primary",onClick:u,disabled:!a||o,children:[o?e.jsx("span",{className:"btn-spinner"}):null,o?"Checking…":"Add"]})})]})}const fi=[{label:"General",sections:[{id:"theme",label:"Theme",icon:ra},{id:"layout",label:"Layout",icon:Pt},{id:"general",label:"General",icon:Pt}]},{label:"Core",sections:[{id:"env-vars",label:"Env Vars",icon:ns},{id:"providers",label:"Providers",icon:en},{id:"memory",label:"Memory",icon:Pe},{id:"system-llm",label:"System LLM",icon:_s}]},{label:"Experience",sections:[{id:"updates",label:"Updates",icon:de},{id:"skills",label:"Skills",icon:He},{id:"headroom",label:"Headroom",icon:sn}]},{label:"Data",sections:[{id:"backup",label:"Backup",icon:la}]}];function ji({activeSection:s,onSectionChange:t,onExitSettings:a}){return e.jsxs("div",{className:"settings-nav-root","aria-label":"Settings sections",children:[e.jsxs("button",{type:"button",className:"settings-nav-back",onClick:a,"aria-label":"Exit settings",children:[e.jsx(bt,{size:14}),e.jsx("span",{children:"Back"})]}),e.jsx("div",{className:"settings-nav-divider","aria-hidden":"true"}),fi.map(i=>e.jsxs("div",{className:"settings-nav-group",children:[e.jsx("div",{className:"settings-nav-group-label",children:i.label}),i.sections.map(n=>{const c=n.icon,o=s===n.id;return e.jsxs("button",{type:"button",className:V("settings-nav-item",o&&"settings-nav-item-active"),onClick:()=>t(o?null:n.id),"aria-current":o?"page":void 0,children:[c&&e.jsx(c,{size:14,className:"settings-nav-item-icon","aria-hidden":!0}),e.jsx("span",{className:"settings-nav-item-label",children:n.label}),o&&e.jsx(Xe,{size:12,className:"settings-nav-item-chevron","aria-hidden":!0})]},n.id)})]},i.label))]})}function vi({tabs:s,activeTab:t,onTabChange:a,settingsMode:i,settingsActiveSection:n,onSettingsSectionChange:c,onExitSettings:o}){if(i)return e.jsx("aside",{className:"sidebar sidebar-settings-mode","aria-label":"Settings navigation",children:e.jsx(ji,{activeSection:n??null,onSectionChange:c??(()=>{}),onExitSettings:o??(()=>{})})});const l=s.filter(p=>!p.isMod),x=s.filter(p=>p.isMod);return e.jsx("aside",{className:"sidebar","aria-label":"Primary navigation",children:e.jsxs("nav",{className:"sidebar-nav",role:"tablist",children:[l.map(p=>{const u=p.icon,d=p.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:V("sidebar-tab",d&&"sidebar-tab-active"),onClick:()=>a(p.id),title:p.label,children:[e.jsx(u,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:p.label})]},p.id)}),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sidebar-section-divider","aria-hidden":"true"}),e.jsx("div",{className:"sidebar-section-label",children:"Mods"}),x.map(p=>{const u=p.icon,d=p.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:V("sidebar-tab","sidebar-tab-mod",d&&"sidebar-tab-active"),onClick:()=>a(p.id),title:`${p.label} (mod)`,children:[e.jsx(u,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:p.label})]},p.id)})]})]})})}const tt=[{id:"all",label:"All"},{id:"projects",label:"Projects"},{id:"agents",label:"Agents"},{id:"tasks",label:"Tasks"},{id:"mods",label:"Mods"},{id:"schedules",label:"Schedules"},{id:"commands",label:"Commands"},{id:"settings",label:"Settings"}],Ot={all:null,projects:"project",agents:"agent",tasks:"task",mods:"mod",schedules:"schedule",commands:"command",settings:"setting"};function yi({open:s,onClose:t,onSelect:a}){const i=re(),[n,c]=r.useState(""),[o,l]=r.useState("all"),[x,p]=r.useState([]),[u,d]=r.useState(!1),[m,h]=r.useState(0),g=r.useRef(null),j=r.useRef(null);if(r.useEffect(()=>{let S;return s&&(j.current=document.activeElement instanceof HTMLElement?document.activeElement:null,c(""),p([]),h(0),S=window.setTimeout(()=>{var E;return(E=g.current)==null?void 0:E.focus()},30)),()=>{if(S&&window.clearTimeout(S),!s)return;const E=j.current;E&&E.isConnected&&E.focus()}},[s]),r.useEffect(()=>{if(!s)return;if(!n.trim()){p([]),h(0);return}let S=!1;d(!0);const E=setTimeout(()=>{T.get(`/search?q=${encodeURIComponent(n)}&scope=${o}`).then(v=>{S||(p(v.results||[]),h(0))}).catch(v=>{S||i.error(`Search failed: ${v.message}`)}).finally(()=>!S&&d(!1))},150);return()=>{S=!0,clearTimeout(E)}},[n,o,s,i]),!s)return null;const k={};for(const S of x){const E=S.type.toLowerCase();k[E]=k[E]||[],k[E].push(S)}const z=[];for(const S of tt.map(E=>E.id)){const E=Ot[S];E&&k[E]&&z.push(...k[E])}const N=S=>{if(S.key==="Escape")t();else if(S.key==="ArrowDown"){if(S.preventDefault(),z.length===0)return;h(E=>Math.min(E+1,z.length-1))}else if(S.key==="ArrowUp"){if(S.preventDefault(),z.length===0)return;h(E=>Math.max(E-1,0))}else S.key==="Enter"&&z[m]&&(S.preventDefault(),a(z[m]),t())};return e.jsx("div",{className:"search-modal-backdrop",onClick:t,children:e.jsxs("div",{className:"search-modal",role:"dialog","aria-modal":"true","aria-labelledby":"search-modal-title",onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{className:"search-modal-head",role:"search",children:[e.jsx(ye,{size:14,"aria-hidden":!0}),e.jsx("span",{id:"search-modal-title",className:"sr-only",children:"Search"}),e.jsx("input",{ref:g,className:"search-modal-input",placeholder:"Search tasks, agents, settings, projects…",value:n,onChange:S=>c(S.target.value),onKeyDown:N,"aria-label":"Search"}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:e.jsx(Ne,{size:14})})]}),e.jsx("div",{className:"search-modal-scopes",role:"tablist","aria-label":"Search scope",children:tt.map(S=>e.jsx("button",{type:"button",role:"tab","aria-selected":o===S.id,className:V("search-scope",o===S.id&&"search-scope-active"),onClick:()=>l(S.id),children:S.label},S.id))}),e.jsxs("div",{className:"search-modal-body",children:[u&&e.jsx("div",{className:"muted",children:"Searching…"}),!u&&n&&z.length===0&&e.jsx("div",{className:"muted",children:"No results."}),!u&&!n&&e.jsx("div",{className:"muted",children:"Type to search…"}),tt.map(S=>{const E=Ot[S.id];if(!E)return null;const v=k[E];return!v||v.length===0?null:e.jsxs("div",{className:"search-group",children:[e.jsx("div",{className:"search-group-head",children:S.label}),v.map(b=>{const w=z.indexOf(b);return e.jsxs("button",{type:"button",className:V("search-result",w===m&&"search-result-active"),onMouseEnter:()=>h(w),onClick:()=>{a(b),t()},children:[e.jsx("span",{className:"search-result-type",children:b.type}),e.jsx("span",{className:"search-result-label",children:bi(b)})]},`${b.type}-${w}`)})]},S.id)})]}),e.jsx("div",{className:"search-modal-foot",children:e.jsx("span",{className:"muted",children:"↑↓ navigate · ↵ open · esc close"})})]})})}function bi(s){const t=s.item||{};if(s.type==="project")return`${t.name} — ${t.path}`;if(s.type==="agent")return`${t.name} — ${t.description||t.model||""}`;if(s.type==="task")return`${t.title} — ${t.status||""}`;if(s.type==="mod")return`${t.name} v${t.version} — ${t.description||""}`;if(s.type==="schedule")return`${t.name} (${t.type}: ${t.schedule})`;if(s.type==="command")return`${t.name} — ${t.description||""}`;if(s.type==="setting"){const a=t.value===null||t.value===void 0?"":typeof t.value=="string"?` = ${t.value}`:` = ${JSON.stringify(t.value)}`;return`${t.label}${a} — ${t.desc||""}`.trim()}return JSON.stringify(t).slice(0,80)}const Ni={info:wt,success:qe,warning:Te,error:ta};function ki({onCountChange:s,wsSubscribe:t}){const a=re(),[i,n]=r.useState(!1),[c,o]=r.useState([]),[l,x]=r.useState(null),[p,u]=r.useState(!1),d=r.useRef(null),m=r.useRef(0),h=async()=>{var N;try{u(!0);const S=await T.get("/notifications?limit=200");o(S.notifications||[]),x(S.stats||null),m.current=((N=S.stats)==null?void 0:N.unread)||0,s==null||s(m.current)}catch(S){console.warn("[notifications] reload failed:",S.message)}finally{u(!1)}};r.useEffect(()=>{h()},[]),r.useEffect(()=>t?t(S=>{if(S.type==="notification:new"){const E=S.notification;o(v=>[E,...v.filter(b=>b.id!==E.id)]),E.read||(m.current+=1,x(v=>v?{...v,unread:(v.unread||0)+1}:{total:1,unread:1,lastTs:E.ts,counts:{[E.severity||"info"]:1}}),s==null||s(m.current))}else S.type==="notifications:change"&&h()}):void 0,[t]),r.useEffect(()=>{if(!i)return;const N=E=>{d.current&&(d.current.contains(E.target)||n(!1))},S=E=>{E.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",N),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",S)}},[i]);const g=async()=>{try{await T.post("/notifications/read-all",{}),o(N=>N.map(S=>({...S,read:!0}))),x(N=>N&&{...N,unread:0}),m.current=0,s==null||s(0),a.success("All notifications marked as read.",1500)}catch(N){a.error(`Failed: ${N.message}`)}},j=async N=>{try{await T.post(`/notifications/${encodeURIComponent(N)}/read`,{}),o(S=>S.map(E=>E.id===N?{...E,read:!0}:E)),x(S=>S&&{...S,unread:Math.max(0,(S.unread||1)-1)}),m.current=Math.max(0,m.current-1),s==null||s(m.current)}catch(S){a.error(`Failed: ${S.message}`)}},k=async N=>{try{await T.del(`/notifications/${encodeURIComponent(N)}`),o(S=>{const E=S.find(v=>v.id===N);return E&&!E.read&&(m.current=Math.max(0,m.current-1),x(v=>v&&{...v,unread:Math.max(0,v.unread-1)}),s==null||s(m.current)),S.filter(v=>v.id!==N)})}catch(S){a.error(`Failed: ${S.message}`)}},z=(l==null?void 0:l.unread)||0;return e.jsxs("div",{className:"notifications-root",ref:d,children:[e.jsxs("button",{type:"button",className:V("topbar-icon-btn notifications-bell",i&&"is-open"),onClick:()=>n(N=>!N),title:"Notifications","aria-label":"Notifications","aria-haspopup":"true","aria-expanded":i,children:[e.jsx(tn,{size:16}),z>0&&e.jsx("span",{className:"notifications-badge",children:z>99?"99+":z})]}),i&&e.jsxs("div",{className:"notifications-panel",role:"dialog","aria-label":"Notifications",children:[e.jsxs("header",{className:"notifications-panel-head",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Notifications"}),z>0&&e.jsxs("span",{className:"muted text-sm",children:[" · ",z," unread"]})]}),e.jsxs("div",{className:"notifications-panel-head-actions",children:[e.jsxs($,{size:"sm",variant:"ghost",onClick:g,disabled:z===0,children:[e.jsx(gs,{size:12})," Mark all read"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>n(!1),"aria-label":"Close",title:"Close",children:e.jsx(Ne,{size:14})})]})]}),e.jsx("div",{className:"notifications-list",children:p&&c.length===0?e.jsx("div",{className:"notifications-empty muted",children:"Loading…"}):c.length===0?e.jsx("div",{className:"notifications-empty muted",children:"No notifications yet."}):c.map(N=>{const S=Ni[N.severity]||wt;return e.jsxs("div",{className:V("notification-item",!N.read&&"is-unread",`severity-${N.severity}`),children:[e.jsx(S,{size:14,className:`notification-icon severity-${N.severity}`}),e.jsxs("div",{className:"notification-body",children:[N.title&&e.jsx("div",{className:"notification-title",children:N.title}),e.jsx("div",{className:"notification-msg",children:N.message}),e.jsxs("div",{className:"notification-meta muted",children:[e.jsx("span",{className:"mono",children:N.source}),e.jsx("span",{children:"·"}),e.jsx("span",{children:Ce(N.ts)})]})]}),e.jsxs("div",{className:"notification-actions",children:[!N.read&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>j(N.id),title:"Mark as read","aria-label":"Mark as read",children:e.jsx(gs,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",onClick:()=>k(N.id),title:"Remove","aria-label":"Remove",children:e.jsx(Ne,{size:12})})]})]},N.id)})}),e.jsx("footer",{className:"notifications-panel-foot",children:e.jsx("span",{className:"muted text-sm",children:l?`${l.total} total · last ${Ce(l.lastTs||new Date().toISOString())}`:""})})]})]})}function wi({data:s,onClose:t}){const a=s==null?void 0:s.enabled;s==null||s.previousEnabled;const i=s==null?void 0:s.mode,n=s==null?void 0:s.defaultTemplate,c=s==null?void 0:s.lastUsedSlug,o=i==="toggle";return e.jsxs("div",{children:[o?e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Visual plan mode has been ",e.jsx("strong",{children:a?"enabled":"disabled"}),".",a?" The agent will create a plan and wait for your feedback on complex tasks.":" The agent will work without a visual plan canvas."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:8,fontWeight:600},children:["Visual Plan: ",e.jsx("span",{style:{color:a?"var(--color-success)":"var(--color-muted)"},children:a?"ON":"OFF"})]}),e.jsx("p",{style:{lineHeight:1.6,color:"var(--color-muted)",fontSize:13},children:"When enabled, the agent creates a visual plan and waits for your feedback before proceeding with complex tasks."}),n&&e.jsxs("p",{style:{marginTop:8,fontSize:13,color:"var(--color-muted)"},children:["Default template: ",e.jsx("code",{children:n})]}),c&&e.jsxs("p",{style:{fontSize:13,color:"var(--color-muted)"},children:["Last used plan: ",e.jsx("code",{children:c})]}),e.jsxs("p",{style:{marginTop:12,fontSize:13,color:"var(--color-muted)"},children:["Use ",e.jsx("code",{children:"/visual-plan on"})," or ",e.jsx("code",{children:"/visual-plan off"})," to toggle."]})]}),e.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:e.jsx($,{variant:"ghost",onClick:t,children:"Close"})})]})}const Si=["blank","feature-design","bug-investigation","decision-record","horizontal","vertical"];function Ci({data:s,onClose:t}){const a=(s==null?void 0:s.templates)??Si,i=(s==null?void 0:s.defaultTemplate)??"blank",[n,c]=r.useState(""),[o,l]=r.useState(i),[x,p]=r.useState(!1),[u,d]=r.useState(null),m=async()=>{if(!n.trim()){d("Slug is required.");return}if(!/^[a-z0-9][a-z0-9-]{0,63}$/.test(n)){d("Invalid slug. Use lowercase letters, numbers, and hyphens. Must start with an alphanumeric character.");return}p(!0),d(null);try{await T.post("/artifacts",{slug:n,template:o}),t()}catch(h){d(h.message),p(!1)}};return e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:["Create a new visual plan. Plans are stored in ",e.jsx("code",{children:"artifacts/"})," in your worktree."]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-slug",children:"Plan slug"}),e.jsx("input",{id:"plan-slug",className:"input",type:"text",placeholder:"e.g. my-feature",value:n,onChange:h=>{c(h.target.value),d(null)},autoFocus:!0})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-template",children:"Template"}),e.jsx("select",{id:"plan-template",className:"select",value:o,onChange:h=>l(h.target.value),children:a.map(h=>e.jsx("option",{value:h,children:h},h))})]}),u&&e.jsx("p",{style:{marginBottom:12,color:"var(--color-danger)",fontSize:13},children:u}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx($,{variant:"ghost",onClick:t,disabled:x,children:"Cancel"}),e.jsx($,{variant:"primary",onClick:m,disabled:x||!n.trim(),children:x?"Creating…":"Create"})]})]})}function zi({data:s,onClose:t}){const a=(s==null?void 0:s.plans)??[],i=(s==null?void 0:s.count)??a.length,n=c=>{window.open(`/artifacts/${c}/`,"_blank")};return e.jsxs("div",{children:[a.length===0?e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:["No plans found in this worktree. Use ",e.jsx("code",{children:"/artifact new <slug>"})," to create one."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:12,fontSize:13,color:"var(--color-muted)"},children:[i," plan",i!==1?"s":""," in this worktree:"]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0},children:a.map(c=>e.jsxs("li",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 0",borderBottom:"1px solid var(--color-border)"},children:[e.jsx("code",{style:{fontSize:13},children:c}),e.jsx($,{variant:"ghost",size:"sm",onClick:()=>n(c),children:"Open"})]},c))})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx($,{variant:"ghost",onClick:t,children:"Close"})})]})}function Ti({data:s,onClose:t}){const a=(s==null?void 0:s.commands)??[],i=(s==null?void 0:s.templates)??[],n=(s==null?void 0:s.statuses)??[];return e.jsxs("div",{children:[a.length>0?e.jsx("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:16,fontSize:13},children:e.jsx("tbody",{children:a.map(c=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e.jsx("td",{style:{padding:"5px 8px 5px 0",whiteSpace:"nowrap"},children:e.jsx("code",{style:{fontSize:12},children:c.cmd})}),e.jsx("td",{style:{padding:"5px 0",color:"var(--color-muted)"},children:c.desc})]},c.cmd))})}):e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:"No commands available."}),i.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available templates:"}),e.jsx("p",{style:{fontSize:13},children:i.join(", ")})]}),n.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available statuses:"}),e.jsx("p",{style:{fontSize:13},children:n.join(", ")})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx($,{variant:"ghost",onClick:t,children:"Close"})})]})}function Ri({data:s,onClose:t}){const[a,i]=r.useState(!1),[n,c]=r.useState(null),o=async()=>{i(!0),c(null);try{const l=await T.post("/chat/audit",{});c(l)}catch(l){c({ok:!1,findings:[],error:l.message})}finally{i(!1)}};return e.jsx("div",{children:n===null?e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:"Run a security audit of your Bizar agent configuration. The audit checks for common misconfigurations, exposed secrets, and insecure defaults."}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx($,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx($,{variant:"primary",onClick:o,disabled:a,children:a?"Running…":"Run Audit"})]})]}):e.jsxs(e.Fragment,{children:[n.ok?e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:12,fontWeight:600,color:"var(--color-success)"},children:"Audit passed — no issues found."}),n.findings.length>0&&e.jsx("ul",{style:{marginBottom:16,paddingLeft:20},children:n.findings.map((l,x)=>e.jsx("li",{style:{marginBottom:4,fontSize:13},children:l},x))})]}):e.jsxs("p",{style:{marginBottom:16,color:"var(--color-danger)"},children:["Audit failed: ",n.error??"unknown error"]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx($,{variant:"ghost",onClick:t,children:"Close"})})]})})}function $i({dialog:s,onClose:t}){if(!s.data)return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:`Command: ${s.command}`}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]});const{message:a,detail:i,url:n}=s.data;return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:a??`Command: ${s.command}`}),i&&e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:i}),n&&e.jsx("p",{style:{marginBottom:16},children:e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:n})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]})}function Ai({dialog:s,onClose:t}){switch(s.component){case"visual-artifact":return e.jsx(wi,{data:s.data,onClose:t});case"artifact-create":return e.jsx(Ci,{data:s.data,onClose:t});case"artifact-list":return e.jsx(zi,{data:s.data,onClose:t});case"help":return e.jsx(Ti,{data:s.data,onClose:t});case"audit":return e.jsx(Ri,{data:s.data,onClose:t});default:return e.jsx($i,{dialog:s,onClose:t})}}function Mi({setActiveTab:s,refreshKey:t=0}){var p;const[a,i]=r.useState(null),[n,c]=r.useState(!0),o=async()=>{c(!0);try{const[u,d,m]=await Promise.all([T.get("/memory/status").catch(()=>null),T.get("/memory/health").catch(()=>null),T.get("/memory/lightrag/stats").catch(()=>null)]);i({initialized:!!(u!=null&&u.initialized),mode:u==null?void 0:u.mode,projectId:u==null?void 0:u.projectId,vaultRoot:u==null?void 0:u.vaultRoot,branch:u==null?void 0:u.branch,gitClean:u==null?void 0:u.gitClean,noteCount:(u==null?void 0:u.noteCount)||0,healthScore:d==null?void 0:d.score,healthStatus:d==null?void 0:d.status,lightrag:m?{running:m.running,indexedApprox:m.indexedApprox}:void 0})}catch{i({initialized:!1})}finally{c(!1)}};r.useEffect(()=>{o()},[t]);const l=()=>s("memory"),x=(a==null?void 0:a.healthStatus)==="healthy"?"var(--success)":(a==null?void 0:a.healthStatus)==="degraded"?"var(--warning)":(a==null?void 0:a.healthStatus)==="unhealthy"?"var(--error)":"var(--text-dim)";return e.jsxs(G,{className:"memory-overview-card",children:[e.jsxs(te,{children:[e.jsx(Pe,{size:14})," Memory",e.jsxs($,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:l,children:["Open Memory ",e.jsx(ys,{size:12})]}),e.jsx($,{variant:"ghost",size:"sm",onClick:o,"aria-label":"Refresh",title:"Refresh",children:e.jsx(de,{size:12})})]}),e.jsx(ne,{children:"LightRAG + Obsidian vault + git sync — opens the dedicated Memory tab."}),a!=null&&a.initialized?e.jsxs("div",{className:"memory-status-card-grid",children:[e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(De,{size:11})," Health"]}),e.jsx("div",{className:"memory-status-card-value",style:{color:x},children:a.healthScore!==void 0?`${a.healthScore}/100`:"—"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.healthStatus||"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(Pe,{size:11})," LightRAG"]}),e.jsx("div",{className:"memory-status-card-value",children:(p=a.lightrag)!=null&&p.running?"running":"stopped"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.lightrag?`${a.lightrag.indexedApprox} chunks`:"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(be,{size:11})," Vault"]}),e.jsxs("div",{className:"memory-status-card-value",children:[a.noteCount," notes"]}),e.jsx("div",{className:"memory-status-card-sub muted ellipsis",title:a.vaultRoot||"",children:a.vaultRoot?a.vaultRoot.split("/").slice(-2).join("/"):"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(is,{size:11})," Git"]}),e.jsx("div",{className:"memory-status-card-value",children:a.gitClean===null?a.mode==="local-only"?"local-only":"—":a.gitClean?"clean":"dirty"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.branch?`branch ${a.branch}`:_e(a.branch||"")||"—"})]})]}):e.jsxs("div",{className:"muted",children:["Memory not initialised. Click ",e.jsx("strong",{children:"Open Memory"})," to set it up."]}),n&&!a&&e.jsx("div",{className:"muted text-sm",children:"Loading…"})]})}function pe({icon:s,title:t,message:a,action:i,className:n}){return e.jsxs("div",{className:V("empty-state",n),children:[e.jsx("div",{className:"empty-icon",children:s??e.jsx(Gs,{size:32})}),e.jsx("div",{className:"empty-title",children:t}),a&&e.jsx("div",{className:"empty-message",children:a}),i&&e.jsx("div",{className:"empty-action",children:i})]})}function Ii({snapshot:s,settings:t,setActiveTab:a,refreshSnapshot:i}){var J,ae,ee;const n=re(),c=$e(),o=r.useRef(null),[l,x]=r.useState(s.overview??null),[p,u]=r.useState(!s.overview),[d,m]=r.useState(s.projects||[]),[h,g]=r.useState(((J=s.activeProject)==null?void 0:J.id)||null),[j,k]=r.useState(s.mods||[]),[z,N]=r.useState(!1),[S,E]=r.useState(((ae=s.overview)==null?void 0:ae.recentActivity)??[]),[v,b]=r.useState(!1),[w,f]=r.useState(new Set);r.useEffect(()=>{let F=!1;return(async()=>{try{const H=await T.get("/activity/hidden");F||f(new Set(H.hidden||[]))}catch{}})(),()=>{F=!0}},[]);const L=(F,H)=>{const K=`${F.kind||""}|${F.ts||""}|${F.slug||F.title||""}|${H}`;let B=0;for(let Z=0;Z<K.length;Z++)B=(B<<5)-B+K.charCodeAt(Z)|0;return Math.abs(B).toString(16).padStart(8,"0").slice(0,16)},R=async F=>{const H=new Set(w);H.add(F),f(H);try{await T.post("/activity/hide",{keys:[F]})}catch(K){const B=new Set(w);f(B),n.error(`Hide failed: ${K.message}`)}},y=async()=>{if(!confirm("Hide every recent activity item from the overview? The full log stays in Settings → Activity Log."))return;const F=S.map((K,B)=>L(K,B)),H=new Set(w);F.forEach(K=>H.add(K)),f(H);try{await T.post("/activity/hide",{keys:F}),n.success(`Hidden ${F.length} item(s). Restore them in Settings → Activity Log.`)}catch(K){n.error(`Clear failed: ${K.message}`)}},A=async()=>{f(new Set);try{await T.del("/activity/hide"),n.success("All hidden activity restored to the overview.")}catch(F){n.error(`Restore failed: ${F.message}`)}};r.useEffect(()=>{var F;s.overview&&(x(s.overview),E(s.overview.recentActivity??[]),u(!1)),m(s.projects||[]),g(((F=s.activeProject)==null?void 0:F.id)||null),k(s.mods||[])},[s.overview,s.projects,s.activeProject,s.mods]),r.useEffect(()=>{let F;try{const H=T.getToken(),K=H?`/api/activity/stream?token=${encodeURIComponent(H)}`:"/api/activity/stream";F=new EventSource(K),F.addEventListener("snapshot",B=>{try{const Z=JSON.parse(B.data);E(Array.isArray(Z.events)?Z.events.slice(0,50):[])}catch{}}),F.addEventListener("activity",B=>{try{const Z=JSON.parse(B.data);E(he=>[Z,...he].slice(0,50))}catch{}})}catch{}return()=>{try{F==null||F.close()}catch{}}},[]);const P=async()=>{n.info("Refreshing…",1500),await i();try{const F=await T.get("/projects");m(F.projects||[]),g(F.active||null)}catch{}},C=()=>{c.open({title:"Add project",children:e.jsx(Ei,{settings:t,onAdd:async(F,H)=>{try{const K=await T.post("/projects",{path:F,name:H});m(B=>[...B.filter(Z=>Z.id!==K.id),K]),n.success("Project added."),c.close()}catch(K){n.error(`Add failed: ${K.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx($,{variant:"ghost",onClick:()=>c.close(),children:"Cancel"})})})},D=async()=>{var F;try{const H=await T.post("/projects/auto-detect");m(H.projects||[]),g(H.active||null);const K=(F=H.projects)==null?void 0:F.find(B=>B.id===H.active);n.success(K?`Active: ${K.name}`:"Projects refreshed."),await i()}catch(H){n.error(`Auto-detect failed: ${H.message}`)}},Y=async F=>{try{await T.post(`/projects/${encodeURIComponent(F)}/activate`),g(F),n.success("Project activated."),await i()}catch(H){n.error(`Activate failed: ${H.message}`)}},O=async F=>{if(confirm(`Remove project "${F}" from the registry?`))try{await T.del(`/projects/${encodeURIComponent(F)}`),m(H=>H.filter(K=>K.id!==F)),h===F&&g(null),n.success("Project removed.")}catch(H){n.error(`Remove failed: ${H.message}`)}};return p||!l?e.jsxs("div",{className:"view-loading",children:[e.jsx(oe,{size:"lg"}),e.jsx("p",{children:"Loading overview…"})]}):e.jsxs("div",{className:"view view-overview",children:[e.jsxs("div",{className:"overview-hero-noframe",children:[e.jsx("h1",{children:"What do you want to do?"}),e.jsx("p",{className:"overview-hero-subtitle",children:"Describe what you want — Odin will split it into tasks, create a plan, delegate to background agents, and track progress in real time."}),e.jsxs("form",{className:"overview-hero-form-noframe",onSubmit:async F=>{var K,B;F.preventDefault();const H=(((K=o.current)==null?void 0:K.value)||"").trim();if(H){N(!0);try{const Z=await T.post("/tasks/submit",{title:H});n.success(`Odin split it into ${((B=Z.subtasks)==null?void 0:B.length)||1} task(s)`),o.current&&(o.current.value=""),await i()}catch(Z){n.error(`Failed: ${Z.message}`)}finally{N(!1)}}},children:[e.jsx("label",{htmlFor:"overview-hero-input",className:"sr-only",children:"Describe what you want Odin to do"}),e.jsx("textarea",{id:"overview-hero-input",ref:o,className:"overview-input-hero",placeholder:"e.g. Implement user authentication with email + password, including registration, login, password reset, and integration tests. Use Bcrypt, JWT tokens, and the existing API style.",disabled:z,"aria-label":"Describe what you want Odin to do"}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-2)",alignItems:"center",flexWrap:"wrap"},children:[e.jsxs($,{type:"submit",variant:"primary",size:"lg",disabled:z,children:[z?e.jsx(oe,{size:"sm"}):e.jsx(rs,{size:16}),"Submit to Odin"]}),e.jsxs("span",{className:"muted",style:{fontSize:12},children:[e.jsx(He,{size:12,style:{display:"inline",verticalAlign:-2,color:"var(--accent)"}})," ","Odin + 12 specialist agents available"]})]})]}),e.jsx("div",{className:"overview-quick-actions-row",children:["Implement feature","Fix bug","Refactor","Investigate","Add tests","Document","Optimize","Deploy"].map(F=>e.jsx("button",{type:"button",className:"overview-quick-chip",onClick:()=>{o.current&&(o.current.value=F,o.current.focus())},children:F},F))})]}),e.jsxs("div",{className:"overview-feed",children:[e.jsxs("div",{className:"overview-feed-head",children:[e.jsx("h2",{children:"Recent activity"}),e.jsxs("div",{className:"overview-feed-head-actions",children:[w.size>0&&e.jsxs($,{variant:"ghost",size:"sm",onClick:A,title:"Restore hidden items to this overview",children:[e.jsx(fs,{size:12})," Show ",w.size," hidden"]}),S.length>8&&e.jsx($,{variant:"ghost",size:"sm",onClick:()=>b(F=>!F),children:v?"Show less":"Show all"}),S.length>0&&e.jsxs($,{variant:"ghost",size:"sm",onClick:y,title:"Hide every item from the overview (full log kept)",children:[e.jsx(pt,{size:12})," Hide all"]})]})]}),w.size>0&&e.jsxs("div",{className:"activity-hidden-banner",role:"status",children:[e.jsxs("span",{children:[e.jsx(pt,{size:12,style:{verticalAlign:-2,marginRight:6}}),w.size," item",w.size===1?"":"s"," hidden from the overview."]}),e.jsxs($,{variant:"ghost",size:"sm",onClick:A,children:[e.jsx(fs,{size:12})," Show them again"]})]}),S.length===0?e.jsx("div",{className:"muted",style:{padding:"24px 0",fontSize:13},children:"No activity yet. Use the chat above or invoke a Bizar command to start a feed."}):e.jsxs("div",{className:V("activity-feed-list-wrap",!v&&"activity-feed-list-wrap-collapsed"),"aria-live":"polite","aria-relevant":"additions",children:[e.jsx(Mt,{items:S.slice(0,30).filter((F,H)=>!w.has(L(F,H))),itemHeight:60,height:Math.min(S.filter((F,H)=>!w.has(L(F,H))).length*60,480),className:"activity-feed-list",renderItem:(F,H)=>{const K=S.slice(0,30).findIndex(B=>B===F);return e.jsx(Wi,{item:F,activityKey:L(F,K),onNavigate:a,onHide:R})}}),!v&&S.length>8&&e.jsx("div",{className:"activity-feed-fade","aria-hidden":"true"})]})]}),e.jsxs(G,{className:"project-picker",children:[e.jsxs(te,{children:[e.jsx(Fe,{size:14})," Projects",e.jsxs($,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:C,children:[e.jsx(ze,{size:12})," Add"]}),e.jsxs($,{variant:"ghost",size:"sm",onClick:D,title:"Use the server's working directory",children:[e.jsx(ze,{size:12})," Auto-detect"]}),((ee=t==null?void 0:t.dashboard)==null?void 0:ee.projectsDirectory)&&e.jsxs($,{variant:"ghost",size:"sm",title:`Scan ${t.dashboard.projectsDirectory} for projects`,onClick:async()=>{try{const F=await T.post("/projects/scan");F.error?n.error(F.error):n.success(`Added ${F.added.length}, skipped ${F.skipped}.`),await i();const H=await T.get("/projects");m(H.projects||[]),g(H.active||null)}catch(F){n.error(`Scan failed: ${F.message}`)}},children:[e.jsx(an,{size:12})," Scan"]}),e.jsx($,{variant:"ghost",size:"sm",onClick:P,title:"Refresh",children:e.jsx(de,{size:12})})]}),e.jsxs(ne,{children:[d.length," project",d.length===1?"":"s"," ·"," ",l.counts.agents," agents ·"," ",l.counts.sessions," session",l.counts.sessions===1?"":"s"]}),d.length===0?e.jsx(pe,{icon:e.jsx(Fe,{size:32}),title:"No projects yet",message:"Add a project to start tracking its tasks, plans, and schedules.",action:e.jsxs("div",{className:"empty-state-actions",children:[e.jsxs($,{variant:"primary",onClick:D,children:[e.jsx(ze,{size:14})," Use current directory"]}),e.jsx($,{variant:"secondary",onClick:C,children:"Add by path…"})]})}):e.jsx("div",{className:"project-grid",children:d.map(F=>e.jsx(Li,{project:F,active:h===F.id,onOpen:()=>Y(F.id),onRemove:()=>O(F.id)},F.id))})]}),e.jsx(Mi,{setActiveTab:a}),e.jsxs("div",{className:"overview-cols",children:[e.jsxs(G,{children:[e.jsx(te,{children:"Mods"}),e.jsxs(ne,{children:["Extensions installed under ",e.jsx("code",{children:"~/.config/bizar/mods/"})]}),j.length===0?e.jsx("div",{className:"muted",children:"No mods installed."}):e.jsx("ul",{className:"mod-mini-list",children:j.map(F=>e.jsxs("li",{className:"mod-mini",children:[e.jsx("span",{className:"mod-mini-name",children:F.name}),e.jsxs("span",{className:"mod-mini-meta",children:["v",F.version," · ",F.type]}),e.jsx("span",{className:`mod-mini-pill ${F.enabled?"mod-mini-pill-on":"mod-mini-pill-off"}`,children:F.enabled?"on":"off"})]},F.id))})]}),e.jsxs(G,{children:[e.jsx(te,{children:"Environment"}),e.jsx(ne,{children:"Runtime + paths"}),e.jsxs("dl",{className:"env-table",children:[e.jsx("dt",{children:"Node"}),e.jsx("dd",{className:"mono",children:l.versions.node}),e.jsx("dt",{children:"Platform"}),e.jsx("dd",{className:"mono",children:l.versions.platform}),e.jsx("dt",{children:"Project root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.projectRoot,children:l.versions.projectRoot}),e.jsx("dt",{children:"Bizar root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.bizarRoot,children:l.versions.bizarRoot}),e.jsx("dt",{children:"Generated"}),e.jsx("dd",{className:"mono tabular-nums",children:_e(l.generatedAt)})]})]})]})]})}function Ei({settings:s,onAdd:t}){var d,m;const[a,i]=r.useState(((d=s==null?void 0:s.dashboard)==null?void 0:d.projectsDirectory)??""),[n,c]=r.useState(""),[o,l]=r.useState(!1),[x,p]=r.useState(null),u=async()=>{var h;if(a){l(!0),p(null);try{await T.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(g){const j=g;j.status===404?p("That folder no longer exists. Pick another."):p(((h=j.data)==null?void 0:h.message)??g.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(wa,{value:a,onChange:h=>{i(h),p(null)},projectsDirectory:(m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory,height:320}),x&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:x}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:h=>c(h.target.value)}),e.jsx("p",{className:"field-help",style:{marginTop:4},children:"Display name for this project. Defaults to the folder name."})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs($,{variant:"primary",onClick:u,disabled:!a||o,children:[o?e.jsx("span",{className:"btn-spinner"}):null,o?"Checking…":"Add"]})})]})}function Li({project:s,active:t,onOpen:a,onRemove:i}){const n={active:"status-on",inactive:"status-neutral",error:"status-error"}[s.status]||"status-neutral";return e.jsxs("div",{className:`project-card ${t?"project-card-active":""}`,children:[e.jsxs("div",{className:"project-card-head",children:[e.jsx("span",{className:`project-card-status ${n}`,children:s.status}),e.jsx("div",{className:"project-card-name",children:s.name}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Remove project",title:"Remove",onClick:c=>{c.stopPropagation(),i()},children:e.jsx(ke,{size:12})})]}),e.jsx("div",{className:"project-card-path mono ellipsis",title:s.path,children:s.path}),e.jsx("div",{className:"project-card-meta",children:s.lastAccessed&&e.jsxs("span",{className:"muted",children:["Last opened ",Ce(s.lastAccessed)]})}),e.jsx("div",{className:"project-card-actions",children:e.jsx($,{variant:t?"ghost":"primary",size:"sm",onClick:a,children:t?e.jsxs(e.Fragment,{children:[e.jsx(St,{size:12})," Active"]}):e.jsx(e.Fragment,{children:"Open"})})})]})}function Di(s){return s&&s.charAt(0).toUpperCase()+s.slice(1)}function Pi(s){const t=s.trim().toLowerCase().replace(/[:_]/g,"."),[a,i="updated"]=t.split("."),n={settings:"Settings",task:"Task",tasks:"Task",agent:"Agent",agents:"Agent",plan:"Plan",plans:"Plan",bg:"Background job",background:"Background job",session:"Session",mod:"Mod",mods:"Mod",provider:"Provider",providers:"Provider"},c={create:"created",created:"created",add:"added",added:"added",update:"updated",updated:"updated",delegate:"delegated",delegated:"delegated",invoke:"invoked",invoked:"invoked",restart:"restarted",restarted:"restarted",delete:"deleted",deleted:"deleted",remove:"removed",removed:"removed",archive:"archived",archived:"archived",restore:"restored",restored:"restored",complete:"completed",completed:"completed",fail:"failed",failed:"failed",error:"errored",stuck:"marked stuck"},o=n[a]||Di(a.replace(/-/g," ")),l=c[i]||i.replace(/-/g," ");return`${o} ${l}`.trim()}function Fs(s,t){for(const a of t){const i=s[a];if(typeof i=="string"&&i.trim())return i.trim()}return""}function Fi(s){const t=Fs(s,["message","text","prompt","title","name"]);if(t)return t;const a=[],i=Fs(s,["slug"]),n=Fs(s,["agent","author"]),c=Fs(s,["status"]);return i&&a.push(`Plan ${i}`),n&&a.push(n),c&&a.push(c),a.length?a.join(" · "):"No additional details."}function Oi(s){return Ce(s)}function Bi(s){const t=(s.kind||"").toLowerCase(),a=(s.status||"").toLowerCase();return t.includes("error")||a==="error"||a==="failure"?"error":t.includes("warn")||a==="blocked"?"warning":t.includes("done")||t.includes("success")||a==="done"?"success":"info"}function Ui(s){const t=s.toLowerCase();return t==="task"?Rs:t==="agent"?Ye:t==="plan"?Hs:t.includes("bg")||t.includes("background")||t.includes("job")?Ct:t==="mod"?ts:t==="skill"?He:t.includes("error")||t.includes("failure")?ps:t.includes("warn")?Te:De}function _i(s){const t=s.toLowerCase();return t==="task"?"tasks":t==="agent"?"agents":t==="plan"?"artifacts":t.includes("bg")||t.includes("background")?"activity":t==="mod"?"mods":t==="skill"?"skills":null}function Wi({item:s,activityKey:t,onNavigate:a,onHide:i}){const n=Bi(s),c=Ui(s.kind||""),o=Pi(s.kind||"activity"),l=Fi(s),x=_i(s.kind||""),p=n==="error"?"var(--error)":n==="warning"?"var(--warning)":n==="success"?"var(--success)":"var(--accent)";return e.jsxs("div",{className:V("activity-feed-row",`activity-feed-row-${n}`),children:[e.jsxs("button",{type:"button",className:"activity-feed-row-main",onClick:()=>{x&&a(x)},title:x?`Open ${x}`:o,children:[e.jsx("div",{className:"activity-feed-icon",style:{color:p},children:e.jsx(c,{size:14})}),e.jsxs("div",{className:"activity-feed-body",children:[e.jsxs("div",{className:"activity-feed-title-row",children:[e.jsx("div",{className:"activity-feed-title",children:o}),e.jsx("div",{className:"activity-feed-time text-xs muted tabular-nums",children:Oi(s.ts)})]}),e.jsx("div",{className:"activity-feed-summary text-sm",children:l})]})]}),e.jsx("button",{type:"button",className:"activity-feed-hide-btn",onClick:()=>i(t),title:"Hide this from the overview (kept in Settings → Activity Log)","aria-label":"Hide from overview",children:e.jsx(Ne,{size:12})})]})}const qi=Oe.memo(Ii);function Vi({icon:s,title:t,message:a,action:i}){return e.jsxs("div",{className:"chat-empty-state",children:[s&&e.jsx("div",{className:"chat-empty-state-icon",children:s}),e.jsx("h2",{className:"chat-empty-state-title",children:t}),e.jsx("p",{className:"chat-empty-state-message",children:a}),i&&e.jsx("div",{className:"chat-empty-state-action",children:i})]})}function Hi({session:s,mode:t,anchor:a,renameDraft:i,setRenameDraft:n,onEdit:c,onDeleteRequest:o,onConfirmDelete:l,onConfirmRename:x,onClose:p}){const u=r.useRef(null),d=Math.round(a.rect.bottom+2),m=Math.max(8,Math.round(window.innerWidth-a.rect.right));r.useEffect(()=>{const g=z=>{const N=z.target;!u.current||!N||u.current.contains(N)||p()},j=z=>{z.key==="Escape"&&p()},k=window.setTimeout(()=>{document.addEventListener("mousedown",g),document.addEventListener("keydown",j)},0);return()=>{window.clearTimeout(k),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",j)}},[p]),r.useEffect(()=>{if(t!=="rename")return;const g=window.setTimeout(()=>{var k;const j=(k=u.current)==null?void 0:k.querySelector("input.session-row-menu-input");j==null||j.focus(),j==null||j.select()},0);return()=>window.clearTimeout(g)},[t]);const h=e.jsxs("div",{ref:u,className:"session-row-menu",role:"menu","aria-label":`Options for ${s.title}`,style:{position:"fixed",top:d,right:m},onClick:g=>g.stopPropagation(),children:[t==="main"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"session-row-menu-item",role:"menuitem",onClick:g=>{g.stopPropagation(),c()},children:[e.jsx(nn,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Rename"}),e.jsx("kbd",{children:"R"})]}),e.jsxs("button",{type:"button",className:"session-row-menu-item session-row-menu-item-danger",role:"menuitem",onClick:g=>{g.stopPropagation(),o()},children:[e.jsx(ke,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Delete"}),e.jsx("kbd",{children:"⌫"})]})]}),t==="rename"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Rename session"}),e.jsx("input",{type:"text",className:"session-row-menu-input",value:i,onChange:g=>n(g.target.value),onKeyDown:g=>{g.key==="Enter"?(g.preventDefault(),x()):g.key==="Escape"&&(g.preventDefault(),p())},onClick:g=>g.stopPropagation(),"aria-label":"New session name"}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:g=>{g.stopPropagation(),p()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:g=>{g.stopPropagation(),x()},children:"Save"})]})]}),t==="confirm-delete"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Delete this session?"}),e.jsxs("div",{className:"session-row-menu-inline-message",children:['"',s.title,'" and its sub-agents will be removed.']}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:g=>{g.stopPropagation(),p()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:g=>{g.stopPropagation(),l()},children:"Delete"})]})]})]});return sa.createPortal(h,document.body)}function vt({node:s,depth:t=0,collapsible:a=!1,isLast:i=!0,open:n,onToggle:c}){var h;const[o,l]=r.useState(a),x=n!==void 0,p=x?n:o,u=g=>{x||l(g),c==null||c(g)},d=(((h=s.children)==null?void 0:h.length)??0)>0,m=e.jsxs(e.Fragment,{children:[a&&e.jsx("span",{className:`agent-node-chevron ${p?"open":""}`,"aria-hidden":!0,children:"›"}),e.jsx("span",{className:`agent-node-dot status-${s.status}`,"aria-hidden":!0}),e.jsx("span",{className:"agent-node-name",children:s.name}),s.role&&e.jsx("span",{className:"agent-node-role chat-mono",children:s.role}),e.jsx("span",{className:`agent-node-pill status-${s.status}`,children:s.status})]});return e.jsxs("div",{className:["agent-node",`depth-${t}`,`status-${s.status}`,p?"open":"closed",i?"last":""].filter(Boolean).join(" "),children:[a?e.jsx("button",{type:"button",className:`agent-node-head status-${s.status} collapsible`,onClick:g=>{g.stopPropagation(),u(!p)},"aria-expanded":p,children:m}):e.jsx("div",{className:`agent-node-head status-${s.status}`,children:m}),p&&e.jsxs(e.Fragment,{children:[s.summary&&e.jsx("div",{className:"agent-node-summary",children:s.summary}),d&&e.jsx("div",{className:"agent-node-children",children:s.children.map((g,j)=>e.jsx(vt,{node:g,depth:t+1,collapsible:!1,isLast:j===s.children.length-1},g.id))})]})]})}function Gi(s){return s.tree!==void 0}function Ki(s){const t=s.open??!0;if(Gi(s))return e.jsx("div",{className:`agent-tree variant-${s.variant??"full"}`,children:e.jsx(vt,{node:s.tree.root,depth:0,open:t})});const a=s.children??[];return e.jsx("div",{className:`agent-tree variant-${s.variant} agent-tree-children-only`,children:e.jsx("div",{className:"agent-tree-children-body",children:a.map((i,n)=>e.jsx(r.Fragment,{children:e.jsx(vt,{node:i,depth:0,collapsible:!1,open:t,isLast:n===a.length-1})},i.id))})})}function Yi({children:s,variant:t="rail",open:a=!0}){return a?e.jsx(Ki,{variant:t,open:a,children:s}):null}const Xi=["Today","Yesterday","This week","Earlier"];function Bt(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function Ji(s,t){const a=s.getTime()-t.getTime();return Math.floor(a/(1e3*60*60*24))}function Qi(s){const t=new Date,a=new Date(t);a.setDate(a.getDate()-1);const i=new Date(t);i.setDate(i.getDate()-7);const n={Today:[],Yesterday:[],"This week":[],Earlier:[]};for(const c of s){const o=new Date(Number(c.mtime)||Date.now());Bt(o,t)?n.Today.push(c):Bt(o,a)?n.Yesterday.push(c):Ji(t,o)<7?n["This week"].push(c):n.Earlier.push(c)}return n}function Zi(s){return new Date(Number(s)||Date.now()).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function er({state:s,agent:t}){return s==="streaming"?e.jsx("span",{className:"session-state session-state-streaming",title:`${t||"Odin"} is typing…`}):s==="awaiting"?e.jsx("span",{className:"session-state session-state-awaiting",title:"Awaiting your reply","aria-hidden":!0}):s==="idle"?e.jsx("span",{className:"session-state session-state-idle","aria-hidden":!0}):null}function sr({sessions:s,opencodeSessions:t=[],activeSessionId:a,activeOpencodeSessionId:i,activeProject:n,creating:c,onCreateSession:o,onSelectSession:l,onSelectOpencodeSession:x,onRenameSession:p,onDeleteSession:u,groupBy:d}){var O;const m=r.useMemo(()=>[...s,...t],[s,t]),h=r.useMemo(()=>[...m].sort((J,ae)=>Number(ae.mtime??0)-Number(J.mtime??0)),[m]),g=r.useMemo(()=>d?d(h):Qi(h),[d,h]),[j,k]=r.useState({}),z=J=>j[J]===!0,[N,S]=r.useState(null),[E,v]=r.useState("main"),[b,w]=r.useState(""),[f,L]=r.useState(null),R=r.useRef({}),y=(J,ae="main")=>{const ee=R.current[J];if(!ee)return;const F=ae==="main"?ee:ee.querySelector(".chat-rail-item-menu-trigger")??ee;if(L({id:J,rect:F.getBoundingClientRect()}),S(J),v(ae),ae==="rename"){const H=[...s,...t].find(K=>K.id===J);w((H==null?void 0:H.title)??(H==null?void 0:H.id)??"")}},A=()=>{S(null),v("main"),w(""),L(null)},P=J=>{if(J.source==="opencode"){x(J);return}l(J.id)},C=()=>{if(!f)return;const J=f.id,ae=b.trim();if(!ae){A();return}p==null||p(J,ae),A()},D=()=>{f&&(u==null||u(f.id),A())},Y=d?Object.entries(g):Xi.filter(J=>{var ae;return(ae=g[J])==null?void 0:ae.length}).map(J=>[J,g[J]]);return e.jsxs("aside",{className:"chat-rail",children:[e.jsx("div",{className:"chat-rail-head",children:e.jsxs("button",{type:"button",className:"chat-new-btn",onClick:o,disabled:c||!n,title:n?"Create new session":"Pick a project first","aria-label":"Create new session",children:[e.jsx(ze,{size:14,"aria-hidden":!0}),e.jsx("span",{children:c?"Creating…":"New session"})]})}),h.length===0?e.jsx("div",{className:"chat-sessions-empty",children:e.jsx(Vi,{icon:e.jsx(ze,{size:20,"aria-hidden":!0}),title:n?"No sessions yet":"No project",message:n?"Create your first session to start chatting.":"Pick a project in Overview to scope chat sessions."})}):e.jsx("div",{className:"chat-rail-list",children:Y.map(([J,ae])=>e.jsxs("div",{className:"chat-rail-group",children:[e.jsx("div",{className:"chat-rail-group-label",children:J}),ae.map(ee=>{var he,we;const F=ee.source==="opencode",H=F?i===ee.id:a===ee.id,K=ee.tree,B=!!((he=K==null?void 0:K.root)!=null&&he.children&&K.root.children.length>0),Z=z(ee.id);return e.jsxs(r.Fragment,{children:[e.jsxs("div",{ref:W=>{R.current[ee.id]=W},role:"button",tabIndex:0,className:`chat-rail-item state-${ee.state??"idle"}${H?" active":""}`,onClick:()=>P(ee),onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),P(ee))},"aria-current":H?"true":void 0,children:[e.jsx(er,{state:ee.state??"idle",agent:ee.agent}),e.jsxs("div",{className:"chat-rail-item-title",children:[ee.pinned&&e.jsx("span",{className:"chat-rail-pin","aria-hidden":!0,children:"★"}),F&&e.jsx(ys,{size:11,style:{color:"var(--text-muted)",flexShrink:0},"aria-hidden":!0}),e.jsx("span",{className:"chat-ellipsis",children:ee.title||ee.id})]}),e.jsxs("div",{className:"chat-rail-item-meta",children:[e.jsx("span",{className:"chat-rail-item-meta-time",children:ee.time??Zi(ee.mtime)}),(ee.unread??0)>0&&e.jsx("span",{className:"chat-rail-badge",children:ee.unread})]}),e.jsx("button",{type:"button",className:`chat-rail-item-menu-trigger${N===ee.id?" open":""}`,"aria-label":`Session options for ${ee.title||ee.id}`,"aria-haspopup":"menu","aria-expanded":N===ee.id,onClick:W=>{W.stopPropagation(),N===ee.id?A():y(ee.id,"main")},children:e.jsxs("svg",{viewBox:"0 0 14 14","aria-hidden":!0,children:[e.jsx("circle",{cx:"3",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"7",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"11",cy:"7",r:"1.2",fill:"currentColor"})]})}),H&&B&&e.jsx("button",{type:"button",className:`chat-rail-tree-chevron${Z?" open":""}`,"aria-label":Z?"Collapse sub-agents":"Expand sub-agents","aria-expanded":Z,onClick:W=>{W.stopPropagation(),k(se=>({...se,[ee.id]:!se[ee.id]}))},children:e.jsx("svg",{viewBox:"0 0 10 10","aria-hidden":!0,children:e.jsx("polyline",{points:"3,1.5 7,5 3,8.5"})})})]}),H&&B&&Z&&((we=K==null?void 0:K.root)==null?void 0:we.children)&&e.jsx(Yi,{children:K.root.children,variant:"rail",open:!0})]},F?`oc-${ee.id}`:ee.id)})]},J))}),N&&f&&e.jsx(Hi,{session:{id:f.id,title:((O=[...s,...t].find(J=>J.id===f.id))==null?void 0:O.title)??f.id},mode:E,anchor:f,renameDraft:b,setRenameDraft:w,onEdit:()=>y(N,"rename"),onDeleteRequest:()=>y(N,"confirm-delete"),onConfirmDelete:D,onConfirmRename:C,onClose:A})]})}function tr(s){const{text:t,sending:a,onSend:i,activeSource:n}=s,[c,o]=r.useState(!1),l=()=>{!t.trim()||a||(o(!0),i(),window.setTimeout(()=>o(!1),320))};return e.jsxs("div",{className:`chat-composer-wrap chat-composer-source-${n??"none"}`,children:[e.jsx("div",{className:`chat-composer-pill${c?" takeoff":""}`,children:e.jsx(Qn,{...s,onSend:l})}),e.jsxs("div",{className:"chat-composer-hint chat-muted",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"⏎"})," send"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"⇧⏎"})," newline"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"/"})," commands"]}),n==="opencode"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ opencode"}),n==="bizar"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ bizar chat"}),a&&e.jsx("span",{className:"chat-composer-source-hint",children:"sending…"})]})]})}function at(s){return s.toLocaleString()}function ar(s){return!s||!s.includes("/")?"":s.split("/")[0]}function nr(s){if(!s)return 0;const t=s.toLowerCase();return t.includes("opus")?15:t.includes("sonnet")?3:t.includes("haiku")?.8:t.includes("gpt-4o")?5:t.includes("gpt-4")?10:t.includes("deepseek")?.27:t.includes("minimax")?.3:t.includes("llama-3.3-70b")?.59:1}function ir({sessionId:s,messages:t,pinned:a,agent:i,model:n,agents:c,mcps:o,allCommands:l,activeSource:x="bizar",onRename:p,onDelete:u,onExport:d,busy:m,error:h,onRetry:g}){const[j,k]=r.useState(null);r.useEffect(()=>{let y=!1;return(async()=>{try{const A=await fetch("/api/usage?range=24h",{headers:{Accept:"application/json"}});if(!A.ok)return;const P=await A.json();y||k(P)}catch{}})(),()=>{y=!0}},[s]);const z=(t==null?void 0:t.length)??0,N=(a==null?void 0:a.size)??0,S=t.reduce((y,A)=>y+(A.content||A.message||"").length,0),E=Math.round(S/4),v=nr(n),b=E/1e6*v,w=(j==null?void 0:j.totalTokens)??E,f=(j==null?void 0:j.costUsd)??b,L=128e3,R=ar(n);return e.jsxs("aside",{className:"chat-info",children:[h&&e.jsxs("div",{className:"chat-info-section chat-info-error",role:"alert","aria-live":"polite",children:[e.jsxs("h4",{children:[e.jsx(Te,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Couldn't load session"]}),e.jsx("p",{className:"chat-info-value chat-ellipsis",title:h.message,children:h.message}),e.jsxs("div",{className:"chat-info-mono",children:["code · ",h.code]}),h.suggestion?e.jsx("p",{className:"chat-info-suggestion",children:h.suggestion}):null,h.canRetry!==!1&&g?e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm chat-info-retry",onClick:g,title:"Retry loading the session",children:[e.jsx(Js,{size:12,"aria-hidden":!0})," Retry"]}):null]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("div",{className:"chat-info-section-head",children:[e.jsxs("h4",{children:[e.jsx(Xs,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Session"]}),e.jsx("span",{className:`chat-source-badge chat-source-${x??"none"}`,style:{marginLeft:"auto"},children:x==="opencode"?"opencode":"bizar chat"})]}),e.jsx("div",{className:"chat-info-mono chat-ellipsis",title:s,children:s||"Live"}),e.jsxs("div",{className:"chat-info-mono",children:[at(z)," message",z===1?"":"s",N>0&&` · ${N} pinned`]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Ye,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Agent"]}),e.jsx("div",{className:"chat-info-value",children:i||"—"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(js,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Model"]}),e.jsx("div",{className:"chat-mono chat-ellipsis",title:n,children:n||"—"}),R&&e.jsxs("div",{className:"chat-info-mono",children:["provider · ",R]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Tokens"}),e.jsxs("div",{className:"chat-mono",children:[at(w)," / ",at(L)]}),e.jsx("div",{className:"chat-info-bar","aria-hidden":!0,children:e.jsx("div",{className:"chat-info-bar-fill",style:{width:`${Math.min(100,w/Math.max(1,L)*100)}%`}})})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(rn,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Cost"]}),e.jsxs("div",{className:"chat-mono",children:["$",f.toFixed(4)]}),!j&&e.jsx("div",{className:"chat-info-mono",children:"approx · live from MiniMax"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Ye,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Attached agents"]}),c!=null&&c.length?e.jsx("div",{className:"chat-info-agents",children:c.map(y=>e.jsx("span",{className:"chat-info-agent",children:y.name},y.name))}):e.jsx("div",{className:"chat-info-mono",children:"None attached"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(js,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","MCPs"]}),o!=null&&o.length?e.jsx("div",{className:"chat-info-agents",children:o.map(y=>e.jsx("span",{className:"chat-info-agent",children:y.id},y.id))}):e.jsx("div",{className:"chat-info-mono",children:"No MCPs configured"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(ns,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Slash commands"]}),e.jsxs("div",{className:"chat-info-mono",children:[(l==null?void 0:l.length)??0," available"]})]}),(p||u||d)&&e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Actions"}),e.jsxs("div",{className:"chat-info-actions",children:[p&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:p,disabled:m==null?void 0:m.rename,title:"Rename session",children:[e.jsx(Es,{size:12,"aria-hidden":!0})," Rename"]}),d&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:d,title:"Export transcript",children:[e.jsx(ls,{size:12,"aria-hidden":!0})," Export"]}),u&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm btn-danger",onClick:u,disabled:m==null?void 0:m.delete,title:"Delete session",children:[e.jsx(ke,{size:12,"aria-hidden":!0})," Delete"]})]})]})]})}function rr({streaming:s,newMessageCount:t,onClick:a,streamingLabel:i="Odin is replying"}){return e.jsx("button",{type:"button",className:`jump-to-latest${s?" is-streaming":""}`,onClick:a,"aria-label":"Jump to latest message",title:"Jump to latest (⌘/Ctrl+End)",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"jump-dots","aria-hidden":!0,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("span",{children:i}),t>0&&e.jsx("span",{className:"jump-badge jump-badge-live",children:"live"})]}):e.jsxs(e.Fragment,{children:[e.jsx(oa,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Jump to latest"}),t>0&&e.jsxs("span",{className:"jump-badge",children:[t," new"]})]})})}function lr({snapshot:s,settings:t,setActiveTab:a,initialTaskId:i,onClearTaskId:n}){const c=re(),o=$e(),l=Zn(s,t,i??"");r.useEffect(()=>{l.setToast({error:O=>c.error(O),success:O=>c.success(O),info:O=>c.info(O),warning:O=>c.warning(O)})},[l,c]);const[x,p]=r.useState(""),[u,d]=r.useState(t.defaultAgent||"odin"),[m,h]=r.useState(t.defaultModel||""),[g,j]=r.useState([]),k=r.useRef(null),{allCommands:z,suggestions:N,setQuery:S}=ei(s);r.useEffect(()=>{S(x)},[x,S]);const E=()=>{var O;return(O=k.current)==null?void 0:O.click()},v=O=>{const J=O.target.files;if(!J)return;const ae=[];for(let ee=0;ee<J.length;ee++)ae.push(J[ee].name);j(ee=>{const F=ae.filter(H=>!ee.includes(H));return[...ee,...F]}),k.current&&(k.current.value="")},b=async()=>{const O=x.trim();if(!O)return;p(""),S(""),(await l.onSend(O,u,m,g)).ok&&l.jumpToLatest()},w=async()=>{l.busy.create||await l.onCreateSession()},f=O=>{o.open({title:"Delete message?",children:e.jsx("p",{style:{margin:0},children:"This action cannot be undone."}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx($,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx($,{variant:"danger",size:"sm",onClick:()=>{o.close(),l.deleteMessage(O)},children:"Delete"})]})})},L=(O,J)=>{let ae="";o.open({title:"Rename session",children:e.jsx("input",{id:"rename-session-input",autoFocus:!0,defaultValue:J,"aria-label":"Session title",onChange:ee=>{ae=ee.target.value},onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),o.close(),l.renameSession(O,ae).then(F=>{F&&c.success("Renamed.")}))},style:{width:"100%",padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text)",font:"13px/1.4 var(--font-sans)",marginTop:6}}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx($,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx($,{variant:"primary",size:"sm",onClick:()=>{o.close(),l.renameSession(O,ae)},children:"Save"})]})})},R=(O,J)=>{o.open({title:"Delete session?",children:e.jsxs("p",{style:{margin:0},children:["Delete ",e.jsx("strong",{children:J}),"? Messages on the opencode serve will be removed. This cannot be undone."]}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx($,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx($,{variant:"danger",size:"sm",onClick:async()=>{o.close(),await l.deleteSession(O)},children:"Delete"})]})})},y=()=>{const O=l.activeSource==="opencode"?l.activeOpencodeSessionId:l.sessionId;if(!O)return;const ae=(l.activeSource==="opencode"?l.opencodeMessages:l.bizarMessages).map(K=>{const B=K.ts??"",Z=(K.role||"unknown").toUpperCase(),he=K.content||K.message||"";return`[${B}] ${Z}: ${he}`}).join(`
|
|
2
2
|
|
|
3
3
|
`),ee=new Blob([ae],{type:"text/plain;charset=utf-8"}),F=URL.createObjectURL(ee),H=document.createElement("a");H.href=F,H.download=`${O}.txt`,document.body.appendChild(H),H.click(),document.body.removeChild(H),URL.revokeObjectURL(F)},A=r.useMemo(()=>l.sessions.map(O=>l.getSessionDisplay(O)),[l.sessions,l.getSessionDisplay]),P=r.useMemo(()=>l.opencodeSessions.map(O=>l.getSessionDisplay(O)),[l.opencodeSessions,l.getSessionDisplay]),C=r.useMemo(()=>{const O=l.activeSource==="opencode"?l.activeOpencodeSessionId??"":l.sessionId;return O?A.find(J=>J.id===O)??P.find(J=>J.id===O)??null:null},[l.activeSource,l.activeOpencodeSessionId,l.sessionId,A,P]),D=(()=>{var ae;const O=`${u||"Odin"} · ${((ae=s.activeProject)==null?void 0:ae.name)??"no project"}`,J=(C==null?void 0:C.state)??"idle";return J==="streaming"?`Replying · ${O}`:J==="awaiting"?`Your turn · ${O}`:`${O} · idle`})(),Y=l.activeSource==="opencode"?"opencode":"bizar chat";return e.jsxs("div",{className:"chat-shell",children:[e.jsx(si,{activeProject:s.activeProject,sessionCount:l.sessions.length,sessionsOpen:!0,infoOpen:!0,onToggleSessions:()=>{},onToggleInfo:()=>{},onOpenOverview:()=>a==null?void 0:a("overview")}),e.jsxs("div",{className:"chat-page",children:[e.jsx(sr,{sessions:A,opencodeSessions:P,activeSessionId:l.sessionId,activeOpencodeSessionId:l.activeOpencodeSessionId,activeProject:s.activeProject,creating:l.busy.create,onCreateSession:w,onSelectSession:l.selectBizarSession,onSelectOpencodeSession:O=>l.loadOpencodeSession(O.id),onRenameSession:L,onDeleteSession:O=>{const J=l.sessions.find(ae=>ae.id===O)??l.opencodeSessions.find(ae=>ae.id===O);R(O,(J==null?void 0:J.title)??"")}}),e.jsxs("section",{className:"chat-thread-section",children:[e.jsxs("div",{className:"chat-thread-head",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"chat-thread-title-row",children:[e.jsx("div",{className:"chat-thread-title",children:(C==null?void 0:C.title)??l.sessionId??"New chat"}),e.jsx("span",{className:`chat-source-badge chat-source-${l.activeSource??"none"}`,title:l.activeSource==="opencode"?"Messages go to the opencode serve child":"Messages go to the local chat store",children:Y})]}),e.jsxs("div",{className:`chat-thread-sub chat-muted state-${(C==null?void 0:C.state)??"idle"}`,children:[e.jsx("span",{className:"chat-thread-dot"}),D]}),l.opencodeError&&e.jsxs("div",{className:"chat-thread-error",role:"alert",children:[e.jsx("p",{className:"chat-error-message",children:l.opencodeError}),l.opencodeSuggestion&&e.jsx("p",{className:"chat-error-suggestion",children:l.opencodeSuggestion}),l.activeOpencodeSessionId&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>l.loadOpencodeSession(l.activeOpencodeSessionId),children:"Retry"})]})]}),e.jsxs("div",{className:"chat-thread-actions",children:[C&&e.jsxs("button",{className:"btn btn-ghost",title:"Rename session",type:"button",disabled:l.busy.rename,onClick:()=>L(C.id,C.title??""),children:[e.jsx(Es,{size:12,"aria-hidden":!0})," ",e.jsx("span",{className:"mono",children:"rename"})]}),C&&e.jsxs("button",{className:"btn btn-ghost btn-danger",title:"Delete session",type:"button",disabled:l.busy.delete,onClick:()=>R(C.id,C.title??C.id),children:[e.jsx(ke,{size:12,"aria-hidden":!0})," ",e.jsx("span",{className:"mono",children:"delete"})]}),e.jsx("button",{className:"btn btn-ghost",title:"Export transcript",type:"button",onClick:y,children:e.jsx("span",{className:"mono",children:"export"})})]})]}),e.jsx("div",{className:"chat-thread-scroll",ref:l.listRef,onScroll:l.handleScroll,role:"log","aria-live":"polite","aria-relevant":"additions","aria-label":"Chat message thread",children:e.jsx(ti,{messages:l.activeSource==="opencode"?l.opencodeMessages:l.bizarMessages,loading:l.loading,activeProject:s.activeProject,sessionId:l.activeSource==="opencode"?l.activeOpencodeSessionId??l.sessionId:l.sessionId,pinned:l.pinned,activeSource:l.activeSource,onPickSuggestion:O=>p(O),onCopy:O=>l.copyMessage(O),onDelete:f,onTogglePin:l.togglePin,onRegenerate:l.onRegenerate})}),!l.stickToBottom&&e.jsx(rr,{streaming:(C==null?void 0:C.state)==="streaming",newMessageCount:l.newMessageCount,onClick:l.jumpToLatest}),e.jsx(tr,{agent:u,setAgent:d,model:m,setModel:h,text:x,setText:p,sending:l.sending,activeSource:l.activeSource,onSend:b,attachments:g,setAttachments:j,suggestions:N,onPickSuggestion:O=>p(`${O.split(" ")[0]} `),agents:s.agents||[],onAttach:E}),e.jsx("input",{ref:k,type:"file",multiple:!0,style:{display:"none"},onChange:v,"aria-label":"Attach files to message",tabIndex:-1})]}),e.jsx(ir,{sessionId:l.activeSource==="opencode"?l.activeOpencodeSessionId??l.sessionId:l.sessionId,messages:l.activeSource==="opencode"?l.opencodeMessages:l.bizarMessages,pinned:l.pinned,agent:u,model:m,agents:s.agents||[],mcps:s.mcps||[],allCommands:z,activeSource:l.activeSource,onRename:()=>{C&&L(C.id,C.title??"")},onDelete:()=>{C&&R(C.id,C.title??C.id)},onExport:y,busy:l.busy})]})]})}function or(s){return s==="ok"?"success":s==="warn"?"warning":s==="fail"?"error":s}function Je({kind:s="neutral",children:t,className:a,dot:i=!1}){const n=or(s);return e.jsxs("span",{className:V("badge",`badge-${n}`,a),title:`status: ${s}`,children:[i&&e.jsx("span",{className:"badge-dot"}),t]})}const Ut=["bash","read","edit","write","webfetch","websearch","task","glob","grep"],_t=["anthropic/claude-3-5-sonnet","anthropic/claude-3-5-haiku","openai/gpt-4o","openai/gpt-4o-mini","openrouter/minimax/minimax-m3","openrouter/minimax/minimax-m2.7"],Ws=[{id:"reasoning",label:"Reasoning",color:"var(--accent)"},{id:"code",label:"Code",color:"var(--info)"},{id:"design",label:"Design",color:"var(--success)"},{id:"planning",label:"Planning",color:"var(--warning)"},{id:"gitops",label:"GitOps",color:"var(--error)"},{id:"analysis",label:"Analysis",color:"var(--text-dim)"}];function cr(s){var t;return((t=Ws.find(a=>a.id===s))==null?void 0:t.color)||"var(--text-dim)"}function dr({status:s,isStuck:t}){const a=t?"var(--error)":s==="working"?"var(--info)":s==="error"?"var(--error)":"var(--text-dim)";return e.jsx("span",{className:"agent-status-dot",style:{background:a}})}function mr({agent:s}){if(s.isStuck)return e.jsx(Je,{kind:"error",dot:!0,children:"stuck"});const t=s.status||"idle";return t==="working"?e.jsx(Je,{kind:"info",dot:!0,children:"working"}):t==="error"?e.jsx(Je,{kind:"error",dot:!0,children:"error"}):e.jsx(Je,{kind:"neutral",dot:!0,children:"idle"})}function ur({snapshot:s,refreshSnapshot:t}){const a=re(),i=$e(),[n,c]=r.useState(s.agents||[]),[o,l]=r.useState(!s.agents),[x,p]=r.useState(""),[u,d]=r.useState("");r.useEffect(()=>{c(s.agents||[]),l(!s.agents)},[s.agents]);const m=async()=>{try{const v=await T.get("/agents");c(v.agents||[])}catch(v){a.error(`Agents load failed: ${v.message}`)}finally{l(!1)}},h=r.useMemo(()=>{let v=[...n];if(x&&(v=v.filter(b=>x==="__none__"?!b.category:(b.category||"")===x)),u){const b=u.toLowerCase();v=v.filter(w=>w.name.toLowerCase().includes(b)||(w.description||"").toLowerCase().includes(b)||(w.tags||[]).some(f=>f.toLowerCase().includes(b)))}return v.sort((b,w)=>b.name.localeCompare(w.name))},[n,x,u]),g=r.useMemo(()=>{const v=new Set;for(const b of n)for(const w of b.tags||[])v.add(w);return Array.from(v).sort()},[n]),j=()=>{let v=null,b=null,w=null,f=null,L=null,R=null,y=null,A=null,P=null;i.open({title:"New agent",width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-name",children:"Name (a-z, 0-9, dashes)"}),e.jsx("input",{id:"agent-new-name",ref:C=>v=C,className:"input",type:"text",placeholder:"my-agent",autoFocus:!0}),e.jsx("label",{className:"field-label",htmlFor:"agent-new-desc",children:"Description"}),e.jsx("input",{id:"agent-new-desc",ref:C=>{b=C},className:"input",type:"text",placeholder:"What does this agent do?"}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-model",children:"Model"}),e.jsxs("select",{id:"agent-new-model",ref:C=>w=C,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(provider default)"}),_t.map(C=>e.jsx("option",{value:C,children:C},C))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-mode",children:"Mode"}),e.jsxs("select",{id:"agent-new-mode",ref:C=>f=C,className:"select",defaultValue:"subagent",children:[e.jsx("option",{value:"primary",children:"primary"}),e.jsx("option",{value:"subagent",children:"subagent"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:"0 0 80px"},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-color",children:"Color"}),e.jsx("input",{id:"agent-new-color",ref:C=>L=C,className:"input",type:"color",defaultValue:"#8b5cf6"})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-category",children:"Category"}),e.jsxs("select",{id:"agent-new-category",ref:C=>P=C,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(none)"}),Ws.map(C=>e.jsx("option",{value:C.id,children:C.label},C.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-tags",children:"Tags (comma-separated)"}),e.jsx("input",{id:"agent-new-tags",ref:C=>A=C,className:"input",type:"text",placeholder:"reasoning, code, planning"})]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"field-label",style:{padding:0},children:"Tools"}),e.jsx("div",{ref:C=>y=C,className:"agent-tools",children:Ut.map(C=>e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:C,"aria-label":C}),e.jsx("span",{children:C})]},C))})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-new-prompt",children:"System prompt"}),e.jsx("textarea",{id:"agent-new-prompt",ref:C=>R=C,className:"textarea",rows:6,placeholder:"You are a..."})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx($,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs($,{variant:"primary",onClick:async()=>{const C=((v==null?void 0:v.value)||"").trim();if(!/^[a-z0-9][a-z0-9-]{0,63}$/i.test(C)){a.warning("Invalid name (a-z, 0-9, dashes).");return}const D=[];y&&y.querySelectorAll('input[type="checkbox"]:checked').forEach(O=>{D.push(O.value)});const Y=((A==null?void 0:A.value)||"").split(",").map(O=>O.trim()).filter(Boolean);try{const O=await T.post("/agents",{name:C,description:((b==null?void 0:b.value)||"").trim(),model:(w==null?void 0:w.value)||"",mode:(f==null?void 0:f.value)||"subagent",color:(L==null?void 0:L.value)||"",tools:D,tags:Y,category:(P==null?void 0:P.value)||"",prompt:(R==null?void 0:R.value)||""});c(J=>[...J,O]),a.success("Agent created."),i.close(),await t()}catch(O){a.error(`Create failed: ${O.message}`)}},children:[e.jsx(As,{size:12})," Create"]})]})})},k=async v=>{let b=null,w=null,f=null,L=null,R=null,y=null,A=null,P=null;try{const C=await T.get(`/agents/${encodeURIComponent(v.name)}`);i.open({title:`Edit ${v.name}`,width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsxs("div",{className:"muted",children:["File: ",e.jsx("code",{children:C.path})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-edit-desc",children:"Description"}),e.jsx("input",{id:"agent-edit-desc",ref:D=>{b=D},className:"input",type:"text",defaultValue:C.description}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-model",children:"Model"}),e.jsxs("select",{id:"agent-edit-model",ref:D=>w=D,className:"select",defaultValue:C.model,children:[e.jsx("option",{value:"",children:"(provider default)"}),_t.map(D=>e.jsx("option",{value:D,children:D},D))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-mode",children:"Mode"}),e.jsxs("select",{id:"agent-edit-mode",ref:D=>f=D,className:"select",defaultValue:C.mode||"subagent",children:[e.jsx("option",{value:"primary",children:"primary"}),e.jsx("option",{value:"subagent",children:"subagent"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:"0 0 80px"},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-color",children:"Color"}),e.jsx("input",{id:"agent-edit-color",ref:D=>L=D,className:"input",type:"color",defaultValue:C.color||"#8b5cf6"})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-category",children:"Category"}),e.jsxs("select",{id:"agent-edit-category",ref:D=>P=D,className:"select",defaultValue:C.category||"",children:[e.jsx("option",{value:"",children:"(none)"}),Ws.map(D=>e.jsx("option",{value:D.id,children:D.label},D.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-tags",children:"Tags (comma-separated)"}),e.jsx("input",{id:"agent-edit-tags",ref:D=>A=D,className:"input",type:"text",defaultValue:(C.tags||[]).join(", ")})]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"field-label",style:{padding:0},children:"Tools"}),e.jsx("div",{ref:D=>y=D,className:"agent-tools",children:Ut.map(D=>{var Y;return e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:D,"aria-label":D,defaultChecked:(Y=C.tools)==null?void 0:Y.includes(D)}),e.jsx("span",{children:D})]},D)})})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-edit-prompt",children:"System prompt"}),e.jsx("textarea",{id:"agent-edit-prompt",ref:D=>R=D,className:"textarea",rows:8,defaultValue:C.prompt||""})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx($,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs($,{variant:"primary",onClick:async()=>{const D=[];y&&y.querySelectorAll('input[type="checkbox"]:checked').forEach(O=>{D.push(O.value)});const Y=((A==null?void 0:A.value)||"").split(",").map(O=>O.trim()).filter(Boolean);try{const O=await T.put(`/agents/${encodeURIComponent(v.name)}`,{description:((b==null?void 0:b.value)||"").trim(),model:(w==null?void 0:w.value)||"",mode:(f==null?void 0:f.value)||"subagent",color:(L==null?void 0:L.value)||"",tools:D,tags:Y,category:(P==null?void 0:P.value)||"",prompt:(R==null?void 0:R.value)||""});c(J=>J.map(ae=>ae.name===v.name?O:ae)),a.success("Agent saved."),i.close(),await t()}catch(O){a.error(`Save failed: ${O.message}`)}},children:[e.jsx(As,{size:12})," Save"]})]})})}catch(C){a.error(`Load failed: ${C.message}`)}},z=async v=>{if(confirm(`Delete agent "${v.name}"? This removes ${v.path}.`))try{await T.del(`/agents/${encodeURIComponent(v.name)}`),c(b=>b.filter(w=>w.name!==v.name)),a.success("Agent deleted.")}catch(b){a.error(`Delete failed: ${b.message}`)}},N=async v=>{let b=null;i.open({title:`Invoke ${v.name}`,children:e.jsxs("div",{className:"invoke-form",children:[e.jsxs("p",{className:"muted invoke-form-meta mono",children:[v.model||"—"," · ",v.path]}),e.jsx("p",{className:"invoke-form-desc",children:v.description}),e.jsx("label",{className:"field-label",htmlFor:"invoke-prompt",children:"Prompt"}),e.jsx("textarea",{ref:w=>b=w,id:"invoke-prompt",className:"textarea",rows:5,placeholder:"What should this agent do?",autoFocus:!0})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx($,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs($,{variant:"primary",onClick:async()=>{const w=((b==null?void 0:b.value)||"").trim();if(!w){a.warning("Prompt is required.");return}try{await T.post(`/agents/${encodeURIComponent(v.name)}/invoke`,{prompt:w}),a.success(`Invoked ${v.name}.`),i.close()}catch(f){a.error(`Invoke failed: ${f.message}`)}},children:[e.jsx(Ls,{size:14})," Invoke"]})]})})},S=async v=>{try{const b=await T.post(`/agents/${encodeURIComponent(v.name)}/restart`);c(w=>w.map(f=>f.name===v.name?b:f)),a.success(`${v.name} restarted.`)}catch(b){a.error(`Restart failed: ${b.message}`)}},E=async(v,b)=>{try{const w=await T.post(`/agents/${encodeURIComponent(v.name)}/status`,{status:b});c(f=>f.map(L=>L.name===v.name?w:L))}catch(w){a.error(`Status update failed: ${w.message}`)}};return e.jsxs("div",{className:"view view-agents",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Ye,{size:18})," Agents (",h.length,")"]}),e.jsxs("p",{className:"view-subtitle",children:["The Norse pantheon — click ",e.jsx("kbd",{children:"Edit"})," to modify or ",e.jsx("kbd",{children:"Invoke"})," to dispatch."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"search-input",children:[e.jsx("label",{htmlFor:"agents-search",className:"sr-only",children:"Search agents"}),e.jsx("input",{id:"agents-search",className:"input",type:"text",placeholder:"Search…",value:u,onChange:v=>d(v.target.value),"aria-label":"Search agents"})]}),e.jsx("label",{htmlFor:"agents-category-filter",className:"sr-only",children:"Filter by category"}),e.jsxs("select",{id:"agents-category-filter",className:"select select-sm",value:x,onChange:v=>p(v.target.value),children:[e.jsx("option",{value:"",children:"All categories"}),Ws.map(v=>e.jsx("option",{value:v.id,children:v.label},v.id)),e.jsx("option",{value:"__none__",children:"(no category)"})]}),e.jsxs($,{variant:"secondary",size:"sm",onClick:m,children:[e.jsx(de,{size:14})," Refresh"]}),e.jsxs($,{variant:"primary",size:"sm",onClick:j,children:[e.jsx(ze,{size:14})," New agent"]})]})]}),g.length>0&&e.jsxs("div",{className:"agent-tags-row",children:[e.jsx(ca,{size:12}),g.map(v=>e.jsx("span",{className:"tag",children:v},v))]}),o?e.jsx("div",{className:"view-loading",children:e.jsx(oe,{size:"lg"})}):h.length===0?e.jsx(pe,{icon:e.jsx(Ye,{size:32}),title:"No agents found",message:"Run bizar in the terminal to install Bizar."}):e.jsx("div",{className:"agent-grid",children:h.map(v=>e.jsx(hr,{agent:v,onInvoke:()=>N(v),onEdit:()=>k(v),onDelete:()=>z(v),onRestart:()=>S(v),onSetStatus:b=>E(v,b)},v.name))})]})}function hr({agent:s,onInvoke:t,onEdit:a,onDelete:i,onRestart:n,onSetStatus:c}){const[o,l]=r.useState(!1),x=cr(s.category),p=(s.status==="working"||!!s.currentTaskId)&&!s.isStuck;return e.jsxs(G,{variant:"elevated",interactive:!0,className:V("agent-card",p&&"is-working",s.isStuck&&"is-stuck"),children:[e.jsxs("div",{className:"agent-card-head",children:[e.jsxs("div",{className:"agent-card-name",children:[e.jsx(dr,{status:s.status,isStuck:s.isStuck}),s.name]}),e.jsxs("div",{className:"agent-card-badges",children:[s.category&&e.jsx("span",{className:"agent-card-category",style:{background:`color-mix(in srgb, ${x} 18%, transparent)`,color:x},children:s.category}),e.jsx(mr,{agent:s})]})]}),e.jsx("p",{className:"agent-card-desc",children:Zt(s.description,200)}),e.jsxs("div",{className:"agent-card-meta",children:[e.jsx("span",{className:"mono",title:s.model||"",children:s.model||"—"}),e.jsx("span",{className:"tabular-nums muted",children:Ce(s.mtime)})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"agent-card-tags",children:s.tags.map(u=>e.jsx("span",{className:"agent-card-tag",children:u},u))}),(p||s.lastTask)&&e.jsxs("div",{className:"agent-card-activity",children:[s.currentTaskId&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(De,{size:12}),e.jsx("span",{className:"muted",children:"Working on"}),e.jsx("code",{className:"mono",children:s.currentTaskId})]}),s.lastTask&&!s.currentTaskId&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(qe,{size:12}),e.jsx("span",{className:"muted",children:"Last"}),e.jsx("code",{className:"mono",children:s.lastTask.id}),e.jsx("span",{className:"muted tabular-nums",children:Ce(s.lastTask.finishedAt)})]}),s.tasksTotal!=null&&s.tasksTotal>0&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(ln,{size:12}),e.jsx("span",{className:"muted",children:"Success rate"}),e.jsxs("span",{className:"tabular-nums",children:[Math.round((s.successRate||0)*100),"%"]}),e.jsxs("span",{className:"muted tabular-nums",children:["(",s.tasksSucceeded,"/",s.tasksTotal,")"]})]})]}),s.lastError&&e.jsxs("div",{className:"agent-card-error",children:[e.jsx(Te,{size:12}),e.jsxs("span",{className:"muted",children:["Last error: ",s.lastError.message]})]}),e.jsxs("div",{className:"agent-card-actions",children:[e.jsxs($,{variant:"primary",size:"sm",onClick:t,children:[e.jsx(Ls,{size:12})," Invoke"]}),e.jsxs($,{variant:"secondary",size:"sm",onClick:a,children:[e.jsx(Es,{size:12})," Edit"]}),(s.isStuck||s.status==="working"||s.status==="error")&&e.jsxs($,{variant:"ghost",size:"sm",onClick:n,title:"Reset agent status",children:[e.jsx(Js,{size:12})," Restart"]}),e.jsx($,{variant:"ghost",size:"sm",onClick:i,children:e.jsx(ke,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":o?"Collapse":"Expand",onClick:()=>l(u=>!u),style:{marginLeft:"auto"},children:o?e.jsx(We,{size:12}):e.jsx(Xe,{size:12})})]}),o&&e.jsxs("div",{className:"agent-card-expanded",children:[e.jsxs("div",{className:"agent-card-status-actions",children:[e.jsx("span",{className:"muted text-sm",children:"Set status:"}),e.jsx($,{variant:s.status==="idle"?"primary":"ghost",size:"sm",onClick:()=>c("idle"),children:"Idle"}),e.jsx($,{variant:s.status==="working"?"primary":"ghost",size:"sm",onClick:()=>c("working"),children:"Working"}),e.jsx($,{variant:s.status==="error"?"primary":"ghost",size:"sm",onClick:()=>c("error"),children:"Error"})]}),e.jsxs("div",{className:"agent-card-meta",children:[e.jsx(Fe,{size:11}),e.jsx("code",{className:"mono agent-card-path",children:s.path})]})]})]})}function xr({id:s,children:t}){return e.jsx("div",{id:s,"data-block-id":s,className:V("glyph-richtext"),style:Ca,children:e.jsx(ba,{remarkPlugins:[Na],children:t})})}const pr={info:{bg:"var(--info-soft, rgba(96, 165, 250, 0.12))",border:"var(--info)",fg:"var(--info)",icon:wt,label:"Note"},warn:{bg:"var(--warning-soft, rgba(251, 191, 36, 0.15))",border:"var(--warning)",fg:"var(--warning)",icon:Te,label:"Warning"},success:{bg:"var(--success-soft, rgba(52, 211, 153, 0.15))",border:"var(--success)",fg:"var(--success)",icon:qe,label:"Success"},danger:{bg:"var(--error-soft, rgba(248, 113, 113, 0.12))",border:"var(--error)",fg:"var(--error)",icon:Qs,label:"Danger"}};function gr({id:s,tone:t="info",children:a}){const i=pr[t],n=i.icon;return e.jsxs("div",{id:s,"data-block-id":s,className:V("glyph-callout",`glyph-callout-${t}`),style:{display:"flex",gap:12,padding:"12px 16px",margin:"12px 0",borderLeft:`3px solid ${i.border}`,background:i.bg,borderRadius:8,color:"var(--text)"},role:t==="danger"||t==="warn"?"alert":void 0,children:[e.jsx("div",{style:{flexShrink:0,color:i.fg,paddingTop:2},children:e.jsx(n,{size:18})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontWeight:600,fontSize:13,color:i.fg,marginBottom:4},children:i.label}),e.jsx("div",{className:"glyph-richtext",style:{...Ca,fontSize:14},children:e.jsx(ba,{remarkPlugins:[Na],children:a})})]})]})}function fr({id:s,items:t}){return e.jsx("ul",{id:s,"data-block-id":s,className:"glyph-checklist",style:{listStyle:"none",padding:0,margin:"12px 0",display:"flex",flexDirection:"column",gap:6},children:t.map(a=>e.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"6px 10px",borderRadius:6,background:"var(--bg-elev)",border:"1px solid var(--border)",fontSize:14},children:[e.jsx("span",{"aria-hidden":!0,style:{flexShrink:0,marginTop:1,width:16,height:16,borderRadius:4,border:`1.5px solid ${a.checked?"var(--success)":"var(--border-strong)"}`,background:a.checked?"var(--success)":"transparent",color:"var(--bg)",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:a.checked?e.jsx(gs,{size:12,strokeWidth:3}):null}),e.jsx("span",{style:{color:a.checked?"var(--text-dim)":"var(--text)",textDecoration:a.checked?"line-through":"none",wordBreak:"break-word"},children:a.label})]},a.id))})}function jr({id:s,columns:t,rows:a}){return e.jsx("div",{id:s,"data-block-id":s,className:"glyph-table-wrap",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"auto",background:"var(--bg-elev)"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map((i,n)=>e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",borderBottom:"1px solid var(--border-strong)",background:"var(--bg)",color:"var(--text-dim)",fontWeight:600,fontSize:12,textTransform:"uppercase",letterSpacing:.3,whiteSpace:"nowrap"},children:i},n))})}),e.jsx("tbody",{children:a.map((i,n)=>e.jsx("tr",{style:{borderTop:n===0?"none":"1px solid var(--border)"},children:i.map((c,o)=>e.jsx("td",{style:{padding:"8px 12px",color:"var(--text)",verticalAlign:"top",wordBreak:"break-word"},children:c},o))},n))})]})})}function vr({id:s,tabs:t}){var c;const[a,i]=r.useState(((c=t[0])==null?void 0:c.id)??""),n=r.useMemo(()=>t.find(o=>o.id===a)??t[0],[t,a]);return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-codetabs",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:"var(--bg-elev)"},children:[e.jsx("div",{role:"tablist",style:{display:"flex",gap:2,padding:4,background:"var(--bg)",borderBottom:"1px solid var(--border)",overflowX:"auto"},children:t.map(o=>{const l=o.id===(n==null?void 0:n.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,onClick:()=>i(o.id),style:{padding:"6px 12px",fontSize:12,fontFamily:"var(--font-mono)",borderRadius:6,border:"none",cursor:"pointer",background:l?"var(--bg-elev)":"transparent",color:l?"var(--text-strong)":"var(--text-dim)",boxShadow:l?"0 0 0 1px var(--border)":"none",whiteSpace:"nowrap"},children:[e.jsx("span",{children:o.label}),o.language&&e.jsx("span",{style:{marginLeft:6,color:"var(--text-dim)",fontSize:11},children:o.language})]},o.id)})}),n&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{style:{margin:0,padding:14,overflowX:"auto",fontFamily:"var(--font-mono)",fontSize:12.5,lineHeight:1.55,color:"var(--text)",background:"var(--bg-elev)"},children:e.jsx("code",{children:n.code})}),n.caption&&e.jsx("div",{style:{padding:"8px 14px",borderTop:"1px solid var(--border)",fontSize:12,color:"var(--text-dim)",background:"var(--bg)"},children:n.caption})]})]})}function yr({id:s,title:t,question:a,options:i}){return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-decision",style:{margin:"16px 0",padding:16,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)"},children:[t&&e.jsx("h3",{style:{margin:0,marginBottom:4,fontSize:15,fontWeight:600,color:"var(--text-strong)"},children:t}),a&&e.jsx("p",{style:{margin:0,marginBottom:12,fontSize:13,color:"var(--text-dim)"},children:a}),e.jsx("div",{style:{display:"grid",gap:10,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:i.map(n=>{const c=!!n.recommended;return e.jsxs("div",{style:{position:"relative",padding:12,borderRadius:8,border:c?"2px solid var(--success)":"1px solid var(--border)",background:c?"var(--success-soft)":"var(--bg)"},children:[c&&e.jsx("span",{style:{position:"absolute",top:-10,right:10,padding:"2px 8px",fontSize:11,fontWeight:600,color:"var(--bg)",background:"var(--success)",borderRadius:999},children:"Recommended"}),e.jsx("div",{style:{fontWeight:600,fontSize:14,color:"var(--text-strong)",marginBottom:4},children:n.label}),e.jsx("div",{style:{fontSize:13,color:"var(--text)"},children:n.detail})]},n.id)})})]})}function br({id:s,questions:t}){const[a,i]=r.useState({});function n(c,o){i(l=>({...l,[c]:o}))}return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-openquestions",style:{margin:"16px 0",padding:16,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)",display:"flex",flexDirection:"column",gap:14},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-strong)"},children:"Open questions"}),t.map(c=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{htmlFor:`oq-${c.id}`,style:{fontSize:13,color:"var(--text)",fontWeight:500},children:c.label}),c.kind==="choice"&&e.jsxs("select",{id:`oq-${c.id}`,value:a[c.id]??"",onChange:o=>n(c.id,o.target.value),style:Wt,children:[e.jsx("option",{value:"",children:"— select —"}),(c.options??[]).map(o=>e.jsx("option",{value:o,children:o},o))]}),c.kind==="text"&&e.jsx("input",{id:`oq-${c.id}`,type:"text",value:a[c.id]??"",onChange:o=>n(c.id,o.target.value),style:Wt}),c.kind==="multi"&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:(c.options??[]).map(o=>{const l=a[c.id]??[],x=l.includes(o);return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--text)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:x,onChange:()=>{const p=x?l.filter(u=>u!==o):[...l,o];n(c.id,p)}}),e.jsx("span",{children:o})]},o)})})]},c.id))]})}const Wt={padding:"6px 10px",fontSize:13,borderRadius:6,border:"1px solid var(--border-strong)",background:"var(--bg)",color:"var(--text)",fontFamily:"inherit"},Nr={added:{bg:"var(--success-soft)",fg:"var(--success)",label:"A"},modified:{bg:"var(--info-soft, rgba(96, 165, 250, 0.12))",fg:"var(--info)",label:"M"},removed:{bg:"var(--error-soft)",fg:"var(--error)",label:"D"},renamed:{bg:"rgba(139, 92, 246, 0.15)",fg:"var(--accent)",label:"R"}};function kr({id:s,title:t,entries:a}){return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-filetree",style:{margin:"12px 0",padding:t?14:8,border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-elev)"},children:[t&&e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:.4,marginBottom:8},children:t}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:2},children:a.map(i=>{const n=Nr[i.change];return e.jsxs("li",{style:{display:"flex",alignItems:"center",gap:10,padding:"5px 8px",borderRadius:5,fontSize:13},children:[e.jsx("span",{"aria-label":i.change,title:i.change,style:{flexShrink:0,width:22,height:18,borderRadius:4,background:n.bg,color:n.fg,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,fontFamily:"var(--font-mono)"},children:n.label}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)",wordBreak:"break-all",flex:1},children:i.path}),i.note&&e.jsx("span",{style:{fontSize:12,color:"var(--text-dim)"},children:i.note})]},i.path)})})]})}function wr({id:s,filename:t,language:a,mode:i="unified",before:n,after:c}){const o=n.split(`
|
|
4
4
|
`),l=c.split(`
|