orbital-command 1.0.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/commands/launch.js +0 -1
- package/bin/lib/helpers.js +1 -31
- package/bin/orbital.js +34 -32
- package/dist/assets/Landing-B6q9U0Vd.js +11 -0
- package/dist/assets/{PrimitivesConfig-DThSipFy.js → PrimitivesConfig-TlFvypvg.js} +9 -14
- package/dist/assets/{QualityGates-B4kxM5UU.js → QualityGates-D8uvclW4.js} +1 -1
- package/dist/assets/SessionTimeline-QUaJw6Aa.js +1 -0
- package/dist/assets/Settings-CAEnAZAk.js +12 -0
- package/dist/assets/{SourceControl-BMNIz7Lt.js → SourceControl-DPeSBaMV.js} +7 -12
- package/dist/assets/{WorkflowVisualizer-CxuSBOYu.js → WorkflowVisualizer-DHrIjx6W.js} +1 -1
- package/dist/assets/{arrow-down-DVPp6_qp.js → arrow-down-DnfKgF33.js} +1 -1
- package/dist/assets/{bot-NFaJBDn_.js → bot-DUPnHZfM.js} +1 -1
- package/dist/assets/{circle-x-IsFCkBZu.js → circle-x-B4nA79je.js} +1 -1
- package/dist/assets/{file-text-J1cebZXF.js → file-text-PnzRO4pO.js} +1 -1
- package/dist/assets/{globe-WzeyHsUc.js → globe-CIX_GBr0.js} +1 -1
- package/dist/assets/index-B-B-tTjw.css +1 -0
- package/dist/assets/index-DQVAzHMu.js +354 -0
- package/dist/assets/{key-CKR8JJSj.js → key-DpAZM-3d.js} +1 -1
- package/dist/assets/{minus-CHBsJyjp.js → minus-CJlpKNUB.js} +1 -1
- package/dist/assets/{radio-xqZaR-Uk.js → radio-DhynLcSx.js} +1 -1
- package/dist/assets/{rocket-D_xvvNG6.js → rocket-DnuQh3sF.js} +1 -1
- package/dist/assets/{shield-TdB1yv_a.js → shield-DLMQmvFQ.js} +1 -1
- package/dist/assets/{ui-BmsSg9jU.js → ui-QhrRH5wk.js} +6 -6
- package/dist/assets/{useSocketListener-0L5yiN5i.js → useSocketListener-DPrExNDV.js} +1 -1
- package/dist/assets/{useWorkflowEditor-CqeRWVQX.js → useWorkflowEditor-BxN7phfr.js} +2 -2
- package/dist/assets/{workflow-constants-Rw-GmgHZ.js → workflow-constants-ZcCN11vm.js} +1 -1
- package/dist/assets/{zap-C9wqYMpl.js → zap-eJ3z8HRI.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/server/server/index.js +9 -10
- package/dist/server/server/launch.js +0 -3
- package/dist/server/server/routes/sync-routes.js +175 -0
- package/dist/server/server/services/telemetry-service.js +143 -0
- package/dist/server/server/wizard/detect.js +0 -79
- package/dist/server/server/wizard/index.js +43 -113
- package/dist/server/server/wizard/phases/setup-wizard.js +4 -34
- package/dist/server/server/wizard/types.js +3 -25
- package/dist/server/shared/workflow-presets.js +22 -0
- package/package.json +1 -1
- package/server/index.ts +7 -14
- package/server/launch.ts +0 -3
- package/server/routes/sync-routes.ts +205 -0
- package/server/wizard/detect.ts +1 -81
- package/server/wizard/index.ts +45 -146
- package/server/wizard/phases/setup-wizard.ts +7 -38
- package/server/wizard/types.ts +4 -45
- package/shared/workflow-presets.ts +28 -0
- package/templates/hooks/block-push.sh +16 -2
- package/templates/hooks/git-commit-guard.sh +3 -2
- package/dist/assets/Landing-CfQdHR0N.js +0 -11
- package/dist/assets/SessionTimeline-Bz1iZnmg.js +0 -1
- package/dist/assets/Settings-DLcZwbCT.js +0 -12
- package/dist/assets/index-BdJ57EhC.css +0 -1
- package/dist/assets/index-o4ScMAuR.js +0 -349
- package/dist/server/server/wizard/phases/confirm.js +0 -39
- package/dist/server/server/wizard/phases/project-setup.js +0 -90
- package/dist/server/server/wizard/phases/welcome.js +0 -32
- package/dist/server/server/wizard/phases/workflow-setup.js +0 -22
- package/server/wizard/phases/confirm.ts +0 -45
- package/server/wizard/phases/project-setup.ts +0 -106
- package/server/wizard/phases/welcome.ts +0 -39
- package/server/wizard/phases/workflow-setup.ts +0 -28
|
@@ -1,32 +1,27 @@
|
|
|
1
|
-
import{E as Mt,j as e,L as lt,G as ct,H as dt}from"./ui-
|
|
1
|
+
import{E as Mt,j as e,L as lt,G as ct,H as dt}from"./ui-QhrRH5wk.js";import{a as d,b as Tt}from"./vendor-Bqt8AJn2.js";import{c as Ee,s as ee,a as R,E as $t,T as Ht,S as Ft,X as ft,u as Pe,C as Ne,b as Ce,F as ut,d as Ge,P as ht,e as Me,f as Ue,g as mt,B as se,h as je,i as Rt,j as Ot,k as xt,W as Dt,l as At,A as Lt,m as It,n as Se,o as pt,p as Bt,G as Wt,L as zt,q as _t,r as Gt,t as Ut,v as Vt,D as Jt,w as Kt,x as qe,y as Yt,z as Zt}from"./index-DQVAzHMu.js";import{C as qt,a as Xt}from"./workflow-constants-ZcCN11vm.js";import{B as Te}from"./bot-DUPnHZfM.js";import{P as gt,S as Qt,u as es}from"./useWorkflowEditor-BxN7phfr.js";import{Z as $e}from"./zap-eJ3z8HRI.js";import{F as Xe}from"./file-text-PnzRO4pO.js";import{A as Qe}from"./arrow-down-DnfKgF33.js";import{G as ts}from"./globe-CIX_GBr0.js";import"./charts-LGLb8hyU.js";/**
|
|
2
2
|
* @license lucide-react v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ss=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],et=
|
|
6
|
+
*/const ss=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],et=Ee("corner-down-left",ss);/**
|
|
7
7
|
* @license lucide-react v0.577.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const rs=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],bt=Ee("file",rs);/**
|
|
12
12
|
* @license lucide-react v0.577.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const os=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],jt=Ee("folder",os);/**
|
|
17
17
|
* @license lucide-react v0.577.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const ns=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],jt=we("folder",ns);/**
|
|
22
|
-
* @license lucide-react v0.577.0 - ISC
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const as=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],is=we("timer",as);function ls(t){const[o,r]=d.useState(null),[s,i]=d.useState(!1),[n,a]=d.useState(null),l=d.useCallback(async()=>{if(!t){r(null),a(null),i(!1);return}i(!0),a(null);try{const u=await fetch(`/api/orbital/sync/state/${t}`);u.ok?r(await u.json()):a(`Sync state fetch failed (HTTP ${u.status})`)}catch(u){a(u instanceof Error?u.message:"Sync state fetch failed")}finally{i(!1)}},[t]);return d.useEffect(()=>{l()},[l]),d.useEffect(()=>{const u=()=>l();return ee.on("sync:file:updated",u),ee.on("sync:file:created",u),ee.on("sync:file:deleted",u),()=>{ee.off("sync:file:updated",u),ee.off("sync:file:created",u),ee.off("sync:file:deleted",u)}},[l]),{report:o,loading:s,error:n,refetch:l}}function cs(){const[t,o]=d.useState(null),[r,s]=d.useState(!1),[i,n]=d.useState(null),a=d.useCallback(async()=>{s(!0),n(null);try{const l=await fetch("/api/orbital/sync/global-state");l.ok?o(await l.json()):n(`Global sync state fetch failed (HTTP ${l.status})`)}catch(l){n(l instanceof Error?l.message:"Global sync state fetch failed")}finally{s(!1)}},[]);return d.useEffect(()=>{a()},[a]),d.useEffect(()=>{const l=()=>a();return ee.on("sync:file:updated",l),ee.on("sync:file:created",l),ee.on("sync:file:deleted",l),()=>{ee.off("sync:file:updated",l),ee.off("sync:file:created",l),ee.off("sync:file:deleted",l)}},[a]),{report:t,loading:r,error:i,refetch:a}}async function ds(t,o,r){return(await fetch("/api/orbital/sync/resolve-drift",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:t,relativePath:o,resolution:r})})).ok}const fs=Mt,wt=d.forwardRef(({className:t,...o},r)=>e.jsx(lt,{ref:r,className:R("card-glass inline-flex h-8 items-center justify-center rounded bg-surface p-0.5 border border-border text-muted-foreground",t),...o}));wt.displayName=lt.displayName;const vt=d.forwardRef(({className:t,...o},r)=>e.jsx(ct,{ref:r,className:R("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-2.5 py-1 text-xxs uppercase tracking-wider font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-surface-light data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...o}));vt.displayName=ct.displayName;const us=d.forwardRef(({className:t,...o},r)=>e.jsx(dt,{ref:r,className:R("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...o}));us.displayName=dt.displayName;const kt={guard:{icon:Ft,bg:"bg-red-500/10",border:"border-red-500/30",text:"text-red-400",hex:"#ef4444"},gate:{icon:Ht,bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-400",hex:"#f59e0b"},lifecycle:{icon:qt,bg:"bg-cyan-500/10",border:"border-cyan-500/30",text:"text-cyan-400",hex:"#06b6d4"},observer:{icon:$t,bg:"bg-zinc-500/10",border:"border-zinc-500/30",text:"text-zinc-400",hex:"#71717a"}};function Ve({hook:t,selected:o,onClick:r,onRemove:s}){const i=kt[t.category],n=i.icon;return e.jsxs("button",{type:"button",onClick:r,"data-pipeline-path":t.filePath??void 0,className:R("inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors",i.bg,i.border,i.text,"hover:brightness-125 cursor-pointer",o&&"glow-selected-pulse"),style:o?{"--glow-color":`${i.hex}A0`,"--glow-color-wide":`${i.hex}40`}:void 0,children:[e.jsx(n,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[120px]",children:t.id}),s&&e.jsx("span",{role:"button",onClick:a=>{a.stopPropagation(),s()},className:"ml-0.5 rounded-full p-0.5 hover:bg-red-500/20",children:e.jsx(ft,{className:"h-2.5 w-2.5"})})]})}function Be({node:t,depth:o,selectedPath:r,expandedPaths:s,primitiveType:i,onSelect:n,onToggle:a,onContextAction:l,hookCategoryMap:u,agentTeamMap:b,dimmed:$}){var q,X;const x=t.type==="folder",P=s.has(t.path),w=t.path===r,m=(q=t.frontmatter)!=null&&q.name?String(t.frontmatter.name):t.name,g=x?"":`tree::${i}::${t.path}`,{attributes:j,listeners:D,setNodeRef:I,isDragging:v}=Pe({id:g,disabled:x,data:{type:i,path:t.path,name:m}}),M=()=>{x?a(t.path):n(t)},B=x||u==null?void 0:u.get(t.path),L=B?kt[B]:void 0,ne=L==null?void 0:L.icon,y=x||b==null?void 0:b.get(t.path),C=w&&!x?B?Xt[B]:y?y.color:i==="skills"?"#22c55e":"#00bcd4":void 0,_=o>0,Z=C?{"--glow-color":`${C}50`,backgroundColor:`${C}18`,color:C}:{};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:x?void 0:I,"data-tree-path":x?void 0:t.path,className:R("group flex w-full items-center rounded text-left text-xs transition-colors",w&&C?"glow-selected":w?"bg-[#00bcd4]/15 text-[#00bcd4]":"text-muted-foreground hover:bg-surface-light hover:text-foreground",v&&"opacity-40",$&&!w&&"opacity-50"),style:Z,...x?{}:{...D,...j},children:[_&&e.jsx("span",{"aria-hidden":!0,className:"self-stretch shrink-0 border-l border-emerald-500/25",style:{marginLeft:`${(o-1)*14+14}px`,width:0}}),e.jsxs("button",{onClick:M,className:"flex flex-1 min-w-0 items-center gap-1.5 px-2 py-1",style:{paddingLeft:_?"10px":`${o*12+8}px`},children:[x?e.jsxs(e.Fragment,{children:[P?e.jsx(Ce,{className:"h-3 w-3 shrink-0 opacity-60"}):e.jsx(Se,{className:"h-3 w-3 shrink-0 opacity-60"}),P?e.jsx(bt,{className:"h-3.5 w-3.5 shrink-0 text-warning-amber/70"}):e.jsx(jt,{className:"h-3.5 w-3.5 shrink-0 text-warning-amber/70"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-3"}),e.jsx(gt,{className:"h-3.5 w-3.5 shrink-0 opacity-50"})]}),e.jsx("span",{className:"min-w-0 truncate",title:m,children:m}),L&&ne&&e.jsxs("span",{className:R("inline-flex shrink-0 items-center gap-0.5 rounded border px-1 py-0 text-[9px] font-medium",L.bg,L.border,L.text),children:[e.jsx(ne,{className:"h-2.5 w-2.5"}),B]}),y&&e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 rounded border px-1 py-0 text-[9px] font-medium",style:{color:y.color,borderColor:`${y.color}4D`,backgroundColor:`${y.color}1A`},children:[e.jsx(Te,{className:"h-2.5 w-2.5"}),y.team]})]}),e.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:z=>{z.stopPropagation(),l("rename",t)},className:"rounded p-0.5 hover:bg-surface-light",title:"Rename",children:e.jsx(pt,{className:"h-3 w-3"})}),t.type==="file"&&e.jsx("button",{onClick:z=>{z.stopPropagation(),l("delete",t)},className:"rounded p-0.5 hover:bg-ask-red/20 text-muted-foreground hover:text-ask-red",title:"Delete",children:e.jsx(Ge,{className:"h-3 w-3"})}),t.type==="folder"&&e.jsx("button",{onClick:z=>{z.stopPropagation(),l("new-file",t)},className:"rounded p-0.5 hover:bg-surface-light",title:"New file",children:e.jsx(ut,{className:"h-3 w-3"})})]})]}),x&&P&&((X=t.children)==null?void 0:X.map(z=>e.jsx(Be,{node:z,depth:o+1,selectedPath:r,expandedPaths:s,primitiveType:i,onSelect:n,onToggle:a,onContextAction:l,hookCategoryMap:u,agentTeamMap:b,dimmed:$},z.path)))]})}function hs({menu:t,onRename:o,onDelete:r,onNewFile:s,onNewFolder:i,onClose:n}){return Tt.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:n}),e.jsxs("div",{className:"fixed z-50 min-w-[140px] rounded border border-border bg-surface shadow-lg",style:{top:t.y,left:t.x},onClick:a=>a.stopPropagation(),children:[e.jsxs("button",{onClick:()=>o(t.node),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-surface-light transition-colors",children:[e.jsx(pt,{className:"h-3 w-3"}),"Rename"]}),t.node.type==="folder"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>s(t.node.path),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-surface-light transition-colors",children:[e.jsx(gt,{className:"h-3 w-3"}),"New File"]}),e.jsxs("button",{onClick:()=>i(t.node.path),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-surface-light transition-colors",children:[e.jsx(jt,{className:"h-3 w-3"}),"New Folder"]})]}),e.jsx("div",{className:"border-t border-border"}),t.node.type==="file"&&e.jsxs("button",{onClick:()=>r(t.node),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-ask-red hover:bg-surface-light transition-colors",children:[e.jsx(Ge,{className:"h-3 w-3"}),"Delete"]})]})]}),document.body)}const ms=[{value:"agents",icon:Te,label:"Agents"},{value:"skills",icon:Ue,label:"Skills"},{value:"hooks",icon:$e,label:"Hooks"}];function tt(t){const o=[];function r(s){for(const i of s)i.type==="file"&&o.push(i),i.children&&r(i.children)}return r(t),o.sort((s,i)=>{var l,u;const n=(l=s.frontmatter)!=null&&l.name?String(s.frontmatter.name):s.name,a=(u=i.frontmatter)!=null&&u.name?String(i.frontmatter.name):i.name;return n.localeCompare(a)})}function xs({tree:t,loading:o,selectedPath:r,type:s,onSelect:i,onRefresh:n,onTabChange:a,activePaths:l,activeSkills:u,hookCategoryMap:b,agentTeamMap:$}){const[x,P]=d.useState(new Set),w=Me(),[m,g]=d.useState(null),[j,D]=d.useState(null),[I,v]=d.useState(""),[M,B]=d.useState(null),[L,ne]=d.useState("");d.useEffect(()=>{r&&requestAnimationFrame(()=>{const f=document.querySelector(`[data-tree-path="${CSS.escape(r)}"]`);f==null||f.scrollIntoView({behavior:"smooth",block:"nearest"})})},[r]);const y=s==="skills"?tt(t):t,{activeItems:C,inactiveFiles:_}=d.useMemo(()=>{if(!l)return{activeItems:null,inactiveFiles:null};const f=tt(t);if(u){const Q=new Set(u.map(J=>J.path)),de=new Map(f.map(J=>[J.path,J])),fe=[];for(const J of u){const me=de.get(J.path);me&&fe.push({node:me,depth:J.depth})}const he=f.filter(J=>!Q.has(J.path));return{activeItems:fe,inactiveFiles:he}}const S=[],G=[];for(const Q of f)l.has(Q.path)?S.push({node:Q,depth:0}):G.push(Q);return{activeItems:S,inactiveFiles:G}},[t,l,u]),Z=d.useCallback(f=>{P(S=>{const G=new Set(S);return G.has(f)?G.delete(f):G.add(f),G})},[]),q=d.useCallback((f,S)=>{f.preventDefault(),g({node:S,x:f.clientX,y:f.clientY})},[]),X=d.useCallback(()=>{g(null)},[]),z=d.useCallback(f=>{D(f),v(f.name),g(null)},[]),ae=d.useCallback(async()=>{if(!j||!I.trim()||I===j.name){D(null);return}const f=j.path.includes("/")?j.path.slice(0,j.path.lastIndexOf("/")):"",S=f?`${f}/${I}`:I;try{if(!(await fetch(w(`/config/${s}/rename`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:j.path,newPath:S})})).ok)throw new Error("Rename failed");n()}catch{}D(null)},[j,I,s,n,w]),le=d.useCallback(async f=>{g(null);try{if(!(await fetch(w(`/config/${s}/file?path=${encodeURIComponent(f.path)}`),{method:"DELETE"})).ok)throw new Error("Delete failed");n()}catch{}},[s,n,w]),V=d.useCallback((f,S)=>{B({kind:f,parent:S}),ne(""),g(null)},[]),p=d.useCallback((f,S)=>{f==="rename"?z(S):f==="delete"?le(S):f==="new-file"?V("file",S.path):f==="new-folder"&&V("folder",S.path)},[z,le,V]),ce=d.useCallback(async()=>{if(!M||!L.trim()){B(null);return}const f=M.parent?`${M.parent}/${L}`:L;try{if(M.kind==="folder"){if(!(await fetch(w(`/config/${s}/folder`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:f})})).ok)throw new Error("Create folder failed")}else if(!(await fetch(w(`/config/${s}/file`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:f,content:""})})).ok)throw new Error("Create file failed");n()}catch{}B(null)},[M,L,s,n,w]),ge=(f,S,G=0)=>e.jsx("div",{onContextMenu:Q=>q(Q,f),children:e.jsx(Be,{node:f,depth:G,selectedPath:r,expandedPaths:x,primitiveType:s,onSelect:i,onToggle:Z,onContextAction:p,hookCategoryMap:b,agentTeamMap:$,dimmed:S})},f.path);return e.jsxs("div",{className:"flex h-full flex-col",onClick:X,children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-2 py-1.5",children:[e.jsx(fs,{value:s,onValueChange:f=>a(f),children:e.jsx(wt,{children:ms.map(({value:f,icon:S,label:G})=>e.jsxs(vt,{value:f,className:"gap-1.5",children:[e.jsx(S,{className:"h-3 w-3"}),G]},f))})}),e.jsx("button",{onClick:()=>V("file",""),className:"rounded p-1 text-muted-foreground hover:bg-surface-light hover:text-foreground transition-colors",title:"New file",children:e.jsx(ut,{className:"h-3.5 w-3.5"})})]}),e.jsx(ht,{className:"flex-1",children:e.jsxs("div",{className:"py-1",children:[o?e.jsx("div",{className:"flex h-20 items-center justify-center",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):t.length===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground/60",children:"No files found"}):C&&_?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2 pb-1",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500/70"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-emerald-400/80",children:"Active"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/30",children:["(",C.length,")"]}),e.jsx("div",{className:"flex-1 border-t border-emerald-500/15"})]}),C.length===0?e.jsxs("div",{className:"px-3 py-2 text-[10px] text-muted-foreground/40 italic",children:["No active ",s]}):C.map(({node:f,depth:S})=>ge(f,!1,S)),e.jsxs("div",{className:"flex items-center gap-2 px-3 pt-3 pb-1",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground/30"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/40",children:"Inactive"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/20",children:["(",_.length,")"]}),e.jsx("div",{className:"flex-1 border-t border-border/20"})]}),_.length===0?e.jsxs("div",{className:"px-3 py-2 text-[10px] text-muted-foreground/40 italic",children:["All ",s," are active"]}):_.map(f=>ge(f,!0))]}):y.map(f=>e.jsx("div",{onContextMenu:S=>q(S,f),children:e.jsx(Be,{node:f,depth:0,selectedPath:r,expandedPaths:x,primitiveType:s,onSelect:i,onToggle:Z,onContextAction:p,hookCategoryMap:b,agentTeamMap:$})},f.path)),j&&e.jsx("div",{className:"px-3 py-1",children:e.jsx("input",{autoFocus:!0,value:I,onChange:f=>v(f.target.value),onKeyDown:f=>{f.key==="Enter"&&ae(),f.key==="Escape"&&D(null)},onBlur:ae,className:"w-full rounded border border-accent-blue/40 bg-surface px-2 py-0.5 text-xs text-foreground outline-none",placeholder:"New name"})}),M&&e.jsx("div",{className:"px-3 py-1",children:e.jsx("input",{autoFocus:!0,value:L,onChange:f=>ne(f.target.value),onKeyDown:f=>{f.key==="Enter"&&ce(),f.key==="Escape"&&B(null)},onBlur:ce,className:"w-full rounded border border-accent-blue/40 bg-surface px-2 py-0.5 text-xs text-foreground outline-none",placeholder:M.kind==="folder"?"Folder name":"File name"})})]})}),m&&e.jsx(hs,{menu:m,onRename:z,onDelete:le,onNewFile:f=>V("file",f),onNewFolder:f=>V("folder",f),onClose:X})]})}const N={comment:"#6B7280",keyword:"#e91e63",string:"#00c853",number:"#ffab00",variable:"#40c4ff",heading:"#00bcd4",bold:"#e0e0e0",operator:"#e91e63",key:"#40c4ff",builtin:"#536dfe",link:"#8B5CF6",punctuation:"#6B7280"};function ps(t){return t?t.endsWith(".sh")?"shell":t.endsWith(".md")?"markdown":t.endsWith(".yml")||t.endsWith(".yaml")?"yaml":t.endsWith(".json")||t.endsWith(".jsonc")?"json":"text":"text"}function gs(t,o){return o==="text"?[{text:t}]:o==="shell"?js(t):o==="markdown"?ws(t):o==="yaml"?vs(t):o==="json"?ks(t):[{text:t}]}const bs=new Set(["if","then","else","elif","fi","for","in","do","done","while","until","case","esac","function","return","exit","local","export","readonly","source","set","unset","shift","break","continue","true","false"]);function js(t){const o=[];if(t.trimStart().startsWith("#"))return[{text:t,color:N.comment,italic:!0}];let s=0;for(;s<t.length;){if(t[s]==="#"&&(s===0||/\s/.test(t[s-1]))){o.push({text:t.slice(s),color:N.comment,italic:!0});break}if(t[s]==='"'){const a=We(t,s,'"');o.push({text:t.slice(s,a),color:N.string}),s=a;continue}if(t[s]==="'"){const a=We(t,s,"'");o.push({text:t.slice(s,a),color:N.string}),s=a;continue}if(t[s]==="$"){if(t[s+1]==="{"){const a=t.indexOf("}",s+2),l=a===-1?t.length:a+1;o.push({text:t.slice(s,l),color:N.variable}),s=l}else if(t[s+1]==="(")o.push({text:"$(",color:N.variable}),s+=2;else{const a=t.slice(s).match(/^\$[A-Za-z_]\w*/);a?(o.push({text:a[0],color:N.variable}),s+=a[0].length):(o.push({text:"$",color:N.variable}),s++)}continue}if("|&;><".includes(t[s])){let a=t[s];s+1<t.length&&(t.slice(s,s+2)==="||"||t.slice(s,s+2)==="&&"||t.slice(s,s+2)===">>"||t.slice(s,s+2)==="<<")&&(a=t.slice(s,s+2)),o.push({text:a,color:N.operator}),s+=a.length;continue}const i=t.slice(s).match(/^[A-Za-z_]\w*/);if(i){const a=i[0];bs.has(a)?o.push({text:a,color:N.keyword,bold:!0}):o.push({text:a}),s+=a.length;continue}const n=t.slice(s).match(/^\d+/);if(n){o.push({text:n[0],color:N.number}),s+=n[0].length;continue}o.push({text:t[s]}),s++}return o}function ws(t){const o=t.trimStart();if(o.match(/^(#{1,6})\s/))return[{text:t,color:N.heading,bold:!0}];if(o.startsWith("```"))return[{text:t,color:N.builtin}];if(o.startsWith("<!--"))return[{text:t,color:N.comment,italic:!0}];if(/^(\s*[-*+]|\s*\d+\.)\s/.test(t)){const s=t.match(/^(\s*[-*+\d.]+\s)(.*)$/);if(s)return[{text:s[1],color:N.operator},...st(s[2])]}return st(t)}function st(t){const o=[];let r=0;for(;r<t.length;){if(t[r]==="`"){const s=t.indexOf("`",r+1);if(s!==-1){o.push({text:t.slice(r,s+1),color:N.builtin}),r=s+1;continue}}if(t.slice(r,r+2)==="**"){const s=t.indexOf("**",r+2);if(s!==-1){o.push({text:t.slice(r,s+2),color:N.bold,bold:!0}),r=s+2;continue}}if(t[r]==="["){const s=t.slice(r).match(/^\[([^\]]*)\]\(([^)]*)\)/);if(s){o.push({text:`[${s[1]}]`,color:N.heading}),o.push({text:`(${s[2]})`,color:N.link}),r+=s[0].length;continue}}o.push({text:t[r]}),r++}return o}function vs(t){if(t.trimStart().startsWith("#"))return[{text:t,color:N.comment,italic:!0}];const r=t.match(/^(\s*)([\w.-]+)(:)(.*)/);if(r){const s=[{text:r[1]},{text:r[2],color:N.key},{text:r[3],color:N.punctuation}],i=r[4];return i&&s.push(...ot(i)),s}if(/^\s*-\s/.test(t)){const s=t.match(/^(\s*-\s)(.*)/);if(s)return[{text:s[1],color:N.operator},...ot(s[2])]}return[{text:t}]}function ot(t){const o=t.trim();if(!o)return[{text:t}];if(/^["']/.test(o))return[{text:t,color:N.string}];if(/^(true|false|null|yes|no)$/i.test(o))return[{text:t,color:N.keyword}];if(/^-?\d+(\.\d+)?$/.test(o))return[{text:t,color:N.number}];if(o.startsWith("#"))return[{text:t,color:N.comment,italic:!0}];const r=t.indexOf(" #");return r!==-1?[{text:t.slice(0,r)},{text:t.slice(r),color:N.comment,italic:!0}]:[{text:t,color:N.string}]}function ks(t){const o=[];let r=0;for(;r<t.length;){if(t[r]==='"'){const n=We(t,r,'"'),a=t.slice(r,n),u=t.slice(n).trimStart().startsWith(":")?N.key:N.string;o.push({text:a,color:u}),r=n;continue}const s=t.slice(r).match(/^-?\d+(\.\d+)?([eE][+-]?\d+)?/);if(s){o.push({text:s[0],color:N.number}),r+=s[0].length;continue}const i=t.slice(r).match(/^(true|false|null)\b/);if(i){o.push({text:i[0],color:N.keyword}),r+=i[0].length;continue}if("{}[]:,".includes(t[r])){o.push({text:t[r],color:N.punctuation}),r++;continue}o.push({text:t[r]}),r++}return o}function We(t,o,r){let s=o+1;for(;s<t.length;){if(t[s]==="\\"){s+=2;continue}if(t[s]===r)return s+1;s++}return t.length}const rt="'JetBrains Mono', 'SF Mono', 'Fira Code', monospace";function ys({value:t,onChange:o,filePath:r}){const s=d.useRef(null),i=d.useRef(null),n=d.useRef(null),a=d.useMemo(()=>ps(r),[r]),l=d.useMemo(()=>t.split(`
|
|
27
|
-
`),[t]),u=d.useMemo(()=>l.map(x=>gs(x,a)),[l,a]),b=d.useCallback(()=>{const x=s.current;i.current&&(i.current.scrollTop=(x==null?void 0:x.scrollTop)??0),n.current&&(n.current.scrollTop=(x==null?void 0:x.scrollTop)??0,n.current.scrollLeft=(x==null?void 0:x.scrollLeft)??0)},[]),$={fontFamily:rt,fontSize:"12px",lineHeight:"1.625",padding:"12px",tabSize:2};return e.jsxs("div",{className:"flex flex-1 overflow-hidden rounded border border-border bg-surface transition-colors focus-within:border-accent-blue/50",style:{fontFamily:rt},children:[e.jsx("div",{ref:i,"aria-hidden":!0,className:"select-none overflow-hidden border-r border-border py-3 pl-2 pr-3 text-right text-muted-foreground/40",style:{fontSize:"12px",lineHeight:"1.625"},children:l.map((x,P)=>e.jsx("div",{children:P+1},P))}),e.jsxs("div",{className:"relative flex-1 min-w-0 overflow-hidden",children:[e.jsx("pre",{ref:n,"aria-hidden":!0,className:"absolute inset-0 overflow-hidden whitespace-pre pointer-events-none m-0",style:$,children:u.map((x,P)=>e.jsx("div",{children:x.length===0?" ":x.map((w,m)=>e.jsx("span",{style:{color:w.color,fontWeight:w.bold?600:void 0,fontStyle:w.italic?"italic":void 0},children:w.text},m))},P))}),e.jsx("textarea",{ref:s,value:t,onChange:x=>o(x.target.value),onScroll:b,className:"relative z-10 w-full h-full resize-none bg-transparent outline-none",style:{...$,color:"transparent",caretColor:"hsl(0 0% 88%)",WebkitTextFillColor:"transparent"},spellCheck:!1})]})]})}function Ns({filePath:t,content:o,setContent:r,frontmatter:s,setFrontmatterField:i,body:n,setBody:a,dirty:l,saving:u,loading:b,error:$,onSave:x}){const P=d.useCallback(g=>{(g.metaKey||g.ctrlKey)&&g.key==="s"&&(g.preventDefault(),l&&!u&&x())},[l,u,x]);if(d.useEffect(()=>(window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)),[P]),!t)return e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx(Xe,{className:"h-10 w-10 text-muted-foreground/30"}),e.jsx("p",{className:"text-sm text-muted-foreground/60",children:"Select a file to edit"})]})});if(b)return e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})});const w=Object.keys(s),m=w.length>0;return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Xe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-xs text-foreground",children:t}),l&&e.jsx(se,{variant:"warning",className:"shrink-0 text-[10px] px-1 py-0",children:"unsaved"})]}),e.jsxs(je,{variant:"default",size:"sm",disabled:!l||u,onClick:x,className:"shrink-0",children:[e.jsx(Qt,{className:"mr-1.5 h-3.5 w-3.5"}),u?"Saving...":"Save"]})]}),$&&e.jsxs("div",{className:"flex items-center gap-2 border-b border-red-500/20 bg-red-500/10 px-3 py-1.5 text-xs text-ask-red",children:[e.jsx(Rt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:$})]}),m&&e.jsxs("div",{className:"space-y-2 border-b border-border px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:"Frontmatter"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsx("div",{className:"grid gap-2",children:w.map(g=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"w-28 shrink-0 text-right text-xxs text-muted-foreground",children:g}),e.jsx("input",{value:s[g]??"",onChange:j=>i(g,j.target.value),className:R("flex-1 rounded border border-border bg-surface px-2 py-1 text-xs text-foreground","outline-none focus:border-accent-blue/50 transition-colors")})]},g))})]}),e.jsxs("div",{className:"flex flex-1 flex-col min-h-0 p-3",children:[m&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:"Content"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsx(ys,{value:n,onChange:a,filePath:t})]})]})}const Cs={synced:{color:"bg-emerald-500",label:"Synced",title:"Synced with global"},override:{color:"bg-blue-500",label:"Override",title:"Project override — not tracking global"},drifted:{color:"bg-amber-500",label:"Drifted",title:"Modified outside dashboard — needs resolution"},absent:{color:"bg-muted-foreground/30",label:"Absent",title:"Not present in this project"}};function Ss({state:t,className:o}){const r=Cs[t];return e.jsxs("span",{className:R("inline-flex items-center gap-1",o),title:r.title,children:[e.jsx("span",{className:R("h-2 w-2 rounded-full shrink-0",r.color)}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:r.label})]})}function Es(){const{report:t,loading:o}=cs();return o||!t?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):t.projects.length===0?e.jsxs("div",{className:"text-sm text-muted-foreground p-4",children:["No projects registered. Use ",e.jsx("code",{children:"orbital register"})," to add projects."]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50",children:[e.jsx("th",{className:"text-left py-2 px-3 font-medium text-muted-foreground",children:"File"}),t.projects.map(r=>e.jsx("th",{className:"text-center py-2 px-3 font-medium text-muted-foreground",children:r.projectName},r.projectId))]})}),e.jsx("tbody",{children:t.files.map(r=>e.jsxs("tr",{className:"border-b border-border/20 hover:bg-muted/20",children:[e.jsx("td",{className:"py-1.5 px-3 font-mono text-[11px] text-foreground/80",children:r}),t.projects.map(s=>e.jsx("td",{className:"py-1.5 px-3 text-center",children:e.jsx(Ss,{state:s.states[r]??"absent"})},s.projectId))]},r))})]})})}function Ps({projectId:t,relativePath:o,onResolved:r,onCancel:s}){const[i,n]=d.useState(!1),[a,l]=d.useState(null);async function u(b){n(!0),l(null);try{await ds(t,o,b)?r():l("Failed to resolve drift. Please try again.")}catch{l("Failed to resolve drift. Please try again.")}finally{n(!1)}}return e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-amber-400",children:"Drift Detected"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This file was synced with global but has been modified outside the dashboard."}),a&&e.jsx("p",{className:"text-xs text-destructive",children:a}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx("button",{onClick:()=>u("reset-global"),disabled:i,className:"rounded border border-border bg-muted px-3 py-1.5 text-xs hover:bg-muted/80 transition-colors disabled:opacity-50",children:i?"Resolving…":"Reset to Global"}),e.jsx("button",{onClick:()=>u("pin-override"),disabled:i,className:"rounded border border-blue-500/30 bg-blue-500/10 px-3 py-1.5 text-xs text-blue-400 hover:bg-blue-500/20 transition-colors disabled:opacity-50",children:i?"Resolving…":"Pin as Override"}),e.jsx("button",{onClick:s,disabled:i,className:"ml-auto rounded px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:"Later"})]})]})}function Ne(t){const[o,r]=d.useState([]),s=Me(),i=d.useCallback(async()=>{const a=await fetch(s(`/config/${t}/tree`));if(!a.ok)throw new Error(`HTTP ${a.status}`);const l=await a.json();r(l.data??[])},[t,s]),{loading:n}=Ot(i);return d.useEffect(()=>{const a=`config:${t}:changed`,l=()=>{i()},u=a;return ee.on(u,l),()=>{ee.off(u,l)}},[t,i]),{tree:o,loading:n,refresh:i}}function yt(t){const o=new Set;for(const r of t)if(r.type==="file"&&o.add(r.path),r.children)for(const s of yt(r.children))o.add(s);return o}function _e(t){const o=new Map;for(const r of t){if(r.type==="file"){const s=r.path.split("/");if(s.length>=2){const n=s[s.length-2].toLowerCase();o.has(n)||o.set(n,r.path)}const i=r.name.replace(/\.(md|sh)$/,"").toLowerCase();o.has(i)||o.set(i,r.path)}if(r.children){const s=_e(r.children);for(const[i,n]of s)o.has(i)||o.set(i,n)}}return o}function nt(t){return t?t.replace(/^\//,"").replace(/\s+\{.*\}$/,"").toLowerCase():null}function Ie(t,o){return{id:t.id,label:t.label,category:t.category,enforcement:Dt(t),filePath:o.get(t.id)??null,timing:t.timing,blocking:t.blocking??!1,description:t.description}}function Nt(t){const{engine:o}=mt(),{tree:r}=Ne("skills"),{tree:s}=Ne("hooks"),{tree:i}=Ne("agents");return d.useMemo(()=>{var me,ve;const n=t?new At(t):o,a=n.getLists(),l=n.getAllEdges(),u=n.getAllHooks(),b=_e(r),$=_e(i),x=yt(s),P=".claude/hooks/",w=new Map;for(const c of u){const h=c.target.startsWith(P)?c.target.slice(P.length):c.target;x.has(h)&&w.set(c.id,h)}const m=new Map(u.map(c=>[c.id,c])),g=a.map(c=>c.id),j=new Map;for(const c of a){const h=new Set(c.activeHooks??[]);for(const T of h)j.set(T,(j.get(T)??0)+1)}const D=new Map;for(const c of g)D.set(c,new Set);for(const c of l)for(const h of c.hooks??[])(me=D.get(c.from))==null||me.add(h),(ve=D.get(c.to))==null||ve.add(h);for(const[,c]of D)for(const h of c)j.set(h,(j.get(h)??0)+1);const I=Math.max(1,g.length-1),v=new Set;for(const[c,h]of j)h>=I&&v.add(c);const M=[];for(const c of v){const h=m.get(c);h&&M.push(Ie(h,w))}const B={guard:0,gate:1,lifecycle:2,observer:3};M.sort((c,h)=>B[c.category]-B[h.category]);const L=new Map,ne=new Map;function y(c){var h,T;for(const E of c){if(E.type==="file"&&((h=E.frontmatter)!=null&&h["agent-mode"]&&L.set(E.path,String(E.frontmatter["agent-mode"])),Array.isArray((T=E.frontmatter)==null?void 0:T.orchestrates))){const U=E.frontmatter.orchestrates.filter(K=>typeof K=="string");U.length>0&&ne.set(E.path,U)}E.children&&y(E.children)}}y(r);function C(c){const h=b.get(c);return h?L.get(h):void 0}function _(c,h){var U;const T=h?h.path:$.get(c.toLowerCase())??null,E=(U=h==null?void 0:h.frontmatter)!=null&&U.name?String(h.frontmatter.name):c.split("-").map(K=>K.charAt(0).toUpperCase()+K.slice(1)).join(" ");return{id:c,label:E,emoji:It[c]??"",color:Lt[c]??"",filePath:T}}const Z={"red-team":"#ef4444","blue-team":"#3b82f6","green-team":"#22c55e"},q=new Set(["reference","workflows"]),X=[];function z(c,h){var T;for(const E of c)if(E.type==="folder")!q.has(E.name.toLowerCase())&&E.children&&z(E.children,E.name);else if(h&&E.name.endsWith(".md")&&((T=E.frontmatter)!=null&&T.name)){const U=E.name.replace(/\.md$/,"").toLowerCase(),K=_(U,E);K.team=h,K.color=Z[h.toLowerCase()]??(K.color||"#8B5CF6"),X.push(K)}}z(i,null),X.sort((c,h)=>c.team!==h.team?(c.team??"").localeCompare(h.team??""):c.label.localeCompare(h.label));const ae=new Map,le=new Map;for(const c of l)ae.has(c.from)||ae.set(c.from,[]),ae.get(c.from).push(c),le.has(c.to)||le.set(c.to,[]),le.get(c.to).push(c);const V=a.map(c=>{const h=new Set;for(const A of c.activeHooks??[])v.has(A)||h.add(A);for(const A of ae.get(c.id)??[])for(const Y of A.hooks??[])v.has(Y)||h.add(Y);const T=[];for(const A of h){const Y=m.get(A);Y&&T.push(Ie(Y,w))}T.sort((A,Y)=>B[A.category]-B[Y.category]);const E=[],U=le.get(c.id)??[],K=new Map;for(const A of U){const Y=nt(A.command);if(!Y||C(Y)!=="team-review")continue;const pe=A.command??A.label;K.has(pe)||K.set(pe,{skillCommand:pe,skillPath:b.get(Y)??null,agents:[...X]})}const He=[...K.values()],Fe=(ae.get(c.id)??[]).filter(A=>A.direction==="forward"||A.direction==="shortcut").map(A=>{const Y=nt(A.command),pe=(A.hooks??[]).filter(ue=>!v.has(ue)).map(ue=>m.get(ue)).filter(ue=>ue!==void 0).map(ue=>Ie(ue,w));return{edge:A,skillPath:Y?b.get(Y)??null:null,edgeHooks:pe}}),Re=(ae.get(c.id)??[]).filter(A=>A.direction==="backward");return{list:c,stageHooks:T,alwaysOnAgents:E,reviewTeams:He,forwardEdges:Fe,backwardEdges:Re}}),p=new Set,ce=new Map,ge=[...M,...V.flatMap(c=>c.stageHooks),...V.flatMap(c=>c.forwardEdges.flatMap(h=>h.edgeHooks))];for(const c of ge)c.filePath&&(p.add(c.filePath),ce.set(c.filePath,c.category));for(const c of u){const h=w.get(c.id);h&&!ce.has(h)&&ce.set(h,c.category)}const f=new Set;for(const c of V){for(const h of c.alwaysOnAgents)h.filePath&&f.add(h.filePath);for(const h of c.reviewTeams)for(const T of h.agents)T.filePath&&f.add(T.filePath)}const S=new Map;for(const[c,h]of ne){const T=[];for(const E of h){const U=b.get(E.toLowerCase());U&&T.push(U)}T.length>0&&S.set(c,T)}const G=[],Q=new Set;for(const c of V)for(const h of c.forwardEdges)h.skillPath&&!Q.has(h.skillPath)&&(Q.add(h.skillPath),G.push(h.skillPath));const de=new Map;for(const[c,h]of b)c!=="skill"&&(de.has(h)||de.set(h,c));const fe=[],he=new Set;function J(c,h,T){if(he.has(c))return;he.add(c),fe.push({path:c,name:de.get(c)??c,parentPath:h,depth:T});const E=S.get(c);if(E)for(const U of E)J(U,c,T+1)}for(const c of G)J(c,null,0);return{globalHooks:M,stages:V,skillPathMap:b,hookPathMap:w,agentPathMap:$,activeSkills:fe,activeSkillPaths:he,activeAgentPaths:f,activeHookPaths:p,hookCategoryMap:ce}},[t,o,r,s,i])}function at({agent:t,mode:o,selected:r,onClick:s,onRemove:i}){const n=t.color||"#8B5CF6";return e.jsxs("button",{type:"button",onClick:s,"data-pipeline-path":t.filePath??void 0,className:R("inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors","hover:brightness-125 cursor-pointer",r&&"glow-selected-pulse"),style:{color:n,borderColor:`${n}4D`,backgroundColor:`${n}1A`,...r?{"--glow-color":`${n}A0`,"--glow-color-wide":`${n}40`}:{}},children:[t.emoji?e.jsx("span",{className:"text-xs",children:t.emoji}):e.jsx(Te,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[100px]",children:t.label}),o==="always-on"&&e.jsx("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-green-500 shrink-0",title:"Auto-invoke"}),i&&e.jsx("span",{role:"button",onClick:a=>{a.stopPropagation(),i()},className:"ml-0.5 rounded-full p-0.5 hover:bg-red-500/20",children:e.jsx(ft,{className:"h-2.5 w-2.5"})})]})}function Ms({hook:t,dragId:o,selected:r,onClick:s,onRemove:i,editable:n}){const{attributes:a,listeners:l,setNodeRef:u,isDragging:b}=Pe({id:o,disabled:!n,data:{hookId:t.id}});return e.jsx("div",{ref:u,className:R("cursor-pointer",b&&"opacity-40"),onClick:s,...l,...a,children:e.jsx(Ve,{hook:t,selected:r,onRemove:i})})}function Ts({stage:t,selectedPath:o,onSelectItem:r,editable:s,onRemoveHook:i}){const{list:n,stageHooks:a,alwaysOnAgents:l,reviewTeams:u}=t,[b,$]=d.useState(!0),[x,P]=d.useState(!0),w=a.length>0,m=l.length>0||u.length>0,g=w||s,j=`drop::stage-hooks::${n.id}`,{setNodeRef:D,isOver:I}=Ee({id:j,disabled:!s});return e.jsxs(xt,{className:"overflow-hidden border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("div",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:n.hex}}),e.jsx("span",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:n.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground/40 font-mono",children:n.id}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[n.isEntryPoint&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-amber-500/30 text-amber-400",children:[e.jsx(Bt,{className:"h-2.5 w-2.5"})," entry"]}),n.gitBranch&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-green-500/30 text-green-400",children:[e.jsx(Wt,{className:"h-2.5 w-2.5"})," ",n.gitBranch]}),n.supportsBatch&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-cyan-500/30 text-cyan-400",children:[e.jsx(_t,{className:"h-2.5 w-2.5"})," batch"]}),n.supportsSprint&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-indigo-500/30 text-indigo-400",children:[e.jsx(is,{className:"h-2.5 w-2.5"})," sprint"]})]})]}),g&&e.jsxs("div",{className:"border-t border-border/40",children:[e.jsxs("button",{type:"button",onClick:()=>$(!b),className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-muted-foreground hover:text-foreground transition-colors",children:[b?e.jsx(Ce,{className:"h-3 w-3"}):e.jsx(Se,{className:"h-3 w-3"}),e.jsx($e,{className:"h-3 w-3"}),"Stage Hooks",e.jsxs("span",{className:"text-muted-foreground/50",children:["(",a.length,")"]})]}),b&&e.jsxs("div",{ref:D,className:R("flex flex-wrap gap-1 px-3 pb-2 min-h-[28px]",s&&"border border-dashed border-transparent rounded-md mx-2 mb-1 p-1",I&&"border-accent-blue bg-accent-blue/10"),children:[a.map(v=>e.jsx(Ms,{hook:v,dragId:`pipeline::stage-hook::${n.id}::${v.id}`,selected:v.filePath!=null&&v.filePath===o,onClick:()=>v.filePath&&r("hooks",v.filePath),onRemove:s&&i?()=>i(n.id,v.id):void 0,editable:s},v.id)),s&&a.length===0&&e.jsx("span",{className:"text-[9px] text-muted-foreground/40 italic py-0.5",children:"drop hooks here"})]})]}),m&&e.jsxs("div",{className:"border-t border-border/40",children:[e.jsxs("button",{type:"button",onClick:()=>P(!x),className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-muted-foreground hover:text-foreground transition-colors",children:[x?e.jsx(Ce,{className:"h-3 w-3"}):e.jsx(Se,{className:"h-3 w-3"}),e.jsx(Te,{className:"h-3 w-3"}),"Agents",e.jsxs("span",{className:"text-muted-foreground/50",children:["(",l.length+u.reduce((v,M)=>v+M.agents.length,0),")"]})]}),x&&e.jsxs("div",{className:"px-3 pb-2 space-y-2",children:[l.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[9px] uppercase tracking-wider text-muted-foreground/50 mb-1",children:"Always-On"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:l.map(v=>e.jsx(at,{agent:v,mode:"always-on",selected:v.filePath!=null&&v.filePath===o,onClick:()=>v.filePath&&r("agents",v.filePath)},v.id))})]}),u.map(v=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-1 text-[9px] uppercase tracking-wider text-muted-foreground/50 mb-1",children:e.jsxs("span",{children:[v.skillCommand," team:"]})}),e.jsx("div",{className:"flex flex-wrap gap-1",children:v.agents.map(M=>e.jsx(at,{agent:M,mode:"review",selected:M.filePath!=null&&M.filePath===o,onClick:()=>M.filePath&&r("agents",M.filePath)},M.id))})]},v.skillCommand))]})]}),!g&&!m&&e.jsx("div",{className:"border-t border-border/40 px-3 py-2",children:e.jsx("span",{className:"text-[10px] text-muted-foreground/40 italic",children:"No stage-specific hooks or agents"})})]})}function $s({hook:t,dragId:o,selected:r,onClick:s,onRemove:i,editable:n}){const{attributes:a,listeners:l,setNodeRef:u,isDragging:b}=Pe({id:o,disabled:!n,data:{hookId:t.id}});return e.jsx("div",{ref:u,className:R("cursor-pointer",b&&"opacity-40"),onClick:s,...l,...a,children:e.jsx(Ve,{hook:t,selected:r,onRemove:i})})}const ze={forward:{arrow:"text-green-500",label:"text-green-400",border:"border-green-500/20",bg:"bg-green-500/5"},backward:{arrow:"text-amber-500",label:"text-amber-400",border:"border-amber-500/20",bg:"bg-amber-500/5"},shortcut:{arrow:"text-indigo-500",label:"text-indigo-400",border:"border-indigo-500/20",bg:"bg-indigo-500/5"}};function Hs({edgeData:t,selectedPath:o,onSelectItem:r,editable:s,onRemoveHook:i}){const{edge:n,skillPath:a,edgeHooks:l}=t,u=ze[n.direction]??ze.forward,b=`drop::edge-skill::${n.from}:${n.to}`,{setNodeRef:$,isOver:x}=Ee({id:b,disabled:!s}),P=`drop::edge-hooks::${n.from}:${n.to}`,{setNodeRef:w,isOver:m}=Ee({id:P,disabled:!s}),g=n.direction==="shortcut"?"SHORTCUT":"DEFAULT";return e.jsxs("div",{className:R("flex items-center rounded-lg border overflow-hidden",u.border,"bg-card"),children:[e.jsx("div",{className:R("shrink-0 self-stretch flex items-center px-2.5",u.bg),children:e.jsx("span",{className:R("text-[9px] font-semibold uppercase tracking-wider whitespace-nowrap",u.label),children:g})}),e.jsxs("div",{className:"flex items-center flex-1 min-w-0 border-l",style:{borderColor:"inherit"},children:[e.jsx("div",{ref:$,className:R("flex items-center gap-1.5 px-2 py-1 shrink-0",x&&"bg-green-500/10"),children:n.command?e.jsxs("button",{type:"button",onClick:()=>a&&r("skills",a),"data-pipeline-path":a??void 0,className:R("inline-flex items-center gap-1 text-[11px] font-semibold transition-colors whitespace-nowrap rounded-md px-1 -mx-1",u.label,a&&"hover:brightness-125 cursor-pointer",!a&&"cursor-default opacity-60",a!=null&&a===o&&"glow-selected-pulse"),style:a!=null&&a===o?{"--glow-color":"#22c55eA0","--glow-color-wide":"#22c55e40"}:void 0,children:[e.jsx(Ue,{className:"h-3 w-3 shrink-0"}),n.command.replace(/\s+\{.*\}$/,"")]}):e.jsx("span",{className:R("text-[10px] text-muted-foreground/40 italic whitespace-nowrap",s&&"border border-dashed border-muted-foreground/20 rounded px-1.5 py-0.5"),children:s?"drop skill":"no skill"})}),e.jsx("div",{className:R("w-px self-stretch",u.border.replace("border-","bg-"))}),e.jsxs("div",{ref:w,className:R("flex items-center gap-1 px-2 py-1 flex-1 min-w-0",m&&"bg-[#00bcd4]/10"),children:[e.jsx($e,{className:"h-3 w-3 shrink-0 text-muted-foreground/30"}),l.map(j=>e.jsx($s,{hook:j,dragId:`pipeline::edge-hook::${n.from}:${n.to}::${j.id}`,selected:j.filePath!=null&&j.filePath===o,onClick:()=>j.filePath&&r("hooks",j.filePath),onRemove:s&&i?()=>i(n.from,n.to,j.id):void 0,editable:s},j.id)),l.length===0&&e.jsx("span",{className:R("text-[10px] text-muted-foreground/40 italic",s&&"border border-dashed border-muted-foreground/20 rounded px-1.5 py-0.5"),children:s?"drop hooks":"none"})]})]})]})}function Fs({edges:t,selectedPath:o,onSelectItem:r,editable:s,onRemoveHook:i}){if(t.length===0)return null;const n=ze.forward.arrow;return e.jsxs("div",{className:"flex flex-col items-center py-1",children:[e.jsx(Qe,{className:R("h-7 w-4",n)}),e.jsx("div",{className:"flex w-full flex-wrap justify-center gap-1 px-1 my-0.5",children:t.map(a=>e.jsx(Hs,{edgeData:a,selectedPath:o,onSelectItem:r,editable:s,onRemoveHook:i},`${a.edge.from}:${a.edge.to}`))}),e.jsx(Qe,{className:R("h-7 w-4",n)})]})}function Rs({hook:t,dragId:o,selected:r,onClick:s,onRemove:i,editable:n}){const{attributes:a,listeners:l,setNodeRef:u,isDragging:b}=Pe({id:o,disabled:!n,data:{hookId:t.id}});return e.jsx("div",{ref:u,className:R("cursor-pointer",b&&"opacity-40"),onClick:s,...l,...a,children:e.jsx(Ve,{hook:t,selected:r,onRemove:i})})}function Os({selectedPath:t,onSelectItem:o,editConfig:r,editable:s,onRemoveEdgeHook:i,onRemoveStageHook:n,onRemoveGlobalHook:a}){const l=Nt(r),[u,b]=d.useState(!1);d.useEffect(()=>{t&&requestAnimationFrame(()=>{const m=document.querySelector(`[data-pipeline-path="${CSS.escape(t)}"]`);m==null||m.scrollIntoView({behavior:"smooth",block:"nearest"})})},[t]);const $=l.stages.flatMap(m=>m.backwardEdges),x=new Set([...l.globalHooks.map(m=>m.id),...l.stages.flatMap(m=>m.stageHooks.map(g=>g.id))]).size,P=new Set(l.stages.flatMap(m=>m.forwardEdges.filter(g=>g.edge.command).map(g=>g.edge.command))).size,w=new Set([...l.stages.flatMap(m=>m.alwaysOnAgents.map(g=>g.id)),...l.stages.flatMap(m=>m.reviewTeams.flatMap(g=>g.agents.map(j=>j.id)))]).size;return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:"Workflow Pipeline"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[l.stages.length," stages"]}),P>0&&e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[P," skills"]}),x>0&&e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[x," hooks"]}),w>0&&e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[w," agents"]})]})]}),e.jsx(ht,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-0",children:[l.globalHooks.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(xt,{className:"overflow-hidden border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("span",{className:"text-sm",children:"🌐"}),e.jsx("span",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:"Global Hooks"}),e.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"active in all stages"})]}),e.jsx("div",{className:"border-t border-border/40",children:e.jsx("div",{className:"flex flex-wrap gap-1 px-3 py-2",children:l.globalHooks.map(m=>e.jsx(Rs,{hook:m,dragId:`pipeline::global-hook::${m.id}`,selected:m.filePath!=null&&m.filePath===t,onClick:()=>m.filePath&&o("hooks",m.filePath),onRemove:s&&a?()=>a(m.id):void 0,editable:s},m.id))})})]}),e.jsxs("div",{className:"flex items-center gap-2 py-2 px-4",children:[e.jsx("div",{className:"flex-1 border-t border-border/40"}),e.jsx("span",{className:"text-[9px] text-muted-foreground/30 uppercase tracking-wider",children:"stages"}),e.jsx("div",{className:"flex-1 border-t border-border/40"})]})]}),l.stages.map((m,g)=>e.jsxs("div",{children:[e.jsx(Ts,{stage:m,selectedPath:t,onSelectItem:o,editable:s,onRemoveHook:n}),m.forwardEdges.length>0&&e.jsx(Fs,{edges:m.forwardEdges,selectedPath:t,onSelectItem:o,editable:s,onRemoveHook:i}),m.forwardEdges.length===0&&g<l.stages.length-1&&e.jsx("div",{className:"h-2"})]},m.list.id)),$.length>0&&e.jsxs("div",{className:"mt-3 border-t border-border/30 pt-2",children:[e.jsxs("button",{type:"button",onClick:()=>b(!u),className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-[10px] font-medium text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors",children:[u?e.jsx(Ce,{className:"h-3 w-3"}):e.jsx(Se,{className:"h-3 w-3"}),e.jsx(et,{className:"h-3 w-3"}),$.length," rework paths"]}),u&&e.jsx("div",{className:"space-y-1 px-2 pt-1",children:$.map(m=>e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground/70 py-0.5",children:[e.jsx(et,{className:"h-2.5 w-2.5 text-amber-500/50"}),e.jsx("span",{className:"font-mono",children:m.from}),e.jsx("span",{className:"text-muted-foreground/30",children:"→"}),e.jsx("span",{className:"font-mono",children:m.to}),e.jsx("span",{className:"text-muted-foreground/40 truncate",children:m.label})]},`${m.from}:${m.to}`))})]}),e.jsx("div",{className:"mt-4 px-2 text-center",children:e.jsx("span",{className:"text-[9px] text-muted-foreground/30",children:s?"Drag items from the tree onto stages or edges":"Click any hook, agent, or skill to open in editor"})})]})})]})}function it(t){const o=t.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!o)return{fields:{},body:t};const r={};for(const s of o[1].split(`
|
|
28
|
-
`)){const i=s.indexOf(":");if(i>0){const n=s.slice(0,i).trim(),a=s.slice(i+1).trim();r[n]=a}}return{fields:r,body:o[2]}}function As(t,o){const r=Object.entries(t).filter(([,i])=>i!=="");return r.length===0?o:`---
|
|
29
|
-
${r.map(([i,n])=>`${i}: ${n}`).join(`
|
|
21
|
+
*/const ns=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],as=Ee("timer",ns);function is(t){const[r,o]=d.useState(null),[s,i]=d.useState(!1),[n,a]=d.useState(null),l=d.useCallback(async()=>{if(!t){o(null),a(null),i(!1);return}i(!0),a(null);try{const u=await fetch(`/api/orbital/sync/state/${t}`);u.ok?o(await u.json()):a(`Sync state fetch failed (HTTP ${u.status})`)}catch(u){a(u instanceof Error?u.message:"Sync state fetch failed")}finally{i(!1)}},[t]);return d.useEffect(()=>{l()},[l]),d.useEffect(()=>{const u=()=>l();return ee.on("sync:file:updated",u),ee.on("sync:file:created",u),ee.on("sync:file:deleted",u),()=>{ee.off("sync:file:updated",u),ee.off("sync:file:created",u),ee.off("sync:file:deleted",u)}},[l]),{report:r,loading:s,error:n,refetch:l}}function ls(){const[t,r]=d.useState(null),[o,s]=d.useState(!1),[i,n]=d.useState(null),a=d.useCallback(async()=>{s(!0),n(null);try{const l=await fetch("/api/orbital/sync/global-state");l.ok?r(await l.json()):n(`Global sync state fetch failed (HTTP ${l.status})`)}catch(l){n(l instanceof Error?l.message:"Global sync state fetch failed")}finally{s(!1)}},[]);return d.useEffect(()=>{a()},[a]),d.useEffect(()=>{const l=()=>a();return ee.on("sync:file:updated",l),ee.on("sync:file:created",l),ee.on("sync:file:deleted",l),()=>{ee.off("sync:file:updated",l),ee.off("sync:file:created",l),ee.off("sync:file:deleted",l)}},[a]),{report:t,loading:o,error:i,refetch:a}}async function cs(t,r,o){return(await fetch("/api/orbital/sync/resolve-drift",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:t,relativePath:r,resolution:o})})).ok}const ds=Mt,wt=d.forwardRef(({className:t,...r},o)=>e.jsx(lt,{ref:o,className:R("card-glass inline-flex h-8 items-center justify-center rounded bg-surface p-0.5 border border-border text-muted-foreground",t),...r}));wt.displayName=lt.displayName;const vt=d.forwardRef(({className:t,...r},o)=>e.jsx(ct,{ref:o,className:R("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-2.5 py-1 text-xxs uppercase tracking-wider font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-surface-light data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...r}));vt.displayName=ct.displayName;const fs=d.forwardRef(({className:t,...r},o)=>e.jsx(dt,{ref:o,className:R("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...r}));fs.displayName=dt.displayName;const kt={guard:{icon:Ft,bg:"bg-red-500/10",border:"border-red-500/30",text:"text-red-400",hex:"#ef4444"},gate:{icon:Ht,bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-400",hex:"#f59e0b"},lifecycle:{icon:qt,bg:"bg-cyan-500/10",border:"border-cyan-500/30",text:"text-cyan-400",hex:"#06b6d4"},observer:{icon:$t,bg:"bg-zinc-500/10",border:"border-zinc-500/30",text:"text-zinc-400",hex:"#71717a"}};function Ve({hook:t,selected:r,onClick:o,onRemove:s}){const i=kt[t.category],n=i.icon;return e.jsxs("button",{type:"button",onClick:o,"data-pipeline-path":t.filePath??void 0,className:R("inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors",i.bg,i.border,i.text,"hover:brightness-125 cursor-pointer",r&&"glow-selected-pulse"),style:r?{"--glow-color":`${i.hex}A0`,"--glow-color-wide":`${i.hex}40`}:void 0,children:[e.jsx(n,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[120px]",children:t.id}),s&&e.jsx("span",{role:"button",onClick:a=>{a.stopPropagation(),s()},className:"ml-0.5 rounded-full p-0.5 hover:bg-red-500/20",children:e.jsx(ft,{className:"h-2.5 w-2.5"})})]})}function Be({node:t,depth:r,selectedPath:o,expandedPaths:s,primitiveType:i,onSelect:n,onToggle:a,onContextAction:l,hookCategoryMap:u,agentTeamMap:b,dimmed:$}){var q,X;const x=t.type==="folder",P=s.has(t.path),w=t.path===o,m=(q=t.frontmatter)!=null&&q.name?String(t.frontmatter.name):t.name,g=x?"":`tree::${i}::${t.path}`,{attributes:j,listeners:A,setNodeRef:I,isDragging:v}=Pe({id:g,disabled:x,data:{type:i,path:t.path,name:m}}),M=()=>{x?a(t.path):n(t)},B=x||u==null?void 0:u.get(t.path),L=B?kt[B]:void 0,ne=L==null?void 0:L.icon,y=x||b==null?void 0:b.get(t.path),C=w&&!x?B?Xt[B]:y?y.color:i==="skills"?"#22c55e":"#00bcd4":void 0,z=r>0,Z=C?{"--glow-color":`${C}50`,backgroundColor:`${C}18`,color:C}:{};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:x?void 0:I,"data-tree-path":x?void 0:t.path,className:R("group flex w-full items-center rounded text-left text-xs transition-colors",w&&C?"glow-selected":w?"bg-[#00bcd4]/15 text-[#00bcd4]":"text-muted-foreground hover:bg-surface-light hover:text-foreground",v&&"opacity-40",$&&!w&&"opacity-50"),style:Z,...x?{}:{...A,...j},children:[z&&e.jsx("span",{"aria-hidden":!0,className:"self-stretch shrink-0 border-l border-emerald-500/25",style:{marginLeft:`${(r-1)*14+14}px`,width:0}}),e.jsxs("button",{onClick:M,className:"flex flex-1 min-w-0 items-center gap-1.5 px-2 py-1",style:{paddingLeft:z?"10px":`${r*12+8}px`},children:[x?e.jsxs(e.Fragment,{children:[P?e.jsx(Ne,{className:"h-3 w-3 shrink-0 opacity-60"}):e.jsx(Ce,{className:"h-3 w-3 shrink-0 opacity-60"}),P?e.jsx(ut,{className:"h-3.5 w-3.5 shrink-0 text-warning-amber/70"}):e.jsx(jt,{className:"h-3.5 w-3.5 shrink-0 text-warning-amber/70"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-3"}),e.jsx(bt,{className:"h-3.5 w-3.5 shrink-0 opacity-50"})]}),e.jsx("span",{className:"min-w-0 truncate",title:m,children:m}),L&&ne&&e.jsxs("span",{className:R("inline-flex shrink-0 items-center gap-0.5 rounded border px-1 py-0 text-[9px] font-medium",L.bg,L.border,L.text),children:[e.jsx(ne,{className:"h-2.5 w-2.5"}),B]}),y&&e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 rounded border px-1 py-0 text-[9px] font-medium",style:{color:y.color,borderColor:`${y.color}4D`,backgroundColor:`${y.color}1A`},children:[e.jsx(Te,{className:"h-2.5 w-2.5"}),y.team]})]}),e.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:_=>{_.stopPropagation(),l("rename",t)},className:"rounded p-0.5 hover:bg-surface-light",title:"Rename",children:e.jsx(gt,{className:"h-3 w-3"})}),t.type==="file"&&e.jsx("button",{onClick:_=>{_.stopPropagation(),l("delete",t)},className:"rounded p-0.5 hover:bg-ask-red/20 text-muted-foreground hover:text-ask-red",title:"Delete",children:e.jsx(Ge,{className:"h-3 w-3"})}),t.type==="folder"&&e.jsx("button",{onClick:_=>{_.stopPropagation(),l("new-file",t)},className:"rounded p-0.5 hover:bg-surface-light",title:"New file",children:e.jsx(ht,{className:"h-3 w-3"})})]})]}),x&&P&&((X=t.children)==null?void 0:X.map(_=>e.jsx(Be,{node:_,depth:r+1,selectedPath:o,expandedPaths:s,primitiveType:i,onSelect:n,onToggle:a,onContextAction:l,hookCategoryMap:u,agentTeamMap:b,dimmed:$},_.path)))]})}function us({menu:t,onRename:r,onDelete:o,onNewFile:s,onNewFolder:i,onClose:n}){return Tt.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:n}),e.jsxs("div",{className:"fixed z-50 min-w-[140px] rounded border border-border bg-surface shadow-lg",style:{top:t.y,left:t.x},onClick:a=>a.stopPropagation(),children:[e.jsxs("button",{onClick:()=>r(t.node),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-surface-light transition-colors",children:[e.jsx(gt,{className:"h-3 w-3"}),"Rename"]}),t.node.type==="folder"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>s(t.node.path),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-surface-light transition-colors",children:[e.jsx(bt,{className:"h-3 w-3"}),"New File"]}),e.jsxs("button",{onClick:()=>i(t.node.path),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-surface-light transition-colors",children:[e.jsx(jt,{className:"h-3 w-3"}),"New Folder"]})]}),e.jsx("div",{className:"border-t border-border"}),t.node.type==="file"&&e.jsxs("button",{onClick:()=>o(t.node),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-ask-red hover:bg-surface-light transition-colors",children:[e.jsx(Ge,{className:"h-3 w-3"}),"Delete"]})]})]}),document.body)}const hs=[{value:"agents",icon:Te,label:"Agents"},{value:"skills",icon:Ue,label:"Skills"},{value:"hooks",icon:$e,label:"Hooks"}];function tt(t){const r=[];function o(s){for(const i of s)i.type==="file"&&r.push(i),i.children&&o(i.children)}return o(t),r.sort((s,i)=>{var l,u;const n=(l=s.frontmatter)!=null&&l.name?String(s.frontmatter.name):s.name,a=(u=i.frontmatter)!=null&&u.name?String(i.frontmatter.name):i.name;return n.localeCompare(a)})}function ms({tree:t,loading:r,selectedPath:o,type:s,onSelect:i,onRefresh:n,onTabChange:a,activePaths:l,activeSkills:u,hookCategoryMap:b,agentTeamMap:$}){const[x,P]=d.useState(new Set),w=Me(),[m,g]=d.useState(null),[j,A]=d.useState(null),[I,v]=d.useState(""),[M,B]=d.useState(null),[L,ne]=d.useState("");d.useEffect(()=>{o&&requestAnimationFrame(()=>{const f=document.querySelector(`[data-tree-path="${CSS.escape(o)}"]`);f==null||f.scrollIntoView({behavior:"smooth",block:"nearest"})})},[o]);const y=s==="skills"?tt(t):t,{activeItems:C,inactiveFiles:z}=d.useMemo(()=>{if(!l)return{activeItems:null,inactiveFiles:null};const f=tt(t);if(u){const Q=new Set(u.map(J=>J.path)),de=new Map(f.map(J=>[J.path,J])),fe=[];for(const J of u){const me=de.get(J.path);me&&fe.push({node:me,depth:J.depth})}const he=f.filter(J=>!Q.has(J.path));return{activeItems:fe,inactiveFiles:he}}const S=[],G=[];for(const Q of f)l.has(Q.path)?S.push({node:Q,depth:0}):G.push(Q);return{activeItems:S,inactiveFiles:G}},[t,l,u]),Z=d.useCallback(f=>{P(S=>{const G=new Set(S);return G.has(f)?G.delete(f):G.add(f),G})},[]),q=d.useCallback((f,S)=>{f.preventDefault(),g({node:S,x:f.clientX,y:f.clientY})},[]),X=d.useCallback(()=>{g(null)},[]),_=d.useCallback(f=>{A(f),v(f.name),g(null)},[]),ae=d.useCallback(async()=>{if(!j||!I.trim()||I===j.name){A(null);return}const f=j.path.includes("/")?j.path.slice(0,j.path.lastIndexOf("/")):"",S=f?`${f}/${I}`:I;try{if(!(await fetch(w(`/config/${s}/rename`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:j.path,newPath:S})})).ok)throw new Error("Rename failed");n()}catch{}A(null)},[j,I,s,n,w]),le=d.useCallback(async f=>{g(null);try{if(!(await fetch(w(`/config/${s}/file?path=${encodeURIComponent(f.path)}`),{method:"DELETE"})).ok)throw new Error("Delete failed");n()}catch{}},[s,n,w]),V=d.useCallback((f,S)=>{B({kind:f,parent:S}),ne(""),g(null)},[]),p=d.useCallback((f,S)=>{f==="rename"?_(S):f==="delete"?le(S):f==="new-file"?V("file",S.path):f==="new-folder"&&V("folder",S.path)},[_,le,V]),ce=d.useCallback(async()=>{if(!M||!L.trim()){B(null);return}const f=M.parent?`${M.parent}/${L}`:L;try{if(M.kind==="folder"){if(!(await fetch(w(`/config/${s}/folder`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:f})})).ok)throw new Error("Create folder failed")}else if(!(await fetch(w(`/config/${s}/file`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:f,content:""})})).ok)throw new Error("Create file failed");n()}catch{}B(null)},[M,L,s,n,w]),ge=(f,S,G=0)=>e.jsx("div",{onContextMenu:Q=>q(Q,f),children:e.jsx(Be,{node:f,depth:G,selectedPath:o,expandedPaths:x,primitiveType:s,onSelect:i,onToggle:Z,onContextAction:p,hookCategoryMap:b,agentTeamMap:$,dimmed:S})},f.path);return e.jsxs("div",{className:"flex h-full flex-col",onClick:X,children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-2 py-1.5",children:[e.jsx(ds,{value:s,onValueChange:f=>a(f),children:e.jsx(wt,{children:hs.map(({value:f,icon:S,label:G})=>e.jsxs(vt,{value:f,className:"gap-1.5",children:[e.jsx(S,{className:"h-3 w-3"}),G]},f))})}),e.jsx("button",{onClick:()=>V("file",""),className:"rounded p-1 text-muted-foreground hover:bg-surface-light hover:text-foreground transition-colors",title:"New file",children:e.jsx(ht,{className:"h-3.5 w-3.5"})})]}),e.jsx(mt,{className:"flex-1",children:e.jsxs("div",{className:"py-1",children:[r?e.jsx("div",{className:"flex h-20 items-center justify-center",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):t.length===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground/60",children:"No files found"}):C&&z?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2 pb-1",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500/70"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-emerald-400/80",children:"Active"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/30",children:["(",C.length,")"]}),e.jsx("div",{className:"flex-1 border-t border-emerald-500/15"})]}),C.length===0?e.jsxs("div",{className:"px-3 py-2 text-[10px] text-muted-foreground/40 italic",children:["No active ",s]}):C.map(({node:f,depth:S})=>ge(f,!1,S)),e.jsxs("div",{className:"flex items-center gap-2 px-3 pt-3 pb-1",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground/30"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/40",children:"Inactive"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/20",children:["(",z.length,")"]}),e.jsx("div",{className:"flex-1 border-t border-border/20"})]}),z.length===0?e.jsxs("div",{className:"px-3 py-2 text-[10px] text-muted-foreground/40 italic",children:["All ",s," are active"]}):z.map(f=>ge(f,!0))]}):y.map(f=>e.jsx("div",{onContextMenu:S=>q(S,f),children:e.jsx(Be,{node:f,depth:0,selectedPath:o,expandedPaths:x,primitiveType:s,onSelect:i,onToggle:Z,onContextAction:p,hookCategoryMap:b,agentTeamMap:$})},f.path)),j&&e.jsx("div",{className:"px-3 py-1",children:e.jsx("input",{autoFocus:!0,value:I,onChange:f=>v(f.target.value),onKeyDown:f=>{f.key==="Enter"&&ae(),f.key==="Escape"&&A(null)},onBlur:ae,className:"w-full rounded border border-accent-blue/40 bg-surface px-2 py-0.5 text-xs text-foreground outline-none",placeholder:"New name"})}),M&&e.jsx("div",{className:"px-3 py-1",children:e.jsx("input",{autoFocus:!0,value:L,onChange:f=>ne(f.target.value),onKeyDown:f=>{f.key==="Enter"&&ce(),f.key==="Escape"&&B(null)},onBlur:ce,className:"w-full rounded border border-accent-blue/40 bg-surface px-2 py-0.5 text-xs text-foreground outline-none",placeholder:M.kind==="folder"?"Folder name":"File name"})})]})}),m&&e.jsx(us,{menu:m,onRename:_,onDelete:le,onNewFile:f=>V("file",f),onNewFolder:f=>V("folder",f),onClose:X})]})}const N={comment:"#6B7280",keyword:"#e91e63",string:"#00c853",number:"#ffab00",variable:"#40c4ff",heading:"#00bcd4",bold:"#e0e0e0",operator:"#e91e63",key:"#40c4ff",builtin:"#536dfe",link:"#8B5CF6",punctuation:"#6B7280"};function xs(t){return t?t.endsWith(".sh")?"shell":t.endsWith(".md")?"markdown":t.endsWith(".yml")||t.endsWith(".yaml")?"yaml":t.endsWith(".json")||t.endsWith(".jsonc")?"json":"text":"text"}function ps(t,r){return r==="text"?[{text:t}]:r==="shell"?bs(t):r==="markdown"?js(t):r==="yaml"?ws(t):r==="json"?vs(t):[{text:t}]}const gs=new Set(["if","then","else","elif","fi","for","in","do","done","while","until","case","esac","function","return","exit","local","export","readonly","source","set","unset","shift","break","continue","true","false"]);function bs(t){const r=[];if(t.trimStart().startsWith("#"))return[{text:t,color:N.comment,italic:!0}];let s=0;for(;s<t.length;){if(t[s]==="#"&&(s===0||/\s/.test(t[s-1]))){r.push({text:t.slice(s),color:N.comment,italic:!0});break}if(t[s]==='"'){const a=We(t,s,'"');r.push({text:t.slice(s,a),color:N.string}),s=a;continue}if(t[s]==="'"){const a=We(t,s,"'");r.push({text:t.slice(s,a),color:N.string}),s=a;continue}if(t[s]==="$"){if(t[s+1]==="{"){const a=t.indexOf("}",s+2),l=a===-1?t.length:a+1;r.push({text:t.slice(s,l),color:N.variable}),s=l}else if(t[s+1]==="(")r.push({text:"$(",color:N.variable}),s+=2;else{const a=t.slice(s).match(/^\$[A-Za-z_]\w*/);a?(r.push({text:a[0],color:N.variable}),s+=a[0].length):(r.push({text:"$",color:N.variable}),s++)}continue}if("|&;><".includes(t[s])){let a=t[s];s+1<t.length&&(t.slice(s,s+2)==="||"||t.slice(s,s+2)==="&&"||t.slice(s,s+2)===">>"||t.slice(s,s+2)==="<<")&&(a=t.slice(s,s+2)),r.push({text:a,color:N.operator}),s+=a.length;continue}const i=t.slice(s).match(/^[A-Za-z_]\w*/);if(i){const a=i[0];gs.has(a)?r.push({text:a,color:N.keyword,bold:!0}):r.push({text:a}),s+=a.length;continue}const n=t.slice(s).match(/^\d+/);if(n){r.push({text:n[0],color:N.number}),s+=n[0].length;continue}r.push({text:t[s]}),s++}return r}function js(t){const r=t.trimStart();if(r.match(/^(#{1,6})\s/))return[{text:t,color:N.heading,bold:!0}];if(r.startsWith("```"))return[{text:t,color:N.builtin}];if(r.startsWith("<!--"))return[{text:t,color:N.comment,italic:!0}];if(/^(\s*[-*+]|\s*\d+\.)\s/.test(t)){const s=t.match(/^(\s*[-*+\d.]+\s)(.*)$/);if(s)return[{text:s[1],color:N.operator},...st(s[2])]}return st(t)}function st(t){const r=[];let o=0;for(;o<t.length;){if(t[o]==="`"){const s=t.indexOf("`",o+1);if(s!==-1){r.push({text:t.slice(o,s+1),color:N.builtin}),o=s+1;continue}}if(t.slice(o,o+2)==="**"){const s=t.indexOf("**",o+2);if(s!==-1){r.push({text:t.slice(o,s+2),color:N.bold,bold:!0}),o=s+2;continue}}if(t[o]==="["){const s=t.slice(o).match(/^\[([^\]]*)\]\(([^)]*)\)/);if(s){r.push({text:`[${s[1]}]`,color:N.heading}),r.push({text:`(${s[2]})`,color:N.link}),o+=s[0].length;continue}}r.push({text:t[o]}),o++}return r}function ws(t){if(t.trimStart().startsWith("#"))return[{text:t,color:N.comment,italic:!0}];const o=t.match(/^(\s*)([\w.-]+)(:)(.*)/);if(o){const s=[{text:o[1]},{text:o[2],color:N.key},{text:o[3],color:N.punctuation}],i=o[4];return i&&s.push(...rt(i)),s}if(/^\s*-\s/.test(t)){const s=t.match(/^(\s*-\s)(.*)/);if(s)return[{text:s[1],color:N.operator},...rt(s[2])]}return[{text:t}]}function rt(t){const r=t.trim();if(!r)return[{text:t}];if(/^["']/.test(r))return[{text:t,color:N.string}];if(/^(true|false|null|yes|no)$/i.test(r))return[{text:t,color:N.keyword}];if(/^-?\d+(\.\d+)?$/.test(r))return[{text:t,color:N.number}];if(r.startsWith("#"))return[{text:t,color:N.comment,italic:!0}];const o=t.indexOf(" #");return o!==-1?[{text:t.slice(0,o)},{text:t.slice(o),color:N.comment,italic:!0}]:[{text:t,color:N.string}]}function vs(t){const r=[];let o=0;for(;o<t.length;){if(t[o]==='"'){const n=We(t,o,'"'),a=t.slice(o,n),u=t.slice(n).trimStart().startsWith(":")?N.key:N.string;r.push({text:a,color:u}),o=n;continue}const s=t.slice(o).match(/^-?\d+(\.\d+)?([eE][+-]?\d+)?/);if(s){r.push({text:s[0],color:N.number}),o+=s[0].length;continue}const i=t.slice(o).match(/^(true|false|null)\b/);if(i){r.push({text:i[0],color:N.keyword}),o+=i[0].length;continue}if("{}[]:,".includes(t[o])){r.push({text:t[o],color:N.punctuation}),o++;continue}r.push({text:t[o]}),o++}return r}function We(t,r,o){let s=r+1;for(;s<t.length;){if(t[s]==="\\"){s+=2;continue}if(t[s]===o)return s+1;s++}return t.length}const ot="'JetBrains Mono', 'SF Mono', 'Fira Code', monospace";function ks({value:t,onChange:r,filePath:o}){const s=d.useRef(null),i=d.useRef(null),n=d.useRef(null),a=d.useMemo(()=>xs(o),[o]),l=d.useMemo(()=>t.split(`
|
|
22
|
+
`),[t]),u=d.useMemo(()=>l.map(x=>ps(x,a)),[l,a]),b=d.useCallback(()=>{const x=s.current;i.current&&(i.current.scrollTop=(x==null?void 0:x.scrollTop)??0),n.current&&(n.current.scrollTop=(x==null?void 0:x.scrollTop)??0,n.current.scrollLeft=(x==null?void 0:x.scrollLeft)??0)},[]),$={fontFamily:ot,fontSize:"12px",lineHeight:"1.625",padding:"12px",tabSize:2};return e.jsxs("div",{className:"flex flex-1 overflow-hidden rounded border border-border bg-surface transition-colors focus-within:border-accent-blue/50",style:{fontFamily:ot},children:[e.jsx("div",{ref:i,"aria-hidden":!0,className:"select-none overflow-hidden border-r border-border py-3 pl-2 pr-3 text-right text-muted-foreground/40",style:{fontSize:"12px",lineHeight:"1.625"},children:l.map((x,P)=>e.jsx("div",{children:P+1},P))}),e.jsxs("div",{className:"relative flex-1 min-w-0 overflow-hidden",children:[e.jsx("pre",{ref:n,"aria-hidden":!0,className:"absolute inset-0 overflow-hidden whitespace-pre pointer-events-none m-0",style:$,children:u.map((x,P)=>e.jsx("div",{children:x.length===0?" ":x.map((w,m)=>e.jsx("span",{style:{color:w.color,fontWeight:w.bold?600:void 0,fontStyle:w.italic?"italic":void 0},children:w.text},m))},P))}),e.jsx("textarea",{ref:s,value:t,onChange:x=>r(x.target.value),onScroll:b,className:"relative z-10 w-full h-full resize-none bg-transparent outline-none",style:{...$,color:"transparent",caretColor:"hsl(0 0% 88%)",WebkitTextFillColor:"transparent"},spellCheck:!1})]})]})}function ys({filePath:t,content:r,setContent:o,frontmatter:s,setFrontmatterField:i,body:n,setBody:a,dirty:l,saving:u,loading:b,error:$,onSave:x}){const P=d.useCallback(g=>{(g.metaKey||g.ctrlKey)&&g.key==="s"&&(g.preventDefault(),l&&!u&&x())},[l,u,x]);if(d.useEffect(()=>(window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)),[P]),!t)return e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx(Xe,{className:"h-10 w-10 text-muted-foreground/30"}),e.jsx("p",{className:"text-sm text-muted-foreground/60",children:"Select a file to edit"})]})});if(b)return e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})});const w=Object.keys(s),m=w.length>0;return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Xe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-xs text-foreground",children:t}),l&&e.jsx(se,{variant:"warning",className:"shrink-0 text-[10px] px-1 py-0",children:"unsaved"})]}),e.jsxs(je,{variant:"default",size:"sm",disabled:!l||u,onClick:x,className:"shrink-0",children:[e.jsx(Qt,{className:"mr-1.5 h-3.5 w-3.5"}),u?"Saving...":"Save"]})]}),$&&e.jsxs("div",{className:"flex items-center gap-2 border-b border-red-500/20 bg-red-500/10 px-3 py-1.5 text-xs text-ask-red",children:[e.jsx(Rt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:$})]}),m&&e.jsxs("div",{className:"space-y-2 border-b border-border px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:"Frontmatter"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsx("div",{className:"grid gap-2",children:w.map(g=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"w-28 shrink-0 text-right text-xxs text-muted-foreground",children:g}),e.jsx("input",{value:s[g]??"",onChange:j=>i(g,j.target.value),className:R("flex-1 rounded border border-border bg-surface px-2 py-1 text-xs text-foreground","outline-none focus:border-accent-blue/50 transition-colors")})]},g))})]}),e.jsxs("div",{className:"flex flex-1 flex-col min-h-0 p-3",children:[m&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:"Content"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsx(ks,{value:n,onChange:a,filePath:t})]})]})}const Ns={synced:{color:"bg-emerald-500",label:"Synced",title:"Synced with global"},override:{color:"bg-blue-500",label:"Override",title:"Project override — not tracking global"},drifted:{color:"bg-amber-500",label:"Drifted",title:"Modified outside dashboard — needs resolution"},absent:{color:"bg-muted-foreground/30",label:"Absent",title:"Not present in this project"}};function Cs({state:t,className:r}){const o=Ns[t];return e.jsxs("span",{className:R("inline-flex items-center gap-1",r),title:o.title,children:[e.jsx("span",{className:R("h-2 w-2 rounded-full shrink-0",o.color)}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:o.label})]})}function Ss(){const{report:t,loading:r}=ls();return r||!t?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):t.projects.length===0?e.jsxs("div",{className:"text-sm text-muted-foreground p-4",children:["No projects registered. Use ",e.jsx("code",{children:"orbital register"})," to add projects."]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50",children:[e.jsx("th",{className:"text-left py-2 px-3 font-medium text-muted-foreground",children:"File"}),t.projects.map(o=>e.jsx("th",{className:"text-center py-2 px-3 font-medium text-muted-foreground",children:o.projectName},o.projectId))]})}),e.jsx("tbody",{children:t.files.map(o=>e.jsxs("tr",{className:"border-b border-border/20 hover:bg-muted/20",children:[e.jsx("td",{className:"py-1.5 px-3 font-mono text-[11px] text-foreground/80",children:o}),t.projects.map(s=>e.jsx("td",{className:"py-1.5 px-3 text-center",children:e.jsx(Cs,{state:s.states[o]??"absent"})},s.projectId))]},o))})]})})}function Es({projectId:t,relativePath:r,onResolved:o,onCancel:s}){const[i,n]=d.useState(!1),[a,l]=d.useState(null);async function u(b){n(!0),l(null);try{await cs(t,r,b)?o():l("Failed to resolve drift. Please try again.")}catch{l("Failed to resolve drift. Please try again.")}finally{n(!1)}}return e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-amber-400",children:"Drift Detected"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:r}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This file was synced with global but has been modified outside the dashboard."}),a&&e.jsx("p",{className:"text-xs text-destructive",children:a}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx("button",{onClick:()=>u("reset-global"),disabled:i,className:"rounded border border-border bg-muted px-3 py-1.5 text-xs hover:bg-muted/80 transition-colors disabled:opacity-50",children:i?"Resolving…":"Reset to Global"}),e.jsx("button",{onClick:()=>u("pin-override"),disabled:i,className:"rounded border border-blue-500/30 bg-blue-500/10 px-3 py-1.5 text-xs text-blue-400 hover:bg-blue-500/20 transition-colors disabled:opacity-50",children:i?"Resolving…":"Pin as Override"}),e.jsx("button",{onClick:s,disabled:i,className:"ml-auto rounded px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:"Later"})]})]})}function ye(t){const[r,o]=d.useState([]),s=Me(),i=d.useCallback(async()=>{const a=await fetch(s(`/config/${t}/tree`));if(!a.ok)throw new Error(`HTTP ${a.status}`);const l=await a.json();o(l.data??[])},[t,s]),{loading:n}=Ot(i);return d.useEffect(()=>{const a=`config:${t}:changed`,l=()=>{i()},u=a;return ee.on(u,l),()=>{ee.off(u,l)}},[t,i]),{tree:r,loading:n,refresh:i}}function yt(t){const r=new Set;for(const o of t)if(o.type==="file"&&r.add(o.path),o.children)for(const s of yt(o.children))r.add(s);return r}function ze(t){const r=new Map;for(const o of t){if(o.type==="file"){const s=o.path.split("/");if(s.length>=2){const n=s[s.length-2].toLowerCase();r.has(n)||r.set(n,o.path)}const i=o.name.replace(/\.(md|sh)$/,"").toLowerCase();r.has(i)||r.set(i,o.path)}if(o.children){const s=ze(o.children);for(const[i,n]of s)r.has(i)||r.set(i,n)}}return r}function nt(t){return t?t.replace(/^\//,"").replace(/\s+\{.*\}$/,"").toLowerCase():null}function Ie(t,r){return{id:t.id,label:t.label,category:t.category,enforcement:At(t),filePath:r.get(t.id)??null,timing:t.timing,blocking:t.blocking??!1,description:t.description}}function Nt(t){const{engine:r}=xt(),{tree:o}=ye("skills"),{tree:s}=ye("hooks"),{tree:i}=ye("agents");return d.useMemo(()=>{var me,we;const n=t?new Dt(t):r,a=n.getLists(),l=n.getAllEdges(),u=n.getAllHooks(),b=ze(o),$=ze(i),x=yt(s),P=".claude/hooks/",w=new Map;for(const c of u){const h=c.target.startsWith(P)?c.target.slice(P.length):c.target;x.has(h)&&w.set(c.id,h)}const m=new Map(u.map(c=>[c.id,c])),g=a.map(c=>c.id),j=new Map;for(const c of a){const h=new Set(c.activeHooks??[]);for(const T of h)j.set(T,(j.get(T)??0)+1)}const A=new Map;for(const c of g)A.set(c,new Set);for(const c of l)for(const h of c.hooks??[])(me=A.get(c.from))==null||me.add(h),(we=A.get(c.to))==null||we.add(h);for(const[,c]of A)for(const h of c)j.set(h,(j.get(h)??0)+1);const I=Math.max(1,g.length-1),v=new Set;for(const[c,h]of j)h>=I&&v.add(c);const M=[];for(const c of v){const h=m.get(c);h&&M.push(Ie(h,w))}const B={guard:0,gate:1,lifecycle:2,observer:3};M.sort((c,h)=>B[c.category]-B[h.category]);const L=new Map,ne=new Map;function y(c){var h,T;for(const E of c){if(E.type==="file"&&((h=E.frontmatter)!=null&&h["agent-mode"]&&L.set(E.path,String(E.frontmatter["agent-mode"])),Array.isArray((T=E.frontmatter)==null?void 0:T.orchestrates))){const U=E.frontmatter.orchestrates.filter(K=>typeof K=="string");U.length>0&&ne.set(E.path,U)}E.children&&y(E.children)}}y(o);function C(c){const h=b.get(c);return h?L.get(h):void 0}function z(c,h){var U;const T=h?h.path:$.get(c.toLowerCase())??null,E=(U=h==null?void 0:h.frontmatter)!=null&&U.name?String(h.frontmatter.name):c.split("-").map(K=>K.charAt(0).toUpperCase()+K.slice(1)).join(" ");return{id:c,label:E,emoji:It[c]??"",color:Lt[c]??"",filePath:T}}const Z={"red-team":"#ef4444","blue-team":"#3b82f6","green-team":"#22c55e"},q=new Set(["reference","workflows"]),X=[];function _(c,h){var T;for(const E of c)if(E.type==="folder")!q.has(E.name.toLowerCase())&&E.children&&_(E.children,E.name);else if(h&&E.name.endsWith(".md")&&((T=E.frontmatter)!=null&&T.name)){const U=E.name.replace(/\.md$/,"").toLowerCase(),K=z(U,E);K.team=h,K.color=Z[h.toLowerCase()]??(K.color||"#8B5CF6"),X.push(K)}}_(i,null),X.sort((c,h)=>c.team!==h.team?(c.team??"").localeCompare(h.team??""):c.label.localeCompare(h.label));const ae=new Map,le=new Map;for(const c of l)ae.has(c.from)||ae.set(c.from,[]),ae.get(c.from).push(c),le.has(c.to)||le.set(c.to,[]),le.get(c.to).push(c);const V=a.map(c=>{const h=new Set;for(const D of c.activeHooks??[])v.has(D)||h.add(D);for(const D of ae.get(c.id)??[])for(const Y of D.hooks??[])v.has(Y)||h.add(Y);const T=[];for(const D of h){const Y=m.get(D);Y&&T.push(Ie(Y,w))}T.sort((D,Y)=>B[D.category]-B[Y.category]);const E=[],U=le.get(c.id)??[],K=new Map;for(const D of U){const Y=nt(D.command);if(!Y||C(Y)!=="team-review")continue;const pe=D.command??D.label;K.has(pe)||K.set(pe,{skillCommand:pe,skillPath:b.get(Y)??null,agents:[...X]})}const He=[...K.values()],Fe=(ae.get(c.id)??[]).filter(D=>D.direction==="forward"||D.direction==="shortcut").map(D=>{const Y=nt(D.command),pe=(D.hooks??[]).filter(ue=>!v.has(ue)).map(ue=>m.get(ue)).filter(ue=>ue!==void 0).map(ue=>Ie(ue,w));return{edge:D,skillPath:Y?b.get(Y)??null:null,edgeHooks:pe}}),Re=(ae.get(c.id)??[]).filter(D=>D.direction==="backward");return{list:c,stageHooks:T,alwaysOnAgents:E,reviewTeams:He,forwardEdges:Fe,backwardEdges:Re}}),p=new Set,ce=new Map,ge=[...M,...V.flatMap(c=>c.stageHooks),...V.flatMap(c=>c.forwardEdges.flatMap(h=>h.edgeHooks))];for(const c of ge)c.filePath&&(p.add(c.filePath),ce.set(c.filePath,c.category));for(const c of u){const h=w.get(c.id);h&&!ce.has(h)&&ce.set(h,c.category)}const f=new Set;for(const c of V){for(const h of c.alwaysOnAgents)h.filePath&&f.add(h.filePath);for(const h of c.reviewTeams)for(const T of h.agents)T.filePath&&f.add(T.filePath)}const S=new Map;for(const[c,h]of ne){const T=[];for(const E of h){const U=b.get(E.toLowerCase());U&&T.push(U)}T.length>0&&S.set(c,T)}const G=[],Q=new Set;for(const c of V)for(const h of c.forwardEdges)h.skillPath&&!Q.has(h.skillPath)&&(Q.add(h.skillPath),G.push(h.skillPath));const de=new Map;for(const[c,h]of b)c!=="skill"&&(de.has(h)||de.set(h,c));const fe=[],he=new Set;function J(c,h,T){if(he.has(c))return;he.add(c),fe.push({path:c,name:de.get(c)??c,parentPath:h,depth:T});const E=S.get(c);if(E)for(const U of E)J(U,c,T+1)}for(const c of G)J(c,null,0);return{globalHooks:M,stages:V,skillPathMap:b,hookPathMap:w,agentPathMap:$,activeSkills:fe,activeSkillPaths:he,activeAgentPaths:f,activeHookPaths:p,hookCategoryMap:ce}},[t,r,o,s,i])}function at({agent:t,mode:r,selected:o,onClick:s,onRemove:i}){const n=t.color||"#8B5CF6";return e.jsxs("button",{type:"button",onClick:s,"data-pipeline-path":t.filePath??void 0,className:R("inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors","hover:brightness-125 cursor-pointer",o&&"glow-selected-pulse"),style:{color:n,borderColor:`${n}4D`,backgroundColor:`${n}1A`,...o?{"--glow-color":`${n}A0`,"--glow-color-wide":`${n}40`}:{}},children:[t.emoji?e.jsx("span",{className:"text-xs",children:t.emoji}):e.jsx(Te,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[100px]",children:t.label}),r==="always-on"&&e.jsx("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-green-500 shrink-0",title:"Auto-invoke"}),i&&e.jsx("span",{role:"button",onClick:a=>{a.stopPropagation(),i()},className:"ml-0.5 rounded-full p-0.5 hover:bg-red-500/20",children:e.jsx(ft,{className:"h-2.5 w-2.5"})})]})}function Ps({hook:t,dragId:r,selected:o,onClick:s,onRemove:i,editable:n}){const{attributes:a,listeners:l,setNodeRef:u,isDragging:b}=Pe({id:r,disabled:!n,data:{hookId:t.id}});return e.jsx("div",{ref:u,className:R("cursor-pointer",b&&"opacity-40"),onClick:s,...l,...a,children:e.jsx(Ve,{hook:t,selected:o,onRemove:i})})}function Ms({stage:t,selectedPath:r,onSelectItem:o,editable:s,onRemoveHook:i}){const{list:n,stageHooks:a,alwaysOnAgents:l,reviewTeams:u}=t,[b,$]=d.useState(!0),[x,P]=d.useState(!0),w=a.length>0,m=l.length>0||u.length>0,g=w||s,j=`drop::stage-hooks::${n.id}`,{setNodeRef:A,isOver:I}=Se({id:j,disabled:!s});return e.jsxs(pt,{className:"overflow-hidden border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("div",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:n.hex}}),e.jsx("span",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:n.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground/40 font-mono",children:n.id}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[n.isEntryPoint&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-amber-500/30 text-amber-400",children:[e.jsx(Bt,{className:"h-2.5 w-2.5"})," entry"]}),n.gitBranch&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-green-500/30 text-green-400",children:[e.jsx(Wt,{className:"h-2.5 w-2.5"})," ",n.gitBranch]}),n.supportsBatch&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-cyan-500/30 text-cyan-400",children:[e.jsx(zt,{className:"h-2.5 w-2.5"})," batch"]}),n.supportsSprint&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-indigo-500/30 text-indigo-400",children:[e.jsx(as,{className:"h-2.5 w-2.5"})," sprint"]})]})]}),g&&e.jsxs("div",{className:"border-t border-border/40",children:[e.jsxs("button",{type:"button",onClick:()=>$(!b),className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-muted-foreground hover:text-foreground transition-colors",children:[b?e.jsx(Ne,{className:"h-3 w-3"}):e.jsx(Ce,{className:"h-3 w-3"}),e.jsx($e,{className:"h-3 w-3"}),"Stage Hooks",e.jsxs("span",{className:"text-muted-foreground/50",children:["(",a.length,")"]})]}),b&&e.jsxs("div",{ref:A,className:R("flex flex-wrap gap-1 px-3 pb-2 min-h-[28px]",s&&"border border-dashed border-transparent rounded-md mx-2 mb-1 p-1",I&&"border-accent-blue bg-accent-blue/10"),children:[a.map(v=>e.jsx(Ps,{hook:v,dragId:`pipeline::stage-hook::${n.id}::${v.id}`,selected:v.filePath!=null&&v.filePath===r,onClick:()=>v.filePath&&o("hooks",v.filePath),onRemove:s&&i?()=>i(n.id,v.id):void 0,editable:s},v.id)),s&&a.length===0&&e.jsx("span",{className:"text-[9px] text-muted-foreground/40 italic py-0.5",children:"drop hooks here"})]})]}),m&&e.jsxs("div",{className:"border-t border-border/40",children:[e.jsxs("button",{type:"button",onClick:()=>P(!x),className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-muted-foreground hover:text-foreground transition-colors",children:[x?e.jsx(Ne,{className:"h-3 w-3"}):e.jsx(Ce,{className:"h-3 w-3"}),e.jsx(Te,{className:"h-3 w-3"}),"Agents",e.jsxs("span",{className:"text-muted-foreground/50",children:["(",l.length+u.reduce((v,M)=>v+M.agents.length,0),")"]})]}),x&&e.jsxs("div",{className:"px-3 pb-2 space-y-2",children:[l.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[9px] uppercase tracking-wider text-muted-foreground/50 mb-1",children:"Always-On"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:l.map(v=>e.jsx(at,{agent:v,mode:"always-on",selected:v.filePath!=null&&v.filePath===r,onClick:()=>v.filePath&&o("agents",v.filePath)},v.id))})]}),u.map(v=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-1 text-[9px] uppercase tracking-wider text-muted-foreground/50 mb-1",children:e.jsxs("span",{children:[v.skillCommand," team:"]})}),e.jsx("div",{className:"flex flex-wrap gap-1",children:v.agents.map(M=>e.jsx(at,{agent:M,mode:"review",selected:M.filePath!=null&&M.filePath===r,onClick:()=>M.filePath&&o("agents",M.filePath)},M.id))})]},v.skillCommand))]})]}),!g&&!m&&e.jsx("div",{className:"border-t border-border/40 px-3 py-2",children:e.jsx("span",{className:"text-[10px] text-muted-foreground/40 italic",children:"No stage-specific hooks or agents"})})]})}function Ts({hook:t,dragId:r,selected:o,onClick:s,onRemove:i,editable:n}){const{attributes:a,listeners:l,setNodeRef:u,isDragging:b}=Pe({id:r,disabled:!n,data:{hookId:t.id}});return e.jsx("div",{ref:u,className:R("cursor-pointer",b&&"opacity-40"),onClick:s,...l,...a,children:e.jsx(Ve,{hook:t,selected:o,onRemove:i})})}const _e={forward:{arrow:"text-green-500",label:"text-green-400",border:"border-green-500/20",bg:"bg-green-500/5"},backward:{arrow:"text-amber-500",label:"text-amber-400",border:"border-amber-500/20",bg:"bg-amber-500/5"},shortcut:{arrow:"text-indigo-500",label:"text-indigo-400",border:"border-indigo-500/20",bg:"bg-indigo-500/5"}};function $s({edgeData:t,selectedPath:r,onSelectItem:o,editable:s,onRemoveHook:i}){const{edge:n,skillPath:a,edgeHooks:l}=t,u=_e[n.direction]??_e.forward,b=`drop::edge-skill::${n.from}:${n.to}`,{setNodeRef:$,isOver:x}=Se({id:b,disabled:!s}),P=`drop::edge-hooks::${n.from}:${n.to}`,{setNodeRef:w,isOver:m}=Se({id:P,disabled:!s}),g=n.direction==="shortcut"?"SHORTCUT":"DEFAULT";return e.jsxs("div",{className:R("flex items-center rounded-lg border overflow-hidden",u.border,"bg-card"),children:[e.jsx("div",{className:R("shrink-0 self-stretch flex items-center px-2.5",u.bg),children:e.jsx("span",{className:R("text-[9px] font-semibold uppercase tracking-wider whitespace-nowrap",u.label),children:g})}),e.jsxs("div",{className:"flex items-center flex-1 min-w-0 border-l",style:{borderColor:"inherit"},children:[e.jsx("div",{ref:$,className:R("flex items-center gap-1.5 px-2 py-1 shrink-0",x&&"bg-green-500/10"),children:n.command?e.jsxs("button",{type:"button",onClick:()=>a&&o("skills",a),"data-pipeline-path":a??void 0,className:R("inline-flex items-center gap-1 text-[11px] font-semibold transition-colors whitespace-nowrap rounded-md px-1 -mx-1",u.label,a&&"hover:brightness-125 cursor-pointer",!a&&"cursor-default opacity-60",a!=null&&a===r&&"glow-selected-pulse"),style:a!=null&&a===r?{"--glow-color":"#22c55eA0","--glow-color-wide":"#22c55e40"}:void 0,children:[e.jsx(Ue,{className:"h-3 w-3 shrink-0"}),n.command.replace(/\s+\{.*\}$/,"")]}):e.jsx("span",{className:R("text-[10px] text-muted-foreground/40 italic whitespace-nowrap",s&&"border border-dashed border-muted-foreground/20 rounded px-1.5 py-0.5"),children:s?"drop skill":"no skill"})}),e.jsx("div",{className:R("w-px self-stretch",u.border.replace("border-","bg-"))}),e.jsxs("div",{ref:w,className:R("flex items-center gap-1 px-2 py-1 flex-1 min-w-0",m&&"bg-[#00bcd4]/10"),children:[e.jsx($e,{className:"h-3 w-3 shrink-0 text-muted-foreground/30"}),l.map(j=>e.jsx(Ts,{hook:j,dragId:`pipeline::edge-hook::${n.from}:${n.to}::${j.id}`,selected:j.filePath!=null&&j.filePath===r,onClick:()=>j.filePath&&o("hooks",j.filePath),onRemove:s&&i?()=>i(n.from,n.to,j.id):void 0,editable:s},j.id)),l.length===0&&e.jsx("span",{className:R("text-[10px] text-muted-foreground/40 italic",s&&"border border-dashed border-muted-foreground/20 rounded px-1.5 py-0.5"),children:s?"drop hooks":"none"})]})]})]})}function Hs({edges:t,selectedPath:r,onSelectItem:o,editable:s,onRemoveHook:i}){if(t.length===0)return null;const n=_e.forward.arrow;return e.jsxs("div",{className:"flex flex-col items-center py-1",children:[e.jsx(Qe,{className:R("h-7 w-4",n)}),e.jsx("div",{className:"flex w-full flex-wrap justify-center gap-1 px-1 my-0.5",children:t.map(a=>e.jsx($s,{edgeData:a,selectedPath:r,onSelectItem:o,editable:s,onRemoveHook:i},`${a.edge.from}:${a.edge.to}`))}),e.jsx(Qe,{className:R("h-7 w-4",n)})]})}function Fs({hook:t,dragId:r,selected:o,onClick:s,onRemove:i,editable:n}){const{attributes:a,listeners:l,setNodeRef:u,isDragging:b}=Pe({id:r,disabled:!n,data:{hookId:t.id}});return e.jsx("div",{ref:u,className:R("cursor-pointer",b&&"opacity-40"),onClick:s,...l,...a,children:e.jsx(Ve,{hook:t,selected:o,onRemove:i})})}function Rs({selectedPath:t,onSelectItem:r,editConfig:o,editable:s,onRemoveEdgeHook:i,onRemoveStageHook:n,onRemoveGlobalHook:a}){const l=Nt(o),[u,b]=d.useState(!1);d.useEffect(()=>{t&&requestAnimationFrame(()=>{const m=document.querySelector(`[data-pipeline-path="${CSS.escape(t)}"]`);m==null||m.scrollIntoView({behavior:"smooth",block:"nearest"})})},[t]);const $=l.stages.flatMap(m=>m.backwardEdges),x=new Set([...l.globalHooks.map(m=>m.id),...l.stages.flatMap(m=>m.stageHooks.map(g=>g.id))]).size,P=new Set(l.stages.flatMap(m=>m.forwardEdges.filter(g=>g.edge.command).map(g=>g.edge.command))).size,w=new Set([...l.stages.flatMap(m=>m.alwaysOnAgents.map(g=>g.id)),...l.stages.flatMap(m=>m.reviewTeams.flatMap(g=>g.agents.map(j=>j.id)))]).size;return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:"Workflow Pipeline"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[l.stages.length," stages"]}),P>0&&e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[P," skills"]}),x>0&&e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[x," hooks"]}),w>0&&e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[w," agents"]})]})]}),e.jsx(mt,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-0",children:[l.globalHooks.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(pt,{className:"overflow-hidden border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("span",{className:"text-sm",children:"🌐"}),e.jsx("span",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:"Global Hooks"}),e.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"active in all stages"})]}),e.jsx("div",{className:"border-t border-border/40",children:e.jsx("div",{className:"flex flex-wrap gap-1 px-3 py-2",children:l.globalHooks.map(m=>e.jsx(Fs,{hook:m,dragId:`pipeline::global-hook::${m.id}`,selected:m.filePath!=null&&m.filePath===t,onClick:()=>m.filePath&&r("hooks",m.filePath),onRemove:s&&a?()=>a(m.id):void 0,editable:s},m.id))})})]}),e.jsxs("div",{className:"flex items-center gap-2 py-2 px-4",children:[e.jsx("div",{className:"flex-1 border-t border-border/40"}),e.jsx("span",{className:"text-[9px] text-muted-foreground/30 uppercase tracking-wider",children:"stages"}),e.jsx("div",{className:"flex-1 border-t border-border/40"})]})]}),l.stages.map((m,g)=>e.jsxs("div",{children:[e.jsx(Ms,{stage:m,selectedPath:t,onSelectItem:r,editable:s,onRemoveHook:n}),m.forwardEdges.length>0&&e.jsx(Hs,{edges:m.forwardEdges,selectedPath:t,onSelectItem:r,editable:s,onRemoveHook:i}),m.forwardEdges.length===0&&g<l.stages.length-1&&e.jsx("div",{className:"h-2"})]},m.list.id)),$.length>0&&e.jsxs("div",{className:"mt-3 border-t border-border/30 pt-2",children:[e.jsxs("button",{type:"button",onClick:()=>b(!u),className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-[10px] font-medium text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors",children:[u?e.jsx(Ne,{className:"h-3 w-3"}):e.jsx(Ce,{className:"h-3 w-3"}),e.jsx(et,{className:"h-3 w-3"}),$.length," rework paths"]}),u&&e.jsx("div",{className:"space-y-1 px-2 pt-1",children:$.map(m=>e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground/70 py-0.5",children:[e.jsx(et,{className:"h-2.5 w-2.5 text-amber-500/50"}),e.jsx("span",{className:"font-mono",children:m.from}),e.jsx("span",{className:"text-muted-foreground/30",children:"→"}),e.jsx("span",{className:"font-mono",children:m.to}),e.jsx("span",{className:"text-muted-foreground/40 truncate",children:m.label})]},`${m.from}:${m.to}`))})]}),e.jsx("div",{className:"mt-4 px-2 text-center",children:e.jsx("span",{className:"text-[9px] text-muted-foreground/30",children:s?"Drag items from the tree onto stages or edges":"Click any hook, agent, or skill to open in editor"})})]})})]})}function it(t){const r=t.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!r)return{fields:{},body:t};const o={};for(const s of r[1].split(`
|
|
23
|
+
`)){const i=s.indexOf(":");if(i>0){const n=s.slice(0,i).trim(),a=s.slice(i+1).trim();o[n]=a}}return{fields:o,body:r[2]}}function Os(t,r){const o=Object.entries(t).filter(([,i])=>i!=="");return o.length===0?r:`---
|
|
24
|
+
${o.map(([i,n])=>`${i}: ${n}`).join(`
|
|
30
25
|
`)}
|
|
31
26
|
---
|
|
32
|
-
${
|
|
27
|
+
${r}`}function Ds(t,r){const[o,s]=d.useState(""),[i,n]=d.useState(""),[a,l]=d.useState({}),[u,b]=d.useState(""),[$,x]=d.useState(!1),[P,w]=d.useState(!1),[m,g]=d.useState(null),j=Me(),A=d.useRef(0);d.useEffect(()=>{if(!t||!r){s(""),n(""),l({}),b(""),g(null);return}const y=++A.current;x(!0),g(null),fetch(j(`/config/${t}/file?path=${encodeURIComponent(r)}`)).then(async C=>{var X;if(!C.ok)throw new Error(`HTTP ${C.status}`);const z=await C.json();if(y!==A.current)return;const Z=((X=z.data)==null?void 0:X.content)??"";s(Z),n(Z);const q=it(Z);l(q.fields),b(q.body)}).catch(C=>{y===A.current&&g(C instanceof Error?C.message:"Failed to load file")}).finally(()=>{y===A.current&&x(!1)})},[t,r,j]);const I=d.useCallback((y,C)=>{const z=Os(y,C);s(z)},[]),v=d.useCallback((y,C)=>{l(z=>{const Z={...z,[y]:C};return b(q=>(I(Z,q),q)),Z})},[I]),M=d.useCallback(y=>{b(y),l(C=>(I(C,y),C))},[I]),B=d.useCallback(y=>{s(y);const C=it(y);l(C.fields),b(C.body)},[]),L=d.useCallback(async()=>{if(!(!t||!r)){w(!0),g(null);try{const y=await fetch(j(`/config/${t}/file`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r,content:o})});if(!y.ok){const C=await y.json().catch(()=>({error:"Save failed"}));throw new Error(C.error??`HTTP ${y.status}`)}n(o)}catch(y){g(y instanceof Error?y.message:"Save failed")}finally{w(!1)}}},[t,r,o,j]);return{content:o,setContent:B,frontmatter:a,setFrontmatterField:v,body:u,setBody:M,dirty:o!==i,saving:P,loading:$,save:L,error:m}}function As(t){const r=t.split("/"),o=r[r.length-1];return r.length>=2&&/^(SKILL|AGENT)\.md$/i.test(o)?r[r.length-2].toLowerCase():o.replace(/\.(md|sh)$/,"").toLowerCase()}function Ys(){const[t,r]=d.useState("agents"),o=Me(),[s,i]=d.useState(null),[n,a]=d.useState(null),[l,u]=d.useState(!1),[b,$]=d.useState(null),{activeProjectId:x,hasMultipleProjects:P}=_t(),{report:w,refetch:m}=is(P?x:null),g=(w==null?void 0:w.files.some(k=>k.state==="drifted"))??!1,{tree:j,loading:A,refresh:I}=ye(t),v=(s==null?void 0:s.type)??null,M=(s==null?void 0:s.path)??null,{content:B,setContent:L,frontmatter:ne,setFrontmatterField:y,body:C,setBody:z,dirty:Z,saving:q,loading:X,save:_,error:ae}=Ds(v,M),{engine:le}=xt(),V=le.getConfig(),p=es(V),ce=Gt(Ut(Zt,{activationConstraint:{distance:8}})),ge=Vt(),f=d.useCallback(k=>{r(k),i(null)},[]),S=d.useCallback(k=>{k.type==="file"&&i({type:t,path:k.path})},[t]),G=d.useCallback((k,O)=>{r(k),i({type:k,path:O})},[]),Q=d.useCallback((k,O,H)=>{p.editMode||p.enterEditMode();const F=p.editConfig.edges.find(W=>W.from===k&&W.to===O);F&&p.updateEdge(F,{...F,hooks:(F.hooks??[]).filter(W=>W!==H)})},[p]),de=d.useCallback((k,O)=>{p.editMode||p.enterEditMode();const H=p.editConfig.lists.find(F=>F.id===k);H&&p.updateList(H,{...H,activeHooks:(H.activeHooks??[]).filter(F=>F!==O)})},[p]),fe=d.useCallback(k=>{var H,F;p.editMode||p.enterEditMode();const O=structuredClone(p.editMode?p.editConfig:V);for(const W of O.lists)(H=W.activeHooks)!=null&&H.includes(k)&&(W.activeHooks=W.activeHooks.filter(te=>te!==k));for(const W of O.edges)(F=W.hooks)!=null&&F.includes(k)&&(W.hooks=W.hooks.filter(te=>te!==k));p.updateConfig(O)},[p,V]),he=p.editMode?p.editConfig:void 0,J=Nt(he),me=d.useMemo(()=>{const k=new Map;for(const[O,H]of J.hookPathMap)k.set(H,O);return k},[J.hookPathMap]),we=d.useCallback(k=>{if(String(k.active.id).startsWith("pipeline::")){const F=k.active.data.current;a({type:"pipeline",name:(F==null?void 0:F.hookId)??"hook"});return}const H=k.active.data.current;H!=null&&H.type&&(H!=null&&H.name)&&a({type:H.type,name:H.name})},[]),c=d.useCallback(k=>{var Ye,Ze;a(null);const{active:O,over:H}=k;if(!H)return;const F=String(O.id),W=String(H.id);if(W==="drop::remove"){const re=F.match(/^pipeline::edge-hook::(.+?):(.+?)::(.+)$/);if(re){const[,ie,Le,Pt]=re;Q(ie,Le,Pt);return}const xe=F.match(/^pipeline::stage-hook::(.+?)::(.+)$/);if(xe){const[,ie,Le]=xe;de(ie,Le);return}const oe=F.match(/^pipeline::global-hook::(.+)$/);if(oe){const[,ie]=oe;fe(ie);return}return}const te=F.match(/^tree::(hooks|skills|agents)::(.+)$/),ve=W.match(/^drop::(edge-hooks|stage-hooks|edge-skill)::(.+)$/);if(!te||!ve)return;const[,ke,Ke]=te,[,De,Ae]=ve,be=ke==="hooks"?me.get(Ke):As(Ke);if(be){if(p.editMode||p.enterEditMode(),De==="edge-hooks"&&ke==="hooks"){const[re,xe]=Ae.split(":"),oe=p.editConfig.edges.find(ie=>ie.from===re&&ie.to===xe);if(!oe||(Ye=oe.hooks)!=null&&Ye.includes(be))return;p.updateEdge(oe,{...oe,hooks:[...oe.hooks??[],be]})}if(De==="stage-hooks"&&ke==="hooks"){const re=p.editConfig.lists.find(xe=>xe.id===Ae);if(!re||(Ze=re.activeHooks)!=null&&Ze.includes(be))return;p.updateList(re,{...re,activeHooks:[...re.activeHooks??[],be]})}if(De==="edge-skill"&&ke==="skills"){const[re,xe]=Ae.split(":"),oe=p.editConfig.edges.find(ie=>ie.from===re&&ie.to===xe);if(!oe)return;p.updateEdge(oe,{...oe,command:`/${be} {id}`})}}},[p,Q,de,fe,me]),h=d.useCallback(()=>{a(null)},[]),[T,E]=d.useState(!1),[U,K]=d.useState(null),He=d.useCallback(async()=>{if(!(!p.validation.valid||T)){E(!0),K(null);try{const O=await(await fetch(o("/workflow"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(p.editConfig)})).json();if(!O.success)throw new Error(O.error??"Save failed");p.discard()}catch(k){const O=k instanceof Error?k.message:"Workflow save failed";console.error("Workflow save failed:",k),K(O)}finally{E(!1)}}},[p,T,o]),{activeSkills:Fe,activeSkillPaths:Re,activeAgentPaths:D,activeHookPaths:Y,hookCategoryMap:Oe}=J,pe=t==="skills"?Re:t==="agents"?D:Y,ue=d.useMemo(()=>{if(t!=="agents")return;const k={"red-team":"#ef4444","blue-team":"#3b82f6","green-team":"#22c55e"},O=new Map;function H(F,W){for(const te of F)if(te.type==="folder"&&te.children)H(te.children,te.name);else if(te.type==="file"&&W){const ve=k[W.toLowerCase()]??"#8B5CF6";O.set(te.path,{team:W,color:ve})}}return H(j,null),O},[t,j]),{setNodeRef:Ct,isOver:Je}=Se({id:"drop::remove"}),St=(n==null?void 0:n.type)==="pipeline",Et=d.useMemo(()=>{let k=0;function O(H){for(const F of H)F.type==="file"&&k++,F.children&&O(F.children)}return O(j),k},[j]);return e.jsxs(Jt,{sensors:ce,modifiers:ge,onDragStart:we,onDragEnd:c,onDragCancel:h,children:[e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(Kt,{}),e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(qe,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Primitives"}),e.jsxs(se,{variant:"secondary",className:"ml-2",children:[Et," ",t]}),P&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[x?e.jsxs(se,{variant:"outline",className:"gap-1.5",children:[e.jsx(ut,{className:"h-3 w-3"}),"Project scope"]}):e.jsxs(se,{variant:"outline",className:"gap-1.5",children:[e.jsx(ts,{className:"h-3 w-3"}),"Global scope"]}),e.jsxs(je,{variant:l?"default":"outline",size:"sm",onClick:()=>u(!l),children:["Sync Status",g&&e.jsx("span",{className:"ml-1.5 h-2 w-2 rounded-full bg-amber-500 animate-pulse"})]})]})})]}),l&&P&&e.jsx("div",{className:"mb-4 rounded border border-border bg-card p-2",children:e.jsx(Ss,{})}),b&&x&&e.jsx("div",{className:"mb-4",children:e.jsx(Es,{projectId:x,relativePath:b.relativePath,onResolved:()=>{$(null),m()},onCancel:()=>$(null)})}),p.editMode&&p.changeCount>0&&e.jsxs("div",{className:"mb-2 flex items-center gap-2 rounded border border-border bg-card px-3 py-2",children:[e.jsxs(se,{variant:"outline",children:[p.changeCount," unsaved"]}),p.canUndo&&e.jsx(je,{variant:"ghost",size:"sm",onClick:p.undo,children:"Undo"}),p.canRedo&&e.jsx(je,{variant:"ghost",size:"sm",onClick:p.redo,children:"Redo"}),e.jsx("div",{className:"flex-1"}),e.jsx(je,{variant:"ghost",size:"sm",onClick:p.discard,children:"Discard"}),e.jsx(je,{size:"sm",onClick:He,disabled:T||!p.validation.valid,children:T?"Saving...":"Save"}),U&&e.jsx("span",{className:"text-xs text-destructive ml-2",children:U})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 gap-2",children:[e.jsxs("div",{ref:Ct,className:R("flex w-[20%] min-w-[180px] flex-col rounded border bg-card card-glass neon-border-blue transition-colors",Je?"border-ask-red/60 bg-ask-red/5":"border-border"),children:[St&&Je&&e.jsxs("div",{className:"flex items-center justify-center gap-1.5 border-b border-ask-red/30 bg-ask-red/10 px-2 py-1.5 text-[10px] text-ask-red",children:[e.jsx(Ge,{className:"h-3 w-3"})," Drop to remove"]}),e.jsx(ms,{tree:j,loading:A,selectedPath:M,type:t,onSelect:S,onRefresh:I,onTabChange:f,activePaths:pe,activeSkills:t==="skills"?Fe:void 0,hookCategoryMap:t==="hooks"?Oe:void 0,agentTeamMap:ue})]}),e.jsx("div",{className:"flex w-[35%] min-w-[220px] flex-col rounded border border-border bg-card card-glass neon-border-blue",children:e.jsx(Rs,{selectedPath:M,onSelectItem:G,editConfig:he,editable:!0,onRemoveEdgeHook:Q,onRemoveStageHook:de,onRemoveGlobalHook:fe})}),e.jsx("div",{className:"flex w-[45%] min-w-[280px] flex-col rounded border border-border bg-card card-glass neon-border-blue",children:e.jsx(ys,{type:v,filePath:M,content:B,setContent:L,frontmatter:ne,setFrontmatterField:y,body:C,setBody:z,dirty:Z,saving:q,loading:X,error:ae,onSave:_})})]})]}),e.jsx(Yt,{children:n&&e.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-[11px] font-medium bg-card shadow-lg border-accent-blue/50 text-foreground",children:[n.type==="hooks"&&e.jsx($e,{className:"h-3 w-3 text-amber-400"}),n.type==="skills"&&e.jsx(Ue,{className:"h-3 w-3 text-green-400"}),n.type==="agents"&&e.jsx(qe,{className:"h-3 w-3 text-purple-400"}),n.name]})})]})}export{Ys as PrimitivesConfig};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./ui-
|
|
1
|
+
import{j as e}from"./ui-QhrRH5wk.js";import{c as j,e as k,j as D,E as le,H as g,I as oe,J as ie,K as U,T as ce,a as x,B as v,M as de,s as $,o as B,N as W,O as X,Q as q,h as me,R as xe,U as ue,V as pe,w as he,S as fe}from"./index-DQVAzHMu.js";import{a as d}from"./vendor-Bqt8AJn2.js";import{u as R,f as L}from"./useSocketListener-DPrExNDV.js";import{C as ge,E as K}from"./workflow-constants-ZcCN11vm.js";import{S as T}from"./shield-DLMQmvFQ.js";import{Z as y}from"./zap-eJ3z8HRI.js";import{F as je}from"./file-text-PnzRO4pO.js";import{C as Y}from"./circle-x-B4nA79je.js";import{R as S,A as be,C as J,X as E,Y as _,T as A,a as Ne,B as I,b as w,d as C}from"./charts-LGLb8hyU.js";/**
|
|
2
2
|
* @license lucide-react v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./ui-QhrRH5wk.js";import{a as d}from"./vendor-Bqt8AJn2.js";import{q as V,ak as q,s as B,w as J,V as D,B as y,g as F,a as T,ab as b,al as E,am as U,a9 as K,h as W,f as Q}from"./index-DQVAzHMu.js";import{F as X}from"./file-text-PnzRO4pO.js";import"./charts-LGLb8hyU.js";const Y={createScope:"Created",reviewScope:"Reviewed",implementScope:"Implemented",verifyScope:"Verified",reviewGate:"Review Gate",fixReview:"Fix Review",commit:"Committed",pushToMain:"Pushed to Main",pushToDev:"Pushed to Dev",pushToStaging:"PR to Staging",pushToProduction:"PR to Production"};function z(s){return Y[s]??s}function ie(){const{activeProjectId:s,getApiBase:t}=V(),[n,o]=d.useState([]),[c,x]=d.useState(!0),[a,m]=d.useState(null),[r,j]=d.useState(null),[w,u]=d.useState(!1),[S,h]=d.useState(!1),v=d.useRef(),[R,_]=d.useState({}),{neonGlass:G}=q(),M=d.useCallback(async()=>{try{const l=await fetch("/api/orbital/aggregate/sessions");if(!l.ok)return;const p=await l.json(),g={};for(const A of p)A.project_id&&(g[A.project_id]=(g[A.project_id]??0)+1);_(g)}catch{}},[]);d.useEffect(()=>{M()},[M]);const k=d.useCallback(async()=>{try{const l=s?`${t(s)}/sessions`:"/api/orbital/aggregate/sessions",p=await fetch(l);p.ok&&o(await p.json())}catch{}finally{x(!1)}},[s,t]);d.useEffect(()=>{k()},[k]),d.useEffect(()=>{const l=()=>{k(),M()};return B.on("session:updated",l),()=>{B.off("session:updated",l)}},[k,M]);const f=n,$=d.useCallback(async l=>{m(l),j(null),u(!0);try{const p=t(l.project_id??s),g=await fetch(`${p}/sessions/${l.id}/content`);g.ok&&j(await g.json())}catch{}finally{u(!1)}},[t]);d.useEffect(()=>{a&&!f.some(l=>l.id===a.id)&&(m(null),j(null))},[f,a]),d.useEffect(()=>{!a&&f.length>0&&$(f[0])},[f,a,$]);const H=d.useCallback(async()=>{const l=r==null?void 0:r.claude_session_id;if(!(!a||!l)){h(!0);try{const p=t(a.project_id??s);await fetch(`${p}/sessions/${a.id}/resume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claude_session_id:l})})}catch{}finally{v.current=setTimeout(()=>h(!1),2e3)}}},[a,r,t]);d.useEffect(()=>()=>{clearTimeout(v.current)},[]);const O=!c&&f.length>0;return e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(J,{countOverrides:R}),e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(D,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Sessions"}),!c&&e.jsxs(y,{variant:"secondary",children:[f.length," sessions"]})]}),e.jsxs("div",{className:"flex flex-1 gap-0 overflow-hidden rounded-lg border border-border/50",children:[e.jsx("div",{className:"w-[40%] border-r border-border/50 overflow-hidden",children:c?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):O?e.jsx(F,{className:"h-full",children:e.jsxs("div",{className:"relative p-3",children:[e.jsx("div",{className:"absolute left-6 top-[29px] bottom-3 w-px bg-border"}),e.jsx("div",{className:"space-y-1",children:f.map(l=>e.jsx(Z,{session:l,isSelected:(a==null?void 0:a.id)===l.id,neonGlass:G,onClick:()=>$(l)},l.id))})]})}):e.jsx("div",{className:"flex h-full items-center justify-center p-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx(D,{className:"mx-auto mb-3 h-8 w-8 text-muted-foreground/30"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No session history yet."})]})})}),e.jsx("div",{className:"w-[60%] overflow-hidden",children:a?e.jsx(ee,{session:a,detail:r,loading:w,resuming:S,onResume:H}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(D,{className:"mx-auto mb-3 h-8 w-8 text-muted-foreground/30"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c?"":O?"Select a session to view details":""})]})})})]})]})}function Z({session:s,isSelected:t,neonGlass:n,onClick:o}){var m;const c=s.scope_ids,x=Array.isArray(s.discoveries)?s.discoveries:[],a=Array.isArray(s.next_steps)?s.next_steps:[];return e.jsxs("div",{className:"relative pl-8 cursor-pointer",onClick:o,children:[e.jsx("div",{className:T("absolute left-[8px] top-3 h-2.5 w-2.5 rounded-full border-2",t?"border-primary bg-primary":"border-muted-foreground/40 bg-background",n&&"timeline-dot-glow glow-blue")}),e.jsxs("div",{className:T("rounded-md px-3 py-2 transition-colors",t?"bg-primary/10 border border-primary/30":"hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.started_at&&e.jsx("span",{className:"text-xxs text-muted-foreground",children:b(new Date(s.started_at),"MMM d")}),c.slice(0,3).map(r=>e.jsx(y,{variant:"outline",className:"font-mono text-xxs px-1 py-0",children:E(r)},r)),c.length>3&&e.jsxs("span",{className:"text-xxs text-muted-foreground",children:["+",c.length-3]}),(m=s.actions)==null?void 0:m.slice(0,2).map(r=>e.jsx(y,{variant:"secondary",className:"text-xxs px-1 py-0 font-light",children:z(r)},r))]}),e.jsx("p",{className:T("mt-0.5 text-xs font-normal truncate",t?"text-foreground":"text-foreground/80"),children:s.summary?P(s.summary,80):"Untitled Session"}),e.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xxs text-muted-foreground",children:[x.length>0&&e.jsxs("span",{className:"text-bid-green",children:[x.length," completed"]}),a.length>0&&e.jsxs("span",{className:"text-accent-blue",children:[a.length," next"]})]})]})]})}function ee({session:s,detail:t,loading:n,resuming:o,onResume:c}){var S;const x=s.scope_ids,a=Array.isArray(s.discoveries)?s.discoveries:[],m=Array.isArray(s.next_steps)?s.next_steps:[],r=(t==null?void 0:t.meta)??null,j=!!(t!=null&&t.claude_session_id),w=(r==null?void 0:r.summary)??s.summary??null,u=[];return x.length>0&&u.push(["Scopes",x.map(h=>E(h)).join(", ")]),((S=s.actions)==null?void 0:S.length)>0&&u.push(["Actions",s.actions.map(z).join(", ")]),s.summary&&u.push(["Summary",P(s.summary,200)]),u.push(["Started",s.started_at?b(new Date(s.started_at),"MMM d, h:mm a"):"—"]),u.push(["Ended",s.ended_at?b(new Date(s.ended_at),"MMM d, h:mm a"):"—"]),r!=null&&r.branch&&r.branch!=="unknown"&&u.push(["Branch",r.branch,"font-mono text-xxs"]),r&&r.fileSize>0&&u.push(["File size",te(r.fileSize)]),r&&u.push(["Plan",r.slug,"text-muted-foreground",`/api/orbital/open-file?path=scopes/${r.slug}.md`]),s.handoff_file&&u.push(["Handoff",s.handoff_file,"font-mono text-xxs"]),t!=null&&t.claude_session_id&&u.push(["Session ID",t.claude_session_id,"font-mono text-xxs text-muted-foreground"]),e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"px-5 pt-4 pb-3",children:[e.jsxs("div",{className:"text-xxs text-muted-foreground",children:[s.started_at&&b(new Date(s.started_at),"MMM d, yyyy — h:mm a"),x.length>0&&x.slice(0,4).map(h=>e.jsx("span",{className:"ml-1.5",children:e.jsx(y,{variant:"outline",className:"font-mono text-xxs",children:E(h)})},h)),x.length>4&&e.jsxs("span",{className:"ml-1 text-xxs",children:["+",x.length-4]})]}),e.jsx("h2",{className:"mt-1 text-sm font-light",children:w?P(w,120):"Untitled Session"})]}),e.jsx(U,{}),e.jsx(F,{className:"flex-1",children:e.jsx("div",{className:"px-5 py-4",children:n?e.jsx("div",{className:"flex h-20 items-center justify-center",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full table-fixed text-xs",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"w-28"}),e.jsx("col",{})]}),e.jsx("tbody",{className:"[&_td]:border-b [&_td]:border-border/30 [&_td]:py-2 [&_td]:align-top [&_td:first-child]:pr-3 [&_td:first-child]:text-muted-foreground [&_td:first-child]:whitespace-nowrap [&_td:last-child]:break-all",children:u.map(([h,v,R,_])=>e.jsxs("tr",{children:[e.jsx("td",{children:h}),e.jsx("td",{className:R,children:_?e.jsxs("button",{onClick:()=>{fetch(_,{method:"POST"})},className:"inline-flex items-center gap-1.5 hover:text-accent-blue transition-colors",title:"Open file",children:[v,e.jsx(K,{className:"h-3 w-3 opacity-50"})]}):v})]},h))})]}),e.jsx(I,{title:"Completed",items:a,color:"text-bid-green"}),e.jsx(I,{title:"Next Steps",items:m,color:"text-accent-blue"}),(t==null?void 0:t.stats)&&e.jsx(se,{stats:t.stats}),s.handoff_file&&e.jsxs("div",{className:"mt-4 flex items-center gap-1.5 text-xxs text-muted-foreground/60",children:[e.jsx(X,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:s.handoff_file})]})]})})}),!n&&e.jsxs("div",{className:"border-t border-border/50 px-5 py-3",children:[e.jsxs(W,{className:"w-full",disabled:!j||o,onClick:c,title:j?"Open in iTerm":"No Claude Code session found",children:[e.jsx(Q,{className:"mr-2 h-4 w-4"}),o?"Opening iTerm...":"Resume Session"]}),!j&&e.jsx("p",{className:"mt-1.5 text-center text-xxs text-muted-foreground",children:"No matching Claude Code session found"})]})]})}function se({stats:s}){const{user:t,assistant:n,system:o,timing:c}=s,x=Object.entries(n.toolsUsed).sort((a,m)=>m[1]-a[1]);return e.jsxs("div",{className:"mt-5 space-y-4",children:[e.jsx(U,{}),e.jsxs(N,{title:"Timing",children:[c.durationMs>0&&e.jsx(i,{label:"Duration",value:L(c.durationMs)}),c.firstTimestamp&&e.jsx(i,{label:"First event",value:b(new Date(c.firstTimestamp),"MMM d, h:mm:ss a")}),c.lastTimestamp&&e.jsx(i,{label:"Last event",value:b(new Date(c.lastTimestamp),"MMM d, h:mm:ss a")})]}),e.jsxs(N,{title:"User",children:[e.jsx(i,{label:"Messages",value:`${t.totalMessages-t.metaMessages-t.toolResults} direct, ${t.metaMessages} meta, ${t.toolResults} tool results`}),t.commands.length>0&&e.jsx(i,{label:"Commands",value:t.commands.join(", "),cls:"font-mono"}),t.permissionModes.length>0&&e.jsx(i,{label:"Permission modes",value:t.permissionModes.join(", ")}),t.version&&e.jsx(i,{label:"Claude Code version",value:t.version,cls:"font-mono"}),t.cwd&&e.jsx(i,{label:"Working directory",value:t.cwd,cls:"font-mono text-xxs"})]}),e.jsxs(N,{title:"Assistant",children:[e.jsx(i,{label:"Responses",value:String(n.totalMessages)}),n.models.length>0&&e.jsx(i,{label:"Models",value:n.models.join(", "),cls:"font-mono"}),e.jsx(i,{label:"Input tokens",value:C(n.totalInputTokens)}),e.jsx(i,{label:"Output tokens",value:C(n.totalOutputTokens)}),n.totalCacheReadTokens>0&&e.jsx(i,{label:"Cache read tokens",value:C(n.totalCacheReadTokens)}),n.totalCacheCreationTokens>0&&e.jsx(i,{label:"Cache creation tokens",value:C(n.totalCacheCreationTokens)}),x.length>0&&e.jsxs("tr",{children:[e.jsx("td",{className:"pr-3 text-muted-foreground whitespace-nowrap align-top",children:"Tools used"}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:x.map(([a,m])=>e.jsxs(y,{variant:"outline",className:"font-mono text-xxs px-1.5 py-0",children:[a," ",e.jsx("span",{className:"ml-1 text-muted-foreground",children:m})]},a))})})]})]}),o.totalMessages>0&&e.jsxs(N,{title:"System",children:[e.jsx(i,{label:"Events",value:String(o.totalMessages)}),o.subtypes.length>0&&e.jsx(i,{label:"Subtypes",value:o.subtypes.join(", ")}),o.stopReasons.length>0&&e.jsx(i,{label:"Stop reasons",value:o.stopReasons.join(", ")}),o.totalDurationMs>0&&e.jsx(i,{label:"Total processing",value:L(o.totalDurationMs)}),o.hookCount>0&&e.jsx(i,{label:"Hooks fired",value:`${o.hookCount}${o.hookErrors>0?` (${o.hookErrors} errors)`:""}`})]}),e.jsx(N,{title:"Raw Counts",children:Object.entries(s.typeCounts).sort((a,m)=>m[1]-a[1]).map(([a,m])=>e.jsx(i,{label:a,value:String(m)},a))})]})}function N({title:s,children:t}){return e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-xxs font-medium uppercase tracking-wider text-foreground",children:s}),e.jsxs("table",{className:"w-full table-fixed text-xs",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"w-40"}),e.jsx("col",{})]}),e.jsx("tbody",{className:"[&_td]:border-b [&_td]:border-border/20 [&_td]:py-1.5 [&_td]:align-top [&_td:first-child]:pr-3 [&_td:first-child]:text-muted-foreground [&_td:first-child]:whitespace-nowrap",children:t})]})]})}function i({label:s,value:t,cls:n}){return e.jsxs("tr",{children:[e.jsx("td",{children:s}),e.jsx("td",{className:n,children:t})]})}function I({title:s,items:t,color:n}){return t.length===0?null:e.jsxs("div",{className:"mt-5",children:[e.jsx("h4",{className:"mb-2 text-xxs font-medium uppercase tracking-wider text-foreground",children:s}),e.jsx("ul",{className:"space-y-1.5",children:t.map(o=>e.jsxs("li",{className:"flex items-start gap-2 text-xs",children:[e.jsx("span",{className:T("mt-0.5",n),children:"•"}),e.jsx("span",{children:o})]},o))})]})}function P(s,t){return s.length>t?s.slice(0,t)+"...":s}function te(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function L(s){if(s<1e3)return`${s}ms`;const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),o=t%60;if(n<60)return`${n}m ${o}s`;const c=Math.floor(n/60),x=n%60;return`${c}h ${x}m`}function C(s){return s.toLocaleString()}export{ie as SessionTimeline};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{j as e}from"./ui-QhrRH5wk.js";import{a as d}from"./vendor-Bqt8AJn2.js";import{c as Se,q as Te,Y as he,s as ye,C as $e,b as Pe,U as E,h as D,an as V,B as xe,a as v,a3 as pe,a5 as fe,a6 as ge,a7 as je,am as w,ao as J,K as Ue,ap as be,a8 as De,S as Ae,aq as _e,H as we,ar as Ie,as as Be,T as ze,at as Ve,aa as He,E as Je,au as Ge,d as We,P as z,X as Ee,av as Me,aw as ke,ax as Ke,ay as Ye,az as Le,g as qe}from"./index-DQVAzHMu.js";import{M as H}from"./minus-CJlpKNUB.js";import"./charts-LGLb8hyU.js";/**
|
|
2
|
+
* @license lucide-react v0.577.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Xe=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],Oe=Se("archive",Xe);/**
|
|
7
|
+
* @license lucide-react v0.577.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Qe=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],Ze=Se("skip-forward",Qe);function et(){const{getApiBase:t}=Te(),[i,s]=d.useState(null),[o,a]=d.useState(null),[n,r]=d.useState([]),[m,u]=d.useState(null),[c,p]=d.useState(null),[b,x]=d.useState(null),[l,f]=d.useState(null),[N,M]=d.useState(null),[y,O]=d.useState(null),[G,W]=d.useState(null),[Z,ee]=d.useState(!0),[A,g]=d.useState(null),$=d.useCallback(async()=>{try{const h=await fetch("/api/orbital/aggregate/manifest/status");if(h.ok){const j=await h.json();s(j)}}catch{}finally{ee(!1)}},[]),C=d.useCallback(async h=>{try{const j=await fetch(`${t(h)}/manifest/files`);if(j.ok){const F=await j.json();r(F.data??[])}}catch{}},[t]);d.useEffect(()=>{$()},[$]),he(()=>{$(),o&&C(o)}),d.useEffect(()=>{const h=()=>{$(),o&&C(o)};return ye.on("manifest:changed",h),()=>{ye.off("manifest:changed",h)}},[$,C,o]);const te=d.useCallback(h=>{if(o===h){a(null),r([]);return}a(h),r([]),C(h)},[o,C]),se=d.useCallback(()=>{a(null),r([])},[]),K=d.useCallback(async()=>{g("update-all");try{await fetch("/api/orbital/aggregate/manifest/update-all",{method:"POST",headers:{"Content-Type":"application/json"}}),await $()}catch{}finally{g(null)}},[$]),Y=d.useCallback(async h=>{g(`preview:${h}`);try{const j=await fetch(`${t(h)}/manifest/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:!0})});if(j.ok){const F=await j.json();p(F.data),x(h)}}catch{}finally{g(null)}},[t]),ae=d.useCallback(async h=>{g(`update:${h}`);try{(await fetch(`${t(h)}/manifest/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:!1})})).ok&&(p(null),x(null),await $())}catch{}finally{g(null)}},[t,$]),_=d.useCallback(async h=>{g(`init:${h}`);try{await fetch(`${t(h)}/manifest/init`,{method:"POST",headers:{"Content-Type":"application/json"}}),await $()}catch{}finally{g(null)}},[t,$]),ne=d.useCallback(async h=>{g(`validate:${h}`);try{const j=await fetch(`${t(h)}/manifest/validate`);if(j.ok){const F=await j.json();u(F.data)}}catch{}finally{g(null)}},[t]),re=d.useCallback(async(h,j,F)=>{g(`pin:${j}`);try{await fetch(`${t(h)}/manifest/pin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:j,reason:F})})}catch{}finally{g(null)}},[t]),L=d.useCallback(async(h,j)=>{g(`unpin:${j}`);try{await fetch(`${t(h)}/manifest/unpin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:j})})}catch{}finally{g(null)}},[t]),q=d.useCallback(async(h,j)=>{g(`reset:${j}`);try{await fetch(`${t(h)}/manifest/reset`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:j})})}catch{}finally{g(null)}},[t]),X=d.useCallback(async(h,j)=>{g(`revert:${j}`);try{await fetch(`${t(h)}/manifest/revert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:j})})}catch{}finally{g(null)}},[t]),Q=d.useCallback(async(h,j,F)=>{var Ne;g(`diff:${j}`),M(j),O(F??null),W(h);try{const ve=await fetch(`${t(h)}/manifest/diff?file=${encodeURIComponent(j)}`);if(ve.ok){const Re=await ve.json();f(((Ne=Re.data)==null?void 0:Ne.diff)??null)}}catch{}finally{g(null)}},[t]),k=d.useCallback(()=>{f(null),M(null),O(null),W(null)},[]),S=d.useCallback(()=>{p(null),x(null)},[]),le=d.useCallback(()=>u(null),[]);return{summary:i,loading:Z,actionLoading:A,expandedProjectId:o,projectFiles:n,validation:m,updatePreview:c,updatePreviewProjectId:b,diffContent:l,diffFile:N,diffFileStatus:y,diffProjectId:G,expandProject:te,collapseProject:se,fetchSummary:$,updateAll:K,previewProjectUpdate:Y,applyProjectUpdate:ae,clearUpdatePreview:S,initProject:_,validateProject:ne,clearValidation:le,pinFile:re,unpinFile:L,resetFile:q,revertFile:X,getDiff:Q,clearDiff:k}}function tt({files:t,actionLoading:i,onPin:s,onUnpin:o,onReset:a,onRevert:n,onDiff:r}){const m=t.filter(l=>l.status==="missing"),u=t.filter(l=>l.status==="outdated"),c=t.filter(l=>l.status==="modified"),p=t.filter(l=>l.status==="pinned"),b=t.filter(l=>l.status==="synced"),x=t.filter(l=>l.status==="user-owned");return t.length===0?e.jsx("div",{className:"text-xs text-muted-foreground/40 py-2 pl-4",children:"No tracked files."}):e.jsxs("div",{className:"pl-4 pb-2",children:[e.jsx(I,{title:`Missing (${m.length})`,description:"expected but not found on disk",files:m,defaultOpen:!0,renderRow:l=>e.jsx(B,{file:l,children:e.jsx(P,{label:"Restore",variant:"cyan",onClick:()=>a(l.path),loading:i===`reset:${l.path}`})},l.path)}),e.jsx(I,{title:`Outdated (${u.length})`,description:"newer template version available",files:u,defaultOpen:!1,renderRow:l=>e.jsxs(B,{file:l,children:[e.jsx(P,{label:"View changes",onClick:()=>r(l.path,l.status),loading:i===`diff:${l.path}`}),e.jsx(P,{label:"Update",variant:"cyan",onClick:()=>a(l.path),loading:i===`reset:${l.path}`}),l.hasPrev&&e.jsx(P,{label:"Revert",onClick:()=>n(l.path),loading:i===`revert:${l.path}`})]},l.path)}),e.jsx(I,{title:`Modified (${c.length})`,description:"edited by you",files:c,defaultOpen:!1,renderRow:l=>e.jsxs(B,{file:l,children:[e.jsx(P,{label:"View changes",onClick:()=>r(l.path,l.status),loading:i===`diff:${l.path}`}),e.jsx(P,{label:"Reset",onClick:()=>a(l.path),loading:i===`reset:${l.path}`}),e.jsx(P,{label:"Pin",variant:"blue",onClick:()=>s(l.path),loading:i===`pin:${l.path}`}),l.hasPrev&&e.jsx(P,{label:"Revert",onClick:()=>n(l.path),loading:i===`revert:${l.path}`})]},l.path)}),e.jsx(I,{title:`Pinned (${p.length})`,description:"locked from updates",files:p,defaultOpen:!1,renderRow:l=>e.jsxs(B,{file:l,meta:l.pinnedReason?`"${l.pinnedReason}"`:void 0,children:[e.jsx(P,{label:"View changes",onClick:()=>r(l.path,l.status),loading:i===`diff:${l.path}`}),e.jsx(P,{label:"Unpin",onClick:()=>o(l.path),loading:i===`unpin:${l.path}`}),e.jsx(P,{label:"Reset",onClick:()=>a(l.path),loading:i===`reset:${l.path}`}),l.hasPrev&&e.jsx(P,{label:"Revert",onClick:()=>n(l.path),loading:i===`revert:${l.path}`})]},l.path)}),e.jsx(I,{title:`Synced (${b.length})`,description:"matches template",files:b,defaultOpen:!1,renderRow:l=>e.jsx(B,{file:l,children:l.hasPrev&&e.jsx(P,{label:"Revert",onClick:()=>n(l.path),loading:i===`revert:${l.path}`})},l.path)}),e.jsx(I,{title:`User (${x.length})`,description:"your files, not managed",files:x,defaultOpen:!1,renderRow:l=>e.jsx(B,{file:l},l.path)})]})}function I({title:t,description:i,files:s,defaultOpen:o,renderRow:a}){const[n,r]=d.useState(o);return s.length===0?null:e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{onClick:()=>r(!n),className:"flex items-center gap-1.5 text-xs text-muted-foreground/70 hover:text-muted-foreground transition-colors mb-1",children:[n?e.jsx($e,{className:"h-3 w-3"}):e.jsx(Pe,{className:"h-3 w-3"}),e.jsx("span",{children:t}),e.jsx("span",{className:"text-muted-foreground/40 font-normal",children:i})]}),n&&e.jsx("div",{className:"space-y-1.5 ml-4",children:s.map(a)})]})}function B({file:t,meta:i,children:s}){return e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs font-mono text-foreground/70",children:t.path}),i&&e.jsx("span",{className:"text-xs text-muted-foreground/40 italic",children:i}),s]})}function P({label:t,variant:i,onClick:s,loading:o}){const a="rounded border px-1.5 py-0 text-[10px] leading-5 transition-colors disabled:opacity-40",n={cyan:"border-cyan-500/30 bg-cyan-500/10 text-cyan-400 hover:bg-cyan-500/20",blue:"border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20",default:"border-border bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"};return e.jsxs("button",{onClick:s,disabled:o,className:`${a} ${n[i??"default"]}`,children:[o?e.jsx(E,{className:"h-3 w-3 animate-spin inline mr-1"}):null,t]})}function st({project:t,expanded:i,files:s,actionLoading:o,onToggle:a,onUpdate:n,onInit:r,onPin:m,onUnpin:u,onReset:c,onRevert:p,onDiff:b}){const{projectId:x,projectName:l,projectColor:f,status:N,manifest:M}=t;if(N==="no-manifest")return e.jsx("div",{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:`hsl(${f})`}}),e.jsx("span",{className:"text-sm text-foreground truncate",children:l}),e.jsx("span",{className:"text-xs text-muted-foreground/40",children:"No manifest"})]}),e.jsxs(D,{size:"sm",variant:"outline",onClick:r,disabled:o===`init:${x}`,className:"h-6 px-2 text-xs border-[rgba(0,188,212,0.3)] text-cyan-400 hover:bg-cyan-500/10",children:[o===`init:${x}`?e.jsx(E,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(V,{className:"h-3 w-3 mr-1"}),"Initialize"]})]})});if(N==="error")return e.jsx("div",{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0 opacity-40",style:{backgroundColor:`hsl(${f})`}}),e.jsx("span",{className:"text-sm text-foreground/50 truncate",children:l}),e.jsx("span",{className:"text-xs text-red-400/60",children:"Offline"})]})});const y=M,O=y.files.outdated>0||y.files.missing>0||y.needsUpdate;return e.jsxs("div",{className:"py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 cursor-pointer hover:opacity-80 transition-opacity",onClick:a,children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:`hsl(${f})`}}),e.jsx("span",{className:"text-sm text-foreground truncate w-[80px] sm:w-[140px] shrink-0",children:l}),e.jsxs(xe,{variant:"outline",className:v("text-[10px] px-1.5 py-0 shrink-0",y.needsUpdate?"border-amber-500/30 text-amber-400 bg-amber-500/10":"border-green-500/30 text-green-400 bg-green-500/10"),children:["v",y.installedVersion]}),y.needsUpdate&&e.jsxs("span",{className:"text-[10px] text-amber-400/60 shrink-0",children:["→ v",y.packageVersion]}),e.jsxs("span",{className:"hidden md:flex items-center text-xs shrink-0 tabular-nums",children:[e.jsxs("span",{className:v("w-[80px] text-center",y.files.missing>0?"text-red-400":"text-red-400/25"),children:[y.files.missing," missing"]}),e.jsxs("span",{className:v("w-[80px] text-center",y.files.outdated>0?"text-amber-400":"text-amber-400/25"),children:[y.files.outdated," outdated"]}),e.jsxs("span",{className:v("w-[80px] text-center",y.files.modified>0?"text-orange-400":"text-orange-400/25"),children:[y.files.modified," modified"]}),e.jsxs("span",{className:v("w-[80px] text-center",y.files.pinned>0?"text-blue-400":"text-blue-400/25"),children:[y.files.pinned," pinned"]}),e.jsxs("span",{className:v("w-[80px] text-center",y.files.synced>0?"text-green-400/50":"text-green-400/20"),children:[y.files.synced," synced"]}),e.jsxs("span",{className:v("w-[80px] text-center",y.files.userOwned>0?"text-muted-foreground/40":"text-muted-foreground/20"),children:[y.files.userOwned," user"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs(D,{size:"sm",variant:"outline",onClick:O?n:void 0,disabled:!O||o===`preview:${x}`||o===`update:${x}`,className:v("h-6 px-2 text-xs w-auto sm:w-[130px] justify-center",O?"border-[rgba(0,188,212,0.3)] text-cyan-400 hover:bg-cyan-500/10":"border-green-500/30 text-green-400/60"),children:[o===`preview:${x}`||o===`update:${x}`?e.jsx(E,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(V,{className:"h-3 w-3 mr-1"}),O?"Update Project":"Up to Date"]}),e.jsx("button",{onClick:a,className:"flex items-center justify-center h-6 w-6 rounded text-muted-foreground/40 hover:text-muted-foreground hover:bg-white/5 transition-colors",children:i?e.jsx($e,{className:"h-3.5 w-3.5"}):e.jsx(Pe,{className:"h-3.5 w-3.5"})})]})]}),i&&e.jsx(tt,{files:s,actionLoading:o,onPin:m,onUnpin:u,onReset:c,onRevert:p,onDiff:b})]})}function at({updatePreview:t,projectName:i,updatePreviewProjectId:s,actionLoading:o,onApply:a,onClose:n}){return e.jsx(pe,{open:t!==null,onOpenChange:r=>{r||n()},children:e.jsxs(fe,{className:"max-w-md p-0 max-h-[80vh] overflow-hidden grid grid-rows-[auto_auto_1fr_auto_auto]",children:[e.jsxs(ge,{className:"px-5 pt-4 pb-3 pr-10",children:[e.jsxs(je,{className:"text-sm",children:["Update ",i]}),e.jsx("span",{className:"text-xs text-muted-foreground/60",children:"Review what will happen before applying"})]}),e.jsx(w,{}),t&&!t.isEmpty&&e.jsxs("div",{className:"px-5 py-4 space-y-3 overflow-auto min-h-0",children:[(t.toUpdate.length>0||t.toAdd.length>0)&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(J,{className:"h-4 w-4 text-cyan-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[t.toUpdate.length+t.toAdd.length," file",t.toUpdate.length+t.toAdd.length!==1?"s":""," will be updated"]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"Synced and outdated files replaced with the latest template version"}),e.jsxs("div",{className:"mt-1.5 space-y-0.5",children:[t.toUpdate.map(r=>e.jsx("div",{className:"text-xs font-mono text-cyan-400/70",children:r},r)),t.toAdd.map(r=>e.jsxs("div",{className:"text-xs font-mono text-green-400/70",children:[r," ",e.jsx("span",{className:"text-muted-foreground/40",children:"(new)"})]},r))]})]})]}),t.toRename.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ue,{className:"h-4 w-4 text-purple-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[t.toRename.length," file",t.toRename.length!==1?"s":""," will be renamed"]}),e.jsx("div",{className:"mt-1.5 space-y-0.5",children:t.toRename.map(r=>e.jsxs("div",{className:"text-xs font-mono text-purple-400/70",children:[r.from," → ",r.to]},r.from))})]})]}),t.toRemove.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(H,{className:"h-4 w-4 text-red-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[t.toRemove.length," file",t.toRemove.length!==1?"s":""," will be removed"]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"No longer part of the template"}),e.jsx("div",{className:"mt-1.5 space-y-0.5",children:t.toRemove.map(r=>e.jsx("div",{className:"text-xs font-mono text-red-400/70",children:r},r))})]})]}),t.toSkip.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ze,{className:"h-4 w-4 text-muted-foreground/50 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground/70",children:[t.toSkip.length," file",t.toSkip.length!==1?"s":""," will be skipped"]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"Modified or pinned files are never overwritten"}),e.jsx("div",{className:"mt-1.5 space-y-0.5",children:t.toSkip.map(r=>e.jsxs("div",{className:"text-xs font-mono text-muted-foreground/40",children:[r.file," ",e.jsxs("span",{className:"text-muted-foreground/30",children:["(",r.reason,")"]})]},r.file))})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Oe,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 shrink-0"}),e.jsx("div",{className:"text-xs text-muted-foreground/50",children:"Previous versions will be backed up and can be reverted"})]})]}),t&&t.isEmpty&&e.jsx("div",{className:"px-5 py-8 text-center text-sm text-muted-foreground",children:"Everything is up to date. No changes needed."}),e.jsx(w,{}),e.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2",children:[e.jsx(be,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",children:"Cancel"})}),t&&!t.isEmpty&&s&&e.jsxs(D,{size:"sm",onClick:()=>a(s),disabled:o===`update:${s}`,className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[o===`update:${s}`&&e.jsx(E,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update Project"]})]})]})})}function nt({open:t,onOpenChange:i,summary:s,actionLoading:o,onUpdateAll:a}){return e.jsx(pe,{open:t,onOpenChange:i,children:e.jsxs(fe,{className:"max-w-md p-0 max-h-[80vh] overflow-hidden grid grid-rows-[auto_auto_1fr_auto_auto]",children:[e.jsxs(ge,{className:"px-5 pt-4 pb-3 pr-10",children:[e.jsx(je,{className:"text-sm",children:"Update All Projects"}),e.jsx(De,{className:"text-xs text-muted-foreground/60",children:"Review what will happen across all projects"})]}),e.jsx(w,{}),e.jsxs("div",{className:"px-5 py-4 space-y-3 overflow-auto min-h-0",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(J,{className:"h-4 w-4 text-cyan-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[s.totalOutdated+s.totalMissing," file",s.totalOutdated+s.totalMissing!==1?"s":""," to sync across ",s.projectsOutdated||s.projects.filter(n=>n.manifest&&(n.manifest.files.outdated>0||n.manifest.files.missing>0)).length," project",s.projects.filter(n=>n.manifest&&(n.manifest.files.outdated>0||n.manifest.files.missing>0)).length!==1?"s":""]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"Synced and outdated files will be replaced with the latest template version"})]})]}),(s.totalModified>0||s.totalPinned>0)&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ae,{className:"h-4 w-4 text-green-400/60 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground/70",children:[s.totalModified+s.totalPinned," file",s.totalModified+s.totalPinned!==1?"s":""," will not be touched"]}),e.jsxs("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:[s.totalModified>0&&e.jsxs(e.Fragment,{children:[s.totalModified," modified"]}),s.totalModified>0&&s.totalPinned>0&&" and ",s.totalPinned>0&&e.jsxs(e.Fragment,{children:[s.totalPinned," pinned"]})," ","file",s.totalModified+s.totalPinned!==1?"s":""," are never overwritten"]})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Oe,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 shrink-0"}),e.jsx("div",{className:"text-xs text-muted-foreground/50",children:"Previous versions will be backed up and can be reverted"})]})]}),e.jsx(w,{}),e.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2",children:[e.jsx(be,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",children:"Cancel"})}),e.jsxs(D,{size:"sm",onClick:()=>{i(!1),a()},disabled:o==="update-all",className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[o==="update-all"&&e.jsx(E,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update All Projects"]})]})]})})}function rt(t){const i=t.split(`
|
|
12
|
+
`),s=[];let o=0,a=0;for(const n of i){const r=n.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@(.*)/);if(r){o=parseInt(r[1],10),a=parseInt(r[2],10),s.push({type:"hunk",content:n});continue}if(n.startsWith("diff ")||n.startsWith("index ")||n.startsWith("--- ")||n.startsWith("+++ ")){s.push({type:"meta",content:n});continue}if(n.startsWith("-"))s.push({type:"remove",content:n.slice(1),oldNum:o}),o++;else if(n.startsWith("+"))s.push({type:"add",content:n.slice(1),newNum:a}),a++;else{const m=n.startsWith(" ")?n.slice(1):n;s.push({type:"context",content:m,oldNum:o,newNum:a}),o++,a++}}return s}function lt({diff:t}){const i=rt(t),s=i.reduce((a,n)=>Math.max(a,n.oldNum??0,n.newNum??0),0),o=String(s).length;return e.jsx("div",{className:"text-[11px] font-mono leading-[1.6] pb-1",children:i.map((a,n)=>{if(a.type==="meta")return null;if(a.type==="hunk")return e.jsx("div",{className:"px-3 py-1.5 mt-1 first:mt-0 text-cyan-400/60 bg-cyan-500/5 border-y border-cyan-500/10 select-none",children:a.content},n);const r=a.oldNum!=null?String(a.oldNum).padStart(o):"".padStart(o),m=a.newNum!=null?String(a.newNum).padStart(o):"".padStart(o),u=v("flex",a.type==="add"&&"bg-green-500/10",a.type==="remove"&&"bg-red-500/10"),c=v("select-none border-r border-border/40 px-2 text-right shrink-0",a.type==="add"&&"text-green-400/40",a.type==="remove"&&"text-red-400/40",a.type==="context"&&"text-muted-foreground/25"),p=v("px-3 whitespace-pre-wrap break-all flex-1 min-w-0",a.type==="add"&&"text-green-400",a.type==="remove"&&"text-red-400",a.type==="context"&&"text-foreground/50"),b=a.type==="add"?"+":a.type==="remove"?"-":" ";return e.jsxs("div",{className:u,children:[e.jsx("span",{className:c,children:r}),e.jsx("span",{className:c,children:m}),e.jsx("span",{className:v("w-4 text-center shrink-0 select-none",a.type==="add"&&"text-green-400/60",a.type==="remove"&&"text-red-400/60",a.type==="context"&&"text-transparent"),children:b}),e.jsx("span",{className:p,children:a.content||" "})]},n)})})}function it({diffFile:t,diffContent:i,diffFileStatus:s,diffProjectId:o,actionLoading:a,onResetFile:n,onClearDiff:r}){return e.jsx(pe,{open:t!==null,onOpenChange:m=>{m||r()},children:e.jsxs(fe,{className:"max-w-2xl p-0 max-h-[80vh] overflow-hidden grid grid-rows-[auto_auto_auto_1fr_auto_auto]",children:[e.jsxs(ge,{className:"px-5 pt-4 pb-3 pr-10",children:[e.jsx(je,{className:"text-sm font-mono",children:t}),e.jsx(De,{className:"text-xs text-muted-foreground/60",children:"Template → Your file"})]}),e.jsx(w,{}),e.jsxs("div",{className:"px-5 py-2 text-xs text-muted-foreground/50",children:[e.jsx("span",{className:"text-red-400/70",children:"−"})," template version",e.jsx("span",{className:"mx-2",children:"·"}),e.jsx("span",{className:"text-green-400/70",children:"+"})," your local file"]}),e.jsx("div",{className:"overflow-auto min-h-0",children:i?e.jsx(lt,{diff:i}):e.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-sm",children:[e.jsx(E,{className:"h-4 w-4 mr-2 animate-spin"}),"Loading diff..."]})}),e.jsx(w,{}),e.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2",children:[e.jsx(be,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",children:"Close"})}),s==="outdated"&&o&&e.jsxs(D,{size:"sm",onClick:()=>{n(o,t),r()},disabled:a===`reset:${t}`,className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[a===`reset:${t}`&&e.jsx(E,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update to latest"]}),s==="modified"&&o&&e.jsxs(D,{size:"sm",onClick:()=>{n(o,t),r()},disabled:a===`reset:${t}`,variant:"outline",children:[a===`reset:${t}`&&e.jsx(E,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Reset to template"]})]})]})})}function ot(){var Q;const{summary:t,loading:i,actionLoading:s,expandedProjectId:o,projectFiles:a,updatePreview:n,updatePreviewProjectId:r,diffContent:m,diffFile:u,diffFileStatus:c,diffProjectId:p,expandProject:b,updateAll:x,previewProjectUpdate:l,applyProjectUpdate:f,clearUpdatePreview:N,initProject:M,pinFile:y,unpinFile:O,resetFile:G,revertFile:W,getDiff:Z,clearDiff:ee}=et(),{version:A,updateAvailable:g,behindCount:$,updateStage:C,updateError:te,checkForUpdate:se,performUpdate:K}=_e(),Y=d.useRef(C);Y.current=C;const ae=d.useCallback(async()=>{await K(),Y.current!=="error"&&await x()},[K,x]),_=C==="pulling"||C==="installing",ne=C==="checking"||C==="checked",[re,L]=d.useState(!1);if(i)return e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(E,{className:"h-4 w-4 animate-spin"}),"Loading configuration status..."]});if(!t||t.total===0)return e.jsx("div",{className:"text-sm text-muted-foreground/60",children:"No projects registered."});const q=t.projects.length>0&&t.projects.every(k=>{var S;return k.status==="ok"&&!((S=k.manifest)!=null&&S.needsUpdate)})&&t.noManifest===0&&t.totalOutdated===0&&t.totalMissing===0&&t.totalModified===0&&t.totalPinned===0,X=t.projects.filter(k=>{var S;return k.status==="ok"&&((S=k.manifest)==null?void 0:S.needsUpdate)}).length;return e.jsxs(e.Fragment,{children:[A&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 flex items-baseline gap-3",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground/70",children:"Package"}),e.jsx("span",{className:"text-[11px] text-muted-foreground/40",children:"Globally installed Orbital Command version"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(V,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm text-foreground",children:"Orbital Command"}),e.jsxs(xe,{variant:"outline",className:v("text-[10px] px-1.5 py-0",g?"border-emerald-500/30 text-emerald-400 bg-emerald-500/10":"border-green-500/30 text-green-400 bg-green-500/10"),children:["v",A.version]}),g&&e.jsxs("span",{className:"text-xs text-emerald-400/70",children:[$," update",$!==1?"s":""," available"]}),C==="checked"&&!g&&e.jsx("span",{className:"text-xs text-green-400",children:"Up to date"}),C==="done"&&e.jsx("span",{className:"text-xs text-green-400",children:"Updated — restart server to apply"}),C==="error"&&e.jsx("span",{className:"text-xs text-red-400 truncate",children:te}),_&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(E,{className:"h-3 w-3 animate-spin"}),C==="pulling"?"Pulling...":"Installing..."]})]}),e.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[e.jsxs(D,{size:"sm",variant:"ghost",onClick:se,disabled:_||ne,className:"h-7 px-2 text-xs",children:[C==="checked"&&!g?e.jsx(we,{className:"h-3 w-3 mr-1 text-green-400"}):e.jsx(Ie,{className:v("h-3 w-3 mr-1",C==="checking"&&"animate-spin")}),C==="checked"&&!g?"Latest":"Check"]}),g&&C!=="done"&&e.jsxs(D,{size:"sm",variant:"outline",onClick:ae,disabled:_,className:"h-7 px-2.5 text-xs border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10",children:[_?e.jsx(E,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(Be,{className:"h-3 w-3 mr-1"}),"Update"]})]})]}),e.jsx(w,{className:"mb-4"})]}),e.jsxs("div",{className:"mb-2 flex items-baseline gap-3",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground/70",children:"Project Sync"}),e.jsx("span",{className:"text-[11px] text-muted-foreground/40",children:"Sync templates and config to your installed version"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 pl-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[q?e.jsx(we,{className:"h-2 w-2 text-green-400 shrink-0"}):e.jsx(ze,{className:"h-2 w-2 text-amber-400 shrink-0"}),e.jsx("span",{className:"text-sm text-foreground truncate w-[80px] sm:w-[140px] shrink-0",children:"All Projects"}),A&&e.jsxs(xe,{variant:"outline",className:"text-[10px] px-1.5 py-0 shrink-0 border-green-500/30 text-green-400 bg-green-500/10",children:["v",A.version]}),e.jsxs("span",{className:"hidden md:flex items-center text-xs shrink-0 tabular-nums",children:[e.jsxs("span",{className:v("w-[80px] text-center",t.totalMissing>0?"text-red-400":"text-red-400/25"),children:[t.totalMissing," missing"]}),e.jsxs("span",{className:v("w-[80px] text-center",t.totalOutdated>0?"text-amber-400":"text-amber-400/25"),children:[t.totalOutdated," outdated"]}),e.jsxs("span",{className:v("w-[80px] text-center",t.totalModified>0?"text-orange-400":"text-orange-400/25"),children:[t.totalModified," modified"]}),e.jsxs("span",{className:v("w-[80px] text-center",t.totalPinned>0?"text-blue-400":"text-blue-400/25"),children:[t.totalPinned," pinned"]}),e.jsxs("span",{className:v("w-[80px] text-center",t.totalSynced>0?"text-green-400/50":"text-green-400/20"),children:[t.totalSynced," synced"]}),e.jsxs("span",{className:v("w-[80px] text-center",t.totalUserOwned>0?"text-muted-foreground/40":"text-muted-foreground/20"),children:[t.totalUserOwned," user"]})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:q?e.jsxs(D,{size:"sm",variant:"outline",disabled:!0,className:"h-6 px-2 text-xs w-auto sm:w-[130px] justify-center border-green-500/30 text-green-400/60",children:[e.jsx(V,{className:"h-3 w-3 mr-1"}),"Up to Date"]}):e.jsxs(D,{size:"sm",variant:"outline",onClick:()=>L(!0),disabled:s==="update-all",className:"h-6 px-2 text-xs w-auto sm:w-[130px] justify-center border-[rgba(0,188,212,0.3)] text-cyan-400 hover:bg-cyan-500/10",children:[s==="update-all"?e.jsx(E,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(V,{className:"h-3 w-3 mr-1"}),X>0?`Update ${X}/${t.projects.length}`:"Update All"]})})]}),e.jsx(w,{className:"mb-2"}),e.jsx("div",{className:"space-y-0.5 pl-3",children:t.projects.map(k=>e.jsx(st,{project:k,expanded:o===k.projectId,files:o===k.projectId?a:[],actionLoading:s,onToggle:()=>b(k.projectId),onUpdate:()=>l(k.projectId),onInit:()=>M(k.projectId),onPin:S=>y(k.projectId,S),onUnpin:S=>O(k.projectId,S),onReset:S=>G(k.projectId,S),onRevert:S=>W(k.projectId,S),onDiff:(S,le)=>Z(k.projectId,S,le)},k.projectId))}),e.jsx(at,{updatePreview:n,projectName:(Q=t.projects.find(k=>k.projectId===r))==null?void 0:Q.projectName,updatePreviewProjectId:r,actionLoading:s,onApply:f,onClose:N}),e.jsx(nt,{open:re,onOpenChange:L,summary:t,actionLoading:s,onUpdateAll:x}),e.jsx(it,{diffFile:u,diffContent:m,diffFileStatus:c,diffProjectId:p,actionLoading:s,onResetFile:G,onClearDiff:ee})]})}function ct(){return e.jsxs("section",{className:"card-glass settings-panel rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary mb-5",children:"Configuration"}),e.jsx(ot,{})]})}function dt(){const{projects:t}=Te(),[i,s]=d.useState(null),[o,a]=d.useState(null),[n,r]=d.useState(null);async function m(c,p){s(c),a(null);try{const b=await fetch(`/api/orbital/projects/${c}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!b.ok){const x=await b.json().catch(()=>({}));a(x.error??`Failed to update project (HTTP ${b.status})`)}}catch{a("Failed to update project")}finally{s(null)}}async function u(c){s(c),a(null);try{const p=await fetch(`/api/orbital/projects/${c}`,{method:"DELETE"});if(!p.ok){const b=await p.json().catch(()=>({}));a(b.error??`Failed to remove project (HTTP ${p.status})`)}}catch{a("Failed to remove project")}finally{s(null),r(null)}}return e.jsxs("section",{className:"card-glass settings-panel rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary mb-5",children:"Projects"}),e.jsxs("div",{className:"space-y-2",children:[t.map(c=>e.jsx(xt,{project:c,updating:i===c.id,confirmDelete:n===c.id,onUpdate:p=>m(c.id,p),onDeleteRequest:()=>r(c.id),onDeleteConfirm:()=>u(c.id),onDeleteCancel:()=>r(null)},c.id)),o&&e.jsx("p",{className:"text-[11px] text-destructive",children:o})]})]})}function xt({project:t,updating:i,confirmDelete:s,onUpdate:o,onDeleteRequest:a,onDeleteConfirm:n,onDeleteCancel:r}){const[m,u]=d.useState(!1),[c,p]=d.useState(t.name),b=d.useRef(null);d.useEffect(()=>{var N;m&&((N=b.current)==null||N.focus())},[m]),d.useEffect(()=>{m||p(t.name)},[t.name,m]);const x=c.trim()!==""&&c.trim()!==t.name,l=d.useCallback(()=>{u(!1);const N=c.trim();N&&N!==t.name?o({name:N}):p(t.name)},[c,t.name,o]),f=t.status==="active"?"bg-green-400":t.status==="error"?"bg-red-400":"bg-muted-foreground/40";return e.jsxs("div",{className:v("flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 rounded border border-white/[0.08] px-3 py-2","transition-colors hover:border-[rgba(var(--neon-cyan),0.2)]",!t.enabled&&"opacity-50"),children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx(Ve,{value:t.color,onChange:N=>o({color:N}),disabled:i}),e.jsxs("div",{className:"flex-1 min-w-0",children:[m?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{ref:b,value:c,onChange:N=>p(N.target.value),onBlur:()=>{p(t.name),u(!1)},onKeyDown:N=>{N.key==="Enter"&&l(),N.key==="Escape"&&(p(t.name),u(!1))},className:"flex-1 min-w-0 bg-transparent text-xs font-medium outline-none border-b border-primary/50 pb-0.5"}),x&&e.jsx("button",{onMouseDown:N=>{N.preventDefault(),l()},className:"shrink-0 text-primary hover:text-primary/80 transition-colors",title:"Save name",children:e.jsx(He,{className:"h-3.5 w-3.5"})})]}):e.jsx("div",{className:"text-xs font-medium truncate cursor-text hover:text-primary transition-colors",onClick:()=>u(!0),title:"Click to rename",children:t.name}),e.jsx("div",{className:"text-[10px] text-muted-foreground/60 font-mono truncate",children:t.path})]}),e.jsx("span",{className:v("h-1.5 w-1.5 rounded-full shrink-0",f),title:t.status})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0 self-end sm:self-auto",children:s?e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[e.jsx("span",{className:"text-destructive",children:"Remove?"}),e.jsx("button",{onClick:n,disabled:i,className:"text-destructive hover:text-destructive/80 font-medium transition-colors disabled:opacity-50",children:"Yes"}),e.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors",children:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>o({enabled:!t.enabled}),disabled:i,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:t.enabled?"Disable project":"Enable project",children:t.enabled?e.jsx(Je,{className:"h-3.5 w-3.5"}):e.jsx(Ge,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:a,disabled:i,className:"shrink-0 text-muted-foreground/50 hover:text-destructive transition-colors disabled:opacity-50",title:"Remove project",children:e.jsx(We,{className:"h-3.5 w-3.5"})})]})})]})}function U({checked:t,onCheckedChange:i,disabled:s}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:s,onClick:()=>i(!t),className:v("relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border transition-colors duration-200",t?"border-[rgba(0,188,212,0.4)] bg-[rgba(0,188,212,0.25)]":"border-[rgba(255,255,255,0.1)] bg-[rgba(255,255,255,0.05)]",s&&"cursor-not-allowed opacity-40"),children:e.jsx("span",{className:v("pointer-events-none block h-3.5 w-3.5 rounded-full transition-all duration-200",t?"translate-x-[18px] bg-[rgb(0,188,212)] shadow-[0_0_8px_rgba(0,188,212,0.5)]":"translate-x-[2px] bg-[rgba(255,255,255,0.4)]")})})}const ie={permissionMode:"bypass",verbose:!0,allowedTools:[],disallowedTools:[],appendSystemPrompt:"",outputFormat:"",noMarkdown:!1,printMode:!1},mt={staleTimeoutMinutes:10,maxBatchSize:20,maxConcurrent:0,envVars:{}},oe="/api/orbital/aggregate/config/dispatch-flags";function ut(){const[t,i]=d.useState(ie),[s,o]=d.useState(!0),[a,n]=d.useState(!1),[r,m]=d.useState(null),u=d.useRef(t);u.current=t;const c=d.useCallback(async()=>{try{const x=await fetch(oe);if(!x.ok)throw new Error(`HTTP ${x.status}`);const{data:l}=await x.json();i(l),m(null)}catch(x){console.warn("[Orbital] Dispatch flags fetch failed:",x),m("Failed to load dispatch settings")}finally{o(!1)}},[]),p=d.useCallback(async x=>{const l={...u.current,...x};i(l),n(!0),m(null);try{const f=await fetch(oe,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!f.ok){const M=await f.json().catch(()=>({}));throw new Error(M.error??`HTTP ${f.status}`)}const{data:N}=await f.json();i(N)}catch(f){console.warn("[Orbital] Dispatch flags update failed:",f),m(f instanceof Error?f.message:"Failed to save"),c()}finally{n(!1)}},[c]),b=d.useCallback(async()=>{i(ie),n(!0),m(null);try{const x=await fetch(oe,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)});if(!x.ok)throw new Error(`HTTP ${x.status}`);const{data:l}=await x.json();i(l)}catch(x){console.warn("[Orbital] Dispatch flags reset failed:",x),m("Failed to reset"),c()}finally{n(!1)}},[c]);return d.useEffect(()=>{c()},[c]),he(c),{flags:t,loading:s,saving:a,error:r,updateFlags:p,resetToDefaults:b}}const R="flex h-7 w-7 items-center justify-center rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground disabled:opacity-30 disabled:cursor-not-allowed",Fe="flex items-center gap-1.5 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground disabled:opacity-40",me="h-8 w-full rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-2.5 text-sm text-foreground outline-none transition-colors hover:border-[rgba(0,188,212,0.3)] focus:border-[rgba(0,188,212,0.5)] focus:shadow-[0_0_8px_rgba(0,188,212,0.15)] placeholder:text-muted-foreground/40";function ue({value:t,onChange:i,options:s,disabled:o,label:a}){return e.jsx("div",{role:"group","aria-label":a,className:"card-glass inline-flex flex-wrap rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.02)] p-0.5",children:s.map(n=>e.jsx("button",{onClick:()=>i(n.value),disabled:o,"aria-pressed":t===n.value,className:`px-2.5 py-1 text-xs rounded-[3px] transition-all duration-150 ${t===n.value?"bg-[rgba(0,188,212,0.2)] text-[rgb(0,188,212)] shadow-[0_0_8px_rgba(0,188,212,0.15)]":"text-muted-foreground hover:text-foreground"} ${o?"opacity-40 cursor-not-allowed":"cursor-pointer"}`,children:n.label},n.value))})}function T({label:t,description:i,children:s}){return e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm text-foreground",children:t}),e.jsx("div",{className:"text-xs text-muted-foreground/60",children:i})]}),e.jsx("div",{className:"flex-shrink-0",children:s})]})}function Ce({label:t,description:i,value:s,onChange:o,disabled:a}){const[n,r]=d.useState(""),m=()=>{const u=n.trim();u&&!s.includes(u)&&(o([...s,u]),r(""))};return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-sm text-foreground",children:t}),e.jsx("div",{className:"text-xs text-muted-foreground/60",children:i})]}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{type:"text",value:n,onChange:u=>r(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),m())},disabled:a,placeholder:"Tool name (e.g. Read, Bash)","aria-label":`Add ${t.toLowerCase()}`,className:me}),e.jsx("button",{onClick:m,disabled:a||!n.trim(),"aria-label":`Add tool to ${t.toLowerCase()}`,className:R+" !w-8 !h-8",children:e.jsx(z,{className:"h-3.5 w-3.5"})})]}),s.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(u=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-2 py-0.5 text-xs text-muted-foreground",children:[u,e.jsx("button",{onClick:()=>o(s.filter(c=>c!==u)),disabled:a,"aria-label":`Remove ${u}`,className:"text-muted-foreground/60 hover:text-foreground transition-colors",children:e.jsx(Ee,{className:"h-3 w-3"})})]},u))})]})}function ht({value:t,onChange:i,disabled:s}){const[o,a]=d.useState(""),[n,r]=d.useState(""),m=Object.entries(t),u=()=>{const c=o.trim();c&&(i({...t,[c]:n}),a(""),r(""))};return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-sm text-foreground",children:"Environment Variables"}),e.jsx("div",{className:"text-xs text-muted-foreground/60",children:"Custom env vars passed to every dispatched session"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 mb-2",children:[e.jsx("input",{type:"text",value:o,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),u())},disabled:s,placeholder:"KEY","aria-label":"Environment variable name",className:me+" sm:w-1/3"}),e.jsxs("div",{className:"flex gap-2 flex-1",children:[e.jsx("input",{type:"text",value:n,onChange:c=>r(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),u())},disabled:s,placeholder:"value","aria-label":"Environment variable value",className:me+" flex-1"}),e.jsx("button",{onClick:u,disabled:s||!o.trim(),"aria-label":"Add environment variable",className:R+" !w-8 !h-8",children:e.jsx(z,{className:"h-3.5 w-3.5"})})]})]}),m.length>0&&e.jsx("div",{className:"flex flex-col gap-1.5",children:m.map(([c,p])=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-2.5 py-1",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:c}),e.jsx("span",{className:"text-xs text-muted-foreground/60",children:"="}),e.jsx("span",{className:"text-xs text-muted-foreground flex-1 truncate",children:p}),e.jsx("button",{onClick:()=>{const b={...t};delete b[c],i(b)},disabled:s,"aria-label":`Remove ${c}`,className:"text-muted-foreground/60 hover:text-foreground transition-colors",children:e.jsx(Ee,{className:"h-3 w-3"})})]},c))})]})}function pt(){const{flags:t,loading:i,saving:s,error:o,updateFlags:a,resetToDefaults:n}=ut();return e.jsxs("section",{className:`card-glass settings-panel rounded-xl p-5 ${i?"opacity-60":""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary",children:"Dispatch"}),o&&e.jsx("span",{className:"text-[11px] text-destructive",children:o})]}),e.jsxs("button",{onClick:n,disabled:s||i,className:Fe,children:[e.jsx(J,{className:"h-3 w-3"}),"Reset to defaults"]})]}),e.jsx(T,{label:"Permission Mode",description:"How permission prompts are handled in dispatched sessions",children:e.jsx(ue,{label:"Permission Mode",value:t.permissionMode,onChange:r=>a({permissionMode:r}),options:[{value:"bypass",label:"Bypass"},{value:"default",label:"Default"},{value:"plan",label:"Plan"},{value:"acceptEdits",label:"Accept Edits"}],disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Verbose Logging",description:"Enable verbose CLI output in dispatched sessions",children:e.jsx(U,{checked:t.verbose,onCheckedChange:r=>a({verbose:r}),disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"No Markdown",description:"Disable markdown rendering in terminal output",children:e.jsx(U,{checked:t.noMarkdown,onCheckedChange:r=>a({noMarkdown:r}),disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Print Mode",description:"Force non-interactive mode for single dispatches",children:e.jsx(U,{checked:t.printMode,onCheckedChange:r=>a({printMode:r}),disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Output Format",description:"Output format for non-interactive mode",children:e.jsx(ue,{label:"Output Format",value:t.outputFormat,onChange:r=>a({outputFormat:r}),options:[{value:"",label:"Default"},{value:"text",label:"Text"},{value:"json",label:"JSON"},{value:"stream-json",label:"Stream"}],disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(Ce,{label:"Allowed Tools",description:"Whitelist specific tools (leave empty for all)",value:t.allowedTools,onChange:r=>a({allowedTools:r}),disabled:s}),e.jsx(w,{className:"my-4"}),e.jsx(Ce,{label:"Disallowed Tools",description:"Block specific tools from being used",value:t.disallowedTools,onChange:r=>a({disallowedTools:r}),disabled:s}),e.jsx(w,{className:"my-4"}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-sm text-foreground",children:"System Prompt"}),e.jsx("div",{className:"text-xs text-muted-foreground/60",children:"Custom instructions appended to every dispatched session"})]}),e.jsx("textarea",{value:t.appendSystemPrompt,onChange:r=>a({appendSystemPrompt:r.target.value}),disabled:s,rows:3,placeholder:"Enter additional instructions...",className:"w-full rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-2.5 py-2 text-sm text-foreground outline-none transition-colors hover:border-[rgba(0,188,212,0.3)] focus:border-[rgba(0,188,212,0.5)] focus:shadow-[0_0_8px_rgba(0,188,212,0.15)] placeholder:text-muted-foreground/40 resize-y"})]})]})}const ce={...mt,terminalAdapter:"auto"},de="/api/orbital/aggregate/config/dispatch-settings";function ft(){const[t,i]=d.useState(ce),[s,o]=d.useState(!0),[a,n]=d.useState(!1),[r,m]=d.useState(null),u=d.useRef(t);u.current=t;const c=d.useCallback(async()=>{try{const x=await fetch(de);if(!x.ok)throw new Error(`HTTP ${x.status}`);const{data:l}=await x.json();i(l),m(null)}catch(x){console.warn("[Orbital] Dispatch settings fetch failed:",x),m("Failed to load dispatch operations")}finally{o(!1)}},[]),p=d.useCallback(async x=>{const l={...u.current,...x};i(l),n(!0),m(null);try{const f=await fetch(de,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!f.ok){const M=await f.json().catch(()=>({}));throw new Error(M.error??`HTTP ${f.status}`)}const{data:N}=await f.json();i(N)}catch(f){console.warn("[Orbital] Dispatch settings update failed:",f),m(f instanceof Error?f.message:"Failed to save"),c()}finally{n(!1)}},[c]),b=d.useCallback(async()=>{i(ce),n(!0),m(null);try{const x=await fetch(de,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(ce)});if(!x.ok)throw new Error(`HTTP ${x.status}`);const{data:l}=await x.json();i(l)}catch(x){console.warn("[Orbital] Dispatch settings reset failed:",x),m("Failed to reset"),c()}finally{n(!1)}},[c]);return d.useEffect(()=>{c()},[c]),he(c),{settings:t,loading:s,saving:a,error:r,updateSettings:p,resetToDefaults:b}}function gt(){const{settings:t,loading:i,saving:s,error:o,updateSettings:a,resetToDefaults:n}=ft();return e.jsxs("section",{className:`card-glass settings-panel rounded-xl p-5 ${i?"opacity-60":""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary",children:"Dispatch: Operations"}),o&&e.jsx("span",{className:"text-[11px] text-destructive",children:o})]}),e.jsxs("button",{onClick:n,disabled:s||i,className:Fe,children:[e.jsx(J,{className:"h-3 w-3"}),"Reset to defaults"]})]}),e.jsx(T,{label:"Terminal Adapter",description:"How dispatch windows are opened",children:e.jsx(ue,{label:"Terminal Adapter",value:t.terminalAdapter,onChange:r=>a({terminalAdapter:r}),options:[{value:"auto",label:"Auto"},{value:"iterm2",label:"iTerm2"},{value:"subprocess",label:"Subprocess"},{value:"none",label:"None"}],disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Stale Timeout",description:"Minutes before unlinked dispatch is marked abandoned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>a({staleTimeoutMinutes:Math.max(1,t.staleTimeoutMinutes-1)}),disabled:s||t.staleTimeoutMinutes<=1,className:R,children:e.jsx(H,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"w-12 text-center text-sm tabular-nums",children:[t.staleTimeoutMinutes,"m"]}),e.jsx("button",{onClick:()=>a({staleTimeoutMinutes:t.staleTimeoutMinutes+1}),disabled:s,className:R,children:e.jsx(z,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Max Batch Size",description:"Maximum scopes per batch dispatch",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>a({maxBatchSize:Math.max(1,t.maxBatchSize-1)}),disabled:s||t.maxBatchSize<=1,className:R,children:e.jsx(H,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"w-12 text-center text-sm tabular-nums",children:t.maxBatchSize}),e.jsx("button",{onClick:()=>a({maxBatchSize:t.maxBatchSize+1}),disabled:s,className:R,children:e.jsx(z,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Max Concurrent",description:"Limit simultaneous dispatches, 0 = unlimited",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>a({maxConcurrent:Math.max(0,t.maxConcurrent-1)}),disabled:s||t.maxConcurrent<=0,className:R,children:e.jsx(H,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"w-12 text-center text-sm tabular-nums",children:t.maxConcurrent===0?"∞":t.maxConcurrent}),e.jsx("button",{onClick:()=>a({maxConcurrent:t.maxConcurrent+1}),disabled:s,className:R,children:e.jsx(z,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx(ht,{value:t.envVars,onChange:r=>a({envVars:r}),disabled:s})]})}const jt={monospace:"Monospace","sans-serif":"Sans-Serif",display:"Display"},bt=["monospace","sans-serif","display"];function Nt(){var a;const{settings:t,updateSetting:i}=Me(),s=()=>{const n=Math.max(.8,Math.round((t.fontScale-.05)*100)/100);i("fontScale",n)},o=()=>{const n=Math.min(1.3,Math.round((t.fontScale+.05)*100)/100);i("fontScale",n)};return e.jsxs("section",{className:"card-glass settings-panel rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary mb-5",children:"Appearance"}),e.jsx(T,{label:"Font Family",description:"Typeface used across the dashboard",children:e.jsx("select",{value:t.fontFamily,onChange:n=>i("fontFamily",n.target.value),style:{fontFamily:`'${t.fontFamily}', ${((a=ke.find(n=>n.family===t.fontFamily))==null?void 0:a.category)==="monospace"?"monospace":"sans-serif"}`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center"},className:"h-8 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-2.5 pr-7 text-sm text-foreground outline-none transition-colors hover:border-[rgba(0,188,212,0.3)] focus:border-[rgba(0,188,212,0.5)] focus:shadow-[0_0_8px_rgba(0,188,212,0.15)] appearance-none cursor-pointer",children:bt.map(n=>e.jsx("optgroup",{label:jt[n],children:ke.filter(r=>r.category===n).map(r=>e.jsxs("option",{value:r.family,children:[r.label,r.family==="Space Grotesk"?" (default)":""]},r.family))},n))})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Font Size",description:"Scale text across the dashboard",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:s,disabled:t.fontScale<=.8,className:"flex h-7 w-7 items-center justify-center rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(H,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"w-12 text-center text-sm tabular-nums",children:[Math.round(t.fontScale*100),"%"]}),e.jsx("button",{onClick:o,disabled:t.fontScale>=1.3,className:"flex h-7 w-7 items-center justify-center rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(z,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Reduce Motion",description:"Disable animations and transitions",children:e.jsx(U,{checked:t.reduceMotion,onCheckedChange:n=>i("reduceMotion",n)})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Background Effects",description:"Animated orbs and grid overlay",children:e.jsx(U,{checked:t.showBackgroundEffects,onCheckedChange:n=>i("showBackgroundEffects",n)})})]})}function vt(){const{settings:t,updateSetting:i}=Me();return e.jsxs("section",{className:"card-glass settings-panel rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary mb-5",children:"Display"}),e.jsx(T,{label:"Status Bar",description:"Scope progress bar at bottom",children:e.jsx(U,{checked:t.showStatusBar,onCheckedChange:s=>i("showStatusBar",s)})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Compact Mode",description:"Reduce spacing for denser layout",children:e.jsx(U,{checked:t.compactMode,onCheckedChange:s=>i("compactMode",s)})})]})}function Tt(){const{restart:t}=Ke();return d.useEffect(()=>{Ye()},[]),e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col -mt-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(Le,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Settings"})]}),e.jsx(qe,{className:"flex-1",children:e.jsxs("div",{className:"columns-1 lg:columns-2 gap-4 sm:gap-6 pr-1 sm:pr-4 pb-8 [&>*]:mb-4 sm:[&>*]:mb-6 [&>*]:break-inside-avoid",children:[e.jsx("div",{className:"lg:[column-span:all]",children:e.jsx(ct,{})}),e.jsx("div",{className:"lg:[column-span:all]",children:e.jsx(dt,{})}),e.jsx(pt,{}),e.jsx(gt,{}),e.jsx(Nt,{}),e.jsx(vt,{}),e.jsxs("section",{className:"card-glass settings-panel rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary mb-5",children:"Onboarding"}),e.jsx(T,{label:"Guided Tour",description:"Interactive walkthrough of all pages",children:e.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground",children:[e.jsx(J,{className:"h-3 w-3"}),"Restart tour"]})})]})]})})]})}export{Tt as Settings};
|