diff --git a/dhee/ui/server.py b/dhee/ui/server.py index ba0a24c..2159d1f 100644 --- a/dhee/ui/server.py +++ b/dhee/ui/server.py @@ -4424,6 +4424,33 @@ def _product_safe(label: str, fn, fallback: Any) -> Any: return {**fallback, "live": False, "error": str(exc)} return fallback + def _learning_preview(value: Any, limit: int = 420) -> str: + text = str(value or "") + text = re.sub(r"[\s\S]*?", " ", text, flags=re.IGNORECASE) + text = re.sub(r"", " ", text, flags=re.IGNORECASE) + lines: List[str] = [] + for line in text.splitlines(): + clean = " ".join(line.strip().split()) + if not clean: + continue + lowered = clean.lower() + if lowered.startswith(("model:", "session:", "source:", "messages:", "representative turns:")): + continue + lines.append(clean) + preview = " ".join(lines) + preview = " ".join(preview.split()) + if len(preview) <= limit: + return preview + clipped = preview[: max(0, limit - 3)].rstrip() + boundary = max(clipped.rfind("."), clipped.rfind(";"), clipped.rfind(","), clipped.rfind(" ")) + if boundary > limit * 0.65: + clipped = clipped[:boundary].rstrip() + return f"{clipped}..." + + def _learning_needs_distillation(value: Any) -> bool: + text = str(value or "").lower() + return "representative turns:" in text or bool(re.search(r"(^|\n)\s*(user|assistant|tool):", text)) + def _compact_learning_row(row: Dict[str, Any]) -> Dict[str, Any]: evidence = row.get("evidence") or [] if not isinstance(evidence, list): @@ -4440,7 +4467,41 @@ def _compact_learning_row(row: Dict[str, Any]) -> Dict[str, Any]: gate = str((evidence[0] or {}).get("kind") or "evidence backed") else: gate = "needs approval" - return {**row, "evidence_gate": gate, "evidence_count": len(evidence)} + metadata = row.get("metadata") or {} + if not isinstance(metadata, dict): + metadata = {} + body = str(row.get("body") or "") + needs_distillation = _learning_needs_distillation(body) + preview = _learning_preview(body) + if needs_distillation: + preview = "Raw session import compacted for review. Promote only after distilling a reusable, evidence-backed rule." + return { + "id": row.get("id"), + "kind": row.get("kind"), + "title": _learning_preview(row.get("title"), limit=140) or str(row.get("id") or "Learning"), + "body": preview, + "preview": preview, + "source_agent_id": row.get("source_agent_id"), + "source_harness": row.get("source_harness"), + "source_model": metadata.get("source_model") or metadata.get("model"), + "task_type": row.get("task_type"), + "repo": row.get("repo"), + "scope": row.get("scope"), + "confidence": row.get("confidence"), + "utility": row.get("utility"), + "status": row.get("status"), + "reuse_count": row.get("reuse_count"), + "success_count": success_count, + "failure_count": failure_count, + "created_at": row.get("created_at"), + "updated_at": row.get("updated_at"), + "promoted_at": row.get("promoted_at"), + "rejected_reason": row.get("rejected_reason"), + "evidence_gate": gate, + "evidence_count": len(evidence), + "raw_body_chars": len(body), + "needs_distillation": needs_distillation, + } def _learning_snapshot(limit: int = 80) -> Dict[str, Any]: from dhee.core.learnings import LearningExchange @@ -4523,6 +4584,37 @@ def _ui_pack_counts() -> Dict[str, Any]: pass return counts + def _ui_workspace_summary() -> Dict[str, Any]: + """Small command-center summary; avoid shipping the full workspace tree.""" + db = _get_db() + try: + workspaces = db.list_workspaces(user_id=_ui_user_id(), limit=200) or [] + except Exception: # noqa: BLE001 + workspaces = [] + project_count = 0 + current_project_id = "" + for workspace in workspaces[:50]: + workspace_id = str(workspace.get("id") or "") + if not workspace_id: + continue + try: + projects = db.list_workspace_projects( + workspace_id=workspace_id, + user_id=_ui_user_id(), + limit=200, + ) or [] + except Exception: # noqa: BLE001 + projects = [] + project_count += len(projects) + if not current_project_id and projects: + current_project_id = str(projects[0].get("id") or "") + return { + "count": len(workspaces), + "project_count": project_count, + "currentWorkspaceId": str(workspaces[0].get("id") or "") if workspaces else "", + "currentProjectId": current_project_id, + } + def _latest_dheemem_packs(limit: int = 8) -> List[Dict[str, Any]]: try: from dhee.protocol import inspect_pack @@ -4585,7 +4677,7 @@ def api_ui_command_center() -> Dict[str, Any]: {"linked": False, "repo_entries": [], "totals": {}}, ) learnings = _product_safe("learnings", lambda: _learning_snapshot(limit=24), {"items": [], "totals": {}}) - workspaces = _product_safe("workspaces", lambda: list_workspaces_api(), {"workspaces": []}) + workspaces = _product_safe("workspaces", lambda: _ui_workspace_summary(), {"count": 0, "project_count": 0}) sessions = router_sessions.get("items") or [] active_task = next( (row for row in (task_data.get("tasks") or []) if str(row.get("status") or "") == "active"), diff --git a/dhee/ui/web/dist/assets/CanvasView-Dg15id0Q.js b/dhee/ui/web/dist/assets/CanvasView-Cl1HxIK0.js similarity index 86% rename from dhee/ui/web/dist/assets/CanvasView-Dg15id0Q.js rename to dhee/ui/web/dist/assets/CanvasView-Cl1HxIK0.js index 7eba39c..130dc0f 100644 --- a/dhee/ui/web/dist/assets/CanvasView-Dg15id0Q.js +++ b/dhee/ui/web/dist/assets/CanvasView-Cl1HxIK0.js @@ -1 +1 @@ -import{r as b,j as e,a as W,R as ye}from"./index-BKI2JxEf.js";const Te={workspace:"#e06b3f",project:"#4d6cff",channel:"#1fa971",session:"#1a1a1a",task:"#0f9f55",result:"#0b8b5f",file:"#64748b",asset:"#d74b7b",broadcast:"#e08b3f"},Re={workspace:"Workspace",project:"Project",channel:"Channel",session:"Session",task:"Task",result:"Tool result",file:"File",asset:"Asset",broadcast:"Broadcast"};function Ee(t){return t.accent||Te[t.type]||"#555"}function be(t){if(!t)return"";const r=new Date(String(t));return Number.isNaN(r.getTime())?"":r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Fe(t,r){const s=t.trim();return s.length<=r?s:`${s.slice(0,r-1).trimEnd()}…`}function De({node:t,x:r,y:s,width:u,height:x,selected:C,dim:y,onSelect:p,onHover:h,entranceDelay:o=0}){const k=Ee(t),c=t.meta||{},w=x<120,j=t.type,N={position:"absolute",left:r,top:s,width:u,height:x,display:"flex",boxSizing:"border-box",background:"white",border:`1px solid ${C?k:"rgba(20,16,10,0.12)"}`,borderLeft:`3px solid ${k}`,borderRadius:8,boxShadow:C?`0 10px 26px rgba(20,16,10,0.12), 0 0 0 3px ${k}22`:"0 1px 2px rgba(20,16,10,0.04), 0 2px 10px rgba(20,16,10,0.04)",transition:"box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease",cursor:"pointer",userSelect:"none",opacity:y?.32:1,willChange:"transform",transform:"translate3d(0, 0, 0)",overflow:"hidden",animation:`dhee-card-in 320ms ${o}ms cubic-bezier(0.17, 0.67, 0.3, 1) both`},z={flex:1,padding:w?"10px 12px":"12px 14px",display:"flex",flexDirection:"column",gap:w?4:6,minWidth:0},M={display:"flex",alignItems:"center",gap:6},T=(O,se)=>({fontFamily:"var(--mono)",fontSize:9,color:se||"var(--ink3)",letterSpacing:.4,textTransform:"uppercase",lineHeight:1.1,padding:"2px 6px",border:"1px solid var(--border)",borderRadius:2,whiteSpace:"nowrap",background:"white",...O?{}:{}}),i={fontSize:w?12:14,fontWeight:600,lineHeight:1.25,color:"var(--ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},v={fontSize:w?11:12,color:"var(--ink2)",lineHeight:1.5,display:"-webkit-box",WebkitLineClamp:w?2:3,WebkitBoxOrient:"vertical",overflow:"hidden"},m={fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:.3},S=Re[j]||j,R=String(c.runtime||""),_=String(c.state||""),$=String(c.ptr||""),X=String(c.toolName||c.tool_name||""),L=String(c.sourcePath||c.source_path||""),d=String(c.model||""),P=String(c.harness||""),Q=Number(c.sessionCount??0),U=Number(c.projectCount??0),I=Number(c.taskCount??0),V=Number(c.messageCount??0),G=c.updatedAt||c.last_seen_at,ne=()=>h(t),oe=()=>h(null),H=O=>{O.stopPropagation(),p(t)};return e.jsx("div",{style:N,onClick:H,onMouseEnter:ne,onMouseLeave:oe,"data-canvas-draggable":"false","data-node-id":t.id,className:"dhee-node-card",children:e.jsxs("div",{style:z,children:[e.jsxs("div",{style:M,children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:k,flexShrink:0}}),e.jsx("span",{style:{...m,color:k},children:S}),t.status?e.jsx("span",{style:T(t.status),children:t.status}):null,_?e.jsx("span",{style:T(_),children:_}):null,R?e.jsx("span",{style:T(R),children:R}):null,P&&!R?e.jsx("span",{style:T(P),children:P}):null,j==="session"&&c.isCurrent?e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--green)",boxShadow:"0 0 0 3px rgba(31,169,113,0.22)",marginLeft:"auto"}}):null]}),e.jsx("div",{style:i,children:t.label||"(unnamed)"}),t.subLabel?e.jsx("div",{style:{...m,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.subLabel}):null,!w&&t.body?e.jsx("div",{style:v,children:t.body}):null,j==="workspace"&&!w?e.jsxs("div",{style:{display:"flex",gap:12,...m},children:[e.jsxs("span",{children:[U||"—"," projects"]}),e.jsxs("span",{children:[Q||"—"," sessions"]})]}):null,j==="project"&&!w?e.jsxs("div",{style:{display:"flex",gap:12,...m},children:[e.jsxs("span",{children:[Q||"—"," sessions"]}),e.jsxs("span",{children:[I||"—"," tasks"]})]}):null,j==="session"&&!w?e.jsxs("div",{style:{display:"flex",gap:12,...m},children:[d?e.jsx("span",{children:Fe(d,22)}):null,G?e.jsx("span",{children:be(G)}):null]}):null,j==="task"&&!w?e.jsxs("div",{style:{display:"flex",gap:12,...m},children:[V?e.jsxs("span",{children:[V," messages"]}):null,G?e.jsx("span",{children:be(G)}):null]}):null,j==="result"?e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",...m},children:[X?e.jsx("span",{children:X}):null,$?e.jsx("span",{children:$}):null,L?e.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["· ",L.split("/").pop()]}):null]}):null,j==="broadcast"?e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",...m},children:[String(c.sourceChannel||c.sourceProject||"")?e.jsxs("span",{children:["from ",String(c.sourceChannel||c.sourceProject||"")]}):null,String(c.targetProject||"")?e.jsxs("span",{children:["→ ",String(c.targetProject)]}):null]}):null]})})}b.memo(De);function A({label:t,sub:r,children:s}){const u=t||s;return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10,marginBottom:12},children:[e.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,fontWeight:700,color:"var(--ink3)",letterSpacing:"0.1em",textTransform:"uppercase"},children:u}),r&&e.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--border2)"},children:r})]})}function Z(t){return(t==null?void 0:t.meta)||{}}function je(t){const r=Z(t);return String(r.task_id||r.taskId||"")||null}function Se(t){const r=Z(t).repo_mappings;return Array.isArray(r)?r:[]}function Ae(t){const r=t.metadata||{},u=(typeof r.label=="string"?r.label.trim():"")||t.local_path||t.repo_url||"folder";return String(u).split("/").filter(Boolean).pop()||String(u)}function ze(t){const r=String(t||"").toLowerCase();return r==="codex"?"var(--indigo)":r==="claude-code"||r==="claude"?"var(--accent)":"var(--ink3)"}function ke(t){const r=new Set,s=[];for(const u of t){const x=String(u.mapping_id||u.local_path||u.repo_url||"");!x||r.has(x)||(r.add(x),s.push(u))}return s}function Me({node:t,graph:r,viewer:s,isManager:u,onClose:x,onOpenVault:C,onOpenSession:y,onChanged:p}){var ve;const[h,o]=b.useState(null),[k,c]=b.useState(""),[w,j]=b.useState(""),[N,z]=b.useState(""),[M,T]=b.useState(""),[i,v]=b.useState(""),[m,S]=b.useState(""),[R,_]=b.useState(!1),[$,X]=b.useState(!1);if(b.useEffect(()=>{c(""),j(""),z(""),T(""),v(""),S(""),_(!1),X(!1)},[t==null?void 0:t.id]),!t)return null;const L=t.type==="workspace",d=t.type==="project",P=t.type==="team"||t.type==="global_team",Q=t.type==="repo",U=t.type==="folder",I=t.type==="session",V=L&&r?r.edges.filter(a=>a.source===t.id&&a.kind==="contains").map(a=>r.nodes.find(q=>q.id===a.target)).filter(a=>!!a&&a.type==="project"):[],G=d?String(((ve=t.meta)==null?void 0:ve.project_id)||""):"",ne=d&&r?r.edges.filter(a=>a.kind==="contains"&&a.source===t.id).map(a=>r.nodes.find(q=>q.id===a.target)).filter(a=>!!a&&(a.type==="team"||a.type==="global_team")):[],oe=P?Se(t):[],H=Z(t),O=P?String(H.team_id||""):"",se=typeof H.developer_count=="number"?H.developer_count:0,ue=Array.isArray(H.developer_join_events)?H.developer_join_events:[],pe=Array.isArray(H.collaborating_teams)?H.collaborating_teams:[],ae=r?r.nodes.filter(a=>{var q;return(a.type==="team"||a.type==="global_team")&&String(((q=a.meta)==null?void 0:q.team_id)||"")!==O}):[],n=Z(t),l=U?String(n.path||""):"",g=U?!!n.shared:!1,E=U&&r?r.edges.filter(a=>a.source===t.id&&a.kind==="contains").map(a=>r.nodes.find(q=>q.id===a.target)).filter(a=>!!a&&a.type==="session"):[],F=async()=>{o("reset");try{await W.enterpriseResetWorkspace(),p()}finally{o(null)}},D=async()=>{if(N.trim()){o("create-project");try{await W.enterpriseCreateProject({name:N.trim()}),z(""),p()}finally{o(null)}}},J=async()=>{if(!(!G||!M.trim())){o("create-team");try{await W.enterpriseCreateProjectTeam(G,{name:M.trim()}),T(""),p()}finally{o(null)}}},K=async()=>{if(!(!O||!k.trim())){o("add-folder");try{await W.enterpriseAddTeamFolder(O,{local_path:k.trim(),label:w.trim()||void 0,kind:"folder"}),c(""),j(""),p()}finally{o(null)}}},f=async()=>{if(!(!O||!i.trim())){o("add-git");try{await W.enterpriseAddTeamFolder(O,{repo_url:i.trim(),kind:"git"}),v(""),p()}finally{o(null)}}},Y=async()=>{o("pick-folder");try{const a=await W.pickFolderPath("Pick a folder for this team");a.ok&&a.path&&c(a.path)}finally{o(null)}},fe=async()=>{if(G){o("delete-project");try{await W.enterpriseDeleteProject(G),p()}finally{o(null)}}},ge=async a=>{if(a){o("remove-folder");try{await W.enterpriseRemoveFolder(a),p()}finally{o(null)}}},we=async()=>{if(!(!O||!m.trim())){o("collaborate");try{await W.enterpriseAddTeamCollaborator(O,m.trim()),S(""),p()}finally{o(null)}}},Ce=async()=>{if(O){o("extract");try{const a=await W.enterpriseExtractTeam(O);p();const q=`AST extraction · ${a.folders_seen} folder(s) · ${a.files_seen} files (${a.files_extracted} new, ${a.files_cached} cached) · ${a.nodes_upserted} nodes · ${a.edges_upserted} edges`;window.alert(q)}catch(a){window.alert(`Extraction failed: ${String(a)}`)}finally{o(null)}}},_e=async()=>{if(l){o("share-folder");try{await W.localContextShareFolder({path:l,shared:!g}),p()}finally{o(null)}}};return e.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:440,background:"var(--bg)",borderLeft:"1px solid var(--border)",boxShadow:"-12px 0 30px rgba(20,16,10,0.06)",display:"flex",flexDirection:"column",zIndex:25,animation:"fadein 0.18s ease"},children:[e.jsxs("header",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.12em",color:"var(--ink3)",textTransform:"uppercase"},children:Ne(t.type)}),e.jsx("div",{style:{fontSize:16,fontWeight:500,color:"var(--ink)"},children:t.label})]}),e.jsx("button",{onClick:x,"aria-label":"Close drawer",style:{width:24,height:24,borderRadius:4,background:"var(--surface)",border:"1px solid var(--border)",color:"var(--ink2)"},children:"×"})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:14},children:[U?e.jsx(Pe,{node:t,sessions:E,shared:g,onToggleShare:_e,onOpenVault:()=>C(),onOpenSession:y,busy:h}):null,I?e.jsx(Oe,{node:t,onOpenSession:()=>y(t.id,je(t))}):null,L?e.jsx(Le,{projects:V,projectName:N,onProjectName:z,onCreateProject:D,confirmReset:R,onAskReset:()=>_(!0),onCancelReset:()=>_(!1),onConfirmReset:F,busy:h}):null,d?e.jsx(Ie,{teams:ne,teamName:M,onTeamName:T,onCreateTeam:J,confirmDelete:$,onAskDelete:()=>X(!0),onCancelDelete:()=>X(!1),onConfirmDelete:fe,busy:h}):null,P?e.jsx(Be,{node:t,repoMappings:oe,developerCount:se,developerJoinEvents:ue,collaboratingTeams:pe,collaboratorOptions:ae,collabTeamId:m,onCollabTeamId:S,onAddCollaborator:we,folderPath:k,folderLabel:w,gitUrl:i,onFolderPath:c,onFolderLabel:j,onGitUrl:v,onPickFolder:Y,onAddFolder:K,onAddGit:f,onExtract:Ce,onRemoveFolder:ge,onOpenVault:()=>{var a;return C(String(((a=t.meta)==null?void 0:a.team_id)||""))},isManager:u,viewer:s,busy:h}):null,Q?e.jsx($e,{node:t,onRemove:()=>{var a;return ge(String(((a=t.meta)==null?void 0:a.mapping_id)||""))},busy:h}):null]})]})}function Ne(t){return t==="global_team"?"GLOBAL TEAM":t==="folder"?"LOCAL FOLDER":t==="session"?"AGENT SESSION":t.toUpperCase()}function Pe({node:t,sessions:r,shared:s,onToggleShare:u,onOpenVault:x,onOpenSession:C,busy:y}){const p=Z(t),h=String(p.path||""),o=Number(p.active_session_count||0),k=typeof p.context_manager=="object"&&p.context_manager?p.context_manager:null;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx("button",{onClick:x,style:ce(!1),children:"OPEN CONTEXT →"}),e.jsxs("div",{children:[e.jsx(A,{children:"Folder"}),e.jsxs("div",{style:{marginTop:6,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"grid",gap:4},children:[e.jsx(B,{label:"path",value:h||t.label,mono:!0}),e.jsx(B,{label:"sessions",value:`${r.length}`}),e.jsx(B,{label:"active",value:`${o}`})]})]}),e.jsxs("div",{children:[e.jsx(A,{children:"Context manager"}),e.jsxs("div",{style:{marginTop:6,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"grid",gap:4},children:[e.jsx(B,{label:"owner",value:String((k==null?void 0:k.display_name)||`${t.label} Context Manager`)}),e.jsx(B,{label:"scope",value:String((k==null?void 0:k.folder_path)||h||t.label),mono:!0})]})]}),e.jsxs("div",{children:[e.jsx(A,{children:"Context sharing"}),e.jsx("button",{onClick:u,disabled:y==="share-folder",style:s?ce(y==="share-folder"):ee(y==="share-folder"),children:y==="share-folder"?"UPDATING...":s?"SHARING ENABLED":"SHARE THIS FOLDER"}),e.jsx(re,{children:"Shared folders exchange local context with the other folders you enable here."})]}),e.jsxs("div",{children:[e.jsxs(A,{children:["Agent sessions (",r.length,")"]}),r.length===0?e.jsx(re,{children:"No Claude Code or Codex sessions detected for this folder yet."}):e.jsx("div",{style:{display:"grid",gap:4,marginTop:6},children:r.map(c=>{const w=Z(c),j=ze(w.runtime);return e.jsxs("div",{style:{padding:"7px 10px",border:"1px solid var(--border)",borderLeft:`3px solid ${j}`,borderRadius:4,background:"var(--surface)",display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",gap:8,alignItems:"center"},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:12,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:c.label,children:c.label}),e.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:j},children:[String(w.runtime||"agent")," · ",String(w.state||"recent")]})]}),e.jsx("button",{onClick:()=>C(c.id,je(c)),style:We(j),children:"OPEN"})]},c.id)})})]})]})}function Oe({node:t,onOpenSession:r}){const s=Z(t);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx("button",{onClick:r,style:ce(!1),children:"OPEN SESSION TASK →"}),e.jsxs("div",{children:[e.jsx(A,{children:"Session"}),e.jsxs("div",{style:{marginTop:6,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"grid",gap:4},children:[e.jsx(B,{label:"runtime",value:String(s.runtime||"agent")}),e.jsx(B,{label:"state",value:String(s.state||"recent")}),s.model?e.jsx(B,{label:"model",value:String(s.model)}):null,s.cwd?e.jsx(B,{label:"folder",value:String(s.cwd),mono:!0}):null,s.updated_at?e.jsx(B,{label:"updated",value:String(s.updated_at)}):null]})]}),s.preview?e.jsxs("div",{children:[e.jsx(A,{children:"Preview"}),e.jsx("div",{style:{marginTop:6,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",color:"var(--ink2)",fontSize:12,lineHeight:1.5,whiteSpace:"pre-wrap"},children:String(s.preview)})]}):null]})}function Le({projects:t,projectName:r,onProjectName:s,onCreateProject:u,confirmReset:x,onAskReset:C,onCancelReset:y,onConfirmReset:p,busy:h}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{children:[e.jsx(A,{children:"Add a project"}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsx("input",{value:r,onChange:o=>s(o.target.value),placeholder:"e.g. Text_to_Speech",onKeyDown:o=>{o.key==="Enter"&&u()},style:te}),e.jsx("button",{onClick:u,disabled:h==="create-project"||!r.trim(),style:ee(h==="create-project"),children:"CREATE"})]})]}),e.jsxs("div",{children:[e.jsxs(A,{children:["Projects (",t.length,")"]}),t.length===0?e.jsx(re,{children:"No projects yet. Add one above."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:8},children:t.map(o=>e.jsxs("div",{style:{padding:"6px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12,color:"var(--ink)"},children:[e.jsx("span",{children:o.label}),e.jsx(xe,{label:"open",tone:"default"})]},o.id))})]}),e.jsxs("div",{style:{marginTop:8,paddingTop:14,borderTop:"1px solid var(--border)"},children:[e.jsx(A,{children:"Danger zone"}),x?e.jsxs("div",{style:{marginTop:8,padding:10,border:"1px solid var(--rose)",background:"var(--rose-dim)",borderRadius:4,fontSize:12,color:"var(--ink)"},children:[e.jsx("div",{style:{marginBottom:8},children:"This deletes projects, teams, folders, context items, proposals, and findings for this org. Memory engrams in the Dhee tier are not affected. Continue?"}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{onClick:p,disabled:h==="reset",style:ie,children:h==="reset"?"RESETTING…":"YES, RESET"}),e.jsx("button",{onClick:y,style:he,children:"CANCEL"})]})]}):e.jsx("button",{onClick:C,style:ie,children:"RESET WORKSPACE"})]})]})}function Ie({teams:t,teamName:r,onTeamName:s,onCreateTeam:u,confirmDelete:x,onAskDelete:C,onCancelDelete:y,onConfirmDelete:p,busy:h}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{children:[e.jsx(A,{children:"Add a team"}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsx("input",{value:r,onChange:o=>s(o.target.value),placeholder:"Backend, Frontend, Data, Mobile",onKeyDown:o=>{o.key==="Enter"&&u()},style:te}),e.jsx("button",{onClick:u,disabled:h==="create-team"||!r.trim(),style:ee(h==="create-team"),children:"ADD"})]})]}),e.jsxs("div",{children:[e.jsxs(A,{children:["Teams (",t.length,")"]}),t.length===0?e.jsx(re,{children:"No teams yet."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:8},children:t.map(o=>{const k=ke(Se(o));return e.jsxs("div",{style:{padding:"6px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsx("span",{style:{color:"var(--ink)",fontSize:12},children:o.label}),e.jsx(xe,{label:`${k.length} ${k.length===1?"repo":"repos"}`,tone:k.length?"green":"default"})]},o.id)})})]}),e.jsx("div",{style:{marginTop:8,paddingTop:14,borderTop:"1px solid var(--border)"},children:x?e.jsxs("div",{style:{marginTop:4,padding:10,border:"1px solid var(--rose)",background:"var(--rose-dim)",borderRadius:4,fontSize:12,color:"var(--ink)"},children:[e.jsx("div",{style:{marginBottom:8},children:"Deletes the project and all its teams + context. Continue?"}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{onClick:p,disabled:h==="delete-project",style:ie,children:h==="delete-project"?"DELETING…":"YES, DELETE"}),e.jsx("button",{onClick:y,style:he,children:"CANCEL"})]})]}):e.jsx("button",{onClick:C,style:ie,children:"DELETE PROJECT"})})]})}function Be({node:t,repoMappings:r,developerCount:s,developerJoinEvents:u,collaboratingTeams:x,collaboratorOptions:C,collabTeamId:y,onCollabTeamId:p,onAddCollaborator:h,folderPath:o,folderLabel:k,gitUrl:c,onFolderPath:w,onFolderLabel:j,onGitUrl:N,onPickFolder:z,onAddFolder:M,onAddGit:T,onExtract:i,onRemoveFolder:v,onOpenVault:m,busy:S}){const R=Z(t),_=R.context_manager,$=String(R.team_id||""),X=String(R.project_id||""),L=ke(r);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx("button",{onClick:m,style:ce(!1),children:"OPEN CONTEXT →"}),e.jsxs("div",{children:[e.jsx(A,{children:"Team details"}),e.jsxs("div",{style:{marginTop:6,display:"grid",gap:4,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",fontSize:12},children:[e.jsx(B,{label:"team",value:$||t.label}),X?e.jsx(B,{label:"project",value:X}):null,e.jsx(B,{label:"git access",value:`${s} dev${s===1?"":"s"} joined`})]})]}),e.jsxs("div",{children:[e.jsx(A,{children:"Manager"}),e.jsx("div",{style:{marginTop:6,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",fontSize:12},children:_!=null&&_.display_name?e.jsxs(e.Fragment,{children:[e.jsx("div",{children:_.display_name}),e.jsx("div",{style:{fontSize:10,color:"var(--ink3)"},children:_.manager_id})]}):e.jsx("span",{style:{color:"var(--ink3)"},children:"no manager assigned"})})]}),e.jsxs("div",{children:[e.jsx(A,{children:"Add a local folder"}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsx("input",{value:o,onChange:d=>w(d.target.value),placeholder:"/Users/me/code/backend",onKeyDown:d=>{d.key==="Enter"&&M()},style:te}),e.jsx("button",{onClick:z,disabled:S==="pick-folder",style:he,title:"Browse",children:"BROWSE"})]}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:6},children:[e.jsx("input",{value:k,onChange:d=>j(d.target.value),placeholder:"Optional label",style:te}),e.jsx("button",{onClick:M,disabled:S==="add-folder"||!o.trim(),style:ee(S==="add-folder"),children:"ADD"})]})]}),e.jsxs("div",{children:[e.jsx(A,{children:"Add a git repo"}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsx("input",{value:c,onChange:d=>N(d.target.value),placeholder:"git@github.com:org/backend.git",onKeyDown:d=>{d.key==="Enter"&&T()},style:te}),e.jsx("button",{onClick:T,disabled:S==="add-git"||!c.trim(),style:ee(S==="add-git"),children:"ADD"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsxs(A,{children:["Git + local folders (",L.length,")"]}),e.jsx("button",{onClick:i,disabled:S==="extract"||L.length===0,title:"Run AST extraction for this team's local folders",style:ee(S==="extract"),children:S==="extract"?"INDEXING...":"INDEX TEAM"})]}),L.length===0?e.jsx(re,{children:"None mapped to this team."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:6},children:L.map(d=>{const P=String(d.mapping_id||d.local_path||d.repo_url);return e.jsxs("div",{style:{padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"grid",gap:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsx("div",{style:{fontSize:12,color:"var(--ink)"},children:Ae(d)}),e.jsx("button",{onClick:()=>v(d.mapping_id),style:Ge,title:"Remove mapping","aria-label":"Remove mapping",children:"×"})]}),d.repo_url?e.jsx(B,{label:"repo",value:String(d.repo_url),mono:!0}):null,d.local_path?e.jsx(B,{label:"folder",value:String(d.local_path),mono:!0}):null]},P)})})]}),u.length?e.jsxs("div",{children:[e.jsx(A,{children:"Recent joins"}),e.jsx("div",{style:{display:"grid",gap:4,marginTop:6},children:u.slice(0,4).map((d,P)=>e.jsxs("div",{style:{padding:"6px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",fontSize:11,color:"var(--ink2)"},children:[e.jsx("div",{style:{fontFamily:"var(--mono)",overflow:"hidden",textOverflow:"ellipsis"},children:d.repo_root||"workspace"}),e.jsxs("div",{style:{color:"var(--ink3)",marginTop:2},children:[d.role||"developer"," - ",d.received_at||"recent"]})]},`${d.repo_root||"join"}-${P}`))})]}):null,e.jsxs("div",{children:[e.jsx(A,{children:"Collaborate teams"}),x.length===0?e.jsx(re,{children:"No team context shares yet."}):e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:6},children:x.map(d=>e.jsx(xe,{label:String(d.name||d.team_id),tone:"default"},String(d.team_id||d.name)))}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsxs("select",{value:y,onChange:d=>p(d.target.value),style:te,children:[e.jsx("option",{value:"",children:"Select team"}),C.map(d=>{var Q;const P=String(((Q=d.meta)==null?void 0:Q.team_id)||"");return e.jsx("option",{value:P,children:d.label},d.id)})]}),e.jsx("button",{onClick:h,disabled:S==="collaborate"||!y,style:ee(S==="collaborate"),children:"ADD"})]})]})]})}function $e({node:t,onRemove:r,busy:s}){const u=t.meta||{};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(A,{children:"Folder / path"}),e.jsx("div",{style:{padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",fontFamily:"var(--mono)",fontSize:11,color:"var(--ink2)",wordBreak:"break-all"},children:u.local_path||u.repo_url||t.label}),e.jsx("button",{onClick:r,disabled:s==="remove-folder",style:ie,children:s==="remove-folder"?"REMOVING…":"REMOVE"})]})}function B({label:t,value:r,mono:s=!1}){return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"82px minmax(0, 1fr)",gap:8,alignItems:"baseline"},children:[e.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",textTransform:"uppercase"},children:t}),e.jsx("span",{title:r,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:s?"var(--mono)":void 0,fontSize:s?10:12,color:"var(--ink2)"},children:r})]})}function re({children:t}){return e.jsx("div",{style:{fontSize:11,color:"var(--ink3)",marginTop:6},children:t})}function xe({label:t,tone:r="default"}){const u={default:{bg:"var(--surface)",fg:"var(--ink2)"},green:{bg:"var(--green-dim)",fg:"var(--green)"},indigo:{bg:"var(--indigo-dim)",fg:"var(--indigo)"},rose:{bg:"var(--rose-dim)",fg:"var(--rose)"},accent:{bg:"var(--accent-dim)",fg:"var(--accent)"}}[r];return e.jsx("span",{style:{display:"inline-flex",padding:"2px 7px",borderRadius:3,background:u.bg,color:u.fg,fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.04em"},children:t})}const te={flex:1,fontFamily:"var(--mono)",fontSize:11,padding:"6px 8px",background:"var(--surface)",border:"1px solid var(--border)",borderRadius:3,color:"var(--ink)"};function ee(t){return{fontFamily:"var(--mono)",fontSize:10,padding:"5px 12px",background:t?"var(--surface)":"var(--accent-dim)",color:"var(--accent)",border:"1px solid var(--accent)",borderRadius:3,cursor:t?"wait":"pointer"}}function ce(t){return{fontFamily:"var(--mono)",fontSize:11,padding:"8px 12px",background:t?"var(--surface)":"var(--accent-dim)",color:"var(--accent)",border:"1px solid var(--accent)",borderRadius:4,textAlign:"center",cursor:t?"wait":"pointer"}}function We(t){return{fontFamily:"var(--mono)",fontSize:9,padding:"5px 8px",background:"white",color:t,border:`1px solid ${t}`,borderRadius:3,cursor:"pointer",whiteSpace:"nowrap"}}const he={fontFamily:"var(--mono)",fontSize:10,padding:"5px 10px",background:"var(--surface)",color:"var(--ink2)",border:"1px solid var(--border)",borderRadius:3},ie={fontFamily:"var(--mono)",fontSize:10,padding:"5px 12px",background:"var(--rose-dim)",color:"var(--rose)",border:"1px solid var(--rose)",borderRadius:3},Ge={width:22,height:22,borderRadius:3,background:"var(--surface)",color:"var(--ink2)",border:"1px solid var(--border)",fontSize:12,lineHeight:1};function Ye(t,r={}){const s=r.siblingGap??24,u=r.levelGap??100,x=new Map;for(const i of t)x.set(i.id,{id:i.id,parent:i.parent,children:[],width:i.width,height:i.height,depth:i.depth,subtreeWidth:i.width,x:0,y:0});const C=[];for(const i of x.values())i.parent&&x.has(i.parent)?x.get(i.parent).children.push(i.id):C.push(i);const y=i=>{const v=x.get(i);if(!v.children.length)return v.subtreeWidth=v.width,v.subtreeWidth;let m=0;for(const S of v.children)m+=y(S);return m+=s*(v.children.length-1),v.subtreeWidth=Math.max(v.width,m),v.subtreeWidth},p=new Map;for(const i of x.values())p.set(i.depth,Math.max(p.get(i.depth)||0,i.height));const h=new Map;let o=0;const k=Math.max(0,...Array.from(p.keys()));for(let i=0;i<=k;i+=1)h.set(i,o),o+=(p.get(i)||0)+u;const c=(i,v)=>{const m=x.get(i);if(m.y=h.get(m.depth)||0,!m.children.length){m.x=v+m.width/2;return}let S=v,R=[];for(const _ of m.children){const $=x.get(_);c(_,S),R.push($.x),S+=$.subtreeWidth+s}if(R.length===0)m.x=v+m.width/2;else{const _=Math.min(...R),$=Math.max(...R);m.x=(_+$)/2}};let w=0;for(const i of C)y(i.id),c(i.id,w),w+=i.subtreeWidth+s*2;let j=1/0,N=1/0,z=-1/0,M=-1/0;const T=[];for(const i of x.values()){const v=i.width/2;j=Math.min(j,i.x-v),z=Math.max(z,i.x+v),N=Math.min(N,i.y),M=Math.max(M,i.y+i.height),T.push({id:i.id,parent:i.parent,width:i.width,height:i.height,depth:i.depth,x:i.x,y:i.y})}return Number.isFinite(j)||(j=0,N=0,z=0,M=0),{nodes:T,bounds:{minX:j,minY:N,maxX:z,maxY:M}}}const le={workspace:{w:280,h:76},project:{w:200,h:64},team:{w:180,h:56},global_team:{w:200,h:60},repo:{w:180,h:52},folder:{w:230,h:70},session:{w:190,h:58},integration:{w:150,h:46},default:{w:160,h:50}};function Xe(t){return le[t]?le[t]:t.startsWith("integration:")?le.integration:le.default}function me(t){return String((t.meta||{}).runtime||"").toLowerCase()}function He(t){return t==="codex"?"var(--indigo)":t==="claude-code"||t==="claude"?"var(--accent)":"var(--ink3)"}function Ke(t){return t==="codex"?"var(--indigo-dim)":t==="claude-code"||t==="claude"?"var(--accent-dim)":"var(--surface)"}function Ue(t,r){return r==="needs_work"?"var(--rose)":r==="watch"?"var(--accent)":t==="folder"?"var(--green)":t==="session"?"var(--accent)":t==="workspace"?"var(--ink2)":t==="project"?"var(--accent)":t==="team"?"var(--green)":t==="global_team"?"var(--indigo)":t==="repo"?"var(--green)":t==="integration:slack"?"var(--indigo)":t==="integration:docs"?"var(--accent)":t==="integration:email"?"var(--rose)":t==="integration:git"?"var(--green)":"var(--ink3)"}function Ve(t){return t.health==="needs_work"?"var(--rose)":t.type==="session"?He(me(t)):Ue(t.type,t.health)}function Je(t){return t==="workspace"?"white":t==="folder"?"var(--green-dim)":t==="session"?"var(--surface)":t==="project"?"var(--accent-dim)":t==="team"||t==="global_team"?"var(--surface)":t==="repo"?"var(--green-dim)":(t.startsWith("integration:"),"var(--surface)")}function qe(t){return t.type==="session"?Ke(me(t)):Je(t.type)}function Qe({graph:t,viewer:r,onOpenVault:s,onOpenSession:u,onChanged:x}){var ae;const C=b.useRef(null),y=b.useRef({down:!1,lastX:0,lastY:0}),p=b.useRef(!1),h=b.useRef(null),[o,k]=b.useState({w:1200,h:700}),[c,w]=b.useState(0),[j,N]=b.useState(0),[z,M]=b.useState(1),[T,i]=b.useState(null),[v,m]=b.useState(null),[S,R]=b.useState(null),[_,$]=b.useState(""),[X,L]=b.useState(null),d=((ae=t.raw)==null?void 0:ae.mode)==="local_context",P=async()=>{R("add-folder"),L(null);try{const n=await W.pickFolderPath("Choose a folder to share context");n.ok&&n.path&&(await W.localContextAddFolder({path:n.path,shared:!0}),x())}catch(n){L(String(n))}finally{R(null)}},Q=async()=>{const n=_.trim();if(!(!n||S)){R("manual-folder"),L(null);try{await W.localContextAddFolder({path:n,shared:!0}),$(""),x()}catch(l){L(String(l))}finally{R(null)}}};b.useEffect(()=>{const n=C.current;if(!n)return;const l=()=>{const E=n.getBoundingClientRect(),F={w:Math.round(E.width),h:Math.round(E.height)};k(D=>D.w===F.w&&D.h===F.h?D:F)};l();const g=new ResizeObserver(l);return g.observe(n),()=>g.disconnect()},[]);const{positions:U,bounds:I}=b.useMemo(()=>{const n=new Map;for(const f of t.edges){if(f.kind!=="contains"&&f.kind!=="uses")continue;const Y=n.get(f.source)||[];Y.push(f.target),n.set(f.source,Y)}const l=new Map;for(const f of t.edges)f.kind!=="contains"&&f.kind!=="uses"||l.set(f.target,f.source);const g=new Map,F=t.nodes.filter(f=>f.type==="workspace"||!l.has(f.id)).map(f=>f.id).map(f=>({id:f,depth:0}));for(;F.length;){const{id:f,depth:Y}=F.shift();if(!g.has(f)){g.set(f,Y);for(const fe of n.get(f)||[])F.push({id:fe,depth:Y+1})}}const D=t.nodes.map(f=>{const Y=Xe(f.type);return{id:f.id,parent:l.get(f.id)||null,width:Y.w,height:Y.h,depth:g.get(f.id)??0}}),J=Ye(D,{siblingGap:24,levelGap:90}),K=new Map;for(const f of J.nodes)K.set(f.id,{x:f.x,y:f.y,w:f.width,h:f.height});return{positions:K,bounds:J.bounds}},[t.nodes,t.edges]),V=b.useMemo(()=>JSON.stringify({nodes:t.nodes.map(n=>[n.id,n.type,n.label,n.health||""]),edges:t.edges.map(n=>[n.source,n.target,n.kind])}),[t.nodes,t.edges]),G=()=>{const n=I.maxX-I.minX,l=I.maxY-I.minY;if(n<=0||l<=0||o.w<=0||o.h<=0)return!1;const g=80,E=(o.w-g*2)/n,F=(o.h-g*2)/l,D=Math.min(1.2,Math.max(.45,Math.min(E,F)));return M(D),w(o.w/2-(I.minX+I.maxX)/2*D),N(g-I.minY*D),!0};b.useEffect(()=>{const n=`${o.w}x${o.h}`,l=h.current,g=(l==null?void 0:l.structure)!==V,E=(l==null?void 0:l.size)!==n;if(!(!g&&!E)){if(l&&p.current){h.current={structure:V,size:n};return}G()&&(h.current={structure:V,size:n})}},[I.minX,I.maxX,I.minY,I.maxY,o.w,o.h,V]);const ne=n=>{var J;n.preventDefault(),p.current=!0;const l=Math.exp(-n.deltaY*.001),g=Math.min(2.5,Math.max(.3,z*l)),E=(J=C.current)==null?void 0:J.getBoundingClientRect();if(!E){M(g);return}const F=n.clientX-E.left,D=n.clientY-E.top;w(K=>F-(F-K)/z*g),N(K=>D-(D-K)/z*g),M(g)},oe=n=>{y.current={down:!0,lastX:n.clientX,lastY:n.clientY}},H=n=>{const l=y.current;l.down&&(p.current=!0,w(g=>g+(n.clientX-l.lastX)),N(g=>g+(n.clientY-l.lastY)),y.current={down:!0,lastX:n.clientX,lastY:n.clientY})},O=()=>{y.current.down=!1},se=()=>{p.current=!1,G()&&(h.current={structure:V,size:`${o.w}x${o.h}`})},ue=t.totals.projects>0||t.totals.teams>0||t.totals.repos>0||(t.totals.folders||0)>0||(t.totals.sessions||0)>0||t.totals.context_items>0;if(!t.live||!ue)return e.jsxs("div",{className:"dhee-canvas-bg",style:{position:"relative",flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(ye,{onOpenContext:()=>s()}),e.jsx(rt,{viewer:r,busy:S,onAddFolder:P,manualPath:_,onManualPathChange:$,onAddManualFolder:Q,error:X})]});const pe=(r==null?void 0:r.role)==="manager"||(r==null?void 0:r.role)==="admin";return e.jsxs("div",{ref:C,onWheel:ne,onMouseDown:oe,onMouseMove:H,onMouseUp:O,onMouseLeave:O,onDoubleClick:se,className:"dhee-canvas-bg",style:{position:"relative",flex:1,cursor:y.current.down?"grabbing":"grab",overflow:"hidden"},children:[e.jsx(ye,{onOpenContext:()=>s()}),e.jsx("svg",{width:o.w,height:o.h,style:{display:"block",userSelect:"none"},children:e.jsxs("g",{transform:`translate(${c},${j}) scale(${z})`,children:[t.edges.map((n,l)=>{const g=U.get(n.source),E=U.get(n.target);if(!g||!E)return null;const F=g.x,D=g.y+g.h/2,J=E.x,K=E.y-E.h/2,f=(D+K)/2,Y=v&&(n.source===v||n.target===v);return e.jsx("path",{d:`M ${F},${D} C ${F},${f} ${J},${f} ${J},${K}`,className:Y?"dhee-edge-path dhee-edge-path--highlight":v?"dhee-edge-path dhee-edge-path--dim":"dhee-edge-path"},`${n.source}-${n.target}-${l}`)}),t.nodes.map(n=>{const l=U.get(n.id);if(!l)return null;const g=Ve(n),E=qe(n),F=(T==null?void 0:T.id)===n.id;return e.jsxs("g",{onMouseEnter:()=>m(n.id),onMouseLeave:()=>m(null),onClick:D=>{D.stopPropagation(),i(n)},style:{cursor:"pointer"},children:[e.jsx("rect",{x:l.x-l.w/2,y:l.y,width:l.w,height:l.h,rx:8,ry:8,fill:E,stroke:g,strokeWidth:F?2.4:n.type==="workspace"?1.6:1.2}),n.type==="workspace"?e.jsx("text",{x:l.x,y:l.y+24,textAnchor:"middle",fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.12em",fill:"var(--ink3)",pointerEvents:"none",children:"WORKSPACE"}):null,e.jsx("text",{x:l.x,y:n.type==="workspace"?l.y+50:l.y+l.h/2+4,textAnchor:"middle",fontFamily:"var(--font)",fontSize:n.type==="workspace"?16:12,fontWeight:n.type==="workspace"?500:400,fill:"var(--ink)",pointerEvents:"none",children:et(n.label,n.type==="workspace"?30:22)}),n.type!=="workspace"?e.jsx("text",{x:l.x,y:l.y+16,textAnchor:"middle",fontFamily:"var(--mono)",fontSize:8,letterSpacing:"0.1em",fill:"var(--ink3)",pointerEvents:"none",children:Ze(n)}):null]},n.id)})]})}),d?e.jsxs("div",{style:{position:"absolute",left:12,top:12,display:"flex",gap:8,alignItems:"center",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,padding:"6px 8px",boxShadow:"0 4px 14px rgba(20,16,10,0.05)"},children:[e.jsx("button",{onClick:P,disabled:S==="add-folder",style:{fontFamily:"var(--mono)",fontSize:10,border:"1px solid var(--accent)",color:"var(--accent)",background:"var(--accent-dim)",borderRadius:4,padding:"5px 8px",cursor:S==="add-folder"?"wait":"pointer"},children:S==="add-folder"?"ADDING...":"ADD FOLDER"}),e.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"local context sharing"})]}):null,e.jsx(tt,{graph:t}),T?e.jsx(Me,{node:T,graph:t,viewer:r,isManager:pe,onClose:()=>i(null),onOpenVault:s,onOpenSession:u,onChanged:()=>{i(null),x()}}):null]})}function Ze(t){const r=t.type;if(r==="session"){const s=me(t);if(s==="codex")return"CODEX";if(s==="claude-code"||s==="claude")return"CLAUDE CODE"}return r.startsWith("integration:")?r.split(":")[1].toUpperCase():r.toUpperCase()}function et(t,r){return t?t.length<=r?t:t.slice(0,r-1)+"…":""}function tt({graph:t}){var r;return((r=t.raw)==null?void 0:r.mode)==="local_context"?e.jsxs("div",{style:{position:"absolute",left:12,bottom:12,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,padding:"5px 9px",letterSpacing:"0.04em"},children:[t.totals.folders||t.totals.repos," folders ·"," ",t.totals.sessions||t.totals.teams," sessions ·"," ",t.totals.shared_folders||0," shared"]}):e.jsxs("div",{style:{position:"absolute",left:12,bottom:12,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,padding:"5px 9px",letterSpacing:"0.04em"},children:[t.totals.projects," projects · ",t.totals.teams," teams ·"," ",t.totals.repos," folders · ",t.totals.pending_proposals," pending"]})}function rt({viewer:t,busy:r,onAddFolder:s,manualPath:u,onManualPathChange:x,onAddManualFolder:C,error:y}){return e.jsx("div",{className:"dhee-canvas-bg",style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:32},children:e.jsxs("div",{style:{width:"min(640px, calc(100vw - 64px))",padding:24,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 18px rgba(20,16,10,0.05)",animation:"dhee-card-in 0.22s ease"},children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.12em",color:"var(--ink3)",textTransform:"uppercase",marginBottom:6},children:t!=null&&t.user_id?`local · ${t.user_id}`:"local context"}),e.jsx("div",{style:{fontSize:18,fontWeight:500,color:"var(--ink)",marginBottom:6},children:"No local agent folders yet"}),e.jsx("div",{style:{fontSize:12,color:"var(--ink2)",lineHeight:1.5,marginBottom:14},children:"Dhee will show local Claude Code and Codex sessions grouped by folder. Add any folder you want to share context with the rest of your local agent folders."}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.jsx("button",{onClick:s,disabled:r==="add-folder",style:{fontFamily:"var(--mono)",fontSize:11,padding:"8px 14px",background:r==="add-folder"?"var(--surface)":"var(--accent-dim)",color:"var(--accent)",border:"1px solid var(--accent)",borderRadius:4,cursor:r==="add-folder"?"wait":"pointer"},children:r==="add-folder"?"ADDING...":"ADD FOLDER"})}),e.jsxs("div",{style:{marginTop:14,borderTop:"1px solid var(--border)",paddingTop:14,display:"grid",gap:8},children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"REPO PATH"}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{value:u,onChange:p=>x(p.target.value),onKeyDown:p=>{p.key==="Enter"&&C()},placeholder:"/Users/me/work/repo",style:{flex:1,minWidth:0,border:"1px solid var(--border)",borderRadius:4,padding:"9px 10px",background:"white",fontFamily:"var(--mono)",fontSize:11,color:"var(--ink)"}}),e.jsx("button",{onClick:()=>void C(),disabled:!u.trim()||r==="manual-folder",style:{fontFamily:"var(--mono)",fontSize:11,padding:"8px 12px",background:"white",color:"var(--accent)",border:"1px solid var(--border)",borderRadius:4,opacity:!u.trim()||r==="manual-folder"?.55:1,cursor:!u.trim()||r==="manual-folder"?"not-allowed":"pointer"},children:r==="manual-folder"?"LINKING...":"LINK PATH"})]}),e.jsx("code",{style:{display:"block",border:"1px solid var(--border)",background:"var(--surface)",borderRadius:4,padding:"8px 9px",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink2)",overflowWrap:"anywhere"},children:"dhee onboard --root ."}),y?e.jsx("div",{style:{fontSize:11,color:"var(--rose)"},children:y}):null]})]})})}const de={live:!1,org_id:"local",nodes:[],edges:[],totals:{projects:0,teams:0,repos:0,context_items:0,pending_proposals:0,folders:0,sessions:0,shared_folders:0},raw:{mode:"local_context",folders:[],sessions:[],shared_folder_paths:[],context_index:[],pending_proposals:[],context_managers_by_team:{}}};function nt(t){var r;return t?{...de,...t,org_id:t.org_id||"local",nodes:t.nodes||[],edges:t.edges||[],totals:{...de.totals,...t.totals||{}},raw:{...de.raw,...t.raw||{},mode:((r=t.raw)==null?void 0:r.mode)||"local_context"}}:de}function st(t){return e.jsx(Qe,{graph:nt(t.orgGraph),viewer:t.viewer||null,tweaks:t.tweaks,onOpenVault:t.onOpenVault||(()=>{}),onOpenSession:t.onSelectSession,onChanged:t.onOrgGraphChanged||(()=>{})})}export{st as CanvasView}; +import{r as b,j as e,a as W,R as ye}from"./index-BboZhdsv.js";const Te={workspace:"#e06b3f",project:"#4d6cff",channel:"#1fa971",session:"#1a1a1a",task:"#0f9f55",result:"#0b8b5f",file:"#64748b",asset:"#d74b7b",broadcast:"#e08b3f"},Re={workspace:"Workspace",project:"Project",channel:"Channel",session:"Session",task:"Task",result:"Tool result",file:"File",asset:"Asset",broadcast:"Broadcast"};function Ee(t){return t.accent||Te[t.type]||"#555"}function be(t){if(!t)return"";const r=new Date(String(t));return Number.isNaN(r.getTime())?"":r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Fe(t,r){const s=t.trim();return s.length<=r?s:`${s.slice(0,r-1).trimEnd()}…`}function De({node:t,x:r,y:s,width:u,height:x,selected:C,dim:y,onSelect:p,onHover:h,entranceDelay:o=0}){const k=Ee(t),c=t.meta||{},w=x<120,j=t.type,N={position:"absolute",left:r,top:s,width:u,height:x,display:"flex",boxSizing:"border-box",background:"white",border:`1px solid ${C?k:"rgba(20,16,10,0.12)"}`,borderLeft:`3px solid ${k}`,borderRadius:8,boxShadow:C?`0 10px 26px rgba(20,16,10,0.12), 0 0 0 3px ${k}22`:"0 1px 2px rgba(20,16,10,0.04), 0 2px 10px rgba(20,16,10,0.04)",transition:"box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease",cursor:"pointer",userSelect:"none",opacity:y?.32:1,willChange:"transform",transform:"translate3d(0, 0, 0)",overflow:"hidden",animation:`dhee-card-in 320ms ${o}ms cubic-bezier(0.17, 0.67, 0.3, 1) both`},z={flex:1,padding:w?"10px 12px":"12px 14px",display:"flex",flexDirection:"column",gap:w?4:6,minWidth:0},M={display:"flex",alignItems:"center",gap:6},T=(O,se)=>({fontFamily:"var(--mono)",fontSize:9,color:se||"var(--ink3)",letterSpacing:.4,textTransform:"uppercase",lineHeight:1.1,padding:"2px 6px",border:"1px solid var(--border)",borderRadius:2,whiteSpace:"nowrap",background:"white",...O?{}:{}}),i={fontSize:w?12:14,fontWeight:600,lineHeight:1.25,color:"var(--ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},v={fontSize:w?11:12,color:"var(--ink2)",lineHeight:1.5,display:"-webkit-box",WebkitLineClamp:w?2:3,WebkitBoxOrient:"vertical",overflow:"hidden"},m={fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:.3},S=Re[j]||j,R=String(c.runtime||""),_=String(c.state||""),$=String(c.ptr||""),X=String(c.toolName||c.tool_name||""),L=String(c.sourcePath||c.source_path||""),d=String(c.model||""),P=String(c.harness||""),Q=Number(c.sessionCount??0),U=Number(c.projectCount??0),I=Number(c.taskCount??0),V=Number(c.messageCount??0),G=c.updatedAt||c.last_seen_at,ne=()=>h(t),oe=()=>h(null),H=O=>{O.stopPropagation(),p(t)};return e.jsx("div",{style:N,onClick:H,onMouseEnter:ne,onMouseLeave:oe,"data-canvas-draggable":"false","data-node-id":t.id,className:"dhee-node-card",children:e.jsxs("div",{style:z,children:[e.jsxs("div",{style:M,children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:k,flexShrink:0}}),e.jsx("span",{style:{...m,color:k},children:S}),t.status?e.jsx("span",{style:T(t.status),children:t.status}):null,_?e.jsx("span",{style:T(_),children:_}):null,R?e.jsx("span",{style:T(R),children:R}):null,P&&!R?e.jsx("span",{style:T(P),children:P}):null,j==="session"&&c.isCurrent?e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--green)",boxShadow:"0 0 0 3px rgba(31,169,113,0.22)",marginLeft:"auto"}}):null]}),e.jsx("div",{style:i,children:t.label||"(unnamed)"}),t.subLabel?e.jsx("div",{style:{...m,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.subLabel}):null,!w&&t.body?e.jsx("div",{style:v,children:t.body}):null,j==="workspace"&&!w?e.jsxs("div",{style:{display:"flex",gap:12,...m},children:[e.jsxs("span",{children:[U||"—"," projects"]}),e.jsxs("span",{children:[Q||"—"," sessions"]})]}):null,j==="project"&&!w?e.jsxs("div",{style:{display:"flex",gap:12,...m},children:[e.jsxs("span",{children:[Q||"—"," sessions"]}),e.jsxs("span",{children:[I||"—"," tasks"]})]}):null,j==="session"&&!w?e.jsxs("div",{style:{display:"flex",gap:12,...m},children:[d?e.jsx("span",{children:Fe(d,22)}):null,G?e.jsx("span",{children:be(G)}):null]}):null,j==="task"&&!w?e.jsxs("div",{style:{display:"flex",gap:12,...m},children:[V?e.jsxs("span",{children:[V," messages"]}):null,G?e.jsx("span",{children:be(G)}):null]}):null,j==="result"?e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",...m},children:[X?e.jsx("span",{children:X}):null,$?e.jsx("span",{children:$}):null,L?e.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["· ",L.split("/").pop()]}):null]}):null,j==="broadcast"?e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",...m},children:[String(c.sourceChannel||c.sourceProject||"")?e.jsxs("span",{children:["from ",String(c.sourceChannel||c.sourceProject||"")]}):null,String(c.targetProject||"")?e.jsxs("span",{children:["→ ",String(c.targetProject)]}):null]}):null]})})}b.memo(De);function A({label:t,sub:r,children:s}){const u=t||s;return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10,marginBottom:12},children:[e.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,fontWeight:700,color:"var(--ink3)",letterSpacing:"0.1em",textTransform:"uppercase"},children:u}),r&&e.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--border2)"},children:r})]})}function Z(t){return(t==null?void 0:t.meta)||{}}function je(t){const r=Z(t);return String(r.task_id||r.taskId||"")||null}function Se(t){const r=Z(t).repo_mappings;return Array.isArray(r)?r:[]}function Ae(t){const r=t.metadata||{},u=(typeof r.label=="string"?r.label.trim():"")||t.local_path||t.repo_url||"folder";return String(u).split("/").filter(Boolean).pop()||String(u)}function ze(t){const r=String(t||"").toLowerCase();return r==="codex"?"var(--indigo)":r==="claude-code"||r==="claude"?"var(--accent)":"var(--ink3)"}function ke(t){const r=new Set,s=[];for(const u of t){const x=String(u.mapping_id||u.local_path||u.repo_url||"");!x||r.has(x)||(r.add(x),s.push(u))}return s}function Me({node:t,graph:r,viewer:s,isManager:u,onClose:x,onOpenVault:C,onOpenSession:y,onChanged:p}){var ve;const[h,o]=b.useState(null),[k,c]=b.useState(""),[w,j]=b.useState(""),[N,z]=b.useState(""),[M,T]=b.useState(""),[i,v]=b.useState(""),[m,S]=b.useState(""),[R,_]=b.useState(!1),[$,X]=b.useState(!1);if(b.useEffect(()=>{c(""),j(""),z(""),T(""),v(""),S(""),_(!1),X(!1)},[t==null?void 0:t.id]),!t)return null;const L=t.type==="workspace",d=t.type==="project",P=t.type==="team"||t.type==="global_team",Q=t.type==="repo",U=t.type==="folder",I=t.type==="session",V=L&&r?r.edges.filter(a=>a.source===t.id&&a.kind==="contains").map(a=>r.nodes.find(q=>q.id===a.target)).filter(a=>!!a&&a.type==="project"):[],G=d?String(((ve=t.meta)==null?void 0:ve.project_id)||""):"",ne=d&&r?r.edges.filter(a=>a.kind==="contains"&&a.source===t.id).map(a=>r.nodes.find(q=>q.id===a.target)).filter(a=>!!a&&(a.type==="team"||a.type==="global_team")):[],oe=P?Se(t):[],H=Z(t),O=P?String(H.team_id||""):"",se=typeof H.developer_count=="number"?H.developer_count:0,ue=Array.isArray(H.developer_join_events)?H.developer_join_events:[],pe=Array.isArray(H.collaborating_teams)?H.collaborating_teams:[],ae=r?r.nodes.filter(a=>{var q;return(a.type==="team"||a.type==="global_team")&&String(((q=a.meta)==null?void 0:q.team_id)||"")!==O}):[],n=Z(t),l=U?String(n.path||""):"",g=U?!!n.shared:!1,E=U&&r?r.edges.filter(a=>a.source===t.id&&a.kind==="contains").map(a=>r.nodes.find(q=>q.id===a.target)).filter(a=>!!a&&a.type==="session"):[],F=async()=>{o("reset");try{await W.enterpriseResetWorkspace(),p()}finally{o(null)}},D=async()=>{if(N.trim()){o("create-project");try{await W.enterpriseCreateProject({name:N.trim()}),z(""),p()}finally{o(null)}}},J=async()=>{if(!(!G||!M.trim())){o("create-team");try{await W.enterpriseCreateProjectTeam(G,{name:M.trim()}),T(""),p()}finally{o(null)}}},K=async()=>{if(!(!O||!k.trim())){o("add-folder");try{await W.enterpriseAddTeamFolder(O,{local_path:k.trim(),label:w.trim()||void 0,kind:"folder"}),c(""),j(""),p()}finally{o(null)}}},f=async()=>{if(!(!O||!i.trim())){o("add-git");try{await W.enterpriseAddTeamFolder(O,{repo_url:i.trim(),kind:"git"}),v(""),p()}finally{o(null)}}},Y=async()=>{o("pick-folder");try{const a=await W.pickFolderPath("Pick a folder for this team");a.ok&&a.path&&c(a.path)}finally{o(null)}},fe=async()=>{if(G){o("delete-project");try{await W.enterpriseDeleteProject(G),p()}finally{o(null)}}},ge=async a=>{if(a){o("remove-folder");try{await W.enterpriseRemoveFolder(a),p()}finally{o(null)}}},we=async()=>{if(!(!O||!m.trim())){o("collaborate");try{await W.enterpriseAddTeamCollaborator(O,m.trim()),S(""),p()}finally{o(null)}}},Ce=async()=>{if(O){o("extract");try{const a=await W.enterpriseExtractTeam(O);p();const q=`AST extraction · ${a.folders_seen} folder(s) · ${a.files_seen} files (${a.files_extracted} new, ${a.files_cached} cached) · ${a.nodes_upserted} nodes · ${a.edges_upserted} edges`;window.alert(q)}catch(a){window.alert(`Extraction failed: ${String(a)}`)}finally{o(null)}}},_e=async()=>{if(l){o("share-folder");try{await W.localContextShareFolder({path:l,shared:!g}),p()}finally{o(null)}}};return e.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:440,background:"var(--bg)",borderLeft:"1px solid var(--border)",boxShadow:"-12px 0 30px rgba(20,16,10,0.06)",display:"flex",flexDirection:"column",zIndex:25,animation:"fadein 0.18s ease"},children:[e.jsxs("header",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.12em",color:"var(--ink3)",textTransform:"uppercase"},children:Ne(t.type)}),e.jsx("div",{style:{fontSize:16,fontWeight:500,color:"var(--ink)"},children:t.label})]}),e.jsx("button",{onClick:x,"aria-label":"Close drawer",style:{width:24,height:24,borderRadius:4,background:"var(--surface)",border:"1px solid var(--border)",color:"var(--ink2)"},children:"×"})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:14},children:[U?e.jsx(Pe,{node:t,sessions:E,shared:g,onToggleShare:_e,onOpenVault:()=>C(),onOpenSession:y,busy:h}):null,I?e.jsx(Oe,{node:t,onOpenSession:()=>y(t.id,je(t))}):null,L?e.jsx(Le,{projects:V,projectName:N,onProjectName:z,onCreateProject:D,confirmReset:R,onAskReset:()=>_(!0),onCancelReset:()=>_(!1),onConfirmReset:F,busy:h}):null,d?e.jsx(Ie,{teams:ne,teamName:M,onTeamName:T,onCreateTeam:J,confirmDelete:$,onAskDelete:()=>X(!0),onCancelDelete:()=>X(!1),onConfirmDelete:fe,busy:h}):null,P?e.jsx(Be,{node:t,repoMappings:oe,developerCount:se,developerJoinEvents:ue,collaboratingTeams:pe,collaboratorOptions:ae,collabTeamId:m,onCollabTeamId:S,onAddCollaborator:we,folderPath:k,folderLabel:w,gitUrl:i,onFolderPath:c,onFolderLabel:j,onGitUrl:v,onPickFolder:Y,onAddFolder:K,onAddGit:f,onExtract:Ce,onRemoveFolder:ge,onOpenVault:()=>{var a;return C(String(((a=t.meta)==null?void 0:a.team_id)||""))},isManager:u,viewer:s,busy:h}):null,Q?e.jsx($e,{node:t,onRemove:()=>{var a;return ge(String(((a=t.meta)==null?void 0:a.mapping_id)||""))},busy:h}):null]})]})}function Ne(t){return t==="global_team"?"GLOBAL TEAM":t==="folder"?"LOCAL FOLDER":t==="session"?"AGENT SESSION":t.toUpperCase()}function Pe({node:t,sessions:r,shared:s,onToggleShare:u,onOpenVault:x,onOpenSession:C,busy:y}){const p=Z(t),h=String(p.path||""),o=Number(p.active_session_count||0),k=typeof p.context_manager=="object"&&p.context_manager?p.context_manager:null;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx("button",{onClick:x,style:ce(!1),children:"OPEN CONTEXT →"}),e.jsxs("div",{children:[e.jsx(A,{children:"Folder"}),e.jsxs("div",{style:{marginTop:6,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"grid",gap:4},children:[e.jsx(B,{label:"path",value:h||t.label,mono:!0}),e.jsx(B,{label:"sessions",value:`${r.length}`}),e.jsx(B,{label:"active",value:`${o}`})]})]}),e.jsxs("div",{children:[e.jsx(A,{children:"Context manager"}),e.jsxs("div",{style:{marginTop:6,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"grid",gap:4},children:[e.jsx(B,{label:"owner",value:String((k==null?void 0:k.display_name)||`${t.label} Context Manager`)}),e.jsx(B,{label:"scope",value:String((k==null?void 0:k.folder_path)||h||t.label),mono:!0})]})]}),e.jsxs("div",{children:[e.jsx(A,{children:"Context sharing"}),e.jsx("button",{onClick:u,disabled:y==="share-folder",style:s?ce(y==="share-folder"):ee(y==="share-folder"),children:y==="share-folder"?"UPDATING...":s?"SHARING ENABLED":"SHARE THIS FOLDER"}),e.jsx(re,{children:"Shared folders exchange local context with the other folders you enable here."})]}),e.jsxs("div",{children:[e.jsxs(A,{children:["Agent sessions (",r.length,")"]}),r.length===0?e.jsx(re,{children:"No Claude Code or Codex sessions detected for this folder yet."}):e.jsx("div",{style:{display:"grid",gap:4,marginTop:6},children:r.map(c=>{const w=Z(c),j=ze(w.runtime);return e.jsxs("div",{style:{padding:"7px 10px",border:"1px solid var(--border)",borderLeft:`3px solid ${j}`,borderRadius:4,background:"var(--surface)",display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",gap:8,alignItems:"center"},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:12,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:c.label,children:c.label}),e.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:j},children:[String(w.runtime||"agent")," · ",String(w.state||"recent")]})]}),e.jsx("button",{onClick:()=>C(c.id,je(c)),style:We(j),children:"OPEN"})]},c.id)})})]})]})}function Oe({node:t,onOpenSession:r}){const s=Z(t);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx("button",{onClick:r,style:ce(!1),children:"OPEN SESSION TASK →"}),e.jsxs("div",{children:[e.jsx(A,{children:"Session"}),e.jsxs("div",{style:{marginTop:6,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"grid",gap:4},children:[e.jsx(B,{label:"runtime",value:String(s.runtime||"agent")}),e.jsx(B,{label:"state",value:String(s.state||"recent")}),s.model?e.jsx(B,{label:"model",value:String(s.model)}):null,s.cwd?e.jsx(B,{label:"folder",value:String(s.cwd),mono:!0}):null,s.updated_at?e.jsx(B,{label:"updated",value:String(s.updated_at)}):null]})]}),s.preview?e.jsxs("div",{children:[e.jsx(A,{children:"Preview"}),e.jsx("div",{style:{marginTop:6,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",color:"var(--ink2)",fontSize:12,lineHeight:1.5,whiteSpace:"pre-wrap"},children:String(s.preview)})]}):null]})}function Le({projects:t,projectName:r,onProjectName:s,onCreateProject:u,confirmReset:x,onAskReset:C,onCancelReset:y,onConfirmReset:p,busy:h}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{children:[e.jsx(A,{children:"Add a project"}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsx("input",{value:r,onChange:o=>s(o.target.value),placeholder:"e.g. Text_to_Speech",onKeyDown:o=>{o.key==="Enter"&&u()},style:te}),e.jsx("button",{onClick:u,disabled:h==="create-project"||!r.trim(),style:ee(h==="create-project"),children:"CREATE"})]})]}),e.jsxs("div",{children:[e.jsxs(A,{children:["Projects (",t.length,")"]}),t.length===0?e.jsx(re,{children:"No projects yet. Add one above."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:8},children:t.map(o=>e.jsxs("div",{style:{padding:"6px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12,color:"var(--ink)"},children:[e.jsx("span",{children:o.label}),e.jsx(xe,{label:"open",tone:"default"})]},o.id))})]}),e.jsxs("div",{style:{marginTop:8,paddingTop:14,borderTop:"1px solid var(--border)"},children:[e.jsx(A,{children:"Danger zone"}),x?e.jsxs("div",{style:{marginTop:8,padding:10,border:"1px solid var(--rose)",background:"var(--rose-dim)",borderRadius:4,fontSize:12,color:"var(--ink)"},children:[e.jsx("div",{style:{marginBottom:8},children:"This deletes projects, teams, folders, context items, proposals, and findings for this org. Memory engrams in the Dhee tier are not affected. Continue?"}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{onClick:p,disabled:h==="reset",style:ie,children:h==="reset"?"RESETTING…":"YES, RESET"}),e.jsx("button",{onClick:y,style:he,children:"CANCEL"})]})]}):e.jsx("button",{onClick:C,style:ie,children:"RESET WORKSPACE"})]})]})}function Ie({teams:t,teamName:r,onTeamName:s,onCreateTeam:u,confirmDelete:x,onAskDelete:C,onCancelDelete:y,onConfirmDelete:p,busy:h}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{children:[e.jsx(A,{children:"Add a team"}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsx("input",{value:r,onChange:o=>s(o.target.value),placeholder:"Backend, Frontend, Data, Mobile",onKeyDown:o=>{o.key==="Enter"&&u()},style:te}),e.jsx("button",{onClick:u,disabled:h==="create-team"||!r.trim(),style:ee(h==="create-team"),children:"ADD"})]})]}),e.jsxs("div",{children:[e.jsxs(A,{children:["Teams (",t.length,")"]}),t.length===0?e.jsx(re,{children:"No teams yet."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:8},children:t.map(o=>{const k=ke(Se(o));return e.jsxs("div",{style:{padding:"6px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsx("span",{style:{color:"var(--ink)",fontSize:12},children:o.label}),e.jsx(xe,{label:`${k.length} ${k.length===1?"repo":"repos"}`,tone:k.length?"green":"default"})]},o.id)})})]}),e.jsx("div",{style:{marginTop:8,paddingTop:14,borderTop:"1px solid var(--border)"},children:x?e.jsxs("div",{style:{marginTop:4,padding:10,border:"1px solid var(--rose)",background:"var(--rose-dim)",borderRadius:4,fontSize:12,color:"var(--ink)"},children:[e.jsx("div",{style:{marginBottom:8},children:"Deletes the project and all its teams + context. Continue?"}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{onClick:p,disabled:h==="delete-project",style:ie,children:h==="delete-project"?"DELETING…":"YES, DELETE"}),e.jsx("button",{onClick:y,style:he,children:"CANCEL"})]})]}):e.jsx("button",{onClick:C,style:ie,children:"DELETE PROJECT"})})]})}function Be({node:t,repoMappings:r,developerCount:s,developerJoinEvents:u,collaboratingTeams:x,collaboratorOptions:C,collabTeamId:y,onCollabTeamId:p,onAddCollaborator:h,folderPath:o,folderLabel:k,gitUrl:c,onFolderPath:w,onFolderLabel:j,onGitUrl:N,onPickFolder:z,onAddFolder:M,onAddGit:T,onExtract:i,onRemoveFolder:v,onOpenVault:m,busy:S}){const R=Z(t),_=R.context_manager,$=String(R.team_id||""),X=String(R.project_id||""),L=ke(r);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx("button",{onClick:m,style:ce(!1),children:"OPEN CONTEXT →"}),e.jsxs("div",{children:[e.jsx(A,{children:"Team details"}),e.jsxs("div",{style:{marginTop:6,display:"grid",gap:4,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",fontSize:12},children:[e.jsx(B,{label:"team",value:$||t.label}),X?e.jsx(B,{label:"project",value:X}):null,e.jsx(B,{label:"git access",value:`${s} dev${s===1?"":"s"} joined`})]})]}),e.jsxs("div",{children:[e.jsx(A,{children:"Manager"}),e.jsx("div",{style:{marginTop:6,padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",fontSize:12},children:_!=null&&_.display_name?e.jsxs(e.Fragment,{children:[e.jsx("div",{children:_.display_name}),e.jsx("div",{style:{fontSize:10,color:"var(--ink3)"},children:_.manager_id})]}):e.jsx("span",{style:{color:"var(--ink3)"},children:"no manager assigned"})})]}),e.jsxs("div",{children:[e.jsx(A,{children:"Add a local folder"}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsx("input",{value:o,onChange:d=>w(d.target.value),placeholder:"/Users/me/code/backend",onKeyDown:d=>{d.key==="Enter"&&M()},style:te}),e.jsx("button",{onClick:z,disabled:S==="pick-folder",style:he,title:"Browse",children:"BROWSE"})]}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:6},children:[e.jsx("input",{value:k,onChange:d=>j(d.target.value),placeholder:"Optional label",style:te}),e.jsx("button",{onClick:M,disabled:S==="add-folder"||!o.trim(),style:ee(S==="add-folder"),children:"ADD"})]})]}),e.jsxs("div",{children:[e.jsx(A,{children:"Add a git repo"}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsx("input",{value:c,onChange:d=>N(d.target.value),placeholder:"git@github.com:org/backend.git",onKeyDown:d=>{d.key==="Enter"&&T()},style:te}),e.jsx("button",{onClick:T,disabled:S==="add-git"||!c.trim(),style:ee(S==="add-git"),children:"ADD"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsxs(A,{children:["Git + local folders (",L.length,")"]}),e.jsx("button",{onClick:i,disabled:S==="extract"||L.length===0,title:"Run AST extraction for this team's local folders",style:ee(S==="extract"),children:S==="extract"?"INDEXING...":"INDEX TEAM"})]}),L.length===0?e.jsx(re,{children:"None mapped to this team."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:6},children:L.map(d=>{const P=String(d.mapping_id||d.local_path||d.repo_url);return e.jsxs("div",{style:{padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",display:"grid",gap:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[e.jsx("div",{style:{fontSize:12,color:"var(--ink)"},children:Ae(d)}),e.jsx("button",{onClick:()=>v(d.mapping_id),style:Ge,title:"Remove mapping","aria-label":"Remove mapping",children:"×"})]}),d.repo_url?e.jsx(B,{label:"repo",value:String(d.repo_url),mono:!0}):null,d.local_path?e.jsx(B,{label:"folder",value:String(d.local_path),mono:!0}):null]},P)})})]}),u.length?e.jsxs("div",{children:[e.jsx(A,{children:"Recent joins"}),e.jsx("div",{style:{display:"grid",gap:4,marginTop:6},children:u.slice(0,4).map((d,P)=>e.jsxs("div",{style:{padding:"6px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",fontSize:11,color:"var(--ink2)"},children:[e.jsx("div",{style:{fontFamily:"var(--mono)",overflow:"hidden",textOverflow:"ellipsis"},children:d.repo_root||"workspace"}),e.jsxs("div",{style:{color:"var(--ink3)",marginTop:2},children:[d.role||"developer"," - ",d.received_at||"recent"]})]},`${d.repo_root||"join"}-${P}`))})]}):null,e.jsxs("div",{children:[e.jsx(A,{children:"Collaborate teams"}),x.length===0?e.jsx(re,{children:"No team context shares yet."}):e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:6},children:x.map(d=>e.jsx(xe,{label:String(d.name||d.team_id),tone:"default"},String(d.team_id||d.name)))}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[e.jsxs("select",{value:y,onChange:d=>p(d.target.value),style:te,children:[e.jsx("option",{value:"",children:"Select team"}),C.map(d=>{var Q;const P=String(((Q=d.meta)==null?void 0:Q.team_id)||"");return e.jsx("option",{value:P,children:d.label},d.id)})]}),e.jsx("button",{onClick:h,disabled:S==="collaborate"||!y,style:ee(S==="collaborate"),children:"ADD"})]})]})]})}function $e({node:t,onRemove:r,busy:s}){const u=t.meta||{};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx(A,{children:"Folder / path"}),e.jsx("div",{style:{padding:"8px 10px",border:"1px solid var(--border)",borderRadius:4,background:"var(--surface)",fontFamily:"var(--mono)",fontSize:11,color:"var(--ink2)",wordBreak:"break-all"},children:u.local_path||u.repo_url||t.label}),e.jsx("button",{onClick:r,disabled:s==="remove-folder",style:ie,children:s==="remove-folder"?"REMOVING…":"REMOVE"})]})}function B({label:t,value:r,mono:s=!1}){return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"82px minmax(0, 1fr)",gap:8,alignItems:"baseline"},children:[e.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",textTransform:"uppercase"},children:t}),e.jsx("span",{title:r,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:s?"var(--mono)":void 0,fontSize:s?10:12,color:"var(--ink2)"},children:r})]})}function re({children:t}){return e.jsx("div",{style:{fontSize:11,color:"var(--ink3)",marginTop:6},children:t})}function xe({label:t,tone:r="default"}){const u={default:{bg:"var(--surface)",fg:"var(--ink2)"},green:{bg:"var(--green-dim)",fg:"var(--green)"},indigo:{bg:"var(--indigo-dim)",fg:"var(--indigo)"},rose:{bg:"var(--rose-dim)",fg:"var(--rose)"},accent:{bg:"var(--accent-dim)",fg:"var(--accent)"}}[r];return e.jsx("span",{style:{display:"inline-flex",padding:"2px 7px",borderRadius:3,background:u.bg,color:u.fg,fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.04em"},children:t})}const te={flex:1,fontFamily:"var(--mono)",fontSize:11,padding:"6px 8px",background:"var(--surface)",border:"1px solid var(--border)",borderRadius:3,color:"var(--ink)"};function ee(t){return{fontFamily:"var(--mono)",fontSize:10,padding:"5px 12px",background:t?"var(--surface)":"var(--accent-dim)",color:"var(--accent)",border:"1px solid var(--accent)",borderRadius:3,cursor:t?"wait":"pointer"}}function ce(t){return{fontFamily:"var(--mono)",fontSize:11,padding:"8px 12px",background:t?"var(--surface)":"var(--accent-dim)",color:"var(--accent)",border:"1px solid var(--accent)",borderRadius:4,textAlign:"center",cursor:t?"wait":"pointer"}}function We(t){return{fontFamily:"var(--mono)",fontSize:9,padding:"5px 8px",background:"white",color:t,border:`1px solid ${t}`,borderRadius:3,cursor:"pointer",whiteSpace:"nowrap"}}const he={fontFamily:"var(--mono)",fontSize:10,padding:"5px 10px",background:"var(--surface)",color:"var(--ink2)",border:"1px solid var(--border)",borderRadius:3},ie={fontFamily:"var(--mono)",fontSize:10,padding:"5px 12px",background:"var(--rose-dim)",color:"var(--rose)",border:"1px solid var(--rose)",borderRadius:3},Ge={width:22,height:22,borderRadius:3,background:"var(--surface)",color:"var(--ink2)",border:"1px solid var(--border)",fontSize:12,lineHeight:1};function Ye(t,r={}){const s=r.siblingGap??24,u=r.levelGap??100,x=new Map;for(const i of t)x.set(i.id,{id:i.id,parent:i.parent,children:[],width:i.width,height:i.height,depth:i.depth,subtreeWidth:i.width,x:0,y:0});const C=[];for(const i of x.values())i.parent&&x.has(i.parent)?x.get(i.parent).children.push(i.id):C.push(i);const y=i=>{const v=x.get(i);if(!v.children.length)return v.subtreeWidth=v.width,v.subtreeWidth;let m=0;for(const S of v.children)m+=y(S);return m+=s*(v.children.length-1),v.subtreeWidth=Math.max(v.width,m),v.subtreeWidth},p=new Map;for(const i of x.values())p.set(i.depth,Math.max(p.get(i.depth)||0,i.height));const h=new Map;let o=0;const k=Math.max(0,...Array.from(p.keys()));for(let i=0;i<=k;i+=1)h.set(i,o),o+=(p.get(i)||0)+u;const c=(i,v)=>{const m=x.get(i);if(m.y=h.get(m.depth)||0,!m.children.length){m.x=v+m.width/2;return}let S=v,R=[];for(const _ of m.children){const $=x.get(_);c(_,S),R.push($.x),S+=$.subtreeWidth+s}if(R.length===0)m.x=v+m.width/2;else{const _=Math.min(...R),$=Math.max(...R);m.x=(_+$)/2}};let w=0;for(const i of C)y(i.id),c(i.id,w),w+=i.subtreeWidth+s*2;let j=1/0,N=1/0,z=-1/0,M=-1/0;const T=[];for(const i of x.values()){const v=i.width/2;j=Math.min(j,i.x-v),z=Math.max(z,i.x+v),N=Math.min(N,i.y),M=Math.max(M,i.y+i.height),T.push({id:i.id,parent:i.parent,width:i.width,height:i.height,depth:i.depth,x:i.x,y:i.y})}return Number.isFinite(j)||(j=0,N=0,z=0,M=0),{nodes:T,bounds:{minX:j,minY:N,maxX:z,maxY:M}}}const le={workspace:{w:280,h:76},project:{w:200,h:64},team:{w:180,h:56},global_team:{w:200,h:60},repo:{w:180,h:52},folder:{w:230,h:70},session:{w:190,h:58},integration:{w:150,h:46},default:{w:160,h:50}};function Xe(t){return le[t]?le[t]:t.startsWith("integration:")?le.integration:le.default}function me(t){return String((t.meta||{}).runtime||"").toLowerCase()}function He(t){return t==="codex"?"var(--indigo)":t==="claude-code"||t==="claude"?"var(--accent)":"var(--ink3)"}function Ke(t){return t==="codex"?"var(--indigo-dim)":t==="claude-code"||t==="claude"?"var(--accent-dim)":"var(--surface)"}function Ue(t,r){return r==="needs_work"?"var(--rose)":r==="watch"?"var(--accent)":t==="folder"?"var(--green)":t==="session"?"var(--accent)":t==="workspace"?"var(--ink2)":t==="project"?"var(--accent)":t==="team"?"var(--green)":t==="global_team"?"var(--indigo)":t==="repo"?"var(--green)":t==="integration:slack"?"var(--indigo)":t==="integration:docs"?"var(--accent)":t==="integration:email"?"var(--rose)":t==="integration:git"?"var(--green)":"var(--ink3)"}function Ve(t){return t.health==="needs_work"?"var(--rose)":t.type==="session"?He(me(t)):Ue(t.type,t.health)}function Je(t){return t==="workspace"?"white":t==="folder"?"var(--green-dim)":t==="session"?"var(--surface)":t==="project"?"var(--accent-dim)":t==="team"||t==="global_team"?"var(--surface)":t==="repo"?"var(--green-dim)":(t.startsWith("integration:"),"var(--surface)")}function qe(t){return t.type==="session"?Ke(me(t)):Je(t.type)}function Qe({graph:t,viewer:r,onOpenVault:s,onOpenSession:u,onChanged:x}){var ae;const C=b.useRef(null),y=b.useRef({down:!1,lastX:0,lastY:0}),p=b.useRef(!1),h=b.useRef(null),[o,k]=b.useState({w:1200,h:700}),[c,w]=b.useState(0),[j,N]=b.useState(0),[z,M]=b.useState(1),[T,i]=b.useState(null),[v,m]=b.useState(null),[S,R]=b.useState(null),[_,$]=b.useState(""),[X,L]=b.useState(null),d=((ae=t.raw)==null?void 0:ae.mode)==="local_context",P=async()=>{R("add-folder"),L(null);try{const n=await W.pickFolderPath("Choose a folder to share context");n.ok&&n.path&&(await W.localContextAddFolder({path:n.path,shared:!0}),x())}catch(n){L(String(n))}finally{R(null)}},Q=async()=>{const n=_.trim();if(!(!n||S)){R("manual-folder"),L(null);try{await W.localContextAddFolder({path:n,shared:!0}),$(""),x()}catch(l){L(String(l))}finally{R(null)}}};b.useEffect(()=>{const n=C.current;if(!n)return;const l=()=>{const E=n.getBoundingClientRect(),F={w:Math.round(E.width),h:Math.round(E.height)};k(D=>D.w===F.w&&D.h===F.h?D:F)};l();const g=new ResizeObserver(l);return g.observe(n),()=>g.disconnect()},[]);const{positions:U,bounds:I}=b.useMemo(()=>{const n=new Map;for(const f of t.edges){if(f.kind!=="contains"&&f.kind!=="uses")continue;const Y=n.get(f.source)||[];Y.push(f.target),n.set(f.source,Y)}const l=new Map;for(const f of t.edges)f.kind!=="contains"&&f.kind!=="uses"||l.set(f.target,f.source);const g=new Map,F=t.nodes.filter(f=>f.type==="workspace"||!l.has(f.id)).map(f=>f.id).map(f=>({id:f,depth:0}));for(;F.length;){const{id:f,depth:Y}=F.shift();if(!g.has(f)){g.set(f,Y);for(const fe of n.get(f)||[])F.push({id:fe,depth:Y+1})}}const D=t.nodes.map(f=>{const Y=Xe(f.type);return{id:f.id,parent:l.get(f.id)||null,width:Y.w,height:Y.h,depth:g.get(f.id)??0}}),J=Ye(D,{siblingGap:24,levelGap:90}),K=new Map;for(const f of J.nodes)K.set(f.id,{x:f.x,y:f.y,w:f.width,h:f.height});return{positions:K,bounds:J.bounds}},[t.nodes,t.edges]),V=b.useMemo(()=>JSON.stringify({nodes:t.nodes.map(n=>[n.id,n.type,n.label,n.health||""]),edges:t.edges.map(n=>[n.source,n.target,n.kind])}),[t.nodes,t.edges]),G=()=>{const n=I.maxX-I.minX,l=I.maxY-I.minY;if(n<=0||l<=0||o.w<=0||o.h<=0)return!1;const g=80,E=(o.w-g*2)/n,F=(o.h-g*2)/l,D=Math.min(1.2,Math.max(.45,Math.min(E,F)));return M(D),w(o.w/2-(I.minX+I.maxX)/2*D),N(g-I.minY*D),!0};b.useEffect(()=>{const n=`${o.w}x${o.h}`,l=h.current,g=(l==null?void 0:l.structure)!==V,E=(l==null?void 0:l.size)!==n;if(!(!g&&!E)){if(l&&p.current){h.current={structure:V,size:n};return}G()&&(h.current={structure:V,size:n})}},[I.minX,I.maxX,I.minY,I.maxY,o.w,o.h,V]);const ne=n=>{var J;n.preventDefault(),p.current=!0;const l=Math.exp(-n.deltaY*.001),g=Math.min(2.5,Math.max(.3,z*l)),E=(J=C.current)==null?void 0:J.getBoundingClientRect();if(!E){M(g);return}const F=n.clientX-E.left,D=n.clientY-E.top;w(K=>F-(F-K)/z*g),N(K=>D-(D-K)/z*g),M(g)},oe=n=>{y.current={down:!0,lastX:n.clientX,lastY:n.clientY}},H=n=>{const l=y.current;l.down&&(p.current=!0,w(g=>g+(n.clientX-l.lastX)),N(g=>g+(n.clientY-l.lastY)),y.current={down:!0,lastX:n.clientX,lastY:n.clientY})},O=()=>{y.current.down=!1},se=()=>{p.current=!1,G()&&(h.current={structure:V,size:`${o.w}x${o.h}`})},ue=t.totals.projects>0||t.totals.teams>0||t.totals.repos>0||(t.totals.folders||0)>0||(t.totals.sessions||0)>0||t.totals.context_items>0;if(!t.live||!ue)return e.jsxs("div",{className:"dhee-canvas-bg",style:{position:"relative",flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(ye,{onOpenContext:()=>s()}),e.jsx(rt,{viewer:r,busy:S,onAddFolder:P,manualPath:_,onManualPathChange:$,onAddManualFolder:Q,error:X})]});const pe=(r==null?void 0:r.role)==="manager"||(r==null?void 0:r.role)==="admin";return e.jsxs("div",{ref:C,onWheel:ne,onMouseDown:oe,onMouseMove:H,onMouseUp:O,onMouseLeave:O,onDoubleClick:se,className:"dhee-canvas-bg",style:{position:"relative",flex:1,cursor:y.current.down?"grabbing":"grab",overflow:"hidden"},children:[e.jsx(ye,{onOpenContext:()=>s()}),e.jsx("svg",{width:o.w,height:o.h,style:{display:"block",userSelect:"none"},children:e.jsxs("g",{transform:`translate(${c},${j}) scale(${z})`,children:[t.edges.map((n,l)=>{const g=U.get(n.source),E=U.get(n.target);if(!g||!E)return null;const F=g.x,D=g.y+g.h/2,J=E.x,K=E.y-E.h/2,f=(D+K)/2,Y=v&&(n.source===v||n.target===v);return e.jsx("path",{d:`M ${F},${D} C ${F},${f} ${J},${f} ${J},${K}`,className:Y?"dhee-edge-path dhee-edge-path--highlight":v?"dhee-edge-path dhee-edge-path--dim":"dhee-edge-path"},`${n.source}-${n.target}-${l}`)}),t.nodes.map(n=>{const l=U.get(n.id);if(!l)return null;const g=Ve(n),E=qe(n),F=(T==null?void 0:T.id)===n.id;return e.jsxs("g",{onMouseEnter:()=>m(n.id),onMouseLeave:()=>m(null),onClick:D=>{D.stopPropagation(),i(n)},style:{cursor:"pointer"},children:[e.jsx("rect",{x:l.x-l.w/2,y:l.y,width:l.w,height:l.h,rx:8,ry:8,fill:E,stroke:g,strokeWidth:F?2.4:n.type==="workspace"?1.6:1.2}),n.type==="workspace"?e.jsx("text",{x:l.x,y:l.y+24,textAnchor:"middle",fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.12em",fill:"var(--ink3)",pointerEvents:"none",children:"WORKSPACE"}):null,e.jsx("text",{x:l.x,y:n.type==="workspace"?l.y+50:l.y+l.h/2+4,textAnchor:"middle",fontFamily:"var(--font)",fontSize:n.type==="workspace"?16:12,fontWeight:n.type==="workspace"?500:400,fill:"var(--ink)",pointerEvents:"none",children:et(n.label,n.type==="workspace"?30:22)}),n.type!=="workspace"?e.jsx("text",{x:l.x,y:l.y+16,textAnchor:"middle",fontFamily:"var(--mono)",fontSize:8,letterSpacing:"0.1em",fill:"var(--ink3)",pointerEvents:"none",children:Ze(n)}):null]},n.id)})]})}),d?e.jsxs("div",{className:"repo-brain-local-controls",style:{position:"absolute",left:12,top:12,display:"flex",gap:8,alignItems:"center",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,padding:"6px 8px",boxShadow:"0 4px 14px rgba(20,16,10,0.05)"},children:[e.jsx("button",{onClick:P,disabled:S==="add-folder",style:{fontFamily:"var(--mono)",fontSize:10,border:"1px solid var(--accent)",color:"var(--accent)",background:"var(--accent-dim)",borderRadius:4,padding:"5px 8px",cursor:S==="add-folder"?"wait":"pointer"},children:S==="add-folder"?"ADDING...":"ADD FOLDER"}),e.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"local context sharing"})]}):null,e.jsx(tt,{graph:t}),T?e.jsx(Me,{node:T,graph:t,viewer:r,isManager:pe,onClose:()=>i(null),onOpenVault:s,onOpenSession:u,onChanged:()=>{i(null),x()}}):null]})}function Ze(t){const r=t.type;if(r==="session"){const s=me(t);if(s==="codex")return"CODEX";if(s==="claude-code"||s==="claude")return"CLAUDE CODE"}return r.startsWith("integration:")?r.split(":")[1].toUpperCase():r.toUpperCase()}function et(t,r){return t?t.length<=r?t:t.slice(0,r-1)+"…":""}function tt({graph:t}){var r;return((r=t.raw)==null?void 0:r.mode)==="local_context"?e.jsxs("div",{style:{position:"absolute",left:12,bottom:12,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,padding:"5px 9px",letterSpacing:"0.04em"},children:[t.totals.folders||t.totals.repos," folders ·"," ",t.totals.sessions||t.totals.teams," sessions ·"," ",t.totals.shared_folders||0," shared"]}):e.jsxs("div",{style:{position:"absolute",left:12,bottom:12,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,padding:"5px 9px",letterSpacing:"0.04em"},children:[t.totals.projects," projects · ",t.totals.teams," teams ·"," ",t.totals.repos," folders · ",t.totals.pending_proposals," pending"]})}function rt({viewer:t,busy:r,onAddFolder:s,manualPath:u,onManualPathChange:x,onAddManualFolder:C,error:y}){return e.jsx("div",{className:"dhee-canvas-bg",style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:32},children:e.jsxs("div",{style:{width:"min(640px, calc(100vw - 64px))",padding:24,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 6px 18px rgba(20,16,10,0.05)",animation:"dhee-card-in 0.22s ease"},children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.12em",color:"var(--ink3)",textTransform:"uppercase",marginBottom:6},children:t!=null&&t.user_id?`local · ${t.user_id}`:"local context"}),e.jsx("div",{style:{fontSize:18,fontWeight:500,color:"var(--ink)",marginBottom:6},children:"No local agent folders yet"}),e.jsx("div",{style:{fontSize:12,color:"var(--ink2)",lineHeight:1.5,marginBottom:14},children:"Dhee will show local Claude Code and Codex sessions grouped by folder. Add any folder you want to share context with the rest of your local agent folders."}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.jsx("button",{onClick:s,disabled:r==="add-folder",style:{fontFamily:"var(--mono)",fontSize:11,padding:"8px 14px",background:r==="add-folder"?"var(--surface)":"var(--accent-dim)",color:"var(--accent)",border:"1px solid var(--accent)",borderRadius:4,cursor:r==="add-folder"?"wait":"pointer"},children:r==="add-folder"?"ADDING...":"ADD FOLDER"})}),e.jsxs("div",{style:{marginTop:14,borderTop:"1px solid var(--border)",paddingTop:14,display:"grid",gap:8},children:[e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"REPO PATH"}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{value:u,onChange:p=>x(p.target.value),onKeyDown:p=>{p.key==="Enter"&&C()},placeholder:"/Users/me/work/repo",style:{flex:1,minWidth:0,border:"1px solid var(--border)",borderRadius:4,padding:"9px 10px",background:"white",fontFamily:"var(--mono)",fontSize:11,color:"var(--ink)"}}),e.jsx("button",{onClick:()=>void C(),disabled:!u.trim()||r==="manual-folder",style:{fontFamily:"var(--mono)",fontSize:11,padding:"8px 12px",background:"white",color:"var(--accent)",border:"1px solid var(--border)",borderRadius:4,opacity:!u.trim()||r==="manual-folder"?.55:1,cursor:!u.trim()||r==="manual-folder"?"not-allowed":"pointer"},children:r==="manual-folder"?"LINKING...":"LINK PATH"})]}),e.jsx("code",{style:{display:"block",border:"1px solid var(--border)",background:"var(--surface)",borderRadius:4,padding:"8px 9px",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink2)",overflowWrap:"anywhere"},children:"dhee onboard --root ."}),y?e.jsx("div",{style:{fontSize:11,color:"var(--rose)"},children:y}):null]})]})})}const de={live:!1,org_id:"local",nodes:[],edges:[],totals:{projects:0,teams:0,repos:0,context_items:0,pending_proposals:0,folders:0,sessions:0,shared_folders:0},raw:{mode:"local_context",folders:[],sessions:[],shared_folder_paths:[],context_index:[],pending_proposals:[],context_managers_by_team:{}}};function nt(t){var r;return t?{...de,...t,org_id:t.org_id||"local",nodes:t.nodes||[],edges:t.edges||[],totals:{...de.totals,...t.totals||{}},raw:{...de.raw,...t.raw||{},mode:((r=t.raw)==null?void 0:r.mode)||"local_context"}}:de}function st(t){return e.jsx(Qe,{graph:nt(t.orgGraph),viewer:t.viewer||null,tweaks:t.tweaks,onOpenVault:t.onOpenVault||(()=>{}),onOpenSession:t.onSelectSession,onChanged:t.onOrgGraphChanged||(()=>{})})}export{st as CanvasView}; diff --git a/dhee/ui/web/dist/assets/index-BKI2JxEf.js b/dhee/ui/web/dist/assets/index-BKI2JxEf.js deleted file mode 100644 index 2ce244b..0000000 --- a/dhee/ui/web/dist/assets/index-BKI2JxEf.js +++ /dev/null @@ -1,51 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const s of l.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function kp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ju={exports:{}},Mo={},Xu={exports:{}},ue={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var xi=Symbol.for("react.element"),jp=Symbol.for("react.portal"),wp=Symbol.for("react.fragment"),Cp=Symbol.for("react.strict_mode"),bp=Symbol.for("react.profiler"),_p=Symbol.for("react.provider"),Ep=Symbol.for("react.context"),Tp=Symbol.for("react.forward_ref"),zp=Symbol.for("react.suspense"),Rp=Symbol.for("react.memo"),Np=Symbol.for("react.lazy"),fd=Symbol.iterator;function Pp(e){return e===null||typeof e!="object"?null:(e=fd&&e[fd]||e["@@iterator"],typeof e=="function"?e:null)}var qu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Zu=Object.assign,Gu={};function jr(e,t,n){this.props=e,this.context=t,this.refs=Gu,this.updater=n||qu}jr.prototype.isReactComponent={};jr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};jr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ec(){}ec.prototype=jr.prototype;function Ns(e,t,n){this.props=e,this.context=t,this.refs=Gu,this.updater=n||qu}var Ps=Ns.prototype=new ec;Ps.constructor=Ns;Zu(Ps,jr.prototype);Ps.isPureReactComponent=!0;var pd=Array.isArray,tc=Object.prototype.hasOwnProperty,Fs={current:null},nc={key:!0,ref:!0,__self:!0,__source:!0};function rc(e,t,n){var r,o={},l=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(l=""+t.key),t)tc.call(t,r)&&!nc.hasOwnProperty(r)&&(o[r]=t[r]);var a=arguments.length-2;if(a===1)o.children=n;else if(1>>1,ie=C[ee];if(0>>1;eeo(se,W))meo($,se)?(C[ee]=$,C[me]=W,ee=me):(C[ee]=se,C[fe]=W,ee=fe);else if(meo($,W))C[ee]=$,C[me]=W,ee=me;else break e}}return A}function o(C,A){var W=C.sortIndex-A.sortIndex;return W!==0?W:C.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var s=Date,a=s.now();e.unstable_now=function(){return s.now()-a}}var d=[],c=[],g=1,m=null,x=3,S=!1,E=!1,T=!1,H=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,u=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function f(C){for(var A=n(c);A!==null;){if(A.callback===null)r(c);else if(A.startTime<=C)r(c),A.sortIndex=A.expirationTime,t(d,A);else break;A=n(c)}}function p(C){if(T=!1,f(C),!E)if(n(d)!==null)E=!0,V(j);else{var A=n(c);A!==null&&ye(p,A.startTime-C)}}function j(C,A){E=!1,T&&(T=!1,h(z),z=-1),S=!0;var W=x;try{for(f(A),m=n(d);m!==null&&(!(m.expirationTime>A)||C&&!J());){var ee=m.callback;if(typeof ee=="function"){m.callback=null,x=m.priorityLevel;var ie=ee(m.expirationTime<=A);A=e.unstable_now(),typeof ie=="function"?m.callback=ie:m===n(d)&&r(d),f(A)}else r(d);m=n(d)}if(m!==null)var D=!0;else{var fe=n(c);fe!==null&&ye(p,fe.startTime-A),D=!1}return D}finally{m=null,x=W,S=!1}}var _=!1,P=null,z=-1,Q=5,R=-1;function J(){return!(e.unstable_now()-RC||125ee?(C.sortIndex=W,t(c,C),n(d)===null&&C===n(c)&&(T?(h(z),z=-1):T=!0,ye(p,W-ee))):(C.sortIndex=ie,t(d,C),E||S||(E=!0,V(j))),C},e.unstable_shouldYield=J,e.unstable_wrapCallback=function(C){var A=x;return function(){var W=x;x=A;try{return C.apply(this,arguments)}finally{x=W}}}})(ac);sc.exports=ac;var Hp=sc.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Vp=v,vt=Hp;function L(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ml=Object.prototype.hasOwnProperty,Kp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,hd={},gd={};function Qp(e){return Ml.call(gd,e)?!0:Ml.call(hd,e)?!1:Kp.test(e)?gd[e]=!0:(hd[e]=!0,!1)}function Yp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Jp(e,t,n,r){if(t===null||typeof t>"u"||Yp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function lt(e,t,n,r,o,l,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=l,this.removeEmptyString=s}var Xe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Xe[e]=new lt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Xe[t]=new lt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Xe[e]=new lt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Xe[e]=new lt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Xe[e]=new lt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Xe[e]=new lt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Xe[e]=new lt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Xe[e]=new lt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Xe[e]=new lt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Os=/[\-:]([a-z])/g;function $s(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Os,$s);Xe[t]=new lt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Os,$s);Xe[t]=new lt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Os,$s);Xe[t]=new lt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Xe[e]=new lt(e,1,!1,e.toLowerCase(),null,!1,!1)});Xe.xlinkHref=new lt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Xe[e]=new lt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ds(e,t,n,r){var o=Xe.hasOwnProperty(t)?Xe[t]:null;(o!==null?o.type!==0:r||!(2a||o[s]!==l[a]){var d=` -`+o[s].replace(" at new "," at ");return e.displayName&&d.includes("")&&(d=d.replace("",e.displayName)),d}while(1<=s&&0<=a);break}}}finally{il=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Ir(e):""}function Xp(e){switch(e.tag){case 5:return Ir(e.type);case 16:return Ir("Lazy");case 13:return Ir("Suspense");case 19:return Ir("SuspenseList");case 0:case 2:case 15:return e=ol(e.type,!1),e;case 11:return e=ol(e.type.render,!1),e;case 1:return e=ol(e.type,!0),e;default:return""}}function Ul(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Zn:return"Fragment";case qn:return"Portal";case Il:return"Profiler";case Ms:return"StrictMode";case Bl:return"Suspense";case Al:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case cc:return(e.displayName||"Context")+".Consumer";case uc:return(e._context.displayName||"Context")+".Provider";case Is:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Bs:return t=e.displayName||null,t!==null?t:Ul(e.type)||"Memo";case en:t=e._payload,e=e._init;try{return Ul(e(t))}catch{}}return null}function qp(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ul(t);case 8:return t===Ms?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function yn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function pc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Zp(e){var t=pc(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,l=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(s){r=""+s,l.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function zi(e){e._valueTracker||(e._valueTracker=Zp(e))}function mc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=pc(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function fo(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Wl(e,t){var n=t.checked;return Ne({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function yd(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=yn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function hc(e,t){t=t.checked,t!=null&&Ds(e,"checked",t,!1)}function Hl(e,t){hc(e,t);var n=yn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Vl(e,t.type,n):t.hasOwnProperty("defaultValue")&&Vl(e,t.type,yn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function xd(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Vl(e,t,n){(t!=="number"||fo(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Br=Array.isArray;function dr(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o"+t.valueOf().toString()+"",t=Ri.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ri(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Kr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Gp=["Webkit","ms","Moz","O"];Object.keys(Kr).forEach(function(e){Gp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Kr[t]=Kr[e]})});function xc(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Kr.hasOwnProperty(e)&&Kr[e]?(""+t).trim():t+"px"}function Sc(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=xc(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var em=Ne({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Yl(e,t){if(t){if(em[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(L(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(L(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(L(61))}if(t.style!=null&&typeof t.style!="object")throw Error(L(62))}}function Jl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Xl=null;function As(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ql=null,ur=null,cr=null;function jd(e){if(e=ji(e)){if(typeof ql!="function")throw Error(L(280));var t=e.stateNode;t&&(t=Wo(t),ql(e.stateNode,e.type,t))}}function kc(e){ur?cr?cr.push(e):cr=[e]:ur=e}function jc(){if(ur){var e=ur,t=cr;if(cr=ur=null,jd(e),t)for(e=0;e>>=0,e===0?32:31-(cm(e)/fm|0)|0}var Ni=64,Pi=4194304;function Ar(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function go(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,l=e.pingedLanes,s=n&268435455;if(s!==0){var a=s&~o;a!==0?r=Ar(a):(l&=s,l!==0&&(r=Ar(l)))}else s=n&~o,s!==0?r=Ar(s):l!==0&&(r=Ar(l));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,l=t&-t,o>=l||o===16&&(l&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Si(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Rt(t),e[t]=n}function gm(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Yr),Nd=" ",Pd=!1;function Uc(e,t){switch(e){case"keyup":return Hm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Gn=!1;function Km(e,t){switch(e){case"compositionend":return Wc(t);case"keypress":return t.which!==32?null:(Pd=!0,Nd);case"textInput":return e=t.data,e===Nd&&Pd?null:e;default:return null}}function Qm(e,t){if(Gn)return e==="compositionend"||!Js&&Uc(e,t)?(e=Bc(),Gi=Ks=ln=null,Gn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=$d(n)}}function Qc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Qc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Yc(){for(var e=window,t=fo();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=fo(e.document)}return t}function Xs(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function nh(e){var t=Yc(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Qc(n.ownerDocument.documentElement,n)){if(r!==null&&Xs(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,l=Math.min(r.start,o);r=r.end===void 0?l:Math.min(r.end,o),!e.extend&&l>r&&(o=r,r=l,l=o),o=Dd(n,l);var s=Dd(n,r);o&&s&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),l>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,er=null,rs=null,Xr=null,is=!1;function Md(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;is||er==null||er!==fo(r)||(r=er,"selectionStart"in r&&Xs(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Xr&&di(Xr,r)||(Xr=r,r=xo(rs,"onSelect"),0rr||(e.current=us[rr],us[rr]=null,rr--)}function ke(e,t){rr++,us[rr]=e.current,e.current=t}var xn={},nt=kn(xn),ut=kn(!1),In=xn;function gr(e,t){var n=e.type.contextTypes;if(!n)return xn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},l;for(l in n)o[l]=t[l];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function ct(e){return e=e.childContextTypes,e!=null}function ko(){Ce(ut),Ce(nt)}function Vd(e,t,n){if(nt.current!==xn)throw Error(L(168));ke(nt,t),ke(ut,n)}function rf(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(L(108,qp(e)||"Unknown",o));return Ne({},n,r)}function jo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xn,In=nt.current,ke(nt,e),ke(ut,ut.current),!0}function Kd(e,t,n){var r=e.stateNode;if(!r)throw Error(L(169));n?(e=rf(e,t,In),r.__reactInternalMemoizedMergedChildContext=e,Ce(ut),Ce(nt),ke(nt,e)):Ce(ut),ke(ut,n)}var Ht=null,Ho=!1,xl=!1;function of(e){Ht===null?Ht=[e]:Ht.push(e)}function mh(e){Ho=!0,of(e)}function jn(){if(!xl&&Ht!==null){xl=!0;var e=0,t=ge;try{var n=Ht;for(ge=1;e>=s,o-=s,Vt=1<<32-Rt(t)+o|n<z?(Q=P,P=null):Q=P.sibling;var R=x(h,P,f[z],p);if(R===null){P===null&&(P=Q);break}e&&P&&R.alternate===null&&t(h,P),u=l(R,u,z),_===null?j=R:_.sibling=R,_=R,P=Q}if(z===f.length)return n(h,P),be&&zn(h,z),j;if(P===null){for(;zz?(Q=P,P=null):Q=P.sibling;var J=x(h,P,R.value,p);if(J===null){P===null&&(P=Q);break}e&&P&&J.alternate===null&&t(h,P),u=l(J,u,z),_===null?j=J:_.sibling=J,_=J,P=Q}if(R.done)return n(h,P),be&&zn(h,z),j;if(P===null){for(;!R.done;z++,R=f.next())R=m(h,R.value,p),R!==null&&(u=l(R,u,z),_===null?j=R:_.sibling=R,_=R);return be&&zn(h,z),j}for(P=r(h,P);!R.done;z++,R=f.next())R=S(P,h,z,R.value,p),R!==null&&(e&&R.alternate!==null&&P.delete(R.key===null?z:R.key),u=l(R,u,z),_===null?j=R:_.sibling=R,_=R);return e&&P.forEach(function(X){return t(h,X)}),be&&zn(h,z),j}function H(h,u,f,p){if(typeof f=="object"&&f!==null&&f.type===Zn&&f.key===null&&(f=f.props.children),typeof f=="object"&&f!==null){switch(f.$$typeof){case Ti:e:{for(var j=f.key,_=u;_!==null;){if(_.key===j){if(j=f.type,j===Zn){if(_.tag===7){n(h,_.sibling),u=o(_,f.props.children),u.return=h,h=u;break e}}else if(_.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===en&&Jd(j)===_.type){n(h,_.sibling),u=o(_,f.props),u.ref=Nr(h,_,f),u.return=h,h=u;break e}n(h,_);break}else t(h,_);_=_.sibling}f.type===Zn?(u=Dn(f.props.children,h.mode,p,f.key),u.return=h,h=u):(p=so(f.type,f.key,f.props,null,h.mode,p),p.ref=Nr(h,u,f),p.return=h,h=p)}return s(h);case qn:e:{for(_=f.key;u!==null;){if(u.key===_)if(u.tag===4&&u.stateNode.containerInfo===f.containerInfo&&u.stateNode.implementation===f.implementation){n(h,u.sibling),u=o(u,f.children||[]),u.return=h,h=u;break e}else{n(h,u);break}else t(h,u);u=u.sibling}u=El(f,h.mode,p),u.return=h,h=u}return s(h);case en:return _=f._init,H(h,u,_(f._payload),p)}if(Br(f))return E(h,u,f,p);if(_r(f))return T(h,u,f,p);Ii(h,f)}return typeof f=="string"&&f!==""||typeof f=="number"?(f=""+f,u!==null&&u.tag===6?(n(h,u.sibling),u=o(u,f),u.return=h,h=u):(n(h,u),u=_l(f,h.mode,p),u.return=h,h=u),s(h)):n(h,u)}return H}var yr=df(!0),uf=df(!1),bo=kn(null),_o=null,lr=null,ea=null;function ta(){ea=lr=_o=null}function na(e){var t=bo.current;Ce(bo),e._currentValue=t}function ps(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function pr(e,t){_o=e,ea=lr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(dt=!0),e.firstContext=null)}function Ct(e){var t=e._currentValue;if(ea!==e)if(e={context:e,memoizedValue:t,next:null},lr===null){if(_o===null)throw Error(L(308));lr=e,_o.dependencies={lanes:0,firstContext:e}}else lr=lr.next=e;return t}var Fn=null;function ra(e){Fn===null?Fn=[e]:Fn.push(e)}function cf(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,ra(t)):(n.next=o.next,o.next=n),t.interleaved=n,Xt(e,r)}function Xt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var tn=!1;function ia(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ff(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Qt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function pn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,pe&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,Xt(e,n)}return o=r.interleaved,o===null?(t.next=t,ra(r)):(t.next=o.next,o.next=t),r.interleaved=t,Xt(e,n)}function to(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ws(e,n)}}function Xd(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var o=null,l=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};l===null?o=l=s:l=l.next=s,n=n.next}while(n!==null);l===null?o=l=t:l=l.next=t}else o=l=t;n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:l,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Eo(e,t,n,r){var o=e.updateQueue;tn=!1;var l=o.firstBaseUpdate,s=o.lastBaseUpdate,a=o.shared.pending;if(a!==null){o.shared.pending=null;var d=a,c=d.next;d.next=null,s===null?l=c:s.next=c,s=d;var g=e.alternate;g!==null&&(g=g.updateQueue,a=g.lastBaseUpdate,a!==s&&(a===null?g.firstBaseUpdate=c:a.next=c,g.lastBaseUpdate=d))}if(l!==null){var m=o.baseState;s=0,g=c=d=null,a=l;do{var x=a.lane,S=a.eventTime;if((r&x)===x){g!==null&&(g=g.next={eventTime:S,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var E=e,T=a;switch(x=t,S=n,T.tag){case 1:if(E=T.payload,typeof E=="function"){m=E.call(S,m,x);break e}m=E;break e;case 3:E.flags=E.flags&-65537|128;case 0:if(E=T.payload,x=typeof E=="function"?E.call(S,m,x):E,x==null)break e;m=Ne({},m,x);break e;case 2:tn=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,x=o.effects,x===null?o.effects=[a]:x.push(a))}else S={eventTime:S,lane:x,tag:a.tag,payload:a.payload,callback:a.callback,next:null},g===null?(c=g=S,d=m):g=g.next=S,s|=x;if(a=a.next,a===null){if(a=o.shared.pending,a===null)break;x=a,a=x.next,x.next=null,o.lastBaseUpdate=x,o.shared.pending=null}}while(!0);if(g===null&&(d=m),o.baseState=d,o.firstBaseUpdate=c,o.lastBaseUpdate=g,t=o.shared.interleaved,t!==null){o=t;do s|=o.lane,o=o.next;while(o!==t)}else l===null&&(o.shared.lanes=0);Un|=s,e.lanes=s,e.memoizedState=m}}function qd(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=kl.transition;kl.transition={};try{e(!1),t()}finally{ge=n,kl.transition=r}}function zf(){return bt().memoizedState}function yh(e,t,n){var r=hn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Rf(e))Nf(t,n);else if(n=cf(e,t,n,r),n!==null){var o=it();Nt(n,e,r,o),Pf(n,t,r)}}function xh(e,t,n){var r=hn(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rf(e))Nf(t,o);else{var l=e.alternate;if(e.lanes===0&&(l===null||l.lanes===0)&&(l=t.lastRenderedReducer,l!==null))try{var s=t.lastRenderedState,a=l(s,n);if(o.hasEagerState=!0,o.eagerState=a,Pt(a,s)){var d=t.interleaved;d===null?(o.next=o,ra(t)):(o.next=d.next,d.next=o),t.interleaved=o;return}}catch{}finally{}n=cf(e,t,o,r),n!==null&&(o=it(),Nt(n,e,r,o),Pf(n,t,r))}}function Rf(e){var t=e.alternate;return e===Re||t!==null&&t===Re}function Nf(e,t){qr=zo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Pf(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ws(e,n)}}var Ro={readContext:Ct,useCallback:qe,useContext:qe,useEffect:qe,useImperativeHandle:qe,useInsertionEffect:qe,useLayoutEffect:qe,useMemo:qe,useReducer:qe,useRef:qe,useState:qe,useDebugValue:qe,useDeferredValue:qe,useTransition:qe,useMutableSource:qe,useSyncExternalStore:qe,useId:qe,unstable_isNewReconciler:!1},Sh={readContext:Ct,useCallback:function(e,t){return $t().memoizedState=[e,t===void 0?null:t],e},useContext:Ct,useEffect:Gd,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ro(4194308,4,Cf.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ro(4194308,4,e,t)},useInsertionEffect:function(e,t){return ro(4,2,e,t)},useMemo:function(e,t){var n=$t();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=$t();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=yh.bind(null,Re,e),[r.memoizedState,e]},useRef:function(e){var t=$t();return e={current:e},t.memoizedState=e},useState:Zd,useDebugValue:fa,useDeferredValue:function(e){return $t().memoizedState=e},useTransition:function(){var e=Zd(!1),t=e[0];return e=vh.bind(null,e[1]),$t().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Re,o=$t();if(be){if(n===void 0)throw Error(L(407));n=n()}else{if(n=t(),Ve===null)throw Error(L(349));An&30||gf(r,t,n)}o.memoizedState=n;var l={value:n,getSnapshot:t};return o.queue=l,Gd(yf.bind(null,r,l,e),[e]),r.flags|=2048,vi(9,vf.bind(null,r,l,n,t),void 0,null),n},useId:function(){var e=$t(),t=Ve.identifierPrefix;if(be){var n=Kt,r=Vt;n=(r&~(1<<32-Rt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=hi++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[Dt]=t,e[fi]=r,Uf(e,t,!1,!1),t.stateNode=e;e:{switch(s=Jl(n,r),n){case"dialog":we("cancel",e),we("close",e),o=r;break;case"iframe":case"object":case"embed":we("load",e),o=r;break;case"video":case"audio":for(o=0;okr&&(t.flags|=128,r=!0,Pr(l,!1),t.lanes=4194304)}else{if(!r)if(e=To(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Pr(l,!0),l.tail===null&&l.tailMode==="hidden"&&!s.alternate&&!be)return Ze(t),null}else 2*Oe()-l.renderingStartTime>kr&&n!==1073741824&&(t.flags|=128,r=!0,Pr(l,!1),t.lanes=4194304);l.isBackwards?(s.sibling=t.child,t.child=s):(n=l.last,n!==null?n.sibling=s:t.child=s,l.last=s)}return l.tail!==null?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=Oe(),t.sibling=null,n=Te.current,ke(Te,r?n&1|2:n&1),t):(Ze(t),null);case 22:case 23:return ya(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?mt&1073741824&&(Ze(t),t.subtreeFlags&6&&(t.flags|=8192)):Ze(t),null;case 24:return null;case 25:return null}throw Error(L(156,t.tag))}function Th(e,t){switch(Zs(t),t.tag){case 1:return ct(t.type)&&ko(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return xr(),Ce(ut),Ce(nt),sa(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return la(t),null;case 13:if(Ce(Te),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(L(340));vr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ce(Te),null;case 4:return xr(),null;case 10:return na(t.type._context),null;case 22:case 23:return ya(),null;case 24:return null;default:return null}}var Ai=!1,et=!1,zh=typeof WeakSet=="function"?WeakSet:Set,U=null;function sr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Pe(e,t,r)}else n.current=null}function js(e,t,n){try{n()}catch(r){Pe(e,t,r)}}var uu=!1;function Rh(e,t){if(os=vo,e=Yc(),Xs(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,l=r.focusNode;r=r.focusOffset;try{n.nodeType,l.nodeType}catch{n=null;break e}var s=0,a=-1,d=-1,c=0,g=0,m=e,x=null;t:for(;;){for(var S;m!==n||o!==0&&m.nodeType!==3||(a=s+o),m!==l||r!==0&&m.nodeType!==3||(d=s+r),m.nodeType===3&&(s+=m.nodeValue.length),(S=m.firstChild)!==null;)x=m,m=S;for(;;){if(m===e)break t;if(x===n&&++c===o&&(a=s),x===l&&++g===r&&(d=s),(S=m.nextSibling)!==null)break;m=x,x=m.parentNode}m=S}n=a===-1||d===-1?null:{start:a,end:d}}else n=null}n=n||{start:0,end:0}}else n=null;for(ls={focusedElem:e,selectionRange:n},vo=!1,U=t;U!==null;)if(t=U,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,U=e;else for(;U!==null;){t=U;try{var E=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(E!==null){var T=E.memoizedProps,H=E.memoizedState,h=t.stateNode,u=h.getSnapshotBeforeUpdate(t.elementType===t.type?T:Et(t.type,T),H);h.__reactInternalSnapshotBeforeUpdate=u}break;case 3:var f=t.stateNode.containerInfo;f.nodeType===1?f.textContent="":f.nodeType===9&&f.documentElement&&f.removeChild(f.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(L(163))}}catch(p){Pe(t,t.return,p)}if(e=t.sibling,e!==null){e.return=t.return,U=e;break}U=t.return}return E=uu,uu=!1,E}function Zr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var l=o.destroy;o.destroy=void 0,l!==void 0&&js(t,n,l)}o=o.next}while(o!==r)}}function Qo(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ws(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Vf(e){var t=e.alternate;t!==null&&(e.alternate=null,Vf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Dt],delete t[fi],delete t[ds],delete t[fh],delete t[ph])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Kf(e){return e.tag===5||e.tag===3||e.tag===4}function cu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Kf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Cs(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=So));else if(r!==4&&(e=e.child,e!==null))for(Cs(e,t,n),e=e.sibling;e!==null;)Cs(e,t,n),e=e.sibling}function bs(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(bs(e,t,n),e=e.sibling;e!==null;)bs(e,t,n),e=e.sibling}var Qe=null,Tt=!1;function Gt(e,t,n){for(n=n.child;n!==null;)Qf(e,t,n),n=n.sibling}function Qf(e,t,n){if(It&&typeof It.onCommitFiberUnmount=="function")try{It.onCommitFiberUnmount(Io,n)}catch{}switch(n.tag){case 5:et||sr(n,t);case 6:var r=Qe,o=Tt;Qe=null,Gt(e,t,n),Qe=r,Tt=o,Qe!==null&&(Tt?(e=Qe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Qe.removeChild(n.stateNode));break;case 18:Qe!==null&&(Tt?(e=Qe,n=n.stateNode,e.nodeType===8?yl(e.parentNode,n):e.nodeType===1&&yl(e,n),si(e)):yl(Qe,n.stateNode));break;case 4:r=Qe,o=Tt,Qe=n.stateNode.containerInfo,Tt=!0,Gt(e,t,n),Qe=r,Tt=o;break;case 0:case 11:case 14:case 15:if(!et&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var l=o,s=l.destroy;l=l.tag,s!==void 0&&(l&2||l&4)&&js(n,t,s),o=o.next}while(o!==r)}Gt(e,t,n);break;case 1:if(!et&&(sr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Pe(n,t,a)}Gt(e,t,n);break;case 21:Gt(e,t,n);break;case 22:n.mode&1?(et=(r=et)||n.memoizedState!==null,Gt(e,t,n),et=r):Gt(e,t,n);break;default:Gt(e,t,n)}}function fu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new zh),t.forEach(function(r){var o=Ih.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function _t(e,t){var n=t.deletions;if(n!==null)for(var r=0;ro&&(o=s),r&=~l}if(r=o,r=Oe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Ph(r/1960))-r,10e?16:e,sn===null)var r=!1;else{if(e=sn,sn=null,Fo=0,pe&6)throw Error(L(331));var o=pe;for(pe|=4,U=e.current;U!==null;){var l=U,s=l.child;if(U.flags&16){var a=l.deletions;if(a!==null){for(var d=0;dOe()-ga?$n(e,0):ha|=n),ft(e,t)}function tp(e,t){t===0&&(e.mode&1?(t=Pi,Pi<<=1,!(Pi&130023424)&&(Pi=4194304)):t=1);var n=it();e=Xt(e,t),e!==null&&(Si(e,t,n),ft(e,n))}function Mh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),tp(e,n)}function Ih(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(L(314))}r!==null&&r.delete(t),tp(e,n)}var np;np=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ut.current)dt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return dt=!1,_h(e,t,n);dt=!!(e.flags&131072)}else dt=!1,be&&t.flags&1048576&&lf(t,Co,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;io(e,t),e=t.pendingProps;var o=gr(t,nt.current);pr(t,n),o=da(null,t,r,e,o,n);var l=ua();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ct(r)?(l=!0,jo(t)):l=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,ia(t),o.updater=Ko,t.stateNode=o,o._reactInternals=t,hs(t,r,e,n),t=ys(null,t,r,!0,l,n)):(t.tag=0,be&&l&&qs(t),rt(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(io(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=Ah(r),e=Et(r,e),o){case 0:t=vs(null,t,r,e,n);break e;case 1:t=su(null,t,r,e,n);break e;case 11:t=ou(null,t,r,e,n);break e;case 14:t=lu(null,t,r,Et(r.type,e),n);break e}throw Error(L(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Et(r,o),vs(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Et(r,o),su(e,t,r,o,n);case 3:e:{if(If(t),e===null)throw Error(L(387));r=t.pendingProps,l=t.memoizedState,o=l.element,ff(e,t),Eo(t,r,null,n);var s=t.memoizedState;if(r=s.element,l.isDehydrated)if(l={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=l,t.memoizedState=l,t.flags&256){o=Sr(Error(L(423)),t),t=au(e,t,r,n,o);break e}else if(r!==o){o=Sr(Error(L(424)),t),t=au(e,t,r,n,o);break e}else for(ht=fn(t.stateNode.containerInfo.firstChild),gt=t,be=!0,zt=null,n=uf(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(vr(),r===o){t=qt(e,t,n);break e}rt(e,t,r,n)}t=t.child}return t;case 5:return pf(t),e===null&&fs(t),r=t.type,o=t.pendingProps,l=e!==null?e.memoizedProps:null,s=o.children,ss(r,o)?s=null:l!==null&&ss(r,l)&&(t.flags|=32),Mf(e,t),rt(e,t,s,n),t.child;case 6:return e===null&&fs(t),null;case 13:return Bf(e,t,n);case 4:return oa(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=yr(t,null,r,n):rt(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Et(r,o),ou(e,t,r,o,n);case 7:return rt(e,t,t.pendingProps,n),t.child;case 8:return rt(e,t,t.pendingProps.children,n),t.child;case 12:return rt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,l=t.memoizedProps,s=o.value,ke(bo,r._currentValue),r._currentValue=s,l!==null)if(Pt(l.value,s)){if(l.children===o.children&&!ut.current){t=qt(e,t,n);break e}}else for(l=t.child,l!==null&&(l.return=t);l!==null;){var a=l.dependencies;if(a!==null){s=l.child;for(var d=a.firstContext;d!==null;){if(d.context===r){if(l.tag===1){d=Qt(-1,n&-n),d.tag=2;var c=l.updateQueue;if(c!==null){c=c.shared;var g=c.pending;g===null?d.next=d:(d.next=g.next,g.next=d),c.pending=d}}l.lanes|=n,d=l.alternate,d!==null&&(d.lanes|=n),ps(l.return,n,t),a.lanes|=n;break}d=d.next}}else if(l.tag===10)s=l.type===t.type?null:l.child;else if(l.tag===18){if(s=l.return,s===null)throw Error(L(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),ps(s,n,t),s=l.sibling}else s=l.child;if(s!==null)s.return=l;else for(s=l;s!==null;){if(s===t){s=null;break}if(l=s.sibling,l!==null){l.return=s.return,s=l;break}s=s.return}l=s}rt(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,pr(t,n),o=Ct(o),r=r(o),t.flags|=1,rt(e,t,r,n),t.child;case 14:return r=t.type,o=Et(r,t.pendingProps),o=Et(r.type,o),lu(e,t,r,o,n);case 15:return $f(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Et(r,o),io(e,t),t.tag=1,ct(r)?(e=!0,jo(t)):e=!1,pr(t,n),Ff(t,r,o),hs(t,r,o,n),ys(null,t,r,!0,e,n);case 19:return Af(e,t,n);case 22:return Df(e,t,n)}throw Error(L(156,t.tag))};function rp(e,t){return zc(e,t)}function Bh(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function jt(e,t,n,r){return new Bh(e,t,n,r)}function Sa(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ah(e){if(typeof e=="function")return Sa(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Is)return 11;if(e===Bs)return 14}return 2}function gn(e,t){var n=e.alternate;return n===null?(n=jt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function so(e,t,n,r,o,l){var s=2;if(r=e,typeof e=="function")Sa(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case Zn:return Dn(n.children,o,l,t);case Ms:s=8,o|=8;break;case Il:return e=jt(12,n,t,o|2),e.elementType=Il,e.lanes=l,e;case Bl:return e=jt(13,n,t,o),e.elementType=Bl,e.lanes=l,e;case Al:return e=jt(19,n,t,o),e.elementType=Al,e.lanes=l,e;case fc:return Jo(n,o,l,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case uc:s=10;break e;case cc:s=9;break e;case Is:s=11;break e;case Bs:s=14;break e;case en:s=16,r=null;break e}throw Error(L(130,e==null?e:typeof e,""))}return t=jt(s,n,t,o),t.elementType=e,t.type=r,t.lanes=l,t}function Dn(e,t,n,r){return e=jt(7,e,r,t),e.lanes=n,e}function Jo(e,t,n,r){return e=jt(22,e,r,t),e.elementType=fc,e.lanes=n,e.stateNode={isHidden:!1},e}function _l(e,t,n){return e=jt(6,e,null,t),e.lanes=n,e}function El(e,t,n){return t=jt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Uh(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=sl(0),this.expirationTimes=sl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=sl(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function ka(e,t,n,r,o,l,s,a,d){return e=new Uh(e,t,n,a,d),t===1?(t=1,l===!0&&(t|=8)):t=0,l=jt(3,null,null,t),e.current=l,l.stateNode=e,l.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ia(l),e}function Wh(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(sp)}catch(e){console.error(e)}}sp(),lc.exports=yt;var Yh=lc.exports,Su=Yh;Dl.createRoot=Su.createRoot,Dl.hydrateRoot=Su.hydrateRoot;const Jh="modulepreload",Xh=function(e){return"/"+e},ku={},qh=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),a=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));o=Promise.allSettled(n.map(d=>{if(d=Xh(d),d in ku)return;ku[d]=!0;const c=d.endsWith(".css"),g=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${g}`))return;const m=document.createElement("link");if(m.rel=c?"stylesheet":Jh,c||(m.as="script"),m.crossOrigin="",m.href=d,a&&m.setAttribute("nonce",a),document.head.appendChild(m),c)return new Promise((x,S)=>{m.addEventListener("load",x),m.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${d}`)))})}))}function l(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return o.then(s=>{for(const a of s||[])a.status==="rejected"&&l(a.reason);return t().catch(l)})},ao="/api";async function F(e,t){const n=await fetch(ao+e,{...t,headers:{"Content-Type":"application/json",...(t==null?void 0:t.headers)||{}}});if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);return await n.json()}const B={listMemories:()=>F("/memories"),remember:(e,t,n)=>F("/memories",{method:"POST",body:JSON.stringify({content:e,tier:t,tags:n})}),archiveMemory:e=>F(`/memories/${encodeURIComponent(e)}`,{method:"DELETE"}),routerStats:e=>F(`/router/stats${e?`?agent_id=${encodeURIComponent(e)}`:""}`),routerPolicy:()=>F("/router/policy"),routerTune:()=>F("/router/tune",{method:"POST"}),metaBuddhi:()=>F("/meta-buddhi"),evolution:()=>F("/evolution"),conflicts:()=>F("/conflicts"),resolveConflict:(e,t)=>F(`/conflicts/${encodeURIComponent(e)}/resolve`,{method:"POST",body:JSON.stringify({action:t})}),resolveConflictDetailed:(e,t)=>F(`/conflicts/${encodeURIComponent(e)}/resolve`,{method:"POST",body:JSON.stringify(t)}),tasks:()=>F("/tasks"),createTask:(e,t)=>F("/tasks",{method:"POST",body:JSON.stringify({title:e,harness:t})}),taskDetail:(e,t=24)=>F(`/tasks/${encodeURIComponent(e)}?limit=${encodeURIComponent(String(t))}`),updateTaskStatus:(e,t)=>F(`/tasks/${encodeURIComponent(e)}/status`,{method:"POST",body:JSON.stringify({status:t})}),addTaskNote:(e,t)=>F(`/tasks/${encodeURIComponent(e)}/notes`,{method:"POST",body:JSON.stringify({content:t})}),workspaceGraph:(e,t)=>F(`/workspace/graph${e?`?workspace_id=${encodeURIComponent(e)}${t?`&project_id=${encodeURIComponent(t)}`:""}`:""}`),projects:()=>F("/workspaces"),workspaces:()=>F("/workspaces"),createWorkspaceRoot:(e,t)=>F("/workspaces",{method:"POST",body:JSON.stringify({name:e,description:t})}),createProject:(e,t)=>F(`/workspaces/${encodeURIComponent(e)}/projects`,{method:"POST",body:JSON.stringify(t)}),updateProject:(e,t)=>F(`/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}),projectSessions:e=>F(`/projects/${encodeURIComponent(e)}/sessions`),projectCanvas:e=>F(`/projects/${encodeURIComponent(e)}/canvas`),workspaceCanvas:e=>F(`/workspaces/${encodeURIComponent(e)}/canvas`),pickFolder:e=>F("/folders/pick",{method:"POST",body:JSON.stringify({prompt:e})}),addWorkspaceFolder:(e,t,n)=>F(`/workspaces/${encodeURIComponent(e)}/folders`,{method:"POST",body:JSON.stringify({path:t,label:n})}),removeWorkspaceFolder:(e,t)=>F(`/workspaces/${encodeURIComponent(e)}/mounts?path=${encodeURIComponent(t)}`,{method:"DELETE"}),updateWorkspace:(e,t)=>F(`/workspaces/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}),deleteWorkspace:e=>F(`/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"}),deleteProject:e=>F(`/projects/${encodeURIComponent(e)}`,{method:"DELETE"}),workspaceDetail:e=>F(`/workspaces/${encodeURIComponent(e)}`),workspaceSessions:e=>F(`/workspaces/${encodeURIComponent(e)}/sessions`),sessionDetail:e=>F(`/sessions/${encodeURIComponent(e)}`),launchWorkspaceSession:(e,t,n,r,o,l)=>F(`/workspaces/${encodeURIComponent(e)}/sessions/launch`,{method:"POST",body:JSON.stringify({runtime:t,title:n,permission_mode:r,task_id:o,project_id:l})}),workspaceLineMessages:(e,t)=>F(`/workspaces/${encodeURIComponent(e)}/line/messages?${new URLSearchParams(Object.entries({project_id:t==null?void 0:t.project_id,channel:t==null?void 0:t.channel,cursor:t==null?void 0:t.cursor,limit:t!=null&&t.limit?String(t.limit):void 0}).filter(n=>!!n[1])).toString()}`),publishWorkspaceLineMessage:(e,t)=>F(`/workspaces/${encodeURIComponent(e)}/line/messages`,{method:"POST",body:JSON.stringify(t)}),uploadSessionAsset:async(e,t,n)=>{const r=new FormData;r.append("file",t),n&&r.append("label",n);const o=await fetch(`${ao}/sessions/${encodeURIComponent(e)}/assets`,{method:"POST",body:r});if(!o.ok)throw new Error(`${o.status} ${o.statusText}`);return await o.json()},listProjectAssets:e=>F(`/projects/${encodeURIComponent(e)}/assets`),listWorkspaceAssets:(e,t=!0)=>F(`/workspaces/${encodeURIComponent(e)}/assets?include_project_assets=${t?"true":"false"}`),uploadProjectAsset:async(e,t,n)=>{const r=new FormData;r.append("file",t),n!=null&&n.label&&r.append("label",n.label),n!=null&&n.folder&&r.append("folder",n.folder);const o=await fetch(`${ao}/projects/${encodeURIComponent(e)}/assets`,{method:"POST",body:r});if(!o.ok)throw new Error(`${o.status} ${o.statusText}`);return await o.json()},uploadWorkspaceAsset:async(e,t,n)=>{const r=new FormData;r.append("file",t),n!=null&&n.label&&r.append("label",n.label),n!=null&&n.folder&&r.append("folder",n.folder),n!=null&&n.project_id&&r.append("project_id",n.project_id);const o=await fetch(`${ao}/workspaces/${encodeURIComponent(e)}/assets`,{method:"POST",body:r});if(!o.ok)throw new Error(`${o.status} ${o.statusText}`);return await o.json()},deleteProjectAsset:e=>F(`/project-assets/${encodeURIComponent(e)}`,{method:"DELETE"}),fileContext:(e,t)=>F(`/files/${encodeURIComponent(e)}/context${t?`?workspace_id=${encodeURIComponent(t)}`:""}`),assetContext:e=>F(`/assets/${encodeURIComponent(e)}/context`),askAsset:(e,t)=>F(`/assets/${encodeURIComponent(e)}/ask`,{method:"POST",body:JSON.stringify({question:t})}),runtimeStatus:()=>F("/runtime-status"),status:()=>F("/status"),memoryNow:()=>F("/memory/now"),captureTimeline:(e=16)=>F(`/capture/timeline?limit=${encodeURIComponent(String(e))}`),launch:(e,t,n)=>F("/launch",{method:"POST",body:JSON.stringify({runtime:e,taskId:t,title:n})}),apiKeys:()=>F("/security/api-keys"),storeApiKey:(e,t,n)=>F("/security/api-keys",{method:"POST",body:JSON.stringify({provider:e,apiKey:t,label:n})}),rotateApiKey:(e,t,n)=>F(`/security/api-keys/${encodeURIComponent(e)}/rotate`,{method:"POST",body:JSON.stringify({apiKey:t,label:n})}),me:()=>F("/me"),continuity:()=>F("/continuity"),orgGraph:(e,t)=>{const n=new URLSearchParams;e&&n.set("org",e),t!=null&&t.active&&n.set("active","true");const r=n.toString();return F(`/org/graph${r?`?${r}`:""}`)},routerSessions:e=>{const t=new URLSearchParams;(e==null?void 0:e.active)!=null&&t.set("active",e.active?"true":"false"),e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.agent&&t.set("agent",e.agent);const n=t.toString();return F(`/router/sessions${n?`?${n}`:""}`)},contextEntries:(e,t=200)=>{const n=new URLSearchParams;return e&&n.set("repo",e),n.set("limit",String(t)),F(`/context/entries?${n.toString()}`)},contextPromote:e=>F("/context/promote",{method:"POST",body:JSON.stringify(e)}),contextDemote:e=>F("/context/demote",{method:"POST",body:JSON.stringify(e)}),localWorkspaces:()=>F("/local/workspaces"),localWorkspaceCreate:e=>F("/local/workspaces",{method:"POST",body:JSON.stringify(e)}),localContextLinkFolder:e=>F("/local-context/folders/link",{method:"POST",body:JSON.stringify({path:e})}),localContextUnlinkFolder:e=>F("/local-context/folders/unlink",{method:"POST",body:JSON.stringify({path:e})}),contextItems:(e={})=>{const t=new URLSearchParams;e.team&&t.set("team",e.team),e.project&&t.set("project",e.project),e.scope&&t.set("scope",e.scope),e.kind&&t.set("kind",e.kind),e.limit&&t.set("limit",String(e.limit));const n=t.toString();return F(`/context/items${n?`?${n}`:""}`)},contextUsage:(e={})=>{const t=new URLSearchParams;e.team&&t.set("team",e.team),e.project&&t.set("project",e.project),e.scope&&t.set("scope",e.scope),e.kind&&t.set("kind",e.kind),e.limit&&t.set("limit",String(e.limit));const n=t.toString();return F(`/context/usage${n?`?${n}`:""}`)},commandCenter:()=>F("/ui/command-center"),proofReplay:(e=80)=>F(`/ui/proof-replay?limit=${encodeURIComponent(String(e))}`),handoffUi:()=>F("/ui/handoff"),learningsUi:(e=120)=>F(`/ui/learnings?limit=${encodeURIComponent(String(e))}`),promoteLearning:(e,t)=>F(`/ui/learnings/${encodeURIComponent(e)}/promote`,{method:"POST",body:JSON.stringify(t||{approved_by:"dhee-ui"})}),rejectLearning:(e,t)=>F(`/ui/learnings/${encodeURIComponent(e)}/reject`,{method:"POST",body:JSON.stringify(t||{reason:"rejected in Dhee UI"})}),portabilityUi:()=>F("/ui/portability"),exportPackUi:e=>F("/ui/portability/export",{method:"POST",body:JSON.stringify(e||{})}),importPackDryRunUi:e=>F("/ui/portability/import-dry-run",{method:"POST",body:JSON.stringify(e)}),upsertContext:e=>F("/context",{method:"POST",body:JSON.stringify(e)}),proposeContext:e=>F("/proposals",{method:"POST",body:JSON.stringify(e)}),approveProposal:(e,t)=>F(`/proposals/${encodeURIComponent(e)}/approve`,{method:"POST",body:JSON.stringify({reviewer_user_id:t})}),rejectProposal:(e,t)=>F(`/proposals/${encodeURIComponent(e)}/reject`,{method:"POST",body:JSON.stringify({reviewer_user_id:t})}),inbox:(e={})=>{const t=new URLSearchParams;e.team&&t.set("team",e.team),e.user&&t.set("user",e.user);const n=t.toString();return F(`/inbox${n?`?${n}`:""}`)},resolveFinding:(e,t)=>F(`/findings/${encodeURIComponent(e)}/resolve`,{method:"POST",body:JSON.stringify({resolved_by:t})}),backlinks:(e,t=50)=>F(`/backlinks?context_id=${encodeURIComponent(e)}&limit=${encodeURIComponent(String(t))}`),setIntegration:e=>F("/integrations",{method:"POST",body:JSON.stringify(e)}),teamJoin:e=>F("/team-join",{method:"POST",body:JSON.stringify(e)}),localContextAddFolder:e=>F("/local-context/folders",{method:"POST",body:JSON.stringify(e)}),localContextShareFolder:e=>F("/local-context/folders/share",{method:"POST",body:JSON.stringify(e)}),enterpriseSetWorkspace:e=>F("/workspace",{method:"POST",body:JSON.stringify(e)}),enterpriseResetWorkspace:()=>F("/workspace/reset",{method:"POST",body:"{}"}),enterpriseCreateProject:e=>F("/projects",{method:"POST",body:JSON.stringify(e)}),enterpriseDeleteProject:e=>F(`/projects/${encodeURIComponent(e)}`,{method:"DELETE"}),enterpriseCreateProjectTeam:(e,t)=>F(`/projects/${encodeURIComponent(e)}/teams`,{method:"POST",body:JSON.stringify(t)}),enterpriseAddProjectFolder:(e,t)=>F(`/projects/${encodeURIComponent(e)}/folders`,{method:"POST",body:JSON.stringify(t)}),enterpriseAddTeamFolder:(e,t)=>F(`/teams/${encodeURIComponent(e)}/folders`,{method:"POST",body:JSON.stringify(t)}),enterpriseRemoveFolder:e=>F(`/folders/${encodeURIComponent(e)}`,{method:"DELETE"}),enterpriseAddTeamCollaborator:(e,t)=>F(`/teams/${encodeURIComponent(e)}/collaborators`,{method:"POST",body:JSON.stringify({target_team_id:t})}),enterpriseExtractProject:e=>F(`/projects/${encodeURIComponent(e)}/extract`,{method:"POST",body:"{}"}),enterpriseExtractTeam:e=>F(`/teams/${encodeURIComponent(e)}/extract`,{method:"POST",body:"{}"}),pickFolderPath:e=>F("/folders/pick",{method:"POST",body:JSON.stringify({prompt:e})})};function Zh({view:e,setView:t,conflictCount:n}){const r=[{id:"command",icon:"⌂",label:"HOME",tip:"Command center · current truth · next action"},{id:"router",icon:"⇌",label:"FIREWALL",tip:"Context firewall · routing · expansions · tokens saved"},{id:"canvas",icon:"⊞",label:"BRAIN",tip:"Repo Brain · linked folders · active sessions"},{id:"handoff",icon:"↗",label:"HANDOFF",tip:"Resume state across agents"},{id:"replay",icon:"◌",label:"REPLAY",tip:"Context decision replay"},{id:"learnings",icon:"↑",label:"LEARN",tip:"Evidence-backed learning review"},{id:"context",icon:"◐",label:"CONTEXT",tip:"Context vault · personal and shared memory"},{id:"portability",icon:"□",label:"PACKS",tip:".dheemem export · import dry-run · portability"},{id:"conflicts",icon:"⟷",label:"INBOX",tip:"Proposals · findings · conflicts",badge:n}];return i.jsxs("div",{style:{width:"var(--nav)",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg)",zIndex:20},children:[i.jsx("div",{style:{height:48,borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx("img",{src:"/dhee-logo.png",alt:"Dhee",style:{width:22,height:22,objectFit:"contain"}})}),i.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",padding:"6px 0",gap:0},children:r.map(o=>{const l=o.id==="router"?e==="router"||e.startsWith("router/"):e===o.id;return i.jsxs("div",{title:o.tip,onClick:()=>t(o.id),style:{position:"relative",height:44,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:"pointer",background:l?"var(--surface)":"transparent",borderLeft:`2px solid ${l?"var(--accent)":"transparent"}`,gap:2,transition:"all 0.1s"},onMouseEnter:s=>{l||(s.currentTarget.style.background="var(--surface)")},onMouseLeave:s=>{l||(s.currentTarget.style.background="transparent")},children:[i.jsx("span",{style:{fontSize:14,color:l?"var(--accent)":"var(--ink3)",lineHeight:1},children:o.icon}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:7,color:l?"var(--accent)":"var(--ink3)",letterSpacing:"0.04em"},children:o.label}),o.badge&&o.badge>0?i.jsx("div",{style:{position:"absolute",top:6,right:6,width:14,height:14,borderRadius:"50%",background:"var(--rose)",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:8,color:"white",fontWeight:700},children:o.badge})}):null]},o.id)})}),i.jsx("div",{style:{borderTop:"1px solid var(--border)",height:44,display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx("div",{title:"Dhee active",style:{width:5,height:5,borderRadius:"50%",background:"var(--green)"}})})]})}function Lr(e){return!e||e<=0?"0":new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e)}function Gh(e){if(!e)return 0;const t=Number(e.sessionTokensSaved||0),n=Number(e.enterpriseSavedTokens||0);return t+n}function eg(e){return e?Number(e.enterpriseSavedPct||0):0}function tg({viewer:e,routerStats:t,onRefresh:n,onOpenTweaks:r,onResetWorkspace:o}){const[l,s]=v.useState(!1),[a,d]=v.useState(null),c=v.useRef(null);v.useEffect(()=>{if(!l)return;const u=f=>{c.current&&(c.current.contains(f.target)||s(!1))};return window.addEventListener("mousedown",u),()=>window.removeEventListener("mousedown",u)},[l]),v.useEffect(()=>{if(t){d(null);return}let u=!1;const f=async()=>{try{const j=await B.routerStats();u||d(j)}catch{}};f();const p=window.setInterval(f,5e3);return()=>{u=!0,window.clearInterval(p)}},[t]);const g=(e==null?void 0:e.org_id)||"default",m=(e==null?void 0:e.project_id)||null,x=(e==null?void 0:e.team_id)||null,S=[g,m,x].filter(Boolean).join(" · "),E=t||a,T=Gh(E),H=eg(E),h=(()=>{if(!E)return"loading";const u=Number(E.sessionTokensSaved||0),f=Number(E.enterpriseSavedTokens||0),p=Number(E.enterpriseRawTokens||0),j=Number(E.enterpriseSummaryTokens||0),_=Number(E.enterpriseRawFallbacks||0),P=Number(E.enterpriseGateSuggestions||0);return`Session: ${Lr(u)} · Repo index: ${Lr(f)} · Raw avoided: ${Lr(p)} -> ${Lr(j)} · Fallbacks: ${_} · Gates: ${P}`})();return i.jsxs("div",{style:{height:32,borderBottom:"1px solid var(--border)",background:"var(--bg)",display:"flex",alignItems:"center",padding:"0 12px",gap:10,flexShrink:0,zIndex:15},children:[i.jsxs("div",{className:"workspace-pill",title:S,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"3px 9px",borderRadius:4,background:"var(--surface)",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink2)",letterSpacing:"0.04em"},children:[i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:e!=null&&e.live?"var(--green)":"var(--ink3)"}}),i.jsx("span",{children:S||"no workspace"}),e!=null&&e.role?i.jsx("span",{style:{marginLeft:6,padding:"1px 5px",borderRadius:3,background:"var(--surface2)",color:"var(--ink2)",fontSize:9},children:String(e.role).toUpperCase()}):null]}),i.jsx("div",{style:{flex:1}}),i.jsxs("div",{className:"tokens-chip",title:h,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"3px 9px",borderRadius:4,background:"var(--accent-dim)",border:"1px solid var(--accent)",color:"var(--accent)",fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.04em"},children:[i.jsx("span",{style:{fontSize:11},children:"↯"}),i.jsxs("span",{children:[Lr(T)," saved"]}),H>0?i.jsxs("span",{style:{color:"var(--ink3)"},children:["· ",H.toFixed(0),"%"]}):null]}),i.jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[i.jsx("button",{"aria-label":"Menu",onClick:()=>s(u=>!u),style:{width:22,height:22,borderRadius:4,background:l?"var(--surface2)":"var(--surface)",border:"1px solid var(--border)",color:"var(--ink2)",fontSize:12,lineHeight:1,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:"⋮"}),l?i.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",right:0,minWidth:180,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,boxShadow:"0 6px 18px rgba(20,16,10,0.08)",zIndex:30,padding:4,fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.04em"},children:[i.jsx(Hi,{label:"REFRESH",onClick:()=>{s(!1),n()}}),i.jsx(Hi,{label:"TWEAKS",hint:"⌘K",onClick:()=>{s(!1),r()}}),o?i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{height:1,background:"var(--border)",margin:"3px 0"}}),i.jsx(Hi,{label:"RESET WORKSPACE",onClick:()=>{s(!1),o()},danger:!0})]}):null,i.jsx("div",{style:{height:1,background:"var(--border)",margin:"3px 0"}}),i.jsx(Hi,{label:"USER ID",hint:(e==null?void 0:e.user_id)||"—",onClick:()=>s(!1),dim:!0})]}):null]})]})}function Hi({label:e,hint:t,onClick:n,dim:r,danger:o}){return i.jsxs("button",{onClick:n,style:{width:"100%",textAlign:"left",padding:"5px 8px",borderRadius:3,background:"transparent",color:o?"var(--rose)":r?"var(--ink3)":"var(--ink2)",display:"flex",justifyContent:"space-between",alignItems:"center",gap:8},onMouseEnter:l=>{l.currentTarget.style.background=o?"var(--rose-dim)":"var(--surface)"},onMouseLeave:l=>{l.currentTarget.style.background="transparent"},children:[i.jsx("span",{children:e}),t?i.jsx("span",{style:{color:"var(--ink3)",fontSize:9},children:t}):null]})}function ng({tweaks:e,setTweaks:t,visible:n}){if(!n)return null;const r=(o,l)=>{const s={...e,[o]:l};t(s)};return i.jsxs("div",{style:{position:"fixed",bottom:20,right:20,width:236,border:"1px solid var(--border)",background:"white",zIndex:1e3,boxShadow:"0 8px 32px rgba(0,0,0,0.1)"},children:[i.jsx("div",{style:{padding:"9px 14px",borderBottom:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:10,fontWeight:700,letterSpacing:"0.06em"},children:"TWEAKS"}),i.jsxs("div",{style:{padding:"14px"},children:[i.jsxs("div",{style:{marginBottom:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6,textTransform:"uppercase"},children:"Accent hue"}),i.jsx("input",{type:"range",min:"0",max:"360",value:e.accentHue,onChange:o=>{const l=o.target.value;r("accentHue",l),document.documentElement.style.setProperty("--accent",`oklch(0.64 0.18 ${l})`),document.documentElement.style.setProperty("--accent-dim",`oklch(0.97 0.04 ${l})`)},style:{width:"100%"}}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:2},children:["hue ",e.accentHue,"°"]})]}),i.jsxs("div",{style:{marginBottom:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6,textTransform:"uppercase"},children:"Compact nav"}),i.jsx("button",{onClick:()=>r("compactNav",!e.compactNav),style:{padding:"4px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:10,background:e.compactNav?"var(--ink)":"transparent",color:e.compactNav?"var(--bg)":"var(--ink)",cursor:"pointer"},children:e.compactNav?"ON":"OFF"})]}),i.jsxs("div",{style:{marginBottom:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6,textTransform:"uppercase"},children:"Canvas style"}),i.jsx("div",{style:{display:"flex",gap:5},children:["dots","grid"].map(o=>i.jsx("button",{onClick:()=>r("canvasStyle",o),style:{padding:"4px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,background:e.canvasStyle===o?"var(--ink)":"transparent",color:e.canvasStyle===o?"var(--bg)":"var(--ink)",cursor:"pointer"},children:o},o))})]}),i.jsxs("div",{children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6,textTransform:"uppercase"},children:"Timestamps"}),i.jsx("button",{onClick:()=>r("showTimestamps",!e.showTimestamps),style:{padding:"4px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:10,background:e.showTimestamps?"var(--ink)":"transparent",color:e.showTimestamps?"var(--bg)":"var(--ink)",cursor:"pointer"},children:e.showTimestamps?"ON":"OFF"})]})]})]})}const rg={position:"fixed",inset:0,background:"rgba(20,16,10,0.28)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},ig={width:640,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 60px)",background:"white",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 20px 60px rgba(20,16,10,0.20)",display:"flex",flexDirection:"column",overflow:"hidden"},pt={width:"100%",border:"1px solid var(--border)",padding:"9px 11px",background:"var(--bg)",fontSize:13,lineHeight:1.4},Nn={fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:.5,textTransform:"uppercase",marginBottom:4,display:"block"},Vi={padding:"8px 14px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10,letterSpacing:.4,cursor:"pointer"},Wr={padding:"8px 14px",border:"1px solid var(--border)",background:"white",color:"var(--ink2)",fontFamily:"var(--mono)",fontSize:10,letterSpacing:.4,cursor:"pointer"},ju={padding:"8px 14px",border:"1px solid var(--rose)",background:"white",color:"var(--rose)",fontFamily:"var(--mono)",fontSize:10,letterSpacing:.4,cursor:"pointer"},wu=["codex","claude-code"];function og({open:e,onClose:t,projectIndex:n,initialWorkspaceId:r,initialTab:o="workspaces",onChanged:l}){var he,_e;const s=(n==null?void 0:n.workspaces)||[],[a,d]=v.useState(o),[c,g]=v.useState(r||((he=s[0])==null?void 0:he.id)||""),m=s.find(N=>N.id===c)||null,[x,S]=v.useState(""),[E,T]=v.useState(""),[H,h]=v.useState(""),[u,f]=v.useState(""),[p,j]=v.useState(""),[_,P]=v.useState(""),[z,Q]=v.useState(""),[R,J]=v.useState("codex"),[X,K]=v.useState([]),[G,M]=v.useState({}),[V,ye]=v.useState(!1),[C,A]=v.useState(null),[W,ee]=v.useState(null);if(v.useEffect(()=>{var N;e&&(d(o),g(r||((N=s[0])==null?void 0:N.id)||""),A(null),ee(null),S(""),T(""),P(""),Q(""),J("codex"),K([]),j(""))},[e]),v.useEffect(()=>{if(!m){h(""),f("");return}h(String(m.label||m.name||"")),f(String(m.description||"")),j("")},[m==null?void 0:m.id,m==null?void 0:m.label,m==null?void 0:m.description]),v.useEffect(()=>{m&&M(N=>{const oe={};for(const q of m.projects||[]){const te=(q.scopeRules||[]).map(Ae=>Ae.pathPrefix);oe[q.id]=N[q.id]||{name:q.name,description:q.description||"",defaultRuntime:q.defaultRuntime||"codex",folders:te}}return oe})},[m==null?void 0:m.id,(_e=m==null?void 0:m.projects)==null?void 0:_e.length]),!e)return null;const ie=async(N,oe)=>{A(null);try{const q=await B.pickFolder(oe||"Choose a folder");q.ok&&q.path&&N(q.path)}catch(q){A(String(q))}},D=async(N,oe)=>{ye(!0),A(null),ee(null);try{await oe(),ee(N),await l()}catch(q){A(String(q))}finally{ye(!1)}},fe=()=>D("Workspace created.",async()=>{const N=x.trim();if(!N)throw new Error("Name is required.");await B.createWorkspaceRoot(N,E.trim()||void 0),S(""),T("")}),se=()=>D("Workspace updated.",async()=>{if(!m)return;const N={};if(H.trim()&&H!==(m.label||m.name)&&(N.label=H.trim()),u!==(m.description||"")&&(N.description=u),!Object.keys(N).length)throw new Error("Nothing to save.");await B.updateWorkspace(m.id,N)}),me=()=>D("Workspace deleted.",async()=>{if(m){if(p.trim()!==(m.label||m.name))throw new Error("Type the workspace name exactly to confirm.");await B.deleteWorkspace(m.id),g(""),j("")}}),$=()=>D("Project created.",async()=>{if(!m)throw new Error("Pick a workspace first.");const N=_.trim();if(!N)throw new Error("Project name is required.");const oe=X.map(q=>q.trim()).filter(Boolean).map(q=>({path_prefix:q}));await B.createProject(m.id,{name:N,description:z.trim()||void 0,default_runtime:R,scope_rules:oe}),P(""),Q(""),J("codex"),K([])}),de=N=>()=>D("Project updated.",async()=>{const oe=G[N.id];if(!oe)return;const q={};oe.name.trim()&&oe.name.trim()!==N.name&&(q.name=oe.name.trim()),oe.description!==(N.description||"")&&(q.description=oe.description),oe.defaultRuntime&&oe.defaultRuntime!==(N.defaultRuntime||"codex")&&(q.default_runtime=oe.defaultRuntime);const te=(N.scopeRules||[]).map(xe=>xe.pathPrefix),Ae=oe.folders.map(xe=>xe.trim()).filter(Boolean);if((te.length!==Ae.length||te.some((xe,Me)=>xe!==Ae[Me]))&&(q.scope_rules=Ae.map(xe=>({path_prefix:xe}))),!Object.keys(q).length)throw new Error("Nothing to save.");await B.updateProject(N.id,q)}),ce=N=>()=>D("Project deleted.",async()=>{if(!window.confirm(`Delete project "${N.name}"? This removes its assets. The workspace stays.`))throw new Error("cancelled");await B.deleteProject(N.id)});return i.jsx("div",{style:rg,onClick:t,children:i.jsxs("div",{style:ig,onClick:N=>N.stopPropagation(),children:[i.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:15,fontWeight:700},children:"Workspaces & projects"}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:2},children:"Organise every agent under a shared brain."})]}),i.jsx("button",{onClick:t,style:{width:28,height:28,border:"1px solid var(--border)",borderRadius:4,background:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ink3)"},children:i.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",children:i.jsx("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})})})]}),i.jsx("div",{style:{padding:"10px 20px",borderBottom:"1px solid var(--border)",display:"flex",gap:6},children:["workspaces","projects"].map(N=>i.jsx("button",{onClick:()=>d(N),style:{padding:"6px 12px",border:`1px solid ${a===N?"var(--ink)":"var(--border)"}`,background:a===N?"var(--ink)":"white",color:a===N?"white":"var(--ink2)",fontFamily:"var(--mono)",fontSize:10,letterSpacing:.4,textTransform:"uppercase",cursor:"pointer"},children:N},N))}),i.jsxs("div",{style:{padding:20,overflowY:"auto",display:"flex",flexDirection:"column",gap:16},children:[a==="workspaces"&&i.jsxs(i.Fragment,{children:[i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsx("div",{style:Nn,children:"New workspace"}),i.jsx("input",{placeholder:"Name (e.g. Office, Personal, Sankhya AI Labs)",value:x,onChange:N=>S(N.target.value),style:pt}),i.jsx("textarea",{placeholder:"Description (optional)",value:E,onChange:N=>T(N.target.value),rows:2,style:{...pt,resize:"vertical"}}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",lineHeight:1.5},children:"A workspace is a collection of projects. Folders attach to projects, not workspaces."}),i.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:i.jsx("button",{onClick:()=>void fe(),disabled:V||!x.trim(),style:{...Vi,opacity:V||!x.trim()?.5:1},children:"create workspace"})})]}),i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsxs("div",{style:Nn,children:["Existing · ",s.length]}),s.length===0?i.jsx("div",{style:{padding:14,border:"1px dashed var(--border)",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55},children:"No workspaces yet. Create one above."}):i.jsx("div",{style:{display:"grid",gap:6},children:s.map(N=>{var te;const oe=N.id===c,q=((te=N.projects)==null?void 0:te.length)||0;return i.jsxs("button",{onClick:()=>g(N.id),style:{textAlign:"left",padding:"10px 12px",border:`1px solid ${oe?"var(--accent)":"var(--border)"}`,background:oe?"var(--surface)":"white",display:"flex",justifyContent:"space-between",gap:12,cursor:"pointer"},children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:13,fontWeight:600,lineHeight:1.3},children:N.label||N.name}),N.description&&i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:2},children:N.description})]}),i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[q," project",q===1?"":"s"]})]},N.id)})})]}),m&&i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8,borderTop:"1px solid var(--border)",paddingTop:14},children:[i.jsxs("div",{style:Nn,children:["Edit · ",m.label||m.name]}),i.jsx("input",{value:H,onChange:N=>h(N.target.value),placeholder:"Name",style:pt}),i.jsx("textarea",{value:u,onChange:N=>f(N.target.value),placeholder:"Description",rows:2,style:{...pt,resize:"vertical"}}),i.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:i.jsx("button",{onClick:()=>void se(),disabled:V,style:{...Vi,opacity:V?.5:1},children:"save changes"})}),i.jsxs("div",{style:{marginTop:8,padding:12,border:"1px solid rgba(203,63,78,0.3)",borderRadius:4,background:"rgba(203,63,78,0.04)"},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--rose)",letterSpacing:.5,textTransform:"uppercase",marginBottom:6},children:"Danger zone"}),i.jsxs("div",{style:{fontSize:11,color:"var(--ink2)",lineHeight:1.5,marginBottom:8},children:["Deleting ",i.jsx("strong",{children:m.label||m.name})," removes every project, asset, and line message. Sessions remain but detach. Type the workspace name to confirm."]}),i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsx("input",{value:p,onChange:N=>j(N.target.value),placeholder:m.label||m.name,style:{...pt,flex:1}}),i.jsx("button",{onClick:()=>void me(),disabled:V||p.trim()!==(m.label||m.name),style:{...ju,opacity:V||p.trim()!==(m.label||m.name)?.5:1},children:"delete workspace"})]})]})]})]}),a==="projects"&&i.jsxs(i.Fragment,{children:[i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsx("div",{style:Nn,children:"Workspace"}),i.jsxs("select",{value:c,onChange:N=>g(N.target.value),style:pt,children:[i.jsx("option",{value:"",children:"— pick a workspace —"}),s.map(N=>i.jsx("option",{value:N.id,children:N.label||N.name},N.id))]})]}),m&&i.jsxs(i.Fragment,{children:[i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsxs("div",{style:Nn,children:["Add project to ",m.label||m.name]}),i.jsx("input",{placeholder:"Project name (e.g. frontend, backend, design)",value:_,onChange:N=>P(N.target.value),style:pt}),i.jsx("textarea",{placeholder:"Description (optional)",value:z,onChange:N=>Q(N.target.value),rows:2,style:{...pt,resize:"vertical"}}),i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"default runtime"}),i.jsx("select",{value:R,onChange:N=>J(N.target.value),style:{...pt,flex:1},children:wu.map(N=>i.jsx("option",{value:N,children:N},N))})]}),i.jsx(Cu,{folders:X,onChange:K,onPick:N=>void ie(N,"Choose a project folder"),disabled:V}),i.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:i.jsx("button",{onClick:()=>void $(),disabled:V||!_.trim(),style:{...Vi,opacity:V||!_.trim()?.5:1},children:"add project"})})]}),i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsxs("div",{style:Nn,children:["Projects · ",(m.projects||[]).length]}),(m.projects||[]).length===0?i.jsx("div",{style:{padding:14,border:"1px dashed var(--border)",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55},children:"No projects yet — add the first one above."}):i.jsx("div",{style:{display:"grid",gap:10},children:(m.projects||[]).map(N=>{const oe=G[N.id]||{name:N.name,description:N.description||"",defaultRuntime:N.defaultRuntime||"codex",folders:(N.scopeRules||[]).map(te=>te.pathPrefix)},q=te=>M(Ae=>({...Ae,[N.id]:{...oe,...te}}));return i.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:10,display:"flex",flexDirection:"column",gap:8},children:[i.jsx("input",{value:oe.name,onChange:te=>q({name:te.target.value}),style:pt}),i.jsx("textarea",{value:oe.description,onChange:te=>q({description:te.target.value}),rows:2,style:{...pt,resize:"vertical"}}),i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"runtime"}),i.jsx("select",{value:oe.defaultRuntime,onChange:te=>q({defaultRuntime:te.target.value}),style:{...pt,flex:1},children:wu.map(te=>i.jsx("option",{value:te,children:te},te))})]}),i.jsx(Cu,{folders:oe.folders,onChange:te=>q({folders:te}),onPick:te=>void ie(te,`Add a folder to ${N.name}`),disabled:V}),i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:8},children:[i.jsx("button",{onClick:()=>void ce(N)(),disabled:V,style:{...ju,opacity:V?.5:1},children:"delete"}),i.jsx("button",{onClick:()=>void de(N)(),disabled:V,style:{...Vi,opacity:V?.5:1},children:"save"})]})]},N.id)})})]})]})]})]}),i.jsxs("div",{style:{padding:"10px 20px",borderTop:"1px solid var(--border)",background:"var(--bg)",display:"flex",alignItems:"center",justifyContent:"space-between",minHeight:44},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,lineHeight:1.4},children:C?i.jsx("span",{style:{color:"var(--rose)"},children:C}):W?i.jsx("span",{style:{color:"var(--green)"},children:W}):i.jsx("span",{style:{color:"var(--ink3)"},children:"Changes save immediately."})}),i.jsx("button",{onClick:t,style:Wr,children:"close"})]})]})})}function Cu({folders:e,onChange:t,onPick:n,disabled:r}){const o=(d,c)=>{const g=e.slice();g[d]=c,t(g)},l=d=>{const c=e.slice();c.splice(d,1),t(c)},s=()=>t([...e,""]),a=()=>n(d=>t([...e,d]));return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsxs("div",{style:Nn,children:["Folders · ",e.length]}),e.length===0&&i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",lineHeight:1.5},children:"No folders yet. A project can have one or many."}),e.map((d,c)=>i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("input",{value:d,onChange:g=>o(c,g.target.value),placeholder:"/absolute/path",style:{...pt,flex:1}}),i.jsx("button",{onClick:()=>n(g=>o(c,g)),style:Wr,disabled:r,children:"browse…"}),i.jsx("button",{onClick:()=>l(c),style:Wr,disabled:r,title:"Remove folder",children:"✕"})]},c)),i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("button",{onClick:a,style:Wr,disabled:r,children:"+ pick folder"}),i.jsx("button",{onClick:s,style:Wr,disabled:r,children:"+ type path"})]})]})}function $e({label:e,tone:t="var(--ink3)"}){return i.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 7px",border:`1px solid ${t}`,color:t,fontFamily:"var(--mono)",fontSize:9,lineHeight:1.2,whiteSpace:"nowrap"},children:e})}const bu=6e4,_u=36e5,Eu=864e5;function ap(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return String(e);const n=Date.now()-t;return nvoid t(e),disabled:n,title:"Remove asset","aria-label":"Remove asset",style:{width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid transparent",borderRadius:3,background:"transparent",color:"var(--ink3)",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,padding:0,flexShrink:0},onMouseEnter:a=>{n||(a.currentTarget.style.background="rgba(203,63,78,0.08)",a.currentTarget.style.color="var(--rose)")},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--ink3)"},children:i.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",children:i.jsx("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})})})]}),i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[s.size>0?i.jsx($e,{label:`${l.length} processed`,tone:"var(--green)"}):i.jsx($e,{label:"not yet processed"}),Array.from(s).slice(0,3).map(a=>i.jsx($e,{label:a,tone:Rs(a)},a))]}),l.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>o(a=>!a),style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",background:"transparent",border:0,padding:0,textAlign:"left",cursor:"pointer",letterSpacing:.4},children:r?"▾ hide processing feed":`▸ show processing feed (${l.length})`}),r&&i.jsx("div",{style:{display:"flex",flexDirection:"column",borderTop:"1px dashed var(--border)",paddingTop:6},children:l.slice(0,8).map(a=>i.jsx(dg,{result:a},a.id))})]})]})}function cg({workspace:e,project:t,onActivity:n}){const[r,o]=v.useState([]),[l,s]=v.useState(!1),[a,d]=v.useState(null),[c,g]=v.useState("idle"),[m,x]=v.useState(""),[S,E]=v.useState(!1),[T,H]=v.useState(null),h=v.useRef(null),u=v.useMemo(()=>t?t.name:e?`${e.label||e.name} (workspace)`:"—",[t,e]),f=v.useCallback(async()=>{if(!e){o([]);return}s(!0),d(null);try{const R=t?await B.listProjectAssets(t.id):await B.listWorkspaceAssets(e.id,!1);o(R.assets||[])}catch(R){d(String(R))}finally{s(!1)}},[t,e]);v.useEffect(()=>{f()},[f]),v.useEffect(()=>{if(!e)return;const R=window.setInterval(()=>void f(),5e3);return()=>window.clearInterval(R)},[f,e]);const p=v.useCallback(async R=>{if(!e)return;const J=Array.from(R);if(J.length!==0){g("uploading"),x(`uploading ${J.length} file${J.length===1?"":"s"}…`),d(null);try{for(const X of J)t?await B.uploadProjectAsset(t.id,X):await B.uploadWorkspaceAsset(e.id,X);g("success"),x(J.length===1?`uploaded ${J[0].name}`:`uploaded ${J.length} files`),await f(),n==null||n()}catch(X){g("error"),x(String(X))}finally{window.setTimeout(()=>{g("idle"),x("")},2200)}}},[t,e,f,n]),j=R=>{var X;R.preventDefault(),R.stopPropagation(),E(!1);const J=R.dataTransfer;(X=J==null?void 0:J.files)!=null&&X.length&&p(J.files)},_=R=>{var J;e&&(R.preventDefault(),R.stopPropagation(),(J=R.dataTransfer.types)!=null&&J.includes("Files")&&!S&&E(!0))},P=R=>{R.currentTarget===R.target&&E(!1)},z=R=>{const J=R.target.files;J!=null&&J.length&&p(J),R.target.value=""},Q=async R=>{if(window.confirm(`Remove "${R.name}"?`)){H(R.id);try{await B.deleteProjectAsset(R.id),o(J=>J.filter(X=>X.id!==R.id)),n==null||n()}catch(J){d(String(J))}finally{H(null)}}};return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},onDrop:j,onDragOver:_,onDragLeave:P,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.5,color:"var(--ink3)",textTransform:"uppercase"},children:[i.jsxs("span",{children:["Assets · ",u]}),i.jsx("span",{children:r.length})]}),i.jsxs("div",{onClick:()=>{var R;return e&&((R=h.current)==null?void 0:R.click())},style:{padding:"16px 14px",border:`1px dashed ${S?"var(--accent)":"var(--border)"}`,background:S?"rgba(224,107,63,0.06)":"white",borderRadius:6,textAlign:"center",cursor:e?"pointer":"not-allowed",opacity:e?1:.55,transition:"background 0.18s ease, border-color 0.18s ease"},children:[i.jsx("input",{ref:h,type:"file",multiple:!0,style:{display:"none"},onChange:z}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:S?"var(--accent)":"var(--ink2)",fontWeight:500,marginBottom:4},children:c==="uploading"?m:S?"release to upload":"drop files here or click to upload"}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:.4},children:t?"visible to every agent working on this project":e?"workspace-wide — every project sees it":"select a workspace first"})]}),c==="success"&&i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--green)",lineHeight:1.4},children:m}),c==="error"&&i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--rose)",lineHeight:1.4},children:m}),a&&c!=="error"?i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--rose)",lineHeight:1.4},children:a}):null,l&&r.length===0?i.jsx("div",{style:{display:"grid",gap:8},children:[0,1,2].map(R=>i.jsx("div",{style:{height:66,borderRadius:6,background:"linear-gradient(90deg, rgba(20,16,10,0.04) 0%, rgba(20,16,10,0.08) 50%, rgba(20,16,10,0.04) 100%)",backgroundSize:"200% 100%",animation:`dhee-shimmer 1.4s linear ${R*140}ms infinite`,border:"1px solid rgba(20,16,10,0.06)"}},R))}):r.length===0?i.jsxs("div",{style:{padding:14,border:"1px dashed var(--border)",borderRadius:6,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55,background:"white"},children:["No assets yet. Drop a spec PDF, design export, or schema doc here — every agent in this",t?" project":" workspace"," will see it."]}):i.jsx("div",{style:{display:"grid",gap:8},children:r.map(R=>i.jsx(ug,{asset:R,onDelete:Q,busyDelete:T===R.id},R.id))})]})}const Tu=6e4,zu=36e5,Ru=864e5;function dp(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return String(e);const n=Date.now()-t;return n{const l=String(o.runtime||"unknown").toLowerCase(),s=n.get(l)||{count:0,latestUpdate:null,isLive:!1};s.count+=1,o.updatedAt&&(!s.latestUpdate||o.updatedAt>s.latestUpdate)&&(s.latestUpdate=o.updatedAt),(o.isCurrent||o.state==="active"||o.state==="recent")&&(s.isLive=!0),n.set(l,s)};for(const o of t||[])r(o);for(const o of e||[])for(const l of o.sessions||[])r(l);return Array.from(n.entries()).map(([o,l])=>({runtime:o,...l})).sort((o,l)=>l.count-o.count)}function gg({workspace:e,projects:t,workspaceSessions:n}){const r=v.useMemo(()=>hg(t,n),[t,n]),o=r.reduce((l,s)=>l+s.count,0);return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:14},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:10},children:[i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:["Connected agents · ",o]}),e?i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:e.label||e.name}):null]}),r.length===0?i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55},children:"No agent sessions yet. Launch claude-code or codex in this workspace — they will register here and start publishing to the line."}):i.jsx("div",{style:{display:"grid",gap:6},children:r.map(l=>i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:l.isLive?"var(--green)":"var(--ink3)",boxShadow:l.isLive?"0 0 0 3px rgba(31,169,113,0.18)":"none",flexShrink:0}}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:11,color:up(l.runtime),whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:l.runtime}),i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:["· ",l.count]})]}),l.latestUpdate?i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:dp(l.latestUpdate)}):null]},l.runtime))})]})}function cp({message:e,workspace:t,onOpenTask:n}){var m,x;const r=((m=t==null?void 0:t.projects.find(S=>S.id===e.project_id))==null?void 0:m.name)||"workspace",o=((x=t==null?void 0:t.projects.find(S=>S.id===e.target_project_id))==null?void 0:x.name)||"",l=e.metadata||{},s=String(l.harness||l.runtime||""),a=String(l.tool_name||l.toolName||""),d=String(l.ptr||""),c=e.body||"",g=pg(e.message_kind);return i.jsxs("div",{style:{border:"1px solid var(--border)",borderLeft:`3px solid ${g}`,background:"white",padding:"11px 13px"},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:10,marginBottom:6},children:[i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:up(s),letterSpacing:.4},children:[fg(e.created_at),s?` · ${s}`:"",r!=="workspace"?` · ${r}`:""]}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:dp(e.created_at)})]}),e.title?i.jsx("div",{style:{fontSize:13,fontWeight:600,marginBottom:5,lineHeight:1.35},children:e.title}):null,c?i.jsx("div",{style:{fontSize:12,color:"var(--ink2)",lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:c}):null,i.jsxs("div",{style:{display:"flex",gap:5,flexWrap:"wrap",marginTop:8},children:[i.jsx($e,{label:mg(e.message_kind),tone:g}),a?i.jsx($e,{label:a.toLowerCase()}):null,o?i.jsx($e,{label:`→ ${o}`,tone:"#4d6cff"}):null,d?i.jsx($e,{label:d}):null,e.task_id&&n?i.jsx("button",{onClick:()=>n(String(e.task_id)),style:{padding:"2px 8px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.4,textTransform:"uppercase",cursor:"pointer"},children:"open task"}):null]})]})}function fp({workspace:e,activeProjectId:t,sessionId:n,taskId:r,onPublished:o}){var P;const[l,s]=v.useState(""),[a,d]=v.useState(""),[c,g]=v.useState(""),[m,x]=v.useState(!1),[S,E]=v.useState(null),[T,H]=v.useState(null),h=v.useRef(null);v.useEffect(()=>{var z;(z=h.current)==null||z.focus()},[e==null?void 0:e.id]);const u=v.useMemo(()=>((e==null?void 0:e.projects)||[]).filter(z=>!t||z.id!==t),[e==null?void 0:e.projects,t]),f=async()=>{var z;if(!(!(e!=null&&e.id)||!a.trim()||m)){x(!0),H(null),E(null);try{const Q=await B.publishWorkspaceLineMessage(e.id,{project_id:t||void 0,target_project_id:c||void 0,channel:t?"project":"workspace",session_id:n||void 0,task_id:r||void 0,message_kind:c?"broadcast":"note",title:l.trim()||void 0,body:a.trim(),metadata:{sourceProject:(z=e.projects.find(R=>R.id===t))==null?void 0:z.name}});if(Q.suggestedTask){const R=e.projects.find(J=>J.id===c);E(R?`Broadcast sent · suggested task created in ${R.name}.`:"Broadcast sent · suggested task created.")}else E("Published to the workspace line.");s(""),d(""),g(""),o==null||o(Q.message,Q.suggestedTask)}catch(Q){H(String(Q))}finally{x(!1)}}};if(!e)return i.jsx("div",{style:{padding:16,border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",background:"white"},children:"No workspace selected."});const p=!a.trim()||m,j=(P=u.find(z=>z.id===c))==null?void 0:P.name,_=m?"publishing…":c?`broadcast → ${j||"project"}`:"publish update";return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:14,display:"flex",flexDirection:"column",gap:8},children:[i.jsx("input",{value:l,onChange:z=>s(z.target.value),placeholder:"headline (optional) — e.g. user.plan field added",style:{border:"1px solid var(--border)",padding:"9px 11px",background:"var(--bg)",fontSize:13}}),i.jsxs("select",{value:c,onChange:z=>g(z.target.value),style:{border:"1px solid var(--border)",padding:"9px 11px",background:"var(--bg)",fontFamily:"var(--mono)",fontSize:10},children:[i.jsxs("option",{value:"",children:["Publish to current ",t?"project":"workspace"," only"]}),u.map(z=>i.jsxs("option",{value:z.id,children:["Broadcast into ",z.name," (creates task)"]},z.id))]}),i.jsx("textarea",{ref:h,value:a,onChange:z=>d(z.target.value),placeholder:c?"What should the target project's agent know? It will spawn a task with this context.":"Broadcast a dependency change, a tool result, or a follow-up signal to the workspace line…",rows:4,onKeyDown:z=>{(z.metaKey||z.ctrlKey)&&z.key==="Enter"&&(z.preventDefault(),f())},style:{border:"1px solid var(--border)",padding:"10px 12px",background:"var(--bg)",fontSize:13,lineHeight:1.55,resize:"vertical"}}),i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:10},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:.3},children:"⌘/Ctrl + Enter to publish"}),i.jsx("button",{onClick:()=>void f(),disabled:p,style:{padding:"8px 14px",border:"1px solid var(--ink)",background:p?"var(--ink3)":"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10,letterSpacing:.4,opacity:p?.7:1,cursor:p?"not-allowed":"pointer"},children:_})]}),S?i.jsx("div",{style:{fontSize:11,color:"var(--green)",lineHeight:1.5},children:S}):null,T?i.jsx("div",{style:{fontSize:11,color:"var(--rose)",lineHeight:1.5},children:T}):null]})}function pp(e,t){const[n,r]=v.useState([]),[o,l]=v.useState(!1),[s,a]=v.useState(null),d=g=>{r(m=>{const x=new Map;return[...g,...m].forEach(S=>{S!=null&&S.id&&x.set(S.id,S)}),Array.from(x.values()).sort((S,E)=>String(E.created_at||"").localeCompare(String(S.created_at||"")))})},c=async()=>{if(!e){r([]);return}try{const g=await B.workspaceLineMessages(e,{project_id:t||void 0,limit:100});r(g.messages||[])}catch(g){a(String(g))}};return v.useEffect(()=>{c()},[e,t]),v.useEffect(()=>{if(!e){l(!1);return}const g=new URLSearchParams;t&&g.set("project_id",t);const m=new EventSource(`/api/workspaces/${encodeURIComponent(e)}/line/stream${g.toString()?`?${g.toString()}`:""}`);return m.onopen=()=>l(!0),m.onmessage=x=>{try{const S=JSON.parse(x.data);d([S])}catch{}},m.onerror=()=>{l(!1),m.close()},()=>{m.close(),l(!1)}},[e,t]),{messages:n,live:o,error:s,merge:d,refresh:c}}function vg(e,t){if(!e)return[];const n=new Set(e.projects.map(r=>r.id));return t.filter(r=>{const o=String(r.source||"").toLowerCase();if(o!=="broadcast"&&!o.includes("suggested"))return!1;const l=r.project_id;return!l||n.has(String(l))})}function yg({projectIndex:e,workspaceGraph:t,tasks:n,viewer:r,orgGraph:o,selectedWorkspaceId:l,selectedProjectId:s,onSelectWorkspace:a,onSelectProject:d,onSelectTask:c,onTasksRefresh:g,onOpenCanvas:m,onLaunchSession:x,onOpenManager:S}){var A,W,ee,ie,D,fe,se,me;const E=(e==null?void 0:e.workspaces)||[],[T,H]=v.useState(null),h=v.useMemo(()=>{var he;const $=((he=o==null?void 0:o.raw)==null?void 0:he.context_index)||[],de=(r==null?void 0:r.team_id)||"",ce=(r==null?void 0:r.project_id)||"";return $.filter(_e=>!!(_e.scope==="company"||de&&_e.team_id===de||ce&&_e.project_id===ce||_e.scope==="user"&&_e.user_id===(r==null?void 0:r.user_id)))},[(A=o==null?void 0:o.raw)==null?void 0:A.context_index,r==null?void 0:r.project_id,r==null?void 0:r.team_id,r==null?void 0:r.user_id]),u=v.useMemo(()=>{var ce;const $=((ce=o==null?void 0:o.raw)==null?void 0:ce.pending_proposals)||[],de=(r==null?void 0:r.team_id)||"";return de?$.filter(he=>!he.team_id||he.team_id===de):$},[(W=o==null?void 0:o.raw)==null?void 0:W.pending_proposals,r==null?void 0:r.team_id]),[f,p]=v.useState("all"),j=v.useMemo(()=>E.find($=>$.id===l)||E.find($=>$.id===(e==null?void 0:e.currentWorkspaceId))||E[0]||(t==null?void 0:t.workspace)||null,[E,l,e==null?void 0:e.currentWorkspaceId,t]),_=v.useMemo(()=>j&&(j.projects.find($=>$.id===s)||j.projects.find($=>$.id===(e==null?void 0:e.currentProjectId)))||null,[j,s,e==null?void 0:e.currentProjectId]),P=(j==null?void 0:j.sessions)||[],z=v.useMemo(()=>{var ce,he;const $=e==null?void 0:e.currentSessionId;if(!j)return null;const de=((ce=_==null?void 0:_.sessions)==null?void 0:ce.find(_e=>_e.id===$))||((he=_==null?void 0:_.sessions)==null?void 0:he[0]);return de||P.find(_e=>_e.id===$)||P[0]||null},[j,_,e==null?void 0:e.currentSessionId,P]),{messages:Q,live:R,error:J,refresh:X}=pp(j==null?void 0:j.id,_==null?void 0:_.id);v.useEffect(()=>{let $=!0;return B.continuity().then(de=>{$&&H(de)}).catch(()=>{$&&H(null)}),()=>{$=!1}},[r==null?void 0:r.org_id,r==null?void 0:r.team_id]);const K=v.useMemo(()=>f==="all"?Q:Q.filter($=>{const de=String($.message_kind||"").toLowerCase();return f==="broadcast"?de==="broadcast":f==="tool"?de.startsWith("tool."):f==="note"?de==="note"||de==="update":!0}),[Q,f]),G=v.useMemo(()=>vg(j,n),[j,n]),[M,V]=v.useState(null);v.useEffect(()=>{var de;const $=(de=Q[0])==null?void 0:de.id;$&&$!==M&&V($)},[Q,M]);const ye=$=>({padding:"5px 10px",border:`1px solid ${$?"var(--ink)":"var(--border)"}`,background:$?"var(--ink)":"white",color:$?"white":"var(--ink2)",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.5,textTransform:"uppercase",cursor:"pointer"}),C=$=>({width:"100%",textAlign:"left",padding:"9px 10px",border:`1px solid ${$?"var(--accent)":"var(--border)"}`,background:$?"var(--surface)":"white",fontFamily:$?"var(--sans)":"var(--mono)",fontSize:$?12:11,color:"var(--ink)",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",gap:8});return i.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{height:48,borderBottom:"1px solid var(--border)",padding:"0 20px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0},children:[i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[(j==null?void 0:j.label)||(j==null?void 0:j.name)||"channel",_?` / ${_.name}`:""]}),i.jsx($e,{label:R?"live":"offline",tone:R?"var(--green)":"var(--ink3)"}),i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[K.length," events · ",G.length," suggested tasks"]}),i.jsx($e,{label:`${(r==null?void 0:r.role)||"developer"} context`,tone:(r==null?void 0:r.role)==="manager"||(r==null?void 0:r.role)==="admin"?"var(--accent)":"var(--indigo)"})]}),i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[i.jsx("button",{onClick:m,style:{padding:"6px 12px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink2)",background:"white",cursor:"pointer",letterSpacing:.4},children:"open canvas"}),i.jsx("button",{onClick:()=>void X(),style:{padding:"6px 12px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink2)",background:"white",cursor:"pointer",letterSpacing:.4},children:"refresh"})]})]}),i.jsxs("div",{style:{flex:1,display:"grid",gridTemplateColumns:"260px minmax(0, 1fr) 360px",overflow:"hidden"},children:[i.jsxs("div",{style:{borderRight:"1px solid var(--border)",padding:16,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[i.jsxs("div",{style:{padding:12,border:"1px solid var(--border)",background:"var(--surface)",display:"grid",gap:8},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Context scope"}),i.jsx("div",{style:{fontSize:13,color:"var(--ink)"},children:(r==null?void 0:r.team_id)||(r==null?void 0:r.project_id)||(r==null?void 0:r.org_id)||"local dhee"}),i.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[i.jsxs("span",{children:[h.length," context items"]}),i.jsx("span",{children:"·"}),i.jsxs("span",{children:[u.length," pending"]})]}),i.jsx("button",{onClick:m,style:{padding:"6px 8px",border:"1px solid var(--accent)",background:"var(--accent-dim)",color:"var(--accent)",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.5,cursor:"pointer"},children:"OPEN ORG MAP"})]}),i.jsxs("div",{style:{padding:12,border:"1px solid var(--border)",background:"white",display:"grid",gap:8},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Continue context"}),i.jsx("div",{style:{fontSize:12,color:"var(--ink2)",lineHeight:1.45},children:((ee=T==null?void 0:T.last_session)==null?void 0:ee.task_summary)||((D=(ie=T==null?void 0:T.claude_sessions)==null?void 0:ie[0])==null?void 0:D.preview)||"No Claude session recovered yet for this repo."}),i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[i.jsx("span",{children:((fe=T==null?void 0:T.last_session)==null?void 0:fe.source)||"waiting"}),i.jsx("span",{children:"·"}),i.jsxs("span",{children:[((se=T==null?void 0:T.claude_sessions)==null?void 0:se.length)||0," claude sessions"]})]})]}),i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8,gap:8},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Workspace"}),S?i.jsx("button",{onClick:()=>S("workspaces"),title:"Manage workspaces",style:{padding:"3px 7px",border:"1px solid var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.4,color:"var(--ink3)",cursor:"pointer"},children:"+ new / manage"}):null]}),E.length===0?i.jsx("button",{onClick:()=>S==null?void 0:S("workspaces"),style:{width:"100%",padding:"10px 12px",border:"1px dashed var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink2)",textAlign:"left",cursor:"pointer",lineHeight:1.5},children:"Create your first workspace → e.g. Office, Personal, Sankhya AI Labs."}):i.jsx("select",{value:(j==null?void 0:j.id)||"",onChange:$=>a($.target.value),style:{width:"100%",padding:"9px 10px",border:"1px solid var(--border)",background:"white",fontSize:12},children:E.map($=>i.jsx("option",{value:$.id,children:$.label||$.name},$.id))})]}),i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8,gap:8},children:[i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:["Projects · ",((me=j==null?void 0:j.projects)==null?void 0:me.length)||0]}),S&&j?i.jsx("button",{onClick:()=>S("projects"),title:"Add or edit projects",style:{padding:"3px 7px",border:"1px solid var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.4,color:"var(--ink3)",cursor:"pointer"},children:"+ project"}):null]}),i.jsxs("div",{style:{display:"grid",gap:6},children:[i.jsxs("button",{onClick:()=>d("",j==null?void 0:j.id),style:C(!_),children:[i.jsx("span",{children:"All projects (workspace line)"}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:P.length})]}),((j==null?void 0:j.projects)||[]).map($=>{var he;const de=$.id===(_==null?void 0:_.id),ce=((he=$.sessions)==null?void 0:he.length)||0;return i.jsxs("button",{onClick:()=>d($.id,j==null?void 0:j.id),style:C(de),children:[i.jsx("span",{children:$.name}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:ce})]},$.id)})]})]}),i.jsx(gg,{workspace:j,projects:(j==null?void 0:j.projects)||[],workspaceSessions:P}),j&&i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Launch"}),i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[i.jsx("button",{onClick:()=>void x("channel session","codex",j.id,void 0,_==null?void 0:_.id),style:ye(!1),children:"+ codex"}),i.jsx("button",{onClick:()=>void x("channel session","claude-code",j.id,"standard",_==null?void 0:_.id),style:ye(!1),children:"+ claude"})]})]})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--bg)"},children:[i.jsxs("div",{style:{padding:"12px 20px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Shared line"}),i.jsx("button",{onClick:()=>p("all"),style:ye(f==="all"),children:"all"}),i.jsx("button",{onClick:()=>p("broadcast"),style:ye(f==="broadcast"),children:"broadcasts"}),i.jsx("button",{onClick:()=>p("tool"),style:ye(f==="tool"),children:"tool events"}),i.jsx("button",{onClick:()=>p("note"),style:ye(f==="note"),children:"notes"}),i.jsx("span",{style:{flex:1}}),J?i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--rose)"},children:J}):null]}),i.jsx("div",{style:{flex:1,overflowY:"auto",padding:20,display:"flex",flexDirection:"column",gap:10},children:K.length===0?i.jsxs("div",{style:{padding:24,border:"1px dashed var(--border)",background:"white",textAlign:"center"},children:[i.jsx("div",{style:{fontSize:13,fontWeight:600,marginBottom:6},children:"The line is quiet."}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55},children:"Every agent tool-call in this workspace will appear here. Launch a session from the left rail, or broadcast a note from the composer to get started."})]}):K.map($=>i.jsx(cp,{message:$,workspace:j,onOpenTask:c},$.id))})]}),i.jsxs("div",{style:{borderLeft:"1px solid var(--border)",padding:16,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Broadcast"}),i.jsx(fp,{workspace:j,activeProjectId:_==null?void 0:_.id,sessionId:z==null?void 0:z.id,onPublished:async()=>{await g(),X()}}),i.jsx(cg,{workspace:j,project:_,onActivity:()=>void X()}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase",marginTop:2},children:["Suggested tasks · ",G.length]}),i.jsx("div",{style:{display:"grid",gap:8},children:G.length===0?i.jsx("div",{style:{padding:12,border:"1px dashed var(--border)",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55,background:"white"},children:"When an agent broadcasts to another project, a task is auto-created there. It will show up here."}):G.slice(0,10).map($=>i.jsxs("button",{onClick:()=>c($.id),style:{textAlign:"left",padding:"10px 12px",border:"1px solid var(--border)",background:"white",cursor:"pointer",display:"flex",flexDirection:"column",gap:6},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,lineHeight:1.35},children:$.title}),i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[i.jsx($e,{label:$.status||"active",tone:"var(--accent)"}),$.harness?i.jsx($e,{label:String($.harness)}):null]})]},$.id))})]})]})]})}const xg={live:!1,proposals:[],findings:[],conflicts:[],totals:{proposals:0,findings:0,conflicts:0}};function Pu(e){return e==="high"?"var(--rose)":e==="medium"?"var(--accent)":"var(--indigo)"}function Sg(e){const t=e.summary||e.content||"";return t.length>260?`${t.slice(0,260)}...`:t}function kg({viewer:e,onChanged:t}){var T,H,h;const[n,r]=v.useState(xg),[o,l]=v.useState(null),[s,a]=v.useState(null),[d,c]=v.useState(null),g=async()=>{try{const u=await B.inbox(e!=null&&e.team_id?{team:e.team_id,user:e.user_id}:{user:e==null?void 0:e.user_id});r(u),l(f=>{var p,j,_,P,z,Q;return f||((j=(p=u.proposals)==null?void 0:p[0])==null?void 0:j.context_id)||((P=(_=u.findings)==null?void 0:_[0])==null?void 0:P.finding_id)||String(((Q=(z=u.conflicts)==null?void 0:z[0])==null?void 0:Q.id)||"")||null})}catch(u){c(u instanceof Error?u.message:String(u))}};v.useEffect(()=>{g();const u=window.setInterval(()=>void g(),6e3);return()=>window.clearInterval(u)},[e==null?void 0:e.team_id,e==null?void 0:e.user_id]);const m=v.useMemo(()=>{var u,f,p;return(((u=n.totals)==null?void 0:u.proposals)||0)+(((f=n.totals)==null?void 0:f.findings)||0)+(((p=n.totals)==null?void 0:p.conflicts)||0)},[n.totals]),x=async(u,f)=>{a(`${f}:${u.context_id}`),c(null);try{f==="approve"?await B.approveProposal(u.context_id,(e==null?void 0:e.user_id)||"manager"):await B.rejectProposal(u.context_id,(e==null?void 0:e.user_id)||"manager"),await g(),await(t==null?void 0:t())}catch(p){c(p instanceof Error?p.message:String(p))}finally{a(null)}},S=async u=>{a(`finding:${u.finding_id}`),c(null);try{await B.resolveFinding(u.finding_id,(e==null?void 0:e.user_id)||"manager"),await g(),await(t==null?void 0:t())}catch(f){c(f instanceof Error?f.message:String(f))}finally{a(null)}},E=async(u,f)=>{const p=String(u.id||"");if(p){a(`conflict:${p}:${f}`),c(null);try{await B.resolveConflictDetailed(p,{action:f}),await g(),await(t==null?void 0:t())}catch(j){c(j instanceof Error?j.message:String(j))}finally{a(null)}}};return i.jsxs("div",{style:{display:"flex",height:"100%",minHeight:0},children:[i.jsxs("aside",{style:{width:300,borderRight:"1px solid var(--border)",background:"white",padding:16,overflowY:"auto",flexShrink:0},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",letterSpacing:"0.08em",textTransform:"uppercase"},children:"Inbox"}),i.jsxs("div",{style:{fontSize:22,fontWeight:650,marginTop:6},children:[m," open"]}),i.jsxs("div",{style:{marginTop:10,display:"grid",gap:8,fontFamily:"var(--mono)",fontSize:10},children:[i.jsx(Tl,{label:"Proposals",value:((T=n.totals)==null?void 0:T.proposals)||0}),i.jsx(Tl,{label:"Findings",value:((H=n.totals)==null?void 0:H.findings)||0}),i.jsx(Tl,{label:"Conflicts",value:((h=n.totals)==null?void 0:h.conflicts)||0})]}),i.jsx("div",{style:{marginTop:18,padding:12,border:"1px solid var(--border)",background:"var(--surface)",fontSize:12,lineHeight:1.5,color:"var(--ink2)"},children:"Review context changes, stale-context findings, and memory conflicts from one queue. Approvals activate context used by routing."}),d?i.jsx("div",{style:{marginTop:12,padding:10,border:"1px solid var(--rose)",background:"var(--rose-dim)",color:"var(--rose)",fontFamily:"var(--mono)",fontSize:10,lineHeight:1.5},children:d}):null]}),i.jsxs("main",{style:{flex:1,minWidth:0,overflowY:"auto",background:"var(--bg)",padding:18,display:"grid",gap:16,alignContent:"start"},children:[i.jsx(zl,{title:"Pending Proposals",count:n.proposals.length,empty:"No context edits are waiting for approval.",children:n.proposals.map(u=>i.jsxs("article",{onClick:()=>l(u.context_id),style:Fl(o===u.context_id),children:[i.jsxs("div",{style:Rl,children:[i.jsxs("div",{children:[i.jsx("div",{style:Nl,children:u.title}),i.jsxs("div",{style:Pl,children:[u.proposed_by_user_id||"developer"," · ",u.team_id||u.project_id||u.scope]})]}),i.jsx(uo,{color:"var(--accent)",children:"pending"})]}),i.jsx("p",{style:Lu,children:Sg(u)||"No preview available."}),i.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[i.jsx(Or,{label:"Open in Context",onClick:f=>{f.stopPropagation(),window.location.hash=`#vault/item/${u.context_id}`,window.history.replaceState(null,"",`?view=context${window.location.hash}`),window.dispatchEvent(new PopStateEvent("popstate"))}}),i.jsx(Or,{label:"Reject",color:"var(--rose)",busy:s===`reject:${u.context_id}`,onClick:f=>{f.stopPropagation(),x(u,"reject")}}),i.jsx(Or,{label:"Approve",color:"var(--green)",busy:s===`approve:${u.context_id}`,onClick:f=>{f.stopPropagation(),x(u,"approve")}})]})]},u.context_id))}),i.jsx(zl,{title:"Manager Findings",count:n.findings.length,empty:"No stale, low-quality, or duplicate context findings.",children:n.findings.map(u=>i.jsxs("article",{onClick:()=>l(u.finding_id),style:Fl(o===u.finding_id),children:[i.jsxs("div",{style:Rl,children:[i.jsxs("div",{children:[i.jsx("div",{style:Nl,children:u.title}),i.jsxs("div",{style:Pl,children:[u.team_id," · ",u.finding_type]})]}),i.jsx(uo,{color:Pu(u.severity),children:u.severity})]}),i.jsx("p",{style:Lu,children:u.detail}),i.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:i.jsx(Or,{label:"Resolve",color:"var(--green)",busy:s===`finding:${u.finding_id}`,onClick:f=>{f.stopPropagation(),S(u)}})})]},u.finding_id))}),i.jsx(zl,{title:"Memory Conflicts",count:n.conflicts.length,empty:"No memory contradictions detected.",children:n.conflicts.map(u=>{var j,_;const f=u,p=String(f.id||Math.random());return i.jsxs("article",{onClick:()=>l(p),style:Fl(o===p),children:[i.jsxs("div",{style:Rl,children:[i.jsxs("div",{children:[i.jsx("div",{style:Nl,children:"Memory conflict"}),i.jsx("div",{style:Pl,children:f.reason||"Contradiction"})]}),i.jsx(uo,{color:Pu(f.severity),children:f.severity||"open"})]}),i.jsxs("div",{style:{display:"grid",gap:6,marginTop:10},children:[i.jsx(Fu,{label:"A",text:(j=f.belief_a)==null?void 0:j.content}),i.jsx(Fu,{label:"B",text:(_=f.belief_b)==null?void 0:_.content})]}),i.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:10},children:["KEEP A","KEEP B","MERGE"].map(P=>i.jsx(Or,{label:P,busy:s===`conflict:${p}:${P}`,onClick:z=>{z.stopPropagation(),E(u,P)}},P))})]},p)})})]})]})}function Tl({label:e,value:t}){return i.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[i.jsx("span",{style:{color:"var(--ink3)"},children:e}),i.jsx("span",{style:{color:t?"var(--accent)":"var(--ink2)"},children:t})]})}function zl({title:e,count:t,empty:n,children:r}){return i.jsxs("section",{style:{display:"grid",gap:10},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.08em",color:"var(--ink3)",textTransform:"uppercase"},children:[i.jsx("span",{children:e}),i.jsx(uo,{children:t})]}),t===0?i.jsx("div",{style:{border:"1px dashed var(--border)",background:"white",color:"var(--ink3)",padding:16,fontSize:12},children:n}):r]})}function uo({children:e,color:t="var(--ink3)"}){return i.jsx("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 7px",border:`1px solid ${t}`,color:t,background:"white",borderRadius:3,fontFamily:"var(--mono)",fontSize:9},children:e})}function Or({label:e,onClick:t,color:n="var(--ink2)",busy:r}){return i.jsx("button",{onClick:t,disabled:r,style:{padding:"6px 9px",border:`1px solid ${n}`,color:n,background:"white",fontFamily:"var(--mono)",fontSize:9,borderRadius:3,cursor:r?"wait":"pointer"},children:r?"...":e})}function Fu({label:e,text:t}){return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"var(--surface)",padding:10,display:"grid",gridTemplateColumns:"20px minmax(0, 1fr)",gap:8},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",color:"var(--ink3)"},children:e}),i.jsx("span",{style:{color:"var(--ink2)",fontSize:12,lineHeight:1.5},children:t||"No content"})]})}const Rl={display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:12},Nl={fontSize:15,fontWeight:650,color:"var(--ink)"},Pl={fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginTop:3},Lu={margin:"10px 0",color:"var(--ink2)",fontSize:12,lineHeight:1.55};function Fl(e){return{border:`1px solid ${e?"var(--accent)":"var(--border)"}`,background:"white",padding:14,boxShadow:e?"0 10px 24px rgba(20,16,10,0.06)":"none",cursor:"pointer"}}const jg={"&":"&","<":"<",">":">",'"':""","'":"'"};function ti(e){return e.replace(/[&<>"']/g,t=>jg[t]||t)}function wg(e){const t=e.trim();return/^(https?:|mailto:|#|\/)/i.test(t)?t:"#"}function Cn(e,t){let n=ti(e);return n=n.replace(/`([^`]+)`/g,(r,o)=>`${o}`),n=n.replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(r,o,l)=>{const s=(l||o).trim(),a=t?t(o.trim()):null;return a?`${s}`:`${s}`}),n=n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,o,l)=>`${o}`),n=n.replace(/\*\*([^*]+)\*\*/g,"$1"),n=n.replace(/(^|[^*])\*([^*]+)\*/g,"$1$2"),n}function Cg({source:e,wikiResolve:t}){const n=(e||"").replace(/\r\n/g,` -`).split(` -`),r=[];let o=0;for(;o${ti(d.join(` -`))}`);continue}if(/^### /.test(l)){r.push(`

${Cn(l.slice(4),t)}

`),o+=1;continue}if(/^## /.test(l)){r.push(`

${Cn(l.slice(3),t)}

`),o+=1;continue}if(/^# /.test(l)){r.push(`

${Cn(l.slice(2),t)}

`),o+=1;continue}if(/^>\s?/.test(l)){const a=[];for(;o\s?/.test(n[o]);)a.push(n[o].replace(/^>\s?/,"")),o+=1;r.push(`
${Cn(a.join(" "),t)}
`);continue}if(/^\s*[-*]\s/.test(l)){const a=[];for(;o${Cn(n[o].replace(/^\s*[-*]\s/,""),t)}`),o+=1;r.push(`
    ${a.join("")}
`);continue}if(/^\s*\d+\.\s/.test(l)){const a=[];for(;o${Cn(n[o].replace(/^\s*\d+\.\s/,""),t)}`),o+=1;r.push(`
    ${a.join("")}
`);continue}if(l.trim()===""){o+=1;continue}const s=[l];for(o+=1;o\s?)/.test(n[o]);)s.push(n[o]),o+=1;r.push(`

${Cn(s.join(` -`),t)}

`)}return i.jsx("div",{className:"md-root",style:{fontFamily:"var(--font)",fontSize:13.5,lineHeight:1.55,color:"var(--ink)"},dangerouslySetInnerHTML:{__html:r.join("")}})}const Ki={title:"",content:"",scope:"team",kind:"note",project_id:"",team_id:"",tags:""},bg=["user","company","global_team","project","team","agent"],Ou={items:[],next_cursor:null,active_only:!1,totals:{tokens_saved:0,estimated_cost_saved_usd:0,router_calls:0,sessions:0}},$u={live:!1,items:[],totals:{contexts:0,used_contexts:0,usage_count:0,tokens_served:0,proven_tokens_saved:0,theoretical_api_value_usd:0,realized_cost_saved_usd:0}};function _g(e){return{...e,tags:Array.isArray(e.tags)?e.tags:[]}}function Du(e){return(e==null?void 0:e.role)==="manager"||(e==null?void 0:e.role)==="admin"?e.team_id?{...Ki,scope:"team",team_id:e.team_id,project_id:e.project_id||""}:e.project_id?{...Ki,scope:"project",project_id:e.project_id}:{...Ki,scope:"company"}:{...Ki,scope:"user",user_id:e==null?void 0:e.user_id}}function Eg(e){return{title:e.title||"Untitled context",content:e.content||e.summary||"",scope:e.scope||"team",kind:e.kind||"note",project_id:e.project_id||"",team_id:e.team_id||"",tags:(e.tags||[]).join(", ")}}function Tg(e){return{title:ba(e),content:e.content||"",scope:"memory",kind:e.tier,project_id:"",team_id:"",tags:(e.tags||[]).join(", ")}}function Mu(e,t,n){return(e==null?void 0:e.role)==="admin"||(e==null?void 0:e.role)==="manager"?!0:((t==null?void 0:t.scope)||(n==null?void 0:n.scope))==="user"?!(t!=null&&t.user_id)||t.user_id===(e==null?void 0:e.user_id):!1}function Iu(e){return e==="pending_review"?"var(--accent)":e==="rejected"||e==="inactive"?"var(--rose)":"var(--green)"}function Ll(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function zg(e){return e.team_id?e.team_id:e.project_id?e.project_id:e.user_id?"mine":e.scope}function Rg(e){return e==="user"?"Mine":e==="company"?"Company":e==="global_team"?"Global Teams":e==="project"?"Projects":e==="team"?"Teams":e==="agent"?"Agents":e}function Bu(e){return e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())}function ba(e){var n;return(e.content||"").split(/\r?\n/).map(r=>r.trim()).find(Boolean)||""||((n=e.tags)==null?void 0:n[0])||`${e.tier} memory`}function Ng(e){var l;const t=ba(e),n=t.match(/^([^>]{3,72})\s*>\s*.+$/);if(n!=null&&n[1])return n[1].trim();const r=[t,e.source,...e.tags||[]].join(" ").toLowerCase();if(r.includes("repository guideline")||r.includes("agents.md"))return"Repository Guidelines";if(r.startsWith("edited ")||r.includes("/users/")||r.includes("/tmp/"))return"File Edits";if(r.includes("session")||r.includes("continuity"))return"Session Continuity";const o=(l=e.tags)==null?void 0:l.find(s=>s&&s!==e.tier);return o?Bu(o):`${Bu(e.tier)} Memory`}function Pg(e){const t=ba(e),n=t.split(/\s*>\s*/);return(n.length>1?n.slice(1).join(" > "):t).slice(0,72)||"Memory"}function on(e){return!e||e<=0?"0":new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e)}function On(e){const t=Math.max(0,Number(e||0));return t>0&&t<.01?"<$0.01":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:t>=10?0:2}).format(t)}function Fg(e){const t=e.pricing;if(!t)return"PAYG input-token estimate";const n=t.input_cost_per_million,r=t.model_family||e.model||"model",o=t.provider||e.runtime||e.agent||"provider",l=typeof n=="number"?`$${n}/1M input tokens`:"input-token rate";return`${o} · ${r} · ${l}`}function Lg(e,t){const n=(t==null?void 0:t.usage_count)??e.usage_count??0,r=(t==null?void 0:t.proven_tokens_saved)??0,o=[`${e.kind} · ${zg(e)}`,`${n} use${n===1?"":"s"}`];return o.push(r>0?`${on(r)} proven saved`:"no proven $"),o.join(" · ")}function Og(e){const t=String(e.runtime||e.agent||"").toLowerCase();return t==="codex"?"var(--indigo)":t==="claude-code"||t==="claude"?"var(--accent)":"var(--green)"}function $g(e){const t=(e.title||"").trim();return t||(e.cwd||e.repo_root||"").split("/").filter(Boolean).pop()||e.session_id||"Session"}function Dg({onMemoryCountChange:e,viewer:t,orgGraph:n,onInboxChanged:r}){var wn,Ut,Z,ae,Se,le,Ee,Lt,Qn;const[o,l]=v.useState([]),[s,a]=v.useState([]),[d,c]=v.useState(null),[g,m]=v.useState(()=>Du(t||null)),[x,S]=v.useState(!1),[E,T]=v.useState(""),[H,h]=v.useState(null),[u,f]=v.useState(null),[p,j]=v.useState(!0),[_,P]=v.useState(null),[z,Q]=v.useState(Ou),[R,J]=v.useState($u),[X,K]=v.useState({}),[G,M]=v.useState(""),V=v.useRef({}),ye=async()=>{var w,b,k;try{const[O,I,ne,ve]=await Promise.all([B.listMemories().catch(Ue=>({live:!1,engrams:[],count:0,error:String(Ue)})),B.contextItems({limit:500}).catch(Ue=>({live:!1,items:[],error:String(Ue)})),B.routerSessions({active:!1,limit:50}).catch(()=>Ou),B.contextUsage({limit:500}).catch(()=>$u)]),Ke=(w=I.items)!=null&&w.length||!((b=n==null?void 0:n.raw)!=null&&b.context_index)?I.items||[]:n.raw.context_index,st=new Map((ve.items||[]).map(Ue=>[Ue.context_id,Ue]));l(Ke.map(_g).map(Ue=>{const Yn=st.get(Ue.context_id);return Yn?{...Ue,usage_count:Yn.usage_count,last_used_at:Yn.last_used_at,token_cost:Yn.token_cost}:Ue})),a(O.engrams||[]),Q(ne),J(ve),j(!!(O.live||I.live||n!=null&&n.live)),f(I.error||O.error||null),e==null||e(((k=O.engrams)==null?void 0:k.length)||0)}catch(O){f(O instanceof Error?O.message:String(O)),j(!1)}};v.useEffect(()=>{ye();const w=window.setInterval(()=>void ye(),6e3);return()=>window.clearInterval(w)},[]),v.useEffect(()=>{if(d)return;const w=decodeURIComponent(window.location.hash||""),b=w.startsWith("#vault/")?w.replace("#vault/","").trim():"",k=b?o.find(O=>O.team_id===b):null;if(k){c({kind:"context",id:k.context_id});return}if(o[0]){c({kind:"context",id:o[0].context_id});return}s[0]&&c({kind:"memory",id:s[0].id})},[o,s,d]);const C=(d==null?void 0:d.kind)==="context"&&o.find(w=>w.context_id===d.id)||null,A=(d==null?void 0:d.kind)==="memory"&&s.find(w=>w.id===d.id)||null;v.useEffect(()=>{if(C){m(Eg(C)),S(!1);return}if(A){m(Tg(A)),S(!1);return}(d==null?void 0:d.kind)==="new"&&(m(Du(t||null)),S(!0))},[C,A,d==null?void 0:d.kind,t]),v.useEffect(()=>{if(!C){P(null);return}let w=!0;return B.backlinks(C.context_id).then(b=>{w&&P(b)}).catch(()=>{w&&P(null)}),()=>{w=!1}},[C==null?void 0:C.context_id]);const W=v.useMemo(()=>{const w=E.trim().toLowerCase();return w?o.filter(b=>[b.title,b.summary,b.content,b.kind,b.scope,b.team_id,b.project_id,...b.tags||[]].filter(Boolean).join(" ").toLowerCase().includes(w)):o},[o,E]),ee=v.useMemo(()=>{const w=new Map;for(const b of bg)w.set(b,[]);for(const b of W){const k=b.scope||"team";w.set(k,[...w.get(k)||[],b])}return w},[W]),ie=v.useMemo(()=>{const w=E.trim().toLowerCase();return w?s.filter(b=>[b.content,b.source,b.tier,...b.tags||[]].filter(Boolean).join(" ").toLowerCase().includes(w)):s},[s,E]),D=v.useMemo(()=>{const w=new Map;for(const b of ie){const k=Ng(b);w.set(k,[...w.get(k)||[],b])}return new Map([...w.entries()].sort(([b],[k])=>b.localeCompare(k)))},[ie]),fe=v.useMemo(()=>{const w=[];for(const[b,k]of ee.entries())k.length!==0&&w.push({id:`context:${b}`,kind:"context",label:Rg(b),count:k.length,rows:k});for(const[b,k]of D.entries())k.length!==0&&w.push({id:`memory:${b}`,kind:"memory",label:b,count:k.length,rows:k});return w},[ee,D]),se=v.useMemo(()=>{const w=[];for(const b of fe)if(w.push({id:`section:${b.id}`,type:"section",sectionId:b.id}),!!X[b.id])if(b.kind==="context")for(const k of b.rows)w.push({id:`context-item:${k.context_id}`,type:"context",sectionId:b.id,item:k});else for(const k of b.rows)w.push({id:`memory-item:${k.id}`,type:"memory",sectionId:b.id,memory:k});return w},[X,fe]);v.useEffect(()=>{E.trim()&&K({})},[E]),v.useEffect(()=>{if(!se.length){G&&M("");return}(!G||!se.some(w=>w.id===G))&&M(se[0].id)},[G,se]),v.useEffect(()=>{var w;G&&((w=V.current[G])==null||w.focus())},[G]);const me=(w,b)=>{K(k=>({...k,[w]:typeof b=="boolean"?b:!k[w]}))},$=w=>{c({kind:"context",id:w.context_id}),window.location.hash=`#vault/item/${w.context_id}`},de=w=>{c({kind:"memory",id:w.id})},ce=w=>{M(w)},he=(w,b)=>{const k=se.findIndex(I=>I.id===w);if(k<0)return;const O=se[Math.max(0,Math.min(se.length-1,k+b))];O&&ce(O.id)},_e=(w,b)=>{if(w.key==="ArrowDown"){w.preventDefault(),he(b.id,1);return}if(w.key==="ArrowUp"){w.preventDefault(),he(b.id,-1);return}if(w.key==="Home"){w.preventDefault(),se[0]&&ce(se[0].id);return}if(w.key==="End"){w.preventDefault();const k=se[se.length-1];k&&ce(k.id);return}if(w.key==="ArrowRight"&&b.type==="section"){if(w.preventDefault(),!X[b.sectionId])me(b.sectionId,!0);else{const k=se.find(O=>O.sectionId===b.sectionId&&O.type!=="section");k&&ce(k.id)}return}if(w.key==="ArrowLeft"){w.preventDefault(),b.type==="section"?X[b.sectionId]&&me(b.sectionId,!1):ce(`section:${b.sectionId}`);return}(w.key==="Enter"||w.key===" ")&&b.type==="section"&&(w.preventDefault(),me(b.sectionId))},N=w=>{const b=o.find(k=>k.title.toLowerCase()===w.toLowerCase());return b?`#vault/item/${b.context_id}`:null},oe=()=>{c({kind:"new",id:"new"})},q=async()=>{if(!g.title.trim()||!g.content.trim()){f("Title and content are required.");return}h("save"),f(null);const w={title:g.title.trim(),content:g.content,scope:g.scope,kind:g.kind||"note",project_id:g.project_id||(t==null?void 0:t.project_id)||void 0,team_id:g.team_id||(t==null?void 0:t.team_id)||void 0,tags:Ll(g.tags),metadata:{source:"sankhya-vault"}};try{if(Mu(t||null,C,g)){const b=await B.upsertContext({...w,context_id:C==null?void 0:C.context_id,user_id:g.scope==="user"?t==null?void 0:t.user_id:void 0});c({kind:"context",id:b.item.context_id})}else{const b=await B.proposeContext({...w,proposed_by_user_id:(t==null?void 0:t.user_id)||"developer",supersedes_id:C==null?void 0:C.context_id});c({kind:"context",id:b.proposal.context_id}),await(r==null?void 0:r())}await ye(),S(!1)}catch(b){f(b instanceof Error?b.message:String(b))}finally{h(null)}},te=async w=>{if(C){h(w);try{w==="approve"?await B.approveProposal(C.context_id,(t==null?void 0:t.user_id)||"manager"):await B.rejectProposal(C.context_id,(t==null?void 0:t.user_id)||"manager"),await ye(),await(r==null?void 0:r())}catch(b){f(b instanceof Error?b.message:String(b))}finally{h(null)}}},Ae=(d==null?void 0:d.kind)==="memory",Ft=Mu(t||null,C,g),xe=v.useMemo(()=>[...z.items||[]].sort((b,k)=>{const O=(k.tokens_saved||0)-(b.tokens_saved||0);return O!==0?O:String(k.updated_at||"").localeCompare(String(b.updated_at||""))}).filter(b=>b.tokens_saved>0).slice(0,4),[z.items]),Me=v.useMemo(()=>new Map((R.items||[]).map(w=>[w.context_id,w])),[R.items]),je=C&&Me.get(C.context_id)||null,Fe=v.useMemo(()=>[...R.items||[]].filter(w=>(w.usage_count||0)>0).sort((w,b)=>{const k=(b.usage_count||0)-(w.usage_count||0);return k!==0?k:(b.proven_tokens_saved||0)-(w.proven_tokens_saved||0)}).slice(0,5),[R.items]);return i.jsxs("div",{style:{display:"flex",height:"100%",minHeight:0},children:[i.jsxs("aside",{style:{width:282,borderRight:"1px solid var(--border)",background:"white",display:"flex",flexDirection:"column",flexShrink:0},children:[i.jsxs("div",{style:{padding:14,borderBottom:"1px solid var(--border)"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:10},children:[i.jsxs("div",{children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",letterSpacing:"0.08em",textTransform:"uppercase"},children:"Context"}),i.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--ink)"},children:"Manager"})]}),i.jsx("button",{onClick:oe,style:{padding:"5px 8px",border:"1px solid var(--accent)",background:"var(--accent-dim)",color:"var(--accent)",fontFamily:"var(--mono)",fontSize:10,borderRadius:3},children:"NEW"})]}),i.jsx("input",{value:E,onChange:w=>T(w.target.value),placeholder:"search context or memory",style:{width:"100%",boxSizing:"border-box",border:"1px solid var(--border)",background:"var(--surface)",color:"var(--ink)",padding:"8px 9px",fontSize:12}}),i.jsxs("div",{style:{marginTop:8},children:[i.jsx(Bg,{rows:Fe,totals:R.totals,onSelect:w=>{c({kind:"context",id:w}),window.location.hash=`#vault/item/${w}`}}),i.jsx(Ag,{rows:xe,totalTokens:((wn=z.totals)==null?void 0:wn.tokens_saved)||0,totalCost:((Ut=z.totals)==null?void 0:Ut.realized_cost_saved_usd)??((Z=z.totals)==null?void 0:Z.estimated_cost_saved_usd)??0,apiValue:((ae=z.totals)==null?void 0:ae.theoretical_api_value_usd)??((Se=z.totals)==null?void 0:Se.estimated_cost_saved_usd)??0,totalSessions:((le=z.totals)==null?void 0:le.sessions)||0,budget:z.budget})]})]}),i.jsx("div",{style:{flex:1,overflowY:"auto",padding:10},role:"tree","aria-label":"Context categories",children:fe.map(w=>{const b={id:`section:${w.id}`,type:"section",sectionId:w.id},k=!!X[w.id],O=w.kind==="context"?w.rows.some(I=>(d==null?void 0:d.kind)==="context"&&d.id===I.context_id):w.rows.some(I=>(d==null?void 0:d.kind)==="memory"&&d.id===I.id);return i.jsx(Ig,{label:w.label,count:w.count,open:k,active:O,focused:G===b.id,buttonRef:I=>{V.current[b.id]=I},onFocus:()=>M(b.id),onToggle:()=>me(w.id),onKeyDown:I=>_e(I,b),children:w.kind==="context"?w.rows.map(I=>{const ne={id:`context-item:${I.context_id}`,type:"context",sectionId:w.id};return i.jsx(Au,{treeId:ne.id,buttonRef:ve=>{V.current[ne.id]=ve},focused:G===ne.id,active:(d==null?void 0:d.kind)==="context"&&d.id===I.context_id,dot:Iu(I.proposal_status||I.status),title:I.title,meta:Lg(I,Me.get(I.context_id)),onFocus:()=>M(ne.id),onKeyDown:ve=>_e(ve,ne),onClick:()=>$(I)},I.context_id)}):w.rows.map(I=>{const ne={id:`memory-item:${I.id}`,type:"memory",sectionId:w.id};return i.jsx(Au,{treeId:ne.id,buttonRef:ve=>{V.current[ne.id]=ve},focused:G===ne.id,active:(d==null?void 0:d.kind)==="memory"&&d.id===I.id,dot:"var(--indigo)",title:Pg(I),meta:`${I.tier} · ${I.tokens||0} tok`,onFocus:()=>M(ne.id),onKeyDown:ve=>_e(ve,ne),onClick:()=>de(I)},I.id)})},w.id)})})]}),i.jsxs("main",{style:{flex:1,minWidth:0,display:"grid",gridTemplateColumns:"minmax(0, 1fr) 320px",background:"var(--bg)"},children:[i.jsxs("section",{style:{minWidth:0,display:"flex",flexDirection:"column"},children:[i.jsxs("header",{style:{height:52,borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 18px",background:"white",gap:12},children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.08em",color:"var(--ink3)",textTransform:"uppercase"},children:[A?"Legacy memory":g.scope||"context",p?"":" · offline"]}),i.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title||"New context item"})]}),i.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[(C==null?void 0:C.proposal_status)==="pending_review"&&((t==null?void 0:t.role)==="manager"||(t==null?void 0:t.role)==="admin")?i.jsxs(i.Fragment,{children:[i.jsx(Qi,{label:"APPROVE",tone:"green",busy:H==="approve",onClick:()=>void te("approve")}),i.jsx(Qi,{label:"REJECT",tone:"rose",busy:H==="reject",onClick:()=>void te("reject")})]}):null,Ae?null:i.jsxs(i.Fragment,{children:[i.jsx(Qi,{label:x?"PREVIEW":"EDIT",onClick:()=>S(w=>!w)}),i.jsx(Qi,{label:Ft?"SAVE":"REQUEST",tone:Ft?"accent":"indigo",busy:H==="save",onClick:()=>void q()})]})]})]}),i.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:18,display:"grid",gridTemplateColumns:x?"minmax(0, 1fr) minmax(0, 1fr)":"minmax(0, 760px)",gap:16,alignContent:"start"},children:[x&&!Ae?i.jsxs("div",{style:{display:"grid",gap:10,alignContent:"start"},children:[i.jsx("input",{value:g.title,onChange:w=>m(b=>({...b,title:w.target.value})),placeholder:"Context title",style:bn}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[i.jsxs("select",{value:g.scope,onChange:w=>m(b=>({...b,scope:w.target.value})),style:bn,children:[i.jsx("option",{value:"company",children:"company"}),i.jsx("option",{value:"project",children:"project"}),i.jsx("option",{value:"global_team",children:"global_team"}),i.jsx("option",{value:"team",children:"team"}),i.jsx("option",{value:"user",children:"user"}),i.jsx("option",{value:"agent",children:"agent"})]}),i.jsx("input",{value:g.kind,onChange:w=>m(b=>({...b,kind:w.target.value})),placeholder:"kind: runbook / policy / decision",style:bn})]}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[i.jsx("input",{value:g.project_id,onChange:w=>m(b=>({...b,project_id:w.target.value})),placeholder:"project id",style:bn}),i.jsx("input",{value:g.team_id,onChange:w=>m(b=>({...b,team_id:w.target.value})),placeholder:"team id",style:bn})]}),i.jsx("input",{value:g.tags,onChange:w=>m(b=>({...b,tags:w.target.value})),placeholder:"tags, comma separated",style:bn}),i.jsx("textarea",{value:g.content,onChange:w=>m(b=>({...b,content:w.target.value})),rows:20,placeholder:"Write markdown context here...",style:{...bn,minHeight:420,resize:"vertical",lineHeight:1.55,fontFamily:"var(--mono)"}})]}):null,i.jsx("article",{style:{border:"1px solid var(--border)",background:"white",padding:18,minHeight:420,boxShadow:"0 10px 28px rgba(20,16,10,0.04)"},children:i.jsx(Cg,{source:g.content||"_No context selected._",wikiResolve:N})})]})]}),i.jsxs("aside",{style:{borderLeft:"1px solid var(--border)",background:"white",padding:16,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[i.jsxs(_n,{label:"Scope",children:[i.jsx($r,{children:g.scope}),g.kind?i.jsx($r,{children:g.kind}):null,C!=null&&C.proposal_status?i.jsx($r,{color:Iu(C.proposal_status),children:C.proposal_status}):null]}),i.jsxs(_n,{label:"Ownership",children:[i.jsx(Ge,{k:"org",v:t==null?void 0:t.org_id}),i.jsx(Ge,{k:"project",v:g.project_id||(t==null?void 0:t.project_id)}),i.jsx(Ge,{k:"team",v:g.team_id||(t==null?void 0:t.team_id)}),i.jsx(Ge,{k:"viewer",v:t==null?void 0:t.user_id}),i.jsx(Ge,{k:"role",v:(t==null?void 0:t.role)||"developer"})]}),i.jsxs(_n,{label:"Health",children:[i.jsx(Ge,{k:"quality",v:C==null?void 0:C.quality_score}),i.jsx(Ge,{k:"freshness",v:C==null?void 0:C.freshness_score}),i.jsx(Ge,{k:"confidence",v:C==null?void 0:C.confidence}),i.jsx(Ge,{k:"token cost",v:C==null?void 0:C.token_cost}),i.jsx(Ge,{k:"updated",v:(C==null?void 0:C.updated_at)||(A==null?void 0:A.created)})]}),C?i.jsxs(_n,{label:"Usage",children:[i.jsx(Ge,{k:"uses",v:(je==null?void 0:je.usage_count)??C.usage_count??0}),i.jsx(Ge,{k:"last used",v:(je==null?void 0:je.last_used_at)??C.last_used_at}),i.jsx(Ge,{k:"tokens served",v:(je==null?void 0:je.tokens_served)??0}),i.jsx(Ge,{k:"proven saved",v:(je==null?void 0:je.proven_tokens_saved)??0}),i.jsx(Ge,{k:"proven $",v:On(je==null?void 0:je.realized_cost_saved_usd)}),i.jsx(Ge,{k:"evidence",v:(Ee=je==null?void 0:je.evidence)!=null&&Ee.has_direct_savings_evidence?"direct attribution":"usage only"})]}):null,i.jsx(_n,{label:"Tags",children:Ll(g.tags).length?Ll(g.tags).map(w=>i.jsx($r,{children:w},w)):i.jsx("span",{style:{color:"var(--ink3)",fontSize:12},children:"none"})}),i.jsx(_n,{label:"Backlinks",children:(Lt=_==null?void 0:_.backlinks)!=null&&Lt.length?_.backlinks.map(w=>i.jsx("button",{onClick:()=>c({kind:"context",id:w.src}),style:Mg,children:w.src_title||w.src},`${w.src}:${w.edge_type}`)):i.jsx("span",{style:{color:"var(--ink3)",fontSize:12},children:"none"})}),i.jsx(_n,{label:"Shares",children:(Qn=_==null?void 0:_.shares)!=null&&Qn.length?_.shares.map((w,b)=>i.jsx($r,{children:String(w.scope||w.team_id||"share")},b)):i.jsx("span",{style:{color:"var(--ink3)",fontSize:12},children:"private"})}),u?i.jsx("div",{style:{border:"1px solid var(--rose)",color:"var(--rose)",background:"var(--rose-dim)",padding:10,fontFamily:"var(--mono)",fontSize:10,lineHeight:1.5},children:u}):null]})]})]})}const bn={width:"100%",boxSizing:"border-box",border:"1px solid var(--border)",background:"white",color:"var(--ink)",padding:"8px 9px",fontSize:12},Mg={display:"block",width:"100%",textAlign:"left",border:"1px solid var(--border)",background:"var(--surface)",color:"var(--ink2)",padding:"7px 8px",fontSize:12,cursor:"pointer"};function Ig({label:e,count:t,open:n,active:r,focused:o,buttonRef:l,onFocus:s,onToggle:a,onKeyDown:d,children:c}){return i.jsxs("div",{style:{marginBottom:6},children:[i.jsxs("button",{ref:l,type:"button",role:"treeitem","aria-expanded":n,"aria-selected":r,tabIndex:o?0:-1,onFocus:s,onClick:a,onKeyDown:d,style:{width:"100%",border:`1px solid ${r?"var(--accent)":"var(--border)"}`,background:r?"var(--accent-dim)":"var(--surface)",color:"var(--ink)",borderRadius:4,padding:"7px 8px",cursor:"pointer",display:"grid",gridTemplateColumns:"12px minmax(0, 1fr) auto",alignItems:"center",gap:8,textAlign:"left",fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase",outline:o?"2px solid var(--accent-dim)":"none"},children:[i.jsx("span",{style:{color:"var(--ink3)"},children:n?"v":">"}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),i.jsx("span",{style:{color:"var(--ink3)"},children:t})]}),n?i.jsx("div",{role:"group",style:{display:"grid",gap:4,margin:"4px 0 8px 14px"},children:c}):null]})}function Bg({rows:e,totals:t,onSelect:n}){return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",borderRadius:4,padding:8,marginBottom:8},children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:"0.04em",textTransform:"uppercase"},children:"Frequent context"}),i.jsxs("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:[on((t==null?void 0:t.usage_count)||0)," uses"]})]}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginTop:2,lineHeight:1.35},children:[on((t==null?void 0:t.tokens_served)||0)," served ·"," ",on((t==null?void 0:t.proven_tokens_saved)||0)," proven saved ·"," ",On(t==null?void 0:t.realized_cost_saved_usd)]}),i.jsx("div",{style:{display:"grid",gap:5,marginTop:8},children:e.length?e.map(r=>i.jsxs("button",{type:"button",onClick:()=>n(r.context_id),style:{border:"0",borderTop:"1px solid var(--border)",background:"transparent",padding:"6px 0 0",textAlign:"left",cursor:"pointer",display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",gap:8},children:[i.jsxs("span",{style:{minWidth:0},children:[i.jsx("span",{style:{display:"block",color:"var(--ink)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:r.title,children:r.title}),i.jsxs("span",{style:{display:"block",fontFamily:"var(--mono)",color:"var(--ink3)",fontSize:9,marginTop:2},children:[r.usage_count," uses · ",on(r.tokens_served)," served"]})]}),i.jsxs("span",{style:{textAlign:"right",fontFamily:"var(--mono)"},children:[i.jsx("span",{style:{display:"block",color:"var(--green)",fontSize:11},children:on(r.proven_tokens_saved)}),i.jsx("span",{style:{display:"block",color:"var(--ink3)",fontSize:9},children:On(r.realized_cost_saved_usd)})]})]},r.context_id)):i.jsx("div",{style:{borderTop:"1px solid var(--border)",paddingTop:7,fontSize:11,color:"var(--ink3)",lineHeight:1.4},children:"No context has been injected yet."})}),i.jsx("div",{style:{borderTop:"1px solid var(--border)",marginTop:8,paddingTop:6,color:"var(--ink3)",fontSize:10,lineHeight:1.35},children:"Per-context dollars are shown only when Dhee has direct attribution."})]})}function Ag({rows:e,totalTokens:t,totalCost:n,apiValue:r,totalSessions:o,budget:l}){return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",borderRadius:4,padding:8},children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:"0.04em",textTransform:"uppercase"},children:"Budget-capped savings"}),i.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--green)"},children:On(n)})]}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginTop:2},children:[on(t)," input tokens avoided across ",o," sessions"]}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:2,lineHeight:1.35},children:["API value ",On(r),l!=null&&l.monthly_budget_usd?`; monthly cap ${On(l.monthly_budget_usd)}`:""]}),i.jsx("div",{style:{display:"grid",gap:5,marginTop:8},children:e.length?e.map(s=>{const a=Og(s);return i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",gap:8,borderTop:"1px solid var(--border)",paddingTop:6},children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:99,background:a,flexShrink:0}}),i.jsx("span",{style:{fontSize:11,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$g(s)})]}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:a,marginTop:2},children:[s.runtime||s.agent||"agent"," · ",s.router_calls," calls"]})]}),i.jsxs("div",{style:{textAlign:"right"},title:Fg(s),children:[i.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--ink)"},children:On(s.estimated_cost_saved_usd)}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[on(s.tokens_saved)," tok"]})]})]},s.session_id)}):i.jsx("div",{style:{borderTop:"1px solid var(--border)",paddingTop:7,fontSize:11,color:"var(--ink3)",lineHeight:1.4},children:"No session-level savings recorded yet."})})]})}function Au({treeId:e,buttonRef:t,focused:n,active:r,dot:o,title:l,meta:s,onFocus:a,onKeyDown:d,onClick:c}){return i.jsxs("button",{ref:t,type:"button","data-tree-id":e,role:"treeitem","aria-selected":r,tabIndex:n?0:-1,onFocus:a,onKeyDown:d,onClick:c,style:{textAlign:"left",border:`1px solid ${r?"var(--accent)":"transparent"}`,background:r?"var(--accent-dim)":"transparent",color:"var(--ink)",padding:"7px 8px",borderRadius:4,cursor:"pointer",display:"grid",gridTemplateColumns:"8px minmax(0, 1fr)",gap:8,alignItems:"start",outline:n?"2px solid var(--accent-dim)":"none"},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:99,background:o,marginTop:5}}),i.jsxs("span",{style:{minWidth:0},children:[i.jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12},children:l}),i.jsx("span",{style:{display:"block",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:2},children:s})]})]})}function Qi({label:e,onClick:t,tone:n="default",busy:r}){const o=n==="accent"?"var(--accent)":n==="indigo"?"var(--indigo)":n==="green"?"var(--green)":n==="rose"?"var(--rose)":"var(--ink2)";return i.jsx("button",{onClick:t,disabled:r,style:{padding:"7px 10px",border:`1px solid ${o}`,background:n==="default"?"white":"var(--surface)",color:o,fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.06em",borderRadius:3,cursor:r?"wait":"pointer"},children:r?"...":e})}function _n({label:e,children:t}){return i.jsxs("section",{style:{display:"grid",gap:8},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.08em",color:"var(--ink3)",textTransform:"uppercase"},children:e}),i.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:t})]})}function $r({children:e,color:t="var(--ink2)"}){return i.jsx("span",{style:{display:"inline-flex",border:"1px solid var(--border)",background:"var(--surface)",color:t,padding:"3px 7px",borderRadius:3,fontFamily:"var(--mono)",fontSize:10},children:e})}function Ge({k:e,v:t}){return t==null||t===""?null:i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"76px minmax(0, 1fr)",gap:6,width:"100%",fontSize:12},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:e}),i.jsx("span",{style:{color:"var(--ink2)",wordBreak:"break-word"},children:String(t)})]})}function Ug({projectIndex:e,memories:t,tokensSaved:n,onAddMemory:r,onSelectSession:o,onCreateWorkspace:l,onLaunchSession:s,onOpenWorkspace:a,onOpenTasks:d}){var ie;const[c,g]=v.useState(""),[m,x]=v.useState("task"),[S,E]=v.useState("codex"),[T,H]=v.useState("standard"),[h,u]=v.useState(""),[f,p]=v.useState(""),[j,_]=v.useState(!1),[P,z]=v.useState(""),[Q,R]=v.useState(!1),[J,X]=v.useState(null),K=v.useRef(null);v.useEffect(()=>{var D;(D=K.current)==null||D.focus()},[]);const G=(e==null?void 0:e.workspaces)||[],M=v.useMemo(()=>G.find(D=>D.id===(h||(e==null?void 0:e.currentWorkspaceId)))||G[0]||null,[e==null?void 0:e.currentWorkspaceId,h,G]),V=v.useMemo(()=>{var D,fe;return((D=M==null?void 0:M.projects)==null?void 0:D.find(se=>se.id===(f||(e==null?void 0:e.currentProjectId))))||((fe=M==null?void 0:M.projects)==null?void 0:fe[0])||null},[M,e==null?void 0:e.currentProjectId,f]),ye=v.useMemo(()=>{var D,fe,se,me;return((D=V==null?void 0:V.sessions)==null?void 0:D.find($=>$.id===(e==null?void 0:e.currentSessionId)))||((fe=V==null?void 0:V.sessions)==null?void 0:fe[0])||((se=M==null?void 0:M.sessions)==null?void 0:se.find($=>$.id===(e==null?void 0:e.currentSessionId)))||((me=M==null?void 0:M.sessions)==null?void 0:me[0])||null},[V,M,e==null?void 0:e.currentSessionId]);v.useEffect(()=>{!h&&(e!=null&&e.currentWorkspaceId)&&u(e.currentWorkspaceId)},[e==null?void 0:e.currentWorkspaceId,h]),v.useEffect(()=>{!f&&(e!=null&&e.currentProjectId)&&p(e.currentProjectId)},[e==null?void 0:e.currentProjectId,f]),v.useEffect(()=>{M&&V&&!M.projects.some(D=>D.id===f)&&p(V.id)},[M,V,f]);const C=c.split(` -`).map(D=>D.trim()).filter(Boolean),A=async()=>{if(!(!C.length||Q)){R(!0),X(null);try{if(m==="memory")for(const D of C)await r(D);else for(const D of C)await s(D,S,M==null?void 0:M.id,S==="claude-code"?T:void 0,V==null?void 0:V.id);g("")}catch(D){X(String(D))}finally{R(!1)}}},W=async()=>{if(!(!P.trim()||Q)){R(!0),X(null);try{await l(P.trim()),z(""),_(!1)}catch(D){X(String(D))}finally{R(!1)}}},ee=D=>({padding:"6px 10px",border:"1px solid var(--border)",background:D?"var(--ink)":"white",color:D?"white":"var(--ink2)",fontFamily:"var(--mono)",fontSize:9});return i.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{height:48,borderBottom:"1px solid var(--border)",padding:"0 24px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[i.jsx("div",{style:{display:"flex",gap:10,alignItems:"center",minWidth:0},children:i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[(M==null?void 0:M.label)||(M==null?void 0:M.name)||"workspace",V?` / ${V.name}`:""]})}),i.jsxs("div",{style:{display:"flex",gap:18,alignItems:"center",fontFamily:"var(--mono)",fontSize:10},children:[i.jsx("button",{onClick:d,style:{color:"var(--ink3)"},children:"tasks"}),i.jsxs("span",{style:{color:"var(--ink3)"},children:[t," engrams"]})]})]}),i.jsxs("div",{style:{flex:1,overflow:"auto",padding:28,display:"grid",gridTemplateColumns:"minmax(0, 1fr) 280px",gap:24},children:[i.jsxs("div",{style:{border:"1px solid var(--border)",background:"transparent",padding:24,display:"flex",flexDirection:"column",minHeight:0},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("button",{onClick:()=>x("task"),style:ee(m==="task"),children:"create task"}),i.jsx("button",{onClick:()=>x("memory"),style:ee(m==="memory"),children:"save memory"}),m==="task"&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>E("codex"),style:ee(S==="codex"),children:"codex"}),i.jsx("button",{onClick:()=>E("claude-code"),style:ee(S==="claude-code"),children:"claude-code"}),S==="claude-code"&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>H("standard"),style:ee(T==="standard"),children:"standard"}),i.jsx("button",{onClick:()=>H("full-access"),style:ee(T==="full-access"),children:"full access"})]})]})]}),i.jsx("button",{onClick:a,style:{padding:"7px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"open workspace"})]}),m==="task"&&i.jsxs("div",{style:{display:"grid",gap:10,marginBottom:14},children:[i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"workspace"}),i.jsx("select",{value:(M==null?void 0:M.id)||"",onChange:D=>u(D.target.value),style:{border:"1px solid var(--border)",padding:"7px 10px",background:"white",minWidth:220},children:G.map(D=>i.jsx("option",{value:D.id,children:D.label||D.name},D.id))})]}),(ie=M==null?void 0:M.projects)!=null&&ie.length?i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"project"}),M.projects.map(D=>i.jsx("button",{onClick:()=>p(D.id),style:{...ee(D.id===(V==null?void 0:V.id)),background:D.id===(V==null?void 0:V.id)?"var(--accent)":"white"},children:D.name},D.id))]}):null]}),i.jsx("textarea",{ref:K,value:c,onChange:D=>g(D.target.value),onKeyDown:D=>{(D.metaKey||D.ctrlKey)&&D.key==="Enter"&&(D.preventDefault(),A())},placeholder:m==="task"?`- broadcast backend contract changes -- compare project scope rules -- create follow-up task for frontend stream`:`- backend project now emits model version updates -- paper asset is chunked and queryable -- avoid reprocessing shared results`,style:{width:"100%",flex:1,border:"1px solid var(--border)",padding:"18px 20px",fontSize:22,lineHeight:1.55,background:"white",resize:"none",minHeight:420}}),i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:14},children:[i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[C.length," point",C.length===1?"":"s"]}),i.jsx("button",{onClick:()=>void A(),style:{padding:"10px 16px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10},children:Q?"saving…":m==="task"?"create task":"save memory"})]}),J&&i.jsx("div",{style:{marginTop:12,fontSize:11,color:"var(--rose)"},children:J})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[i.jsxs("div",{onClick:a,style:{border:"1px solid var(--border)",background:"white",padding:16,cursor:"pointer"},children:[i.jsx("div",{style:{marginBottom:8,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"CURRENT WORKSPACE"}),i.jsx("div",{style:{fontSize:16,fontWeight:600},children:(M==null?void 0:M.label)||(M==null?void 0:M.name)||"No workspace"}),i.jsx("div",{style:{marginTop:6,fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:(M==null?void 0:M.workspacePath)||"Select or create a workspace"}),V&&i.jsxs("div",{style:{marginTop:10,fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[V.name," · default ",V.defaultRuntime||"codex"]}),ye&&i.jsx("button",{onClick:D=>{D.stopPropagation(),o(ye.id,ye.taskId||null)},style:{marginTop:12,padding:"7px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"open current session"})]}),i.jsx("button",{onClick:()=>_(!0),style:{padding:"12px 14px",border:"1px solid var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:10,textAlign:"left"},children:"+ add workspace"})]})]}),j&&i.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.18)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:40},onClick:()=>_(!1),children:i.jsxs("div",{onClick:D=>D.stopPropagation(),style:{width:460,maxWidth:"calc(100vw - 32px)",border:"1px solid var(--border)",background:"white",padding:20},children:[i.jsx("div",{style:{marginBottom:14,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"ADD WORKSPACE"}),i.jsxs("div",{style:{display:"grid",gap:10},children:[i.jsx("input",{value:P,onChange:D=>z(D.target.value),placeholder:"Workspace name",style:{border:"1px solid var(--border)",padding:"11px 12px",background:"white"}}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",lineHeight:1.5},children:"A workspace is a collection of projects. Add projects and their folders after creating it."}),i.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[i.jsx("button",{onClick:()=>_(!1),style:{padding:"10px 12px",border:"1px solid var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:10},children:"cancel"}),i.jsx("button",{onClick:()=>void W(),style:{padding:"10px 12px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10},children:Q?"creating…":"create workspace"})]})]})]})})]})}const el={fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"};function Mt(e){return Array.isArray(e)?e.filter(Boolean):[]}function Y(e,t,n=void 0){return!e||typeof e!="object"?n:e[t]??n}function ze(e){const t=Number(e||0);return new Intl.NumberFormat("en",{notation:Math.abs(t)>=1e4?"compact":"standard",maximumFractionDigits:Math.abs(t)>=1e4?1:0}).format(t)}function Wg(e){const t=String(e||"");if(!t)return"not linked";const n=t.split("/").filter(Boolean);return n.length>3?`.../${n.slice(-3).join("/")}`:t}function _a(e){if(!e)return"no timestamp";const t=new Date(e).getTime();if(Number.isNaN(t))return String(e);const n=Date.now()-t;return n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}function $o(e){const t=String(e||"").toLowerCase();return t.includes("reject")||t.includes("fail")||t.includes("stale")?"var(--rose)":t.includes("pending")||t.includes("candidate")||t.includes("derived")?"var(--accent)":t.includes("promoted")||t.includes("active")||t.includes("ok")?"var(--green)":t.includes("evidence")||t.includes("digest")?"var(--indigo)":"var(--ink3)"}function Ci(e){const[t,n]=v.useState(null),[r,o]=v.useState(""),[l,s]=v.useState(!0),a=async()=>{s(!0),o("");try{n(await e())}catch(d){o(String(d))}finally{s(!1)}};return v.useEffect(()=>{a()},[]),{data:t,error:r,loading:l,refresh:a}}function bi({eyebrow:e,title:t,subtitle:n,children:r,action:o}){return i.jsx("div",{style:{height:"100%",overflowY:"auto",background:"var(--surface)"},children:i.jsxs("div",{style:{minHeight:"100%",padding:24,display:"flex",flexDirection:"column",gap:18},children:[i.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:20,borderBottom:"1px solid var(--border)",paddingBottom:18},children:[i.jsxs("div",{style:{maxWidth:760},children:[i.jsx("div",{style:{...el,color:"var(--accent)",marginBottom:8},children:e}),i.jsx("h1",{style:{fontSize:30,lineHeight:1.08,fontWeight:700,letterSpacing:0},children:t}),i.jsx("p",{style:{marginTop:8,color:"var(--ink2)",fontSize:14,lineHeight:1.55},children:n})]}),o]}),r]})})}function He({label:e,children:t,style:n}){return i.jsxs("section",{style:{background:"white",border:"1px solid var(--border)",padding:16,minWidth:0,...n},children:[e?i.jsx("div",{style:{...el,color:"var(--ink3)",marginBottom:12},children:e}):null,t]})}function Ye({label:e,value:t,tone:n}){return i.jsxs(He,{style:{minHeight:94},children:[i.jsx("div",{style:{fontSize:26,lineHeight:1,fontWeight:700,color:n||"var(--ink)"},children:t}),i.jsx("div",{style:{marginTop:8,color:"var(--ink3)",fontSize:12},children:e})]})}function tt({children:e,tone:t}){return i.jsx("span",{style:{...el,display:"inline-flex",alignItems:"center",minHeight:22,padding:"3px 8px",color:t||"var(--ink2)",background:"var(--surface2)",border:"1px solid var(--border)"},children:e})}function tl({rows:e,empty:t,render:n}){return e.length?i.jsx("div",{style:{display:"grid",gap:10},children:e.map(n)}):i.jsx("div",{style:{color:"var(--ink3)",fontSize:13},children:t})}function _i({loading:e,error:t}){return e?i.jsx(He,{children:"Loading Dhee state..."}):t?i.jsx(He,{children:i.jsx("span",{style:{color:"var(--rose)"},children:t})}):null}function Hg({onNavigate:e}){const{data:t,error:n,loading:r,refresh:o}=Ci(B.commandCenter),l=Y(t,"router",{}),s=Y(t,"context",{}),a=Y(t,"learnings",{}),d=Y(t,"inbox",{}),c=Y(t,"active_task",null),g=Mt(Y(t,"router_sessions",[])),m=Y(a,"totals",{}),x=Y(d,"totals",{});return i.jsxs(bi,{eyebrow:"COMMAND CENTER",title:"The current truth before the agent sees anything.",subtitle:"Start here to see task continuity, context health, routed savings, review queues, and the next best action for this repo.",action:i.jsx("button",{onClick:o,style:At,children:"refresh"}),children:[i.jsx(_i,{loading:r,error:n}),t?i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:12},children:[i.jsx(Ye,{label:"tokens avoided",value:ze(Y(l,"sessionTokensSaved",0)),tone:"var(--green)"}),i.jsx(Ye,{label:"router calls",value:ze(Y(l,"totalCalls",0)),tone:"var(--accent)"}),i.jsx(Ye,{label:"repo context",value:ze(Y(Y(s,"totals",{}),"repo_entries",0)),tone:"var(--indigo)"}),i.jsx(Ye,{label:"learning candidates",value:ze(Y(m,"candidate",0)),tone:"var(--accent)"})]}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.1fr 0.9fr",gap:14},children:[i.jsx(He,{label:"ACTIVE WORK",children:c?i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:22,lineHeight:1.2,fontWeight:700},children:String(Y(c,"title","Active task"))}),i.jsxs("div",{style:{marginTop:8,display:"flex",gap:8,flexWrap:"wrap"},children:[i.jsx(tt,{tone:$o(Y(c,"status")),children:String(Y(c,"status","active"))}),i.jsx(tt,{children:String(Y(c,"harness","agent"))})]})]}):i.jsx("div",{style:{color:"var(--ink3)"},children:"No active task yet. Start from a linked repo to let Dhee compile state."})}),i.jsxs(He,{label:"NEXT ACTION",children:[i.jsx("div",{style:{fontSize:18,fontWeight:650,lineHeight:1.35},children:String(Y(t,"next_action","Start a routed agent task"))}),i.jsxs("div",{style:{marginTop:14,display:"flex",gap:8,flexWrap:"wrap"},children:[i.jsx("button",{onClick:()=>e("handoff"),style:At,children:"handoff"}),i.jsx("button",{onClick:()=>e("router"),style:Do,children:"firewall"}),i.jsx("button",{onClick:()=>e("learnings"),style:Do,children:"learnings"})]})]})]}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:14},children:[i.jsx(He,{label:"LIVE SESSIONS",children:i.jsx(tl,{rows:g.slice(0,5),empty:"No routed sessions yet.",render:S=>i.jsx(Hr,{title:String(S.title||S.session_id||"session"),meta:`${S.agent||S.runtime||"agent"} - ${ze(S.tokens_saved)} tokens`,tone:$o(S.state)},String(S.session_id))})}),i.jsxs(He,{label:"REVIEW QUEUE",children:[i.jsx(Hr,{title:"proposals",meta:ze(Y(x,"proposals",0)),tone:"var(--accent)"}),i.jsx(Hr,{title:"findings",meta:ze(Y(x,"findings",0)),tone:"var(--rose)"}),i.jsx(Hr,{title:"conflicts",meta:ze(Y(x,"conflicts",0)),tone:"var(--indigo)"})]}),i.jsxs(He,{label:"ADDRESSABLE CONTEXT",children:[(Mt(Y(t,"dhee_aliases",[])).length,null),(Y(t,"dhee_aliases",[])||[]).map(S=>i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,padding:"5px 0",color:"var(--ink2)"},children:S},S))]})]})]}):null]})}function Vg(){const{data:e,error:t,loading:n,refresh:r}=Ci(B.handoffUi),o=Y(e,"continuity",{}),l=Y(o,"last_session",{})||{},s=Mt(Y(e,"tasks",[])),a=Mt(Y(e,"sessions",[])),d=Mt(Y(l,"files_touched",Y(l,"filesTouched",[]))),c=Mt(Y(l,"decisions",[])),g=Mt(Y(l,"todos",[]));return i.jsxs(bi,{eyebrow:"HANDOFF HUB",title:"Resume without replaying the transcript.",subtitle:"Dhee turns the latest work into task state: decisions, files, blockers, commands, tests, resume confidence, and the next step.",action:i.jsx("button",{onClick:r,style:At,children:"refresh"}),children:[i.jsx(_i,{loading:n,error:t}),e?i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.1fr 0.9fr",gap:14},children:[i.jsxs(He,{label:"LATEST HANDOFF",children:[i.jsx("div",{style:{fontSize:24,lineHeight:1.15,fontWeight:700},children:String(Y(l,"task_summary","No handoff saved yet"))}),i.jsxs("div",{style:{marginTop:12,display:"flex",gap:8,flexWrap:"wrap"},children:[i.jsxs(tt,{tone:"var(--green)",children:["confidence ",Math.round(Number(Y(e,"resume_confidence",0))*100),"%"]}),i.jsx(tt,{children:_a(Y(l,"updated")||Y(l,"ended_at"))}),i.jsx(tt,{children:String(Y(l,"agent_id",Y(l,"source","dhee")))})]}),i.jsx("pre",{style:mp,children:String(Y(e,"command",""))})]}),i.jsx(He,{label:"RESUME INVENTORY",children:i.jsx(Jg,{rows:[["tasks",s.length],["sessions",a.length],["files",d.length],["decisions",c.length],["todos",g.length]]})}),i.jsx(He,{label:"DECISIONS",style:{gridColumn:"span 1"},children:i.jsx(Uu,{rows:c,empty:"No decisions captured yet."})}),i.jsx(He,{label:"FILES TOUCHED",children:i.jsx(Uu,{rows:d.map(m=>Wg(String(m))),empty:"No files in the latest handoff."})})]}):null]})}function Kg(){const{data:e,error:t,loading:n,refresh:r}=Ci(()=>B.proofReplay(120)),o=Mt(Y(e,"items",[])),l=Y(e,"totals",{});return i.jsxs(bi,{eyebrow:"PROOF REPLAY",title:"Replay the context decisions, not just the chat.",subtitle:"See the expansion trace: what Dhee digested, hid, expanded, injected, promoted, rejected, or derived from local records.",action:i.jsx("button",{onClick:r,style:At,children:"refresh"}),children:[i.jsx(_i,{loading:n,error:t}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:12},children:[i.jsx(Ye,{label:"events",value:ze(Y(l,"events",o.length))}),i.jsx(Ye,{label:"digests",value:ze(Y(l,"digests",0)),tone:"var(--green)"}),i.jsx(Ye,{label:"expansion trace",value:ze(Y(l,"expansions",0)),tone:"var(--accent)"}),i.jsx(Ye,{label:"evidence",value:ze(Y(l,"evidence",0)),tone:"var(--indigo)"}),i.jsx(Ye,{label:"derived rows",value:ze(Y(l,"derived",0))})]}),i.jsx(He,{label:"DECISION TIMELINE",children:i.jsx(tl,{rows:o,empty:"No context decisions recorded yet.",render:(s,a)=>i.jsx(Xg,{index:a,title:String(s.title||"Decision"),meta:`${s.source||"dhee"} - ${_a(s.time)}`,detail:String(s.detail||""),kind:String(s.kind||"event"),derived:!!s.derived},String(s.id||a))})})]})}function Qg(){const{data:e,error:t,loading:n,refresh:r}=Ci(()=>B.learningsUi(160)),[o,l]=v.useState(""),s=Mt(Y(e,"items",[])),a=Y(e,"totals",{}),d=async(c,g)=>{l(c);try{g==="promote"?await B.promoteLearning(c,{approved_by:"dhee-ui"}):await B.rejectLearning(c,{reason:"rejected in Dhee UI"}),await r()}finally{l("")}};return i.jsxs(bi,{eyebrow:"LEARNING INBOX",title:"Only evidence-backed learnings get promoted.",subtitle:"Clear pending review candidates from agent work. Dhee should learn from success, avoided failure, repeated utility, or explicit approval.",action:i.jsx("button",{onClick:r,style:At,children:"refresh"}),children:[i.jsx(_i,{loading:n,error:t}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:12},children:[i.jsx(Ye,{label:"candidates",value:ze(Y(a,"candidate",0)),tone:"var(--accent)"}),i.jsx(Ye,{label:"promoted",value:ze(Y(a,"promoted",0)),tone:"var(--green)"}),i.jsx(Ye,{label:"rejected",value:ze(Y(a,"rejected",0)),tone:"var(--rose)"}),i.jsx(Ye,{label:"all learnings",value:ze(Y(a,"all",s.length))})]}),i.jsx(He,{label:"LEARNING REVIEW",children:i.jsx(tl,{rows:s,empty:"No learning candidates yet.",render:c=>{const g=String(c.id||""),m=String(c.status||"candidate");return i.jsxs("div",{style:Zg,children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:8},children:[i.jsx(tt,{tone:$o(m),children:m}),i.jsx(tt,{children:String(c.evidence_gate||"needs approval")}),i.jsx(tt,{children:String(c.source_harness||c.source_agent_id||"agent")})]}),i.jsx("div",{style:{fontSize:17,fontWeight:700,lineHeight:1.25},children:String(c.title||g)}),i.jsx("div",{style:{marginTop:6,color:"var(--ink2)",lineHeight:1.55},children:String(c.body||"")})]}),i.jsxs("div",{style:{display:"flex",gap:8,flexShrink:0},children:[i.jsx("button",{disabled:!g||o===g||m==="promoted",onClick:()=>d(g,"promote"),style:At,children:"promote"}),i.jsx("button",{disabled:!g||o===g||m==="rejected",onClick:()=>d(g,"reject"),style:Do,children:"reject"})]})]},g)}})})]})}function Yg(){const{data:e,error:t,loading:n,refresh:r}=Ci(B.portabilityUi),[o,l]=v.useState(!1),[s,a]=v.useState(""),[d,c]=v.useState(null),[g,m]=v.useState(""),x=Y(e,"counts",{}),S=Mt(Y(e,"packs",[])),E=(Y(e,"contract",[])||[]).filter(Boolean),T=async()=>{l(!0),m("");try{await B.exportPackUi({}),await r()}catch(h){m(String(h))}finally{l(!1)}},H=async()=>{m(""),c(null);try{c(await B.importPackDryRunUi({input_path:s}))}catch(h){m(String(h))}};return i.jsxs(bi,{eyebrow:"PORTABILITY & TRUST",title:"Local memory should be inspectable, signed, and movable.",subtitle:"Dhee keeps export/import as a product surface, not an afterthought. No lock-in tricks, no hidden hosted dependency.",action:i.jsx("button",{onClick:r,style:At,children:"refresh"}),children:[i.jsx(_i,{loading:n,error:t}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:12},children:[i.jsx(Ye,{label:"memories",value:ze(Y(x,"memories",0))}),i.jsx(Ye,{label:"artifacts",value:ze(Y(x,"artifacts",0)),tone:"var(--indigo)"}),i.jsx(Ye,{label:"repo context",value:ze(Y(x,"repo_context_entries",0)),tone:"var(--green)"}),i.jsx(Ye,{label:"packs found",value:ze(S.length),tone:"var(--accent)"})]}),g?i.jsx(He,{children:i.jsx("span",{style:{color:"var(--rose)"},children:g})}):null,i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"0.9fr 1.1fr",gap:14},children:[i.jsxs(He,{label:"PORTABLE SUBSTRATE",children:[i.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:E.map(h=>i.jsx(tt,{tone:"var(--green)",children:h},h))}),i.jsx("button",{disabled:o,onClick:T,style:{...At,marginTop:16},children:o?"exporting...":"export .dheemem"})]}),i.jsxs(He,{label:"IMPORT DRY RUN",children:[i.jsxs("div",{style:{display:"flex",gap:10},children:[i.jsx("input",{value:s,onChange:h=>a(h.target.value),placeholder:"/path/to/backup.dheemem",style:qg}),i.jsx("button",{disabled:!s.trim(),onClick:H,style:At,children:"dry run"})]}),d?i.jsx("pre",{style:mp,children:JSON.stringify(Y(d,"result",d),null,2)}):null]})]}),i.jsx(He,{label:"RECENT PACKS",children:i.jsx(tl,{rows:S,empty:"No .dheemem packs found yet.",render:h=>i.jsx(Hr,{title:String(h.name||h.path),meta:`${h.verified?"verified":"unverified"} - ${ze(Number(h.size_bytes||0))} bytes - ${_a(h.updated_at)}`,tone:h.verified?"var(--green)":"var(--accent)"},String(h.path))})})]})}function Ev({onOpenContext:e}){return i.jsxs("div",{style:{position:"absolute",left:68,top:14,zIndex:8,display:"flex",gap:10,alignItems:"center",pointerEvents:"auto"},children:[i.jsx(tt,{tone:"var(--green)",children:"REPO BRAIN"}),i.jsx(tt,{children:"dhee://state/current"}),i.jsx(tt,{children:"dhee://handoff/latest"}),e?i.jsx("button",{onClick:e,style:Do,children:"context vault"}):null]})}function Uu({rows:e,empty:t}){return e.length?i.jsx("div",{style:{display:"grid",gap:8},children:e.map((n,r)=>i.jsx("div",{style:{padding:"8px 0",borderBottom:"1px solid var(--border)",color:"var(--ink2)"},children:String(n)},r))}):i.jsx("div",{style:{color:"var(--ink3)"},children:t})}function Jg({rows:e}){return i.jsx("div",{style:{display:"grid",gap:8},children:e.map(([t,n])=>i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:20},children:[i.jsx("span",{style:{color:"var(--ink3)"},children:t}),i.jsx("strong",{children:ze(n)})]},t))})}function Hr({title:e,meta:t,tone:n}){return i.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start",padding:"7px 0",borderBottom:"1px solid var(--border)"},children:[i.jsx("span",{style:{width:8,height:8,marginTop:6,background:n||"var(--ink3)",flexShrink:0}}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:13,fontWeight:650,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginTop:2},children:t})]})]})}function Xg({index:e,title:t,meta:n,detail:r,kind:o,derived:l}){return i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"44px 1fr",gap:14,padding:"12px 0",borderBottom:"1px solid var(--border)"},children:[i.jsx("div",{style:{...el,color:"var(--ink3)"},children:String(e+1).padStart(2,"0")}),i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:6},children:[i.jsx(tt,{tone:$o(o),children:o}),l?i.jsx(tt,{tone:"var(--accent)",children:"derived"}):i.jsx(tt,{tone:"var(--green)",children:"recorded"}),i.jsx(tt,{children:n})]}),i.jsx("div",{style:{fontSize:16,fontWeight:700},children:t}),r?i.jsx("div",{style:{marginTop:4,color:"var(--ink2)",lineHeight:1.55},children:r}):null]})]})}const At={border:"1px solid var(--ink)",background:"var(--ink)",color:"white",padding:"8px 12px",fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"},Do={...At,color:"var(--ink)",background:"white",borderColor:"var(--border2)"},qg={minHeight:36,flex:1,border:"1px solid var(--border2)",background:"white",padding:"0 10px",fontFamily:"var(--mono)",fontSize:11},mp={marginTop:14,border:"1px solid var(--border)",background:"var(--surface2)",padding:12,fontFamily:"var(--mono)",fontSize:11,whiteSpace:"pre-wrap",overflowX:"auto"},Zg={display:"grid",gridTemplateColumns:"1fr auto",gap:18,padding:"14px 0",borderBottom:"1px solid var(--border)",alignItems:"start"},Gg={border:"1px solid var(--border)",background:"var(--bg)",borderRadius:8,padding:18,width:"min(760px, 100%)",boxSizing:"border-box",display:"flex",flexWrap:"wrap",gap:18,boxShadow:"0 10px 28px rgba(20,16,10,0.06)"},Wu={fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--ink3)"},ev={borderRadius:5,cursor:"pointer",fontFamily:"var(--mono)",fontSize:10,padding:"8px 11px",whiteSpace:"nowrap"};function tv(e="secondary",t){const n=e==="primary";return{...ev,border:`1px solid ${n?"var(--ink)":"var(--border)"}`,background:n?"var(--ink)":"white",color:n?"white":"var(--accent)",opacity:t?.55:1,cursor:t?"not-allowed":"pointer"}}function hp({title:e="Set up a developer workspace",eyebrow:t="First run",body:n="Connect a repo folder, then start Codex or Claude Code from that folder so Dhee can mirror sessions and context.",actions:r=[],commands:o=["dhee onboard --root .","dhee doctor"],aside:l}){return i.jsxs("section",{style:Gg,children:[i.jsxs("div",{style:{flex:"1 1 300px",minWidth:0},children:[i.jsx("div",{style:Wu,children:t}),i.jsx("h2",{style:{margin:"5px 0 7px",fontSize:22,lineHeight:1.15,color:"var(--ink)",letterSpacing:0},children:e}),i.jsx("div",{style:{color:"var(--ink2)",fontSize:12.5,lineHeight:1.55,maxWidth:680},children:n}),r.length?i.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:14},children:r.map(s=>i.jsx("button",{type:"button",onClick:s.onClick,disabled:s.disabled,style:tv(s.tone,s.disabled),children:s.label},s.label))}):null]}),i.jsxs("div",{style:{flex:"1 1 260px",border:"1px solid var(--border)",background:"var(--surface)",borderRadius:6,padding:12,minWidth:0},children:[i.jsx("div",{style:{...Wu,marginBottom:8},children:"Terminal path"}),i.jsx("div",{style:{display:"grid",gap:7},children:o.map(s=>i.jsx("code",{style:{display:"block",border:"1px solid var(--border)",background:"white",borderRadius:4,padding:"8px 9px",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink)",lineHeight:1.45,overflowWrap:"anywhere"},children:s},s))}),l?i.jsx("div",{style:{marginTop:10},children:l}):null]})]})}const Dr=[{key:"day",label:"Daily",short:"24h",ms:24*60*60*1e3},{key:"week",label:"Weekly",short:"7d",ms:7*24*60*60*1e3},{key:"month",label:"Monthly",short:"30d",ms:30*24*60*60*1e3},{key:"year",label:"Yearly",short:"365d",ms:365*24*60*60*1e3}],Hu={items:[],next_cursor:null,active_only:!1,totals:{tokens_saved:0,estimated_cost_saved_usd:0,router_calls:0,sessions:0}};function vn(e){return e==null?"0":new Intl.NumberFormat("en",{notation:Math.abs(e)>=1e4?"compact":"standard",maximumFractionDigits:Math.abs(e)>=1e4?1:0}).format(e)}function Mn(e){return new Intl.NumberFormat("en-US").format(Math.max(0,Number(e||0)))}function Vr(e){const t=Math.max(0,Number(e||0));return t>0&&t<.01?"<$0.01":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:t>=100?0:2}).format(t)}function Xn(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function Ea(e){const t=Xn(e);if(!t)return"n/a";const n=Date.now()-t;return n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}function Ta(e){if(!e)return"n/a";const t=e.split("/").filter(Boolean);return t.length<=2?e:".../"+t.slice(-2).join("/")}function gp(e){var r;const t=typeof e=="string"?e:e.agent||e.runtime||((r=e.agents)==null?void 0:r[0])||"unknown",n=String(t||"").toLowerCase();return n.includes("codex")?"codex":n.includes("claude")?"claude-code":n||"unknown"}function nv(e){const t=gp(e||"");return t==="codex"?"Codex":t==="claude-code"?"Claude Code":e||"Unknown"}function za(e){const t=gp(e||"");return t==="codex"?"var(--indigo)":t==="claude-code"?"var(--accent)":"var(--ink3)"}function Ra(e){var t;return Number(((t=e.pricing)==null?void 0:t.input_cost_per_million)||0)>0}function Na(e){return e.tokens_saved>0&&!Ra(e)?"unpriced":Vr(e.estimated_cost_saved_usd)}function rv(e){const t=String(e.state||"").toLowerCase();return!!e.active&&(t==="active"||t==="running"||t==="live")}function vp(e){const t=e.pricing;if(!t||!Ra(e))return(t==null?void 0:t.note)||"No official provider/model rate mapped yet.";const n=t.provider||e.runtime||e.agent||"provider",r=t.model_family||e.model||"model";return`${n} ${r}: $${t.input_cost_per_million}/1M input tokens`}function yp(e,t){if(!e)return Number.POSITIVE_INFINITY;const r=Number(e[t==="day"?"daily_budget_usd":t==="week"?"weekly_budget_usd":t==="year"?"yearly_budget_usd":"monthly_budget_usd"]||0);return r>0?r:Number.POSITIVE_INFINITY}function Vu(e,t,n){return e.reduce((r,o)=>(r.tokens+=o.tokens_saved||0,r.apiValue+=Number(o.estimated_cost_saved_usd||0),r.calls+=o.router_calls||0,r.sessions+=1,r.cost=Math.min(r.apiValue,yp(t,n)),r),{tokens:0,apiValue:0,cost:0,calls:0,sessions:0})}function Ku(){const e=new URLSearchParams(window.location.search),t=String(e.get("view")||"").toLowerCase(),n=window.location.pathname.replace(/^\/+|\/+$/g,"").toLowerCase();return t==="router/sessionshistory"||t==="router/session-history"||t==="router/history"||n==="router/sessionshistory"?"history":"live"}function iv(e){const t=new URLSearchParams(window.location.search);t.set("view",e==="history"?"router/sessionshistory":"router");const n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:""}${window.location.hash||""}`;window.history.pushState({},"",r),window.dispatchEvent(new Event("popstate"))}function ov({onOpenFolders:e,onOpenSetup:t}){return i.jsx("div",{style:{height:"100%",overflowY:"auto",background:"var(--surface)"},children:i.jsx(lv,{onOpenFolders:e,onOpenSetup:t})})}function lv({onOpenFolders:e,onOpenSetup:t}){const n=v.useRef(null),[r,o]=v.useState(Hu),[l,s]=v.useState(Hu),[a,d]=v.useState("week"),[c,g]=v.useState(()=>Ku()),[m,x]=v.useState(""),[S,E]=v.useState(!1),[T,H]=v.useState(null),h=async(K=!1)=>{K||E(!0),H(null);try{const[G,M]=await Promise.all([B.routerSessions({active:!1,limit:100}),B.routerSessions({active:!0,limit:50})]);o(G),s(M)}catch(G){H(String(G))}finally{K||E(!1)}};v.useEffect(()=>{h(!1);const K=window.setInterval(()=>void h(!0),15e3);return()=>window.clearInterval(K)},[]),v.useEffect(()=>{const K=()=>g(Ku());return window.addEventListener("popstate",K),()=>window.removeEventListener("popstate",K)},[]),v.useEffect(()=>{var K,G;(G=(K=n.current)==null?void 0:K.parentElement)==null||G.scrollTo({top:0,behavior:"auto"})},[c]);const u=v.useMemo(()=>[...l.items].filter(rv).sort((K,G)=>Xn(G.updated_at)-Xn(K.updated_at)),[l.items]),f=v.useMemo(()=>{const K=Dr.find(M=>M.key===a)||Dr[1],G=Date.now()-K.ms;return[...r.items].filter(M=>Xn(M.updated_at||M.started_at)>=G).sort((M,V)=>Xn(V.updated_at)-Xn(M.updated_at))},[r.items,a]),p=c==="history"?f.find(K=>K.session_id===m)||null:u.find(K=>K.session_id===m)||null,j=r.budget||l.budget,_=Vu(f,j,a),P=Vu(u,j,"day"),z=l.items.length>0||r.items.length>0,Q=Dr.find(K=>K.key===a)||Dr[1],R=yp(j,a),J=Number.isFinite(R)&&_.apiValue>R,X=K=>{g(K),iv(K)};return i.jsxs("div",{ref:n,style:{padding:"clamp(10px, 3vw, 18px)",display:"grid",gap:14,minWidth:0,width:"100%",boxSizing:"border-box"},children:[i.jsxs("section",{style:{border:"1px solid var(--border)",background:"var(--bg)",borderRadius:8,padding:16,minWidth:0,boxSizing:"border-box"},children:[i.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:14,alignItems:"start",justifyContent:"space-between",marginBottom:14},children:[i.jsxs("div",{style:{flex:"1 1 240px",minWidth:0},children:[i.jsx(Hn,{children:"Context Firewall"}),i.jsx("h1",{style:{margin:"2px 0 0",fontSize:26,lineHeight:1.1,color:"var(--ink)",letterSpacing:0},children:c==="history"?"Firewall session history":"Live context firewall"}),i.jsx("p",{style:{margin:"6px 0 0",color:"var(--ink3)",fontSize:12,maxWidth:780},children:c==="history"?"Every completed and recent local agent session, with pointer-backed evidence and avoided raw context.":"Running Claude Code and Codex sessions, with raw output kept behind digests until the agent asks to expand."})]}),i.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-start",flexWrap:"wrap",flex:"0 1 auto"},children:[i.jsx("button",{onClick:()=>X(c==="history"?"live":"history"),style:{border:"1px solid var(--accent)",background:c==="history"?"white":"var(--accent-dim)",borderRadius:5,color:"var(--accent)",cursor:"pointer",fontFamily:"var(--mono)",fontSize:10,padding:"8px 11px"},children:c==="history"?"LIVE FIREWALL":"SESSION HISTORY"}),i.jsx("button",{onClick:()=>h(!1),disabled:S,style:{border:"1px solid var(--border)",background:"white",borderRadius:5,color:S?"var(--ink3)":"var(--accent)",cursor:S?"wait":"pointer",fontFamily:"var(--mono)",fontSize:10,padding:"8px 11px"},children:S?"SYNCING":"REFRESH"})]})]}),i.jsx("div",{style:{display:"flex",gap:7,flexWrap:"wrap",marginBottom:12},children:Dr.map(K=>{const G=K.key===a;return i.jsxs("button",{onClick:()=>d(K.key),style:{border:`1px solid ${G?"var(--accent)":"var(--border)"}`,background:G?"var(--accent-dim)":"white",color:G?"var(--accent)":"var(--ink2)",borderRadius:5,padding:"6px 10px",fontFamily:"var(--mono)",fontSize:10,cursor:"pointer"},children:[K.label,i.jsx("span",{style:{color:"var(--ink3)",marginLeft:6},children:K.short})]},K.key)})}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(118px, 1fr))",gap:10},children:[i.jsx(an,{label:`${Q.label} API value`,value:Vr(_.apiValue),sub:"official input-rate estimate",accent:"var(--green)"}),i.jsx(an,{label:"Budget-capped savings",value:Vr(_.cost),sub:J?`capped at ${Vr(R)}`:"same as API value for this range",accent:"var(--green)"}),i.jsx(an,{label:`${Q.label} raw tokens avoided`,value:vn(_.tokens),sub:`${Mn(_.tokens)} avoided input tokens`,accent:"var(--green)"}),i.jsx(an,{label:"Live governed sessions",value:Mn(P.sessions),sub:`${vn(P.tokens)} active-session savings`,accent:"var(--accent)"})]})]}),T?i.jsxs("div",{style:{border:"1px solid var(--rose)",background:"white",color:"var(--rose)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--mono)",fontSize:11},children:["context firewall data unavailable: ",T]}):null,!S&&!T&&!z?i.jsx(hp,{body:"Point Dhee at a repo folder, then start an agent task from that folder. The context firewall will fill with digests, evidence pointers, and expansions after the first mirrored Codex or Claude Code run.",actions:[...e?[{label:"ADD REPO FOLDER",onClick:e,tone:"primary"}]:[],...t?[{label:"START TASK",onClick:t}]:[]]}):null,c==="history"?i.jsx(Qu,{title:"Session history",sub:`${f.length} sessions in the last ${Q.short} · ${vn(_.tokens)} tokens · ${Vr(_.apiValue)} API value`,action:i.jsx("button",{onClick:()=>X("live"),style:{border:"1px solid var(--border)",background:"white",borderRadius:5,color:"var(--accent)",cursor:"pointer",fontFamily:"var(--mono)",fontSize:10,padding:"7px 10px",whiteSpace:"nowrap"},children:"LIVE FIREWALL"}),children:i.jsx(av,{rows:f,selectedId:(p==null?void 0:p.session_id)||"",onSelect:x,loading:S})}):i.jsx(Qu,{title:"Live governed sessions",sub:`${u.length} active local agent session${u.length===1?"":"s"} · click a session to inspect routing, evidence, and savings`,action:i.jsx("button",{onClick:()=>X("history"),style:{border:"1px solid var(--border)",background:"white",borderRadius:5,color:"var(--accent)",cursor:"pointer",fontFamily:"var(--mono)",fontSize:10,padding:"7px 10px",whiteSpace:"nowrap"},children:"HISTORY"}),children:u.length===0?i.jsx(xp,{children:"No active Claude Code or Codex sessions detected."}):i.jsx("div",{style:{display:"grid",gap:8},children:u.map(K=>i.jsx(sv,{row:K,selected:(p==null?void 0:p.session_id)===K.session_id,onSelect:()=>x(G=>G===K.session_id?"":K.session_id)},K.session_id))})})]})}function sv({row:e,selected:t,onSelect:n}){const r=za(e.agent||e.runtime),o=e.live_usage;return i.jsxs("div",{style:{width:"100%",border:`1px solid ${t?r:"var(--border)"}`,background:t?"var(--surface)":"white",borderRadius:6,overflow:"hidden"},children:[i.jsx("button",{type:"button","aria-expanded":t,onClick:n,style:{width:"100%",textAlign:"left",background:"transparent",border:0,padding:12,cursor:"pointer"},children:i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) repeat(3, minmax(86px, max-content)) 22px",gap:16,alignItems:"center"},children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsx(Pa,{agent:e.agent||e.runtime||"unknown"}),i.jsx("div",{style:{fontSize:15,fontWeight:600,color:"var(--ink)",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",marginTop:4},title:e.title,children:e.title||e.session_id}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginTop:3},title:e.cwd||e.repo_root,children:[Ta(e.repo_root||e.cwd)," - updated ",Ea(e.updated_at)]})]}),i.jsx(co,{label:"saved",value:vn(e.tokens_saved)}),i.jsx(co,{label:"API value",value:Na(e)}),i.jsx(co,{label:"live tokens",value:o!=null&&o.available?vn(o.total_tokens):"n/a"}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:18,lineHeight:1,color:t?r:"var(--ink3)",textAlign:"right"},"aria-hidden":"true",children:t?"-":"+"})]})}),t?i.jsx("div",{style:{borderTop:"1px solid var(--border)",padding:"12px 12px 14px",background:"white"},children:i.jsx(dv,{row:e,showHeader:!1})}):null]})}function av({rows:e,selectedId:t,onSelect:n,loading:r}){return e.length===0?i.jsx(xp,{children:r?"Loading sessions...":"No sessions in this range."}):i.jsx("div",{style:{border:"1px solid var(--border)",borderRadius:6,overflowX:"auto",background:"white"},children:i.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontFamily:"var(--mono)",fontSize:11},children:[i.jsx("thead",{children:i.jsxs("tr",{style:{background:"var(--surface)"},children:[i.jsx(En,{children:"Session"}),i.jsx(En,{children:"Agent"}),i.jsx(En,{children:"State"}),i.jsx(En,{children:"Updated"}),i.jsx(En,{align:"right",children:"Tokens saved"}),i.jsx(En,{align:"right",children:"API value"}),i.jsx(En,{align:"right",children:"Calls"})]})}),i.jsx("tbody",{children:e.map(o=>{const l=t===o.session_id;return i.jsxs("tr",{onClick:()=>n(o.session_id),style:{borderTop:"1px solid var(--border)",background:l?"oklch(0.98 0.02 262)":"white",cursor:"pointer"},children:[i.jsxs(Tn,{title:o.title||o.session_id,children:[i.jsx("div",{style:{color:"var(--ink)",fontWeight:l?700:500,maxWidth:420,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.title||o.session_id}),i.jsx("div",{style:{color:"var(--ink3)",marginTop:2,maxWidth:420,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:o.cwd||o.repo_root,children:Ta(o.repo_root||o.cwd)})]}),i.jsx(Tn,{children:i.jsx(Pa,{agent:o.agent||o.runtime||"unknown"})}),i.jsx(Tn,{children:i.jsx(cv,{state:o.state,active:o.active})}),i.jsx(Tn,{children:Ea(o.updated_at)}),i.jsx(Tn,{align:"right",children:Mn(o.tokens_saved)}),i.jsx(Tn,{align:"right",title:vp(o),children:Na(o)}),i.jsx(Tn,{align:"right",children:Mn(o.router_calls)})]},o.session_id)})})]})})}function dv({row:e,showHeader:t=!0}){var o;const n=e.live_usage,r=Object.entries(e.tool_breakdown||{}).sort((l,s)=>s[1]-l[1]);return i.jsxs("div",{style:{display:"grid",gap:10},children:[t?i.jsxs("div",{children:[i.jsx(Pa,{agent:e.agent||e.runtime||"unknown"}),i.jsx("h2",{style:{margin:"6px 0 4px",fontSize:18,lineHeight:1.25,color:"var(--ink)",letterSpacing:0,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},title:e.title||e.session_id,children:e.title||e.session_id}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.cwd||e.repo_root||void 0,children:[e.model||"model unavailable"," · ",Ta(e.cwd||e.repo_root)]})]}):null,i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:8},children:[i.jsx(an,{label:"tokens saved",value:vn(e.tokens_saved),sub:`${Mn(e.tokens_saved)} avoided`,accent:"var(--green)"}),i.jsx(an,{label:"API value",value:Na(e),sub:Ra(e)?"API value":"model unpriced",accent:"var(--green)"}),i.jsx(an,{label:"router calls",value:Mn(e.router_calls),sub:"cached reads",accent:"var(--ink2)"}),i.jsx(an,{label:"live tokens",value:n!=null&&n.available?vn(n.total_tokens):"n/a",sub:n!=null&&n.available?"native telemetry":"not captured",accent:za(e.agent||e.runtime)})]}),i.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:10,background:"white"},children:[i.jsx(Hn,{children:"Pricing"}),i.jsx("div",{style:{fontSize:12,color:"var(--ink)",marginTop:5},children:vp(e)}),(o=e.pricing)!=null&&o.source?i.jsx("a",{href:e.pricing.source,target:"_blank",rel:"noreferrer",style:{display:"inline-block",marginTop:7,fontFamily:"var(--mono)",fontSize:10,color:"var(--accent)"},children:"official pricing source"}):null]}),n!=null&&n.available?i.jsx(uv,{row:e}):null,i.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:10,background:"white"},children:[i.jsx(Hn,{children:"Read savings by tool"}),r.length===0?i.jsx("div",{style:{color:"var(--ink3)",fontSize:12,marginTop:7},children:"No cached reads yet."}):i.jsx("div",{style:{display:"grid",gap:6,marginTop:8},children:r.map(([l,s])=>i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:10,fontFamily:"var(--mono)",fontSize:11},children:[i.jsx("span",{style:{color:"var(--ink2)"},children:l}),i.jsxs("span",{style:{color:"var(--ink)"},children:[Mn(s)," calls"]})]},l))})]})]})}function uv({row:e}){const t=e.live_usage;if(!(t!=null&&t.available))return i.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:12,background:"white"},children:[i.jsx(Hn,{children:"Live token usage"}),i.jsx("div",{style:{color:"var(--ink3)",fontSize:12,marginTop:8},children:"No exact live token report captured for this session yet."})]});const n=[["Input",t.input_tokens],["Cached input",t.cached_input_tokens],["Output",t.output_tokens],["Reasoning",t.reasoning_output_tokens],["Last turn",t.last_turn_tokens],["Context",t.context_window]];return i.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:12,background:"white"},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[i.jsx(Hn,{children:"Live token usage"}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--green)",whiteSpace:"nowrap"},children:"exact"})]}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:9,marginTop:10},children:n.map(([r,o])=>i.jsx(co,{label:r,value:vn(o)},r))}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginTop:10},children:[t.source||"native telemetry"," - updated ",Ea(t.updated_at||e.updated_at)]})]})}function Qu({title:e,sub:t,action:n,children:r}){return i.jsxs("section",{style:{border:"1px solid var(--border)",background:"var(--bg)",borderRadius:8,padding:16,minWidth:0,boxSizing:"border-box"},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline",marginBottom:12},children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsx(Hn,{children:e}),t?i.jsx("div",{style:{marginTop:4,color:"var(--ink3)",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}):null]}),n?i.jsx("div",{style:{flexShrink:0},children:n}):null]}),r]})}function an({label:e,value:t,sub:n,accent:r}){return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",borderRadius:6,padding:11,minWidth:0},children:[i.jsx(Hn,{children:e}),i.jsx("div",{style:{marginTop:7,fontFamily:"var(--mono)",fontSize:22,lineHeight:1.05,fontWeight:700,color:r,overflow:"hidden",textOverflow:"ellipsis"},children:t}),n?i.jsx("div",{style:{color:"var(--ink3)",fontSize:11,marginTop:4},children:n}):null]})}function co({label:e,value:t}){return i.jsxs("div",{style:{minWidth:80},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:3},children:e}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:14,fontWeight:700,color:"var(--ink)",whiteSpace:"nowrap"},children:t})]})}function Pa({agent:e}){const t=za(e);return i.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontFamily:"var(--mono)",fontSize:10,color:t,textTransform:"uppercase",letterSpacing:"0.06em"},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:999,background:t,flexShrink:0}}),nv(e)]})}function cv({state:e,active:t}){const n=t?"var(--green)":"var(--ink3)";return i.jsx("span",{style:{border:`1px solid ${n}`,color:n,borderRadius:4,padding:"1px 6px",fontSize:10},children:t?"active":e||"n/a"})}function xp({children:e}){return i.jsx("div",{style:{border:"1px dashed var(--border)",color:"var(--ink3)",background:"white",borderRadius:6,padding:18,textAlign:"center",fontSize:12},children:e})}function Hn({children:e}){return i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",letterSpacing:"0.08em",textTransform:"uppercase",fontWeight:700},children:e})}function En({children:e,align:t}){return i.jsx("th",{style:{padding:"8px 10px",textAlign:t||"left",color:"var(--ink2)",fontWeight:700,letterSpacing:"0.04em",borderBottom:"1px solid var(--border)",whiteSpace:"nowrap"},children:e})}function Tn({children:e,align:t,title:n}){return i.jsx("td",{title:n,style:{padding:"8px 10px",textAlign:t||"left",color:"var(--ink2)",verticalAlign:"middle"},children:e})}function fv({tasks:e,projectIndex:t,onSelectTask:n,onSelectSession:r,tweaks:o}){var x,S,E,T,H,h,u,f;const l={green:"var(--green)",indigo:"var(--indigo)",orange:"var(--accent)",rose:"var(--rose)"},s=((x=t==null?void 0:t.workspaces)==null?void 0:x.find(p=>p.id===(t==null?void 0:t.currentWorkspaceId)))||((S=t==null?void 0:t.workspaces)==null?void 0:S[0])||null,a=((E=s==null?void 0:s.projects)==null?void 0:E.find(p=>p.id===(t==null?void 0:t.currentProjectId)))||((T=s==null?void 0:s.projects)==null?void 0:T[0])||null,d=((H=a==null?void 0:a.sessions)==null?void 0:H.find(p=>p.id===(t==null?void 0:t.currentSessionId)))||((h=a==null?void 0:a.sessions)==null?void 0:h[0])||((u=s==null?void 0:s.sessions)==null?void 0:u.find(p=>p.id===(t==null?void 0:t.currentSessionId)))||((f=s==null?void 0:s.sessions)==null?void 0:f[0])||null,c=e.find(p=>p.id===(d==null?void 0:d.taskId))||e[0]||null,g=e.filter(p=>p.id!==(c==null?void 0:c.id)),m=p=>i.jsxs("button",{onClick:()=>n(p.id),style:{display:"grid",gridTemplateColumns:"12px minmax(0, 1fr) 18px",alignItems:"center",gap:14,padding:"14px 0",borderBottom:"1px solid var(--border)",textAlign:"left",background:"transparent"},children:[i.jsx("span",{style:{width:10,height:10,background:l[p.color]||"var(--accent)",display:"inline-block"}}),i.jsxs("span",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:16,fontWeight:560,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.title}),i.jsxs("div",{style:{marginTop:4,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",display:"flex",gap:10,flexWrap:"wrap"},children:[o.showTimestamps&&i.jsx("span",{children:p.created}),i.jsxs("span",{children:[p.messages.length," msgs"]}),p.harness&&i.jsx("span",{children:p.harness})]})]}),i.jsx("span",{style:{color:"var(--ink3)",fontSize:18},children:"→"})]},p.id);return i.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{height:48,borderBottom:"1px solid var(--border)",padding:"0 24px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink3)",letterSpacing:"0.08em"},children:"TASKS"}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[e.length," tracked tasks"]})]}),i.jsxs("div",{style:{flex:1,overflow:"auto",padding:24,display:"grid",gap:20},children:[d&&i.jsxs("div",{onClick:()=>r(d.id,d.taskId||null),style:{border:"1px solid var(--green)",background:"white",padding:18,cursor:"pointer"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10,flexWrap:"wrap"},children:[i.jsx("span",{style:{width:9,height:9,background:"var(--green)",display:"inline-block"}}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"LIVE TASK"}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--accent)"},children:d.runtime})]}),i.jsx("div",{style:{fontSize:24,fontWeight:650,lineHeight:1.2},children:(c==null?void 0:c.title)||d.title}),i.jsx("div",{style:{marginTop:8,fontSize:13,color:"var(--ink2)",lineHeight:1.5},children:d.preview||"Current mirrored session is ready to continue."})]}),i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:18},children:[i.jsx("div",{style:{marginBottom:12,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"TASK HISTORY"}),i.jsxs("div",{style:{display:"grid",gap:0},children:[g.length===0&&i.jsx("div",{style:{padding:"36px 0",textAlign:"center",fontFamily:"var(--mono)",fontSize:11,color:"var(--ink3)"},children:"No task history yet."}),g.map(m)]})]})]})]})}function pv({url:e,title:t,lines:n}){const[r,o]=v.useState(!0);return i.jsxs("div",{style:{border:"1px solid var(--border)",marginTop:8,background:"white"},children:[i.jsxs("div",{onClick:()=>o(l=>!l),style:{borderBottom:r?"1px solid var(--border)":"none",padding:"6px 10px",display:"flex",alignItems:"center",gap:8,background:"var(--surface)",cursor:"pointer"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:1},children:"BROWSER"}),i.jsx("span",{style:{flex:1,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink2)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),i.jsx("span",{style:{fontSize:10,color:"var(--ink3)"},children:r?"▲":"▼"})]}),r&&i.jsxs("div",{style:{padding:"10px 12px"},children:[i.jsx("div",{style:{fontWeight:600,fontSize:13,marginBottom:8},children:t}),n.map((l,s)=>i.jsxs("div",{style:{display:"flex",gap:7,marginBottom:3},children:[i.jsx("span",{style:{color:"var(--accent)",fontFamily:"var(--mono)",fontSize:9,marginTop:2,flexShrink:0},children:"→"}),i.jsx("span",{style:{color:"var(--ink2)",fontSize:12.5,lineHeight:1.4},children:l})]},s))]})]})}function mv({query:e,files:t}){return i.jsxs("div",{style:{border:"1px solid var(--border)",marginTop:8,background:"white"},children:[i.jsxs("div",{style:{borderBottom:"1px solid var(--border)",padding:"6px 10px",display:"flex",gap:8,alignItems:"center",background:"var(--surface)"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:1},children:"GREP"}),i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--accent)"},children:['"',e,'"']}),i.jsxs("span",{style:{marginLeft:"auto",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[t.length," matches"]})]}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11.5},children:t.map((n,r)=>i.jsxs("div",{style:{padding:"8px 12px",borderBottom:ri.jsx("div",{style:{color:n.c==="comment"?"oklch(0.5 0.01 260)":n.c==="bad"?"var(--rose)":n.c==="good"?"var(--green-mid)":"oklch(0.88 0.01 260)"},children:n.t||" "},r))})]})}function gv({title:e,lines:t}){return i.jsxs("div",{style:{border:"1px solid var(--border)",marginTop:8,background:"white"},children:[i.jsxs("div",{style:{borderBottom:"1px solid var(--border)",padding:"6px 12px",display:"flex",gap:8,alignItems:"center",background:"var(--surface)"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:1},children:"DOCUMENT"}),i.jsx("span",{style:{fontSize:11,fontWeight:500,fontFamily:"var(--mono)",color:"var(--ink2)"},children:e})]}),i.jsx("div",{style:{padding:"12px 16px",fontSize:13,lineHeight:1.65},children:t.map((n,r)=>typeof n=="object"&&"h"in n?i.jsx("div",{style:{fontWeight:700,marginTop:r>0?12:0,marginBottom:3,fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--ink2)"},children:n.h},r):i.jsx("div",{style:{color:"var(--ink)"},children:n},r))})]})}function vv({linkedTask:e,preview:t,tasks:n,onSelectTask:r}){const o=n.find(a=>a.id===e);if(!o)return null;const s={green:"var(--green)",indigo:"var(--indigo)",orange:"var(--accent)",rose:"var(--rose)"}[o.color]||"var(--accent)";return i.jsxs("div",{onClick:()=>r(o.id),style:{border:`1px solid ${s}`,marginTop:8,cursor:"pointer",display:"flex",gap:12,padding:"9px 12px",background:"white",transition:"background 0.12s"},onMouseEnter:a=>a.currentTarget.style.background="var(--surface)",onMouseLeave:a=>a.currentTarget.style.background="white",children:[i.jsx("div",{style:{width:8,height:8,background:s,flexShrink:0,marginTop:3}}),i.jsxs("div",{style:{flex:1},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:1,marginBottom:2},children:"LINKED TASK"}),i.jsx("div",{style:{fontWeight:500,fontSize:13},children:o.title}),i.jsx("div",{style:{fontSize:11,color:"var(--ink2)",marginTop:2},children:t})]}),i.jsx("div",{style:{color:s,fontSize:15,alignSelf:"center"},children:"→"})]})}function Yu({msg:e,tasks:t,onSelectTask:n}){if(e.role==="component"){const o=e;return i.jsxs("div",{style:{marginBottom:14,paddingLeft:14},children:[o.type==="browser"&&i.jsx(pv,{url:o.url,title:o.title,lines:o.lines}),o.type==="grep"&&i.jsx(mv,{query:o.query,files:o.files}),o.type==="code"&&i.jsx(hv,{lang:o.lang,lines:o.lines}),o.type==="document"&&i.jsx(gv,{title:o.title,lines:o.lines}),o.type==="link"&&i.jsx(vv,{linkedTask:o.linkedTask,preview:o.preview,tasks:t,onSelectTask:n})]})}const r=e.role==="user";return i.jsxs("div",{style:{marginBottom:13,display:"flex",flexDirection:"column",alignItems:r?"flex-end":"flex-start"},children:[!r&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:4},children:[i.jsx("div",{style:{width:5,height:5,background:"var(--green)",borderRadius:"50%"}}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:1},children:"AGENT"})]}),i.jsx("div",{style:{maxWidth:"88%",padding:"9px 13px",background:r?"var(--ink)":"white",color:r?"var(--bg)":"var(--ink)",border:r?"none":"1px solid var(--border)",fontSize:13.5,lineHeight:1.6,whiteSpace:"pre-wrap"},children:e.content})]})}function yv(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function xv(e){var t;return e?((t=e.currentSession)==null?void 0:t.state)==="active"?"session live":e.installed?"installed":"not attached":"No runtime selected"}function Sv(e){const t=(e==null?void 0:e.mounts)||(e==null?void 0:e.folders)||[],n=t.find(r=>r.primary)||t[0];return(n==null?void 0:n.path)||(e==null?void 0:e.rootPath)||(e==null?void 0:e.workspacePath)||""}function kv({tasks:e,activeTaskId:t,selectedProjectId:n,selectedWorkspaceId:r,selectedSessionId:o,projectIndex:l,workspaceGraph:s,onSelectTask:a,onSelectSession:d,onSelectProject:c,onCanvasOpen:g,onNotepadOpen:m,onAddTaskNote:x,onUpdateWorkspace:S,onAddWorkspaceFolder:E,onRemoveWorkspaceFolder:T,onCreateProject:H,onUpdateProject:h,onTasksRefresh:u,tweaks:f}){var Fa,La,Oa,$a,Da,Ma,Ia,Ba,Aa,Ua,Wa,Ha,Va,Ka,Qa,Ya,Ja,Xa,qa,Za,Ga,ed,td,nd,rd,id,od,ld,sd,ad,dd,ud;const[p,j]=v.useState(null),[_,P]=v.useState([]),[z,Q]=v.useState(""),[R,J]=v.useState(!1),[X,K]=v.useState(!1),[G,M]=v.useState(null),[V,ye]=v.useState(null),[C,A]=v.useState(""),[W,ee]=v.useState(!1),[ie,D]=v.useState(""),[fe,se]=v.useState(""),[me,$]=v.useState(""),[de,ce]=v.useState(""),[he,_e]=v.useState("codex"),[N,oe]=v.useState(""),[q,te]=v.useState(""),[Ae,Ft]=v.useState("codex"),[xe,Me]=v.useState(!1),[je,Fe]=v.useState(null),wn=v.useRef(null),Ut=v.useRef(null),Z=((Fa=l==null?void 0:l.workspaces)==null?void 0:Fa.find(y=>y.id===r))||((La=l==null?void 0:l.workspaces)==null?void 0:La.find(y=>y.id===(s==null?void 0:s.currentWorkspaceId)))||((Oa=l==null?void 0:l.workspaces)==null?void 0:Oa[0])||(s==null?void 0:s.workspace)||null,ae=(($a=Z==null?void 0:Z.projects)==null?void 0:$a.find(y=>y.id===n))||((Da=Z==null?void 0:Z.projects)==null?void 0:Da.find(y=>y.id===(s==null?void 0:s.currentProjectId)))||((Ma=Z==null?void 0:Z.projects)==null?void 0:Ma[0])||null,Se=((Ia=ae==null?void 0:ae.sessions)==null?void 0:Ia.find(y=>y.id===o))||((Ba=ae==null?void 0:ae.sessions)==null?void 0:Ba.find(y=>y.id===(s==null?void 0:s.currentSessionId)))||((Aa=ae==null?void 0:ae.sessions)==null?void 0:Aa[0])||((Ua=Z==null?void 0:Z.sessions)==null?void 0:Ua.find(y=>y.id===o))||((Wa=Z==null?void 0:Z.sessions)==null?void 0:Wa.find(y=>y.id===(s==null?void 0:s.currentSessionId)))||((Ha=Z==null?void 0:Z.sessions)==null?void 0:Ha[0])||null,le=((Va=l==null?void 0:l.workspaces)==null?void 0:Va.find(y=>y.id===(ie||(Z==null?void 0:Z.id))))||Z||null,Ee=((Ka=le==null?void 0:le.projects)==null?void 0:Ka.find(y=>y.id===(fe||(ae==null?void 0:ae.id))))||((Qa=le==null?void 0:le.projects)==null?void 0:Qa[0])||null;v.useEffect(()=>{Z&&!ie&&D(Z.id)},[Z,ie]),v.useEffect(()=>{var y;le&&!le.projects.some(re=>re.id===fe)&&se(((y=le.projects[0])==null?void 0:y.id)||"")},[le,fe]),v.useEffect(()=>{le&&$(le.label||le.name)},[le==null?void 0:le.id]),v.useEffect(()=>{ae&&ce(ae.name)},[ae==null?void 0:ae.id]),v.useEffect(()=>{Ee&&(ce(Ee.name),_e(Ee.defaultRuntime==="claude-code"?"claude-code":"codex"),oe((Ee.scopeRules||[]).map(y=>y.pathPrefix).filter(Boolean).join(` -`)))},[Ee==null?void 0:Ee.id]);const Lt=async y=>{var Le,cd;const re=y||(Se==null?void 0:Se.id);if(re)try{const br=await B.sessionDetail(re);j(br),P(((Le=br.runtime)==null?void 0:Le.runtimes)||[]),M(((cd=br.files)==null?void 0:cd[0])||null),ye(null),Fe(null)}catch(br){Fe(String(br))}},{messages:Qn}=pp(Z==null?void 0:Z.id,ae==null?void 0:ae.id);v.useEffect(()=>{Lt(o||(Se==null?void 0:Se.id))},[o,Z==null?void 0:Z.id]),v.useEffect(()=>{const y=window.setInterval(()=>{Lt(o||(Se==null?void 0:Se.id))},5e3);return()=>window.clearInterval(y)},[o,Se==null?void 0:Se.id]),v.useEffect(()=>{var y;(y=wn.current)==null||y.focus()},[(Ya=p==null?void 0:p.session)==null?void 0:Ya.id]);const w=e.find(y=>y.id===t)||null,b=(p==null?void 0:p.task)||w||null,k=v.useMemo(()=>{var y,re,Le;return(re=(y=p==null?void 0:p.session)==null?void 0:y.messages)!=null&&re.length?p.session.messages:(Le=b==null?void 0:b.messages)!=null&&Le.length?b.messages:[]},[(Ja=p==null?void 0:p.session)==null?void 0:Ja.messages,b]),O=v.useMemo(()=>{var y;return(y=p==null?void 0:p.session)!=null&&y.runtime?_.filter(re=>re.id===p.session.runtime):_},[(Xa=p==null?void 0:p.session)==null?void 0:Xa.runtime,_]),I=async()=>{var re;const y=z.trim();if(!(!y||!b||R)){J(!0);try{await x(b.id,y),Q(""),await u(),await Lt((re=p==null?void 0:p.session)==null?void 0:re.id)}catch(Le){Fe(String(Le))}finally{J(!1)}}},ne=async y=>{var re;if(!(!y||!((re=p==null?void 0:p.session)!=null&&re.id))){K(!0);try{await B.uploadSessionAsset(p.session.id,y),await Lt(p.session.id)}catch(Le){Fe(String(Le))}finally{K(!1),Ut.current&&(Ut.current.value="")}}},ve=async y=>{try{const re=await B.assetContext(y);ye(re)}catch(re){Fe(String(re))}},Ke=()=>{var y,re;Z&&(D(Z.id),$(Z.label||Z.name),se((ae==null?void 0:ae.id)||((re=(y=Z.projects)==null?void 0:y[0])==null?void 0:re.id)||"")),ee(!0),Fe(null)},st=async()=>{if(!(!le||!me.trim()||xe)){Me(!0);try{await S(le.id,me.trim()),Fe(null)}catch(y){Fe(String(y))}finally{Me(!1)}}},Ue=async()=>{if(!(!le||xe)){Me(!0),Fe(null);try{const y=await B.pickFolder("Select a folder to mount in this workspace");y.ok&&y.path&&await E(le.id,y.path)}catch(y){Fe(String(y))}finally{Me(!1)}}},Yn=async y=>{if(!(!le||xe)){Me(!0),Fe(null);try{await T(le.id,y)}catch(re){Fe(String(re))}finally{Me(!1)}}},Sp=async()=>{if(!Ee||xe)return;const y=N.split(` -`).map(re=>re.trim()).filter(Boolean).map((re,Le)=>({path_prefix:re,label:Le===0?"primary":`scope-${Le+1}`}));Me(!0),Fe(null);try{await h(Ee.id,{name:de.trim()||Ee.name,default_runtime:he,scope_rules:y})}catch(re){Fe(String(re))}finally{Me(!1)}};return!ae||!Z||!Se?i.jsx("div",{style:{height:"100%",display:"grid",alignItems:"center",justifyContent:"center",padding:28},children:i.jsx(hp,{title:"No mirrored workspace session yet",body:"Add a repo folder or start a task from an existing workspace. Once an agent session is mirrored, this view becomes the working console.",actions:[{label:"ADD REPO FOLDER",onClick:g,tone:"primary"},{label:"START TASK",onClick:m}]})}):i.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[i.jsxs("div",{style:{borderBottom:"1px solid var(--border)",padding:"0 14px",height:48,display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0,flex:1},children:[i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[Z.label||Z.name," / ",ae.name]}),i.jsx("span",{style:{fontSize:14,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((qa=p==null?void 0:p.session)==null?void 0:qa.title)||Se.title}),i.jsx($e,{label:`${((Za=p==null?void 0:p.session)==null?void 0:Za.runtime)||Se.runtime}`.replace("-"," "),tone:"var(--green)"}),i.jsx($e,{label:((Ga=p==null?void 0:p.session)==null?void 0:Ga.permissionMode)||Se.permissionMode||"native"}),i.jsx($e,{label:((ed=p==null?void 0:p.session)==null?void 0:ed.state)||Se.state})]}),i.jsx("button",{onClick:()=>{var y;return void Lt((y=p==null?void 0:p.session)==null?void 0:y.id)},style:{height:48,padding:"0 12px",borderLeft:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink2)"},children:"REFRESH"}),i.jsx("button",{onClick:g,style:{height:48,padding:"0 14px",borderLeft:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink2)"},children:"⊞ CANVAS"}),i.jsx("button",{onClick:Ke,style:{height:48,padding:"0 14px",borderLeft:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink2)"},children:"MANAGE"})]}),i.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[i.jsxs("div",{style:{width:f.compactNav?74:260,borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",overflowY:"auto"},children:[i.jsxs("div",{style:{padding:"12px 12px 10px",borderBottom:"1px solid var(--border)"},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:8},children:"WORKSPACE"}),i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:10,marginBottom:12},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:Z.label||Z.name}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",lineHeight:1.5},children:[(Z.folders||Z.mounts||[]).length," mounted folders · ",Z.sessionCount||Z.sessions.length," sessions"]}),i.jsx("button",{onClick:Ke,style:{marginTop:8,padding:"6px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--accent)"},children:"manage workspace"})]}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:8},children:"PROJECTS"}),Z.projects.map(y=>i.jsx("div",{style:{marginBottom:10},children:i.jsxs("button",{onClick:()=>c(y.id,Z.id),style:{width:"100%",textAlign:"left",padding:"8px 9px",border:`1px solid ${y.id===ae.id?"var(--border2)":"var(--border)"}`,background:y.id===ae.id?"var(--surface)":"white",fontSize:12,fontWeight:y.id===ae.id?700:500,color:y.id===ae.id?"var(--ink)":"var(--ink2)"},children:[y.name,i.jsxs("div",{style:{marginTop:4,fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[y.sessions.length," sessions · default ",y.defaultRuntime||"codex"]})]})},y.id))]}),i.jsxs("div",{style:{padding:"12px"},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:8},children:"SESSIONS"}),(ae.sessions||[]).map(y=>{var re,Le;return i.jsxs("button",{onClick:()=>d(y.id,y.taskId),style:{width:"100%",textAlign:"left",padding:"9px 10px",marginBottom:8,border:`1px solid ${((re=p==null?void 0:p.session)==null?void 0:re.id)===y.id?"var(--green)":"var(--border)"}`,background:((Le=p==null?void 0:p.session)==null?void 0:Le.id)===y.id?"oklch(0.98 0.02 145)":"white"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:y.title}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[y.runtime," · ",y.model||"unknown model"]}),i.jsx("div",{style:{fontSize:10.5,color:"var(--ink3)",marginTop:6,lineHeight:1.4},children:y.preview||"No preview yet."})]},y.id)})]})]}),i.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[i.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",display:"flex",gap:8,flexWrap:"wrap"},children:[i.jsx($e,{label:((td=p==null?void 0:p.session)==null?void 0:td.runtime)||Se.runtime,tone:"var(--green)"}),i.jsx($e,{label:((nd=p==null?void 0:p.session)==null?void 0:nd.taskStatus)||(b==null?void 0:b.status)||"mirrored"}),i.jsx($e,{label:`${((id=(rd=p==null?void 0:p.session)==null?void 0:rd.touchedFiles)==null?void 0:id.length)||0} files`}),i.jsx($e,{label:`${((od=p==null?void 0:p.assets)==null?void 0:od.length)||0} assets`}),i.jsx($e,{label:`${((ld=p==null?void 0:p.results)==null?void 0:ld.length)||0} shared results`})]}),i.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 18px 8px"},children:[k.length===0&&i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink3)"},children:"No mirrored messages yet."}),k.map(y=>i.jsx(Yu,{msg:y,tasks:e,onSelectTask:a},y.id)),(sd=p==null?void 0:p.results)==null?void 0:sd.slice(0,8).map(y=>i.jsx(Yu,{msg:{id:`result:${y.id}`,role:"agent",content:`${y.tool_name}: ${y.digest||"No digest recorded."}`},tasks:e,onSelectTask:a},y.id)),i.jsx("div",{style:{height:1}})]}),i.jsxs("div",{style:{borderTop:"1px solid var(--border)",padding:"12px 16px"},children:[i.jsx("textarea",{ref:wn,value:z,onChange:y=>Q(y.target.value),placeholder:b?"Add a Dhee note to this session task…":"This mirrored session has no linked Dhee task yet.",rows:3,disabled:!b,style:{width:"100%",fontFamily:"var(--font)",fontSize:14,lineHeight:1.5,border:"1px solid var(--border)",padding:"12px 14px",background:b?"white":"var(--surface)"}}),i.jsxs("div",{style:{marginTop:10,display:"flex",gap:10,alignItems:"center"},children:[i.jsx("button",{onClick:()=>void I(),disabled:!b||R,style:{padding:"7px 14px",border:"1px solid var(--ink)",background:b?"var(--ink)":"transparent",color:b?"white":"var(--ink3)",fontFamily:"var(--mono)",fontSize:10},children:R?"saving…":"save note"}),je&&i.jsx("span",{style:{fontSize:11,color:"var(--rose)"},children:je})]})]})]}),i.jsxs("div",{style:{width:320,borderLeft:"1px solid var(--border)",overflowY:"auto",padding:"14px 14px 18px"},children:[i.jsxs("div",{style:{marginBottom:18},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:10},children:"RUNTIME"}),O.map(y=>{var re,Le;return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:12,marginBottom:10},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,marginBottom:6},children:[i.jsx("div",{style:{fontSize:12.5,fontWeight:600},children:y.label}),i.jsx($e,{label:xv(y),tone:y.installed?"var(--green)":"var(--rose)"})]}),i.jsx("div",{style:{fontSize:11,color:"var(--ink2)"},children:((re=y.currentSession)==null?void 0:re.title)||((Le=y.currentSession)==null?void 0:Le.cwd)||"No active session"}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:6},children:["limit: ",y.limits.state,y.limits.resetAt?` · reset ${yv(y.limits.resetAt)}`:""]})]},y.id)})]}),i.jsxs("div",{style:{marginBottom:18},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:10},children:"COLLABORATION LINE"}),i.jsx(fp,{workspace:Z,activeProjectId:ae==null?void 0:ae.id,sessionId:((ad=p==null?void 0:p.session)==null?void 0:ad.id)||(Se==null?void 0:Se.id),taskId:b==null?void 0:b.id,onPublished:async()=>{await u()}}),i.jsx("div",{style:{display:"grid",gap:8,marginTop:10},children:(Qn||[]).slice(0,8).map(y=>i.jsx(cp,{message:y,workspace:Z},y.id))})]}),i.jsxs("div",{style:{marginBottom:18},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:10},children:"FILE CONTEXT"}),(dd=p==null?void 0:p.files)==null?void 0:dd.map(y=>i.jsxs("button",{onClick:()=>M(y),style:{width:"100%",textAlign:"left",padding:"10px 11px",border:`1px solid ${(G==null?void 0:G.path)===y.path?"var(--indigo)":"var(--border)"}`,background:"white",marginBottom:8},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:y.path.split("/").pop()}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[y.results.length," results · ",y.memories.length," memories"]})]},y.path)),G&&i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:12},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:G.path}),i.jsx("div",{style:{fontSize:11,color:"var(--ink2)",lineHeight:1.5,marginBottom:8},children:G.summary||"No stored summary yet."}),G.results.slice(0,3).map(y=>i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6},children:[y.tool_name,": ",String(y.digest||"").slice(0,120)]},y.id))]})]}),i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"SESSION ASSETS"}),i.jsx("button",{onClick:()=>{var y;return(y=Ut.current)==null?void 0:y.click()},style:{padding:"4px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--accent)"},children:X?"uploading…":"upload"})]}),i.jsx("input",{ref:Ut,type:"file",hidden:!0,onChange:y=>{var re;return void ne((re=y.target.files)==null?void 0:re[0])}}),(ud=p==null?void 0:p.assets)==null?void 0:ud.map(y=>i.jsxs("button",{onClick:()=>void ve(y.id),style:{width:"100%",textAlign:"left",border:"1px solid var(--border)",background:"white",padding:12,marginBottom:8},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:y.name}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[y.mime_type||"file"," · ",(y.size_bytes||0).toLocaleString()," bytes"]})]},y.id)),V&&i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:12,marginTop:10},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:V.asset.name}),i.jsx("div",{style:{fontSize:11,color:"var(--ink2)",lineHeight:1.5,marginBottom:8},children:V.summary||"No extracted summary yet. Re-upload or parse this asset to make it queryable."}),(V.chunks||[]).slice(0,3).map(y=>i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6},children:["chunk ",y.chunk_index,": ",y.content.slice(0,180)]},`${V.asset.id}:${y.chunk_index}`)),i.jsx("textarea",{value:C,onChange:y=>A(y.target.value),placeholder:"Ask Dhee about this asset…",rows:3,style:{width:"100%",border:"1px solid var(--border)",padding:"10px 12px",marginTop:8,background:"var(--bg)"}}),i.jsx("button",{onClick:async()=>{var y;if(C.trim())try{const re=await B.askAsset(V.asset.id,C.trim());A(""),(y=re.launch)!=null&&y.session_id&&d(re.launch.session_id,re.launch.task_id||null)}catch(re){Fe(String(re))}},style:{marginTop:8,padding:"8px 12px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10},children:"ask with default claude code"})]})]})]})]}),W&&ae&&le&&i.jsx("div",{onClick:()=>ee(!1),style:{position:"fixed",inset:0,background:"rgba(12, 12, 12, 0.22)",display:"flex",alignItems:"center",justifyContent:"center",padding:24,zIndex:80},children:i.jsxs("div",{onClick:y=>y.stopPropagation(),style:{width:"min(1040px, calc(100vw - 80px))",maxHeight:"calc(100vh - 80px)",background:"var(--bg)",border:"1px solid var(--border2)",display:"grid",gridTemplateColumns:"280px minmax(0, 1fr)",overflow:"hidden",boxShadow:"0 30px 80px rgba(0,0,0,0.12)"},children:[i.jsxs("div",{style:{borderRight:"1px solid var(--border)",background:"white",overflowY:"auto"},children:[i.jsxs("div",{style:{padding:16,borderBottom:"1px solid var(--border)"},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"WORKSPACES"}),i.jsx("div",{style:{marginTop:6,fontSize:13,fontWeight:600},children:"switch workspace"})]}),i.jsx("div",{style:{padding:12},children:((l==null?void 0:l.workspaces)||[]).map(y=>i.jsxs("button",{onClick:()=>{var re,Le;D(y.id),se(((Le=(re=y.projects)==null?void 0:re[0])==null?void 0:Le.id)||"")},style:{width:"100%",textAlign:"left",padding:"10px 12px",marginBottom:8,border:`1px solid ${y.id===le.id?"var(--accent)":"var(--border)"}`,background:y.id===le.id?"rgba(224, 107, 63, 0.06)":"white"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:y.label||y.name}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[y.sessionCount||y.sessions.length," sessions · ",(y.folders||y.mounts||[]).length," folders"]})]},y.id))})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{padding:"16px 18px",borderBottom:"1px solid var(--border)",background:"white",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[i.jsxs("div",{children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"WORKSPACE SETTINGS"}),i.jsx("div",{style:{marginTop:6,fontSize:18,fontWeight:650},children:le.label||le.name})]}),i.jsx("button",{onClick:()=>ee(!1),style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"close"})]}),i.jsxs("div",{style:{flex:1,overflowY:"auto",padding:18},children:[i.jsxs("div",{style:{marginBottom:24},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginBottom:10},children:"RENAME"}),i.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[i.jsx("input",{value:me,onChange:y=>$(y.target.value),placeholder:"Workspace name",style:{flex:1,border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:14}}),i.jsx("button",{onClick:()=>void st(),disabled:!me.trim()||xe,style:{padding:"10px 12px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10,opacity:!me.trim()||xe?.6:1},children:xe?"saving...":"save name"})]})]}),i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12,marginBottom:10},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"MOUNTED FOLDERS"}),i.jsx("button",{onClick:()=>void Ue(),disabled:xe,style:{padding:"8px 10px",border:"1px solid var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:9,color:"var(--accent)"},children:xe?"working...":"add folder"})]}),i.jsx("div",{style:{display:"grid",gap:10},children:(le.folders||le.mounts||[]).map(y=>i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:12,display:"flex",justifyContent:"space-between",gap:12,alignItems:"flex-start"},children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:y.primary?"root folder":y.label}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",lineHeight:1.5,wordBreak:"break-all"},children:y.path})]}),i.jsx("button",{onClick:()=>void Yn(y.path),disabled:xe||(le.folders||le.mounts||[]).length<=1,style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--rose)",opacity:xe||(le.folders||le.mounts||[]).length<=1?.5:1},children:"remove"})]},y.path))}),i.jsx("div",{style:{marginTop:10,fontSize:11,color:"var(--ink3)",lineHeight:1.5},children:"Sessions are included in this workspace by matching their working directory against these mounted folders. Removing a folder removes those sessions from this workspace view without deleting the mirrored session record."})]}),i.jsxs("div",{style:{marginTop:24},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginBottom:10},children:"PROJECTS"}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"240px minmax(0, 1fr)",gap:14},children:[i.jsx("div",{style:{display:"grid",gap:10,alignContent:"start"},children:(le.projects||[]).map(y=>i.jsxs("button",{onClick:()=>se(y.id),style:{width:"100%",textAlign:"left",border:`1px solid ${y.id===(Ee==null?void 0:Ee.id)?"var(--accent)":"var(--border)"}`,background:y.id===(Ee==null?void 0:Ee.id)?"rgba(224, 107, 63, 0.06)":"white",padding:12},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600},children:y.name}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:4},children:[y.sessions.length," sessions · default ",y.defaultRuntime||"codex"]})]},y.id))}),i.jsxs("div",{style:{display:"grid",gap:12,alignContent:"start"},children:[Ee?i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginBottom:10},children:"EDIT PROJECT"}),i.jsxs("div",{style:{display:"grid",gap:10},children:[i.jsx("input",{value:de,onChange:y=>ce(y.target.value),placeholder:"Project name",style:{border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:14}}),i.jsxs("select",{value:he,onChange:y=>_e(y.target.value),style:{border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:14},children:[i.jsx("option",{value:"codex",children:"Codex default runtime"}),i.jsx("option",{value:"claude-code",children:"Claude Code default runtime"})]}),i.jsx("textarea",{value:N,onChange:y=>oe(y.target.value),rows:5,placeholder:"One path scope rule per line",style:{border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:13,lineHeight:1.5}}),i.jsx("div",{style:{fontSize:11,color:"var(--ink3)",lineHeight:1.5},children:"Sessions are assigned to this project by the longest matching scope rule path."}),i.jsx("button",{onClick:()=>void Sp(),disabled:xe||!de.trim(),style:{justifySelf:"start",padding:"10px 12px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10,opacity:xe||!de.trim()?.6:1},children:xe?"saving...":"save project"})]})]}):null,i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginBottom:10},children:"ADD PROJECT"}),i.jsxs("div",{style:{display:"grid",gap:10},children:[i.jsx("input",{value:q,onChange:y=>te(y.target.value),placeholder:"New project name",style:{border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:14}}),i.jsxs("select",{value:Ae,onChange:y=>Ft(y.target.value),style:{border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:14},children:[i.jsx("option",{value:"codex",children:"Codex default runtime"}),i.jsx("option",{value:"claude-code",children:"Claude Code default runtime"})]}),i.jsx("button",{onClick:async()=>{if(!(!le||!q.trim())){Me(!0);try{await H(le.id,{name:q.trim(),default_runtime:Ae,scope_rules:[{path_prefix:Sv(le),label:"root"}]}),te("")}catch(y){Fe(String(y))}finally{Me(!1)}}},style:{justifySelf:"start",padding:"10px 12px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10},children:"add project"})]})]})]})]})]}),je&&i.jsx("div",{style:{marginTop:18,fontSize:11,color:"var(--rose)"},children:je})]})]})]})})]})}const jv=v.lazy(()=>qh(()=>import("./CanvasView-Dg15id0Q.js"),[]).then(e=>({default:e.CanvasView}))),wv={accentHue:"36",compactNav:!1,showTimestamps:!0,canvasStyle:"force"},Cv=15e3,bv=new Set(["command","handoff","replay","learnings","portability"]);function Yi(e){return bv.has(e)}function Ol(e){return e==="canvas"}function $l(e){return e==="router"||e==="router/sessionshistory"}function Ji(e){const t=String(e||"").toLowerCase();return t==="home"||t==="overview"?"command":t==="memory"?"context":t==="firewall"||t==="context-firewall"?"router":t==="repo"||t==="brain"||t==="repo-brain"||t==="folders"?"canvas":t==="learn"||t==="learning"?"learnings":t==="packs"||t==="portable"||t==="trust"?"portability":t==="router/sessionshistory"||t==="router/session-history"||t==="router/history"?"router/sessionshistory":t||"command"}function Mr(e){return typeof window>"u"?"":new URLSearchParams(window.location.search).get(e)||""}function _v(){const[e,t]=v.useState(()=>Ji(Mr("view"))),[n,r]=v.useState(!1),[o,l]=v.useState("workspaces"),[s,a]=v.useState([]),[d,c]=v.useState(()=>Mr("task")),[g,m]=v.useState(wv),[x,S]=v.useState(!1),[E,T]=v.useState(0),[H,h]=v.useState([]),[u,f]=v.useState(0),[p,j]=v.useState(0),[_,P]=v.useState(!1),[z,Q]=v.useState(null),[R,J]=v.useState(null),[X,K]=v.useState(null),[G,M]=v.useState(null),[V,ye]=v.useState(0),[C,A]=v.useState(null),[W,ee]=v.useState(()=>Mr("project")),[ie,D]=v.useState(()=>Mr("workspace")),[fe,se]=v.useState(()=>Mr("session")),me=v.useRef({}),$=(k,O,I)=>{let ne="";try{ne=JSON.stringify(O)||""}catch{ne=String(Date.now())}me.current[k]!==ne&&(me.current[k]=ne,I(O))};v.useEffect(()=>{const k=new URLSearchParams(window.location.search),O=k.get("view"),I=k.get("task"),ne=k.get("project"),ve=k.get("workspace"),Ke=k.get("session");O&&t(Ji(O)),I&&c(I),ne&&ee(ne),ve&&D(ve),Ke&&se(Ke);const st=()=>{const Ue=new URLSearchParams(window.location.search);t(Ji(Ue.get("view"))),c(Ue.get("task")||""),ee(Ue.get("project")||""),D(Ue.get("workspace")||""),se(Ue.get("session")||"")};return window.addEventListener("popstate",st),()=>window.removeEventListener("popstate",st)},[]);const de=async()=>{try{const k=await B.tasks();$("tasks",k.tasks||[],a),c(O=>{var I,ne;return O||((ne=(I=k.tasks)==null?void 0:I[0])==null?void 0:ne.id)||""})}catch{}},ce=async()=>{try{const k=ie?await B.workspaceGraph(ie,W||void 0):await B.workspaceGraph();$("workspaceGraph",k,Q)}catch{}},he=async()=>{try{const k=await B.orgGraph(void 0,{active:!0});$("orgGraph",k,J)}catch{}},_e=async()=>{try{const k=await B.me();$("viewer",k,K)}catch{}},N=async()=>{try{const k=await B.routerStats();$("routerStats",k,M),f(k.sessionTokensSaved||0)}catch{}},oe=async()=>{var k,O,I,ne;try{const ve=await B.inbox(X!=null&&X.team_id?{team:X.team_id,user:X.user_id}:{user:X==null?void 0:X.user_id}),Ke=(((k=ve.totals)==null?void 0:k.proposals)||0)+(((O=ve.totals)==null?void 0:O.findings)||0)+(((I=ve.totals)==null?void 0:I.conflicts)||0);ye(Ke),j(((ne=ve.totals)==null?void 0:ne.conflicts)||0)}catch{}},q=async()=>{try{const k=await B.workspaces();$("projectIndex",k,A),D(O=>{var I,ne;return O||k.currentWorkspaceId||((ne=(I=k.workspaces)==null?void 0:I[0])==null?void 0:ne.id)||""}),ee(O=>{var I,ne,ve,Ke;return O||k.currentProjectId||((Ke=(ve=(ne=(I=k.workspaces)==null?void 0:I[0])==null?void 0:ne.projects)==null?void 0:ve[0])==null?void 0:Ke.id)||""}),se(O=>O||k.currentSessionId||"")}catch{}};v.useEffect(()=>{if(_e(),oe(),Yi(e)||N(),Ol(e))he();else{if($l(e))return;Yi(e)||(de(),he(),q().then(()=>ce()),(async()=>{var k;try{const O=await B.listMemories();T(((k=O.engrams)==null?void 0:k.length)||0),h(O.engrams||[])}catch{}})())}},[]),v.useEffect(()=>{const k=window.setInterval(()=>{if(Yi(e)){oe();return}if($l(e)){N(),oe();return}if(Ol(e)){he(),oe();return}de(),q(),ce(),he(),N(),oe()},Cv);return()=>window.clearInterval(k)},[e,ie,W,X==null?void 0:X.team_id]),v.useEffect(()=>{if(!Yi(e)){if($l(e)){N(),oe();return}if(Ol(e)){he();return}de(),q().then(()=>ce()),he(),(async()=>{var k;try{const O=await B.listMemories();T(((k=O.engrams)==null?void 0:k.length)||0),h(O.engrams||[])}catch{}})()}},[e]);const te=(k,O)=>{const I=Ji(k);P(!0),setTimeout(()=>{O&&c(O),t(I);const ne=new URLSearchParams(window.location.search);ne.set("view",I),O||d?ne.set("task",O||d):ne.delete("task"),W?ne.set("project",W):ne.delete("project"),ie?ne.set("workspace",ie):ne.delete("workspace"),fe?ne.set("session",fe):ne.delete("session");const ve=ne.toString(),Ke=ve?`?${ve}`:"",st=I==="context"&&window.location.hash.startsWith("#vault")?window.location.hash:"";window.history.pushState({},"",`${window.location.pathname}${Ke}${st}`),P(!1)},140)},Ae=k=>te("workspace",k),Ft=(k,O)=>{k&&se(k),O&&c(O),te("workspace",O||void 0)},xe=k=>{D(k),ee(""),se(""),te("workspace")},Me=(k,O)=>{O&&D(O),ee(k),se(""),te("workspace")};v.useEffect(()=>{const k=new URLSearchParams(window.location.search);k.set("view",e),d?k.set("task",d):k.delete("task"),W?k.set("project",W):k.delete("project"),ie?k.set("workspace",ie):k.delete("workspace"),fe?k.set("session",fe):k.delete("session");const O=k.toString(),I=`${window.location.pathname}${O?"?"+O:""}`;I!==`${window.location.pathname}${window.location.search}`&&window.history.replaceState({},"",I)},[e,d,W,ie,fe]);const je=async k=>{await B.createWorkspaceRoot(k),await q(),await ce()},Fe=async(k,O)=>{await B.createProject(k,O),await q(),await ce()},wn=async(k,O)=>{await B.updateProject(k,O),await q(),await ce()},Ut=async(k,O,I)=>{await B.addWorkspaceFolder(k,O,I),await q(),await ce()},Z=async(k,O)=>{await B.updateWorkspace(k,{label:O}),await q(),await ce()},ae=async(k,O)=>{await B.removeWorkspaceFolder(k,O),await q(),await ce()},Se=async k=>{try{const O=await B.createTask(k);a(I=>[...I,O.task]),await q(),setTimeout(()=>te("workspace",O.task.id),80)}catch(O){console.warn("createTask failed",O)}},le=async k=>{try{await B.remember(k,"short-term",[]),T(I=>I+1);const O=await B.listMemories();h(O.engrams||[])}catch(O){console.warn("remember failed",O)}},Ee=async(k,O,I,ne,ve)=>{const Ke=I||ie||(C==null?void 0:C.currentWorkspaceId);if(!Ke||!k.trim())return;const st=await B.launchWorkspaceSession(Ke,O,k.trim(),O==="claude-code"?ne:void 0,void 0,ve||W||(C==null?void 0:C.currentProjectId));await de(),await q(),await ce(),st.session_id&&se(st.session_id),st.task_id&&c(st.task_id),te("workspace",st.task_id||void 0)},Lt=async(k,O)=>{try{await B.addTaskNote(k,O),await de(),await q()}catch(I){console.warn("addTaskNote failed",I)}},Qn={opacity:_?0:1,transform:_?"translateY(3px)":"translateY(0)",transition:"opacity 0.14s ease, transform 0.14s ease",flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},w=()=>e==="command"?i.jsx(Hg,{onNavigate:k=>te(k)}):e==="channel"?i.jsx(yg,{projectIndex:C,workspaceGraph:z,tasks:s,viewer:X,orgGraph:R,selectedWorkspaceId:ie,selectedProjectId:W,onSelectWorkspace:xe,onSelectProject:Me,onSelectTask:Ae,onTasksRefresh:de,onOpenCanvas:()=>te("canvas"),onLaunchSession:Ee,onOpenManager:k=>{l(k||"workspaces"),r(!0)},tweaks:g}):e==="notepad"?i.jsx(Ug,{projectIndex:C,memories:E,tokensSaved:u,onAddTask:Se,onAddMemory:le,onSelectSession:Ft,onCreateWorkspace:je,onLaunchSession:Ee,onCreateProject:Fe,onOpenWorkspace:()=>te("workspace"),onOpenTasks:()=>te("tasks"),tweaks:g}):e==="tasks"?i.jsx(fv,{tasks:s,projectIndex:C,onSelectTask:Ae,onSelectSession:Ft,tweaks:g}):e==="workspace"?i.jsx(kv,{tasks:s,activeTaskId:d,selectedProjectId:W,selectedWorkspaceId:ie,selectedSessionId:fe,projectIndex:C,workspaceGraph:z,onSelectTask:Ae,onSelectSession:Ft,onSelectProject:Me,onCanvasOpen:()=>te("canvas"),onNotepadOpen:()=>te("context"),onAddTaskNote:Lt,onUpdateWorkspace:Z,onAddWorkspaceFolder:Ut,onRemoveWorkspaceFolder:ae,onCreateProject:Fe,onUpdateProject:wn,onTasksRefresh:de,tweaks:g}):e==="canvas"?i.jsx(v.Suspense,{fallback:i.jsx("div",{style:{height:"100%",display:"grid",alignItems:"start",background:"var(--surface)",padding:20},children:i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:"16px 18px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:18},children:[i.jsxs("div",{children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--green)",letterSpacing:"0.12em",textTransform:"uppercase"},children:"Repo Brain"}),i.jsx("div",{style:{marginTop:6,fontSize:20,fontWeight:650},children:"Loading folder canvas"})]}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",textTransform:"uppercase"},children:"Context Vault"})]})}),children:i.jsx(jv,{tasks:s,selectedProjectId:W,workspaceGraph:z,orgGraph:R,viewer:X,onOpenVault:k=>{k&&(window.location.hash=`#vault/${k}`),te("context")},onOrgGraphChanged:()=>{he(),_e(),oe()},onSelectTask:Ae,onSelectSession:Ft,onSelectWorkspace:xe,onSelectProject:Me,onClose:()=>te("workspace"),tweaks:g})}):e==="memory"||e==="context"?i.jsx(Dg,{onMemoryCountChange:T,viewer:X,orgGraph:R,onInboxChanged:oe}):e==="router"||e==="router/sessionshistory"?i.jsx(ov,{onOpenFolders:()=>te("canvas"),onOpenSetup:()=>te("notepad")}):e==="handoff"?i.jsx(Vg,{}):e==="replay"?i.jsx(Kg,{}):e==="learnings"?i.jsx(Qg,{}):e==="portability"?i.jsx(Yg,{}):e==="conflicts"?i.jsx(kg,{viewer:X,onChanged:oe}):null;v.useEffect(()=>{const k=O=>{(O.ctrlKey||O.metaKey)&&O.key.toLowerCase()==="k"&&(O.preventDefault(),S(I=>!I))};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[]);const b=()=>{_e(),de(),q(),ce(),he(),N(),oe()};return i.jsxs("div",{style:{height:"100vh",display:"flex",overflow:"hidden"},children:[i.jsx(Zh,{view:e,setView:k=>te(k),conflictCount:V||p}),i.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsx(tg,{viewer:X,routerStats:G,onRefresh:b,onOpenTweaks:()=>S(k=>!k),onResetWorkspace:async()=>{if(window.confirm("Reset workspace? Deletes projects, teams, folders, context items, proposals and findings for this org. Memory engrams are unaffected."))try{await B.enterpriseResetWorkspace()}finally{b()}}}),i.jsx("div",{style:Qn,children:w()})]}),i.jsx(ng,{tweaks:g,setTweaks:m,visible:x}),i.jsx(og,{open:n,onClose:()=>r(!1),projectIndex:C,initialWorkspaceId:ie,initialTab:o,onChanged:async()=>{await q(),await ce()}})]})}Dl.createRoot(document.getElementById("root")).render(i.jsx(Dp.StrictMode,{children:i.jsx(_v,{})}));export{Ev as R,B as a,i as j,v as r}; diff --git a/dhee/ui/web/dist/assets/index-BboZhdsv.js b/dhee/ui/web/dist/assets/index-BboZhdsv.js new file mode 100644 index 0000000..414dd1e --- /dev/null +++ b/dhee/ui/web/dist/assets/index-BboZhdsv.js @@ -0,0 +1,51 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const s of l.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function bp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Gu={exports:{}},Vo={},ec={exports:{}},ce={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var _i=Symbol.for("react.element"),Cp=Symbol.for("react.portal"),Ep=Symbol.for("react.fragment"),Tp=Symbol.for("react.strict_mode"),zp=Symbol.for("react.profiler"),Np=Symbol.for("react.provider"),Rp=Symbol.for("react.context"),Pp=Symbol.for("react.forward_ref"),Fp=Symbol.for("react.suspense"),Lp=Symbol.for("react.memo"),Op=Symbol.for("react.lazy"),hd=Symbol.iterator;function $p(e){return e===null||typeof e!="object"?null:(e=hd&&e[hd]||e["@@iterator"],typeof e=="function"?e:null)}var tc={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},nc=Object.assign,rc={};function Cr(e,t,n){this.props=e,this.context=t,this.refs=rc,this.updater=n||tc}Cr.prototype.isReactComponent={};Cr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Cr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ic(){}ic.prototype=Cr.prototype;function Ds(e,t,n){this.props=e,this.context=t,this.refs=rc,this.updater=n||tc}var Ms=Ds.prototype=new ic;Ms.constructor=Ds;nc(Ms,Cr.prototype);Ms.isPureReactComponent=!0;var md=Array.isArray,oc=Object.prototype.hasOwnProperty,Is={current:null},lc={key:!0,ref:!0,__self:!0,__source:!0};function sc(e,t,n){var r,o={},l=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(l=""+t.key),t)oc.call(t,r)&&!lc.hasOwnProperty(r)&&(o[r]=t[r]);var a=arguments.length-2;if(a===1)o.children=n;else if(1>>1,ie=_[ee];if(0>>1;eeo(ae,K))meo($,ae)?(_[ee]=$,_[me]=K,ee=me):(_[ee]=ae,_[pe]=K,ee=pe);else if(meo($,K))_[ee]=$,_[me]=K,ee=me;else break e}}return W}function o(_,W){var K=_.sortIndex-W.sortIndex;return K!==0?K:_.id-W.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var s=Date,a=s.now();e.unstable_now=function(){return s.now()-a}}var d=[],c=[],g=1,h=null,y=3,S=!1,w=!1,T=!1,V=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,u=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function f(_){for(var W=n(c);W!==null;){if(W.callback===null)r(c);else if(W.startTime<=_)r(c),W.sortIndex=W.expirationTime,t(d,W);else break;W=n(c)}}function p(_){if(T=!1,f(_),!w)if(n(d)!==null)w=!0,U(j);else{var W=n(c);W!==null&&se(p,W.startTime-_)}}function j(_,W){w=!1,T&&(T=!1,m(z),z=-1),S=!0;var K=y;try{for(f(W),h=n(d);h!==null&&(!(h.expirationTime>W)||_&&!J());){var ee=h.callback;if(typeof ee=="function"){h.callback=null,y=h.priorityLevel;var ie=ee(h.expirationTime<=W);W=e.unstable_now(),typeof ie=="function"?h.callback=ie:h===n(d)&&r(d),f(W)}else r(d);h=n(d)}if(h!==null)var M=!0;else{var pe=n(c);pe!==null&&se(p,pe.startTime-W),M=!1}return M}finally{h=null,y=K,S=!1}}var E=!1,P=null,z=-1,Y=5,N=-1;function J(){return!(e.unstable_now()-N_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Y=0<_?Math.floor(1e3/_):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(_){switch(y){case 1:case 2:case 3:var W=3;break;default:W=y}var K=y;y=W;try{return _()}finally{y=K}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(_,W){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var K=y;y=_;try{return W()}finally{y=K}},e.unstable_scheduleCallback=function(_,W,K){var ee=e.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0ee?(_.sortIndex=K,t(c,_),n(d)===null&&_===n(c)&&(T?(m(z),z=-1):T=!0,se(p,K-ee))):(_.sortIndex=ie,t(d,_),w||S||(w=!0,U(j))),_},e.unstable_shouldYield=J,e.unstable_wrapCallback=function(_){var W=y;return function(){var K=y;y=W;try{return _.apply(this,arguments)}finally{y=K}}}})(fc);cc.exports=fc;var Yp=cc.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Jp=v,yt=Yp;function L(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Hl=Object.prototype.hasOwnProperty,Xp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,vd={},yd={};function qp(e){return Hl.call(yd,e)?!0:Hl.call(vd,e)?!1:Xp.test(e)?yd[e]=!0:(vd[e]=!0,!1)}function Zp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Gp(e,t,n,r){if(t===null||typeof t>"u"||Zp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function st(e,t,n,r,o,l,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=l,this.removeEmptyString=s}var Ze={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ze[e]=new st(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ze[t]=new st(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ze[e]=new st(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ze[e]=new st(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Ze[e]=new st(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ze[e]=new st(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ze[e]=new st(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ze[e]=new st(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ze[e]=new st(e,5,!1,e.toLowerCase(),null,!1,!1)});var As=/[\-:]([a-z])/g;function Us(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(As,Us);Ze[t]=new st(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(As,Us);Ze[t]=new st(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(As,Us);Ze[t]=new st(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ze[e]=new st(e,1,!1,e.toLowerCase(),null,!1,!1)});Ze.xlinkHref=new st("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ze[e]=new st(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ws(e,t,n,r){var o=Ze.hasOwnProperty(t)?Ze[t]:null;(o!==null?o.type!==0:r||!(2a||o[s]!==l[a]){var d=` +`+o[s].replace(" at new "," at ");return e.displayName&&d.includes("")&&(d=d.replace("",e.displayName)),d}while(1<=s&&0<=a);break}}}finally{ul=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Wr(e):""}function eh(e){switch(e.tag){case 5:return Wr(e.type);case 16:return Wr("Lazy");case 13:return Wr("Suspense");case 19:return Wr("SuspenseList");case 0:case 2:case 15:return e=cl(e.type,!1),e;case 11:return e=cl(e.type.render,!1),e;case 1:return e=cl(e.type,!0),e;default:return""}}function Yl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case nr:return"Fragment";case tr:return"Portal";case Vl:return"Profiler";case Hs:return"StrictMode";case Kl:return"Suspense";case Ql:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case mc:return(e.displayName||"Context")+".Consumer";case hc:return(e._context.displayName||"Context")+".Provider";case Vs:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ks:return t=e.displayName||null,t!==null?t:Yl(e.type)||"Memo";case nn:t=e._payload,e=e._init;try{return Yl(e(t))}catch{}}return null}function th(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Yl(t);case 8:return t===Hs?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function kn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function nh(e){var t=vc(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,l=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(s){r=""+s,l.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Li(e){e._valueTracker||(e._valueTracker=nh(e))}function yc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=vc(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function go(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Jl(e,t){var n=t.checked;return Pe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Sd(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=kn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function xc(e,t){t=t.checked,t!=null&&Ws(e,"checked",t,!1)}function Xl(e,t){xc(e,t);var n=kn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ql(e,t.type,n):t.hasOwnProperty("defaultValue")&&ql(e,t.type,kn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function kd(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ql(e,t,n){(t!=="number"||go(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Hr=Array.isArray;function pr(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o"+t.valueOf().toString()+"",t=Oi.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function li(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Jr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},rh=["Webkit","ms","Moz","O"];Object.keys(Jr).forEach(function(e){rh.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Jr[t]=Jr[e]})});function wc(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Jr.hasOwnProperty(e)&&Jr[e]?(""+t).trim():t+"px"}function _c(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=wc(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var ih=Pe({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function es(e,t){if(t){if(ih[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(L(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(L(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(L(61))}if(t.style!=null&&typeof t.style!="object")throw Error(L(62))}}function ts(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ns=null;function Qs(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var rs=null,hr=null,mr=null;function _d(e){if(e=Ei(e)){if(typeof rs!="function")throw Error(L(280));var t=e.stateNode;t&&(t=Xo(t),rs(e.stateNode,e.type,t))}}function bc(e){hr?mr?mr.push(e):mr=[e]:hr=e}function Cc(){if(hr){var e=hr,t=mr;if(mr=hr=null,_d(e),t)for(e=0;e>>=0,e===0?32:31-(mh(e)/gh|0)|0}var $i=64,Di=4194304;function Vr(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function So(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,l=e.pingedLanes,s=n&268435455;if(s!==0){var a=s&~o;a!==0?r=Vr(a):(l&=s,l!==0&&(r=Vr(l)))}else s=n&~o,s!==0?r=Vr(s):l!==0&&(r=Vr(l));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,l=t&-t,o>=l||o===16&&(l&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function bi(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Rt(t),e[t]=n}function Sh(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=qr),Fd=" ",Ld=!1;function Kc(e,t){switch(e){case"keyup":return Yh.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var rr=!1;function Xh(e,t){switch(e){case"compositionend":return Qc(t);case"keypress":return t.which!==32?null:(Ld=!0,Fd);case"textInput":return e=t.data,e===Fd&&Ld?null:e;default:return null}}function qh(e,t){if(rr)return e==="compositionend"||!ta&&Kc(e,t)?(e=Hc(),io=Zs=an=null,rr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Md(n)}}function qc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?qc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Zc(){for(var e=window,t=go();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=go(e.document)}return t}function na(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function lm(e){var t=Zc(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&qc(n.ownerDocument.documentElement,n)){if(r!==null&&na(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,l=Math.min(r.start,o);r=r.end===void 0?l:Math.min(r.end,o),!e.extend&&l>r&&(o=r,r=l,l=o),o=Id(n,l);var s=Id(n,r);o&&s&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),l>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ir=null,ds=null,Gr=null,us=!1;function Bd(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;us||ir==null||ir!==go(r)||(r=ir,"selectionStart"in r&&na(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Gr&&fi(Gr,r)||(Gr=r,r=wo(ds,"onSelect"),0sr||(e.current=gs[sr],gs[sr]=null,sr--)}function je(e,t){sr++,gs[sr]=e.current,e.current=t}var jn={},rt=_n(jn),ct=_n(!1),Wn=jn;function Sr(e,t){var n=e.type.contextTypes;if(!n)return jn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},l;for(l in n)o[l]=t[l];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function ft(e){return e=e.childContextTypes,e!=null}function bo(){be(ct),be(rt)}function Qd(e,t,n){if(rt.current!==jn)throw Error(L(168));je(rt,t),je(ct,n)}function af(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(L(108,th(e)||"Unknown",o));return Pe({},n,r)}function Co(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||jn,Wn=rt.current,je(rt,e),je(ct,ct.current),!0}function Yd(e,t,n){var r=e.stateNode;if(!r)throw Error(L(169));n?(e=af(e,t,Wn),r.__reactInternalMemoizedMergedChildContext=e,be(ct),be(rt),je(rt,e)):be(ct),je(ct,n)}var Ht=null,qo=!1,bl=!1;function df(e){Ht===null?Ht=[e]:Ht.push(e)}function ym(e){qo=!0,df(e)}function bn(){if(!bl&&Ht!==null){bl=!0;var e=0,t=ve;try{var n=Ht;for(ve=1;e>=s,o-=s,Kt=1<<32-Rt(t)+o|n<z?(Y=P,P=null):Y=P.sibling;var N=y(m,P,f[z],p);if(N===null){P===null&&(P=Y);break}e&&P&&N.alternate===null&&t(m,P),u=l(N,u,z),E===null?j=N:E.sibling=N,E=N,P=Y}if(z===f.length)return n(m,P),Ce&&Fn(m,z),j;if(P===null){for(;zz?(Y=P,P=null):Y=P.sibling;var J=y(m,P,N.value,p);if(J===null){P===null&&(P=Y);break}e&&P&&J.alternate===null&&t(m,P),u=l(J,u,z),E===null?j=J:E.sibling=J,E=J,P=Y}if(N.done)return n(m,P),Ce&&Fn(m,z),j;if(P===null){for(;!N.done;z++,N=f.next())N=h(m,N.value,p),N!==null&&(u=l(N,u,z),E===null?j=N:E.sibling=N,E=N);return Ce&&Fn(m,z),j}for(P=r(m,P);!N.done;z++,N=f.next())N=S(P,m,z,N.value,p),N!==null&&(e&&N.alternate!==null&&P.delete(N.key===null?z:N.key),u=l(N,u,z),E===null?j=N:E.sibling=N,E=N);return e&&P.forEach(function(X){return t(m,X)}),Ce&&Fn(m,z),j}function V(m,u,f,p){if(typeof f=="object"&&f!==null&&f.type===nr&&f.key===null&&(f=f.props.children),typeof f=="object"&&f!==null){switch(f.$$typeof){case Fi:e:{for(var j=f.key,E=u;E!==null;){if(E.key===j){if(j=f.type,j===nr){if(E.tag===7){n(m,E.sibling),u=o(E,f.props.children),u.return=m,m=u;break e}}else if(E.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===nn&&qd(j)===E.type){n(m,E.sibling),u=o(E,f.props),u.ref=Or(m,E,f),u.return=m,m=u;break e}n(m,E);break}else t(m,E);E=E.sibling}f.type===nr?(u=An(f.props.children,m.mode,p,f.key),u.return=m,m=u):(p=po(f.type,f.key,f.props,null,m.mode,p),p.ref=Or(m,u,f),p.return=m,m=p)}return s(m);case tr:e:{for(E=f.key;u!==null;){if(u.key===E)if(u.tag===4&&u.stateNode.containerInfo===f.containerInfo&&u.stateNode.implementation===f.implementation){n(m,u.sibling),u=o(u,f.children||[]),u.return=m,m=u;break e}else{n(m,u);break}else t(m,u);u=u.sibling}u=Fl(f,m.mode,p),u.return=m,m=u}return s(m);case nn:return E=f._init,V(m,u,E(f._payload),p)}if(Hr(f))return w(m,u,f,p);if(Nr(f))return T(m,u,f,p);Hi(m,f)}return typeof f=="string"&&f!==""||typeof f=="number"?(f=""+f,u!==null&&u.tag===6?(n(m,u.sibling),u=o(u,f),u.return=m,m=u):(n(m,u),u=Pl(f,m.mode,p),u.return=m,m=u),s(m)):n(m,u)}return V}var jr=pf(!0),hf=pf(!1),zo=_n(null),No=null,ur=null,la=null;function sa(){la=ur=No=null}function aa(e){var t=zo.current;be(zo),e._currentValue=t}function xs(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function vr(e,t){No=e,la=ur=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ut=!0),e.firstContext=null)}function bt(e){var t=e._currentValue;if(la!==e)if(e={context:e,memoizedValue:t,next:null},ur===null){if(No===null)throw Error(L(308));ur=e,No.dependencies={lanes:0,firstContext:e}}else ur=ur.next=e;return t}var Dn=null;function da(e){Dn===null?Dn=[e]:Dn.push(e)}function mf(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,da(t)):(n.next=o.next,o.next=n),t.interleaved=n,Zt(e,r)}function Zt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var rn=!1;function ua(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function gf(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Yt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function gn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,he&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,Zt(e,n)}return o=r.interleaved,o===null?(t.next=t,da(r)):(t.next=o.next,o.next=t),r.interleaved=t,Zt(e,n)}function lo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Js(e,n)}}function Zd(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var o=null,l=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};l===null?o=l=s:l=l.next=s,n=n.next}while(n!==null);l===null?o=l=t:l=l.next=t}else o=l=t;n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:l,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Ro(e,t,n,r){var o=e.updateQueue;rn=!1;var l=o.firstBaseUpdate,s=o.lastBaseUpdate,a=o.shared.pending;if(a!==null){o.shared.pending=null;var d=a,c=d.next;d.next=null,s===null?l=c:s.next=c,s=d;var g=e.alternate;g!==null&&(g=g.updateQueue,a=g.lastBaseUpdate,a!==s&&(a===null?g.firstBaseUpdate=c:a.next=c,g.lastBaseUpdate=d))}if(l!==null){var h=o.baseState;s=0,g=c=d=null,a=l;do{var y=a.lane,S=a.eventTime;if((r&y)===y){g!==null&&(g=g.next={eventTime:S,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var w=e,T=a;switch(y=t,S=n,T.tag){case 1:if(w=T.payload,typeof w=="function"){h=w.call(S,h,y);break e}h=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=T.payload,y=typeof w=="function"?w.call(S,h,y):w,y==null)break e;h=Pe({},h,y);break e;case 2:rn=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,y=o.effects,y===null?o.effects=[a]:y.push(a))}else S={eventTime:S,lane:y,tag:a.tag,payload:a.payload,callback:a.callback,next:null},g===null?(c=g=S,d=h):g=g.next=S,s|=y;if(a=a.next,a===null){if(a=o.shared.pending,a===null)break;y=a,a=y.next,y.next=null,o.lastBaseUpdate=y,o.shared.pending=null}}while(!0);if(g===null&&(d=h),o.baseState=d,o.firstBaseUpdate=c,o.lastBaseUpdate=g,t=o.shared.interleaved,t!==null){o=t;do s|=o.lane,o=o.next;while(o!==t)}else l===null&&(o.shared.lanes=0);Kn|=s,e.lanes=s,e.memoizedState=h}}function Gd(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=El.transition;El.transition={};try{e(!1),t()}finally{ve=n,El.transition=r}}function Ff(){return Ct().memoizedState}function jm(e,t,n){var r=yn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Lf(e))Of(t,n);else if(n=mf(e,t,n,r),n!==null){var o=ot();Pt(n,e,r,o),$f(n,t,r)}}function wm(e,t,n){var r=yn(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Lf(e))Of(t,o);else{var l=e.alternate;if(e.lanes===0&&(l===null||l.lanes===0)&&(l=t.lastRenderedReducer,l!==null))try{var s=t.lastRenderedState,a=l(s,n);if(o.hasEagerState=!0,o.eagerState=a,Ft(a,s)){var d=t.interleaved;d===null?(o.next=o,da(t)):(o.next=d.next,d.next=o),t.interleaved=o;return}}catch{}finally{}n=mf(e,t,o,r),n!==null&&(o=ot(),Pt(n,e,r,o),$f(n,t,r))}}function Lf(e){var t=e.alternate;return e===Re||t!==null&&t===Re}function Of(e,t){ei=Fo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function $f(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Js(e,n)}}var Lo={readContext:bt,useCallback:Ge,useContext:Ge,useEffect:Ge,useImperativeHandle:Ge,useInsertionEffect:Ge,useLayoutEffect:Ge,useMemo:Ge,useReducer:Ge,useRef:Ge,useState:Ge,useDebugValue:Ge,useDeferredValue:Ge,useTransition:Ge,useMutableSource:Ge,useSyncExternalStore:Ge,useId:Ge,unstable_isNewReconciler:!1},_m={readContext:bt,useCallback:function(e,t){return Dt().memoizedState=[e,t===void 0?null:t],e},useContext:bt,useEffect:tu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ao(4194308,4,Tf.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ao(4194308,4,e,t)},useInsertionEffect:function(e,t){return ao(4,2,e,t)},useMemo:function(e,t){var n=Dt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Dt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=jm.bind(null,Re,e),[r.memoizedState,e]},useRef:function(e){var t=Dt();return e={current:e},t.memoizedState=e},useState:eu,useDebugValue:ya,useDeferredValue:function(e){return Dt().memoizedState=e},useTransition:function(){var e=eu(!1),t=e[0];return e=km.bind(null,e[1]),Dt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Re,o=Dt();if(Ce){if(n===void 0)throw Error(L(407));n=n()}else{if(n=t(),Qe===null)throw Error(L(349));Vn&30||Sf(r,t,n)}o.memoizedState=n;var l={value:n,getSnapshot:t};return o.queue=l,tu(jf.bind(null,r,l,e),[e]),r.flags|=2048,Si(9,kf.bind(null,r,l,n,t),void 0,null),n},useId:function(){var e=Dt(),t=Qe.identifierPrefix;if(Ce){var n=Qt,r=Kt;n=(r&~(1<<32-Rt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=yi++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[Mt]=t,e[mi]=r,Kf(e,t,!1,!1),t.stateNode=e;e:{switch(s=ts(n,r),n){case"dialog":_e("cancel",e),_e("close",e),o=r;break;case"iframe":case"object":case"embed":_e("load",e),o=r;break;case"video":case"audio":for(o=0;obr&&(t.flags|=128,r=!0,$r(l,!1),t.lanes=4194304)}else{if(!r)if(e=Po(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),$r(l,!0),l.tail===null&&l.tailMode==="hidden"&&!s.alternate&&!Ce)return et(t),null}else 2*De()-l.renderingStartTime>br&&n!==1073741824&&(t.flags|=128,r=!0,$r(l,!1),t.lanes=4194304);l.isBackwards?(s.sibling=t.child,t.child=s):(n=l.last,n!==null?n.sibling=s:t.child=s,l.last=s)}return l.tail!==null?(t=l.tail,l.rendering=t,l.tail=t.sibling,l.renderingStartTime=De(),t.sibling=null,n=Ne.current,je(Ne,r?n&1|2:n&1),t):(et(t),null);case 22:case 23:return _a(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?mt&1073741824&&(et(t),t.subtreeFlags&6&&(t.flags|=8192)):et(t),null;case 24:return null;case 25:return null}throw Error(L(156,t.tag))}function Pm(e,t){switch(ia(t),t.tag){case 1:return ft(t.type)&&bo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return wr(),be(ct),be(rt),pa(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return fa(t),null;case 13:if(be(Ne),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(L(340));kr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return be(Ne),null;case 4:return wr(),null;case 10:return aa(t.type._context),null;case 22:case 23:return _a(),null;case 24:return null;default:return null}}var Ki=!1,nt=!1,Fm=typeof WeakSet=="function"?WeakSet:Set,H=null;function cr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Fe(e,t,r)}else n.current=null}function Ts(e,t,n){try{n()}catch(r){Fe(e,t,r)}}var fu=!1;function Lm(e,t){if(cs=ko,e=Zc(),na(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,l=r.focusNode;r=r.focusOffset;try{n.nodeType,l.nodeType}catch{n=null;break e}var s=0,a=-1,d=-1,c=0,g=0,h=e,y=null;t:for(;;){for(var S;h!==n||o!==0&&h.nodeType!==3||(a=s+o),h!==l||r!==0&&h.nodeType!==3||(d=s+r),h.nodeType===3&&(s+=h.nodeValue.length),(S=h.firstChild)!==null;)y=h,h=S;for(;;){if(h===e)break t;if(y===n&&++c===o&&(a=s),y===l&&++g===r&&(d=s),(S=h.nextSibling)!==null)break;h=y,y=h.parentNode}h=S}n=a===-1||d===-1?null:{start:a,end:d}}else n=null}n=n||{start:0,end:0}}else n=null;for(fs={focusedElem:e,selectionRange:n},ko=!1,H=t;H!==null;)if(t=H,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,H=e;else for(;H!==null;){t=H;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var T=w.memoizedProps,V=w.memoizedState,m=t.stateNode,u=m.getSnapshotBeforeUpdate(t.elementType===t.type?T:Tt(t.type,T),V);m.__reactInternalSnapshotBeforeUpdate=u}break;case 3:var f=t.stateNode.containerInfo;f.nodeType===1?f.textContent="":f.nodeType===9&&f.documentElement&&f.removeChild(f.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(L(163))}}catch(p){Fe(t,t.return,p)}if(e=t.sibling,e!==null){e.return=t.return,H=e;break}H=t.return}return w=fu,fu=!1,w}function ti(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var l=o.destroy;o.destroy=void 0,l!==void 0&&Ts(t,n,l)}o=o.next}while(o!==r)}}function el(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function zs(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Jf(e){var t=e.alternate;t!==null&&(e.alternate=null,Jf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Mt],delete t[mi],delete t[ms],delete t[gm],delete t[vm])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Xf(e){return e.tag===5||e.tag===3||e.tag===4}function pu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Xf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ns(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=_o));else if(r!==4&&(e=e.child,e!==null))for(Ns(e,t,n),e=e.sibling;e!==null;)Ns(e,t,n),e=e.sibling}function Rs(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Rs(e,t,n),e=e.sibling;e!==null;)Rs(e,t,n),e=e.sibling}var Je=null,zt=!1;function tn(e,t,n){for(n=n.child;n!==null;)qf(e,t,n),n=n.sibling}function qf(e,t,n){if(It&&typeof It.onCommitFiberUnmount=="function")try{It.onCommitFiberUnmount(Ko,n)}catch{}switch(n.tag){case 5:nt||cr(n,t);case 6:var r=Je,o=zt;Je=null,tn(e,t,n),Je=r,zt=o,Je!==null&&(zt?(e=Je,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Je.removeChild(n.stateNode));break;case 18:Je!==null&&(zt?(e=Je,n=n.stateNode,e.nodeType===8?_l(e.parentNode,n):e.nodeType===1&&_l(e,n),ui(e)):_l(Je,n.stateNode));break;case 4:r=Je,o=zt,Je=n.stateNode.containerInfo,zt=!0,tn(e,t,n),Je=r,zt=o;break;case 0:case 11:case 14:case 15:if(!nt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var l=o,s=l.destroy;l=l.tag,s!==void 0&&(l&2||l&4)&&Ts(n,t,s),o=o.next}while(o!==r)}tn(e,t,n);break;case 1:if(!nt&&(cr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Fe(n,t,a)}tn(e,t,n);break;case 21:tn(e,t,n);break;case 22:n.mode&1?(nt=(r=nt)||n.memoizedState!==null,tn(e,t,n),nt=r):tn(e,t,n);break;default:tn(e,t,n)}}function hu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Fm),t.forEach(function(r){var o=Wm.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function Et(e,t){var n=t.deletions;if(n!==null)for(var r=0;ro&&(o=s),r&=~l}if(r=o,r=De()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*$m(r/1960))-r,10e?16:e,dn===null)var r=!1;else{if(e=dn,dn=null,Do=0,he&6)throw Error(L(331));var o=he;for(he|=4,H=e.current;H!==null;){var l=H,s=l.child;if(H.flags&16){var a=l.deletions;if(a!==null){for(var d=0;dDe()-ja?Bn(e,0):ka|=n),pt(e,t)}function op(e,t){t===0&&(e.mode&1?(t=Di,Di<<=1,!(Di&130023424)&&(Di=4194304)):t=1);var n=ot();e=Zt(e,t),e!==null&&(bi(e,t,n),pt(e,n))}function Um(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),op(e,n)}function Wm(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(L(314))}r!==null&&r.delete(t),op(e,n)}var lp;lp=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ct.current)ut=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ut=!1,Nm(e,t,n);ut=!!(e.flags&131072)}else ut=!1,Ce&&t.flags&1048576&&uf(t,To,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;uo(e,t),e=t.pendingProps;var o=Sr(t,rt.current);vr(t,n),o=ma(null,t,r,e,o,n);var l=ga();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ft(r)?(l=!0,Co(t)):l=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,ua(t),o.updater=Go,t.stateNode=o,o._reactInternals=t,ks(t,r,e,n),t=_s(null,t,r,!0,l,n)):(t.tag=0,Ce&&l&&ra(t),it(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(uo(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=Vm(r),e=Tt(r,e),o){case 0:t=ws(null,t,r,e,n);break e;case 1:t=du(null,t,r,e,n);break e;case 11:t=su(null,t,r,e,n);break e;case 14:t=au(null,t,r,Tt(r.type,e),n);break e}throw Error(L(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Tt(r,o),ws(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Tt(r,o),du(e,t,r,o,n);case 3:e:{if(Wf(t),e===null)throw Error(L(387));r=t.pendingProps,l=t.memoizedState,o=l.element,gf(e,t),Ro(t,r,null,n);var s=t.memoizedState;if(r=s.element,l.isDehydrated)if(l={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=l,t.memoizedState=l,t.flags&256){o=_r(Error(L(423)),t),t=uu(e,t,r,n,o);break e}else if(r!==o){o=_r(Error(L(424)),t),t=uu(e,t,r,n,o);break e}else for(gt=mn(t.stateNode.containerInfo.firstChild),vt=t,Ce=!0,Nt=null,n=hf(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(kr(),r===o){t=Gt(e,t,n);break e}it(e,t,r,n)}t=t.child}return t;case 5:return vf(t),e===null&&ys(t),r=t.type,o=t.pendingProps,l=e!==null?e.memoizedProps:null,s=o.children,ps(r,o)?s=null:l!==null&&ps(r,l)&&(t.flags|=32),Uf(e,t),it(e,t,s,n),t.child;case 6:return e===null&&ys(t),null;case 13:return Hf(e,t,n);case 4:return ca(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=jr(t,null,r,n):it(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Tt(r,o),su(e,t,r,o,n);case 7:return it(e,t,t.pendingProps,n),t.child;case 8:return it(e,t,t.pendingProps.children,n),t.child;case 12:return it(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,l=t.memoizedProps,s=o.value,je(zo,r._currentValue),r._currentValue=s,l!==null)if(Ft(l.value,s)){if(l.children===o.children&&!ct.current){t=Gt(e,t,n);break e}}else for(l=t.child,l!==null&&(l.return=t);l!==null;){var a=l.dependencies;if(a!==null){s=l.child;for(var d=a.firstContext;d!==null;){if(d.context===r){if(l.tag===1){d=Yt(-1,n&-n),d.tag=2;var c=l.updateQueue;if(c!==null){c=c.shared;var g=c.pending;g===null?d.next=d:(d.next=g.next,g.next=d),c.pending=d}}l.lanes|=n,d=l.alternate,d!==null&&(d.lanes|=n),xs(l.return,n,t),a.lanes|=n;break}d=d.next}}else if(l.tag===10)s=l.type===t.type?null:l.child;else if(l.tag===18){if(s=l.return,s===null)throw Error(L(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),xs(s,n,t),s=l.sibling}else s=l.child;if(s!==null)s.return=l;else for(s=l;s!==null;){if(s===t){s=null;break}if(l=s.sibling,l!==null){l.return=s.return,s=l;break}s=s.return}l=s}it(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,vr(t,n),o=bt(o),r=r(o),t.flags|=1,it(e,t,r,n),t.child;case 14:return r=t.type,o=Tt(r,t.pendingProps),o=Tt(r.type,o),au(e,t,r,o,n);case 15:return Bf(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Tt(r,o),uo(e,t),t.tag=1,ft(r)?(e=!0,Co(t)):e=!1,vr(t,n),Df(t,r,o),ks(t,r,o,n),_s(null,t,r,!0,e,n);case 19:return Vf(e,t,n);case 22:return Af(e,t,n)}throw Error(L(156,t.tag))};function sp(e,t){return Fc(e,t)}function Hm(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function wt(e,t,n,r){return new Hm(e,t,n,r)}function Ca(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Vm(e){if(typeof e=="function")return Ca(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Vs)return 11;if(e===Ks)return 14}return 2}function xn(e,t){var n=e.alternate;return n===null?(n=wt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function po(e,t,n,r,o,l){var s=2;if(r=e,typeof e=="function")Ca(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case nr:return An(n.children,o,l,t);case Hs:s=8,o|=8;break;case Vl:return e=wt(12,n,t,o|2),e.elementType=Vl,e.lanes=l,e;case Kl:return e=wt(13,n,t,o),e.elementType=Kl,e.lanes=l,e;case Ql:return e=wt(19,n,t,o),e.elementType=Ql,e.lanes=l,e;case gc:return nl(n,o,l,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case hc:s=10;break e;case mc:s=9;break e;case Vs:s=11;break e;case Ks:s=14;break e;case nn:s=16,r=null;break e}throw Error(L(130,e==null?e:typeof e,""))}return t=wt(s,n,t,o),t.elementType=e,t.type=r,t.lanes=l,t}function An(e,t,n,r){return e=wt(7,e,r,t),e.lanes=n,e}function nl(e,t,n,r){return e=wt(22,e,r,t),e.elementType=gc,e.lanes=n,e.stateNode={isHidden:!1},e}function Pl(e,t,n){return e=wt(6,e,null,t),e.lanes=n,e}function Fl(e,t,n){return t=wt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Km(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=pl(0),this.expirationTimes=pl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pl(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function Ea(e,t,n,r,o,l,s,a,d){return e=new Km(e,t,n,a,d),t===1?(t=1,l===!0&&(t|=8)):t=0,l=wt(3,null,null,t),e.current=l,l.stateNode=e,l.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ua(l),e}function Qm(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(cp)}catch(e){console.error(e)}}cp(),uc.exports=xt;var Zm=uc.exports,ju=Zm;Wl.createRoot=ju.createRoot,Wl.hydrateRoot=ju.hydrateRoot;const Gm="modulepreload",eg=function(e){return"/"+e},wu={},tg=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),a=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));o=Promise.allSettled(n.map(d=>{if(d=eg(d),d in wu)return;wu[d]=!0;const c=d.endsWith(".css"),g=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${g}`))return;const h=document.createElement("link");if(h.rel=c?"stylesheet":Gm,c||(h.as="script"),h.crossOrigin="",h.href=d,a&&h.setAttribute("nonce",a),document.head.appendChild(h),c)return new Promise((y,S)=>{h.addEventListener("load",y),h.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${d}`)))})}))}function l(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return o.then(s=>{for(const a of s||[])a.status==="rejected"&&l(a.reason);return t().catch(l)})},ho="/api";async function F(e,t){const n=await fetch(ho+e,{...t,headers:{"Content-Type":"application/json",...(t==null?void 0:t.headers)||{}}});if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);return await n.json()}const A={listMemories:()=>F("/memories"),remember:(e,t,n)=>F("/memories",{method:"POST",body:JSON.stringify({content:e,tier:t,tags:n})}),archiveMemory:e=>F(`/memories/${encodeURIComponent(e)}`,{method:"DELETE"}),routerStats:e=>F(`/router/stats${e?`?agent_id=${encodeURIComponent(e)}`:""}`),routerPolicy:()=>F("/router/policy"),routerTune:()=>F("/router/tune",{method:"POST"}),metaBuddhi:()=>F("/meta-buddhi"),evolution:()=>F("/evolution"),conflicts:()=>F("/conflicts"),resolveConflict:(e,t)=>F(`/conflicts/${encodeURIComponent(e)}/resolve`,{method:"POST",body:JSON.stringify({action:t})}),resolveConflictDetailed:(e,t)=>F(`/conflicts/${encodeURIComponent(e)}/resolve`,{method:"POST",body:JSON.stringify(t)}),tasks:()=>F("/tasks"),createTask:(e,t)=>F("/tasks",{method:"POST",body:JSON.stringify({title:e,harness:t})}),taskDetail:(e,t=24)=>F(`/tasks/${encodeURIComponent(e)}?limit=${encodeURIComponent(String(t))}`),updateTaskStatus:(e,t)=>F(`/tasks/${encodeURIComponent(e)}/status`,{method:"POST",body:JSON.stringify({status:t})}),addTaskNote:(e,t)=>F(`/tasks/${encodeURIComponent(e)}/notes`,{method:"POST",body:JSON.stringify({content:t})}),workspaceGraph:(e,t)=>F(`/workspace/graph${e?`?workspace_id=${encodeURIComponent(e)}${t?`&project_id=${encodeURIComponent(t)}`:""}`:""}`),projects:()=>F("/workspaces"),workspaces:()=>F("/workspaces"),createWorkspaceRoot:(e,t)=>F("/workspaces",{method:"POST",body:JSON.stringify({name:e,description:t})}),createProject:(e,t)=>F(`/workspaces/${encodeURIComponent(e)}/projects`,{method:"POST",body:JSON.stringify(t)}),updateProject:(e,t)=>F(`/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}),projectSessions:e=>F(`/projects/${encodeURIComponent(e)}/sessions`),projectCanvas:e=>F(`/projects/${encodeURIComponent(e)}/canvas`),workspaceCanvas:e=>F(`/workspaces/${encodeURIComponent(e)}/canvas`),pickFolder:e=>F("/folders/pick",{method:"POST",body:JSON.stringify({prompt:e})}),addWorkspaceFolder:(e,t,n)=>F(`/workspaces/${encodeURIComponent(e)}/folders`,{method:"POST",body:JSON.stringify({path:t,label:n})}),removeWorkspaceFolder:(e,t)=>F(`/workspaces/${encodeURIComponent(e)}/mounts?path=${encodeURIComponent(t)}`,{method:"DELETE"}),updateWorkspace:(e,t)=>F(`/workspaces/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}),deleteWorkspace:e=>F(`/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"}),deleteProject:e=>F(`/projects/${encodeURIComponent(e)}`,{method:"DELETE"}),workspaceDetail:e=>F(`/workspaces/${encodeURIComponent(e)}`),workspaceSessions:e=>F(`/workspaces/${encodeURIComponent(e)}/sessions`),sessionDetail:e=>F(`/sessions/${encodeURIComponent(e)}`),launchWorkspaceSession:(e,t,n,r,o,l)=>F(`/workspaces/${encodeURIComponent(e)}/sessions/launch`,{method:"POST",body:JSON.stringify({runtime:t,title:n,permission_mode:r,task_id:o,project_id:l})}),workspaceLineMessages:(e,t)=>F(`/workspaces/${encodeURIComponent(e)}/line/messages?${new URLSearchParams(Object.entries({project_id:t==null?void 0:t.project_id,channel:t==null?void 0:t.channel,cursor:t==null?void 0:t.cursor,limit:t!=null&&t.limit?String(t.limit):void 0}).filter(n=>!!n[1])).toString()}`),publishWorkspaceLineMessage:(e,t)=>F(`/workspaces/${encodeURIComponent(e)}/line/messages`,{method:"POST",body:JSON.stringify(t)}),uploadSessionAsset:async(e,t,n)=>{const r=new FormData;r.append("file",t),n&&r.append("label",n);const o=await fetch(`${ho}/sessions/${encodeURIComponent(e)}/assets`,{method:"POST",body:r});if(!o.ok)throw new Error(`${o.status} ${o.statusText}`);return await o.json()},listProjectAssets:e=>F(`/projects/${encodeURIComponent(e)}/assets`),listWorkspaceAssets:(e,t=!0)=>F(`/workspaces/${encodeURIComponent(e)}/assets?include_project_assets=${t?"true":"false"}`),uploadProjectAsset:async(e,t,n)=>{const r=new FormData;r.append("file",t),n!=null&&n.label&&r.append("label",n.label),n!=null&&n.folder&&r.append("folder",n.folder);const o=await fetch(`${ho}/projects/${encodeURIComponent(e)}/assets`,{method:"POST",body:r});if(!o.ok)throw new Error(`${o.status} ${o.statusText}`);return await o.json()},uploadWorkspaceAsset:async(e,t,n)=>{const r=new FormData;r.append("file",t),n!=null&&n.label&&r.append("label",n.label),n!=null&&n.folder&&r.append("folder",n.folder),n!=null&&n.project_id&&r.append("project_id",n.project_id);const o=await fetch(`${ho}/workspaces/${encodeURIComponent(e)}/assets`,{method:"POST",body:r});if(!o.ok)throw new Error(`${o.status} ${o.statusText}`);return await o.json()},deleteProjectAsset:e=>F(`/project-assets/${encodeURIComponent(e)}`,{method:"DELETE"}),fileContext:(e,t)=>F(`/files/${encodeURIComponent(e)}/context${t?`?workspace_id=${encodeURIComponent(t)}`:""}`),assetContext:e=>F(`/assets/${encodeURIComponent(e)}/context`),askAsset:(e,t)=>F(`/assets/${encodeURIComponent(e)}/ask`,{method:"POST",body:JSON.stringify({question:t})}),runtimeStatus:()=>F("/runtime-status"),status:()=>F("/status"),memoryNow:()=>F("/memory/now"),captureTimeline:(e=16)=>F(`/capture/timeline?limit=${encodeURIComponent(String(e))}`),launch:(e,t,n)=>F("/launch",{method:"POST",body:JSON.stringify({runtime:e,taskId:t,title:n})}),apiKeys:()=>F("/security/api-keys"),storeApiKey:(e,t,n)=>F("/security/api-keys",{method:"POST",body:JSON.stringify({provider:e,apiKey:t,label:n})}),rotateApiKey:(e,t,n)=>F(`/security/api-keys/${encodeURIComponent(e)}/rotate`,{method:"POST",body:JSON.stringify({apiKey:t,label:n})}),me:()=>F("/me"),continuity:()=>F("/continuity"),orgGraph:(e,t)=>{const n=new URLSearchParams;e&&n.set("org",e),t!=null&&t.active&&n.set("active","true");const r=n.toString();return F(`/org/graph${r?`?${r}`:""}`)},routerSessions:e=>{const t=new URLSearchParams;(e==null?void 0:e.active)!=null&&t.set("active",e.active?"true":"false"),e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.agent&&t.set("agent",e.agent);const n=t.toString();return F(`/router/sessions${n?`?${n}`:""}`)},contextEntries:(e,t=200)=>{const n=new URLSearchParams;return e&&n.set("repo",e),n.set("limit",String(t)),F(`/context/entries?${n.toString()}`)},contextPromote:e=>F("/context/promote",{method:"POST",body:JSON.stringify(e)}),contextDemote:e=>F("/context/demote",{method:"POST",body:JSON.stringify(e)}),localWorkspaces:()=>F("/local/workspaces"),localWorkspaceCreate:e=>F("/local/workspaces",{method:"POST",body:JSON.stringify(e)}),localContextLinkFolder:e=>F("/local-context/folders/link",{method:"POST",body:JSON.stringify({path:e})}),localContextUnlinkFolder:e=>F("/local-context/folders/unlink",{method:"POST",body:JSON.stringify({path:e})}),contextItems:(e={})=>{const t=new URLSearchParams;e.team&&t.set("team",e.team),e.project&&t.set("project",e.project),e.scope&&t.set("scope",e.scope),e.kind&&t.set("kind",e.kind),e.limit&&t.set("limit",String(e.limit));const n=t.toString();return F(`/context/items${n?`?${n}`:""}`)},contextUsage:(e={})=>{const t=new URLSearchParams;e.team&&t.set("team",e.team),e.project&&t.set("project",e.project),e.scope&&t.set("scope",e.scope),e.kind&&t.set("kind",e.kind),e.limit&&t.set("limit",String(e.limit));const n=t.toString();return F(`/context/usage${n?`?${n}`:""}`)},commandCenter:()=>F("/ui/command-center"),proofReplay:(e=80)=>F(`/ui/proof-replay?limit=${encodeURIComponent(String(e))}`),handoffUi:()=>F("/ui/handoff"),learningsUi:(e=120)=>F(`/ui/learnings?limit=${encodeURIComponent(String(e))}`),promoteLearning:(e,t)=>F(`/ui/learnings/${encodeURIComponent(e)}/promote`,{method:"POST",body:JSON.stringify(t||{approved_by:"dhee-ui"})}),rejectLearning:(e,t)=>F(`/ui/learnings/${encodeURIComponent(e)}/reject`,{method:"POST",body:JSON.stringify(t||{reason:"rejected in Dhee UI"})}),portabilityUi:()=>F("/ui/portability"),exportPackUi:e=>F("/ui/portability/export",{method:"POST",body:JSON.stringify(e||{})}),importPackDryRunUi:e=>F("/ui/portability/import-dry-run",{method:"POST",body:JSON.stringify(e)}),upsertContext:e=>F("/context",{method:"POST",body:JSON.stringify(e)}),proposeContext:e=>F("/proposals",{method:"POST",body:JSON.stringify(e)}),approveProposal:(e,t)=>F(`/proposals/${encodeURIComponent(e)}/approve`,{method:"POST",body:JSON.stringify({reviewer_user_id:t})}),rejectProposal:(e,t)=>F(`/proposals/${encodeURIComponent(e)}/reject`,{method:"POST",body:JSON.stringify({reviewer_user_id:t})}),inbox:(e={})=>{const t=new URLSearchParams;e.team&&t.set("team",e.team),e.user&&t.set("user",e.user);const n=t.toString();return F(`/inbox${n?`?${n}`:""}`)},resolveFinding:(e,t)=>F(`/findings/${encodeURIComponent(e)}/resolve`,{method:"POST",body:JSON.stringify({resolved_by:t})}),backlinks:(e,t=50)=>F(`/backlinks?context_id=${encodeURIComponent(e)}&limit=${encodeURIComponent(String(t))}`),setIntegration:e=>F("/integrations",{method:"POST",body:JSON.stringify(e)}),teamJoin:e=>F("/team-join",{method:"POST",body:JSON.stringify(e)}),localContextAddFolder:e=>F("/local-context/folders",{method:"POST",body:JSON.stringify(e)}),localContextShareFolder:e=>F("/local-context/folders/share",{method:"POST",body:JSON.stringify(e)}),enterpriseSetWorkspace:e=>F("/workspace",{method:"POST",body:JSON.stringify(e)}),enterpriseResetWorkspace:()=>F("/workspace/reset",{method:"POST",body:"{}"}),enterpriseCreateProject:e=>F("/projects",{method:"POST",body:JSON.stringify(e)}),enterpriseDeleteProject:e=>F(`/projects/${encodeURIComponent(e)}`,{method:"DELETE"}),enterpriseCreateProjectTeam:(e,t)=>F(`/projects/${encodeURIComponent(e)}/teams`,{method:"POST",body:JSON.stringify(t)}),enterpriseAddProjectFolder:(e,t)=>F(`/projects/${encodeURIComponent(e)}/folders`,{method:"POST",body:JSON.stringify(t)}),enterpriseAddTeamFolder:(e,t)=>F(`/teams/${encodeURIComponent(e)}/folders`,{method:"POST",body:JSON.stringify(t)}),enterpriseRemoveFolder:e=>F(`/folders/${encodeURIComponent(e)}`,{method:"DELETE"}),enterpriseAddTeamCollaborator:(e,t)=>F(`/teams/${encodeURIComponent(e)}/collaborators`,{method:"POST",body:JSON.stringify({target_team_id:t})}),enterpriseExtractProject:e=>F(`/projects/${encodeURIComponent(e)}/extract`,{method:"POST",body:"{}"}),enterpriseExtractTeam:e=>F(`/teams/${encodeURIComponent(e)}/extract`,{method:"POST",body:"{}"}),pickFolderPath:e=>F("/folders/pick",{method:"POST",body:JSON.stringify({prompt:e})})};function ng({view:e,setView:t,conflictCount:n}){const r=[{id:"command",icon:"⌂",label:"HOME",tip:"Command center · current truth · next action"},{id:"router",icon:"⇌",label:"FIREWALL",tip:"Context firewall · routing · expansions · tokens saved"},{id:"canvas",icon:"⊞",label:"BRAIN",tip:"Repo Brain · linked folders · active sessions"},{id:"handoff",icon:"↗",label:"HANDOFF",tip:"Resume state across agents"},{id:"replay",icon:"◌",label:"REPLAY",tip:"Context decision replay"},{id:"learnings",icon:"↑",label:"LEARN",tip:"Evidence-backed learning review"},{id:"context",icon:"◐",label:"CONTEXT",tip:"Context vault · personal and shared memory"},{id:"portability",icon:"□",label:"PACKS",tip:".dheemem export · import dry-run · portability"},{id:"conflicts",icon:"⟷",label:"INBOX",tip:"Proposals · findings · conflicts",badge:n}];return i.jsxs("div",{style:{width:"var(--nav)",borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",flexShrink:0,background:"var(--bg)",zIndex:20},children:[i.jsx("div",{style:{height:48,borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx("img",{src:"/dhee-logo.png",alt:"Dhee",style:{width:22,height:22,objectFit:"contain"}})}),i.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",padding:"6px 0",gap:0},children:r.map(o=>{const l=o.id==="router"?e==="router"||e.startsWith("router/"):e===o.id;return i.jsxs("div",{title:o.tip,onClick:()=>t(o.id),style:{position:"relative",height:44,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:"pointer",background:l?"var(--surface)":"transparent",borderLeft:`2px solid ${l?"var(--accent)":"transparent"}`,gap:2,transition:"all 0.1s"},onMouseEnter:s=>{l||(s.currentTarget.style.background="var(--surface)")},onMouseLeave:s=>{l||(s.currentTarget.style.background="transparent")},children:[i.jsx("span",{style:{fontSize:14,color:l?"var(--accent)":"var(--ink3)",lineHeight:1},children:o.icon}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:7,color:l?"var(--accent)":"var(--ink3)",letterSpacing:"0.04em"},children:o.label}),o.badge&&o.badge>0?i.jsx("div",{style:{position:"absolute",top:6,right:6,width:14,height:14,borderRadius:"50%",background:"var(--rose)",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:8,color:"white",fontWeight:700},children:o.badge})}):null]},o.id)})}),i.jsx("div",{style:{borderTop:"1px solid var(--border)",height:44,display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx("div",{title:"Dhee active",style:{width:5,height:5,borderRadius:"50%",background:"var(--green)"}})})]})}function Mr(e){return!e||e<=0?"0":new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e)}function rg(e){if(!e)return 0;const t=Number(e.sessionTokensSaved||0),n=Number(e.enterpriseSavedTokens||0);return t+n}function ig(e){return e?Number(e.enterpriseSavedPct||0):0}function og({viewer:e,routerStats:t,onRefresh:n,onOpenTweaks:r,onResetWorkspace:o}){const[l,s]=v.useState(!1),[a,d]=v.useState(null),c=v.useRef(null);v.useEffect(()=>{if(!l)return;const u=f=>{c.current&&(c.current.contains(f.target)||s(!1))};return window.addEventListener("mousedown",u),()=>window.removeEventListener("mousedown",u)},[l]),v.useEffect(()=>{if(t){d(null);return}let u=!1;const f=async()=>{try{const j=await A.routerStats();u||d(j)}catch{}};f();const p=window.setInterval(f,5e3);return()=>{u=!0,window.clearInterval(p)}},[t]);const g=(e==null?void 0:e.org_id)||"default",h=(e==null?void 0:e.project_id)||null,y=(e==null?void 0:e.team_id)||null,S=[g,h,y].filter(Boolean).join(" · "),w=t||a,T=rg(w),V=ig(w),m=(()=>{if(!w)return"loading";const u=Number(w.sessionTokensSaved||0),f=Number(w.enterpriseSavedTokens||0),p=Number(w.enterpriseRawTokens||0),j=Number(w.enterpriseSummaryTokens||0),E=Number(w.enterpriseRawFallbacks||0),P=Number(w.enterpriseGateSuggestions||0);return`Session: ${Mr(u)} · Repo index: ${Mr(f)} · Raw avoided: ${Mr(p)} -> ${Mr(j)} · Fallbacks: ${E} · Gates: ${P}`})();return i.jsxs("div",{style:{height:32,borderBottom:"1px solid var(--border)",background:"var(--bg)",display:"flex",alignItems:"center",padding:"0 12px",gap:10,flexShrink:0,zIndex:15},children:[i.jsxs("div",{className:"workspace-pill",title:S,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"3px 9px",borderRadius:4,background:"var(--surface)",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink2)",letterSpacing:"0.04em"},children:[i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:e!=null&&e.live?"var(--green)":"var(--ink3)"}}),i.jsx("span",{children:S||"no workspace"}),e!=null&&e.role?i.jsx("span",{style:{marginLeft:6,padding:"1px 5px",borderRadius:3,background:"var(--surface2)",color:"var(--ink2)",fontSize:9},children:String(e.role).toUpperCase()}):null]}),i.jsx("div",{style:{flex:1}}),i.jsxs("div",{className:"tokens-chip",title:m,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"3px 9px",borderRadius:4,background:"var(--accent-dim)",border:"1px solid var(--accent)",color:"var(--accent)",fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.04em"},children:[i.jsx("span",{style:{fontSize:11},children:"↯"}),i.jsxs("span",{children:[Mr(T)," saved"]}),V>0?i.jsxs("span",{style:{color:"var(--ink3)"},children:["· ",V.toFixed(0),"%"]}):null]}),i.jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[i.jsx("button",{"aria-label":"Menu",onClick:()=>s(u=>!u),style:{width:22,height:22,borderRadius:4,background:l?"var(--surface2)":"var(--surface)",border:"1px solid var(--border)",color:"var(--ink2)",fontSize:12,lineHeight:1,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:"⋮"}),l?i.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",right:0,minWidth:180,background:"var(--bg)",border:"1px solid var(--border)",borderRadius:4,boxShadow:"0 6px 18px rgba(20,16,10,0.08)",zIndex:30,padding:4,fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.04em"},children:[i.jsx(Ji,{label:"REFRESH",onClick:()=>{s(!1),n()}}),i.jsx(Ji,{label:"TWEAKS",hint:"⌘K",onClick:()=>{s(!1),r()}}),o?i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{height:1,background:"var(--border)",margin:"3px 0"}}),i.jsx(Ji,{label:"RESET WORKSPACE",onClick:()=>{s(!1),o()},danger:!0})]}):null,i.jsx("div",{style:{height:1,background:"var(--border)",margin:"3px 0"}}),i.jsx(Ji,{label:"USER ID",hint:(e==null?void 0:e.user_id)||"—",onClick:()=>s(!1),dim:!0})]}):null]})]})}function Ji({label:e,hint:t,onClick:n,dim:r,danger:o}){return i.jsxs("button",{onClick:n,style:{width:"100%",textAlign:"left",padding:"5px 8px",borderRadius:3,background:"transparent",color:o?"var(--rose)":r?"var(--ink3)":"var(--ink2)",display:"flex",justifyContent:"space-between",alignItems:"center",gap:8},onMouseEnter:l=>{l.currentTarget.style.background=o?"var(--rose-dim)":"var(--surface)"},onMouseLeave:l=>{l.currentTarget.style.background="transparent"},children:[i.jsx("span",{children:e}),t?i.jsx("span",{style:{color:"var(--ink3)",fontSize:9},children:t}):null]})}function lg({tweaks:e,setTweaks:t,visible:n}){if(!n)return null;const r=(o,l)=>{const s={...e,[o]:l};t(s)};return i.jsxs("div",{style:{position:"fixed",bottom:20,right:20,width:236,border:"1px solid var(--border)",background:"white",zIndex:1e3,boxShadow:"0 8px 32px rgba(0,0,0,0.1)"},children:[i.jsx("div",{style:{padding:"9px 14px",borderBottom:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:10,fontWeight:700,letterSpacing:"0.06em"},children:"TWEAKS"}),i.jsxs("div",{style:{padding:"14px"},children:[i.jsxs("div",{style:{marginBottom:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6,textTransform:"uppercase"},children:"Accent hue"}),i.jsx("input",{type:"range",min:"0",max:"360",value:e.accentHue,onChange:o=>{const l=o.target.value;r("accentHue",l),document.documentElement.style.setProperty("--accent",`oklch(0.64 0.18 ${l})`),document.documentElement.style.setProperty("--accent-dim",`oklch(0.97 0.04 ${l})`)},style:{width:"100%"}}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:2},children:["hue ",e.accentHue,"°"]})]}),i.jsxs("div",{style:{marginBottom:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6,textTransform:"uppercase"},children:"Compact nav"}),i.jsx("button",{onClick:()=>r("compactNav",!e.compactNav),style:{padding:"4px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:10,background:e.compactNav?"var(--ink)":"transparent",color:e.compactNav?"var(--bg)":"var(--ink)",cursor:"pointer"},children:e.compactNav?"ON":"OFF"})]}),i.jsxs("div",{style:{marginBottom:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6,textTransform:"uppercase"},children:"Canvas style"}),i.jsx("div",{style:{display:"flex",gap:5},children:["dots","grid"].map(o=>i.jsx("button",{onClick:()=>r("canvasStyle",o),style:{padding:"4px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,background:e.canvasStyle===o?"var(--ink)":"transparent",color:e.canvasStyle===o?"var(--bg)":"var(--ink)",cursor:"pointer"},children:o},o))})]}),i.jsxs("div",{children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6,textTransform:"uppercase"},children:"Timestamps"}),i.jsx("button",{onClick:()=>r("showTimestamps",!e.showTimestamps),style:{padding:"4px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:10,background:e.showTimestamps?"var(--ink)":"transparent",color:e.showTimestamps?"var(--bg)":"var(--ink)",cursor:"pointer"},children:e.showTimestamps?"ON":"OFF"})]})]})]})}const sg={position:"fixed",inset:0,background:"rgba(20,16,10,0.28)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},ag={width:640,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 60px)",background:"white",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 20px 60px rgba(20,16,10,0.20)",display:"flex",flexDirection:"column",overflow:"hidden"},ht={width:"100%",border:"1px solid var(--border)",padding:"9px 11px",background:"var(--bg)",fontSize:13,lineHeight:1.4},On={fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:.5,textTransform:"uppercase",marginBottom:4,display:"block"},Xi={padding:"8px 14px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10,letterSpacing:.4,cursor:"pointer"},Qr={padding:"8px 14px",border:"1px solid var(--border)",background:"white",color:"var(--ink2)",fontFamily:"var(--mono)",fontSize:10,letterSpacing:.4,cursor:"pointer"},_u={padding:"8px 14px",border:"1px solid var(--rose)",background:"white",color:"var(--rose)",fontFamily:"var(--mono)",fontSize:10,letterSpacing:.4,cursor:"pointer"},bu=["codex","claude-code"];function dg({open:e,onClose:t,projectIndex:n,initialWorkspaceId:r,initialTab:o="workspaces",onChanged:l}){var ge,Ee;const s=(n==null?void 0:n.workspaces)||[],[a,d]=v.useState(o),[c,g]=v.useState(r||((ge=s[0])==null?void 0:ge.id)||""),h=s.find(R=>R.id===c)||null,[y,S]=v.useState(""),[w,T]=v.useState(""),[V,m]=v.useState(""),[u,f]=v.useState(""),[p,j]=v.useState(""),[E,P]=v.useState(""),[z,Y]=v.useState(""),[N,J]=v.useState("codex"),[X,Q]=v.useState([]),[G,I]=v.useState({}),[U,se]=v.useState(!1),[_,W]=v.useState(null),[K,ee]=v.useState(null);if(v.useEffect(()=>{var R;e&&(d(o),g(r||((R=s[0])==null?void 0:R.id)||""),W(null),ee(null),S(""),T(""),P(""),Y(""),J("codex"),Q([]),j(""))},[e]),v.useEffect(()=>{if(!h){m(""),f("");return}m(String(h.label||h.name||"")),f(String(h.description||"")),j("")},[h==null?void 0:h.id,h==null?void 0:h.label,h==null?void 0:h.description]),v.useEffect(()=>{h&&I(R=>{const oe={};for(const q of h.projects||[]){const te=(q.scopeRules||[]).map(Ae=>Ae.pathPrefix);oe[q.id]=R[q.id]||{name:q.name,description:q.description||"",defaultRuntime:q.defaultRuntime||"codex",folders:te}}return oe})},[h==null?void 0:h.id,(Ee=h==null?void 0:h.projects)==null?void 0:Ee.length]),!e)return null;const ie=async(R,oe)=>{W(null);try{const q=await A.pickFolder(oe||"Choose a folder");q.ok&&q.path&&R(q.path)}catch(q){W(String(q))}},M=async(R,oe)=>{se(!0),W(null),ee(null);try{await oe(),ee(R),await l()}catch(q){W(String(q))}finally{se(!1)}},pe=()=>M("Workspace created.",async()=>{const R=y.trim();if(!R)throw new Error("Name is required.");await A.createWorkspaceRoot(R,w.trim()||void 0),S(""),T("")}),ae=()=>M("Workspace updated.",async()=>{if(!h)return;const R={};if(V.trim()&&V!==(h.label||h.name)&&(R.label=V.trim()),u!==(h.description||"")&&(R.description=u),!Object.keys(R).length)throw new Error("Nothing to save.");await A.updateWorkspace(h.id,R)}),me=()=>M("Workspace deleted.",async()=>{if(h){if(p.trim()!==(h.label||h.name))throw new Error("Type the workspace name exactly to confirm.");await A.deleteWorkspace(h.id),g(""),j("")}}),$=()=>M("Project created.",async()=>{if(!h)throw new Error("Pick a workspace first.");const R=E.trim();if(!R)throw new Error("Project name is required.");const oe=X.map(q=>q.trim()).filter(Boolean).map(q=>({path_prefix:q}));await A.createProject(h.id,{name:R,description:z.trim()||void 0,default_runtime:N,scope_rules:oe}),P(""),Y(""),J("codex"),Q([])}),ue=R=>()=>M("Project updated.",async()=>{const oe=G[R.id];if(!oe)return;const q={};oe.name.trim()&&oe.name.trim()!==R.name&&(q.name=oe.name.trim()),oe.description!==(R.description||"")&&(q.description=oe.description),oe.defaultRuntime&&oe.defaultRuntime!==(R.defaultRuntime||"codex")&&(q.default_runtime=oe.defaultRuntime);const te=(R.scopeRules||[]).map(xe=>xe.pathPrefix),Ae=oe.folders.map(xe=>xe.trim()).filter(Boolean);if((te.length!==Ae.length||te.some((xe,Ue)=>xe!==Ae[Ue]))&&(q.scope_rules=Ae.map(xe=>({path_prefix:xe}))),!Object.keys(q).length)throw new Error("Nothing to save.");await A.updateProject(R.id,q)}),fe=R=>()=>M("Project deleted.",async()=>{if(!window.confirm(`Delete project "${R.name}"? This removes its assets. The workspace stays.`))throw new Error("cancelled");await A.deleteProject(R.id)});return i.jsx("div",{style:sg,onClick:t,children:i.jsxs("div",{style:ag,onClick:R=>R.stopPropagation(),children:[i.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:15,fontWeight:700},children:"Workspaces & projects"}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:2},children:"Organise every agent under a shared brain."})]}),i.jsx("button",{onClick:t,style:{width:28,height:28,border:"1px solid var(--border)",borderRadius:4,background:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ink3)"},children:i.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",children:i.jsx("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})})})]}),i.jsx("div",{style:{padding:"10px 20px",borderBottom:"1px solid var(--border)",display:"flex",gap:6},children:["workspaces","projects"].map(R=>i.jsx("button",{onClick:()=>d(R),style:{padding:"6px 12px",border:`1px solid ${a===R?"var(--ink)":"var(--border)"}`,background:a===R?"var(--ink)":"white",color:a===R?"white":"var(--ink2)",fontFamily:"var(--mono)",fontSize:10,letterSpacing:.4,textTransform:"uppercase",cursor:"pointer"},children:R},R))}),i.jsxs("div",{style:{padding:20,overflowY:"auto",display:"flex",flexDirection:"column",gap:16},children:[a==="workspaces"&&i.jsxs(i.Fragment,{children:[i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsx("div",{style:On,children:"New workspace"}),i.jsx("input",{placeholder:"Name (e.g. Office, Personal, Sankhya AI Labs)",value:y,onChange:R=>S(R.target.value),style:ht}),i.jsx("textarea",{placeholder:"Description (optional)",value:w,onChange:R=>T(R.target.value),rows:2,style:{...ht,resize:"vertical"}}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",lineHeight:1.5},children:"A workspace is a collection of projects. Folders attach to projects, not workspaces."}),i.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:i.jsx("button",{onClick:()=>void pe(),disabled:U||!y.trim(),style:{...Xi,opacity:U||!y.trim()?.5:1},children:"create workspace"})})]}),i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsxs("div",{style:On,children:["Existing · ",s.length]}),s.length===0?i.jsx("div",{style:{padding:14,border:"1px dashed var(--border)",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55},children:"No workspaces yet. Create one above."}):i.jsx("div",{style:{display:"grid",gap:6},children:s.map(R=>{var te;const oe=R.id===c,q=((te=R.projects)==null?void 0:te.length)||0;return i.jsxs("button",{onClick:()=>g(R.id),style:{textAlign:"left",padding:"10px 12px",border:`1px solid ${oe?"var(--accent)":"var(--border)"}`,background:oe?"var(--surface)":"white",display:"flex",justifyContent:"space-between",gap:12,cursor:"pointer"},children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:13,fontWeight:600,lineHeight:1.3},children:R.label||R.name}),R.description&&i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:2},children:R.description})]}),i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[q," project",q===1?"":"s"]})]},R.id)})})]}),h&&i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8,borderTop:"1px solid var(--border)",paddingTop:14},children:[i.jsxs("div",{style:On,children:["Edit · ",h.label||h.name]}),i.jsx("input",{value:V,onChange:R=>m(R.target.value),placeholder:"Name",style:ht}),i.jsx("textarea",{value:u,onChange:R=>f(R.target.value),placeholder:"Description",rows:2,style:{...ht,resize:"vertical"}}),i.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:i.jsx("button",{onClick:()=>void ae(),disabled:U,style:{...Xi,opacity:U?.5:1},children:"save changes"})}),i.jsxs("div",{style:{marginTop:8,padding:12,border:"1px solid rgba(203,63,78,0.3)",borderRadius:4,background:"rgba(203,63,78,0.04)"},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--rose)",letterSpacing:.5,textTransform:"uppercase",marginBottom:6},children:"Danger zone"}),i.jsxs("div",{style:{fontSize:11,color:"var(--ink2)",lineHeight:1.5,marginBottom:8},children:["Deleting ",i.jsx("strong",{children:h.label||h.name})," removes every project, asset, and line message. Sessions remain but detach. Type the workspace name to confirm."]}),i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsx("input",{value:p,onChange:R=>j(R.target.value),placeholder:h.label||h.name,style:{...ht,flex:1}}),i.jsx("button",{onClick:()=>void me(),disabled:U||p.trim()!==(h.label||h.name),style:{..._u,opacity:U||p.trim()!==(h.label||h.name)?.5:1},children:"delete workspace"})]})]})]})]}),a==="projects"&&i.jsxs(i.Fragment,{children:[i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsx("div",{style:On,children:"Workspace"}),i.jsxs("select",{value:c,onChange:R=>g(R.target.value),style:ht,children:[i.jsx("option",{value:"",children:"— pick a workspace —"}),s.map(R=>i.jsx("option",{value:R.id,children:R.label||R.name},R.id))]})]}),h&&i.jsxs(i.Fragment,{children:[i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsxs("div",{style:On,children:["Add project to ",h.label||h.name]}),i.jsx("input",{placeholder:"Project name (e.g. frontend, backend, design)",value:E,onChange:R=>P(R.target.value),style:ht}),i.jsx("textarea",{placeholder:"Description (optional)",value:z,onChange:R=>Y(R.target.value),rows:2,style:{...ht,resize:"vertical"}}),i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"default runtime"}),i.jsx("select",{value:N,onChange:R=>J(R.target.value),style:{...ht,flex:1},children:bu.map(R=>i.jsx("option",{value:R,children:R},R))})]}),i.jsx(Cu,{folders:X,onChange:Q,onPick:R=>void ie(R,"Choose a project folder"),disabled:U}),i.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:i.jsx("button",{onClick:()=>void $(),disabled:U||!E.trim(),style:{...Xi,opacity:U||!E.trim()?.5:1},children:"add project"})})]}),i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsxs("div",{style:On,children:["Projects · ",(h.projects||[]).length]}),(h.projects||[]).length===0?i.jsx("div",{style:{padding:14,border:"1px dashed var(--border)",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55},children:"No projects yet — add the first one above."}):i.jsx("div",{style:{display:"grid",gap:10},children:(h.projects||[]).map(R=>{const oe=G[R.id]||{name:R.name,description:R.description||"",defaultRuntime:R.defaultRuntime||"codex",folders:(R.scopeRules||[]).map(te=>te.pathPrefix)},q=te=>I(Ae=>({...Ae,[R.id]:{...oe,...te}}));return i.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:10,display:"flex",flexDirection:"column",gap:8},children:[i.jsx("input",{value:oe.name,onChange:te=>q({name:te.target.value}),style:ht}),i.jsx("textarea",{value:oe.description,onChange:te=>q({description:te.target.value}),rows:2,style:{...ht,resize:"vertical"}}),i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"runtime"}),i.jsx("select",{value:oe.defaultRuntime,onChange:te=>q({defaultRuntime:te.target.value}),style:{...ht,flex:1},children:bu.map(te=>i.jsx("option",{value:te,children:te},te))})]}),i.jsx(Cu,{folders:oe.folders,onChange:te=>q({folders:te}),onPick:te=>void ie(te,`Add a folder to ${R.name}`),disabled:U}),i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:8},children:[i.jsx("button",{onClick:()=>void fe(R)(),disabled:U,style:{..._u,opacity:U?.5:1},children:"delete"}),i.jsx("button",{onClick:()=>void ue(R)(),disabled:U,style:{...Xi,opacity:U?.5:1},children:"save"})]})]},R.id)})})]})]})]})]}),i.jsxs("div",{style:{padding:"10px 20px",borderTop:"1px solid var(--border)",background:"var(--bg)",display:"flex",alignItems:"center",justifyContent:"space-between",minHeight:44},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,lineHeight:1.4},children:_?i.jsx("span",{style:{color:"var(--rose)"},children:_}):K?i.jsx("span",{style:{color:"var(--green)"},children:K}):i.jsx("span",{style:{color:"var(--ink3)"},children:"Changes save immediately."})}),i.jsx("button",{onClick:t,style:Qr,children:"close"})]})]})})}function Cu({folders:e,onChange:t,onPick:n,disabled:r}){const o=(d,c)=>{const g=e.slice();g[d]=c,t(g)},l=d=>{const c=e.slice();c.splice(d,1),t(c)},s=()=>t([...e,""]),a=()=>n(d=>t([...e,d]));return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsxs("div",{style:On,children:["Folders · ",e.length]}),e.length===0&&i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",lineHeight:1.5},children:"No folders yet. A project can have one or many."}),e.map((d,c)=>i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("input",{value:d,onChange:g=>o(c,g.target.value),placeholder:"/absolute/path",style:{...ht,flex:1}}),i.jsx("button",{onClick:()=>n(g=>o(c,g)),style:Qr,disabled:r,children:"browse…"}),i.jsx("button",{onClick:()=>l(c),style:Qr,disabled:r,title:"Remove folder",children:"✕"})]},c)),i.jsxs("div",{style:{display:"flex",gap:6},children:[i.jsx("button",{onClick:a,style:Qr,disabled:r,children:"+ pick folder"}),i.jsx("button",{onClick:s,style:Qr,disabled:r,children:"+ type path"})]})]})}function Ie({label:e,tone:t="var(--ink3)"}){return i.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 7px",border:`1px solid ${t}`,color:t,fontFamily:"var(--mono)",fontSize:9,lineHeight:1.2,whiteSpace:"nowrap"},children:e})}const Eu=6e4,Tu=36e5,zu=864e5;function fp(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return String(e);const n=Date.now()-t;return nvoid t(e),disabled:n,title:"Remove asset","aria-label":"Remove asset",style:{width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid transparent",borderRadius:3,background:"transparent",color:"var(--ink3)",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,padding:0,flexShrink:0},onMouseEnter:a=>{n||(a.currentTarget.style.background="rgba(203,63,78,0.08)",a.currentTarget.style.color="var(--rose)")},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.color="var(--ink3)"},children:i.jsx("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",children:i.jsx("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})})})]}),i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[s.size>0?i.jsx(Ie,{label:`${l.length} processed`,tone:"var(--green)"}):i.jsx(Ie,{label:"not yet processed"}),Array.from(s).slice(0,3).map(a=>i.jsx(Ie,{label:a,tone:$s(a)},a))]}),l.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>o(a=>!a),style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",background:"transparent",border:0,padding:0,textAlign:"left",cursor:"pointer",letterSpacing:.4},children:r?"▾ hide processing feed":`▸ show processing feed (${l.length})`}),r&&i.jsx("div",{style:{display:"flex",flexDirection:"column",borderTop:"1px dashed var(--border)",paddingTop:6},children:l.slice(0,8).map(a=>i.jsx(pg,{result:a},a.id))})]})]})}function mg({workspace:e,project:t,onActivity:n}){const[r,o]=v.useState([]),[l,s]=v.useState(!1),[a,d]=v.useState(null),[c,g]=v.useState("idle"),[h,y]=v.useState(""),[S,w]=v.useState(!1),[T,V]=v.useState(null),m=v.useRef(null),u=v.useMemo(()=>t?t.name:e?`${e.label||e.name} (workspace)`:"—",[t,e]),f=v.useCallback(async()=>{if(!e){o([]);return}s(!0),d(null);try{const N=t?await A.listProjectAssets(t.id):await A.listWorkspaceAssets(e.id,!1);o(N.assets||[])}catch(N){d(String(N))}finally{s(!1)}},[t,e]);v.useEffect(()=>{f()},[f]),v.useEffect(()=>{if(!e)return;const N=window.setInterval(()=>void f(),5e3);return()=>window.clearInterval(N)},[f,e]);const p=v.useCallback(async N=>{if(!e)return;const J=Array.from(N);if(J.length!==0){g("uploading"),y(`uploading ${J.length} file${J.length===1?"":"s"}…`),d(null);try{for(const X of J)t?await A.uploadProjectAsset(t.id,X):await A.uploadWorkspaceAsset(e.id,X);g("success"),y(J.length===1?`uploaded ${J[0].name}`:`uploaded ${J.length} files`),await f(),n==null||n()}catch(X){g("error"),y(String(X))}finally{window.setTimeout(()=>{g("idle"),y("")},2200)}}},[t,e,f,n]),j=N=>{var X;N.preventDefault(),N.stopPropagation(),w(!1);const J=N.dataTransfer;(X=J==null?void 0:J.files)!=null&&X.length&&p(J.files)},E=N=>{var J;e&&(N.preventDefault(),N.stopPropagation(),(J=N.dataTransfer.types)!=null&&J.includes("Files")&&!S&&w(!0))},P=N=>{N.currentTarget===N.target&&w(!1)},z=N=>{const J=N.target.files;J!=null&&J.length&&p(J),N.target.value=""},Y=async N=>{if(window.confirm(`Remove "${N.name}"?`)){V(N.id);try{await A.deleteProjectAsset(N.id),o(J=>J.filter(X=>X.id!==N.id)),n==null||n()}catch(J){d(String(J))}finally{V(null)}}};return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},onDrop:j,onDragOver:E,onDragLeave:P,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.5,color:"var(--ink3)",textTransform:"uppercase"},children:[i.jsxs("span",{children:["Assets · ",u]}),i.jsx("span",{children:r.length})]}),i.jsxs("div",{onClick:()=>{var N;return e&&((N=m.current)==null?void 0:N.click())},style:{padding:"16px 14px",border:`1px dashed ${S?"var(--accent)":"var(--border)"}`,background:S?"rgba(224,107,63,0.06)":"white",borderRadius:6,textAlign:"center",cursor:e?"pointer":"not-allowed",opacity:e?1:.55,transition:"background 0.18s ease, border-color 0.18s ease"},children:[i.jsx("input",{ref:m,type:"file",multiple:!0,style:{display:"none"},onChange:z}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:S?"var(--accent)":"var(--ink2)",fontWeight:500,marginBottom:4},children:c==="uploading"?h:S?"release to upload":"drop files here or click to upload"}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:.4},children:t?"visible to every agent working on this project":e?"workspace-wide — every project sees it":"select a workspace first"})]}),c==="success"&&i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--green)",lineHeight:1.4},children:h}),c==="error"&&i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--rose)",lineHeight:1.4},children:h}),a&&c!=="error"?i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--rose)",lineHeight:1.4},children:a}):null,l&&r.length===0?i.jsx("div",{style:{display:"grid",gap:8},children:[0,1,2].map(N=>i.jsx("div",{style:{height:66,borderRadius:6,background:"linear-gradient(90deg, rgba(20,16,10,0.04) 0%, rgba(20,16,10,0.08) 50%, rgba(20,16,10,0.04) 100%)",backgroundSize:"200% 100%",animation:`dhee-shimmer 1.4s linear ${N*140}ms infinite`,border:"1px solid rgba(20,16,10,0.06)"}},N))}):r.length===0?i.jsxs("div",{style:{padding:14,border:"1px dashed var(--border)",borderRadius:6,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55,background:"white"},children:["No assets yet. Drop a spec PDF, design export, or schema doc here — every agent in this",t?" project":" workspace"," will see it."]}):i.jsx("div",{style:{display:"grid",gap:8},children:r.map(N=>i.jsx(hg,{asset:N,onDelete:Y,busyDelete:T===N.id},N.id))})]})}const Nu=6e4,Ru=36e5,Pu=864e5;function pp(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return String(e);const n=Date.now()-t;return n{const l=String(o.runtime||"unknown").toLowerCase(),s=n.get(l)||{count:0,latestUpdate:null,isLive:!1};s.count+=1,o.updatedAt&&(!s.latestUpdate||o.updatedAt>s.latestUpdate)&&(s.latestUpdate=o.updatedAt),(o.isCurrent||o.state==="active"||o.state==="recent")&&(s.isLive=!0),n.set(l,s)};for(const o of t||[])r(o);for(const o of e||[])for(const l of o.sessions||[])r(l);return Array.from(n.entries()).map(([o,l])=>({runtime:o,...l})).sort((o,l)=>l.count-o.count)}function Sg({workspace:e,projects:t,workspaceSessions:n}){const r=v.useMemo(()=>xg(t,n),[t,n]),o=r.reduce((l,s)=>l+s.count,0);return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:14},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:10},children:[i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:["Connected agents · ",o]}),e?i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:e.label||e.name}):null]}),r.length===0?i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55},children:"No agent sessions yet. Launch claude-code or codex in this workspace — they will register here and start publishing to the line."}):i.jsx("div",{style:{display:"grid",gap:6},children:r.map(l=>i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:l.isLive?"var(--green)":"var(--ink3)",boxShadow:l.isLive?"0 0 0 3px rgba(31,169,113,0.18)":"none",flexShrink:0}}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:11,color:hp(l.runtime),whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:l.runtime}),i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:["· ",l.count]})]}),l.latestUpdate?i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:pp(l.latestUpdate)}):null]},l.runtime))})]})}function mp({message:e,workspace:t,onOpenTask:n}){var h,y;const r=((h=t==null?void 0:t.projects.find(S=>S.id===e.project_id))==null?void 0:h.name)||"workspace",o=((y=t==null?void 0:t.projects.find(S=>S.id===e.target_project_id))==null?void 0:y.name)||"",l=e.metadata||{},s=String(l.harness||l.runtime||""),a=String(l.tool_name||l.toolName||""),d=String(l.ptr||""),c=e.body||"",g=vg(e.message_kind);return i.jsxs("div",{style:{border:"1px solid var(--border)",borderLeft:`3px solid ${g}`,background:"white",padding:"11px 13px"},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:10,marginBottom:6},children:[i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:hp(s),letterSpacing:.4},children:[gg(e.created_at),s?` · ${s}`:"",r!=="workspace"?` · ${r}`:""]}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:pp(e.created_at)})]}),e.title?i.jsx("div",{style:{fontSize:13,fontWeight:600,marginBottom:5,lineHeight:1.35},children:e.title}):null,c?i.jsx("div",{style:{fontSize:12,color:"var(--ink2)",lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:c}):null,i.jsxs("div",{style:{display:"flex",gap:5,flexWrap:"wrap",marginTop:8},children:[i.jsx(Ie,{label:yg(e.message_kind),tone:g}),a?i.jsx(Ie,{label:a.toLowerCase()}):null,o?i.jsx(Ie,{label:`→ ${o}`,tone:"#4d6cff"}):null,d?i.jsx(Ie,{label:d}):null,e.task_id&&n?i.jsx("button",{onClick:()=>n(String(e.task_id)),style:{padding:"2px 8px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.4,textTransform:"uppercase",cursor:"pointer"},children:"open task"}):null]})]})}function gp({workspace:e,activeProjectId:t,sessionId:n,taskId:r,onPublished:o}){var P;const[l,s]=v.useState(""),[a,d]=v.useState(""),[c,g]=v.useState(""),[h,y]=v.useState(!1),[S,w]=v.useState(null),[T,V]=v.useState(null),m=v.useRef(null);v.useEffect(()=>{var z;(z=m.current)==null||z.focus()},[e==null?void 0:e.id]);const u=v.useMemo(()=>((e==null?void 0:e.projects)||[]).filter(z=>!t||z.id!==t),[e==null?void 0:e.projects,t]),f=async()=>{var z;if(!(!(e!=null&&e.id)||!a.trim()||h)){y(!0),V(null),w(null);try{const Y=await A.publishWorkspaceLineMessage(e.id,{project_id:t||void 0,target_project_id:c||void 0,channel:t?"project":"workspace",session_id:n||void 0,task_id:r||void 0,message_kind:c?"broadcast":"note",title:l.trim()||void 0,body:a.trim(),metadata:{sourceProject:(z=e.projects.find(N=>N.id===t))==null?void 0:z.name}});if(Y.suggestedTask){const N=e.projects.find(J=>J.id===c);w(N?`Broadcast sent · suggested task created in ${N.name}.`:"Broadcast sent · suggested task created.")}else w("Published to the workspace line.");s(""),d(""),g(""),o==null||o(Y.message,Y.suggestedTask)}catch(Y){V(String(Y))}finally{y(!1)}}};if(!e)return i.jsx("div",{style:{padding:16,border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",background:"white"},children:"No workspace selected."});const p=!a.trim()||h,j=(P=u.find(z=>z.id===c))==null?void 0:P.name,E=h?"publishing…":c?`broadcast → ${j||"project"}`:"publish update";return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:14,display:"flex",flexDirection:"column",gap:8},children:[i.jsx("input",{value:l,onChange:z=>s(z.target.value),placeholder:"headline (optional) — e.g. user.plan field added",style:{border:"1px solid var(--border)",padding:"9px 11px",background:"var(--bg)",fontSize:13}}),i.jsxs("select",{value:c,onChange:z=>g(z.target.value),style:{border:"1px solid var(--border)",padding:"9px 11px",background:"var(--bg)",fontFamily:"var(--mono)",fontSize:10},children:[i.jsxs("option",{value:"",children:["Publish to current ",t?"project":"workspace"," only"]}),u.map(z=>i.jsxs("option",{value:z.id,children:["Broadcast into ",z.name," (creates task)"]},z.id))]}),i.jsx("textarea",{ref:m,value:a,onChange:z=>d(z.target.value),placeholder:c?"What should the target project's agent know? It will spawn a task with this context.":"Broadcast a dependency change, a tool result, or a follow-up signal to the workspace line…",rows:4,onKeyDown:z=>{(z.metaKey||z.ctrlKey)&&z.key==="Enter"&&(z.preventDefault(),f())},style:{border:"1px solid var(--border)",padding:"10px 12px",background:"var(--bg)",fontSize:13,lineHeight:1.55,resize:"vertical"}}),i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:10},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:.3},children:"⌘/Ctrl + Enter to publish"}),i.jsx("button",{onClick:()=>void f(),disabled:p,style:{padding:"8px 14px",border:"1px solid var(--ink)",background:p?"var(--ink3)":"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10,letterSpacing:.4,opacity:p?.7:1,cursor:p?"not-allowed":"pointer"},children:E})]}),S?i.jsx("div",{style:{fontSize:11,color:"var(--green)",lineHeight:1.5},children:S}):null,T?i.jsx("div",{style:{fontSize:11,color:"var(--rose)",lineHeight:1.5},children:T}):null]})}function vp(e,t){const[n,r]=v.useState([]),[o,l]=v.useState(!1),[s,a]=v.useState(null),d=g=>{r(h=>{const y=new Map;return[...g,...h].forEach(S=>{S!=null&&S.id&&y.set(S.id,S)}),Array.from(y.values()).sort((S,w)=>String(w.created_at||"").localeCompare(String(S.created_at||"")))})},c=async()=>{if(!e){r([]);return}try{const g=await A.workspaceLineMessages(e,{project_id:t||void 0,limit:100});r(g.messages||[])}catch(g){a(String(g))}};return v.useEffect(()=>{c()},[e,t]),v.useEffect(()=>{if(!e){l(!1);return}const g=new URLSearchParams;t&&g.set("project_id",t);const h=new EventSource(`/api/workspaces/${encodeURIComponent(e)}/line/stream${g.toString()?`?${g.toString()}`:""}`);return h.onopen=()=>l(!0),h.onmessage=y=>{try{const S=JSON.parse(y.data);d([S])}catch{}},h.onerror=()=>{l(!1),h.close()},()=>{h.close(),l(!1)}},[e,t]),{messages:n,live:o,error:s,merge:d,refresh:c}}function kg(e,t){if(!e)return[];const n=new Set(e.projects.map(r=>r.id));return t.filter(r=>{const o=String(r.source||"").toLowerCase();if(o!=="broadcast"&&!o.includes("suggested"))return!1;const l=r.project_id;return!l||n.has(String(l))})}function jg({projectIndex:e,workspaceGraph:t,tasks:n,viewer:r,orgGraph:o,selectedWorkspaceId:l,selectedProjectId:s,onSelectWorkspace:a,onSelectProject:d,onSelectTask:c,onTasksRefresh:g,onOpenCanvas:h,onLaunchSession:y,onOpenManager:S}){var W,K,ee,ie,M,pe,ae,me;const w=(e==null?void 0:e.workspaces)||[],[T,V]=v.useState(null),m=v.useMemo(()=>{var ge;const $=((ge=o==null?void 0:o.raw)==null?void 0:ge.context_index)||[],ue=(r==null?void 0:r.team_id)||"",fe=(r==null?void 0:r.project_id)||"";return $.filter(Ee=>!!(Ee.scope==="company"||ue&&Ee.team_id===ue||fe&&Ee.project_id===fe||Ee.scope==="user"&&Ee.user_id===(r==null?void 0:r.user_id)))},[(W=o==null?void 0:o.raw)==null?void 0:W.context_index,r==null?void 0:r.project_id,r==null?void 0:r.team_id,r==null?void 0:r.user_id]),u=v.useMemo(()=>{var fe;const $=((fe=o==null?void 0:o.raw)==null?void 0:fe.pending_proposals)||[],ue=(r==null?void 0:r.team_id)||"";return ue?$.filter(ge=>!ge.team_id||ge.team_id===ue):$},[(K=o==null?void 0:o.raw)==null?void 0:K.pending_proposals,r==null?void 0:r.team_id]),[f,p]=v.useState("all"),j=v.useMemo(()=>w.find($=>$.id===l)||w.find($=>$.id===(e==null?void 0:e.currentWorkspaceId))||w[0]||(t==null?void 0:t.workspace)||null,[w,l,e==null?void 0:e.currentWorkspaceId,t]),E=v.useMemo(()=>j&&(j.projects.find($=>$.id===s)||j.projects.find($=>$.id===(e==null?void 0:e.currentProjectId)))||null,[j,s,e==null?void 0:e.currentProjectId]),P=(j==null?void 0:j.sessions)||[],z=v.useMemo(()=>{var fe,ge;const $=e==null?void 0:e.currentSessionId;if(!j)return null;const ue=((fe=E==null?void 0:E.sessions)==null?void 0:fe.find(Ee=>Ee.id===$))||((ge=E==null?void 0:E.sessions)==null?void 0:ge[0]);return ue||P.find(Ee=>Ee.id===$)||P[0]||null},[j,E,e==null?void 0:e.currentSessionId,P]),{messages:Y,live:N,error:J,refresh:X}=vp(j==null?void 0:j.id,E==null?void 0:E.id);v.useEffect(()=>{let $=!0;return A.continuity().then(ue=>{$&&V(ue)}).catch(()=>{$&&V(null)}),()=>{$=!1}},[r==null?void 0:r.org_id,r==null?void 0:r.team_id]);const Q=v.useMemo(()=>f==="all"?Y:Y.filter($=>{const ue=String($.message_kind||"").toLowerCase();return f==="broadcast"?ue==="broadcast":f==="tool"?ue.startsWith("tool."):f==="note"?ue==="note"||ue==="update":!0}),[Y,f]),G=v.useMemo(()=>kg(j,n),[j,n]),[I,U]=v.useState(null);v.useEffect(()=>{var ue;const $=(ue=Y[0])==null?void 0:ue.id;$&&$!==I&&U($)},[Y,I]);const se=$=>({padding:"5px 10px",border:`1px solid ${$?"var(--ink)":"var(--border)"}`,background:$?"var(--ink)":"white",color:$?"white":"var(--ink2)",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.5,textTransform:"uppercase",cursor:"pointer"}),_=$=>({width:"100%",textAlign:"left",padding:"9px 10px",border:`1px solid ${$?"var(--accent)":"var(--border)"}`,background:$?"var(--surface)":"white",fontFamily:$?"var(--sans)":"var(--mono)",fontSize:$?12:11,color:"var(--ink)",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",gap:8});return i.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{height:48,borderBottom:"1px solid var(--border)",padding:"0 20px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0},children:[i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[(j==null?void 0:j.label)||(j==null?void 0:j.name)||"channel",E?` / ${E.name}`:""]}),i.jsx(Ie,{label:N?"live":"offline",tone:N?"var(--green)":"var(--ink3)"}),i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[Q.length," events · ",G.length," suggested tasks"]}),i.jsx(Ie,{label:`${(r==null?void 0:r.role)||"developer"} context`,tone:(r==null?void 0:r.role)==="manager"||(r==null?void 0:r.role)==="admin"?"var(--accent)":"var(--indigo)"})]}),i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[i.jsx("button",{onClick:h,style:{padding:"6px 12px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink2)",background:"white",cursor:"pointer",letterSpacing:.4},children:"open canvas"}),i.jsx("button",{onClick:()=>void X(),style:{padding:"6px 12px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink2)",background:"white",cursor:"pointer",letterSpacing:.4},children:"refresh"})]})]}),i.jsxs("div",{style:{flex:1,display:"grid",gridTemplateColumns:"260px minmax(0, 1fr) 360px",overflow:"hidden"},children:[i.jsxs("div",{style:{borderRight:"1px solid var(--border)",padding:16,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[i.jsxs("div",{style:{padding:12,border:"1px solid var(--border)",background:"var(--surface)",display:"grid",gap:8},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Context scope"}),i.jsx("div",{style:{fontSize:13,color:"var(--ink)"},children:(r==null?void 0:r.team_id)||(r==null?void 0:r.project_id)||(r==null?void 0:r.org_id)||"local dhee"}),i.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[i.jsxs("span",{children:[m.length," context items"]}),i.jsx("span",{children:"·"}),i.jsxs("span",{children:[u.length," pending"]})]}),i.jsx("button",{onClick:h,style:{padding:"6px 8px",border:"1px solid var(--accent)",background:"var(--accent-dim)",color:"var(--accent)",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.5,cursor:"pointer"},children:"OPEN ORG MAP"})]}),i.jsxs("div",{style:{padding:12,border:"1px solid var(--border)",background:"white",display:"grid",gap:8},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Continue context"}),i.jsx("div",{style:{fontSize:12,color:"var(--ink2)",lineHeight:1.45},children:((ee=T==null?void 0:T.last_session)==null?void 0:ee.task_summary)||((M=(ie=T==null?void 0:T.claude_sessions)==null?void 0:ie[0])==null?void 0:M.preview)||"No Claude session recovered yet for this repo."}),i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[i.jsx("span",{children:((pe=T==null?void 0:T.last_session)==null?void 0:pe.source)||"waiting"}),i.jsx("span",{children:"·"}),i.jsxs("span",{children:[((ae=T==null?void 0:T.claude_sessions)==null?void 0:ae.length)||0," claude sessions"]})]})]}),i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8,gap:8},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Workspace"}),S?i.jsx("button",{onClick:()=>S("workspaces"),title:"Manage workspaces",style:{padding:"3px 7px",border:"1px solid var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.4,color:"var(--ink3)",cursor:"pointer"},children:"+ new / manage"}):null]}),w.length===0?i.jsx("button",{onClick:()=>S==null?void 0:S("workspaces"),style:{width:"100%",padding:"10px 12px",border:"1px dashed var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink2)",textAlign:"left",cursor:"pointer",lineHeight:1.5},children:"Create your first workspace → e.g. Office, Personal, Sankhya AI Labs."}):i.jsx("select",{value:(j==null?void 0:j.id)||"",onChange:$=>a($.target.value),style:{width:"100%",padding:"9px 10px",border:"1px solid var(--border)",background:"white",fontSize:12},children:w.map($=>i.jsx("option",{value:$.id,children:$.label||$.name},$.id))})]}),i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8,gap:8},children:[i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:["Projects · ",((me=j==null?void 0:j.projects)==null?void 0:me.length)||0]}),S&&j?i.jsx("button",{onClick:()=>S("projects"),title:"Add or edit projects",style:{padding:"3px 7px",border:"1px solid var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:9,letterSpacing:.4,color:"var(--ink3)",cursor:"pointer"},children:"+ project"}):null]}),i.jsxs("div",{style:{display:"grid",gap:6},children:[i.jsxs("button",{onClick:()=>d("",j==null?void 0:j.id),style:_(!E),children:[i.jsx("span",{children:"All projects (workspace line)"}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:P.length})]}),((j==null?void 0:j.projects)||[]).map($=>{var ge;const ue=$.id===(E==null?void 0:E.id),fe=((ge=$.sessions)==null?void 0:ge.length)||0;return i.jsxs("button",{onClick:()=>d($.id,j==null?void 0:j.id),style:_(ue),children:[i.jsx("span",{children:$.name}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:fe})]},$.id)})]})]}),i.jsx(Sg,{workspace:j,projects:(j==null?void 0:j.projects)||[],workspaceSessions:P}),j&&i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Launch"}),i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[i.jsx("button",{onClick:()=>void y("channel session","codex",j.id,void 0,E==null?void 0:E.id),style:se(!1),children:"+ codex"}),i.jsx("button",{onClick:()=>void y("channel session","claude-code",j.id,"standard",E==null?void 0:E.id),style:se(!1),children:"+ claude"})]})]})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--bg)"},children:[i.jsxs("div",{style:{padding:"12px 20px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Shared line"}),i.jsx("button",{onClick:()=>p("all"),style:se(f==="all"),children:"all"}),i.jsx("button",{onClick:()=>p("broadcast"),style:se(f==="broadcast"),children:"broadcasts"}),i.jsx("button",{onClick:()=>p("tool"),style:se(f==="tool"),children:"tool events"}),i.jsx("button",{onClick:()=>p("note"),style:se(f==="note"),children:"notes"}),i.jsx("span",{style:{flex:1}}),J?i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--rose)"},children:J}):null]}),i.jsx("div",{style:{flex:1,overflowY:"auto",padding:20,display:"flex",flexDirection:"column",gap:10},children:Q.length===0?i.jsxs("div",{style:{padding:24,border:"1px dashed var(--border)",background:"white",textAlign:"center"},children:[i.jsx("div",{style:{fontSize:13,fontWeight:600,marginBottom:6},children:"The line is quiet."}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55},children:"Every agent tool-call in this workspace will appear here. Launch a session from the left rail, or broadcast a note from the composer to get started."})]}):Q.map($=>i.jsx(mp,{message:$,workspace:j,onOpenTask:c},$.id))})]}),i.jsxs("div",{style:{borderLeft:"1px solid var(--border)",padding:16,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase"},children:"Broadcast"}),i.jsx(gp,{workspace:j,activeProjectId:E==null?void 0:E.id,sessionId:z==null?void 0:z.id,onPublished:async()=>{await g(),X()}}),i.jsx(mg,{workspace:j,project:E,onActivity:()=>void X()}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:.6,color:"var(--ink3)",textTransform:"uppercase",marginTop:2},children:["Suggested tasks · ",G.length]}),i.jsx("div",{style:{display:"grid",gap:8},children:G.length===0?i.jsx("div",{style:{padding:12,border:"1px dashed var(--border)",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",lineHeight:1.55,background:"white"},children:"When an agent broadcasts to another project, a task is auto-created there. It will show up here."}):G.slice(0,10).map($=>i.jsxs("button",{onClick:()=>c($.id),style:{textAlign:"left",padding:"10px 12px",border:"1px solid var(--border)",background:"white",cursor:"pointer",display:"flex",flexDirection:"column",gap:6},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,lineHeight:1.35},children:$.title}),i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[i.jsx(Ie,{label:$.status||"active",tone:"var(--accent)"}),$.harness?i.jsx(Ie,{label:String($.harness)}):null]})]},$.id))})]})]})]})}const wg={live:!1,proposals:[],findings:[],conflicts:[],totals:{proposals:0,findings:0,conflicts:0}};function Lu(e){return e==="high"?"var(--rose)":e==="medium"?"var(--accent)":"var(--indigo)"}function _g(e){const t=e.summary||e.content||"";return t.length>260?`${t.slice(0,260)}...`:t}function bg({viewer:e,onChanged:t}){var T,V,m;const[n,r]=v.useState(wg),[o,l]=v.useState(null),[s,a]=v.useState(null),[d,c]=v.useState(null),g=async()=>{try{const u=await A.inbox(e!=null&&e.team_id?{team:e.team_id,user:e.user_id}:{user:e==null?void 0:e.user_id});r(u),l(f=>{var p,j,E,P,z,Y;return f||((j=(p=u.proposals)==null?void 0:p[0])==null?void 0:j.context_id)||((P=(E=u.findings)==null?void 0:E[0])==null?void 0:P.finding_id)||String(((Y=(z=u.conflicts)==null?void 0:z[0])==null?void 0:Y.id)||"")||null})}catch(u){c(u instanceof Error?u.message:String(u))}};v.useEffect(()=>{g();const u=window.setInterval(()=>void g(),6e3);return()=>window.clearInterval(u)},[e==null?void 0:e.team_id,e==null?void 0:e.user_id]);const h=v.useMemo(()=>{var u,f,p;return(((u=n.totals)==null?void 0:u.proposals)||0)+(((f=n.totals)==null?void 0:f.findings)||0)+(((p=n.totals)==null?void 0:p.conflicts)||0)},[n.totals]),y=async(u,f)=>{a(`${f}:${u.context_id}`),c(null);try{f==="approve"?await A.approveProposal(u.context_id,(e==null?void 0:e.user_id)||"manager"):await A.rejectProposal(u.context_id,(e==null?void 0:e.user_id)||"manager"),await g(),await(t==null?void 0:t())}catch(p){c(p instanceof Error?p.message:String(p))}finally{a(null)}},S=async u=>{a(`finding:${u.finding_id}`),c(null);try{await A.resolveFinding(u.finding_id,(e==null?void 0:e.user_id)||"manager"),await g(),await(t==null?void 0:t())}catch(f){c(f instanceof Error?f.message:String(f))}finally{a(null)}},w=async(u,f)=>{const p=String(u.id||"");if(p){a(`conflict:${p}:${f}`),c(null);try{await A.resolveConflictDetailed(p,{action:f}),await g(),await(t==null?void 0:t())}catch(j){c(j instanceof Error?j.message:String(j))}finally{a(null)}}};return i.jsxs("div",{className:"inbox-shell",style:{display:"flex",height:"100%",minHeight:0},children:[i.jsxs("aside",{className:"inbox-sidebar",style:{width:300,borderRight:"1px solid var(--border)",background:"white",padding:16,overflowY:"auto",flexShrink:0},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",letterSpacing:"0.08em",textTransform:"uppercase"},children:"Inbox"}),i.jsxs("div",{style:{fontSize:22,fontWeight:650,marginTop:6},children:[h," open"]}),i.jsxs("div",{style:{marginTop:10,display:"grid",gap:8,fontFamily:"var(--mono)",fontSize:10},children:[i.jsx(Ll,{label:"Proposals",value:((T=n.totals)==null?void 0:T.proposals)||0}),i.jsx(Ll,{label:"Findings",value:((V=n.totals)==null?void 0:V.findings)||0}),i.jsx(Ll,{label:"Conflicts",value:((m=n.totals)==null?void 0:m.conflicts)||0})]}),i.jsx("div",{style:{marginTop:18,padding:12,border:"1px solid var(--border)",background:"var(--surface)",fontSize:12,lineHeight:1.5,color:"var(--ink2)"},children:"Review context changes, stale-context findings, and memory conflicts from one queue. Approvals activate context used by routing."}),d?i.jsx("div",{style:{marginTop:12,padding:10,border:"1px solid var(--rose)",background:"var(--rose-dim)",color:"var(--rose)",fontFamily:"var(--mono)",fontSize:10,lineHeight:1.5},children:d}):null]}),i.jsxs("main",{className:"inbox-main",style:{flex:1,minWidth:0,overflowY:"auto",background:"var(--bg)",padding:18,display:"grid",gap:16,alignContent:"start"},children:[i.jsx(Ol,{title:"Pending Proposals",count:n.proposals.length,empty:"No context edits are waiting for approval.",children:n.proposals.map(u=>i.jsxs("article",{onClick:()=>l(u.context_id),style:Il(o===u.context_id),children:[i.jsxs("div",{style:$l,children:[i.jsxs("div",{children:[i.jsx("div",{style:Dl,children:u.title}),i.jsxs("div",{style:Ml,children:[u.proposed_by_user_id||"developer"," · ",u.team_id||u.project_id||u.scope]})]}),i.jsx(mo,{color:"var(--accent)",children:"pending"})]}),i.jsx("p",{style:$u,children:_g(u)||"No preview available."}),i.jsxs("div",{className:"inbox-actions",style:{display:"flex",gap:8,justifyContent:"flex-end",flexWrap:"wrap"},children:[i.jsx(Ir,{label:"Open in Context",onClick:f=>{f.stopPropagation(),window.location.hash=`#vault/item/${u.context_id}`,window.history.replaceState(null,"",`?view=context${window.location.hash}`),window.dispatchEvent(new PopStateEvent("popstate"))}}),i.jsx(Ir,{label:"Reject",color:"var(--rose)",busy:s===`reject:${u.context_id}`,onClick:f=>{f.stopPropagation(),y(u,"reject")}}),i.jsx(Ir,{label:"Approve",color:"var(--green)",busy:s===`approve:${u.context_id}`,onClick:f=>{f.stopPropagation(),y(u,"approve")}})]})]},u.context_id))}),i.jsx(Ol,{title:"Manager Findings",count:n.findings.length,empty:"No stale, low-quality, or duplicate context findings.",children:n.findings.map(u=>i.jsxs("article",{onClick:()=>l(u.finding_id),style:Il(o===u.finding_id),children:[i.jsxs("div",{style:$l,children:[i.jsxs("div",{children:[i.jsx("div",{style:Dl,children:u.title}),i.jsxs("div",{style:Ml,children:[u.team_id," · ",u.finding_type]})]}),i.jsx(mo,{color:Lu(u.severity),children:u.severity})]}),i.jsx("p",{style:$u,children:u.detail}),i.jsx("div",{className:"inbox-actions",style:{display:"flex",justifyContent:"flex-end",flexWrap:"wrap"},children:i.jsx(Ir,{label:"Resolve",color:"var(--green)",busy:s===`finding:${u.finding_id}`,onClick:f=>{f.stopPropagation(),S(u)}})})]},u.finding_id))}),i.jsx(Ol,{title:"Memory Conflicts",count:n.conflicts.length,empty:"No memory contradictions detected.",children:n.conflicts.map(u=>{var j,E;const f=u,p=String(f.id||Math.random());return i.jsxs("article",{onClick:()=>l(p),style:Il(o===p),children:[i.jsxs("div",{style:$l,children:[i.jsxs("div",{children:[i.jsx("div",{style:Dl,children:"Memory conflict"}),i.jsx("div",{style:Ml,children:f.reason||"Contradiction"})]}),i.jsx(mo,{color:Lu(f.severity),children:f.severity||"open"})]}),i.jsxs("div",{style:{display:"grid",gap:6,marginTop:10},children:[i.jsx(Ou,{label:"A",text:(j=f.belief_a)==null?void 0:j.content}),i.jsx(Ou,{label:"B",text:(E=f.belief_b)==null?void 0:E.content})]}),i.jsx("div",{className:"inbox-actions",style:{display:"flex",gap:8,justifyContent:"flex-end",flexWrap:"wrap",marginTop:10},children:["KEEP A","KEEP B","MERGE"].map(P=>i.jsx(Ir,{label:P,busy:s===`conflict:${p}:${P}`,onClick:z=>{z.stopPropagation(),w(u,P)}},P))})]},p)})})]})]})}function Ll({label:e,value:t}){return i.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[i.jsx("span",{style:{color:"var(--ink3)"},children:e}),i.jsx("span",{style:{color:t?"var(--accent)":"var(--ink2)"},children:t})]})}function Ol({title:e,count:t,empty:n,children:r}){return i.jsxs("section",{style:{display:"grid",gap:10},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.08em",color:"var(--ink3)",textTransform:"uppercase"},children:[i.jsx("span",{children:e}),i.jsx(mo,{children:t})]}),t===0?i.jsx("div",{style:{border:"1px dashed var(--border)",background:"white",color:"var(--ink3)",padding:16,fontSize:12},children:n}):r]})}function mo({children:e,color:t="var(--ink3)"}){return i.jsx("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 7px",border:`1px solid ${t}`,color:t,background:"white",borderRadius:3,fontFamily:"var(--mono)",fontSize:9},children:e})}function Ir({label:e,onClick:t,color:n="var(--ink2)",busy:r}){return i.jsx("button",{onClick:t,disabled:r,style:{padding:"6px 9px",border:`1px solid ${n}`,color:n,background:"white",fontFamily:"var(--mono)",fontSize:9,borderRadius:3,cursor:r?"wait":"pointer"},children:r?"...":e})}function Ou({label:e,text:t}){return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"var(--surface)",padding:10,display:"grid",gridTemplateColumns:"20px minmax(0, 1fr)",gap:8},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",color:"var(--ink3)"},children:e}),i.jsx("span",{style:{color:"var(--ink2)",fontSize:12,lineHeight:1.5},children:t||"No content"})]})}const $l={display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:12},Dl={fontSize:15,fontWeight:650,color:"var(--ink)"},Ml={fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginTop:3},$u={margin:"10px 0",color:"var(--ink2)",fontSize:12,lineHeight:1.55};function Il(e){return{border:`1px solid ${e?"var(--accent)":"var(--border)"}`,background:"white",padding:14,boxShadow:e?"0 10px 24px rgba(20,16,10,0.06)":"none",cursor:"pointer"}}const Cg={"&":"&","<":"<",">":">",'"':""","'":"'"};function ii(e){return e.replace(/[&<>"']/g,t=>Cg[t]||t)}function Eg(e){const t=e.trim();return/^(https?:|mailto:|#|\/)/i.test(t)?t:"#"}function En(e,t){let n=ii(e);return n=n.replace(/`([^`]+)`/g,(r,o)=>`${o}`),n=n.replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(r,o,l)=>{const s=(l||o).trim(),a=t?t(o.trim()):null;return a?`${s}`:`${s}`}),n=n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,o,l)=>`${o}`),n=n.replace(/\*\*([^*]+)\*\*/g,"$1"),n=n.replace(/(^|[^*])\*([^*]+)\*/g,"$1$2"),n}function Tg({source:e,wikiResolve:t}){const n=(e||"").replace(/\r\n/g,` +`).split(` +`),r=[];let o=0;for(;o${ii(d.join(` +`))}`);continue}if(/^### /.test(l)){r.push(`

${En(l.slice(4),t)}

`),o+=1;continue}if(/^## /.test(l)){r.push(`

${En(l.slice(3),t)}

`),o+=1;continue}if(/^# /.test(l)){r.push(`

${En(l.slice(2),t)}

`),o+=1;continue}if(/^>\s?/.test(l)){const a=[];for(;o\s?/.test(n[o]);)a.push(n[o].replace(/^>\s?/,"")),o+=1;r.push(`
${En(a.join(" "),t)}
`);continue}if(/^\s*[-*]\s/.test(l)){const a=[];for(;o${En(n[o].replace(/^\s*[-*]\s/,""),t)}`),o+=1;r.push(`
    ${a.join("")}
`);continue}if(/^\s*\d+\.\s/.test(l)){const a=[];for(;o${En(n[o].replace(/^\s*\d+\.\s/,""),t)}`),o+=1;r.push(`
    ${a.join("")}
`);continue}if(l.trim()===""){o+=1;continue}const s=[l];for(o+=1;o\s?)/.test(n[o]);)s.push(n[o]),o+=1;r.push(`

${En(s.join(` +`),t)}

`)}return i.jsx("div",{className:"md-root",style:{fontFamily:"var(--font)",fontSize:13.5,lineHeight:1.55,color:"var(--ink)"},dangerouslySetInnerHTML:{__html:r.join("")}})}const qi={title:"",content:"",scope:"team",kind:"note",project_id:"",team_id:"",tags:""},zg=["user","company","global_team","project","team","agent"],Du={items:[],next_cursor:null,active_only:!1,totals:{tokens_saved:0,estimated_cost_saved_usd:0,router_calls:0,sessions:0}},Mu={live:!1,items:[],totals:{contexts:0,used_contexts:0,usage_count:0,tokens_served:0,proven_tokens_saved:0,theoretical_api_value_usd:0,realized_cost_saved_usd:0}};function Ng(e){return{...e,tags:Array.isArray(e.tags)?e.tags:[]}}function Iu(e){return(e==null?void 0:e.role)==="manager"||(e==null?void 0:e.role)==="admin"?e.team_id?{...qi,scope:"team",team_id:e.team_id,project_id:e.project_id||""}:e.project_id?{...qi,scope:"project",project_id:e.project_id}:{...qi,scope:"company"}:{...qi,scope:"user",user_id:e==null?void 0:e.user_id}}function Rg(e){return{title:e.title||"Untitled context",content:e.content||e.summary||"",scope:e.scope||"team",kind:e.kind||"note",project_id:e.project_id||"",team_id:e.team_id||"",tags:(e.tags||[]).join(", ")}}function Pg(e){return{title:Ra(e),content:e.content||"",scope:"memory",kind:e.tier,project_id:"",team_id:"",tags:(e.tags||[]).join(", ")}}function Bu(e,t,n){return(e==null?void 0:e.role)==="admin"||(e==null?void 0:e.role)==="manager"?!0:((t==null?void 0:t.scope)||(n==null?void 0:n.scope))==="user"?!(t!=null&&t.user_id)||t.user_id===(e==null?void 0:e.user_id):!1}function Au(e){return e==="pending_review"?"var(--accent)":e==="rejected"||e==="inactive"?"var(--rose)":"var(--green)"}function Bl(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function Fg(e){return e.team_id?e.team_id:e.project_id?e.project_id:e.user_id?"mine":e.scope}function Lg(e){return e==="user"?"Mine":e==="company"?"Company":e==="global_team"?"Global Teams":e==="project"?"Projects":e==="team"?"Teams":e==="agent"?"Agents":e}function Uu(e){return e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())}function Ra(e){var n;return(e.content||"").split(/\r?\n/).map(r=>r.trim()).find(Boolean)||""||((n=e.tags)==null?void 0:n[0])||`${e.tier} memory`}function Og(e){var l;const t=Ra(e),n=t.match(/^([^>]{3,72})\s*>\s*.+$/);if(n!=null&&n[1])return n[1].trim();const r=[t,e.source,...e.tags||[]].join(" ").toLowerCase();if(r.includes("repository guideline")||r.includes("agents.md"))return"Repository Guidelines";if(r.startsWith("edited ")||r.includes("/users/")||r.includes("/tmp/"))return"File Edits";if(r.includes("session")||r.includes("continuity"))return"Session Continuity";const o=(l=e.tags)==null?void 0:l.find(s=>s&&s!==e.tier);return o?Uu(o):`${Uu(e.tier)} Memory`}function $g(e){const t=Ra(e),n=t.split(/\s*>\s*/);return(n.length>1?n.slice(1).join(" > "):t).slice(0,72)||"Memory"}function sn(e){return!e||e<=0?"0":new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e)}function In(e){const t=Math.max(0,Number(e||0));return t>0&&t<.01?"<$0.01":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:t>=10?0:2}).format(t)}function Dg(e){const t=e.pricing;if(!t)return"PAYG input-token estimate";const n=t.input_cost_per_million,r=t.model_family||e.model||"model",o=t.provider||e.runtime||e.agent||"provider",l=typeof n=="number"?`$${n}/1M input tokens`:"input-token rate";return`${o} · ${r} · ${l}`}function Mg(e,t){const n=(t==null?void 0:t.usage_count)??e.usage_count??0,r=(t==null?void 0:t.proven_tokens_saved)??0,o=[`${e.kind} · ${Fg(e)}`,`${n} use${n===1?"":"s"}`];return o.push(r>0?`${sn(r)} proven saved`:"no proven $"),o.join(" · ")}function Ig(e){const t=String(e.runtime||e.agent||"").toLowerCase();return t==="codex"?"var(--indigo)":t==="claude-code"||t==="claude"?"var(--accent)":"var(--green)"}function Bg(e){const t=(e.title||"").trim();return t||(e.cwd||e.repo_root||"").split("/").filter(Boolean).pop()||e.session_id||"Session"}function Ag({onMemoryCountChange:e,viewer:t,orgGraph:n,onInboxChanged:r}){var Cn,Ut,Z,de,ke,le,Te,Ot,qn;const[o,l]=v.useState([]),[s,a]=v.useState([]),[d,c]=v.useState(null),[g,h]=v.useState(()=>Iu(t||null)),[y,S]=v.useState(!1),[w,T]=v.useState(""),[V,m]=v.useState(null),[u,f]=v.useState(null),[p,j]=v.useState(!0),[E,P]=v.useState(null),[z,Y]=v.useState(Du),[N,J]=v.useState(Mu),[X,Q]=v.useState({}),[G,I]=v.useState(""),U=v.useRef({}),se=async()=>{var b,C,k;try{const[O,B,ne,ye]=await Promise.all([A.listMemories().catch(Ve=>({live:!1,engrams:[],count:0,error:String(Ve)})),A.contextItems({limit:500}).catch(Ve=>({live:!1,items:[],error:String(Ve)})),A.routerSessions({active:!1,limit:50}).catch(()=>Du),A.contextUsage({limit:500}).catch(()=>Mu)]),Ye=(b=B.items)!=null&&b.length||!((C=n==null?void 0:n.raw)!=null&&C.context_index)?B.items||[]:n.raw.context_index,at=new Map((ye.items||[]).map(Ve=>[Ve.context_id,Ve]));l(Ye.map(Ng).map(Ve=>{const Zn=at.get(Ve.context_id);return Zn?{...Ve,usage_count:Zn.usage_count,last_used_at:Zn.last_used_at,token_cost:Zn.token_cost}:Ve})),a(O.engrams||[]),Y(ne),J(ye),j(!!(O.live||B.live||n!=null&&n.live)),f(B.error||O.error||null),e==null||e(((k=O.engrams)==null?void 0:k.length)||0)}catch(O){f(O instanceof Error?O.message:String(O)),j(!1)}};v.useEffect(()=>{se();const b=window.setInterval(()=>void se(),6e3);return()=>window.clearInterval(b)},[]),v.useEffect(()=>{if(d)return;const b=decodeURIComponent(window.location.hash||""),C=b.startsWith("#vault/")?b.replace("#vault/","").trim():"",k=C?o.find(O=>O.team_id===C):null;if(k){c({kind:"context",id:k.context_id});return}if(o[0]){c({kind:"context",id:o[0].context_id});return}s[0]&&c({kind:"memory",id:s[0].id})},[o,s,d]);const _=(d==null?void 0:d.kind)==="context"&&o.find(b=>b.context_id===d.id)||null,W=(d==null?void 0:d.kind)==="memory"&&s.find(b=>b.id===d.id)||null;v.useEffect(()=>{if(_){h(Rg(_)),S(!1);return}if(W){h(Pg(W)),S(!1);return}(d==null?void 0:d.kind)==="new"&&(h(Iu(t||null)),S(!0))},[_,W,d==null?void 0:d.kind,t]),v.useEffect(()=>{if(!_){P(null);return}let b=!0;return A.backlinks(_.context_id).then(C=>{b&&P(C)}).catch(()=>{b&&P(null)}),()=>{b=!1}},[_==null?void 0:_.context_id]);const K=v.useMemo(()=>{const b=w.trim().toLowerCase();return b?o.filter(C=>[C.title,C.summary,C.content,C.kind,C.scope,C.team_id,C.project_id,...C.tags||[]].filter(Boolean).join(" ").toLowerCase().includes(b)):o},[o,w]),ee=v.useMemo(()=>{const b=new Map;for(const C of zg)b.set(C,[]);for(const C of K){const k=C.scope||"team";b.set(k,[...b.get(k)||[],C])}return b},[K]),ie=v.useMemo(()=>{const b=w.trim().toLowerCase();return b?s.filter(C=>[C.content,C.source,C.tier,...C.tags||[]].filter(Boolean).join(" ").toLowerCase().includes(b)):s},[s,w]),M=v.useMemo(()=>{const b=new Map;for(const C of ie){const k=Og(C);b.set(k,[...b.get(k)||[],C])}return new Map([...b.entries()].sort(([C],[k])=>C.localeCompare(k)))},[ie]),pe=v.useMemo(()=>{const b=[];for(const[C,k]of ee.entries())k.length!==0&&b.push({id:`context:${C}`,kind:"context",label:Lg(C),count:k.length,rows:k});for(const[C,k]of M.entries())k.length!==0&&b.push({id:`memory:${C}`,kind:"memory",label:C,count:k.length,rows:k});return b},[ee,M]),ae=v.useMemo(()=>{const b=[];for(const C of pe)if(b.push({id:`section:${C.id}`,type:"section",sectionId:C.id}),!!X[C.id])if(C.kind==="context")for(const k of C.rows)b.push({id:`context-item:${k.context_id}`,type:"context",sectionId:C.id,item:k});else for(const k of C.rows)b.push({id:`memory-item:${k.id}`,type:"memory",sectionId:C.id,memory:k});return b},[X,pe]);v.useEffect(()=>{w.trim()&&Q({})},[w]),v.useEffect(()=>{if(!ae.length){G&&I("");return}(!G||!ae.some(b=>b.id===G))&&I(ae[0].id)},[G,ae]),v.useEffect(()=>{var b;G&&((b=U.current[G])==null||b.focus())},[G]);const me=(b,C)=>{Q(k=>({...k,[b]:typeof C=="boolean"?C:!k[b]}))},$=b=>{c({kind:"context",id:b.context_id}),window.location.hash=`#vault/item/${b.context_id}`},ue=b=>{c({kind:"memory",id:b.id})},fe=b=>{I(b)},ge=(b,C)=>{const k=ae.findIndex(B=>B.id===b);if(k<0)return;const O=ae[Math.max(0,Math.min(ae.length-1,k+C))];O&&fe(O.id)},Ee=(b,C)=>{if(b.key==="ArrowDown"){b.preventDefault(),ge(C.id,1);return}if(b.key==="ArrowUp"){b.preventDefault(),ge(C.id,-1);return}if(b.key==="Home"){b.preventDefault(),ae[0]&&fe(ae[0].id);return}if(b.key==="End"){b.preventDefault();const k=ae[ae.length-1];k&&fe(k.id);return}if(b.key==="ArrowRight"&&C.type==="section"){if(b.preventDefault(),!X[C.sectionId])me(C.sectionId,!0);else{const k=ae.find(O=>O.sectionId===C.sectionId&&O.type!=="section");k&&fe(k.id)}return}if(b.key==="ArrowLeft"){b.preventDefault(),C.type==="section"?X[C.sectionId]&&me(C.sectionId,!1):fe(`section:${C.sectionId}`);return}(b.key==="Enter"||b.key===" ")&&C.type==="section"&&(b.preventDefault(),me(C.sectionId))},R=b=>{const C=o.find(k=>k.title.toLowerCase()===b.toLowerCase());return C?`#vault/item/${C.context_id}`:null},oe=()=>{c({kind:"new",id:"new"})},q=async()=>{if(!g.title.trim()||!g.content.trim()){f("Title and content are required.");return}m("save"),f(null);const b={title:g.title.trim(),content:g.content,scope:g.scope,kind:g.kind||"note",project_id:g.project_id||(t==null?void 0:t.project_id)||void 0,team_id:g.team_id||(t==null?void 0:t.team_id)||void 0,tags:Bl(g.tags),metadata:{source:"sankhya-vault"}};try{if(Bu(t||null,_,g)){const C=await A.upsertContext({...b,context_id:_==null?void 0:_.context_id,user_id:g.scope==="user"?t==null?void 0:t.user_id:void 0});c({kind:"context",id:C.item.context_id})}else{const C=await A.proposeContext({...b,proposed_by_user_id:(t==null?void 0:t.user_id)||"developer",supersedes_id:_==null?void 0:_.context_id});c({kind:"context",id:C.proposal.context_id}),await(r==null?void 0:r())}await se(),S(!1)}catch(C){f(C instanceof Error?C.message:String(C))}finally{m(null)}},te=async b=>{if(_){m(b);try{b==="approve"?await A.approveProposal(_.context_id,(t==null?void 0:t.user_id)||"manager"):await A.rejectProposal(_.context_id,(t==null?void 0:t.user_id)||"manager"),await se(),await(r==null?void 0:r())}catch(C){f(C instanceof Error?C.message:String(C))}finally{m(null)}}},Ae=(d==null?void 0:d.kind)==="memory",Lt=Bu(t||null,_,g),xe=v.useMemo(()=>[...z.items||[]].sort((C,k)=>{const O=(k.tokens_saved||0)-(C.tokens_saved||0);return O!==0?O:String(k.updated_at||"").localeCompare(String(C.updated_at||""))}).filter(C=>C.tokens_saved>0).slice(0,4),[z.items]),Ue=v.useMemo(()=>new Map((N.items||[]).map(b=>[b.context_id,b])),[N.items]),we=_&&Ue.get(_.context_id)||null,Oe=v.useMemo(()=>[...N.items||[]].filter(b=>(b.usage_count||0)>0).sort((b,C)=>{const k=(C.usage_count||0)-(b.usage_count||0);return k!==0?k:(C.proven_tokens_saved||0)-(b.proven_tokens_saved||0)}).slice(0,5),[N.items]);return i.jsxs("div",{className:"vault-shell",children:[i.jsxs("aside",{className:"vault-nav",children:[i.jsxs("div",{className:"vault-nav-head",children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:10},children:[i.jsxs("div",{children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",letterSpacing:"0.08em",textTransform:"uppercase"},children:"Context"}),i.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--ink)"},children:"Manager"})]}),i.jsx("button",{onClick:oe,style:{padding:"5px 8px",border:"1px solid var(--accent)",background:"var(--accent-dim)",color:"var(--accent)",fontFamily:"var(--mono)",fontSize:10,borderRadius:3},children:"NEW"})]}),i.jsx("input",{value:w,onChange:b=>T(b.target.value),placeholder:"search context or memory",style:{width:"100%",boxSizing:"border-box",border:"1px solid var(--border)",background:"var(--surface)",color:"var(--ink)",padding:"8px 9px",fontSize:12}}),i.jsxs("div",{style:{marginTop:8},children:[i.jsx(Hg,{rows:Oe,totals:N.totals,onSelect:b=>{c({kind:"context",id:b}),window.location.hash=`#vault/item/${b}`}}),i.jsx(Vg,{rows:xe,totalTokens:((Cn=z.totals)==null?void 0:Cn.tokens_saved)||0,totalCost:((Ut=z.totals)==null?void 0:Ut.realized_cost_saved_usd)??((Z=z.totals)==null?void 0:Z.estimated_cost_saved_usd)??0,apiValue:((de=z.totals)==null?void 0:de.theoretical_api_value_usd)??((ke=z.totals)==null?void 0:ke.estimated_cost_saved_usd)??0,totalSessions:((le=z.totals)==null?void 0:le.sessions)||0,budget:z.budget})]})]}),i.jsx("div",{className:"vault-tree",role:"tree","aria-label":"Context categories",children:pe.map(b=>{const C={id:`section:${b.id}`,type:"section",sectionId:b.id},k=!!X[b.id],O=b.kind==="context"?b.rows.some(B=>(d==null?void 0:d.kind)==="context"&&d.id===B.context_id):b.rows.some(B=>(d==null?void 0:d.kind)==="memory"&&d.id===B.id);return i.jsx(Wg,{label:b.label,count:b.count,open:k,active:O,focused:G===C.id,buttonRef:B=>{U.current[C.id]=B},onFocus:()=>I(C.id),onToggle:()=>me(b.id),onKeyDown:B=>Ee(B,C),children:b.kind==="context"?b.rows.map(B=>{const ne={id:`context-item:${B.context_id}`,type:"context",sectionId:b.id};return i.jsx(Wu,{treeId:ne.id,buttonRef:ye=>{U.current[ne.id]=ye},focused:G===ne.id,active:(d==null?void 0:d.kind)==="context"&&d.id===B.context_id,dot:Au(B.proposal_status||B.status),title:B.title,meta:Mg(B,Ue.get(B.context_id)),onFocus:()=>I(ne.id),onKeyDown:ye=>Ee(ye,ne),onClick:()=>$(B)},B.context_id)}):b.rows.map(B=>{const ne={id:`memory-item:${B.id}`,type:"memory",sectionId:b.id};return i.jsx(Wu,{treeId:ne.id,buttonRef:ye=>{U.current[ne.id]=ye},focused:G===ne.id,active:(d==null?void 0:d.kind)==="memory"&&d.id===B.id,dot:"var(--indigo)",title:$g(B),meta:`${B.tier} · ${B.tokens||0} tok`,onFocus:()=>I(ne.id),onKeyDown:ye=>Ee(ye,ne),onClick:()=>ue(B)},B.id)})},b.id)})})]}),i.jsxs("main",{className:"vault-main",children:[i.jsxs("section",{className:"vault-editor",children:[i.jsxs("header",{className:"vault-editor-header",children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.08em",color:"var(--ink3)",textTransform:"uppercase"},children:[W?"Legacy memory":g.scope||"context",p?"":" · offline"]}),i.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title||"New context item"})]}),i.jsxs("div",{className:"vault-editor-actions",children:[(_==null?void 0:_.proposal_status)==="pending_review"&&((t==null?void 0:t.role)==="manager"||(t==null?void 0:t.role)==="admin")?i.jsxs(i.Fragment,{children:[i.jsx(Zi,{label:"APPROVE",tone:"green",busy:V==="approve",onClick:()=>void te("approve")}),i.jsx(Zi,{label:"REJECT",tone:"rose",busy:V==="reject",onClick:()=>void te("reject")})]}):null,Ae?null:i.jsxs(i.Fragment,{children:[i.jsx(Zi,{label:y?"PREVIEW":"EDIT",onClick:()=>S(b=>!b)}),i.jsx(Zi,{label:Lt?"SAVE":"REQUEST",tone:Lt?"accent":"indigo",busy:V==="save",onClick:()=>void q()})]})]})]}),i.jsxs("div",{className:`vault-body${y&&!Ae?" vault-body--editing":""}`,children:[y&&!Ae?i.jsxs("div",{style:{display:"grid",gap:10,alignContent:"start"},children:[i.jsx("input",{value:g.title,onChange:b=>h(C=>({...C,title:b.target.value})),placeholder:"Context title",style:Tn}),i.jsxs("div",{className:"vault-form-grid",children:[i.jsxs("select",{value:g.scope,onChange:b=>h(C=>({...C,scope:b.target.value})),style:Tn,children:[i.jsx("option",{value:"company",children:"company"}),i.jsx("option",{value:"project",children:"project"}),i.jsx("option",{value:"global_team",children:"global_team"}),i.jsx("option",{value:"team",children:"team"}),i.jsx("option",{value:"user",children:"user"}),i.jsx("option",{value:"agent",children:"agent"})]}),i.jsx("input",{value:g.kind,onChange:b=>h(C=>({...C,kind:b.target.value})),placeholder:"kind: runbook / policy / decision",style:Tn})]}),i.jsxs("div",{className:"vault-form-grid",children:[i.jsx("input",{value:g.project_id,onChange:b=>h(C=>({...C,project_id:b.target.value})),placeholder:"project id",style:Tn}),i.jsx("input",{value:g.team_id,onChange:b=>h(C=>({...C,team_id:b.target.value})),placeholder:"team id",style:Tn})]}),i.jsx("input",{value:g.tags,onChange:b=>h(C=>({...C,tags:b.target.value})),placeholder:"tags, comma separated",style:Tn}),i.jsx("textarea",{value:g.content,onChange:b=>h(C=>({...C,content:b.target.value})),rows:20,placeholder:"Write markdown context here...",style:{...Tn,minHeight:420,resize:"vertical",lineHeight:1.55,fontFamily:"var(--mono)"}})]}):null,i.jsx("article",{className:"vault-preview",children:i.jsx(Tg,{source:g.content||"_No context selected._",wikiResolve:R})})]})]}),i.jsxs("aside",{className:"vault-meta",children:[i.jsxs(zn,{label:"Scope",children:[i.jsx(Br,{children:g.scope}),g.kind?i.jsx(Br,{children:g.kind}):null,_!=null&&_.proposal_status?i.jsx(Br,{color:Au(_.proposal_status),children:_.proposal_status}):null]}),i.jsxs(zn,{label:"Ownership",children:[i.jsx(tt,{k:"org",v:t==null?void 0:t.org_id}),i.jsx(tt,{k:"project",v:g.project_id||(t==null?void 0:t.project_id)}),i.jsx(tt,{k:"team",v:g.team_id||(t==null?void 0:t.team_id)}),i.jsx(tt,{k:"viewer",v:t==null?void 0:t.user_id}),i.jsx(tt,{k:"role",v:(t==null?void 0:t.role)||"developer"})]}),i.jsxs(zn,{label:"Health",children:[i.jsx(tt,{k:"quality",v:_==null?void 0:_.quality_score}),i.jsx(tt,{k:"freshness",v:_==null?void 0:_.freshness_score}),i.jsx(tt,{k:"confidence",v:_==null?void 0:_.confidence}),i.jsx(tt,{k:"token cost",v:_==null?void 0:_.token_cost}),i.jsx(tt,{k:"updated",v:(_==null?void 0:_.updated_at)||(W==null?void 0:W.created)})]}),_?i.jsxs(zn,{label:"Usage",children:[i.jsx(tt,{k:"uses",v:(we==null?void 0:we.usage_count)??_.usage_count??0}),i.jsx(tt,{k:"last used",v:(we==null?void 0:we.last_used_at)??_.last_used_at}),i.jsx(tt,{k:"tokens served",v:(we==null?void 0:we.tokens_served)??0}),i.jsx(tt,{k:"proven saved",v:(we==null?void 0:we.proven_tokens_saved)??0}),i.jsx(tt,{k:"proven $",v:In(we==null?void 0:we.realized_cost_saved_usd)}),i.jsx(tt,{k:"evidence",v:(Te=we==null?void 0:we.evidence)!=null&&Te.has_direct_savings_evidence?"direct attribution":"usage only"})]}):null,i.jsx(zn,{label:"Tags",children:Bl(g.tags).length?Bl(g.tags).map(b=>i.jsx(Br,{children:b},b)):i.jsx("span",{style:{color:"var(--ink3)",fontSize:12},children:"none"})}),i.jsx(zn,{label:"Backlinks",children:(Ot=E==null?void 0:E.backlinks)!=null&&Ot.length?E.backlinks.map(b=>i.jsx("button",{onClick:()=>c({kind:"context",id:b.src}),style:Ug,children:b.src_title||b.src},`${b.src}:${b.edge_type}`)):i.jsx("span",{style:{color:"var(--ink3)",fontSize:12},children:"none"})}),i.jsx(zn,{label:"Shares",children:(qn=E==null?void 0:E.shares)!=null&&qn.length?E.shares.map((b,C)=>i.jsx(Br,{children:String(b.scope||b.team_id||"share")},C)):i.jsx("span",{style:{color:"var(--ink3)",fontSize:12},children:"private"})}),u?i.jsx("div",{style:{border:"1px solid var(--rose)",color:"var(--rose)",background:"var(--rose-dim)",padding:10,fontFamily:"var(--mono)",fontSize:10,lineHeight:1.5},children:u}):null]})]})]})}const Tn={width:"100%",boxSizing:"border-box",border:"1px solid var(--border)",background:"white",color:"var(--ink)",padding:"8px 9px",fontSize:12},Ug={display:"block",width:"100%",textAlign:"left",border:"1px solid var(--border)",background:"var(--surface)",color:"var(--ink2)",padding:"7px 8px",fontSize:12,cursor:"pointer"};function Wg({label:e,count:t,open:n,active:r,focused:o,buttonRef:l,onFocus:s,onToggle:a,onKeyDown:d,children:c}){return i.jsxs("div",{style:{marginBottom:6},children:[i.jsxs("button",{ref:l,type:"button",role:"treeitem","aria-expanded":n,"aria-selected":r,tabIndex:o?0:-1,onFocus:s,onClick:a,onKeyDown:d,style:{width:"100%",border:`1px solid ${r?"var(--accent)":"var(--border)"}`,background:r?"var(--accent-dim)":"var(--surface)",color:"var(--ink)",borderRadius:4,padding:"7px 8px",cursor:"pointer",display:"grid",gridTemplateColumns:"12px minmax(0, 1fr) auto",alignItems:"center",gap:8,textAlign:"left",fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase",outline:o?"2px solid var(--accent-dim)":"none"},children:[i.jsx("span",{style:{color:"var(--ink3)"},children:n?"v":">"}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),i.jsx("span",{style:{color:"var(--ink3)"},children:t})]}),n?i.jsx("div",{role:"group",style:{display:"grid",gap:4,margin:"4px 0 8px 14px"},children:c}):null]})}function Hg({rows:e,totals:t,onSelect:n}){return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",borderRadius:4,padding:8,marginBottom:8},children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:"0.04em",textTransform:"uppercase"},children:"Frequent context"}),i.jsxs("span",{style:{fontSize:13,fontWeight:700,color:"var(--ink)"},children:[sn((t==null?void 0:t.usage_count)||0)," uses"]})]}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginTop:2,lineHeight:1.35},children:[sn((t==null?void 0:t.tokens_served)||0)," served ·"," ",sn((t==null?void 0:t.proven_tokens_saved)||0)," proven saved ·"," ",In(t==null?void 0:t.realized_cost_saved_usd)]}),i.jsx("div",{style:{display:"grid",gap:5,marginTop:8},children:e.length?e.map(r=>i.jsxs("button",{type:"button",onClick:()=>n(r.context_id),style:{border:"0",borderTop:"1px solid var(--border)",background:"transparent",padding:"6px 0 0",textAlign:"left",cursor:"pointer",display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",gap:8},children:[i.jsxs("span",{style:{minWidth:0},children:[i.jsx("span",{style:{display:"block",color:"var(--ink)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:r.title,children:r.title}),i.jsxs("span",{style:{display:"block",fontFamily:"var(--mono)",color:"var(--ink3)",fontSize:9,marginTop:2},children:[r.usage_count," uses · ",sn(r.tokens_served)," served"]})]}),i.jsxs("span",{style:{textAlign:"right",fontFamily:"var(--mono)"},children:[i.jsx("span",{style:{display:"block",color:"var(--green)",fontSize:11},children:sn(r.proven_tokens_saved)}),i.jsx("span",{style:{display:"block",color:"var(--ink3)",fontSize:9},children:In(r.realized_cost_saved_usd)})]})]},r.context_id)):i.jsx("div",{style:{borderTop:"1px solid var(--border)",paddingTop:7,fontSize:11,color:"var(--ink3)",lineHeight:1.4},children:"No context has been injected yet."})}),i.jsx("div",{style:{borderTop:"1px solid var(--border)",marginTop:8,paddingTop:6,color:"var(--ink3)",fontSize:10,lineHeight:1.35},children:"Per-context dollars are shown only when Dhee has direct attribution."})]})}function Vg({rows:e,totalTokens:t,totalCost:n,apiValue:r,totalSessions:o,budget:l}){return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",borderRadius:4,padding:8},children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:"0.04em",textTransform:"uppercase"},children:"Budget-capped savings"}),i.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--green)"},children:In(n)})]}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginTop:2},children:[sn(t)," input tokens avoided across ",o," sessions"]}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:2,lineHeight:1.35},children:["API value ",In(r),l!=null&&l.monthly_budget_usd?`; monthly cap ${In(l.monthly_budget_usd)}`:""]}),i.jsx("div",{style:{display:"grid",gap:5,marginTop:8},children:e.length?e.map(s=>{const a=Ig(s);return i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",gap:8,borderTop:"1px solid var(--border)",paddingTop:6},children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:99,background:a,flexShrink:0}}),i.jsx("span",{style:{fontSize:11,color:"var(--ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Bg(s)})]}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:a,marginTop:2},children:[s.runtime||s.agent||"agent"," · ",s.router_calls," calls"]})]}),i.jsxs("div",{style:{textAlign:"right"},title:Dg(s),children:[i.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--ink)"},children:In(s.estimated_cost_saved_usd)}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[sn(s.tokens_saved)," tok"]})]})]},s.session_id)}):i.jsx("div",{style:{borderTop:"1px solid var(--border)",paddingTop:7,fontSize:11,color:"var(--ink3)",lineHeight:1.4},children:"No session-level savings recorded yet."})})]})}function Wu({treeId:e,buttonRef:t,focused:n,active:r,dot:o,title:l,meta:s,onFocus:a,onKeyDown:d,onClick:c}){return i.jsxs("button",{ref:t,type:"button","data-tree-id":e,role:"treeitem","aria-selected":r,tabIndex:n?0:-1,onFocus:a,onKeyDown:d,onClick:c,style:{textAlign:"left",border:`1px solid ${r?"var(--accent)":"transparent"}`,background:r?"var(--accent-dim)":"transparent",color:"var(--ink)",padding:"7px 8px",borderRadius:4,cursor:"pointer",display:"grid",gridTemplateColumns:"8px minmax(0, 1fr)",gap:8,alignItems:"start",outline:n?"2px solid var(--accent-dim)":"none"},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:99,background:o,marginTop:5}}),i.jsxs("span",{style:{minWidth:0},children:[i.jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12},children:l}),i.jsx("span",{style:{display:"block",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:2},children:s})]})]})}function Zi({label:e,onClick:t,tone:n="default",busy:r}){const o=n==="accent"?"var(--accent)":n==="indigo"?"var(--indigo)":n==="green"?"var(--green)":n==="rose"?"var(--rose)":"var(--ink2)";return i.jsx("button",{onClick:t,disabled:r,style:{padding:"7px 10px",border:`1px solid ${o}`,background:n==="default"?"white":"var(--surface)",color:o,fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.06em",borderRadius:3,cursor:r?"wait":"pointer"},children:r?"...":e})}function zn({label:e,children:t}){return i.jsxs("section",{style:{display:"grid",gap:8},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.08em",color:"var(--ink3)",textTransform:"uppercase"},children:e}),i.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:t})]})}function Br({children:e,color:t="var(--ink2)"}){return i.jsx("span",{style:{display:"inline-flex",border:"1px solid var(--border)",background:"var(--surface)",color:t,padding:"3px 7px",borderRadius:3,fontFamily:"var(--mono)",fontSize:10},children:e})}function tt({k:e,v:t}){return t==null||t===""?null:i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"76px minmax(0, 1fr)",gap:6,width:"100%",fontSize:12},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:e}),i.jsx("span",{style:{color:"var(--ink2)",wordBreak:"break-word"},children:String(t)})]})}function Kg({projectIndex:e,memories:t,tokensSaved:n,onAddMemory:r,onSelectSession:o,onCreateWorkspace:l,onLaunchSession:s,onOpenWorkspace:a,onOpenTasks:d}){var ie;const[c,g]=v.useState(""),[h,y]=v.useState("task"),[S,w]=v.useState("codex"),[T,V]=v.useState("standard"),[m,u]=v.useState(""),[f,p]=v.useState(""),[j,E]=v.useState(!1),[P,z]=v.useState(""),[Y,N]=v.useState(!1),[J,X]=v.useState(null),Q=v.useRef(null);v.useEffect(()=>{var M;(M=Q.current)==null||M.focus()},[]);const G=(e==null?void 0:e.workspaces)||[],I=v.useMemo(()=>G.find(M=>M.id===(m||(e==null?void 0:e.currentWorkspaceId)))||G[0]||null,[e==null?void 0:e.currentWorkspaceId,m,G]),U=v.useMemo(()=>{var M,pe;return((M=I==null?void 0:I.projects)==null?void 0:M.find(ae=>ae.id===(f||(e==null?void 0:e.currentProjectId))))||((pe=I==null?void 0:I.projects)==null?void 0:pe[0])||null},[I,e==null?void 0:e.currentProjectId,f]),se=v.useMemo(()=>{var M,pe,ae,me;return((M=U==null?void 0:U.sessions)==null?void 0:M.find($=>$.id===(e==null?void 0:e.currentSessionId)))||((pe=U==null?void 0:U.sessions)==null?void 0:pe[0])||((ae=I==null?void 0:I.sessions)==null?void 0:ae.find($=>$.id===(e==null?void 0:e.currentSessionId)))||((me=I==null?void 0:I.sessions)==null?void 0:me[0])||null},[U,I,e==null?void 0:e.currentSessionId]);v.useEffect(()=>{!m&&(e!=null&&e.currentWorkspaceId)&&u(e.currentWorkspaceId)},[e==null?void 0:e.currentWorkspaceId,m]),v.useEffect(()=>{!f&&(e!=null&&e.currentProjectId)&&p(e.currentProjectId)},[e==null?void 0:e.currentProjectId,f]),v.useEffect(()=>{I&&U&&!I.projects.some(M=>M.id===f)&&p(U.id)},[I,U,f]);const _=c.split(` +`).map(M=>M.trim()).filter(Boolean),W=async()=>{if(!(!_.length||Y)){N(!0),X(null);try{if(h==="memory")for(const M of _)await r(M);else for(const M of _)await s(M,S,I==null?void 0:I.id,S==="claude-code"?T:void 0,U==null?void 0:U.id);g("")}catch(M){X(String(M))}finally{N(!1)}}},K=async()=>{if(!(!P.trim()||Y)){N(!0),X(null);try{await l(P.trim()),z(""),E(!1)}catch(M){X(String(M))}finally{N(!1)}}},ee=M=>({padding:"6px 10px",border:"1px solid var(--border)",background:M?"var(--ink)":"white",color:M?"white":"var(--ink2)",fontFamily:"var(--mono)",fontSize:9});return i.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{height:48,borderBottom:"1px solid var(--border)",padding:"0 24px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[i.jsx("div",{style:{display:"flex",gap:10,alignItems:"center",minWidth:0},children:i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[(I==null?void 0:I.label)||(I==null?void 0:I.name)||"workspace",U?` / ${U.name}`:""]})}),i.jsxs("div",{style:{display:"flex",gap:18,alignItems:"center",fontFamily:"var(--mono)",fontSize:10},children:[i.jsx("button",{onClick:d,style:{color:"var(--ink3)"},children:"tasks"}),i.jsxs("span",{style:{color:"var(--ink3)"},children:[t," engrams"]})]})]}),i.jsxs("div",{style:{flex:1,overflow:"auto",padding:28,display:"grid",gridTemplateColumns:"minmax(0, 1fr) 280px",gap:24},children:[i.jsxs("div",{style:{border:"1px solid var(--border)",background:"transparent",padding:24,display:"flex",flexDirection:"column",minHeight:0},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("button",{onClick:()=>y("task"),style:ee(h==="task"),children:"create task"}),i.jsx("button",{onClick:()=>y("memory"),style:ee(h==="memory"),children:"save memory"}),h==="task"&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>w("codex"),style:ee(S==="codex"),children:"codex"}),i.jsx("button",{onClick:()=>w("claude-code"),style:ee(S==="claude-code"),children:"claude-code"}),S==="claude-code"&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>V("standard"),style:ee(T==="standard"),children:"standard"}),i.jsx("button",{onClick:()=>V("full-access"),style:ee(T==="full-access"),children:"full access"})]})]})]}),i.jsx("button",{onClick:a,style:{padding:"7px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"open workspace"})]}),h==="task"&&i.jsxs("div",{style:{display:"grid",gap:10,marginBottom:14},children:[i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"workspace"}),i.jsx("select",{value:(I==null?void 0:I.id)||"",onChange:M=>u(M.target.value),style:{border:"1px solid var(--border)",padding:"7px 10px",background:"white",minWidth:220},children:G.map(M=>i.jsx("option",{value:M.id,children:M.label||M.name},M.id))})]}),(ie=I==null?void 0:I.projects)!=null&&ie.length?i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"project"}),I.projects.map(M=>i.jsx("button",{onClick:()=>p(M.id),style:{...ee(M.id===(U==null?void 0:U.id)),background:M.id===(U==null?void 0:U.id)?"var(--accent)":"white"},children:M.name},M.id))]}):null]}),i.jsx("textarea",{ref:Q,value:c,onChange:M=>g(M.target.value),onKeyDown:M=>{(M.metaKey||M.ctrlKey)&&M.key==="Enter"&&(M.preventDefault(),W())},placeholder:h==="task"?`- broadcast backend contract changes +- compare project scope rules +- create follow-up task for frontend stream`:`- backend project now emits model version updates +- paper asset is chunked and queryable +- avoid reprocessing shared results`,style:{width:"100%",flex:1,border:"1px solid var(--border)",padding:"18px 20px",fontSize:22,lineHeight:1.55,background:"white",resize:"none",minHeight:420}}),i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:14},children:[i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[_.length," point",_.length===1?"":"s"]}),i.jsx("button",{onClick:()=>void W(),style:{padding:"10px 16px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10},children:Y?"saving…":h==="task"?"create task":"save memory"})]}),J&&i.jsx("div",{style:{marginTop:12,fontSize:11,color:"var(--rose)"},children:J})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[i.jsxs("div",{onClick:a,style:{border:"1px solid var(--border)",background:"white",padding:16,cursor:"pointer"},children:[i.jsx("div",{style:{marginBottom:8,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"CURRENT WORKSPACE"}),i.jsx("div",{style:{fontSize:16,fontWeight:600},children:(I==null?void 0:I.label)||(I==null?void 0:I.name)||"No workspace"}),i.jsx("div",{style:{marginTop:6,fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:(I==null?void 0:I.workspacePath)||"Select or create a workspace"}),U&&i.jsxs("div",{style:{marginTop:10,fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[U.name," · default ",U.defaultRuntime||"codex"]}),se&&i.jsx("button",{onClick:M=>{M.stopPropagation(),o(se.id,se.taskId||null)},style:{marginTop:12,padding:"7px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"open current session"})]}),i.jsx("button",{onClick:()=>E(!0),style:{padding:"12px 14px",border:"1px solid var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:10,textAlign:"left"},children:"+ add workspace"})]})]}),j&&i.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.18)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:40},onClick:()=>E(!1),children:i.jsxs("div",{onClick:M=>M.stopPropagation(),style:{width:460,maxWidth:"calc(100vw - 32px)",border:"1px solid var(--border)",background:"white",padding:20},children:[i.jsx("div",{style:{marginBottom:14,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"ADD WORKSPACE"}),i.jsxs("div",{style:{display:"grid",gap:10},children:[i.jsx("input",{value:P,onChange:M=>z(M.target.value),placeholder:"Workspace name",style:{border:"1px solid var(--border)",padding:"11px 12px",background:"white"}}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",lineHeight:1.5},children:"A workspace is a collection of projects. Add projects and their folders after creating it."}),i.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[i.jsx("button",{onClick:()=>E(!1),style:{padding:"10px 12px",border:"1px solid var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:10},children:"cancel"}),i.jsx("button",{onClick:()=>void K(),style:{padding:"10px 12px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10},children:Y?"creating…":"create workspace"})]})]})]})})]})}function Vt(e){return Array.isArray(e)?e.filter(Boolean):[]}function D(e,t,n=void 0){return!e||typeof e!="object"?n:e[t]??n}function Se(e){const t=Number(e||0);return new Intl.NumberFormat("en",{notation:Math.abs(t)>=1e4?"compact":"standard",maximumFractionDigits:Math.abs(t)>=1e4?1:0}).format(t)}function Hu(e){const t=String(e||"");if(!t)return"not linked";const n=t.split("/").filter(Boolean);return n.length>3?`.../${n.slice(-3).join("/")}`:t}function ji(e){if(!e)return"no timestamp";let t;if(typeof e=="number")t=e<1e10?e*1e3:e;else{const r=String(e).trim(),o=Number(r);t=r&&!Number.isNaN(o)?o<1e10?o*1e3:o:new Date(r).getTime()}if(Number.isNaN(t))return String(e);const n=Date.now()-t;return n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}function Qg(e){return String(e.preview||e.body||"").replace(/\s+/g," ").trim()||"No evidence preview captured yet."}function Yg(e){const t=Number(e.raw_body_chars||0),n=Number(e.evidence_count||0);return[e.kind?String(e.kind):null,e.scope?`${String(e.scope)} scope`:null,n?`${Se(n)} evidence`:null,t?`${Se(t)} raw chars compacted`:null,ji(e.updated_at||e.created_at)].filter(Boolean).join(" - ")}function wi(e){const t=String(e||"").toLowerCase();return t.includes("reject")||t.includes("fail")||t.includes("stale")?"var(--rose)":t.includes("pending")||t.includes("candidate")||t.includes("derived")?"var(--accent)":t.includes("promoted")||t.includes("active")||t.includes("ok")?"var(--green)":t.includes("evidence")||t.includes("digest")?"var(--indigo)":"var(--ink3)"}function zi(e){const[t,n]=v.useState(null),[r,o]=v.useState(""),[l,s]=v.useState(!0),a=async()=>{s(!0),o("");try{n(await e())}catch(d){o(String(d))}finally{s(!1)}};return v.useEffect(()=>{a()},[]),{data:t,error:r,loading:l,refresh:a}}function Ni({eyebrow:e,title:t,subtitle:n,children:r,action:o}){return i.jsx("div",{className:"product-screen",children:i.jsxs("div",{className:"product-content",children:[i.jsxs("div",{className:"product-hero",children:[i.jsxs("div",{className:"product-hero-copy",children:[i.jsx("div",{className:"product-eyebrow",children:e}),i.jsx("h1",{className:"product-title",children:t}),i.jsx("p",{className:"product-subtitle",children:n})]}),o?i.jsx("div",{className:"product-hero-action",children:o}):null]}),r]})})}function Me({label:e,children:t,style:n}){return i.jsxs("section",{className:"product-panel",style:{...n},children:[e?i.jsx("div",{className:"product-panel-label",children:e}):null,t]})}function Xe({label:e,value:t,tone:n}){return i.jsxs(Me,{style:{minHeight:96},children:[i.jsx("div",{className:"product-metric-value",style:{color:n||"var(--ink)"},children:t}),i.jsx("div",{className:"product-metric-label",children:e})]})}function Le({children:e,tone:t}){return i.jsx("span",{className:"product-pill",style:{color:t||"var(--ink2)"},children:e})}function sl({rows:e,empty:t,render:n}){return e.length?i.jsx("div",{className:"product-list",children:e.map(n)}):i.jsx("div",{className:"product-empty",children:t})}function Nn({width:e="100%",height:t=12,style:n}){return i.jsx("div",{"aria-hidden":"true",style:{width:e,height:t,borderRadius:4,background:"linear-gradient(90deg, rgba(20,16,10,0.045) 0%, rgba(224,107,63,0.13) 48%, rgba(20,16,10,0.045) 100%)",backgroundSize:"220% 100%",animation:"dhee-shimmer 1.35s linear infinite",border:"1px solid rgba(20,16,10,0.055)",...n}})}function Jg(){return i.jsxs("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"product-grid",children:[i.jsxs(Me,{children:[i.jsx("div",{className:"product-panel-label",children:"Loading Dhee state"}),i.jsx("div",{className:"product-metric-grid",children:Array.from({length:4}).map((e,t)=>i.jsxs("div",{children:[i.jsx(Nn,{width:"46%",height:10}),i.jsx(Nn,{width:`${76-t*7}%`,height:28,style:{marginTop:12}}),i.jsx(Nn,{width:"64%",height:10,style:{marginTop:10}})]},t))})]}),i.jsx("div",{className:"product-grid product-grid--two",children:Array.from({length:2}).map((e,t)=>i.jsxs(Me,{children:[i.jsx(Nn,{width:"34%",height:10}),i.jsx(Nn,{width:`${78-t*10}%`,height:22,style:{marginTop:15}}),i.jsx(Nn,{width:"92%",height:12,style:{marginTop:12}}),i.jsx(Nn,{width:"68%",height:12,style:{marginTop:8}})]},t))})]})}function Ri({loading:e,error:t}){return e?i.jsx(Jg,{}):t?i.jsx(Me,{children:i.jsx("span",{style:{color:"var(--rose)"},children:t})}):null}function Xg({onNavigate:e}){const{data:t,error:n,loading:r,refresh:o}=zi(A.commandCenter),l=D(t,"router",{}),s=D(t,"context",{}),a=D(t,"learnings",{}),d=D(t,"inbox",{}),c=D(t,"active_task",null),g=Vt(D(t,"router_sessions",[])),h=D(a,"totals",{}),y=D(d,"totals",{}),S=(D(t,"dhee_aliases",[])||[]).filter(Boolean);return i.jsxs(Ni,{eyebrow:"COMMAND CENTER",title:"The current truth before the agent sees anything.",subtitle:"Start here to see task continuity, context health, routed savings, review queues, and the next best action for this repo.",action:i.jsx("button",{onClick:o,style:At,children:"refresh"}),children:[i.jsx(Ri,{loading:r,error:n}),t?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"product-metric-grid",children:[i.jsx(Xe,{label:"tokens avoided",value:Se(D(l,"sessionTokensSaved",0)),tone:"var(--green)"}),i.jsx(Xe,{label:"router calls",value:Se(D(l,"totalCalls",0)),tone:"var(--accent)"}),i.jsx(Xe,{label:"repo context",value:Se(D(D(s,"totals",{}),"repo_entries",0)),tone:"var(--indigo)"}),i.jsx(Xe,{label:"learning candidates",value:Se(D(h,"candidate",0)),tone:"var(--accent)"})]}),i.jsxs("div",{className:"product-grid product-grid--two",children:[i.jsx(Me,{label:"ACTIVE WORK",children:c?i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:22,lineHeight:1.2,fontWeight:700},children:String(D(c,"title","Active task"))}),i.jsxs("div",{style:{marginTop:8,display:"flex",gap:8,flexWrap:"wrap"},children:[i.jsx(Le,{tone:wi(D(c,"status")),children:String(D(c,"status","active"))}),i.jsx(Le,{children:String(D(c,"harness","agent"))})]})]}):i.jsx("div",{style:{color:"var(--ink3)"},children:"No active task yet. Start from a linked repo to let Dhee compile state."})}),i.jsxs(Me,{label:"NEXT ACTION",children:[i.jsx("div",{style:{fontSize:18,fontWeight:650,lineHeight:1.35},children:String(D(t,"next_action","Start a routed agent task"))}),i.jsxs("div",{style:{marginTop:14,display:"flex",gap:8,flexWrap:"wrap"},children:[i.jsx("button",{onClick:()=>e("handoff"),style:At,children:"handoff"}),i.jsx("button",{onClick:()=>e("router"),style:Bo,children:"firewall"}),i.jsx("button",{onClick:()=>e("learnings"),style:Bo,children:"learnings"})]})]})]}),i.jsxs("div",{className:"product-grid product-grid--three",children:[i.jsx(Me,{label:"LIVE SESSIONS",children:i.jsx(sl,{rows:g.slice(0,5),empty:"No routed sessions yet.",render:w=>i.jsx(un,{title:String(w.title||w.session_id||"session"),meta:`${w.agent||w.runtime||"agent"} - ${Se(w.tokens_saved)} tokens`,tone:wi(w.state)},String(w.session_id))})}),i.jsxs(Me,{label:"REVIEW QUEUE",children:[i.jsx(un,{title:"proposals",meta:Se(D(y,"proposals",0)),tone:"var(--accent)"}),i.jsx(un,{title:"findings",meta:Se(D(y,"findings",0)),tone:"var(--rose)"}),i.jsx(un,{title:"conflicts",meta:Se(D(y,"conflicts",0)),tone:"var(--indigo)"})]}),i.jsx(Me,{label:"ADDRESSABLE CONTEXT",children:S.length?S.map(w=>i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,padding:"5px 0",color:"var(--ink2)"},children:w},w)):i.jsx("div",{className:"product-empty",children:"No dhee:// aliases exposed yet."})})]})]}):null]})}function qg(){const{data:e,error:t,loading:n,refresh:r}=zi(A.handoffUi),o=D(e,"continuity",{}),l=D(o,"last_session",{})||{},s=Vt(D(e,"tasks",[])),a=Vt(D(e,"sessions",[])),d=a.find(f=>f.active||String(f.state||"").toLowerCase()==="active")||a[0]||{},c=D(D(d,"task",{}),"id",""),g=s.find(f=>String(f.id||"")===String(c))||s.find(f=>String(f.status||"").toLowerCase()==="active")||{},h=String(D(g,"title")||D(d,"title")||D(l,"task_summary","No active session yet")),y=D(d,"updated_at")||D(g,"updatedAt")||D(l,"updated")||D(l,"ended_at"),S=String(D(d,"runtime")||D(d,"agent")||D(g,"harness")||D(l,"agent_id","agent")),w=String(D(d,"model")||""),T=String(D(d,"cwd")||D(d,"repo_root")||D(e,"repo","")),V=Vt(D(l,"files_touched",D(l,"filesTouched",[]))),m=Vt(D(l,"decisions",[])),u=Vt(D(l,"todos",[]));return i.jsxs(Ni,{eyebrow:"HANDOFF HUB",title:"Resume without replaying the transcript.",subtitle:"Dhee turns the latest work into task state: decisions, files, blockers, commands, tests, resume confidence, and the next step.",action:i.jsx("button",{onClick:r,style:At,children:"refresh"}),children:[i.jsx(Ri,{loading:n,error:t}),e?i.jsxs("div",{className:"product-grid product-grid--two",children:[i.jsxs(Me,{label:"CURRENT WORK",children:[i.jsx("div",{style:{fontSize:24,lineHeight:1.15,fontWeight:700,overflowWrap:"anywhere"},children:h}),i.jsxs("div",{style:{marginTop:12,display:"flex",gap:8,flexWrap:"wrap"},children:[i.jsx(Le,{tone:wi(D(d,"state")||D(g,"status")),children:String(D(d,"state")||D(g,"status")||"ready")}),i.jsxs(Le,{tone:"var(--green)",children:["confidence ",Math.round(Number(D(e,"resume_confidence",0))*100),"%"]}),i.jsx(Le,{children:S}),w?i.jsx(Le,{children:w}):null,i.jsx(Le,{children:ji(y)})]}),T?i.jsx("div",{className:"product-handoff-path",children:Hu(T)}):null,i.jsxs("div",{className:"product-handoff-stats",children:[i.jsx(un,{title:"router calls",meta:Se(Number(D(d,"router_calls",0))),tone:"var(--accent)"}),i.jsx(un,{title:"tokens saved",meta:Se(Number(D(d,"tokens_saved",0))),tone:"var(--green)"}),i.jsx(un,{title:"task restore",meta:c?"linked":"local handoff",tone:"var(--indigo)"})]})]}),i.jsxs(Me,{label:"RESUME COMMAND",children:[i.jsx("div",{style:{color:"var(--ink2)",lineHeight:1.55},children:"Run the handoff command when a new agent needs the current state without replaying chat."}),i.jsx("pre",{style:yp,children:String(D(e,"command",""))})]}),i.jsxs(Me,{label:"LATEST SAVED HANDOFF",children:[i.jsx("div",{style:{fontSize:20,lineHeight:1.25,fontWeight:700,overflowWrap:"anywhere"},children:String(D(l,"task_summary","No saved handoff yet"))}),i.jsxs("div",{style:{marginTop:12,display:"flex",gap:8,flexWrap:"wrap"},children:[i.jsx(Le,{children:ji(D(l,"updated")||D(l,"ended_at"))}),i.jsx(Le,{children:String(D(l,"agent_id",D(l,"source","dhee")))})]})]}),i.jsx(Me,{label:"RESUME INVENTORY",children:i.jsx(tv,{rows:[["tasks",s.length],["sessions",a.length],["files",V.length],["decisions",m.length],["todos",u.length]]})}),i.jsx(Me,{label:"DECISIONS",style:{gridColumn:"span 1"},children:i.jsx(Vu,{rows:m,empty:"No decisions captured yet."})}),i.jsx(Me,{label:"FILES TOUCHED",children:i.jsx(Vu,{rows:V.map(f=>Hu(String(f))),empty:"No files in the latest handoff."})})]}):null]})}function Zg(){const{data:e,error:t,loading:n,refresh:r}=zi(()=>A.proofReplay(120)),o=Vt(D(e,"items",[])),l=D(e,"totals",{});return i.jsxs(Ni,{eyebrow:"PROOF REPLAY",title:"Replay the context decisions, not just the chat.",subtitle:"See the expansion trace: what Dhee digested, hid, expanded, injected, promoted, rejected, or derived from local records.",action:i.jsx("button",{onClick:r,style:At,children:"refresh"}),children:[i.jsx(Ri,{loading:n,error:t}),e?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"product-metric-grid",children:[i.jsx(Xe,{label:"events",value:Se(D(l,"events",o.length))}),i.jsx(Xe,{label:"digests",value:Se(D(l,"digests",0)),tone:"var(--green)"}),i.jsx(Xe,{label:"expansion trace",value:Se(D(l,"expansions",0)),tone:"var(--accent)"}),i.jsx(Xe,{label:"evidence",value:Se(D(l,"evidence",0)),tone:"var(--indigo)"}),i.jsx(Xe,{label:"derived rows",value:Se(D(l,"derived",0))})]}),i.jsx(Me,{label:"DECISION TIMELINE",children:i.jsx(sl,{rows:o,empty:"No context decisions recorded yet.",render:(s,a)=>i.jsx(nv,{index:a,title:String(s.title||"Decision"),meta:`${s.source||"dhee"} - ${ji(s.time)}`,detail:String(s.detail||""),kind:String(s.kind||"event"),derived:!!s.derived},String(s.id||a))})})]}):null]})}function Gg(){const{data:e,error:t,loading:n,refresh:r}=zi(()=>A.learningsUi(160)),[o,l]=v.useState(""),s=Vt(D(e,"items",[])),a=D(e,"totals",{}),d=async(c,g)=>{l(c);try{g==="promote"?await A.promoteLearning(c,{approved_by:"dhee-ui"}):await A.rejectLearning(c,{reason:"rejected in Dhee UI"}),await r()}finally{l("")}};return i.jsxs(Ni,{eyebrow:"LEARNING INBOX",title:"Only evidence-backed learnings get promoted.",subtitle:"Clear pending review candidates from agent work. Dhee should learn from success, avoided failure, repeated utility, or explicit approval.",action:i.jsx("button",{onClick:r,style:At,children:"refresh"}),children:[i.jsx(Ri,{loading:n,error:t}),e?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"product-metric-grid",children:[i.jsx(Xe,{label:"candidates",value:Se(D(a,"candidate",0)),tone:"var(--accent)"}),i.jsx(Xe,{label:"promoted",value:Se(D(a,"promoted",0)),tone:"var(--green)"}),i.jsx(Xe,{label:"rejected",value:Se(D(a,"rejected",0)),tone:"var(--rose)"}),i.jsx(Xe,{label:"all learnings",value:Se(D(a,"all",s.length))})]}),i.jsx(Me,{label:"LEARNING REVIEW",children:i.jsx(sl,{rows:s,empty:"No learning candidates yet.",render:c=>{const g=String(c.id||""),h=String(c.status||"candidate"),y=Qg(c),S=String(c.source_harness||c.source_agent_id||"agent"),w=String(c.source_model||"");return i.jsxs("div",{className:"product-learning-row",children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:8},children:[i.jsx(Le,{tone:wi(h),children:h}),i.jsx(Le,{children:String(c.evidence_gate||"needs approval")}),c.needs_distillation?i.jsx(Le,{tone:"var(--rose)",children:"needs distillation"}):null,i.jsx(Le,{children:S}),w?i.jsx(Le,{children:w}):null]}),i.jsx("div",{className:"product-learning-title",children:String(c.title||g)}),i.jsx("div",{className:"product-learning-meta",children:Yg(c)}),i.jsx("div",{className:"product-learning-body",title:y,children:y})]}),i.jsxs("div",{className:"product-learning-actions",children:[i.jsx("button",{"aria-label":`Promote ${g||"learning"}`,disabled:!g||o===g||h==="promoted",onClick:()=>d(g,"promote"),style:At,children:"promote"}),i.jsx("button",{"aria-label":`Reject ${g||"learning"}`,disabled:!g||o===g||h==="rejected",onClick:()=>d(g,"reject"),style:Bo,children:"reject"})]})]},g)}})})]}):null]})}function ev(){const{data:e,error:t,loading:n,refresh:r}=zi(A.portabilityUi),[o,l]=v.useState(!1),[s,a]=v.useState(""),[d,c]=v.useState(null),[g,h]=v.useState(""),y=D(e,"counts",{}),S=Vt(D(e,"packs",[])),w=(D(e,"contract",[])||[]).filter(Boolean),T=async()=>{l(!0),h("");try{await A.exportPackUi({}),await r()}catch(m){h(String(m))}finally{l(!1)}},V=async()=>{h(""),c(null);try{c(await A.importPackDryRunUi({input_path:s}))}catch(m){h(String(m))}};return i.jsxs(Ni,{eyebrow:"PORTABILITY & TRUST",title:"Local memory should be inspectable, signed, and movable.",subtitle:"Dhee keeps export/import as a product surface, not an afterthought. No lock-in tricks, no hidden hosted dependency.",action:i.jsx("button",{onClick:r,style:At,children:"refresh"}),children:[i.jsx(Ri,{loading:n,error:t}),e?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"product-metric-grid",children:[i.jsx(Xe,{label:"memories",value:Se(D(y,"memories",0))}),i.jsx(Xe,{label:"artifacts",value:Se(D(y,"artifacts",0)),tone:"var(--indigo)"}),i.jsx(Xe,{label:"repo context",value:Se(D(y,"repo_context_entries",0)),tone:"var(--green)"}),i.jsx(Xe,{label:"packs found",value:Se(S.length),tone:"var(--accent)"})]}),g?i.jsx(Me,{children:i.jsx("span",{style:{color:"var(--rose)"},children:g})}):null,i.jsxs("div",{className:"product-grid product-grid--split",children:[i.jsxs(Me,{label:"PORTABLE SUBSTRATE",children:[i.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:w.map(m=>i.jsx(Le,{tone:"var(--green)",children:m},m))}),i.jsx("button",{disabled:o,onClick:T,style:{...At,marginTop:16},children:o?"exporting...":"export .dheemem"})]}),i.jsxs(Me,{label:"IMPORT DRY RUN",children:[i.jsxs("div",{style:{display:"flex",gap:10},children:[i.jsx("input",{value:s,onChange:m=>a(m.target.value),placeholder:"/path/to/backup.dheemem",style:rv}),i.jsx("button",{disabled:!s.trim(),onClick:V,style:At,children:"dry run"})]}),d?i.jsx("pre",{style:yp,children:JSON.stringify(D(d,"result",d),null,2)}):null]})]}),i.jsx(Me,{label:"RECENT PACKS",children:i.jsx(sl,{rows:S,empty:"No .dheemem packs found yet.",render:m=>i.jsx(un,{title:String(m.name||m.path),meta:`${m.verified?"verified":"unverified"} - ${Se(Number(m.size_bytes||0))} bytes - ${ji(m.updated_at)}`,tone:m.verified?"var(--green)":"var(--accent)"},String(m.path))})})]}):null]})}function Lv({onOpenContext:e}){return i.jsxs("div",{className:"repo-brain-header",children:[i.jsx(Le,{tone:"var(--green)",children:"REPO BRAIN"}),i.jsx(Le,{children:"dhee://state/current"}),i.jsx(Le,{children:"dhee://handoff/latest"}),e?i.jsx("button",{onClick:e,style:Bo,children:"context vault"}):null]})}function Vu({rows:e,empty:t}){return e.length?i.jsx("div",{className:"product-list product-list--tight",children:e.map((n,r)=>i.jsx("div",{className:"product-text-row",children:String(n)},r))}):i.jsx("div",{className:"product-empty",children:t})}function tv({rows:e}){return i.jsx("div",{style:{display:"grid",gap:8},children:e.map(([t,n])=>i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:20},children:[i.jsx("span",{style:{color:"var(--ink3)"},children:t}),i.jsx("strong",{children:Se(n)})]},t))})}function un({title:e,meta:t,tone:n}){return i.jsxs("div",{className:"product-small-row",children:[i.jsx("span",{className:"product-row-dot",style:{background:n||"var(--ink3)"}}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{className:"product-small-title",children:e}),i.jsx("div",{className:"product-small-meta",children:t})]})]})}function nv({index:e,title:t,meta:n,detail:r,kind:o,derived:l}){return i.jsxs("div",{className:"product-timeline-row",children:[i.jsx("div",{className:"product-timeline-index",children:String(e+1).padStart(2,"0")}),i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:6},children:[i.jsx(Le,{tone:wi(o),children:o}),l?i.jsx(Le,{tone:"var(--accent)",children:"derived"}):i.jsx(Le,{tone:"var(--green)",children:"recorded"}),i.jsx(Le,{children:n})]}),i.jsx("div",{className:"product-timeline-title",children:t}),r?i.jsx("div",{className:"product-timeline-detail",children:r}):null]})]})}const At={border:"1px solid var(--ink)",background:"var(--ink)",color:"white",padding:"8px 12px",fontFamily:"var(--mono)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase",borderRadius:4,minHeight:34,whiteSpace:"nowrap",cursor:"pointer",boxShadow:"0 1px 0 rgba(255, 255, 255, 0.22) inset"},Bo={...At,color:"var(--ink)",background:"white",borderColor:"var(--border2)"},rv={minHeight:36,flex:1,border:"1px solid var(--border2)",background:"white",padding:"0 10px",fontFamily:"var(--mono)",fontSize:11},yp={marginTop:14,border:"1px solid var(--border)",background:"var(--surface2)",padding:12,fontFamily:"var(--mono)",fontSize:11,whiteSpace:"pre-wrap",overflowX:"auto"},iv={border:"1px solid var(--border)",background:"var(--bg)",borderRadius:8,padding:18,width:"min(760px, 100%)",boxSizing:"border-box",display:"flex",flexWrap:"wrap",gap:18,boxShadow:"0 10px 28px rgba(20,16,10,0.06)"},Ku={fontFamily:"var(--mono)",fontSize:9,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--ink3)"},ov={borderRadius:5,cursor:"pointer",fontFamily:"var(--mono)",fontSize:10,padding:"8px 11px",whiteSpace:"nowrap"};function lv(e="secondary",t){const n=e==="primary";return{...ov,border:`1px solid ${n?"var(--ink)":"var(--border)"}`,background:n?"var(--ink)":"white",color:n?"white":"var(--accent)",opacity:t?.55:1,cursor:t?"not-allowed":"pointer"}}function xp({title:e="Set up a developer workspace",eyebrow:t="First run",body:n="Connect a repo folder, then start Codex or Claude Code from that folder so Dhee can mirror sessions and context.",actions:r=[],commands:o=["dhee onboard --root .","dhee doctor"],aside:l}){return i.jsxs("section",{style:iv,children:[i.jsxs("div",{style:{flex:"1 1 300px",minWidth:0},children:[i.jsx("div",{style:Ku,children:t}),i.jsx("h2",{style:{margin:"5px 0 7px",fontSize:22,lineHeight:1.15,color:"var(--ink)",letterSpacing:0},children:e}),i.jsx("div",{style:{color:"var(--ink2)",fontSize:12.5,lineHeight:1.55,maxWidth:680},children:n}),r.length?i.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:14},children:r.map(s=>i.jsx("button",{type:"button",onClick:s.onClick,disabled:s.disabled,style:lv(s.tone,s.disabled),children:s.label},s.label))}):null]}),i.jsxs("div",{style:{flex:"1 1 260px",border:"1px solid var(--border)",background:"var(--surface)",borderRadius:6,padding:12,minWidth:0},children:[i.jsx("div",{style:{...Ku,marginBottom:8},children:"Terminal path"}),i.jsx("div",{style:{display:"grid",gap:7},children:o.map(s=>i.jsx("code",{style:{display:"block",border:"1px solid var(--border)",background:"white",borderRadius:4,padding:"8px 9px",fontFamily:"var(--mono)",fontSize:10,color:"var(--ink)",lineHeight:1.45,overflowWrap:"anywhere"},children:s},s))}),l?i.jsx("div",{style:{marginTop:10},children:l}):null]})]})}const Ar=[{key:"day",label:"Daily",short:"24h",ms:24*60*60*1e3},{key:"week",label:"Weekly",short:"7d",ms:7*24*60*60*1e3},{key:"month",label:"Monthly",short:"30d",ms:30*24*60*60*1e3},{key:"year",label:"Yearly",short:"365d",ms:365*24*60*60*1e3}],Qu={items:[],next_cursor:null,active_only:!1,totals:{tokens_saved:0,estimated_cost_saved_usd:0,router_calls:0,sessions:0}};function Jt(e){return e==null?"0":new Intl.NumberFormat("en",{notation:Math.abs(e)>=1e4?"compact":"standard",maximumFractionDigits:Math.abs(e)>=1e4?1:0}).format(e)}function Sn(e){return new Intl.NumberFormat("en-US").format(Math.max(0,Number(e||0)))}function Yr(e){const t=Math.max(0,Number(e||0));return t>0&&t<.01?"<$0.01":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:t>=100?0:2}).format(t)}function er(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function Ao(e){const t=er(e);if(!t)return"n/a";const n=Date.now()-t;return n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}function Uo(e){if(!e)return"n/a";const t=e.split("/").filter(Boolean);return t.length<=2?e:".../"+t.slice(-2).join("/")}function Sp(e){var r;const t=typeof e=="string"?e:e.agent||e.runtime||((r=e.agents)==null?void 0:r[0])||"unknown",n=String(t||"").toLowerCase();return n.includes("codex")?"codex":n.includes("claude")?"claude-code":n||"unknown"}function sv(e){const t=Sp(e||"");return t==="codex"?"Codex":t==="claude-code"?"Claude Code":e||"Unknown"}function Pa(e){const t=Sp(e||"");return t==="codex"?"var(--indigo)":t==="claude-code"?"var(--accent)":"var(--ink3)"}function Fa(e){var t;return Number(((t=e.pricing)==null?void 0:t.input_cost_per_million)||0)>0}function Wo(e){return e.tokens_saved>0&&!Fa(e)?"unpriced":Yr(e.estimated_cost_saved_usd)}function av(e){const t=String(e.state||"").toLowerCase();return!!e.active&&(t==="active"||t==="running"||t==="live")}function kp(e){const t=e.pricing;if(!t||!Fa(e))return(t==null?void 0:t.note)||"No official provider/model rate mapped yet.";const n=t.provider||e.runtime||e.agent||"provider",r=t.model_family||e.model||"model";return`${n} ${r}: $${t.input_cost_per_million}/1M input tokens`}function jp(e,t){if(!e)return Number.POSITIVE_INFINITY;const r=Number(e[t==="day"?"daily_budget_usd":t==="week"?"weekly_budget_usd":t==="year"?"yearly_budget_usd":"monthly_budget_usd"]||0);return r>0?r:Number.POSITIVE_INFINITY}function Yu(e,t,n){return e.reduce((r,o)=>(r.tokens+=o.tokens_saved||0,r.apiValue+=Number(o.estimated_cost_saved_usd||0),r.calls+=o.router_calls||0,r.sessions+=1,r.cost=Math.min(r.apiValue,jp(t,n)),r),{tokens:0,apiValue:0,cost:0,calls:0,sessions:0})}function Ju(){const e=new URLSearchParams(window.location.search),t=String(e.get("view")||"").toLowerCase(),n=window.location.pathname.replace(/^\/+|\/+$/g,"").toLowerCase();return t==="router/sessionshistory"||t==="router/session-history"||t==="router/history"||n==="router/sessionshistory"?"history":"live"}function dv(e){const t=new URLSearchParams(window.location.search);t.set("view",e==="history"?"router/sessionshistory":"router");const n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:""}${window.location.hash||""}`;window.history.pushState({},"",r),window.dispatchEvent(new Event("popstate"))}function uv({onOpenFolders:e,onOpenSetup:t}){return i.jsx("div",{style:{height:"100%",overflowY:"auto",background:"var(--surface)"},children:i.jsx(cv,{onOpenFolders:e,onOpenSetup:t})})}function cv({onOpenFolders:e,onOpenSetup:t}){const n=v.useRef(null),[r,o]=v.useState(Qu),[l,s]=v.useState(Qu),[a,d]=v.useState("week"),[c,g]=v.useState(()=>Ju()),[h,y]=v.useState(""),[S,w]=v.useState(!1),[T,V]=v.useState(null),m=async(Q=!1)=>{Q||w(!0),V(null);const G=A.routerSessions({active:!0,limit:50}).then(se=>({ok:!0,page:se}),se=>({ok:!1,error:se})),I=A.routerSessions({active:!1,limit:100}).then(se=>({ok:!0,page:se}),se=>({ok:!1,error:se})),U=[];try{const se=await G;se.ok?s(se.page):U.push(String(se.error));const _=await I;_.ok?o(_.page):U.push(String(_.error)),U.length&&V(U.join("; "))}finally{Q||w(!1)}};v.useEffect(()=>{m(!1);const Q=window.setInterval(()=>void m(!0),15e3);return()=>window.clearInterval(Q)},[]),v.useEffect(()=>{const Q=()=>g(Ju());return window.addEventListener("popstate",Q),()=>window.removeEventListener("popstate",Q)},[]),v.useEffect(()=>{var Q,G;(G=(Q=n.current)==null?void 0:Q.parentElement)==null||G.scrollTo({top:0,behavior:"auto"})},[c]);const u=v.useMemo(()=>[...l.items].filter(av).sort((Q,G)=>er(G.updated_at)-er(Q.updated_at)),[l.items]),f=v.useMemo(()=>{const Q=Ar.find(I=>I.key===a)||Ar[1],G=Date.now()-Q.ms;return[...r.items].filter(I=>er(I.updated_at||I.started_at)>=G).sort((I,U)=>er(U.updated_at)-er(I.updated_at))},[r.items,a]),p=c==="history"?f.find(Q=>Q.session_id===h)||null:u.find(Q=>Q.session_id===h)||null,j=r.budget||l.budget,E=Yu(f,j,a),P=Yu(u,j,"day"),z=l.items.length>0||r.items.length>0,Y=Ar.find(Q=>Q.key===a)||Ar[1],N=jp(j,a),J=Number.isFinite(N)&&E.apiValue>N,X=Q=>{g(Q),dv(Q)};return i.jsxs("div",{ref:n,style:{padding:"clamp(10px, 3vw, 18px)",display:"grid",gap:14,minWidth:0,width:"100%",boxSizing:"border-box"},children:[i.jsxs("section",{style:{border:"1px solid var(--border)",background:"var(--bg)",borderRadius:8,padding:16,minWidth:0,boxSizing:"border-box"},children:[i.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:14,alignItems:"start",justifyContent:"space-between",marginBottom:14},children:[i.jsxs("div",{style:{flex:"1 1 240px",minWidth:0},children:[i.jsx(Yn,{children:"Context Firewall"}),i.jsx("h1",{style:{margin:"2px 0 0",fontSize:26,lineHeight:1.1,color:"var(--ink)",letterSpacing:0},children:c==="history"?"Firewall session history":"Live context firewall"}),i.jsx("p",{style:{margin:"6px 0 0",color:"var(--ink3)",fontSize:12,maxWidth:780},children:c==="history"?"Every completed and recent local agent session, with pointer-backed evidence and avoided raw context.":"Running Claude Code and Codex sessions, with raw output kept behind digests until the agent asks to expand."})]}),i.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-start",flexWrap:"wrap",flex:"0 1 auto"},children:[i.jsx("button",{onClick:()=>X(c==="history"?"live":"history"),style:{border:"1px solid var(--accent)",background:c==="history"?"white":"var(--accent-dim)",borderRadius:5,color:"var(--accent)",cursor:"pointer",fontFamily:"var(--mono)",fontSize:10,padding:"8px 11px"},children:c==="history"?"LIVE FIREWALL":"SESSION HISTORY"}),i.jsx("button",{onClick:()=>m(!1),disabled:S,style:{border:"1px solid var(--border)",background:"white",borderRadius:5,color:S?"var(--ink3)":"var(--accent)",cursor:S?"wait":"pointer",fontFamily:"var(--mono)",fontSize:10,padding:"8px 11px"},children:S?"SYNCING":"REFRESH"})]})]}),i.jsx("div",{style:{display:"flex",gap:7,flexWrap:"wrap",marginBottom:12},children:Ar.map(Q=>{const G=Q.key===a;return i.jsxs("button",{onClick:()=>d(Q.key),style:{border:`1px solid ${G?"var(--accent)":"var(--border)"}`,background:G?"var(--accent-dim)":"white",color:G?"var(--accent)":"var(--ink2)",borderRadius:5,padding:"6px 10px",fontFamily:"var(--mono)",fontSize:10,cursor:"pointer"},children:[Q.label,i.jsx("span",{style:{color:"var(--ink3)",marginLeft:6},children:Q.short})]},Q.key)})}),S&&!z?i.jsx(hv,{}):i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(118px, 1fr))",gap:10},children:[i.jsx(cn,{label:`${Y.label} API value`,value:Yr(E.apiValue),sub:"official input-rate estimate",accent:"var(--green)"}),i.jsx(cn,{label:"Budget-capped savings",value:Yr(E.cost),sub:J?`capped at ${Yr(N)}`:"same as API value for this range",accent:"var(--green)"}),i.jsx(cn,{label:`${Y.label} raw tokens avoided`,value:Jt(E.tokens),sub:`${Sn(E.tokens)} avoided input tokens`,accent:"var(--green)"}),i.jsx(cn,{label:"Live governed sessions",value:Sn(P.sessions),sub:`${Jt(P.tokens)} active-session savings`,accent:"var(--accent)"})]})]}),T?i.jsxs("div",{style:{border:"1px solid var(--rose)",background:"white",color:"var(--rose)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--mono)",fontSize:11},children:["context firewall data unavailable: ",T]}):null,!S&&!T&&!z?i.jsx(xp,{body:"Point Dhee at a repo folder, then start an agent task from that folder. The context firewall will fill with digests, evidence pointers, and expansions after the first mirrored Codex or Claude Code run.",actions:[...e?[{label:"ADD REPO FOLDER",onClick:e,tone:"primary"}]:[],...t?[{label:"START TASK",onClick:t}]:[]]}):null,c==="history"?i.jsx(Xu,{title:"Session history",sub:`${f.length} sessions in the last ${Y.short} · ${Jt(E.tokens)} tokens · ${Yr(E.apiValue)} API value`,action:i.jsx("button",{onClick:()=>X("live"),style:{border:"1px solid var(--border)",background:"white",borderRadius:5,color:"var(--accent)",cursor:"pointer",fontFamily:"var(--mono)",fontSize:10,padding:"7px 10px",whiteSpace:"nowrap"},children:"LIVE FIREWALL"}),children:i.jsx(pv,{rows:f,selectedId:(p==null?void 0:p.session_id)||"",onSelect:y,loading:S})}):i.jsx(Xu,{title:"Live governed sessions",sub:`${u.length} active local agent session${u.length===1?"":"s"} · click a session to inspect routing, evidence, and savings`,action:i.jsx("button",{onClick:()=>X("history"),style:{border:"1px solid var(--border)",background:"white",borderRadius:5,color:"var(--accent)",cursor:"pointer",fontFamily:"var(--mono)",fontSize:10,padding:"7px 10px",whiteSpace:"nowrap"},children:"HISTORY"}),children:S&&u.length===0?i.jsx(mv,{}):u.length===0?i.jsx(wp,{children:"No active Claude Code or Codex sessions detected."}):i.jsx("div",{style:{display:"grid",gap:8},children:u.map(Q=>i.jsx(fv,{row:Q,selected:(p==null?void 0:p.session_id)===Q.session_id,onSelect:()=>y(G=>G===Q.session_id?"":Q.session_id)},Q.session_id))})})]})}function fv({row:e,selected:t,onSelect:n}){const r=Pa(e.agent||e.runtime),o=e.live_usage;return i.jsxs("div",{className:"router-active-card",style:{width:"100%",border:`1px solid ${t?r:"var(--border)"}`,background:t?"var(--surface)":"white",borderRadius:6,overflow:"hidden"},children:[i.jsx("button",{type:"button",className:"router-active-card__button","aria-expanded":t,onClick:n,style:{width:"100%",textAlign:"left",background:"transparent",border:0,padding:12,cursor:"pointer"},children:i.jsxs("div",{className:"router-active-card__grid",children:[i.jsxs("div",{className:"router-active-card__main",children:[i.jsx(Ho,{agent:e.agent||e.runtime||"unknown"}),i.jsx("div",{className:"router-active-card__title",style:{fontSize:15,fontWeight:600,color:"var(--ink)",marginTop:4},title:e.title,children:e.title||e.session_id}),i.jsxs("div",{className:"router-active-card__meta",style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginTop:3},title:e.cwd||e.repo_root,children:[Uo(e.repo_root||e.cwd)," - updated ",Ao(e.updated_at)]})]}),i.jsxs("div",{className:"router-active-card__stats",children:[i.jsx(Un,{label:"saved",value:Jt(e.tokens_saved)}),i.jsx(Un,{label:"API value",value:Wo(e)}),i.jsx(Un,{label:"live tokens",value:o!=null&&o.available?Jt(o.total_tokens):"n/a"})]}),i.jsx("div",{className:"router-active-card__toggle",style:{fontFamily:"var(--mono)",fontSize:18,lineHeight:1,color:t?r:"var(--ink3)",textAlign:"right"},"aria-hidden":"true",children:t?"-":"+"})]})}),t?i.jsx("div",{style:{borderTop:"1px solid var(--border)",padding:"12px 12px 14px",background:"white"},children:i.jsx(vv,{row:e,showHeader:!1})}):null]})}function pv({rows:e,selectedId:t,onSelect:n,loading:r}){return r&&e.length===0?i.jsx(gv,{}):e.length===0?i.jsx(wp,{children:"No sessions in this range."}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"router-session-table",style:{border:"1px solid var(--border)",borderRadius:6,overflowX:"auto",background:"white"},children:i.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontFamily:"var(--mono)",fontSize:11},children:[i.jsx("thead",{children:i.jsxs("tr",{style:{background:"var(--surface)"},children:[i.jsx(Rn,{children:"Session"}),i.jsx(Rn,{children:"Agent"}),i.jsx(Rn,{children:"State"}),i.jsx(Rn,{children:"Updated"}),i.jsx(Rn,{align:"right",children:"Tokens saved"}),i.jsx(Rn,{align:"right",children:"API value"}),i.jsx(Rn,{align:"right",children:"Calls"})]})}),i.jsx("tbody",{children:e.map(o=>{const l=t===o.session_id;return i.jsxs("tr",{onClick:()=>n(o.session_id),style:{borderTop:"1px solid var(--border)",background:l?"oklch(0.98 0.02 262)":"white",cursor:"pointer"},children:[i.jsxs(Pn,{title:o.title||o.session_id,children:[i.jsx("div",{style:{color:"var(--ink)",fontWeight:l?700:500,maxWidth:420,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.title||o.session_id}),i.jsx("div",{style:{color:"var(--ink3)",marginTop:2,maxWidth:420,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:o.cwd||o.repo_root,children:Uo(o.repo_root||o.cwd)})]}),i.jsx(Pn,{children:i.jsx(Ho,{agent:o.agent||o.runtime||"unknown"})}),i.jsx(Pn,{children:i.jsx(qu,{state:o.state,active:o.active})}),i.jsx(Pn,{children:Ao(o.updated_at)}),i.jsx(Pn,{align:"right",children:Sn(o.tokens_saved)}),i.jsx(Pn,{align:"right",title:kp(o),children:Wo(o)}),i.jsx(Pn,{align:"right",children:Sn(o.router_calls)})]},o.session_id)})})]})}),i.jsx("div",{className:"router-session-cards","aria-label":"Session history cards",children:e.map(o=>{const l=t===o.session_id;return i.jsxs("button",{type:"button",className:`router-session-card${l?" router-session-card--active":""}`,onClick:()=>n(o.session_id),"aria-pressed":l,children:[i.jsxs("div",{className:"router-session-card__head",children:[i.jsx("div",{className:"router-session-card__title",title:o.title||o.session_id,children:o.title||o.session_id}),i.jsx(qu,{state:o.state,active:o.active})]}),i.jsxs("div",{className:"router-session-card__meta",children:[i.jsx(Ho,{agent:o.agent||o.runtime||"unknown"}),i.jsx("span",{children:Ao(o.updated_at)})]}),i.jsx("div",{className:"router-session-card__path",title:o.cwd||o.repo_root||void 0,children:Uo(o.repo_root||o.cwd)}),i.jsxs("div",{className:"router-session-card__stats",children:[i.jsx(Un,{label:"saved",value:Jt(o.tokens_saved)}),i.jsx(Un,{label:"API value",value:Wo(o)}),i.jsx(Un,{label:"calls",value:Sn(o.router_calls)})]})]},o.session_id)})})]})}function ze({width:e="100%",height:t=12,radius:n=4,style:r}){return i.jsx("div",{"aria-hidden":"true",style:{width:e,height:t,borderRadius:n,background:"linear-gradient(90deg, rgba(20,16,10,0.045) 0%, rgba(224,107,63,0.13) 48%, rgba(20,16,10,0.045) 100%)",backgroundSize:"220% 100%",animation:"dhee-shimmer 1.35s linear infinite",border:"1px solid rgba(20,16,10,0.055)",...r}})}function La({label:e,children:t}){return i.jsxs("div",{role:"status","aria-live":"polite","aria-busy":"true",style:{display:"grid",gap:10},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",textTransform:"uppercase",letterSpacing:"0.08em"},children:e}),t]})}function hv(){return i.jsx(La,{label:"Loading router savings",children:i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(118px, 1fr))",gap:10},children:Array.from({length:4}).map((e,t)=>i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",borderRadius:6,padding:11},children:[i.jsx(ze,{width:"42%",height:10}),i.jsx(ze,{width:"70%",height:28,style:{marginTop:12}}),i.jsx(ze,{width:"82%",height:11,style:{marginTop:11}})]},t))})})}function mv(){return i.jsx(La,{label:"Loading active sessions",children:Array.from({length:3}).map((e,t)=>i.jsx("div",{className:"router-active-card",style:{width:"100%",border:"1px solid var(--border)",background:"white",borderRadius:6,padding:12,boxSizing:"border-box"},children:i.jsxs("div",{className:"router-active-card__grid",children:[i.jsxs("div",{className:"router-active-card__main",children:[i.jsx(ze,{width:t===0?76:92,height:18,radius:4}),i.jsx(ze,{width:`${72-t*8}%`,height:16,style:{marginTop:10}}),i.jsx(ze,{width:`${48+t*12}%`,height:10,style:{marginTop:7}})]}),i.jsxs("div",{className:"router-active-card__stats",children:[i.jsx(ze,{height:30}),i.jsx(ze,{height:30}),i.jsx(ze,{height:30})]}),i.jsx(ze,{width:18,height:18,radius:9})]})},t))})}function gv(){return i.jsxs(La,{label:"Loading session history",children:[i.jsx("div",{className:"router-session-table",style:{border:"1px solid var(--border)",borderRadius:6,overflow:"hidden",background:"white",padding:12},children:Array.from({length:6}).map((e,t)=>i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(220px, 1fr) 90px 80px 80px 110px 90px 70px",gap:14,padding:"9px 0",borderTop:t===0?0:"1px solid var(--border)",alignItems:"center"},children:[i.jsx(ze,{width:`${70-t*4}%`,height:12}),i.jsx(ze,{width:"72%",height:18}),i.jsx(ze,{width:"68%",height:18}),i.jsx(ze,{width:"62%",height:12}),i.jsx(ze,{width:"82%",height:12}),i.jsx(ze,{width:"70%",height:12}),i.jsx(ze,{width:"56%",height:12})]},t))}),i.jsx("div",{className:"router-session-cards","aria-hidden":"true",children:Array.from({length:3}).map((e,t)=>i.jsxs("div",{className:"router-session-card",children:[i.jsx(ze,{width:"64%",height:15}),i.jsx(ze,{width:"42%",height:10}),i.jsx(ze,{width:"76%",height:10}),i.jsxs("div",{className:"router-session-card__stats",children:[i.jsx(ze,{height:28}),i.jsx(ze,{height:28}),i.jsx(ze,{height:28})]})]},t))})]})}function vv({row:e,showHeader:t=!0}){var o;const n=e.live_usage,r=Object.entries(e.tool_breakdown||{}).sort((l,s)=>s[1]-l[1]);return i.jsxs("div",{style:{display:"grid",gap:10},children:[t?i.jsxs("div",{children:[i.jsx(Ho,{agent:e.agent||e.runtime||"unknown"}),i.jsx("h2",{style:{margin:"6px 0 4px",fontSize:18,lineHeight:1.25,color:"var(--ink)",letterSpacing:0,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},title:e.title||e.session_id,children:e.title||e.session_id}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.cwd||e.repo_root||void 0,children:[e.model||"model unavailable"," · ",Uo(e.cwd||e.repo_root)]})]}):null,i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:8},children:[i.jsx(cn,{label:"tokens saved",value:Jt(e.tokens_saved),sub:`${Sn(e.tokens_saved)} avoided`,accent:"var(--green)"}),i.jsx(cn,{label:"API value",value:Wo(e),sub:Fa(e)?"API value":"model unpriced",accent:"var(--green)"}),i.jsx(cn,{label:"router calls",value:Sn(e.router_calls),sub:"cached reads",accent:"var(--ink2)"}),i.jsx(cn,{label:"live tokens",value:n!=null&&n.available?Jt(n.total_tokens):"n/a",sub:n!=null&&n.available?"native telemetry":"not captured",accent:Pa(e.agent||e.runtime)})]}),i.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:10,background:"white"},children:[i.jsx(Yn,{children:"Pricing"}),i.jsx("div",{style:{fontSize:12,color:"var(--ink)",marginTop:5},children:kp(e)}),(o=e.pricing)!=null&&o.source?i.jsx("a",{href:e.pricing.source,target:"_blank",rel:"noreferrer",style:{display:"inline-block",marginTop:7,fontFamily:"var(--mono)",fontSize:10,color:"var(--accent)"},children:"official pricing source"}):null]}),n!=null&&n.available?i.jsx(yv,{row:e}):null,i.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:10,background:"white"},children:[i.jsx(Yn,{children:"Read savings by tool"}),r.length===0?i.jsx("div",{style:{color:"var(--ink3)",fontSize:12,marginTop:7},children:"No cached reads yet."}):i.jsx("div",{style:{display:"grid",gap:6,marginTop:8},children:r.map(([l,s])=>i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:10,fontFamily:"var(--mono)",fontSize:11},children:[i.jsx("span",{style:{color:"var(--ink2)"},children:l}),i.jsxs("span",{style:{color:"var(--ink)"},children:[Sn(s)," calls"]})]},l))})]})]})}function yv({row:e}){const t=e.live_usage;if(!(t!=null&&t.available))return i.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:12,background:"white"},children:[i.jsx(Yn,{children:"Live token usage"}),i.jsx("div",{style:{color:"var(--ink3)",fontSize:12,marginTop:8},children:"No exact live token report captured for this session yet."})]});const n=[["Input",t.input_tokens],["Cached input",t.cached_input_tokens],["Output",t.output_tokens],["Reasoning",t.reasoning_output_tokens],["Last turn",t.last_turn_tokens],["Context",t.context_window]];return i.jsxs("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:12,background:"white"},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[i.jsx(Yn,{children:"Live token usage"}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--green)",whiteSpace:"nowrap"},children:"exact"})]}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:9,marginTop:10},children:n.map(([r,o])=>i.jsx(Un,{label:r,value:Jt(o)},r))}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginTop:10},children:[t.source||"native telemetry"," - updated ",Ao(t.updated_at||e.updated_at)]})]})}function Xu({title:e,sub:t,action:n,children:r}){return i.jsxs("section",{style:{border:"1px solid var(--border)",background:"var(--bg)",borderRadius:8,padding:16,minWidth:0,boxSizing:"border-box"},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline",marginBottom:12},children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsx(Yn,{children:e}),t?i.jsx("div",{style:{marginTop:4,color:"var(--ink3)",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}):null]}),n?i.jsx("div",{style:{flexShrink:0},children:n}):null]}),r]})}function cn({label:e,value:t,sub:n,accent:r}){return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",borderRadius:6,padding:11,minWidth:0},children:[i.jsx(Yn,{children:e}),i.jsx("div",{style:{marginTop:7,fontFamily:"var(--mono)",fontSize:22,lineHeight:1.05,fontWeight:700,color:r,overflow:"hidden",textOverflow:"ellipsis"},children:t}),n?i.jsx("div",{style:{color:"var(--ink3)",fontSize:11,marginTop:4},children:n}):null]})}function Un({label:e,value:t}){return i.jsxs("div",{className:"router-mini-stat",style:{minWidth:0},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:3},children:e}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:14,fontWeight:700,color:"var(--ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:t,children:t})]})}function Ho({agent:e}){const t=Pa(e);return i.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontFamily:"var(--mono)",fontSize:10,color:t,textTransform:"uppercase",letterSpacing:"0.06em"},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:999,background:t,flexShrink:0}}),sv(e)]})}function qu({state:e,active:t}){const n=t?"var(--green)":"var(--ink3)";return i.jsx("span",{style:{border:`1px solid ${n}`,color:n,borderRadius:4,padding:"1px 6px",fontSize:10},children:t?"active":e||"n/a"})}function wp({children:e}){return i.jsx("div",{style:{border:"1px dashed var(--border)",color:"var(--ink3)",background:"white",borderRadius:6,padding:18,textAlign:"center",fontSize:12},children:e})}function Yn({children:e}){return i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",letterSpacing:"0.08em",textTransform:"uppercase",fontWeight:700},children:e})}function Rn({children:e,align:t}){return i.jsx("th",{style:{padding:"8px 10px",textAlign:t||"left",color:"var(--ink2)",fontWeight:700,letterSpacing:"0.04em",borderBottom:"1px solid var(--border)",whiteSpace:"nowrap"},children:e})}function Pn({children:e,align:t,title:n}){return i.jsx("td",{title:n,style:{padding:"8px 10px",textAlign:t||"left",color:"var(--ink2)",verticalAlign:"middle"},children:e})}function xv({tasks:e,projectIndex:t,onSelectTask:n,onSelectSession:r,tweaks:o}){var y,S,w,T,V,m,u,f;const l={green:"var(--green)",indigo:"var(--indigo)",orange:"var(--accent)",rose:"var(--rose)"},s=((y=t==null?void 0:t.workspaces)==null?void 0:y.find(p=>p.id===(t==null?void 0:t.currentWorkspaceId)))||((S=t==null?void 0:t.workspaces)==null?void 0:S[0])||null,a=((w=s==null?void 0:s.projects)==null?void 0:w.find(p=>p.id===(t==null?void 0:t.currentProjectId)))||((T=s==null?void 0:s.projects)==null?void 0:T[0])||null,d=((V=a==null?void 0:a.sessions)==null?void 0:V.find(p=>p.id===(t==null?void 0:t.currentSessionId)))||((m=a==null?void 0:a.sessions)==null?void 0:m[0])||((u=s==null?void 0:s.sessions)==null?void 0:u.find(p=>p.id===(t==null?void 0:t.currentSessionId)))||((f=s==null?void 0:s.sessions)==null?void 0:f[0])||null,c=e.find(p=>p.id===(d==null?void 0:d.taskId))||e[0]||null,g=e.filter(p=>p.id!==(c==null?void 0:c.id)),h=p=>i.jsxs("button",{onClick:()=>n(p.id),style:{display:"grid",gridTemplateColumns:"12px minmax(0, 1fr) 18px",alignItems:"center",gap:14,padding:"14px 0",borderBottom:"1px solid var(--border)",textAlign:"left",background:"transparent"},children:[i.jsx("span",{style:{width:10,height:10,background:l[p.color]||"var(--accent)",display:"inline-block"}}),i.jsxs("span",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:16,fontWeight:560,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.title}),i.jsxs("div",{style:{marginTop:4,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",display:"flex",gap:10,flexWrap:"wrap"},children:[o.showTimestamps&&i.jsx("span",{children:p.created}),i.jsxs("span",{children:[p.messages.length," msgs"]}),p.harness&&i.jsx("span",{children:p.harness})]})]}),i.jsx("span",{style:{color:"var(--ink3)",fontSize:18},children:"→"})]},p.id);return i.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{height:48,borderBottom:"1px solid var(--border)",padding:"0 24px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink3)",letterSpacing:"0.08em"},children:"TASKS"}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[e.length," tracked tasks"]})]}),i.jsxs("div",{style:{flex:1,overflow:"auto",padding:24,display:"grid",gap:20},children:[d&&i.jsxs("div",{onClick:()=>r(d.id,d.taskId||null),style:{border:"1px solid var(--green)",background:"white",padding:18,cursor:"pointer"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10,flexWrap:"wrap"},children:[i.jsx("span",{style:{width:9,height:9,background:"var(--green)",display:"inline-block"}}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"LIVE TASK"}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--accent)"},children:d.runtime})]}),i.jsx("div",{style:{fontSize:24,fontWeight:650,lineHeight:1.2},children:(c==null?void 0:c.title)||d.title}),i.jsx("div",{style:{marginTop:8,fontSize:13,color:"var(--ink2)",lineHeight:1.5},children:d.preview||"Current mirrored session is ready to continue."})]}),i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:18},children:[i.jsx("div",{style:{marginBottom:12,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"TASK HISTORY"}),i.jsxs("div",{style:{display:"grid",gap:0},children:[g.length===0&&i.jsx("div",{style:{padding:"36px 0",textAlign:"center",fontFamily:"var(--mono)",fontSize:11,color:"var(--ink3)"},children:"No task history yet."}),g.map(h)]})]})]})]})}function Sv({url:e,title:t,lines:n}){const[r,o]=v.useState(!0);return i.jsxs("div",{style:{border:"1px solid var(--border)",marginTop:8,background:"white"},children:[i.jsxs("div",{onClick:()=>o(l=>!l),style:{borderBottom:r?"1px solid var(--border)":"none",padding:"6px 10px",display:"flex",alignItems:"center",gap:8,background:"var(--surface)",cursor:"pointer"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:1},children:"BROWSER"}),i.jsx("span",{style:{flex:1,fontFamily:"var(--mono)",fontSize:10,color:"var(--ink2)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),i.jsx("span",{style:{fontSize:10,color:"var(--ink3)"},children:r?"▲":"▼"})]}),r&&i.jsxs("div",{style:{padding:"10px 12px"},children:[i.jsx("div",{style:{fontWeight:600,fontSize:13,marginBottom:8},children:t}),n.map((l,s)=>i.jsxs("div",{style:{display:"flex",gap:7,marginBottom:3},children:[i.jsx("span",{style:{color:"var(--accent)",fontFamily:"var(--mono)",fontSize:9,marginTop:2,flexShrink:0},children:"→"}),i.jsx("span",{style:{color:"var(--ink2)",fontSize:12.5,lineHeight:1.4},children:l})]},s))]})]})}function kv({query:e,files:t}){return i.jsxs("div",{style:{border:"1px solid var(--border)",marginTop:8,background:"white"},children:[i.jsxs("div",{style:{borderBottom:"1px solid var(--border)",padding:"6px 10px",display:"flex",gap:8,alignItems:"center",background:"var(--surface)"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:1},children:"GREP"}),i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--accent)"},children:['"',e,'"']}),i.jsxs("span",{style:{marginLeft:"auto",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[t.length," matches"]})]}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11.5},children:t.map((n,r)=>i.jsxs("div",{style:{padding:"8px 12px",borderBottom:ri.jsx("div",{style:{color:n.c==="comment"?"oklch(0.5 0.01 260)":n.c==="bad"?"var(--rose)":n.c==="good"?"var(--green-mid)":"oklch(0.88 0.01 260)"},children:n.t||" "},r))})]})}function wv({title:e,lines:t}){return i.jsxs("div",{style:{border:"1px solid var(--border)",marginTop:8,background:"white"},children:[i.jsxs("div",{style:{borderBottom:"1px solid var(--border)",padding:"6px 12px",display:"flex",gap:8,alignItems:"center",background:"var(--surface)"},children:[i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:1},children:"DOCUMENT"}),i.jsx("span",{style:{fontSize:11,fontWeight:500,fontFamily:"var(--mono)",color:"var(--ink2)"},children:e})]}),i.jsx("div",{style:{padding:"12px 16px",fontSize:13,lineHeight:1.65},children:t.map((n,r)=>typeof n=="object"&&"h"in n?i.jsx("div",{style:{fontWeight:700,marginTop:r>0?12:0,marginBottom:3,fontSize:10.5,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--ink2)"},children:n.h},r):i.jsx("div",{style:{color:"var(--ink)"},children:n},r))})]})}function _v({linkedTask:e,preview:t,tasks:n,onSelectTask:r}){const o=n.find(a=>a.id===e);if(!o)return null;const s={green:"var(--green)",indigo:"var(--indigo)",orange:"var(--accent)",rose:"var(--rose)"}[o.color]||"var(--accent)";return i.jsxs("div",{onClick:()=>r(o.id),style:{border:`1px solid ${s}`,marginTop:8,cursor:"pointer",display:"flex",gap:12,padding:"9px 12px",background:"white",transition:"background 0.12s"},onMouseEnter:a=>a.currentTarget.style.background="var(--surface)",onMouseLeave:a=>a.currentTarget.style.background="white",children:[i.jsx("div",{style:{width:8,height:8,background:s,flexShrink:0,marginTop:3}}),i.jsxs("div",{style:{flex:1},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:1,marginBottom:2},children:"LINKED TASK"}),i.jsx("div",{style:{fontWeight:500,fontSize:13},children:o.title}),i.jsx("div",{style:{fontSize:11,color:"var(--ink2)",marginTop:2},children:t})]}),i.jsx("div",{style:{color:s,fontSize:15,alignSelf:"center"},children:"→"})]})}function Zu({msg:e,tasks:t,onSelectTask:n}){if(e.role==="component"){const o=e;return i.jsxs("div",{style:{marginBottom:14,paddingLeft:14},children:[o.type==="browser"&&i.jsx(Sv,{url:o.url,title:o.title,lines:o.lines}),o.type==="grep"&&i.jsx(kv,{query:o.query,files:o.files}),o.type==="code"&&i.jsx(jv,{lang:o.lang,lines:o.lines}),o.type==="document"&&i.jsx(wv,{title:o.title,lines:o.lines}),o.type==="link"&&i.jsx(_v,{linkedTask:o.linkedTask,preview:o.preview,tasks:t,onSelectTask:n})]})}const r=e.role==="user";return i.jsxs("div",{style:{marginBottom:13,display:"flex",flexDirection:"column",alignItems:r?"flex-end":"flex-start"},children:[!r&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:4},children:[i.jsx("div",{style:{width:5,height:5,background:"var(--green)",borderRadius:"50%"}}),i.jsx("span",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",letterSpacing:1},children:"AGENT"})]}),i.jsx("div",{style:{maxWidth:"88%",padding:"9px 13px",background:r?"var(--ink)":"white",color:r?"var(--bg)":"var(--ink)",border:r?"none":"1px solid var(--border)",fontSize:13.5,lineHeight:1.6,whiteSpace:"pre-wrap"},children:e.content})]})}function bv(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function Cv(e){var t;return e?((t=e.currentSession)==null?void 0:t.state)==="active"?"session live":e.installed?"installed":"not attached":"No runtime selected"}function Ev(e){const t=(e==null?void 0:e.mounts)||(e==null?void 0:e.folders)||[],n=t.find(r=>r.primary)||t[0];return(n==null?void 0:n.path)||(e==null?void 0:e.rootPath)||(e==null?void 0:e.workspacePath)||""}function Tv({tasks:e,activeTaskId:t,selectedProjectId:n,selectedWorkspaceId:r,selectedSessionId:o,projectIndex:l,workspaceGraph:s,onSelectTask:a,onSelectSession:d,onSelectProject:c,onCanvasOpen:g,onNotepadOpen:h,onAddTaskNote:y,onUpdateWorkspace:S,onAddWorkspaceFolder:w,onRemoveWorkspaceFolder:T,onCreateProject:V,onUpdateProject:m,onTasksRefresh:u,tweaks:f}){var Oa,$a,Da,Ma,Ia,Ba,Aa,Ua,Wa,Ha,Va,Ka,Qa,Ya,Ja,Xa,qa,Za,Ga,ed,td,nd,rd,id,od,ld,sd,ad,dd,ud,cd,fd;const[p,j]=v.useState(null),[E,P]=v.useState([]),[z,Y]=v.useState(""),[N,J]=v.useState(!1),[X,Q]=v.useState(!1),[G,I]=v.useState(null),[U,se]=v.useState(null),[_,W]=v.useState(""),[K,ee]=v.useState(!1),[ie,M]=v.useState(""),[pe,ae]=v.useState(""),[me,$]=v.useState(""),[ue,fe]=v.useState(""),[ge,Ee]=v.useState("codex"),[R,oe]=v.useState(""),[q,te]=v.useState(""),[Ae,Lt]=v.useState("codex"),[xe,Ue]=v.useState(!1),[we,Oe]=v.useState(null),Cn=v.useRef(null),Ut=v.useRef(null),Z=((Oa=l==null?void 0:l.workspaces)==null?void 0:Oa.find(x=>x.id===r))||(($a=l==null?void 0:l.workspaces)==null?void 0:$a.find(x=>x.id===(s==null?void 0:s.currentWorkspaceId)))||((Da=l==null?void 0:l.workspaces)==null?void 0:Da[0])||(s==null?void 0:s.workspace)||null,de=((Ma=Z==null?void 0:Z.projects)==null?void 0:Ma.find(x=>x.id===n))||((Ia=Z==null?void 0:Z.projects)==null?void 0:Ia.find(x=>x.id===(s==null?void 0:s.currentProjectId)))||((Ba=Z==null?void 0:Z.projects)==null?void 0:Ba[0])||null,ke=((Aa=de==null?void 0:de.sessions)==null?void 0:Aa.find(x=>x.id===o))||((Ua=de==null?void 0:de.sessions)==null?void 0:Ua.find(x=>x.id===(s==null?void 0:s.currentSessionId)))||((Wa=de==null?void 0:de.sessions)==null?void 0:Wa[0])||((Ha=Z==null?void 0:Z.sessions)==null?void 0:Ha.find(x=>x.id===o))||((Va=Z==null?void 0:Z.sessions)==null?void 0:Va.find(x=>x.id===(s==null?void 0:s.currentSessionId)))||((Ka=Z==null?void 0:Z.sessions)==null?void 0:Ka[0])||null,le=((Qa=l==null?void 0:l.workspaces)==null?void 0:Qa.find(x=>x.id===(ie||(Z==null?void 0:Z.id))))||Z||null,Te=((Ya=le==null?void 0:le.projects)==null?void 0:Ya.find(x=>x.id===(pe||(de==null?void 0:de.id))))||((Ja=le==null?void 0:le.projects)==null?void 0:Ja[0])||null;v.useEffect(()=>{Z&&!ie&&M(Z.id)},[Z,ie]),v.useEffect(()=>{var x;le&&!le.projects.some(re=>re.id===pe)&&ae(((x=le.projects[0])==null?void 0:x.id)||"")},[le,pe]),v.useEffect(()=>{le&&$(le.label||le.name)},[le==null?void 0:le.id]),v.useEffect(()=>{de&&fe(de.name)},[de==null?void 0:de.id]),v.useEffect(()=>{Te&&(fe(Te.name),Ee(Te.defaultRuntime==="claude-code"?"claude-code":"codex"),oe((Te.scopeRules||[]).map(x=>x.pathPrefix).filter(Boolean).join(` +`)))},[Te==null?void 0:Te.id]);const Ot=async x=>{var $e,pd;const re=x||(ke==null?void 0:ke.id);if(re)try{const zr=await A.sessionDetail(re);j(zr),P((($e=zr.runtime)==null?void 0:$e.runtimes)||[]),I(((pd=zr.files)==null?void 0:pd[0])||null),se(null),Oe(null)}catch(zr){Oe(String(zr))}},{messages:qn}=vp(Z==null?void 0:Z.id,de==null?void 0:de.id);v.useEffect(()=>{Ot(o||(ke==null?void 0:ke.id))},[o,Z==null?void 0:Z.id]),v.useEffect(()=>{const x=window.setInterval(()=>{Ot(o||(ke==null?void 0:ke.id))},5e3);return()=>window.clearInterval(x)},[o,ke==null?void 0:ke.id]),v.useEffect(()=>{var x;(x=Cn.current)==null||x.focus()},[(Xa=p==null?void 0:p.session)==null?void 0:Xa.id]);const b=e.find(x=>x.id===t)||null,C=(p==null?void 0:p.task)||b||null,k=v.useMemo(()=>{var x,re,$e;return(re=(x=p==null?void 0:p.session)==null?void 0:x.messages)!=null&&re.length?p.session.messages:($e=C==null?void 0:C.messages)!=null&&$e.length?C.messages:[]},[(qa=p==null?void 0:p.session)==null?void 0:qa.messages,C]),O=v.useMemo(()=>{var x;return(x=p==null?void 0:p.session)!=null&&x.runtime?E.filter(re=>re.id===p.session.runtime):E},[(Za=p==null?void 0:p.session)==null?void 0:Za.runtime,E]),B=async()=>{var re;const x=z.trim();if(!(!x||!C||N)){J(!0);try{await y(C.id,x),Y(""),await u(),await Ot((re=p==null?void 0:p.session)==null?void 0:re.id)}catch($e){Oe(String($e))}finally{J(!1)}}},ne=async x=>{var re;if(!(!x||!((re=p==null?void 0:p.session)!=null&&re.id))){Q(!0);try{await A.uploadSessionAsset(p.session.id,x),await Ot(p.session.id)}catch($e){Oe(String($e))}finally{Q(!1),Ut.current&&(Ut.current.value="")}}},ye=async x=>{try{const re=await A.assetContext(x);se(re)}catch(re){Oe(String(re))}},Ye=()=>{var x,re;Z&&(M(Z.id),$(Z.label||Z.name),ae((de==null?void 0:de.id)||((re=(x=Z.projects)==null?void 0:x[0])==null?void 0:re.id)||"")),ee(!0),Oe(null)},at=async()=>{if(!(!le||!me.trim()||xe)){Ue(!0);try{await S(le.id,me.trim()),Oe(null)}catch(x){Oe(String(x))}finally{Ue(!1)}}},Ve=async()=>{if(!(!le||xe)){Ue(!0),Oe(null);try{const x=await A.pickFolder("Select a folder to mount in this workspace");x.ok&&x.path&&await w(le.id,x.path)}catch(x){Oe(String(x))}finally{Ue(!1)}}},Zn=async x=>{if(!(!le||xe)){Ue(!0),Oe(null);try{await T(le.id,x)}catch(re){Oe(String(re))}finally{Ue(!1)}}},_p=async()=>{if(!Te||xe)return;const x=R.split(` +`).map(re=>re.trim()).filter(Boolean).map((re,$e)=>({path_prefix:re,label:$e===0?"primary":`scope-${$e+1}`}));Ue(!0),Oe(null);try{await m(Te.id,{name:ue.trim()||Te.name,default_runtime:ge,scope_rules:x})}catch(re){Oe(String(re))}finally{Ue(!1)}};return!de||!Z||!ke?i.jsx("div",{style:{height:"100%",display:"grid",alignItems:"center",justifyContent:"center",padding:28},children:i.jsx(xp,{title:"No mirrored workspace session yet",body:"Add a repo folder or start a task from an existing workspace. Once an agent session is mirrored, this view becomes the working console.",actions:[{label:"ADD REPO FOLDER",onClick:g,tone:"primary"},{label:"START TASK",onClick:h}]})}):i.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[i.jsxs("div",{style:{borderBottom:"1px solid var(--border)",padding:"0 14px",height:48,display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0,flex:1},children:[i.jsxs("span",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:[Z.label||Z.name," / ",de.name]}),i.jsx("span",{style:{fontSize:14,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((Ga=p==null?void 0:p.session)==null?void 0:Ga.title)||ke.title}),i.jsx(Ie,{label:`${((ed=p==null?void 0:p.session)==null?void 0:ed.runtime)||ke.runtime}`.replace("-"," "),tone:"var(--green)"}),i.jsx(Ie,{label:((td=p==null?void 0:p.session)==null?void 0:td.permissionMode)||ke.permissionMode||"native"}),i.jsx(Ie,{label:((nd=p==null?void 0:p.session)==null?void 0:nd.state)||ke.state})]}),i.jsx("button",{onClick:()=>{var x;return void Ot((x=p==null?void 0:p.session)==null?void 0:x.id)},style:{height:48,padding:"0 12px",borderLeft:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink2)"},children:"REFRESH"}),i.jsx("button",{onClick:g,style:{height:48,padding:"0 14px",borderLeft:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink2)"},children:"⊞ CANVAS"}),i.jsx("button",{onClick:Ye,style:{height:48,padding:"0 14px",borderLeft:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--ink2)"},children:"MANAGE"})]}),i.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[i.jsxs("div",{style:{width:f.compactNav?74:260,borderRight:"1px solid var(--border)",display:"flex",flexDirection:"column",overflowY:"auto"},children:[i.jsxs("div",{style:{padding:"12px 12px 10px",borderBottom:"1px solid var(--border)"},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:8},children:"WORKSPACE"}),i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:10,marginBottom:12},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:Z.label||Z.name}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",lineHeight:1.5},children:[(Z.folders||Z.mounts||[]).length," mounted folders · ",Z.sessionCount||Z.sessions.length," sessions"]}),i.jsx("button",{onClick:Ye,style:{marginTop:8,padding:"6px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--accent)"},children:"manage workspace"})]}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:8},children:"PROJECTS"}),Z.projects.map(x=>i.jsx("div",{style:{marginBottom:10},children:i.jsxs("button",{onClick:()=>c(x.id,Z.id),style:{width:"100%",textAlign:"left",padding:"8px 9px",border:`1px solid ${x.id===de.id?"var(--border2)":"var(--border)"}`,background:x.id===de.id?"var(--surface)":"white",fontSize:12,fontWeight:x.id===de.id?700:500,color:x.id===de.id?"var(--ink)":"var(--ink2)"},children:[x.name,i.jsxs("div",{style:{marginTop:4,fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[x.sessions.length," sessions · default ",x.defaultRuntime||"codex"]})]})},x.id))]}),i.jsxs("div",{style:{padding:"12px"},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:8},children:"SESSIONS"}),(de.sessions||[]).map(x=>{var re,$e;return i.jsxs("button",{onClick:()=>d(x.id,x.taskId),style:{width:"100%",textAlign:"left",padding:"9px 10px",marginBottom:8,border:`1px solid ${((re=p==null?void 0:p.session)==null?void 0:re.id)===x.id?"var(--green)":"var(--border)"}`,background:(($e=p==null?void 0:p.session)==null?void 0:$e.id)===x.id?"oklch(0.98 0.02 145)":"white"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:x.title}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[x.runtime," · ",x.model||"unknown model"]}),i.jsx("div",{style:{fontSize:10.5,color:"var(--ink3)",marginTop:6,lineHeight:1.4},children:x.preview||"No preview yet."})]},x.id)})]})]}),i.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[i.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--border)",display:"flex",gap:8,flexWrap:"wrap"},children:[i.jsx(Ie,{label:((rd=p==null?void 0:p.session)==null?void 0:rd.runtime)||ke.runtime,tone:"var(--green)"}),i.jsx(Ie,{label:((id=p==null?void 0:p.session)==null?void 0:id.taskStatus)||(C==null?void 0:C.status)||"mirrored"}),i.jsx(Ie,{label:`${((ld=(od=p==null?void 0:p.session)==null?void 0:od.touchedFiles)==null?void 0:ld.length)||0} files`}),i.jsx(Ie,{label:`${((sd=p==null?void 0:p.assets)==null?void 0:sd.length)||0} assets`}),i.jsx(Ie,{label:`${((ad=p==null?void 0:p.results)==null?void 0:ad.length)||0} shared results`})]}),i.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 18px 8px"},children:[k.length===0&&i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink3)"},children:"No mirrored messages yet."}),k.map(x=>i.jsx(Zu,{msg:x,tasks:e,onSelectTask:a},x.id)),(dd=p==null?void 0:p.results)==null?void 0:dd.slice(0,8).map(x=>i.jsx(Zu,{msg:{id:`result:${x.id}`,role:"agent",content:`${x.tool_name}: ${x.digest||"No digest recorded."}`},tasks:e,onSelectTask:a},x.id)),i.jsx("div",{style:{height:1}})]}),i.jsxs("div",{style:{borderTop:"1px solid var(--border)",padding:"12px 16px"},children:[i.jsx("textarea",{ref:Cn,value:z,onChange:x=>Y(x.target.value),placeholder:C?"Add a Dhee note to this session task…":"This mirrored session has no linked Dhee task yet.",rows:3,disabled:!C,style:{width:"100%",fontFamily:"var(--font)",fontSize:14,lineHeight:1.5,border:"1px solid var(--border)",padding:"12px 14px",background:C?"white":"var(--surface)"}}),i.jsxs("div",{style:{marginTop:10,display:"flex",gap:10,alignItems:"center"},children:[i.jsx("button",{onClick:()=>void B(),disabled:!C||N,style:{padding:"7px 14px",border:"1px solid var(--ink)",background:C?"var(--ink)":"transparent",color:C?"white":"var(--ink3)",fontFamily:"var(--mono)",fontSize:10},children:N?"saving…":"save note"}),we&&i.jsx("span",{style:{fontSize:11,color:"var(--rose)"},children:we})]})]})]}),i.jsxs("div",{style:{width:320,borderLeft:"1px solid var(--border)",overflowY:"auto",padding:"14px 14px 18px"},children:[i.jsxs("div",{style:{marginBottom:18},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:10},children:"RUNTIME"}),O.map(x=>{var re,$e;return i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:12,marginBottom:10},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,marginBottom:6},children:[i.jsx("div",{style:{fontSize:12.5,fontWeight:600},children:x.label}),i.jsx(Ie,{label:Cv(x),tone:x.installed?"var(--green)":"var(--rose)"})]}),i.jsx("div",{style:{fontSize:11,color:"var(--ink2)"},children:((re=x.currentSession)==null?void 0:re.title)||(($e=x.currentSession)==null?void 0:$e.cwd)||"No active session"}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:6},children:["limit: ",x.limits.state,x.limits.resetAt?` · reset ${bv(x.limits.resetAt)}`:""]})]},x.id)})]}),i.jsxs("div",{style:{marginBottom:18},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:10},children:"COLLABORATION LINE"}),i.jsx(gp,{workspace:Z,activeProjectId:de==null?void 0:de.id,sessionId:((ud=p==null?void 0:p.session)==null?void 0:ud.id)||(ke==null?void 0:ke.id),taskId:C==null?void 0:C.id,onPublished:async()=>{await u()}}),i.jsx("div",{style:{display:"grid",gap:8,marginTop:10},children:(qn||[]).slice(0,8).map(x=>i.jsx(mp,{message:x,workspace:Z},x.id))})]}),i.jsxs("div",{style:{marginBottom:18},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:10},children:"FILE CONTEXT"}),(cd=p==null?void 0:p.files)==null?void 0:cd.map(x=>i.jsxs("button",{onClick:()=>I(x),style:{width:"100%",textAlign:"left",padding:"10px 11px",border:`1px solid ${(G==null?void 0:G.path)===x.path?"var(--indigo)":"var(--border)"}`,background:"white",marginBottom:8},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:x.path.split("/").pop()}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[x.results.length," results · ",x.memories.length," memories"]})]},x.path)),G&&i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:12},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:G.path}),i.jsx("div",{style:{fontSize:11,color:"var(--ink2)",lineHeight:1.5,marginBottom:8},children:G.summary||"No stored summary yet."}),G.results.slice(0,3).map(x=>i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6},children:[x.tool_name,": ",String(x.digest||"").slice(0,120)]},x.id))]})]}),i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:"SESSION ASSETS"}),i.jsx("button",{onClick:()=>{var x;return(x=Ut.current)==null?void 0:x.click()},style:{padding:"4px 10px",border:"1px solid var(--border)",fontFamily:"var(--mono)",fontSize:9,color:"var(--accent)"},children:X?"uploading…":"upload"})]}),i.jsx("input",{ref:Ut,type:"file",hidden:!0,onChange:x=>{var re;return void ne((re=x.target.files)==null?void 0:re[0])}}),(fd=p==null?void 0:p.assets)==null?void 0:fd.map(x=>i.jsxs("button",{onClick:()=>void ye(x.id),style:{width:"100%",textAlign:"left",border:"1px solid var(--border)",background:"white",padding:12,marginBottom:8},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:x.name}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[x.mime_type||"file"," · ",(x.size_bytes||0).toLocaleString()," bytes"]})]},x.id)),U&&i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:12,marginTop:10},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:U.asset.name}),i.jsx("div",{style:{fontSize:11,color:"var(--ink2)",lineHeight:1.5,marginBottom:8},children:U.summary||"No extracted summary yet. Re-upload or parse this asset to make it queryable."}),(U.chunks||[]).slice(0,3).map(x=>i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginBottom:6},children:["chunk ",x.chunk_index,": ",x.content.slice(0,180)]},`${U.asset.id}:${x.chunk_index}`)),i.jsx("textarea",{value:_,onChange:x=>W(x.target.value),placeholder:"Ask Dhee about this asset…",rows:3,style:{width:"100%",border:"1px solid var(--border)",padding:"10px 12px",marginTop:8,background:"var(--bg)"}}),i.jsx("button",{onClick:async()=>{var x;if(_.trim())try{const re=await A.askAsset(U.asset.id,_.trim());W(""),(x=re.launch)!=null&&x.session_id&&d(re.launch.session_id,re.launch.task_id||null)}catch(re){Oe(String(re))}},style:{marginTop:8,padding:"8px 12px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10},children:"ask with default claude code"})]})]})]})]}),K&&de&&le&&i.jsx("div",{onClick:()=>ee(!1),style:{position:"fixed",inset:0,background:"rgba(12, 12, 12, 0.22)",display:"flex",alignItems:"center",justifyContent:"center",padding:24,zIndex:80},children:i.jsxs("div",{onClick:x=>x.stopPropagation(),style:{width:"min(1040px, calc(100vw - 80px))",maxHeight:"calc(100vh - 80px)",background:"var(--bg)",border:"1px solid var(--border2)",display:"grid",gridTemplateColumns:"280px minmax(0, 1fr)",overflow:"hidden",boxShadow:"0 30px 80px rgba(0,0,0,0.12)"},children:[i.jsxs("div",{style:{borderRight:"1px solid var(--border)",background:"white",overflowY:"auto"},children:[i.jsxs("div",{style:{padding:16,borderBottom:"1px solid var(--border)"},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"WORKSPACES"}),i.jsx("div",{style:{marginTop:6,fontSize:13,fontWeight:600},children:"switch workspace"})]}),i.jsx("div",{style:{padding:12},children:((l==null?void 0:l.workspaces)||[]).map(x=>i.jsxs("button",{onClick:()=>{var re,$e;M(x.id),ae((($e=(re=x.projects)==null?void 0:re[0])==null?void 0:$e.id)||"")},style:{width:"100%",textAlign:"left",padding:"10px 12px",marginBottom:8,border:`1px solid ${x.id===le.id?"var(--accent)":"var(--border)"}`,background:x.id===le.id?"rgba(224, 107, 63, 0.06)":"white"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:x.label||x.name}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)"},children:[x.sessionCount||x.sessions.length," sessions · ",(x.folders||x.mounts||[]).length," folders"]})]},x.id))})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{padding:"16px 18px",borderBottom:"1px solid var(--border)",background:"white",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[i.jsxs("div",{children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"WORKSPACE SETTINGS"}),i.jsx("div",{style:{marginTop:6,fontSize:18,fontWeight:650},children:le.label||le.name})]}),i.jsx("button",{onClick:()=>ee(!1),style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"close"})]}),i.jsxs("div",{style:{flex:1,overflowY:"auto",padding:18},children:[i.jsxs("div",{style:{marginBottom:24},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginBottom:10},children:"RENAME"}),i.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[i.jsx("input",{value:me,onChange:x=>$(x.target.value),placeholder:"Workspace name",style:{flex:1,border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:14}}),i.jsx("button",{onClick:()=>void at(),disabled:!me.trim()||xe,style:{padding:"10px 12px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10,opacity:!me.trim()||xe?.6:1},children:xe?"saving...":"save name"})]})]}),i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12,marginBottom:10},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)"},children:"MOUNTED FOLDERS"}),i.jsx("button",{onClick:()=>void Ve(),disabled:xe,style:{padding:"8px 10px",border:"1px solid var(--border)",background:"white",fontFamily:"var(--mono)",fontSize:9,color:"var(--accent)"},children:xe?"working...":"add folder"})]}),i.jsx("div",{style:{display:"grid",gap:10},children:(le.folders||le.mounts||[]).map(x=>i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:12,display:"flex",justifyContent:"space-between",gap:12,alignItems:"flex-start"},children:[i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:x.primary?"root folder":x.label}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",lineHeight:1.5,wordBreak:"break-all"},children:x.path})]}),i.jsx("button",{onClick:()=>void Zn(x.path),disabled:xe||(le.folders||le.mounts||[]).length<=1,style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--rose)",opacity:xe||(le.folders||le.mounts||[]).length<=1?.5:1},children:"remove"})]},x.path))}),i.jsx("div",{style:{marginTop:10,fontSize:11,color:"var(--ink3)",lineHeight:1.5},children:"Sessions are included in this workspace by matching their working directory against these mounted folders. Removing a folder removes those sessions from this workspace view without deleting the mirrored session record."})]}),i.jsxs("div",{style:{marginTop:24},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginBottom:10},children:"PROJECTS"}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"240px minmax(0, 1fr)",gap:14},children:[i.jsx("div",{style:{display:"grid",gap:10,alignContent:"start"},children:(le.projects||[]).map(x=>i.jsxs("button",{onClick:()=>ae(x.id),style:{width:"100%",textAlign:"left",border:`1px solid ${x.id===(Te==null?void 0:Te.id)?"var(--accent)":"var(--border)"}`,background:x.id===(Te==null?void 0:Te.id)?"rgba(224, 107, 63, 0.06)":"white",padding:12},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600},children:x.name}),i.jsxs("div",{style:{fontFamily:"var(--mono)",fontSize:9,color:"var(--ink3)",marginTop:4},children:[x.sessions.length," sessions · default ",x.defaultRuntime||"codex"]})]},x.id))}),i.jsxs("div",{style:{display:"grid",gap:12,alignContent:"start"},children:[Te?i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginBottom:10},children:"EDIT PROJECT"}),i.jsxs("div",{style:{display:"grid",gap:10},children:[i.jsx("input",{value:ue,onChange:x=>fe(x.target.value),placeholder:"Project name",style:{border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:14}}),i.jsxs("select",{value:ge,onChange:x=>Ee(x.target.value),style:{border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:14},children:[i.jsx("option",{value:"codex",children:"Codex default runtime"}),i.jsx("option",{value:"claude-code",children:"Claude Code default runtime"})]}),i.jsx("textarea",{value:R,onChange:x=>oe(x.target.value),rows:5,placeholder:"One path scope rule per line",style:{border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:13,lineHeight:1.5}}),i.jsx("div",{style:{fontSize:11,color:"var(--ink3)",lineHeight:1.5},children:"Sessions are assigned to this project by the longest matching scope rule path."}),i.jsx("button",{onClick:()=>void _p(),disabled:xe||!ue.trim(),style:{justifySelf:"start",padding:"10px 12px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10,opacity:xe||!ue.trim()?.6:1},children:xe?"saving...":"save project"})]})]}):null,i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:14},children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",marginBottom:10},children:"ADD PROJECT"}),i.jsxs("div",{style:{display:"grid",gap:10},children:[i.jsx("input",{value:q,onChange:x=>te(x.target.value),placeholder:"New project name",style:{border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:14}}),i.jsxs("select",{value:Ae,onChange:x=>Lt(x.target.value),style:{border:"1px solid var(--border)",padding:"10px 12px",background:"white",fontSize:14},children:[i.jsx("option",{value:"codex",children:"Codex default runtime"}),i.jsx("option",{value:"claude-code",children:"Claude Code default runtime"})]}),i.jsx("button",{onClick:async()=>{if(!(!le||!q.trim())){Ue(!0);try{await V(le.id,{name:q.trim(),default_runtime:Ae,scope_rules:[{path_prefix:Ev(le),label:"root"}]}),te("")}catch(x){Oe(String(x))}finally{Ue(!1)}}},style:{justifySelf:"start",padding:"10px 12px",border:"1px solid var(--ink)",background:"var(--ink)",color:"white",fontFamily:"var(--mono)",fontSize:10},children:"add project"})]})]})]})]})]}),we&&i.jsx("div",{style:{marginTop:18,fontSize:11,color:"var(--rose)"},children:we})]})]})]})})]})}const zv=v.lazy(()=>tg(()=>import("./CanvasView-Cl1HxIK0.js"),[]).then(e=>({default:e.CanvasView}))),Nv={accentHue:"36",compactNav:!1,showTimestamps:!0,canvasStyle:"force"},Rv=15e3,Pv=new Set(["command","handoff","replay","learnings","portability"]);function Gi(e){return Pv.has(e)}function Al(e){return e==="canvas"}function Ul(e){return e==="router"||e==="router/sessionshistory"}function eo(e){const t=String(e||"").toLowerCase();return t==="home"||t==="overview"?"command":t==="memory"?"context":t==="firewall"||t==="context-firewall"?"router":t==="repo"||t==="brain"||t==="repo-brain"||t==="folders"?"canvas":t==="learn"||t==="learning"?"learnings":t==="packs"||t==="portable"||t==="trust"?"portability":t==="inbox"||t==="review"||t==="queue"?"conflicts":t==="router/sessionshistory"||t==="router/session-history"||t==="router/history"?"router/sessionshistory":t||"command"}function Ur(e){return typeof window>"u"?"":new URLSearchParams(window.location.search).get(e)||""}function Fv(){const[e,t]=v.useState(()=>eo(Ur("view"))),[n,r]=v.useState(!1),[o,l]=v.useState("workspaces"),[s,a]=v.useState([]),[d,c]=v.useState(()=>Ur("task")),[g,h]=v.useState(Nv),[y,S]=v.useState(!1),[w,T]=v.useState(0),[V,m]=v.useState([]),[u,f]=v.useState(0),[p,j]=v.useState(0),[E,P]=v.useState(!1),[z,Y]=v.useState(null),[N,J]=v.useState(null),[X,Q]=v.useState(null),[G,I]=v.useState(null),[U,se]=v.useState(0),[_,W]=v.useState(null),[K,ee]=v.useState(()=>Ur("project")),[ie,M]=v.useState(()=>Ur("workspace")),[pe,ae]=v.useState(()=>Ur("session")),me=v.useRef({}),$=(k,O,B)=>{let ne="";try{ne=JSON.stringify(O)||""}catch{ne=String(Date.now())}me.current[k]!==ne&&(me.current[k]=ne,B(O))};v.useEffect(()=>{const k=new URLSearchParams(window.location.search),O=k.get("view"),B=k.get("task"),ne=k.get("project"),ye=k.get("workspace"),Ye=k.get("session");O&&t(eo(O)),B&&c(B),ne&&ee(ne),ye&&M(ye),Ye&&ae(Ye);const at=()=>{const Ve=new URLSearchParams(window.location.search);t(eo(Ve.get("view"))),c(Ve.get("task")||""),ee(Ve.get("project")||""),M(Ve.get("workspace")||""),ae(Ve.get("session")||"")};return window.addEventListener("popstate",at),()=>window.removeEventListener("popstate",at)},[]);const ue=async()=>{try{const k=await A.tasks();$("tasks",k.tasks||[],a),c(O=>{var B,ne;return O||((ne=(B=k.tasks)==null?void 0:B[0])==null?void 0:ne.id)||""})}catch{}},fe=async()=>{try{const k=ie?await A.workspaceGraph(ie,K||void 0):await A.workspaceGraph();$("workspaceGraph",k,Y)}catch{}},ge=async()=>{try{const k=await A.orgGraph(void 0,{active:!0});$("orgGraph",k,J)}catch{}},Ee=async()=>{try{const k=await A.me();$("viewer",k,Q)}catch{}},R=async()=>{try{const k=await A.routerStats();$("routerStats",k,I),f(k.sessionTokensSaved||0)}catch{}},oe=async()=>{var k,O,B,ne;try{const ye=await A.inbox(X!=null&&X.team_id?{team:X.team_id,user:X.user_id}:{user:X==null?void 0:X.user_id}),Ye=(((k=ye.totals)==null?void 0:k.proposals)||0)+(((O=ye.totals)==null?void 0:O.findings)||0)+(((B=ye.totals)==null?void 0:B.conflicts)||0);se(Ye),j(((ne=ye.totals)==null?void 0:ne.conflicts)||0)}catch{}},q=async()=>{try{const k=await A.workspaces();$("projectIndex",k,W),M(O=>{var B,ne;return O||k.currentWorkspaceId||((ne=(B=k.workspaces)==null?void 0:B[0])==null?void 0:ne.id)||""}),ee(O=>{var B,ne,ye,Ye;return O||k.currentProjectId||((Ye=(ye=(ne=(B=k.workspaces)==null?void 0:B[0])==null?void 0:ne.projects)==null?void 0:ye[0])==null?void 0:Ye.id)||""}),ae(O=>O||k.currentSessionId||"")}catch{}};v.useEffect(()=>{if(Ee(),oe(),Gi(e)||R(),Al(e))ge();else{if(Ul(e))return;Gi(e)||(ue(),ge(),q().then(()=>fe()),(async()=>{var k;try{const O=await A.listMemories();T(((k=O.engrams)==null?void 0:k.length)||0),m(O.engrams||[])}catch{}})())}},[]),v.useEffect(()=>{const k=window.setInterval(()=>{if(Gi(e)){oe();return}if(Ul(e)){R(),oe();return}if(Al(e)){ge(),oe();return}ue(),q(),fe(),ge(),R(),oe()},Rv);return()=>window.clearInterval(k)},[e,ie,K,X==null?void 0:X.team_id]),v.useEffect(()=>{if(!Gi(e)){if(Ul(e)){R(),oe();return}if(Al(e)){ge();return}ue(),q().then(()=>fe()),ge(),(async()=>{var k;try{const O=await A.listMemories();T(((k=O.engrams)==null?void 0:k.length)||0),m(O.engrams||[])}catch{}})()}},[e]);const te=(k,O)=>{const B=eo(k);P(!0),setTimeout(()=>{O&&c(O),t(B);const ne=new URLSearchParams(window.location.search);ne.set("view",B),O||d?ne.set("task",O||d):ne.delete("task"),K?ne.set("project",K):ne.delete("project"),ie?ne.set("workspace",ie):ne.delete("workspace"),pe?ne.set("session",pe):ne.delete("session");const ye=ne.toString(),Ye=ye?`?${ye}`:"",at=B==="context"&&window.location.hash.startsWith("#vault")?window.location.hash:"";window.history.pushState({},"",`${window.location.pathname}${Ye}${at}`),P(!1)},140)},Ae=k=>te("workspace",k),Lt=(k,O)=>{k&&ae(k),O&&c(O),te("workspace",O||void 0)},xe=k=>{M(k),ee(""),ae(""),te("workspace")},Ue=(k,O)=>{O&&M(O),ee(k),ae(""),te("workspace")};v.useEffect(()=>{const k=new URLSearchParams(window.location.search);k.set("view",e),d?k.set("task",d):k.delete("task"),K?k.set("project",K):k.delete("project"),ie?k.set("workspace",ie):k.delete("workspace"),pe?k.set("session",pe):k.delete("session");const O=k.toString(),B=`${window.location.pathname}${O?"?"+O:""}`;B!==`${window.location.pathname}${window.location.search}`&&window.history.replaceState({},"",B)},[e,d,K,ie,pe]);const we=async k=>{await A.createWorkspaceRoot(k),await q(),await fe()},Oe=async(k,O)=>{await A.createProject(k,O),await q(),await fe()},Cn=async(k,O)=>{await A.updateProject(k,O),await q(),await fe()},Ut=async(k,O,B)=>{await A.addWorkspaceFolder(k,O,B),await q(),await fe()},Z=async(k,O)=>{await A.updateWorkspace(k,{label:O}),await q(),await fe()},de=async(k,O)=>{await A.removeWorkspaceFolder(k,O),await q(),await fe()},ke=async k=>{try{const O=await A.createTask(k);a(B=>[...B,O.task]),await q(),setTimeout(()=>te("workspace",O.task.id),80)}catch(O){console.warn("createTask failed",O)}},le=async k=>{try{await A.remember(k,"short-term",[]),T(B=>B+1);const O=await A.listMemories();m(O.engrams||[])}catch(O){console.warn("remember failed",O)}},Te=async(k,O,B,ne,ye)=>{const Ye=B||ie||(_==null?void 0:_.currentWorkspaceId);if(!Ye||!k.trim())return;const at=await A.launchWorkspaceSession(Ye,O,k.trim(),O==="claude-code"?ne:void 0,void 0,ye||K||(_==null?void 0:_.currentProjectId));await ue(),await q(),await fe(),at.session_id&&ae(at.session_id),at.task_id&&c(at.task_id),te("workspace",at.task_id||void 0)},Ot=async(k,O)=>{try{await A.addTaskNote(k,O),await ue(),await q()}catch(B){console.warn("addTaskNote failed",B)}},qn={opacity:E?0:1,transform:E?"translateY(3px)":"translateY(0)",transition:"opacity 0.14s ease, transform 0.14s ease",flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},b=()=>e==="command"?i.jsx(Xg,{onNavigate:k=>te(k)}):e==="channel"?i.jsx(jg,{projectIndex:_,workspaceGraph:z,tasks:s,viewer:X,orgGraph:N,selectedWorkspaceId:ie,selectedProjectId:K,onSelectWorkspace:xe,onSelectProject:Ue,onSelectTask:Ae,onTasksRefresh:ue,onOpenCanvas:()=>te("canvas"),onLaunchSession:Te,onOpenManager:k=>{l(k||"workspaces"),r(!0)},tweaks:g}):e==="notepad"?i.jsx(Kg,{projectIndex:_,memories:w,tokensSaved:u,onAddTask:ke,onAddMemory:le,onSelectSession:Lt,onCreateWorkspace:we,onLaunchSession:Te,onCreateProject:Oe,onOpenWorkspace:()=>te("workspace"),onOpenTasks:()=>te("tasks"),tweaks:g}):e==="tasks"?i.jsx(xv,{tasks:s,projectIndex:_,onSelectTask:Ae,onSelectSession:Lt,tweaks:g}):e==="workspace"?i.jsx(Tv,{tasks:s,activeTaskId:d,selectedProjectId:K,selectedWorkspaceId:ie,selectedSessionId:pe,projectIndex:_,workspaceGraph:z,onSelectTask:Ae,onSelectSession:Lt,onSelectProject:Ue,onCanvasOpen:()=>te("canvas"),onNotepadOpen:()=>te("context"),onAddTaskNote:Ot,onUpdateWorkspace:Z,onAddWorkspaceFolder:Ut,onRemoveWorkspaceFolder:de,onCreateProject:Oe,onUpdateProject:Cn,onTasksRefresh:ue,tweaks:g}):e==="canvas"?i.jsx(v.Suspense,{fallback:i.jsx("div",{style:{height:"100%",display:"grid",alignItems:"start",background:"var(--surface)",padding:20},children:i.jsxs("div",{style:{border:"1px solid var(--border)",background:"white",padding:"16px 18px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:18},children:[i.jsxs("div",{children:[i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--green)",letterSpacing:"0.12em",textTransform:"uppercase"},children:"Repo Brain"}),i.jsx("div",{style:{marginTop:6,fontSize:20,fontWeight:650},children:"Loading folder canvas"})]}),i.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink3)",textTransform:"uppercase"},children:"Context Vault"})]})}),children:i.jsx(zv,{tasks:s,selectedProjectId:K,workspaceGraph:z,orgGraph:N,viewer:X,onOpenVault:k=>{k&&(window.location.hash=`#vault/${k}`),te("context")},onOrgGraphChanged:()=>{ge(),Ee(),oe()},onSelectTask:Ae,onSelectSession:Lt,onSelectWorkspace:xe,onSelectProject:Ue,onClose:()=>te("workspace"),tweaks:g})}):e==="memory"||e==="context"?i.jsx(Ag,{onMemoryCountChange:T,viewer:X,orgGraph:N,onInboxChanged:oe}):e==="router"||e==="router/sessionshistory"?i.jsx(uv,{onOpenFolders:()=>te("canvas"),onOpenSetup:()=>te("notepad")}):e==="handoff"?i.jsx(qg,{}):e==="replay"?i.jsx(Zg,{}):e==="learnings"?i.jsx(Gg,{}):e==="portability"?i.jsx(ev,{}):e==="conflicts"?i.jsx(bg,{viewer:X,onChanged:oe}):null;v.useEffect(()=>{const k=O=>{(O.ctrlKey||O.metaKey)&&O.key.toLowerCase()==="k"&&(O.preventDefault(),S(B=>!B))};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[]);const C=()=>{Ee(),ue(),q(),fe(),ge(),R(),oe()};return i.jsxs("div",{style:{height:"100vh",display:"flex",overflow:"hidden"},children:[i.jsx(ng,{view:e,setView:k=>te(k),conflictCount:U||p}),i.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsx(og,{viewer:X,routerStats:G,onRefresh:C,onOpenTweaks:()=>S(k=>!k),onResetWorkspace:async()=>{if(window.confirm("Reset workspace? Deletes projects, teams, folders, context items, proposals and findings for this org. Memory engrams are unaffected."))try{await A.enterpriseResetWorkspace()}finally{C()}}}),i.jsx("div",{style:qn,children:b()})]}),i.jsx(lg,{tweaks:g,setTweaks:h,visible:y}),i.jsx(dg,{open:n,onClose:()=>r(!1),projectIndex:_,initialWorkspaceId:ie,initialTab:o,onChanged:async()=>{await q(),await fe()}})]})}Wl.createRoot(document.getElementById("root")).render(i.jsx(Ap.StrictMode,{children:i.jsx(Fv,{})}));export{Lv as R,A as a,i as j,v as r}; diff --git a/dhee/ui/web/dist/assets/index-CIsLOp4u.css b/dhee/ui/web/dist/assets/index-CIsLOp4u.css new file mode 100644 index 0000000..65ec8b8 --- /dev/null +++ b/dhee/ui/web/dist/assets/index-CIsLOp4u.css @@ -0,0 +1 @@ +:root{--bg: oklch(.975 .006 80);--ink: oklch(.1 .01 260);--ink2: oklch(.42 .015 260);--ink3: oklch(.64 .01 260);--surface: oklch(.955 .008 80);--surface2: oklch(.93 .01 80);--border: oklch(.87 .012 80);--border2: oklch(.78 .012 80);--accent: oklch(.64 .18 36);--accent-dim: oklch(.97 .04 36);--green: oklch(.52 .22 145);--green-dim: oklch(.94 .06 145);--green-mid: oklch(.72 .14 145);--indigo: oklch(.52 .2 265);--indigo-dim: oklch(.95 .04 265);--rose: oklch(.58 .2 10);--rose-dim: oklch(.96 .05 10);--font: "Space Grotesk", sans-serif;--mono: "JetBrains Mono", monospace;--nav: 52px}*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}html,body,#root{height:100%;width:100%}body{font-family:var(--font);background:var(--bg);color:var(--ink);overflow:hidden;font-size:13.5px;line-height:1.5;-webkit-font-smoothing:antialiased}::selection{background:var(--accent-dim)}::-webkit-scrollbar{width:3px;height:3px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:var(--border2)}button{font-family:var(--font);cursor:pointer;border:none;background:none;color:inherit}button:disabled{cursor:not-allowed;opacity:.48}textarea,input{font-family:var(--font);color:var(--ink);background:transparent;border:none;outline:none;resize:none}@keyframes blink{0%,to{opacity:1}50%{opacity:0}}@keyframes fadein{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}@keyframes dhee-card-in{0%{opacity:0;transform:translate3d(0,8px,0) scale(.98)}to{opacity:1;transform:translateZ(0) scale(1)}}@keyframes dhee-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@keyframes dhee-pulse{0%,to{box-shadow:0 0 #e06b3f59}50%{box-shadow:0 0 0 6px #e06b3f00}}.dhee-node-card:hover{transform:translate3d(0,-2px,0)!important;box-shadow:0 6px 18px #14100a14,0 2px 6px #14100a0f!important}.dhee-canvas-bg{background-color:#faf7ef;background-image:radial-gradient(rgba(20,16,10,.06) 1px,transparent 1px);background-size:28px 28px;background-position:0 0}.dhee-edge-path{fill:none;stroke:#14100a24;stroke-width:1.4;transition:stroke .18s ease,stroke-width .18s ease,opacity .18s ease}.dhee-edge-path--highlight{stroke:#e06b3f8c;stroke-width:2}.dhee-edge-path--dim{opacity:.28}.md-root{word-wrap:break-word;overflow-wrap:break-word}.md-root .md-h1,.md-root .md-h2,.md-root .md-h3{margin:14px 0 8px;line-height:1.3;color:var(--ink)}.md-root .md-h1{font-size:22px;font-weight:600;border-bottom:1px solid var(--border);padding-bottom:5px}.md-root .md-h2{font-size:18px;font-weight:600}.md-root .md-h3{font-size:15px;font-weight:600;color:var(--ink2)}.md-root .md-p{margin:8px 0}.md-root .md-code{background:var(--surface2);border:1px solid var(--border);border-radius:3px;padding:1px 5px;font-family:var(--mono);font-size:12px;color:var(--ink)}.md-root .md-pre{background:var(--surface2);border:1px solid var(--border);border-radius:4px;padding:10px 12px;overflow-x:auto;margin:10px 0}.md-root .md-pre .md-code{background:transparent;border:0;padding:0;font-size:12px;line-height:1.5}.md-root .md-link{color:var(--accent);text-decoration:none;border-bottom:1px solid rgba(224,107,63,.3)}.md-root .md-link:hover{border-bottom-color:var(--accent)}.md-root .md-wiki{color:var(--indigo);font-weight:500}.md-root .md-wiki-missing{color:var(--ink3);border-bottom:1px dashed var(--ink3);cursor:not-allowed}.md-root .md-list{margin:8px 0 8px 22px;padding:0}.md-root .md-list li{margin:3px 0}.md-root .md-quote{border-left:3px solid var(--border2);padding:2px 12px;margin:10px 0;color:var(--ink2);font-style:italic}.proposal-status{display:inline-flex;align-items:center;padding:2px 7px;border-radius:3px;font-family:var(--mono);font-size:9px;letter-spacing:.04em;text-transform:uppercase}.proposal-status.active{background:var(--green-dim);color:var(--green)}.proposal-status.pending_review{background:var(--accent-dim);color:var(--accent)}.proposal-status.rejected{background:var(--rose-dim);color:var(--rose)}.inbox-row{border:1px solid var(--border);border-radius:4px;background:var(--surface);padding:10px 12px;display:flex;flex-direction:column;gap:6px;animation:dhee-card-in .18s ease}.inbox-row[data-severity=high]{border-left:3px solid var(--rose)}.inbox-row[data-severity=medium]{border-left:3px solid var(--accent)}.inbox-row[data-severity=low]{border-left:3px solid var(--indigo)}.workspace-pill{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:360px}.tokens-chip{cursor:default}.vault-leaf{display:flex;align-items:center;gap:6px;padding:4px 8px;border-radius:3px;cursor:pointer;font-size:12px;color:var(--ink2);background:transparent;border:0;text-align:left;width:100%}.vault-leaf:hover{background:var(--surface)}.vault-leaf[aria-selected=true]{background:var(--accent-dim);color:var(--accent)}.vault-shell{display:flex;height:100%;min-height:0;overflow:hidden}.vault-nav{width:282px;border-right:1px solid var(--border);background:#fff;display:flex;flex-direction:column;flex-shrink:0;min-height:0}.vault-nav-head{padding:14px;border-bottom:1px solid var(--border)}.vault-tree{flex:1;min-height:0;overflow-y:auto;padding:10px}.vault-main{flex:1;min-width:0;min-height:0;display:grid;grid-template-columns:minmax(0,1fr) 320px;background:var(--bg)}.vault-editor{min-width:0;min-height:0;display:flex;flex-direction:column}.vault-editor-header{min-height:52px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;padding:0 18px;background:#fff;gap:12px;flex-shrink:0}.vault-editor-actions{display:flex;gap:8px;flex-shrink:0}.vault-body{flex:1;min-height:0;overflow:auto;padding:18px;display:grid;grid-template-columns:minmax(0,760px);gap:16px;align-content:start}.vault-body--editing{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.vault-form-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px}.vault-preview{min-width:0;min-height:420px;border:1px solid var(--border);background:#fff;padding:18px;box-shadow:0 10px 28px #14100a0a;overflow-wrap:anywhere}.vault-meta{min-width:0;min-height:0;border-left:1px solid var(--border);background:#fff;padding:16px;overflow-y:auto;display:flex;flex-direction:column;gap:14px}.repo-brain-header{position:absolute;left:16px;top:14px;z-index:8;display:flex;gap:10px;align-items:center;max-width:calc(100% - 32px);pointer-events:auto}.repo-brain-header .product-pill,.repo-brain-header button{flex:0 0 auto}.repo-brain-local-controls{left:16px!important;top:56px!important;max-width:calc(100% - 24px)}.inbox-shell,.inbox-sidebar,.inbox-main{min-width:0}.inbox-sidebar{box-shadow:1px 0 #ffffff8c inset}.inbox-main section,.inbox-main article{min-width:0}.inbox-actions{min-width:0}.router-active-card__grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(280px,max-content) 22px;gap:16px;align-items:center}.router-active-card__main,.router-session-card__head,.router-session-card__meta,.router-session-card__path,.router-session-card__title{min-width:0}.router-active-card__title,.router-active-card__meta,.router-session-card__title,.router-session-card__path{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.router-active-card__stats{display:grid;grid-template-columns:repeat(3,minmax(86px,max-content));gap:16px;align-items:center}.router-active-card__toggle{justify-self:end}.router-mini-stat{min-width:0}.router-session-cards{display:none}.router-session-card{width:100%;min-width:0;text-align:left;border:1px solid var(--border);border-radius:6px;background:#fff;padding:12px;display:grid;gap:8px}.router-session-card--active{border-color:var(--indigo);background:var(--indigo-dim)}.router-session-card__head{display:grid;grid-template-columns:minmax(0,1fr) max-content;gap:10px;align-items:start}.router-session-card__title{color:var(--ink);font-size:14px;font-weight:700;line-height:1.25}.router-session-card__meta{display:flex;align-items:center;gap:10px;color:var(--ink3);font-family:var(--mono);font-size:10px;flex-wrap:wrap}.router-session-card__path{color:var(--ink3);font-family:var(--mono);font-size:10px}.router-session-card__stats{border-top:1px solid var(--border);padding-top:10px;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}.product-screen{height:100%;overflow-y:auto;background:linear-gradient(180deg,#ffffff52,#fff0 190px),var(--surface)}.product-content{width:100%;max-width:1480px;min-height:100%;margin:0 auto;padding:24px;display:flex;flex-direction:column;gap:16px}.product-hero{display:flex;align-items:flex-start;justify-content:space-between;gap:20px;padding:18px 18px 20px;border:1px solid var(--border);border-radius:8px;background:#ffffff9e;box-shadow:0 1px #ffffffe0 inset}.product-hero-copy{max-width:820px}.product-eyebrow,.product-panel-label,.product-pill,.product-timeline-index{font-family:var(--mono);font-size:10px;letter-spacing:.08em;text-transform:uppercase}.product-eyebrow{color:var(--accent);margin-bottom:8px}.product-title{font-size:31px;line-height:1.08;font-weight:750;letter-spacing:0;max-width:900px}.product-subtitle{margin-top:8px;color:var(--ink2);font-size:14px;line-height:1.55;max-width:880px}.product-hero-action{flex-shrink:0}.product-panel{min-width:0;padding:16px;border:1px solid var(--border);border-radius:8px;background:#ffffffc2;box-shadow:0 1px #ffffffeb inset,0 10px 28px #14100a06}.product-panel-label{color:var(--ink3);margin-bottom:12px}.product-metric-grid,.product-grid{display:grid;gap:14px}.product-metric-grid{grid-template-columns:repeat(4,minmax(0,1fr))}.product-grid--two{grid-template-columns:minmax(0,1.08fr) minmax(0,.92fr)}.product-grid--three{grid-template-columns:repeat(3,minmax(0,1fr))}.product-grid--split{grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr)}.product-metric-value{font-size:28px;line-height:1;font-weight:760;font-variant-numeric:tabular-nums}.product-metric-label{margin-top:9px;color:var(--ink3);font-size:12px}.product-pill{display:inline-flex;align-items:center;min-height:22px;max-width:100%;padding:3px 8px;border:1px solid var(--border);border-radius:4px;background:var(--surface2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.product-list{display:grid;gap:10px}.product-list--tight{gap:6px}.product-empty{color:var(--ink3);font-size:13px;line-height:1.55}.product-text-row{padding:8px 0;border-bottom:1px solid var(--border);color:var(--ink2)}.product-small-row{display:flex;gap:10px;align-items:flex-start;min-width:0;padding:8px 0;border-bottom:1px solid var(--border)}.product-row-dot{width:8px;height:8px;margin-top:6px;flex-shrink:0}.product-small-title{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:660}.product-small-meta{margin-top:2px;color:var(--ink3);font-family:var(--mono);font-size:10px}.product-timeline-row{display:grid;grid-template-columns:44px minmax(0,1fr);gap:14px;padding:14px 0;border-bottom:1px solid var(--border)}.product-timeline-index{color:var(--ink3)}.product-timeline-title{font-size:16px;font-weight:720;line-height:1.3}.product-timeline-detail{margin-top:4px;color:var(--ink2);line-height:1.55;overflow-wrap:anywhere}.product-handoff-path{margin-top:12px;color:var(--ink3);font-family:var(--mono);font-size:10px;line-height:1.5;text-transform:uppercase;overflow-wrap:anywhere}.product-handoff-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:16px}.product-handoff-stats .product-small-row{border:1px solid var(--border);padding:10px}.product-learning-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:18px;padding:16px 0;border-bottom:1px solid var(--border);align-items:start}.product-learning-title{font-size:17px;font-weight:700;line-height:1.25;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.product-learning-meta{margin-top:6px;color:var(--ink3);font-family:var(--mono);font-size:10px;line-height:1.45;text-transform:uppercase;overflow-wrap:anywhere}.product-learning-body{margin-top:8px;color:var(--ink2);line-height:1.55;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden}.product-learning-actions{display:flex;gap:8px;flex-shrink:0;flex-wrap:wrap;justify-content:flex-end}@media (max-width: 1100px){.product-metric-grid,.product-grid--three{grid-template-columns:repeat(2,minmax(0,1fr))}.product-grid--two,.product-grid--split{grid-template-columns:1fr}}@media (max-width: 720px){.vault-shell{display:block;overflow-y:auto;background:var(--bg)}.vault-nav{width:100%;max-height:48vh;border-right:0;border-bottom:1px solid var(--border)}.vault-nav-head{padding:12px 14px}.vault-main,.vault-editor{display:block}.vault-editor-header{align-items:flex-start;flex-wrap:wrap;padding:12px 14px}.vault-editor-actions{width:100%;justify-content:flex-start;flex-wrap:wrap}.vault-body,.vault-body--editing{overflow:visible;grid-template-columns:1fr;padding:14px}.vault-form-grid{grid-template-columns:1fr}.vault-preview{min-height:260px;padding:14px}.vault-meta{border-left:0;border-top:1px solid var(--border);overflow:visible;padding:14px}.repo-brain-header{left:12px;right:12px;top:12px;max-width:none;flex-wrap:wrap;gap:6px}.repo-brain-header .product-pill,.repo-brain-header button{min-height:24px;max-width:100%}.repo-brain-local-controls{left:12px!important;top:92px!important;right:12px;align-items:flex-start!important;flex-wrap:wrap}.inbox-shell{display:block!important;overflow-y:auto;background:var(--bg)}.inbox-sidebar{width:100%!important;border-right:0!important;border-bottom:1px solid var(--border);overflow:visible!important}.inbox-main{overflow:visible!important;padding:14px!important}.inbox-actions{justify-content:flex-start!important}.router-active-card__button{padding:12px!important}.router-active-card__grid{grid-template-columns:minmax(0,1fr) 18px;gap:10px;align-items:start}.router-active-card__stats{grid-column:1 / -1;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;border-top:1px solid var(--border);padding-top:10px}.router-active-card__toggle{grid-column:2;grid-row:1;padding-top:2px}.router-session-table{display:none}.router-session-cards{display:grid;gap:10px}.product-content{padding:14px}.product-hero{flex-direction:column;padding:16px}.product-title{font-size:24px}.product-metric-grid,.product-grid--three{grid-template-columns:1fr}.product-timeline-row{grid-template-columns:1fr;gap:6px}.product-handoff-stats,.product-learning-row{grid-template-columns:1fr}.product-learning-actions{justify-content:flex-start}}.vault-leaf[data-status=pending_review]:before{content:"";width:6px;height:6px;border-radius:50%;background:var(--accent);flex-shrink:0}.vault-leaf[data-status=active]:before{content:"";width:6px;height:6px;border-radius:50%;background:var(--green);flex-shrink:0} diff --git a/dhee/ui/web/dist/assets/index-DoQLFf8M.css b/dhee/ui/web/dist/assets/index-DoQLFf8M.css deleted file mode 100644 index cf4f2a4..0000000 --- a/dhee/ui/web/dist/assets/index-DoQLFf8M.css +++ /dev/null @@ -1 +0,0 @@ -:root{--bg: oklch(.975 .006 80);--ink: oklch(.1 .01 260);--ink2: oklch(.42 .015 260);--ink3: oklch(.64 .01 260);--surface: oklch(.955 .008 80);--surface2: oklch(.93 .01 80);--border: oklch(.87 .012 80);--border2: oklch(.78 .012 80);--accent: oklch(.64 .18 36);--accent-dim: oklch(.97 .04 36);--green: oklch(.52 .22 145);--green-dim: oklch(.94 .06 145);--green-mid: oklch(.72 .14 145);--indigo: oklch(.52 .2 265);--indigo-dim: oklch(.95 .04 265);--rose: oklch(.58 .2 10);--rose-dim: oklch(.96 .05 10);--font: "Space Grotesk", sans-serif;--mono: "JetBrains Mono", monospace;--nav: 52px}*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}html,body,#root{height:100%;width:100%}body{font-family:var(--font);background:var(--bg);color:var(--ink);overflow:hidden;font-size:13.5px;line-height:1.5;-webkit-font-smoothing:antialiased}::selection{background:var(--accent-dim)}::-webkit-scrollbar{width:3px;height:3px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:var(--border2)}button{font-family:var(--font);cursor:pointer;border:none;background:none;color:inherit}textarea,input{font-family:var(--font);color:var(--ink);background:transparent;border:none;outline:none;resize:none}@keyframes blink{0%,to{opacity:1}50%{opacity:0}}@keyframes fadein{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}@keyframes dhee-card-in{0%{opacity:0;transform:translate3d(0,8px,0) scale(.98)}to{opacity:1;transform:translateZ(0) scale(1)}}@keyframes dhee-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@keyframes dhee-pulse{0%,to{box-shadow:0 0 #e06b3f59}50%{box-shadow:0 0 0 6px #e06b3f00}}.dhee-node-card:hover{transform:translate3d(0,-2px,0)!important;box-shadow:0 6px 18px #14100a14,0 2px 6px #14100a0f!important}.dhee-canvas-bg{background-color:#faf7ef;background-image:radial-gradient(rgba(20,16,10,.06) 1px,transparent 1px);background-size:28px 28px;background-position:0 0}.dhee-edge-path{fill:none;stroke:#14100a24;stroke-width:1.4;transition:stroke .18s ease,stroke-width .18s ease,opacity .18s ease}.dhee-edge-path--highlight{stroke:#e06b3f8c;stroke-width:2}.dhee-edge-path--dim{opacity:.28}.md-root{word-wrap:break-word;overflow-wrap:break-word}.md-root .md-h1,.md-root .md-h2,.md-root .md-h3{margin:14px 0 8px;line-height:1.3;color:var(--ink)}.md-root .md-h1{font-size:22px;font-weight:600;border-bottom:1px solid var(--border);padding-bottom:5px}.md-root .md-h2{font-size:18px;font-weight:600}.md-root .md-h3{font-size:15px;font-weight:600;color:var(--ink2)}.md-root .md-p{margin:8px 0}.md-root .md-code{background:var(--surface2);border:1px solid var(--border);border-radius:3px;padding:1px 5px;font-family:var(--mono);font-size:12px;color:var(--ink)}.md-root .md-pre{background:var(--surface2);border:1px solid var(--border);border-radius:4px;padding:10px 12px;overflow-x:auto;margin:10px 0}.md-root .md-pre .md-code{background:transparent;border:0;padding:0;font-size:12px;line-height:1.5}.md-root .md-link{color:var(--accent);text-decoration:none;border-bottom:1px solid rgba(224,107,63,.3)}.md-root .md-link:hover{border-bottom-color:var(--accent)}.md-root .md-wiki{color:var(--indigo);font-weight:500}.md-root .md-wiki-missing{color:var(--ink3);border-bottom:1px dashed var(--ink3);cursor:not-allowed}.md-root .md-list{margin:8px 0 8px 22px;padding:0}.md-root .md-list li{margin:3px 0}.md-root .md-quote{border-left:3px solid var(--border2);padding:2px 12px;margin:10px 0;color:var(--ink2);font-style:italic}.proposal-status{display:inline-flex;align-items:center;padding:2px 7px;border-radius:3px;font-family:var(--mono);font-size:9px;letter-spacing:.04em;text-transform:uppercase}.proposal-status.active{background:var(--green-dim);color:var(--green)}.proposal-status.pending_review{background:var(--accent-dim);color:var(--accent)}.proposal-status.rejected{background:var(--rose-dim);color:var(--rose)}.inbox-row{border:1px solid var(--border);border-radius:4px;background:var(--surface);padding:10px 12px;display:flex;flex-direction:column;gap:6px;animation:dhee-card-in .18s ease}.inbox-row[data-severity=high]{border-left:3px solid var(--rose)}.inbox-row[data-severity=medium]{border-left:3px solid var(--accent)}.inbox-row[data-severity=low]{border-left:3px solid var(--indigo)}.workspace-pill{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:360px}.tokens-chip{cursor:default}.vault-leaf{display:flex;align-items:center;gap:6px;padding:4px 8px;border-radius:3px;cursor:pointer;font-size:12px;color:var(--ink2);background:transparent;border:0;text-align:left;width:100%}.vault-leaf:hover{background:var(--surface)}.vault-leaf[aria-selected=true]{background:var(--accent-dim);color:var(--accent)}.vault-leaf[data-status=pending_review]:before{content:"";width:6px;height:6px;border-radius:50%;background:var(--accent);flex-shrink:0}.vault-leaf[data-status=active]:before{content:"";width:6px;height:6px;border-radius:50%;background:var(--green);flex-shrink:0} diff --git a/dhee/ui/web/dist/index.html b/dhee/ui/web/dist/index.html index 3953791..2effd30 100644 --- a/dhee/ui/web/dist/index.html +++ b/dhee/ui/web/dist/index.html @@ -9,8 +9,8 @@ href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:ital,wght@0,400;0,500;0,700;1,400&display=swap" rel="stylesheet" /> - - + +
diff --git a/dhee/ui/web/src/App.js b/dhee/ui/web/src/App.js index de139b8..de7df01 100644 --- a/dhee/ui/web/src/App.js +++ b/dhee/ui/web/src/App.js @@ -51,6 +51,8 @@ function normalizeView(view) { return "learnings"; if (raw === "packs" || raw === "portable" || raw === "trust") return "portability"; + if (raw === "inbox" || raw === "review" || raw === "queue") + return "conflicts"; if (raw === "router/sessionshistory" || raw === "router/session-history" || raw === "router/history") diff --git a/dhee/ui/web/src/App.tsx b/dhee/ui/web/src/App.tsx index 402ac4d..463a768 100644 --- a/dhee/ui/web/src/App.tsx +++ b/dhee/ui/web/src/App.tsx @@ -68,6 +68,7 @@ function normalizeView(view: View | string | null): View { if (raw === "repo" || raw === "brain" || raw === "repo-brain" || raw === "folders") return "canvas"; if (raw === "learn" || raw === "learning") return "learnings"; if (raw === "packs" || raw === "portable" || raw === "trust") return "portability"; + if (raw === "inbox" || raw === "review" || raw === "queue") return "conflicts"; if ( raw === "router/sessionshistory" || raw === "router/session-history" || diff --git a/dhee/ui/web/src/styles.css b/dhee/ui/web/src/styles.css index df02337..4c7471e 100644 --- a/dhee/ui/web/src/styles.css +++ b/dhee/ui/web/src/styles.css @@ -62,6 +62,10 @@ button { background: none; color: inherit; } +button:disabled { + cursor: not-allowed; + opacity: 0.48; +} textarea, input { font-family: var(--font); @@ -311,6 +315,626 @@ input { background: var(--accent-dim); color: var(--accent); } +.vault-shell { + display: flex; + height: 100%; + min-height: 0; + overflow: hidden; +} +.vault-nav { + width: 282px; + border-right: 1px solid var(--border); + background: white; + display: flex; + flex-direction: column; + flex-shrink: 0; + min-height: 0; +} +.vault-nav-head { + padding: 14px; + border-bottom: 1px solid var(--border); +} +.vault-tree { + flex: 1; + min-height: 0; + overflow-y: auto; + padding: 10px; +} +.vault-main { + flex: 1; + min-width: 0; + min-height: 0; + display: grid; + grid-template-columns: minmax(0, 1fr) 320px; + background: var(--bg); +} +.vault-editor { + min-width: 0; + min-height: 0; + display: flex; + flex-direction: column; +} +.vault-editor-header { + min-height: 52px; + border-bottom: 1px solid var(--border); + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 18px; + background: white; + gap: 12px; + flex-shrink: 0; +} +.vault-editor-actions { + display: flex; + gap: 8px; + flex-shrink: 0; +} +.vault-body { + flex: 1; + min-height: 0; + overflow: auto; + padding: 18px; + display: grid; + grid-template-columns: minmax(0, 760px); + gap: 16px; + align-content: start; +} +.vault-body--editing { + grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); +} +.vault-form-grid { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); + gap: 8px; +} +.vault-preview { + min-width: 0; + min-height: 420px; + border: 1px solid var(--border); + background: white; + padding: 18px; + box-shadow: 0 10px 28px rgba(20, 16, 10, 0.04); + overflow-wrap: anywhere; +} +.vault-meta { + min-width: 0; + min-height: 0; + border-left: 1px solid var(--border); + background: white; + padding: 16px; + overflow-y: auto; + display: flex; + flex-direction: column; + gap: 14px; +} + +/* ── Repo Brain canvas chrome ─────────────────────────────────────────── */ +.repo-brain-header { + position: absolute; + left: 16px; + top: 14px; + z-index: 8; + display: flex; + gap: 10px; + align-items: center; + max-width: calc(100% - 32px); + pointer-events: auto; +} +.repo-brain-header .product-pill, +.repo-brain-header button { + flex: 0 0 auto; +} +.repo-brain-local-controls { + left: 16px !important; + top: 56px !important; + max-width: calc(100% - 24px); +} + +/* ── Inbox queue ──────────────────────────────────────────────────────── */ +.inbox-shell, +.inbox-sidebar, +.inbox-main { + min-width: 0; +} +.inbox-sidebar { + box-shadow: 1px 0 0 rgba(255, 255, 255, 0.55) inset; +} +.inbox-main section, +.inbox-main article { + min-width: 0; +} +.inbox-actions { + min-width: 0; +} + +/* ── Router: live/history cards ───────────────────────────────────────── */ +.router-active-card__grid { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(280px, max-content) 22px; + gap: 16px; + align-items: center; +} +.router-active-card__main, +.router-session-card__head, +.router-session-card__meta, +.router-session-card__path, +.router-session-card__title { + min-width: 0; +} +.router-active-card__title, +.router-active-card__meta, +.router-session-card__title, +.router-session-card__path { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.router-active-card__stats { + display: grid; + grid-template-columns: repeat(3, minmax(86px, max-content)); + gap: 16px; + align-items: center; +} +.router-active-card__toggle { + justify-self: end; +} +.router-mini-stat { + min-width: 0; +} +.router-session-cards { + display: none; +} +.router-session-card { + width: 100%; + min-width: 0; + text-align: left; + border: 1px solid var(--border); + border-radius: 6px; + background: white; + padding: 12px; + display: grid; + gap: 8px; +} +.router-session-card--active { + border-color: var(--indigo); + background: var(--indigo-dim); +} +.router-session-card__head { + display: grid; + grid-template-columns: minmax(0, 1fr) max-content; + gap: 10px; + align-items: start; +} +.router-session-card__title { + color: var(--ink); + font-size: 14px; + font-weight: 700; + line-height: 1.25; +} +.router-session-card__meta { + display: flex; + align-items: center; + gap: 10px; + color: var(--ink3); + font-family: var(--mono); + font-size: 10px; + flex-wrap: wrap; +} +.router-session-card__path { + color: var(--ink3); + font-family: var(--mono); + font-size: 10px; +} +.router-session-card__stats { + border-top: 1px solid var(--border); + padding-top: 10px; + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 10px; +} + +/* ── Product views: command center, handoff, proof replay ─────────────── */ +.product-screen { + height: 100%; + overflow-y: auto; + background: + linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0) 190px), + var(--surface); +} +.product-content { + width: 100%; + max-width: 1480px; + min-height: 100%; + margin: 0 auto; + padding: 24px; + display: flex; + flex-direction: column; + gap: 16px; +} +.product-hero { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 20px; + padding: 18px 18px 20px; + border: 1px solid var(--border); + border-radius: 8px; + background: rgba(255, 255, 255, 0.62); + box-shadow: 0 1px 0 rgba(255, 255, 255, 0.88) inset; +} +.product-hero-copy { + max-width: 820px; +} +.product-eyebrow, +.product-panel-label, +.product-pill, +.product-timeline-index { + font-family: var(--mono); + font-size: 10px; + letter-spacing: 0.08em; + text-transform: uppercase; +} +.product-eyebrow { + color: var(--accent); + margin-bottom: 8px; +} +.product-title { + font-size: 31px; + line-height: 1.08; + font-weight: 750; + letter-spacing: 0; + max-width: 900px; +} +.product-subtitle { + margin-top: 8px; + color: var(--ink2); + font-size: 14px; + line-height: 1.55; + max-width: 880px; +} +.product-hero-action { + flex-shrink: 0; +} +.product-panel { + min-width: 0; + padding: 16px; + border: 1px solid var(--border); + border-radius: 8px; + background: rgba(255, 255, 255, 0.76); + box-shadow: + 0 1px 0 rgba(255, 255, 255, 0.92) inset, + 0 10px 28px rgba(20, 16, 10, 0.025); +} +.product-panel-label { + color: var(--ink3); + margin-bottom: 12px; +} +.product-metric-grid, +.product-grid { + display: grid; + gap: 14px; +} +.product-metric-grid { + grid-template-columns: repeat(4, minmax(0, 1fr)); +} +.product-grid--two { + grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); +} +.product-grid--three { + grid-template-columns: repeat(3, minmax(0, 1fr)); +} +.product-grid--split { + grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); +} +.product-metric-value { + font-size: 28px; + line-height: 1; + font-weight: 760; + font-variant-numeric: tabular-nums; +} +.product-metric-label { + margin-top: 9px; + color: var(--ink3); + font-size: 12px; +} +.product-pill { + display: inline-flex; + align-items: center; + min-height: 22px; + max-width: 100%; + padding: 3px 8px; + border: 1px solid var(--border); + border-radius: 4px; + background: var(--surface2); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.product-list { + display: grid; + gap: 10px; +} +.product-list--tight { + gap: 6px; +} +.product-empty { + color: var(--ink3); + font-size: 13px; + line-height: 1.55; +} +.product-text-row { + padding: 8px 0; + border-bottom: 1px solid var(--border); + color: var(--ink2); +} +.product-small-row { + display: flex; + gap: 10px; + align-items: flex-start; + min-width: 0; + padding: 8px 0; + border-bottom: 1px solid var(--border); +} +.product-row-dot { + width: 8px; + height: 8px; + margin-top: 6px; + flex-shrink: 0; +} +.product-small-title { + max-width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-size: 13px; + font-weight: 660; +} +.product-small-meta { + margin-top: 2px; + color: var(--ink3); + font-family: var(--mono); + font-size: 10px; +} +.product-timeline-row { + display: grid; + grid-template-columns: 44px minmax(0, 1fr); + gap: 14px; + padding: 14px 0; + border-bottom: 1px solid var(--border); +} +.product-timeline-index { + color: var(--ink3); +} +.product-timeline-title { + font-size: 16px; + font-weight: 720; + line-height: 1.3; +} +.product-timeline-detail { + margin-top: 4px; + color: var(--ink2); + line-height: 1.55; + overflow-wrap: anywhere; +} +.product-handoff-path { + margin-top: 12px; + color: var(--ink3); + font-family: var(--mono); + font-size: 10px; + line-height: 1.5; + text-transform: uppercase; + overflow-wrap: anywhere; +} +.product-handoff-stats { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 10px; + margin-top: 16px; +} +.product-handoff-stats .product-small-row { + border: 1px solid var(--border); + padding: 10px; +} +.product-learning-row { + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + gap: 18px; + padding: 16px 0; + border-bottom: 1px solid var(--border); + align-items: start; +} +.product-learning-title { + font-size: 17px; + font-weight: 700; + line-height: 1.25; + overflow-wrap: anywhere; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; +} +.product-learning-meta { + margin-top: 6px; + color: var(--ink3); + font-family: var(--mono); + font-size: 10px; + line-height: 1.45; + text-transform: uppercase; + overflow-wrap: anywhere; +} +.product-learning-body { + margin-top: 8px; + color: var(--ink2); + line-height: 1.55; + overflow-wrap: anywhere; + display: -webkit-box; + -webkit-line-clamp: 4; + -webkit-box-orient: vertical; + overflow: hidden; +} +.product-learning-actions { + display: flex; + gap: 8px; + flex-shrink: 0; + flex-wrap: wrap; + justify-content: flex-end; +} + +@media (max-width: 1100px) { + .product-metric-grid, + .product-grid--three { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + .product-grid--two, + .product-grid--split { + grid-template-columns: 1fr; + } +} + +@media (max-width: 720px) { + .vault-shell { + display: block; + overflow-y: auto; + background: var(--bg); + } + .vault-nav { + width: 100%; + max-height: 48vh; + border-right: 0; + border-bottom: 1px solid var(--border); + } + .vault-nav-head { + padding: 12px 14px; + } + .vault-main { + display: block; + } + .vault-editor { + display: block; + } + .vault-editor-header { + align-items: flex-start; + flex-wrap: wrap; + padding: 12px 14px; + } + .vault-editor-actions { + width: 100%; + justify-content: flex-start; + flex-wrap: wrap; + } + .vault-body, + .vault-body--editing { + overflow: visible; + grid-template-columns: 1fr; + padding: 14px; + } + .vault-form-grid { + grid-template-columns: 1fr; + } + .vault-preview { + min-height: 260px; + padding: 14px; + } + .vault-meta { + border-left: 0; + border-top: 1px solid var(--border); + overflow: visible; + padding: 14px; + } + .repo-brain-header { + left: 12px; + right: 12px; + top: 12px; + max-width: none; + flex-wrap: wrap; + gap: 6px; + } + .repo-brain-header .product-pill, + .repo-brain-header button { + min-height: 24px; + max-width: 100%; + } + .repo-brain-local-controls { + left: 12px !important; + top: 92px !important; + right: 12px; + align-items: flex-start !important; + flex-wrap: wrap; + } + .inbox-shell { + display: block !important; + overflow-y: auto; + background: var(--bg); + } + .inbox-sidebar { + width: 100% !important; + border-right: 0 !important; + border-bottom: 1px solid var(--border); + overflow: visible !important; + } + .inbox-main { + overflow: visible !important; + padding: 14px !important; + } + .inbox-actions { + justify-content: flex-start !important; + } + .router-active-card__button { + padding: 12px !important; + } + .router-active-card__grid { + grid-template-columns: minmax(0, 1fr) 18px; + gap: 10px; + align-items: start; + } + .router-active-card__stats { + grid-column: 1 / -1; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 10px; + border-top: 1px solid var(--border); + padding-top: 10px; + } + .router-active-card__toggle { + grid-column: 2; + grid-row: 1; + padding-top: 2px; + } + .router-session-table { + display: none; + } + .router-session-cards { + display: grid; + gap: 10px; + } + .product-content { + padding: 14px; + } + .product-hero { + flex-direction: column; + padding: 16px; + } + .product-title { + font-size: 24px; + } + .product-metric-grid, + .product-grid--three { + grid-template-columns: 1fr; + } + .product-timeline-row { + grid-template-columns: 1fr; + gap: 6px; + } + .product-handoff-stats { + grid-template-columns: 1fr; + } + .product-learning-row { + grid-template-columns: 1fr; + } + .product-learning-actions { + justify-content: flex-start; + } +} .vault-leaf[data-status="pending_review"]::before { content: ""; width: 6px; diff --git a/dhee/ui/web/src/views/ConflictView.js b/dhee/ui/web/src/views/ConflictView.js index 4303d5b..4eb3a1c 100644 --- a/dhee/ui/web/src/views/ConflictView.js +++ b/dhee/ui/web/src/views/ConflictView.js @@ -103,7 +103,7 @@ export function ConflictView({ viewer, onChanged }) { setBusy(null); } }; - return (_jsxs("div", { style: { display: "flex", height: "100%", minHeight: 0 }, children: [_jsxs("aside", { style: { + return (_jsxs("div", { className: "inbox-shell", style: { display: "flex", height: "100%", minHeight: 0 }, children: [_jsxs("aside", { className: "inbox-sidebar", style: { width: 300, borderRight: "1px solid var(--border)", background: "white", @@ -139,7 +139,7 @@ export function ConflictView({ viewer, onChanged }) { fontFamily: "var(--mono)", fontSize: 10, lineHeight: 1.5, - }, children: error })) : null] }), _jsxs("main", { style: { + }, children: error })) : null] }), _jsxs("main", { className: "inbox-main", style: { flex: 1, minWidth: 0, overflowY: "auto", @@ -148,7 +148,7 @@ export function ConflictView({ viewer, onChanged }) { display: "grid", gap: 16, alignContent: "start", - }, children: [_jsx(InboxSection, { title: "Pending Proposals", count: snapshot.proposals.length, empty: "No context edits are waiting for approval.", children: snapshot.proposals.map((proposal) => (_jsxs("article", { onClick: () => setSelected(proposal.context_id), style: rowStyle(selected === proposal.context_id), children: [_jsxs("div", { style: rowHeaderStyle, children: [_jsxs("div", { children: [_jsx("div", { style: rowTitleStyle, children: proposal.title }), _jsxs("div", { style: rowMetaStyle, children: [proposal.proposed_by_user_id || "developer", " \u00B7 ", proposal.team_id || proposal.project_id || proposal.scope] })] }), _jsx(Badge, { color: "var(--accent)", children: "pending" })] }), _jsx("p", { style: snippetStyle, children: proposalSnippet(proposal) || "No preview available." }), _jsxs("div", { style: { display: "flex", gap: 8, justifyContent: "flex-end" }, children: [_jsx(QueueButton, { label: "Open in Context", onClick: (e) => { + }, children: [_jsx(InboxSection, { title: "Pending Proposals", count: snapshot.proposals.length, empty: "No context edits are waiting for approval.", children: snapshot.proposals.map((proposal) => (_jsxs("article", { onClick: () => setSelected(proposal.context_id), style: rowStyle(selected === proposal.context_id), children: [_jsxs("div", { style: rowHeaderStyle, children: [_jsxs("div", { children: [_jsx("div", { style: rowTitleStyle, children: proposal.title }), _jsxs("div", { style: rowMetaStyle, children: [proposal.proposed_by_user_id || "developer", " \u00B7 ", proposal.team_id || proposal.project_id || proposal.scope] })] }), _jsx(Badge, { color: "var(--accent)", children: "pending" })] }), _jsx("p", { style: snippetStyle, children: proposalSnippet(proposal) || "No preview available." }), _jsxs("div", { className: "inbox-actions", style: { display: "flex", gap: 8, justifyContent: "flex-end", flexWrap: "wrap" }, children: [_jsx(QueueButton, { label: "Open in Context", onClick: (e) => { e.stopPropagation(); window.location.hash = `#vault/item/${proposal.context_id}`; window.history.replaceState(null, "", `?view=context${window.location.hash}`); @@ -159,13 +159,13 @@ export function ConflictView({ viewer, onChanged }) { } }), _jsx(QueueButton, { label: "Approve", color: "var(--green)", busy: busy === `approve:${proposal.context_id}`, onClick: (e) => { e.stopPropagation(); void decideProposal(proposal, "approve"); - } })] })] }, proposal.context_id))) }), _jsx(InboxSection, { title: "Manager Findings", count: snapshot.findings.length, empty: "No stale, low-quality, or duplicate context findings.", children: snapshot.findings.map((finding) => (_jsxs("article", { onClick: () => setSelected(finding.finding_id), style: rowStyle(selected === finding.finding_id), children: [_jsxs("div", { style: rowHeaderStyle, children: [_jsxs("div", { children: [_jsx("div", { style: rowTitleStyle, children: finding.title }), _jsxs("div", { style: rowMetaStyle, children: [finding.team_id, " \u00B7 ", finding.finding_type] })] }), _jsx(Badge, { color: severityColor(finding.severity), children: finding.severity })] }), _jsx("p", { style: snippetStyle, children: finding.detail }), _jsx("div", { style: { display: "flex", justifyContent: "flex-end" }, children: _jsx(QueueButton, { label: "Resolve", color: "var(--green)", busy: busy === `finding:${finding.finding_id}`, onClick: (e) => { + } })] })] }, proposal.context_id))) }), _jsx(InboxSection, { title: "Manager Findings", count: snapshot.findings.length, empty: "No stale, low-quality, or duplicate context findings.", children: snapshot.findings.map((finding) => (_jsxs("article", { onClick: () => setSelected(finding.finding_id), style: rowStyle(selected === finding.finding_id), children: [_jsxs("div", { style: rowHeaderStyle, children: [_jsxs("div", { children: [_jsx("div", { style: rowTitleStyle, children: finding.title }), _jsxs("div", { style: rowMetaStyle, children: [finding.team_id, " \u00B7 ", finding.finding_type] })] }), _jsx(Badge, { color: severityColor(finding.severity), children: finding.severity })] }), _jsx("p", { style: snippetStyle, children: finding.detail }), _jsx("div", { className: "inbox-actions", style: { display: "flex", justifyContent: "flex-end", flexWrap: "wrap" }, children: _jsx(QueueButton, { label: "Resolve", color: "var(--green)", busy: busy === `finding:${finding.finding_id}`, onClick: (e) => { e.stopPropagation(); void resolveFinding(finding); } }) })] }, finding.finding_id))) }), _jsx(InboxSection, { title: "Memory Conflicts", count: snapshot.conflicts.length, empty: "No memory contradictions detected.", children: snapshot.conflicts.map((conflict) => { const c = conflict; const id = String(c.id || Math.random()); - return (_jsxs("article", { onClick: () => setSelected(id), style: rowStyle(selected === id), children: [_jsxs("div", { style: rowHeaderStyle, children: [_jsxs("div", { children: [_jsx("div", { style: rowTitleStyle, children: "Memory conflict" }), _jsx("div", { style: rowMetaStyle, children: c.reason || "Contradiction" })] }), _jsx(Badge, { color: severityColor(c.severity), children: c.severity || "open" })] }), _jsxs("div", { style: { display: "grid", gap: 6, marginTop: 10 }, children: [_jsx(ConflictQuote, { label: "A", text: c.belief_a?.content }), _jsx(ConflictQuote, { label: "B", text: c.belief_b?.content })] }), _jsx("div", { style: { display: "flex", gap: 8, justifyContent: "flex-end", marginTop: 10 }, children: ["KEEP A", "KEEP B", "MERGE"].map((action) => (_jsx(QueueButton, { label: action, busy: busy === `conflict:${id}:${action}`, onClick: (e) => { + return (_jsxs("article", { onClick: () => setSelected(id), style: rowStyle(selected === id), children: [_jsxs("div", { style: rowHeaderStyle, children: [_jsxs("div", { children: [_jsx("div", { style: rowTitleStyle, children: "Memory conflict" }), _jsx("div", { style: rowMetaStyle, children: c.reason || "Contradiction" })] }), _jsx(Badge, { color: severityColor(c.severity), children: c.severity || "open" })] }), _jsxs("div", { style: { display: "grid", gap: 6, marginTop: 10 }, children: [_jsx(ConflictQuote, { label: "A", text: c.belief_a?.content }), _jsx(ConflictQuote, { label: "B", text: c.belief_b?.content })] }), _jsx("div", { className: "inbox-actions", style: { display: "flex", gap: 8, justifyContent: "flex-end", flexWrap: "wrap", marginTop: 10 }, children: ["KEEP A", "KEEP B", "MERGE"].map((action) => (_jsx(QueueButton, { label: action, busy: busy === `conflict:${id}:${action}`, onClick: (e) => { e.stopPropagation(); void resolveConflict(conflict, action); } }, action))) })] }, id)); diff --git a/dhee/ui/web/src/views/ConflictView.tsx b/dhee/ui/web/src/views/ConflictView.tsx index caf1a15..91f6866 100644 --- a/dhee/ui/web/src/views/ConflictView.tsx +++ b/dhee/ui/web/src/views/ConflictView.tsx @@ -117,8 +117,9 @@ export function ConflictView({ viewer, onChanged }: ConflictViewProps) { }; return ( -
+

{proposalSnippet(proposal) || "No preview available."}

-
+
{ @@ -276,7 +281,10 @@ export function ConflictView({ viewer, onChanged }: ConflictViewProps) {

{finding.detail}

-
+
-
+
{["KEEP A", "KEEP B", "MERGE"].map((action) => ( { + 0, totalSessions: sessionSavings.totals?.sessions || 0, budget: sessionSavings.budget })] })] }), _jsx("div", { className: "vault-tree", role: "tree", "aria-label": "Context categories", children: vaultSections.map((section) => { const sectionRow = { id: `section:${section.id}`, type: "section", @@ -740,22 +733,7 @@ export function MemoryView({ onMemoryCountChange, viewer, orgGraph, onInboxChang treeRefs.current[row.id] = el; }, focused: focusedTreeId === row.id, active: selection?.kind === "memory" && selection.id === memory.id, dot: "var(--indigo)", title: memoryTitle(memory), meta: `${memory.tier} · ${memory.tokens || 0} tok`, onFocus: () => setFocusedTreeId(row.id), onKeyDown: (event) => handleTreeKeyDown(event, row), onClick: () => selectMemory(memory) }, memory.id)); }) }, section.id)); - }) })] }), _jsxs("main", { style: { - flex: 1, - minWidth: 0, - display: "grid", - gridTemplateColumns: "minmax(0, 1fr) 320px", - background: "var(--bg)", - }, children: [_jsxs("section", { style: { minWidth: 0, display: "flex", flexDirection: "column" }, children: [_jsxs("header", { style: { - height: 52, - borderBottom: "1px solid var(--border)", - display: "flex", - alignItems: "center", - justifyContent: "space-between", - padding: "0 18px", - background: "white", - gap: 12, - }, children: [_jsxs("div", { style: { minWidth: 0 }, children: [_jsxs("div", { style: { + }) })] }), _jsxs("main", { className: "vault-main", children: [_jsxs("section", { className: "vault-editor", children: [_jsxs("header", { className: "vault-editor-header", children: [_jsxs("div", { style: { minWidth: 0 }, children: [_jsxs("div", { style: { fontFamily: "var(--mono)", fontSize: 9, letterSpacing: "0.08em", @@ -768,37 +746,14 @@ export function MemoryView({ onMemoryCountChange, viewer, orgGraph, onInboxChang overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", - }, children: draft.title || "New context item" })] }), _jsxs("div", { style: { display: "flex", gap: 8, flexShrink: 0 }, children: [selectedItem?.proposal_status === "pending_review" && - (viewer?.role === "manager" || viewer?.role === "admin") ? (_jsxs(_Fragment, { children: [_jsx(ActionButton, { label: "APPROVE", tone: "green", busy: busy === "approve", onClick: () => void decideProposal("approve") }), _jsx(ActionButton, { label: "REJECT", tone: "rose", busy: busy === "reject", onClick: () => void decideProposal("reject") })] })) : null, !selectedReadOnly ? (_jsxs(_Fragment, { children: [_jsx(ActionButton, { label: editing ? "PREVIEW" : "EDIT", onClick: () => setEditing((v) => !v) }), _jsx(ActionButton, { label: directWrite ? "SAVE" : "REQUEST", tone: directWrite ? "accent" : "indigo", busy: busy === "save", onClick: () => void saveDraft() })] })) : null] })] }), _jsxs("div", { style: { - flex: 1, - minHeight: 0, - overflow: "auto", - padding: 18, - display: "grid", - gridTemplateColumns: editing ? "minmax(0, 1fr) minmax(0, 1fr)" : "minmax(0, 760px)", - gap: 16, - alignContent: "start", - }, children: [editing && !selectedReadOnly ? (_jsxs("div", { style: { display: "grid", gap: 10, alignContent: "start" }, children: [_jsx("input", { value: draft.title, onChange: (e) => setDraft((d) => ({ ...d, title: e.target.value })), placeholder: "Context title", style: inputStyle }), _jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [_jsxs("select", { value: draft.scope, onChange: (e) => setDraft((d) => ({ ...d, scope: e.target.value })), style: inputStyle, children: [_jsx("option", { value: "company", children: "company" }), _jsx("option", { value: "project", children: "project" }), _jsx("option", { value: "global_team", children: "global_team" }), _jsx("option", { value: "team", children: "team" }), _jsx("option", { value: "user", children: "user" }), _jsx("option", { value: "agent", children: "agent" })] }), _jsx("input", { value: draft.kind, onChange: (e) => setDraft((d) => ({ ...d, kind: e.target.value })), placeholder: "kind: runbook / policy / decision", style: inputStyle })] }), _jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [_jsx("input", { value: draft.project_id, onChange: (e) => setDraft((d) => ({ ...d, project_id: e.target.value })), placeholder: "project id", style: inputStyle }), _jsx("input", { value: draft.team_id, onChange: (e) => setDraft((d) => ({ ...d, team_id: e.target.value })), placeholder: "team id", style: inputStyle })] }), _jsx("input", { value: draft.tags, onChange: (e) => setDraft((d) => ({ ...d, tags: e.target.value })), placeholder: "tags, comma separated", style: inputStyle }), _jsx("textarea", { value: draft.content, onChange: (e) => setDraft((d) => ({ ...d, content: e.target.value })), rows: 20, placeholder: "Write markdown context here...", style: { + }, children: draft.title || "New context item" })] }), _jsxs("div", { className: "vault-editor-actions", children: [selectedItem?.proposal_status === "pending_review" && + (viewer?.role === "manager" || viewer?.role === "admin") ? (_jsxs(_Fragment, { children: [_jsx(ActionButton, { label: "APPROVE", tone: "green", busy: busy === "approve", onClick: () => void decideProposal("approve") }), _jsx(ActionButton, { label: "REJECT", tone: "rose", busy: busy === "reject", onClick: () => void decideProposal("reject") })] })) : null, !selectedReadOnly ? (_jsxs(_Fragment, { children: [_jsx(ActionButton, { label: editing ? "PREVIEW" : "EDIT", onClick: () => setEditing((v) => !v) }), _jsx(ActionButton, { label: directWrite ? "SAVE" : "REQUEST", tone: directWrite ? "accent" : "indigo", busy: busy === "save", onClick: () => void saveDraft() })] })) : null] })] }), _jsxs("div", { className: `vault-body${editing && !selectedReadOnly ? " vault-body--editing" : ""}`, children: [editing && !selectedReadOnly ? (_jsxs("div", { style: { display: "grid", gap: 10, alignContent: "start" }, children: [_jsx("input", { value: draft.title, onChange: (e) => setDraft((d) => ({ ...d, title: e.target.value })), placeholder: "Context title", style: inputStyle }), _jsxs("div", { className: "vault-form-grid", children: [_jsxs("select", { value: draft.scope, onChange: (e) => setDraft((d) => ({ ...d, scope: e.target.value })), style: inputStyle, children: [_jsx("option", { value: "company", children: "company" }), _jsx("option", { value: "project", children: "project" }), _jsx("option", { value: "global_team", children: "global_team" }), _jsx("option", { value: "team", children: "team" }), _jsx("option", { value: "user", children: "user" }), _jsx("option", { value: "agent", children: "agent" })] }), _jsx("input", { value: draft.kind, onChange: (e) => setDraft((d) => ({ ...d, kind: e.target.value })), placeholder: "kind: runbook / policy / decision", style: inputStyle })] }), _jsxs("div", { className: "vault-form-grid", children: [_jsx("input", { value: draft.project_id, onChange: (e) => setDraft((d) => ({ ...d, project_id: e.target.value })), placeholder: "project id", style: inputStyle }), _jsx("input", { value: draft.team_id, onChange: (e) => setDraft((d) => ({ ...d, team_id: e.target.value })), placeholder: "team id", style: inputStyle })] }), _jsx("input", { value: draft.tags, onChange: (e) => setDraft((d) => ({ ...d, tags: e.target.value })), placeholder: "tags, comma separated", style: inputStyle }), _jsx("textarea", { value: draft.content, onChange: (e) => setDraft((d) => ({ ...d, content: e.target.value })), rows: 20, placeholder: "Write markdown context here...", style: { ...inputStyle, minHeight: 420, resize: "vertical", lineHeight: 1.55, fontFamily: "var(--mono)", - } })] })) : null, _jsx("article", { style: { - border: "1px solid var(--border)", - background: "white", - padding: 18, - minHeight: 420, - boxShadow: "0 10px 28px rgba(20,16,10,0.04)", - }, children: _jsx(Markdown, { source: draft.content || "_No context selected._", wikiResolve: wikiResolve }) })] })] }), _jsxs("aside", { style: { - borderLeft: "1px solid var(--border)", - background: "white", - padding: 16, - overflowY: "auto", - display: "flex", - flexDirection: "column", - gap: 14, - }, children: [_jsxs(MetaBlock, { label: "Scope", children: [_jsx(Pill, { children: draft.scope }), draft.kind ? _jsx(Pill, { children: draft.kind }) : null, selectedItem?.proposal_status ? (_jsx(Pill, { color: statusTone(selectedItem.proposal_status), children: selectedItem.proposal_status })) : null] }), _jsxs(MetaBlock, { label: "Ownership", children: [_jsx(KV, { k: "org", v: viewer?.org_id }), _jsx(KV, { k: "project", v: draft.project_id || viewer?.project_id }), _jsx(KV, { k: "team", v: draft.team_id || viewer?.team_id }), _jsx(KV, { k: "viewer", v: viewer?.user_id }), _jsx(KV, { k: "role", v: viewer?.role || "developer" })] }), _jsxs(MetaBlock, { label: "Health", children: [_jsx(KV, { k: "quality", v: selectedItem?.quality_score }), _jsx(KV, { k: "freshness", v: selectedItem?.freshness_score }), _jsx(KV, { k: "confidence", v: selectedItem?.confidence }), _jsx(KV, { k: "token cost", v: selectedItem?.token_cost }), _jsx(KV, { k: "updated", v: selectedItem?.updated_at || selectedMemory?.created })] }), selectedItem ? (_jsxs(MetaBlock, { label: "Usage", children: [_jsx(KV, { k: "uses", v: selectedUsage?.usage_count ?? selectedItem.usage_count ?? 0 }), _jsx(KV, { k: "last used", v: selectedUsage?.last_used_at ?? selectedItem.last_used_at }), _jsx(KV, { k: "tokens served", v: selectedUsage?.tokens_served ?? 0 }), _jsx(KV, { k: "proven saved", v: selectedUsage?.proven_tokens_saved ?? 0 }), _jsx(KV, { k: "proven $", v: formatSavedDollars(selectedUsage?.realized_cost_saved_usd) }), _jsx(KV, { k: "evidence", v: selectedUsage?.evidence?.has_direct_savings_evidence + } })] })) : null, _jsx("article", { className: "vault-preview", children: _jsx(Markdown, { source: draft.content || "_No context selected._", wikiResolve: wikiResolve }) })] })] }), _jsxs("aside", { className: "vault-meta", children: [_jsxs(MetaBlock, { label: "Scope", children: [_jsx(Pill, { children: draft.scope }), draft.kind ? _jsx(Pill, { children: draft.kind }) : null, selectedItem?.proposal_status ? (_jsx(Pill, { color: statusTone(selectedItem.proposal_status), children: selectedItem.proposal_status })) : null] }), _jsxs(MetaBlock, { label: "Ownership", children: [_jsx(KV, { k: "org", v: viewer?.org_id }), _jsx(KV, { k: "project", v: draft.project_id || viewer?.project_id }), _jsx(KV, { k: "team", v: draft.team_id || viewer?.team_id }), _jsx(KV, { k: "viewer", v: viewer?.user_id }), _jsx(KV, { k: "role", v: viewer?.role || "developer" })] }), _jsxs(MetaBlock, { label: "Health", children: [_jsx(KV, { k: "quality", v: selectedItem?.quality_score }), _jsx(KV, { k: "freshness", v: selectedItem?.freshness_score }), _jsx(KV, { k: "confidence", v: selectedItem?.confidence }), _jsx(KV, { k: "token cost", v: selectedItem?.token_cost }), _jsx(KV, { k: "updated", v: selectedItem?.updated_at || selectedMemory?.created })] }), selectedItem ? (_jsxs(MetaBlock, { label: "Usage", children: [_jsx(KV, { k: "uses", v: selectedUsage?.usage_count ?? selectedItem.usage_count ?? 0 }), _jsx(KV, { k: "last used", v: selectedUsage?.last_used_at ?? selectedItem.last_used_at }), _jsx(KV, { k: "tokens served", v: selectedUsage?.tokens_served ?? 0 }), _jsx(KV, { k: "proven saved", v: selectedUsage?.proven_tokens_saved ?? 0 }), _jsx(KV, { k: "proven $", v: formatSavedDollars(selectedUsage?.realized_cost_saved_usd) }), _jsx(KV, { k: "evidence", v: selectedUsage?.evidence?.has_direct_savings_evidence ? "direct attribution" : "usage only" })] })) : null, _jsx(MetaBlock, { label: "Tags", children: parseTags(draft.tags).length ? (parseTags(draft.tags).map((tag) => _jsx(Pill, { children: tag }, tag))) : (_jsx("span", { style: { color: "var(--ink3)", fontSize: 12 }, children: "none" })) }), _jsx(MetaBlock, { label: "Backlinks", children: links?.backlinks?.length ? (links.backlinks.map((link) => (_jsx("button", { onClick: () => setSelection({ kind: "context", id: link.src }), style: linkButtonStyle, children: link.src_title || link.src }, `${link.src}:${link.edge_type}`)))) : (_jsx("span", { style: { color: "var(--ink3)", fontSize: 12 }, children: "none" })) }), _jsx(MetaBlock, { label: "Shares", children: links?.shares?.length ? (links.shares.map((share, idx) => (_jsx(Pill, { children: String(share.scope || share.team_id || "share") }, idx)))) : (_jsx("span", { style: { color: "var(--ink3)", fontSize: 12 }, children: "private" })) }), error ? (_jsx("div", { style: { border: "1px solid var(--rose)", diff --git a/dhee/ui/web/src/views/MemoryView.tsx b/dhee/ui/web/src/views/MemoryView.tsx index 1b92a1e..103ac27 100644 --- a/dhee/ui/web/src/views/MemoryView.tsx +++ b/dhee/ui/web/src/views/MemoryView.tsx @@ -747,18 +747,11 @@ export function MemoryView({ ); return ( -
+
-
+
-
+
{selectedItem?.proposal_status === "pending_review" && (viewer?.role === "manager" || viewer?.role === "admin") ? ( <> @@ -1022,16 +1000,7 @@ export function MemoryView({
{editing && !selectedReadOnly ? (
@@ -1041,7 +1010,7 @@ export function MemoryView({ placeholder="Context title" style={inputStyle} /> -
+
setDraft((d) => ({ ...d, project_id: e.target.value }))} @@ -1097,13 +1066,7 @@ export function MemoryView({
) : null}
{error ? ( @@ -536,8 +550,12 @@ function RouterSavingsDashboard({ } > - {activeRows.length === 0 ? ( - No active Claude Code or Codex sessions detected. + {loading && activeRows.length === 0 ? ( + + ) : activeRows.length === 0 ? ( + + No active Claude Code or Codex sessions detected. + ) : (
{activeRows.map((row) => ( @@ -573,6 +591,7 @@ function ActiveSessionCard({ const live = row.live_usage; return (
+ ); + })} +
+ + ); +} + +function ShimmerBlock({ + width = "100%", + height = 12, + radius = 4, + style, +}: { + width?: string | number; + height?: number; + radius?: number; + style?: CSSProperties; +}) { return ( + {children}
); } +function RouterMetricSkeleton() { + return ( + +
+ {Array.from({ length: 4 }).map((_, index) => ( +
+ + + +
+ ))} +
+
+ ); +} + +function ActiveSessionsSkeleton() { + return ( + + {Array.from({ length: 3 }).map((_, index) => ( +
+
+
+ + + +
+
+ + + +
+ +
+
+ ))} +
+ ); +} + +function SessionTableSkeleton() { + return ( + +
+ {Array.from({ length: 6 }).map((_, index) => ( +
+ + + + + + + +
+ ))} +
+ +
+ ); +} + function SelectedSession({ row, showHeader = true, @@ -1094,7 +1323,7 @@ function MetricCard({ function MiniStat({ label, value }: { label: string; value: string }) { return ( -
+
{value}
diff --git a/tests/test_ui.py b/tests/test_ui.py index a50b4b5..659cc07 100644 --- a/tests/test_ui.py +++ b/tests/test_ui.py @@ -5,6 +5,7 @@ from fastapi.testclient import TestClient +from dhee.core.learnings import LearningExchange from dhee.db.sqlite import SQLiteManager from dhee.router import ptr_store from dhee.ui.server import create_app @@ -24,6 +25,8 @@ def test_ui_source_is_canvas_router_app(): nav = (WEB_DIR / "src" / "components" / "NavRail.tsx").read_text(encoding="utf-8") canvas = (WEB_DIR / "src" / "components" / "canvas" / "useInfiniteCanvas.ts").read_text(encoding="utf-8") app = (WEB_DIR / "src" / "App.tsx").read_text(encoding="utf-8") + product_views = (WEB_DIR / "src" / "views" / "ProductViews.tsx").read_text(encoding="utf-8") + router_view = (WEB_DIR / "src" / "views" / "RouterView.tsx").read_text(encoding="utf-8") for label in ["HOME", "FIREWALL", "BRAIN", "HANDOFF", "REPLAY", "LEARN", "PACKS"]: assert f'label: "{label}"' in nav @@ -35,6 +38,11 @@ def test_ui_source_is_canvas_router_app(): assert 'view === "replay"' in app assert 'view === "learnings"' in app assert 'view === "portability"' in app + assert 'label="CURRENT WORK"' in product_views + assert 'label="LATEST SAVED HANDOFF"' in product_views + assert "ProductLoadingSkeleton" in product_views + assert "ActiveSessionsSkeleton" in router_view + assert 'label="Loading active sessions"' in router_view def test_ui_serves_built_spa_and_core_api(tmp_path, monkeypatch): @@ -82,6 +90,47 @@ def test_ui_product_screen_apis(tmp_path, monkeypatch): assert key in payload +def test_ui_learning_rows_are_digest_first(tmp_path, monkeypatch): + monkeypatch.setenv("DHEE_DATA_DIR", str(tmp_path / "dhee-data")) + monkeypatch.setenv("ENGRAM_HANDOFF_DB", str(tmp_path / "handoff.db")) + monkeypatch.setenv("DHEE_UI_REPO", str(tmp_path)) + + exchange = LearningExchange() + raw_body = "\n".join( + [ + "Model: internal-model", + "Session: session-123", + "private reasoning should not be shown in review lists", + "Representative turns:", + "Use routed grep before reading raw files when the repo is large.", + " ".join(["extra-noise"] * 120), + ] + ) + candidate = exchange.submit( + title="Inspect before reading", + body=raw_body, + source_agent_id="codex", + source_harness="codex", + evidence=[{"kind": "successful_outcome"}], + metadata={"model": "codex-local"}, + ) + + client = TestClient(create_app()) + response = client.get("/api/ui/learnings") + assert response.status_code == 200 + items = response.json()["items"] + row = next(item for item in items if item["id"] == candidate.id) + + assert "" not in row["body"] + assert "private reasoning" not in row["body"] + assert "Representative turns" not in row["body"] + assert len(row["body"]) <= 420 + assert row["raw_body_chars"] > len(row["body"]) + assert row["evidence_count"] == 1 + assert row["needs_distillation"] is True + assert "evidence" not in row + + def test_ui_product_router_metrics_use_real_pointer_rollup(tmp_path, monkeypatch): data_dir = tmp_path / "dhee-data" history_db = tmp_path / "history.db"