orbital-command 0.3.0 → 1.0.0

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.
Files changed (160) hide show
  1. package/README.md +67 -42
  2. package/bin/commands/config.js +19 -0
  3. package/bin/commands/events.js +40 -0
  4. package/bin/commands/launch.js +126 -0
  5. package/bin/commands/manifest.js +283 -0
  6. package/bin/commands/registry.js +104 -0
  7. package/bin/commands/update.js +24 -0
  8. package/bin/lib/helpers.js +229 -0
  9. package/bin/orbital.js +95 -870
  10. package/dist/assets/Landing-CfQdHR0N.js +11 -0
  11. package/dist/assets/PrimitivesConfig-DThSipFy.js +32 -0
  12. package/dist/assets/QualityGates-B4kxM5UU.js +26 -0
  13. package/dist/assets/SessionTimeline-Bz1iZnmg.js +1 -0
  14. package/dist/assets/Settings-DLcZwbCT.js +12 -0
  15. package/dist/assets/SourceControl-BMNIz7Lt.js +36 -0
  16. package/dist/assets/WorkflowVisualizer-CxuSBOYu.js +69 -0
  17. package/dist/assets/{arrow-down-CPy85_J6.js → arrow-down-DVPp6_qp.js} +1 -1
  18. package/dist/assets/bot-NFaJBDn_.js +6 -0
  19. package/dist/assets/{charts-DbDg0Psc.js → charts-LGLb8hyU.js} +1 -1
  20. package/dist/assets/{circle-x-Cwz6ZQDV.js → circle-x-IsFCkBZu.js} +1 -1
  21. package/dist/assets/{file-text-C46Xr65c.js → file-text-J1cebZXF.js} +1 -1
  22. package/dist/assets/{globe-Cn2yNZUD.js → globe-WzeyHsUc.js} +1 -1
  23. package/dist/assets/index-BdJ57EhC.css +1 -0
  24. package/dist/assets/index-o4ScMAuR.js +349 -0
  25. package/dist/assets/{key-OPaNTWJ5.js → key-CKR8JJSj.js} +1 -1
  26. package/dist/assets/{minus-GMsbpKym.js → minus-CHBsJyjp.js} +1 -1
  27. package/dist/assets/radio-xqZaR-Uk.js +6 -0
  28. package/dist/assets/rocket-D_xvvNG6.js +6 -0
  29. package/dist/assets/{shield-DwAFkDYI.js → shield-TdB1yv_a.js} +1 -1
  30. package/dist/assets/useSocketListener-0L5yiN5i.js +1 -0
  31. package/dist/assets/useWorkflowEditor-CqeRWVQX.js +11 -0
  32. package/dist/assets/workflow-constants-Rw-GmgHZ.js +6 -0
  33. package/dist/assets/zap-C9wqYMpl.js +6 -0
  34. package/dist/index.html +3 -3
  35. package/dist/server/server/__tests__/data-routes.test.js +2 -0
  36. package/dist/server/server/__tests__/scope-routes.test.js +1 -0
  37. package/dist/server/server/config-migrator.js +0 -3
  38. package/dist/server/server/config.js +35 -6
  39. package/dist/server/server/database.js +0 -22
  40. package/dist/server/server/index.js +26 -814
  41. package/dist/server/server/init.js +32 -399
  42. package/dist/server/server/launch.js +1 -1
  43. package/dist/server/server/parsers/event-parser.js +4 -1
  44. package/dist/server/server/project-context.js +19 -9
  45. package/dist/server/server/project-manager.js +6 -6
  46. package/dist/server/server/routes/aggregate-routes.js +871 -0
  47. package/dist/server/server/routes/config-routes.js +41 -88
  48. package/dist/server/server/routes/data-routes.js +5 -15
  49. package/dist/server/server/routes/dispatch-routes.js +24 -8
  50. package/dist/server/server/routes/manifest-routes.js +1 -1
  51. package/dist/server/server/routes/scope-routes.js +10 -7
  52. package/dist/server/server/schema.js +1 -0
  53. package/dist/server/server/services/batch-orchestrator.js +17 -3
  54. package/dist/server/server/services/config-service.js +10 -1
  55. package/dist/server/server/services/scope-service.js +7 -7
  56. package/dist/server/server/services/sprint-orchestrator.js +24 -11
  57. package/dist/server/server/services/sprint-service.js +2 -2
  58. package/dist/server/server/uninstall.js +195 -0
  59. package/dist/server/server/update.js +212 -0
  60. package/dist/server/server/utils/dispatch-utils.js +8 -6
  61. package/dist/server/server/utils/flag-builder.js +54 -0
  62. package/dist/server/server/utils/json-fields.js +14 -0
  63. package/dist/server/server/utils/json-fields.test.js +73 -0
  64. package/dist/server/server/utils/route-helpers.js +37 -0
  65. package/dist/server/server/utils/route-helpers.test.js +115 -0
  66. package/dist/server/server/watchers/event-watcher.js +28 -13
  67. package/dist/server/server/wizard/config-editor.js +4 -4
  68. package/dist/server/server/wizard/doctor.js +2 -2
  69. package/dist/server/server/wizard/index.js +224 -39
  70. package/dist/server/server/wizard/phases/welcome.js +1 -4
  71. package/dist/server/server/wizard/ui.js +6 -7
  72. package/dist/server/shared/api-types.js +80 -1
  73. package/dist/server/shared/workflow-engine.js +1 -1
  74. package/package.json +20 -20
  75. package/schemas/orbital.config.schema.json +1 -19
  76. package/scripts/postinstall.js +6 -42
  77. package/scripts/release.sh +53 -0
  78. package/server/__tests__/data-routes.test.ts +2 -0
  79. package/server/__tests__/scope-routes.test.ts +1 -0
  80. package/server/config-migrator.ts +0 -3
  81. package/server/config.ts +39 -11
  82. package/server/database.ts +0 -26
  83. package/server/global-config.ts +4 -0
  84. package/server/index.ts +29 -894
  85. package/server/init.ts +32 -443
  86. package/server/launch.ts +1 -1
  87. package/server/parsers/event-parser.ts +4 -1
  88. package/server/project-context.ts +26 -10
  89. package/server/project-manager.ts +5 -6
  90. package/server/routes/aggregate-routes.ts +968 -0
  91. package/server/routes/config-routes.ts +41 -81
  92. package/server/routes/data-routes.ts +7 -16
  93. package/server/routes/dispatch-routes.ts +29 -8
  94. package/server/routes/manifest-routes.ts +1 -1
  95. package/server/routes/scope-routes.ts +12 -7
  96. package/server/schema.ts +1 -0
  97. package/server/services/batch-orchestrator.ts +18 -2
  98. package/server/services/config-service.ts +10 -1
  99. package/server/services/scope-service.ts +6 -6
  100. package/server/services/sprint-orchestrator.ts +24 -9
  101. package/server/services/sprint-service.ts +2 -2
  102. package/server/uninstall.ts +214 -0
  103. package/server/update.ts +263 -0
  104. package/server/utils/dispatch-utils.ts +8 -6
  105. package/server/utils/flag-builder.ts +56 -0
  106. package/server/utils/json-fields.test.ts +83 -0
  107. package/server/utils/json-fields.ts +14 -0
  108. package/server/utils/route-helpers.test.ts +144 -0
  109. package/server/utils/route-helpers.ts +38 -0
  110. package/server/watchers/event-watcher.ts +24 -12
  111. package/server/wizard/config-editor.ts +4 -4
  112. package/server/wizard/doctor.ts +2 -2
  113. package/server/wizard/index.ts +291 -40
  114. package/server/wizard/phases/welcome.ts +1 -5
  115. package/server/wizard/ui.ts +6 -7
  116. package/shared/api-types.ts +106 -0
  117. package/shared/workflow-engine.ts +1 -1
  118. package/templates/agents/QUICK-REFERENCE.md +1 -0
  119. package/templates/agents/README.md +1 -0
  120. package/templates/agents/SKILL-TRIGGERS.md +11 -0
  121. package/templates/agents/green-team/deep-dive.md +361 -0
  122. package/templates/hooks/end-session.sh +1 -0
  123. package/templates/hooks/init-session.sh +1 -0
  124. package/templates/hooks/scope-commit-logger.sh +2 -2
  125. package/templates/hooks/scope-create-gate.sh +2 -4
  126. package/templates/hooks/scope-gate.sh +4 -6
  127. package/templates/hooks/scope-helpers.sh +10 -1
  128. package/templates/hooks/scope-lifecycle-gate.sh +14 -5
  129. package/templates/hooks/scope-prepare.sh +1 -1
  130. package/templates/hooks/scope-transition.sh +14 -6
  131. package/templates/hooks/time-tracker.sh +2 -5
  132. package/templates/orbital.config.json +1 -4
  133. package/templates/presets/development.json +4 -4
  134. package/templates/presets/gitflow.json +7 -0
  135. package/templates/prompts/README.md +23 -0
  136. package/templates/prompts/deep-dive-audit.md +94 -0
  137. package/templates/quick/rules.md +56 -5
  138. package/templates/skills/git-commit/SKILL.md +21 -6
  139. package/templates/skills/git-dev/SKILL.md +8 -4
  140. package/templates/skills/git-main/SKILL.md +8 -4
  141. package/templates/skills/git-production/SKILL.md +6 -3
  142. package/templates/skills/git-staging/SKILL.md +6 -3
  143. package/templates/skills/scope-fix-review/SKILL.md +8 -4
  144. package/templates/skills/scope-implement/SKILL.md +13 -5
  145. package/templates/skills/scope-post-review/SKILL.md +16 -4
  146. package/templates/skills/scope-pre-review/SKILL.md +6 -2
  147. package/dist/assets/PrimitivesConfig-CrmQXYh4.js +0 -32
  148. package/dist/assets/QualityGates-BbasOsF3.js +0 -21
  149. package/dist/assets/SessionTimeline-CGeJsVvy.js +0 -1
  150. package/dist/assets/Settings-oiM496mc.js +0 -12
  151. package/dist/assets/SourceControl-B1fP2nJL.js +0 -41
  152. package/dist/assets/WorkflowVisualizer-CWLYf-f0.js +0 -74
  153. package/dist/assets/formatDistanceToNow-BMqsSP44.js +0 -1
  154. package/dist/assets/index-Aj4sV8Al.css +0 -1
  155. package/dist/assets/index-Bc9dK3MW.js +0 -354
  156. package/dist/assets/useWorkflowEditor-BJkTX_NR.js +0 -16
  157. package/dist/assets/zap-DfbUoOty.js +0 -11
  158. package/dist/server/server/services/telemetry-service.js +0 -143
  159. package/server/services/telemetry-service.ts +0 -195
  160. /package/{shared/default-workflow.json → templates/presets/default.json} +0 -0
@@ -0,0 +1,11 @@
1
+ import{j as e}from"./ui-BmsSg9jU.js";import{a as c}from"./vendor-Bqt8AJn2.js";import{c as ee,aX as j,aY as O,aZ as te,a_ as Ne,a$ as we,b0 as ne,b1 as ke,b2 as Se,b3 as se,b4 as Ee,b5 as ze,b6 as W,b7 as V,b8 as Le,b9 as N,ba as ie,bb as G,bc as Ce,bd as I,be as u,G as T,bf as Ie,f as ae,J as re,C as Y,bg as le,S as oe,aV as ce,U as Ae,L as de,E as Me}from"./index-o4ScMAuR.js";import{Z as ue}from"./zap-C9wqYMpl.js";import{B as me}from"./bot-NFaJBDn_.js";import{R as H}from"./rocket-D_xvvNG6.js";import{R as he}from"./radio-xqZaR-Uk.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 Re=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],fe=ee("command",Re);/**
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 Te=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],ge=ee("cpu",Te);function xe(t,n){let a;const s=()=>{const{currentTime:i}=n,l=(i===null?0:i.value)/100;a!==l&&t(l),a=l};return j.update(s,!0),()=>O(s)}const z=new WeakMap;let p;function Fe(t,n){if(n){const{inlineSize:a,blockSize:s}=n[0];return{width:a,height:s}}else return t instanceof SVGElement&&"getBBox"in t?t.getBBox():{width:t.offsetWidth,height:t.offsetHeight}}function Oe({target:t,contentRect:n,borderBoxSize:a}){var s;(s=z.get(t))===null||s===void 0||s.forEach(i=>{i({target:t,contentSize:n,get size(){return Fe(t,a)}})})}function We(t){t.forEach(Oe)}function Ve(){typeof ResizeObserver>"u"||(p=new ResizeObserver(We))}function He(t,n){p||Ve();const a=te(t);return a.forEach(s=>{let i=z.get(s);i||(i=new Set,z.set(s,i)),i.add(n),p==null||p.observe(s)}),()=>{a.forEach(s=>{const i=z.get(s);i==null||i.delete(n),i!=null&&i.size||p==null||p.unobserve(s)})}}const L=new Set;let w;function Be(){w=()=>{const t={width:window.innerWidth,height:window.innerHeight},n={target:window,size:t,contentSize:t};L.forEach(a=>a(n))},window.addEventListener("resize",w)}function Pe(t){return L.add(t),w||Be(),()=>{L.delete(t),!L.size&&w&&(w=void 0)}}function De(t,n){return typeof t=="function"?Pe(t):He(t,n)}const _e=50,$=()=>({current:0,offset:[],progress:0,scrollLength:0,targetOffset:0,targetLength:0,containerLength:0,velocity:0}),Ge=()=>({time:0,x:$(),y:$()}),Ye={x:{length:"Width",position:"Left"},y:{length:"Height",position:"Top"}};function q(t,n,a,s){const i=a[n],{length:r,position:l}=Ye[n],o=i.current,m=a.time;i.current=t[`scroll${l}`],i.scrollLength=t[`scroll${r}`]-t[`client${r}`],i.offset.length=0,i.offset[0]=0,i.offset[1]=i.scrollLength,i.progress=Ne(0,i.scrollLength,i.current);const d=s-m;i.velocity=d>_e?0:we(i.current-o,d)}function $e(t,n,a){q(t,"x",n,a),q(t,"y",n,a),n.time=a}function qe(t,n){const a={x:0,y:0};let s=t;for(;s&&s!==n;)if(s instanceof HTMLElement)a.x+=s.offsetLeft,a.y+=s.offsetTop,s=s.offsetParent;else if(s.tagName==="svg"){const i=s.getBoundingClientRect();s=s.parentElement;const r=s.getBoundingClientRect();a.x+=i.left-r.left,a.y+=i.top-r.top}else if(s instanceof SVGGraphicsElement){const{x:i,y:r}=s.getBBox();a.x+=i,a.y+=r;let l=null,o=s.parentNode;for(;!l;)o.tagName==="svg"&&(l=o),o=s.parentNode;s=l}else break;return a}const F={start:0,center:.5,end:1};function X(t,n,a=0){let s=0;if(t in F&&(t=F[t]),typeof t=="string"){const i=parseFloat(t);t.endsWith("px")?s=i:t.endsWith("%")?t=i/100:t.endsWith("vw")?s=i/100*document.documentElement.clientWidth:t.endsWith("vh")?s=i/100*document.documentElement.clientHeight:t=i}return typeof t=="number"&&(s=n*t),a+s}const Xe=[0,0];function Ze(t,n,a,s){let i=Array.isArray(t)?t:Xe,r=0,l=0;return typeof t=="number"?i=[t,t]:typeof t=="string"&&(t=t.trim(),t.includes(" ")?i=t.split(" "):i=[t,F[t]?t:"0"]),r=X(i[0],a,s),l=X(i[1],n),r-l}const Ue={All:[[0,0],[1,1]]},Je={x:0,y:0};function Ke(t){return"getBBox"in t&&t.tagName!=="svg"?t.getBBox():{width:t.clientWidth,height:t.clientHeight}}function Qe(t,n,a){const{offset:s=Ue.All}=a,{target:i=t,axis:r="y"}=a,l=r==="y"?"height":"width",o=i!==t?qe(i,t):Je,m=i===t?{width:t.scrollWidth,height:t.scrollHeight}:Ke(i),d={width:t.clientWidth,height:t.clientHeight};n[r].offset.length=0;let h=!n[r].interpolate;const x=s.length;for(let f=0;f<x;f++){const _=Ze(s[f],d[l],m[l],o[r]);!h&&_!==n[r].interpolatorOffsets[f]&&(h=!0),n[r].offset[f]=_}h&&(n[r].interpolate=ne(n[r].offset,ke(s),{clamp:!1}),n[r].interpolatorOffsets=[...n[r].offset]),n[r].progress=Se(0,1,n[r].interpolate(n[r].current))}function et(t,n=t,a){if(a.x.targetOffset=0,a.y.targetOffset=0,n!==t){let s=n;for(;s&&s!==t;)a.x.targetOffset+=s.offsetLeft,a.y.targetOffset+=s.offsetTop,s=s.offsetParent}a.x.targetLength=n===t?n.scrollWidth:n.clientWidth,a.y.targetLength=n===t?n.scrollHeight:n.clientHeight,a.x.containerLength=t.clientWidth,a.y.containerLength=t.clientHeight}function tt(t,n,a,s={}){return{measure:()=>et(t,s.target,a),update:i=>{$e(t,a,i),(s.offset||s.target)&&Qe(t,a,s)},notify:()=>n(a)}}const v=new WeakMap,Z=new WeakMap,A=new WeakMap,U=t=>t===document.documentElement?window:t;function B(t,{container:n=document.documentElement,...a}={}){let s=A.get(n);s||(s=new Set,A.set(n,s));const i=Ge(),r=tt(n,t,i,a);if(s.add(r),!v.has(n)){const o=()=>{for(const f of s)f.measure()},m=()=>{for(const f of s)f.update(se.timestamp)},d=()=>{for(const f of s)f.notify()},h=()=>{j.read(o,!1,!0),j.read(m,!1,!0),j.update(d,!1,!0)};v.set(n,h);const x=U(n);window.addEventListener("resize",h,{passive:!0}),n!==document.documentElement&&Z.set(n,De(n,h)),x.addEventListener("scroll",h,{passive:!0})}const l=v.get(n);return j.read(l,!1,!0),()=>{var o;O(l);const m=A.get(n);if(!m||(m.delete(r),m.size))return;const d=v.get(n);v.delete(n),d&&(U(n).removeEventListener("scroll",d),(o=Z.get(n))===null||o===void 0||o(),window.removeEventListener("resize",d))}}function nt({source:t,container:n,axis:a="y"}){t&&(n=t);const s={value:0},i=B(r=>{s.value=r[a].progress*100},{container:n,axis:a});return{currentTime:s,cancel:i}}const M=new Map;function pe({source:t,container:n=document.documentElement,axis:a="y"}={}){t&&(n=t),M.has(n)||M.set(n,{});const s=M.get(n);return s[a]||(s[a]=ze()?new ScrollTimeline({source:n,axis:a}):nt({source:n,axis:a})),s[a]}function st(t){return t.length===2}function je(t){return t&&(t.target||t.offset)}function it(t,n){return st(t)||je(n)?B(a=>{t(a[n.axis].progress,a)},n):xe(t,pe(n))}function at(t,n){if(t.flatten(),je(n))return t.pause(),B(a=>{t.time=t.duration*a[n.axis].progress},n);{const a=pe(n);return t.attachTimeline?t.attachTimeline(a,s=>(s.pause(),xe(i=>{s.time=s.duration*i},a))):Ee}}function rt(t,{axis:n="y",...a}={}){const s={axis:n,...a};return typeof t=="function"?it(t,s):at(t,s)}function J(t,n){Le(!!(!n||n.current))}const lt=()=>({scrollX:N(0),scrollY:N(0),scrollXProgress:N(0),scrollYProgress:N(0)});function P({container:t,target:n,layoutEffect:a=!0,...s}={}){const i=W(lt);return(a?V:c.useEffect)(()=>(J("target",n),J("container",t),rt((l,{x:o,y:m})=>{i.scrollX.set(o.current),i.scrollXProgress.set(o.progress),i.scrollY.set(m.current),i.scrollYProgress.set(m.progress)},{...s,container:(t==null?void 0:t.current)||void 0,target:(n==null?void 0:n.current)||void 0})),[t,n,JSON.stringify(s.offset)]),i}function ye(t){const n=W(()=>N(t)),{isStatic:a}=c.useContext(ie);if(a){const[,s]=c.useState(t);c.useEffect(()=>n.on("change",s),[])}return n}function be(t,n){const a=ye(n()),s=()=>a.set(n());return s(),V(()=>{const i=()=>j.preRender(s,!1,!0),r=t.map(l=>l.on("change",i));return()=>{r.forEach(l=>l()),O(s)}}),a}function K(t){return typeof t=="number"?t:parseFloat(t)}function ot(t,n={}){const{isStatic:a}=c.useContext(ie),s=c.useRef(null),i=ye(G(t)?K(t.get()):t),r=c.useRef(i.get()),l=c.useRef(()=>{}),o=()=>{const d=s.current;d&&d.time===0&&d.sample(se.delta),m(),s.current=Ce({keyframes:[i.get(),r.current],velocity:i.getVelocity(),type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:l.current})},m=()=>{s.current&&s.current.stop()};return c.useInsertionEffect(()=>i.attach((d,h)=>a?h(d):(r.current=d,l.current=h,j.update(o),i.get()),m),[JSON.stringify(n)]),V(()=>{if(G(t))return t.on("change",d=>i.set(K(d)))},[i]),i}const ct=t=>t&&typeof t=="object"&&t.mix,dt=t=>ct(t)?t.mix:void 0;function ut(...t){const n=!Array.isArray(t[0]),a=n?0:-1,s=t[0+a],i=t[1+a],r=t[2+a],l=t[3+a],o=ne(i,r,{mixer:dt(r[0]),...l});return n?o(s):o}function mt(t){I.current=[],t();const n=be(I.current,t);return I.current=void 0,n}function C(t,n,a,s){if(typeof t=="function")return mt(t);const i=typeof n=="function"?n:ut(n,a,s);return Array.isArray(t)?Q(t,i):Q([t],([r])=>i(r))}function Q(t,n){const a=W(()=>[]);return be(t,()=>{a.length=0;const s=t.length;for(let i=0;i<s;i++)a[i]=t[i].get();return n(a)})}const ht={some:0,all:1};function ft(t,n,{root:a,margin:s,amount:i="some"}={}){const r=te(t),l=new WeakMap,o=d=>{d.forEach(h=>{const x=l.get(h.target);if(h.isIntersecting!==!!x)if(h.isIntersecting){const f=n(h);typeof f=="function"?l.set(h.target,f):m.unobserve(h.target)}else typeof x=="function"&&(x(h),l.delete(h.target))})},m=new IntersectionObserver(o,{root:a,rootMargin:s,threshold:typeof i=="number"?i:ht[i]});return r.forEach(d=>m.observe(d)),()=>m.disconnect()}function ve(t,{root:n,margin:a,amount:s,once:i=!1}={}){const[r,l]=c.useState(!1);return c.useEffect(()=>{if(!t.current||i&&r)return;const o=()=>(l(!0),i?void 0:()=>l(!1)),m={root:n&&n.current||void 0,margin:a,amount:s};return ft(t.current,o,m)},[n,t,a,i,s]),r}const y=[.25,.46,.45,.94];function D(t,n=1500){const a=ve(t,{once:!0,amount:"some"}),[s,i]=c.useState(!1);return c.useEffect(()=>{const r=setTimeout(()=>i(!0),n);return()=>clearTimeout(r)},[n]),a||s}function g({children:t,delay:n=0,className:a=""}){const s=c.useRef(null),i=D(s);return e.jsx(u.div,{ref:s,initial:{opacity:0,y:48},animate:i?{opacity:1,y:0}:{},transition:{duration:.8,delay:n,ease:y},className:a,children:t})}function gt({children:t,delay:n=0,className:a=""}){const s=c.useRef(null),i=D(s);return e.jsx(u.div,{ref:s,initial:{opacity:0,scale:.85},animate:i?{opacity:1,scale:1}:{},transition:{duration:.7,delay:n,ease:y},className:a,children:t})}function k({children:t,delay:n=0,direction:a="left",className:s=""}){const i=c.useRef(null),r=D(i),l=a==="left"?-80:80;return e.jsx(u.div,{ref:i,initial:{opacity:0,x:l},animate:r?{opacity:1,x:0}:{},transition:{duration:.8,delay:n,ease:y},className:s,children:t})}function xt({text:t,className:n=""}){const a=t.split(" ");return e.jsx("span",{className:n,children:a.map((s,i)=>e.jsxs(c.Fragment,{children:[e.jsx(u.span,{initial:{opacity:0,y:40,filter:"blur(8px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.6,delay:.15+i*.12,ease:y},className:"inline-block",children:s})," "]},i))})}function pt(){return e.jsxs("div",{className:"landing-orbital-rings",children:[e.jsxs(u.div,{className:"landing-ring landing-ring-1",animate:{rotate:360},transition:{duration:30,repeat:1/0,ease:"linear"},children:[e.jsx("div",{className:"landing-ring-dot",style:{top:"0%",left:"50%"}}),e.jsx("div",{className:"landing-ring-dot",style:{bottom:"0%",left:"50%"}})]}),e.jsx(u.div,{className:"landing-ring landing-ring-2",animate:{rotate:-360},transition:{duration:45,repeat:1/0,ease:"linear"},children:e.jsx("div",{className:"landing-ring-dot landing-ring-dot-pink",style:{top:"50%",right:"0%"}})}),e.jsxs(u.div,{className:"landing-ring landing-ring-3",animate:{rotate:360},transition:{duration:60,repeat:1/0,ease:"linear"},children:[e.jsx("div",{className:"landing-ring-dot landing-ring-dot-green",style:{top:"10%",left:"15%"}}),e.jsx("div",{className:"landing-ring-dot",style:{bottom:"15%",right:"10%"}})]}),e.jsx("div",{className:"landing-center-glow"})]})}const jt=Array.from({length:30},(t,n)=>({id:n,x:Math.random()*100,y:Math.random()*100,size:1+Math.random()*2,duration:15+Math.random()*25,delay:Math.random()*10}));function yt(){return e.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:jt.map(t=>e.jsx(u.div,{className:"absolute rounded-full",style:{left:`${t.x}%`,top:`${t.y}%`,width:t.size,height:t.size,background:t.id%3===0?"rgba(0, 188, 212, 0.5)":t.id%3===1?"rgba(233, 30, 99, 0.4)":"rgba(255, 255, 255, 0.2)"},animate:{y:[-20,20,-20],x:[-10,10,-10],opacity:[.2,.7,.2]},transition:{duration:t.duration,delay:t.delay,repeat:1/0,ease:"easeInOut"}},t.id))})}function bt({value:t,suffix:n=""}){const[a,s]=c.useState(0);return c.useEffect(()=>{if(t===0)return;const i=setTimeout(()=>{const l=performance.now();function o(m){const d=m-l,h=Math.min(d/1500,1),x=1-Math.pow(1-h,3);s(Math.round(x*t)),h<1&&requestAnimationFrame(o)}requestAnimationFrame(o)},800);return()=>clearTimeout(i)},[t]),e.jsxs("span",{children:[a,n]})}function vt(){const{scrollYProgress:t}=P(),n=ot(t,{stiffness:100,damping:30});return e.jsx(u.div,{className:"fixed top-0 left-0 right-0 h-[2px] z-50 origin-left",style:{scaleX:n,background:"linear-gradient(90deg, #00bcd4, #e91e63, #00bcd4)"}})}function Nt(){const[t,n]=c.useState(!1);return c.useEffect(()=>{const a=()=>n(window.scrollY>50);return window.addEventListener("scroll",a,{passive:!0}),()=>window.removeEventListener("scroll",a)},[]),e.jsx(u.nav,{className:`fixed top-0 left-0 right-0 z-40 transition-all duration-500 ${t?"landing-nav-scrolled":"landing-nav-transparent"}`,initial:{y:-80},animate:{y:0},transition:{duration:.6,ease:y},children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 h-16 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"landing-nav-logo",children:e.jsx(fe,{size:20,className:"text-[#00bcd4]"})}),e.jsx("span",{className:"text-base font-semibold tracking-tight text-white",children:"Orbital Command"})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-8",children:[e.jsx("a",{href:"#features",className:"text-sm text-white/60 hover:text-white transition-colors",children:"Features"}),e.jsx("a",{href:"#how-it-works",className:"text-sm text-white/60 hover:text-white transition-colors",children:"How It Works"}),e.jsx("a",{href:"#architecture",className:"text-sm text-white/60 hover:text-white transition-colors",children:"Architecture"}),e.jsxs("a",{href:"https://github.com/SakaraLabs/orbital-command",target:"_blank",rel:"noopener noreferrer",className:"landing-nav-cta",children:[e.jsx(T,{size:14}),"GitHub"]})]})]})})}function wt(){const t=c.useRef(null),{scrollYProgress:n}=P({target:t,offset:["start start","end start"]}),a=C(n,[0,1],[0,200]),s=C(n,[0,.6],[1,0]),i=C(n,[0,1],[0,100]);return e.jsxs(e.Fragment,{children:[e.jsxs("section",{ref:t,className:"landing-hero",children:[e.jsx("div",{className:"landing-hero-orb landing-hero-orb-1"}),e.jsx("div",{className:"landing-hero-orb landing-hero-orb-2"}),e.jsx("div",{className:"landing-hero-orb landing-hero-orb-3"}),e.jsxs(u.div,{className:"landing-hero-content",style:{y:a,opacity:s},children:[e.jsxs(u.div,{className:"landing-badge",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.5,delay:.1},children:[e.jsx(Ie,{size:14,className:"text-[#00bcd4]"}),e.jsx("span",{children:"Mission control for Claude Code"})]}),e.jsxs("h1",{className:"landing-headline",children:[e.jsx(xt,{text:"Command your"}),e.jsx("br",{}),e.jsx(u.span,{className:"landing-headline-gradient",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.7,delay:.5,ease:y},children:"AI fleet."})]}),e.jsxs(u.p,{className:"landing-subtitle",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.7,delay:.8},children:["Real-time project management dashboard for Claude Code.",e.jsx("br",{className:"hidden sm:block"}),"Kanban boards, sprint orchestration, quality gates, and deploy pipelines",e.jsx("br",{className:"hidden sm:block"}),"— all driven by a file-based event bus."]}),e.jsxs(u.div,{className:"landing-cta-row",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.7,delay:1},children:[e.jsxs("a",{href:"https://github.com/SakaraLabs/orbital-command",target:"_blank",rel:"noopener noreferrer",className:"landing-cta-primary group",children:[e.jsx(ae,{size:18}),"Get Started",e.jsx(re,{size:16,className:"ml-1 transition-transform group-hover:translate-x-1"})]}),e.jsxs("a",{href:"#features",className:"landing-cta-secondary",children:["See Features",e.jsx(Y,{size:16})]})]}),e.jsx(u.div,{className:"landing-install",initial:{opacity:0},animate:{opacity:1},transition:{duration:.6,delay:1.3},children:e.jsx("code",{children:"npm install orbital-command"})})]}),e.jsx(u.div,{className:"landing-hero-visual",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:1.2,delay:.5,ease:y},style:{y:i},children:e.jsx(pt,{})}),e.jsx(u.div,{className:"landing-scroll-indicator",animate:{y:[0,8,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:e.jsx(Y,{size:20,className:"text-white/30"})})]}),e.jsx("section",{className:"landing-stats",children:e.jsx("div",{className:"landing-stats-inner",children:[{value:7,suffix:"",label:"Dashboard Views"},{value:100,suffix:"%",label:"File-Based"},{value:0,suffix:"",label:"Lock-in",staticText:"0"},{label:"Real-time Sync",staticText:"RT"}].map((r,l)=>e.jsxs("div",{className:"contents",children:[l>0&&e.jsx("div",{className:"landing-stat-divider"}),e.jsxs("div",{className:"landing-stat",children:[e.jsx("span",{className:"landing-stat-value",children:r.staticText??e.jsx(bt,{value:r.value,suffix:r.suffix})}),e.jsx("span",{className:"landing-stat-label",children:r.label})]})]},r.label))})})]})}const kt={cyan:{glow:"rgba(0,188,212,0.15)",border:"rgba(0,188,212,0.3)",text:"#00bcd4"},pink:{glow:"rgba(233,30,99,0.15)",border:"rgba(233,30,99,0.3)",text:"#e91e63"},green:{glow:"rgba(0,230,118,0.15)",border:"rgba(0,230,118,0.3)",text:"#00e676"},amber:{glow:"rgba(255,171,0,0.15)",border:"rgba(255,171,0,0.3)",text:"#ffab00"},purple:{glow:"rgba(117,109,158,0.2)",border:"rgba(117,109,158,0.4)",text:"#9c8fd4"}};function b({icon:t,title:n,description:a,color:s,delay:i=0}){const r=kt[s];return e.jsx(g,{delay:i,children:e.jsxs(u.div,{className:"landing-feature-card group",whileHover:{y:-8,transition:{duration:.3}},children:[e.jsx("div",{className:"landing-feature-icon-wrap",style:{background:r.glow,borderColor:r.border},children:e.jsx(t,{size:24,style:{color:r.text}})}),e.jsx("h3",{className:"landing-feature-title",children:n}),e.jsx("p",{className:"landing-feature-desc",children:a}),e.jsx("div",{className:"landing-feature-glow",style:{background:`radial-gradient(ellipse at center, ${r.glow}, transparent 70%)`}})]})})}function St(){return e.jsx("section",{id:"features",className:"landing-section",children:e.jsxs("div",{className:"landing-section-inner",children:[e.jsx(g,{children:e.jsx("p",{className:"landing-section-tag",children:"Features"})}),e.jsx(g,{delay:.1,children:e.jsxs("h2",{className:"landing-section-title",children:["Everything you need to",e.jsx("br",{})," ",e.jsx("span",{className:"landing-gradient-text",children:"orchestrate AI agents."})]})}),e.jsx(g,{delay:.2,children:e.jsx("p",{className:"landing-section-desc",children:"A complete mission control system that turns Claude Code sessions into observable, manageable workflows with real-time feedback."})}),e.jsxs("div",{className:"landing-features-grid",children:[e.jsx(b,{icon:le,title:"Visual Kanban",description:"Drag-and-drop scope cards across workflow columns. Real-time status updates as Claude agents work through tasks.",color:"cyan",delay:0}),e.jsx(b,{icon:ue,title:"Sprint Orchestration",description:"Batch scopes into sprints with automatic sequencing, dependency resolution, and parallel execution across agents.",color:"pink",delay:.08}),e.jsx(b,{icon:oe,title:"Quality Gates",description:"Enforce standards with configurable gates — typecheck, lint, test, build. Auto-block deployments that fail checks.",color:"green",delay:.16}),e.jsx(b,{icon:ce,title:"Workflow DAG Editor",description:"Visual directed acyclic graph editor for custom workflows. Define columns, transitions, hooks, and inference rules.",color:"purple",delay:.08}),e.jsx(b,{icon:me,title:"Agent Feed",description:"Live stream of all Claude Code events across every session. Filter by agent, scope, or event type. Full audit trail.",color:"amber",delay:.16}),e.jsx(b,{icon:H,title:"Deploy Pipeline",description:"Multi-stage deployment visualization from dev to staging to production. Rollback controls and promotion gates.",color:"cyan",delay:.24})]})]})})}const S=({color:t,children:n})=>e.jsx("span",{style:{color:t},children:n}),E=[{elements:e.jsx(e.Fragment,{children:"$ orbital"}),delay:400},{elements:e.jsx(e.Fragment,{children:" Scaffolding hooks, skills, and agents..."}),delay:800},{elements:e.jsx(e.Fragment,{children:" Writing .claude/hooks/on-scope-change.sh"}),delay:200},{elements:e.jsx(e.Fragment,{children:" Writing .claude/hooks/on-quality-gate.sh"}),delay:200},{elements:e.jsx(e.Fragment,{children:" Creating orbital.config.json"}),delay:300},{elements:e.jsxs(e.Fragment,{children:[" ",e.jsx(S,{color:"#00e676",children:"✓"})," Orbital Command initialized"]}),delay:600},{elements:e.jsx(e.Fragment,{children:" "}),delay:300},{elements:e.jsx(e.Fragment,{children:" Launching dashboard..."}),delay:500},{elements:e.jsx(e.Fragment,{children:" Server running on http://localhost:4444"}),delay:400},{elements:e.jsx(e.Fragment,{children:" Client running on http://localhost:4445"}),delay:200},{elements:e.jsxs(e.Fragment,{children:[" ",e.jsx(S,{color:"#00bcd4",children:"◉"})," Watching scopes/ for changes..."]}),delay:300},{elements:e.jsxs(e.Fragment,{children:[" ",e.jsx(S,{color:"#00bcd4",children:"◉"})," Watching .claude/orbital-events/ for events..."]}),delay:200},{elements:e.jsxs(e.Fragment,{children:[" ",e.jsx(S,{color:"#00e676",children:"✓"})," Dashboard ready — mission control is live"]}),delay:0}];function Et(){const t=c.useRef(null),n=ve(t,{once:!0,amount:.1}),[a,s]=c.useState(0);return c.useEffect(()=>{if(!n)return;let i,r=0;function l(){r>=E.length||(s(r+1),r++,r<E.length&&(i=setTimeout(l,E[r].delay)))}return i=setTimeout(l,600),()=>clearTimeout(i)},[n]),e.jsxs("div",{ref:t,className:"landing-terminal",children:[e.jsxs("div",{className:"landing-terminal-header",children:[e.jsx("div",{className:"landing-terminal-dot landing-terminal-dot-red"}),e.jsx("div",{className:"landing-terminal-dot landing-terminal-dot-yellow"}),e.jsx("div",{className:"landing-terminal-dot landing-terminal-dot-green"}),e.jsx("span",{className:"landing-terminal-title",children:"orbital-command"})]}),e.jsxs("div",{className:"landing-terminal-body",children:[E.slice(0,a).map((i,r)=>e.jsx(u.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{duration:.3},className:"landing-terminal-line",children:i.elements},r)),e.jsx(u.span,{className:"landing-terminal-cursor",animate:{opacity:[1,0,1]},transition:{duration:1,repeat:1/0},children:"▌"})]})]})}const zt=[{label:"Kanban Board",gradient:"from-cyan-500/20 to-blue-500/20",icon:le},{label:"Quality Gates",gradient:"from-green-500/20 to-emerald-500/20",icon:oe},{label:"Workflow DAG",gradient:"from-purple-500/20 to-pink-500/20",icon:ce},{label:"Agent Feed",gradient:"from-pink-500/20 to-red-500/20",icon:me},{label:"Sprint View",gradient:"from-amber-500/20 to-orange-500/20",icon:ue},{label:"Deploy Pipeline",gradient:"from-cyan-500/20 to-teal-500/20",icon:H}];function Lt(){const t=c.useRef(null),{scrollYProgress:n}=P({target:t,offset:["start end","end start"]}),a=C(n,[0,1],["5%","-15%"]);return e.jsxs("section",{className:"landing-section-full",children:[e.jsxs(g,{className:"text-center mb-12",children:[e.jsx("p",{className:"landing-section-tag",children:"Dashboard"}),e.jsxs("h2",{className:"landing-section-title",children:["Six views. ",e.jsx("span",{className:"landing-gradient-text",children:"One command center."})]})]}),e.jsx("div",{ref:t,className:"overflow-hidden py-8",children:e.jsx(u.div,{className:"flex gap-6 px-8",style:{x:a},children:zt.map(s=>e.jsxs(u.div,{className:`landing-showcase-card bg-gradient-to-br ${s.gradient}`,whileHover:{scale:1.03},transition:{duration:.3},children:[e.jsx(s.icon,{size:48,className:"text-white/30 mb-4"}),e.jsx("span",{className:"text-lg font-medium text-white/80",children:s.label})]},s.label))})})]})}function R({number:t,title:n,description:a,icon:s,delay:i}){return e.jsxs(g,{delay:i,className:"landing-step",children:[e.jsx("div",{className:"landing-step-number",children:t}),e.jsx("div",{className:"landing-step-icon",children:e.jsx(s,{size:28})}),e.jsx("h3",{className:"text-lg font-semibold text-white mt-4 mb-2",children:n}),e.jsx("p",{className:"text-sm text-white/50 leading-relaxed",children:a})]})}const Ct=[{label:"Frontend",sub:"React + Vite + Tailwind",color:"#00bcd4",icon:Me},{label:"Real-time",sub:"Socket.io Push",color:"#e91e63",icon:he},{label:"API",sub:"Express REST",color:"#ffab00",icon:de},{label:"Engine",sub:"Workflow + Events",color:"#00e676",icon:ge}];function It(){return e.jsx("div",{className:"landing-arch-stack",children:Ct.map(t=>e.jsxs(u.div,{className:"landing-arch-layer",whileHover:{x:8,transition:{duration:.2}},style:{borderLeftColor:t.color},children:[e.jsx("div",{className:"landing-arch-icon",style:{color:t.color},children:e.jsx(t.icon,{size:20})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:t.label}),e.jsx("div",{className:"text-xs text-white/40",children:t.sub})]})]},t.label))})}function Ht(){return e.jsxs("div",{className:"landing-root",children:[e.jsx(vt,{}),e.jsx(Nt,{}),e.jsx(yt,{}),e.jsx(wt,{}),e.jsx(St,{}),e.jsx(Lt,{}),e.jsx("section",{id:"how-it-works",className:"landing-section",children:e.jsxs("div",{className:"landing-section-inner",children:[e.jsx(g,{children:e.jsx("p",{className:"landing-section-tag",children:"How It Works"})}),e.jsx(g,{delay:.1,children:e.jsxs("h2",{className:"landing-section-title",children:["Three steps to",e.jsx("br",{})," ",e.jsx("span",{className:"landing-gradient-text",children:"mission control."})]})}),e.jsxs("div",{className:"landing-steps-grid",children:[e.jsx(R,{number:"01",title:"Initialize",description:"Run orbital in your project. The setup wizard scaffolds hooks, skills, agents, and config into your .claude/ directory. Zero lock-in — everything is plain files.",icon:ae,delay:0}),e.jsx(R,{number:"02",title:"Define Scopes",description:"Write markdown files with YAML frontmatter in scopes/. Each scope is a task card — title, status, category, priority, assignee. Claude reads and updates them.",icon:T,delay:.15}),e.jsx(R,{number:"03",title:"Launch",description:"Select Launch from the hub menu and open the dashboard. Watch your AI fleet in real-time as Claude agents pick up scopes, emit events, and progress through your workflow.",icon:H,delay:.3})]})]})}),e.jsx("section",{className:"landing-section",children:e.jsx("div",{className:"landing-section-inner",children:e.jsxs("div",{className:"landing-split",children:[e.jsxs(k,{direction:"left",className:"flex-1 min-w-0",children:[e.jsx("p",{className:"landing-section-tag",children:"Developer Experience"}),e.jsxs("h2",{className:"landing-section-title text-left",children:["Get running in",e.jsx("br",{})," ",e.jsx("span",{className:"landing-gradient-text",children:"under a minute."})]}),e.jsx("p",{className:"landing-section-desc text-left mt-4",children:"One command to scaffold. One command to launch. File-based architecture means everything is inspectable, versionable, and customizable."}),e.jsxs("div",{className:"landing-dx-features",children:[e.jsxs("div",{className:"landing-dx-item",children:[e.jsx(Ae,{size:16,className:"text-[#00bcd4]"}),e.jsx("span",{children:"Zero-config setup"})]}),e.jsxs("div",{className:"landing-dx-item",children:[e.jsx(de,{size:16,className:"text-[#e91e63]"}),e.jsx("span",{children:"File-based event bus"})]}),e.jsxs("div",{className:"landing-dx-item",children:[e.jsx(he,{size:16,className:"text-[#00e676]"}),e.jsx("span",{children:"Real-time Socket.io sync"})]}),e.jsxs("div",{className:"landing-dx-item",children:[e.jsx(ge,{size:16,className:"text-[#ffab00]"}),e.jsx("span",{children:"SQLite persistence"})]})]})]}),e.jsx(k,{direction:"right",className:"flex-1 min-w-0",children:e.jsx(Et,{})})]})})}),e.jsx("section",{id:"architecture",className:"landing-section",children:e.jsx("div",{className:"landing-section-inner",children:e.jsxs("div",{className:"landing-split",children:[e.jsxs(k,{direction:"left",className:"flex-1 min-w-0",children:[e.jsx("p",{className:"landing-section-tag",children:"Architecture"}),e.jsxs("h2",{className:"landing-section-title text-left",children:["Built on",e.jsx("br",{})," ",e.jsx("span",{className:"landing-gradient-text",children:"open primitives."})]}),e.jsx("p",{className:"landing-section-desc text-left mt-4",children:"Markdown files are tasks. JSON files are events. The workflow engine is pure TypeScript with zero I/O. Everything is observable and hackable."})]}),e.jsx(k,{direction:"right",className:"flex-1 min-w-0",children:e.jsx(It,{})})]})})}),e.jsxs("section",{className:"landing-final-cta",children:[e.jsx("div",{className:"landing-final-cta-bg"}),e.jsxs("div",{className:"relative z-10 max-w-3xl mx-auto text-center px-6",children:[e.jsx(gt,{children:e.jsxs("h2",{className:"landing-final-headline",children:["Ready for",e.jsx("br",{})," ",e.jsx("span",{className:"landing-gradient-text",children:"liftoff?"})]})}),e.jsx(g,{delay:.2,children:e.jsx("p",{className:"text-lg text-white/50 mb-10 leading-relaxed",children:"Install Orbital Command and take control of your AI-powered development workflow. Open source. Zero lock-in. Fully extensible."})}),e.jsx(g,{delay:.4,children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs("a",{href:"https://github.com/SakaraLabs/orbital-command",target:"_blank",rel:"noopener noreferrer",className:"landing-cta-primary group text-base px-8 py-4",children:[e.jsx(T,{size:18}),"View on GitHub",e.jsx(re,{size:16,className:"ml-1 transition-transform group-hover:translate-x-1"})]}),e.jsx("div",{className:"landing-install",children:e.jsx("code",{children:"npm install orbital-command"})})]})})]})]}),e.jsx("footer",{className:"landing-footer",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 flex flex-col sm:flex-row items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{size:16,className:"text-[#00bcd4]"}),e.jsx("span",{className:"text-sm text-white/40",children:"Orbital Command"})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx("a",{href:"https://github.com/SakaraLabs/orbital-command",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/30 hover:text-white/60 transition-colors",children:"GitHub"}),e.jsx("span",{className:"text-xs text-white/20",children:"MIT License"})]})]})})]})}export{Ht as Landing,Ht as default};
@@ -0,0 +1,32 @@
1
+ import{E as Mt,j as e,L as lt,G as ct,H as dt}from"./ui-BmsSg9jU.js";import{a as d,b as Tt}from"./vendor-Bqt8AJn2.js";import{c as we,s as ee,a as R,E as $t,T as Ht,S as Ft,X as ft,u as Pe,C as Ce,b as Se,d as Ge,P as ut,e as Me,f as Ue,g as ht,B as se,h as je,i as Rt,j as Ot,k as mt,W as At,l as Dt,A as Lt,m as It,n as Ee,o as xt,p as Bt,G as Wt,L as _t,q as zt,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-o4ScMAuR.js";import{C as qt,a as Xt}from"./workflow-constants-Rw-GmgHZ.js";import{B as Te}from"./bot-NFaJBDn_.js";import{P as pt,S as Qt,u as es}from"./useWorkflowEditor-CqeRWVQX.js";import{Z as $e}from"./zap-C9wqYMpl.js";import{F as Xe}from"./file-text-J1cebZXF.js";import{A as Qe}from"./arrow-down-DVPp6_qp.js";import{G as ts}from"./globe-WzeyHsUc.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 ss=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],et=we("corner-down-left",ss);/**
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 os=[["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"}]],gt=we("file",os);/**
12
+ * @license lucide-react v0.577.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const rs=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],bt=we("folder-open",rs);/**
17
+ * @license lucide-react v0.577.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
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
+ * This source code is licensed under the ISC license.
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(`
30
+ `)}
31
+ ---
32
+ ${o}`}function Ds(t,o){const[r,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(),D=d.useRef(0);d.useEffect(()=>{if(!t||!o){s(""),n(""),l({}),b(""),g(null);return}const y=++D.current;x(!0),g(null),fetch(j(`/config/${t}/file?path=${encodeURIComponent(o)}`)).then(async C=>{var X;if(!C.ok)throw new Error(`HTTP ${C.status}`);const _=await C.json();if(y!==D.current)return;const Z=((X=_.data)==null?void 0:X.content)??"";s(Z),n(Z);const q=it(Z);l(q.fields),b(q.body)}).catch(C=>{y===D.current&&g(C instanceof Error?C.message:"Failed to load file")}).finally(()=>{y===D.current&&x(!1)})},[t,o,j]);const I=d.useCallback((y,C)=>{const _=As(y,C);s(_)},[]),v=d.useCallback((y,C)=>{l(_=>{const 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||!o)){w(!0),g(null);try{const y=await fetch(j(`/config/${t}/file`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:o,content:r})});if(!y.ok){const C=await y.json().catch(()=>({error:"Save failed"}));throw new Error(C.error??`HTTP ${y.status}`)}n(r)}catch(y){g(y instanceof Error?y.message:"Save failed")}finally{w(!1)}}},[t,o,r,j]);return{content:r,setContent:B,frontmatter:a,setFrontmatterField:v,body:u,setBody:M,dirty:r!==i,saving:P,loading:$,save:L,error:m}}function Ls(t){const o=t.split("/"),r=o[o.length-1];return o.length>=2&&/^(SKILL|AGENT)\.md$/i.test(r)?o[o.length-2].toLowerCase():r.replace(/\.(md|sh)$/,"").toLowerCase()}function Zs(){const[t,o]=d.useState("agents"),r=Me(),[s,i]=d.useState(null),[n,a]=d.useState(null),[l,u]=d.useState(!1),[b,$]=d.useState(null),{activeProjectId:x,hasMultipleProjects:P}=zt(),{report:w,refetch:m}=ls(P?x:null),g=(w==null?void 0:w.files.some(k=>k.state==="drifted"))??!1,{tree:j,loading:D,refresh:I}=Ne(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:_,dirty:Z,saving:q,loading:X,save:z,error:ae}=Ds(v,M),{engine:le}=mt(),V=le.getConfig(),p=es(V),ce=Gt(Ut(Zt,{activationConstraint:{distance:8}})),ge=Vt(),f=d.useCallback(k=>{o(k),i(null)},[]),S=d.useCallback(k=>{k.type==="file"&&i({type:t,path:k.path})},[t]),G=d.useCallback((k,O)=>{o(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]),ve=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 oe=F.match(/^pipeline::edge-hook::(.+?):(.+?)::(.+)$/);if(oe){const[,ie,Le,Pt]=oe;Q(ie,Le,Pt);return}const xe=F.match(/^pipeline::stage-hook::(.+?)::(.+)$/);if(xe){const[,ie,Le]=xe;de(ie,Le);return}const re=F.match(/^pipeline::global-hook::(.+)$/);if(re){const[,ie]=re;fe(ie);return}return}const te=F.match(/^tree::(hooks|skills|agents)::(.+)$/),ke=W.match(/^drop::(edge-hooks|stage-hooks|edge-skill)::(.+)$/);if(!te||!ke)return;const[,ye,Ke]=te,[,Ae,De]=ke,be=ye==="hooks"?me.get(Ke):Ls(Ke);if(be){if(p.editMode||p.enterEditMode(),Ae==="edge-hooks"&&ye==="hooks"){const[oe,xe]=De.split(":"),re=p.editConfig.edges.find(ie=>ie.from===oe&&ie.to===xe);if(!re||(Ye=re.hooks)!=null&&Ye.includes(be))return;p.updateEdge(re,{...re,hooks:[...re.hooks??[],be]})}if(Ae==="stage-hooks"&&ye==="hooks"){const oe=p.editConfig.lists.find(xe=>xe.id===De);if(!oe||(Ze=oe.activeHooks)!=null&&Ze.includes(be))return;p.updateList(oe,{...oe,activeHooks:[...oe.activeHooks??[],be]})}if(Ae==="edge-skill"&&ye==="skills"){const[oe,xe]=De.split(":"),re=p.editConfig.edges.find(ie=>ie.from===oe&&ie.to===xe);if(!re)return;p.updateEdge(re,{...re,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(r("/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,r]),{activeSkills:Fe,activeSkillPaths:Re,activeAgentPaths:A,activeHookPaths:Y,hookCategoryMap:Oe}=J,pe=t==="skills"?Re:t==="agents"?A: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 ke=k[W.toLowerCase()]??"#8B5CF6";O.set(te.path,{team:W,color:ke})}}return H(j,null),O},[t,j]),{setNodeRef:Ct,isOver:Je}=Ee({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:ve,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(bt,{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(Es,{})}),b&&x&&e.jsx("div",{className:"mb-4",children:e.jsx(Ps,{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(xs,{tree:j,loading:D,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(Os,{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(Ns,{type:v,filePath:M,content:B,setContent:L,frontmatter:ne,setFrontmatterField:y,body:C,setBody:_,dirty:Z,saving:q,loading:X,error:ae,onSave:z})})]})]}),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{Zs as PrimitivesConfig};
@@ -0,0 +1,26 @@
1
+ import{j as e}from"./ui-BmsSg9jU.js";import{c as j,e as k,j as D,E as le,F as g,H as oe,I as ie,J as U,T as ce,a as x,B as v,K as de,s as $,o as B,M as W,N as X,O as q,h as me,Q as xe,R as ue,U as pe,w as he,S as fe}from"./index-o4ScMAuR.js";import{a as d}from"./vendor-Bqt8AJn2.js";import{u as R,f as L}from"./useSocketListener-0L5yiN5i.js";import{C as ge,E as K}from"./workflow-constants-Rw-GmgHZ.js";import{S as T}from"./shield-TdB1yv_a.js";import{Z as y}from"./zap-C9wqYMpl.js";import{F as je}from"./file-text-J1cebZXF.js";import{C as Y}from"./circle-x-IsFCkBZu.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
+ * @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 ye=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],Se=j("check-check",ye);/**
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 Ee=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Q=j("play",Ee);/**
12
+ * @license lucide-react v0.577.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const _e=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],P=j("shield-alert",_e);/**
17
+ * @license lucide-react v0.577.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const ke=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],ve=j("square-terminal",ke);/**
22
+ * @license lucide-react v0.577.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Te=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],we=j("wrench",Te);function Z(){const t=k(),[s,a]=d.useState(null),[n,l]=d.useState([]),i=d.useCallback(async()=>{const[r,c]=await Promise.all([fetch(t("/enforcement/rules")),fetch(t("/events/violations/trend?days=30"))]);r.ok&&a(await r.json()),c.ok&&l(await c.json())},[t]),{loading:m}=D(i);return R("event:new",r=>{(r.type==="VIOLATION"||r.type==="OVERRIDE")&&i()},[i]),{data:s,trend:n,loading:m,refetch:i}}const Ce={guard:T,gate:P,lifecycle:ge,observer:le},O={background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"11px"},Ae={VIOLATION:{icon:ce,color:"text-red-400",label:"Violation"},OVERRIDE:{icon:P,color:"text-amber-400",label:"Override"},GATE_PASSED:{icon:g,color:"text-green-400",label:"Gate passed"},GATE_FAILED:{icon:Y,color:"text-red-400",label:"Gate failed"},ALL_GATES_PASSED:{icon:Se,color:"text-green-400",label:"All gates passed"},SCOPE_STATUS_CHANGED:{icon:y,color:"text-cyan-400",label:"Status changed"},SCOPE_TRANSITION:{icon:U,color:"text-cyan-400",label:"Transition"},SCOPE_GATE_LIFTED:{icon:T,color:"text-cyan-400",label:"Gate lifted"},COMMIT:{icon:ie,color:"text-foreground",label:"Commit"},SESSION_START:{icon:Q,color:"text-green-400",label:"Session started"},SESSION_END:{icon:oe,color:"text-muted-foreground",label:"Session ended"},AGENT_STARTED:{icon:y,color:"text-purple-400",label:"Agent started"},AGENT_COMPLETED:{icon:g,color:"text-purple-400",label:"Agent completed"},SCOPE_CREATED:{icon:je,color:"text-cyan-400",label:"Scope created"},SCOPE_COMPLETED:{icon:g,color:"text-green-400",label:"Scope completed"},DISPATCH:{icon:ve,color:"text-cyan-400",label:"Dispatch"},REVIEW_FIXES_COMPLETED:{icon:we,color:"text-purple-400",label:"Review fixes"},SKILL_INVOKED:{icon:y,color:"text-foreground",label:"Skill invoked"},SKILL_COMPLETED:{icon:g,color:"text-foreground",label:"Skill completed"}};function ee(t){return t.replace(/-/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Ie(){const{data:t,loading:s}=Z();return s?e.jsx("div",{className:"flex flex-1 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||t.rules.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No rules configured"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sticky top-0 z-10 border-b border-border/50 bg-surface-light/40 backdrop-blur-sm px-3 py-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(T,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Rules"}),e.jsxs("div",{className:"flex items-center gap-2.5 ml-auto",children:[e.jsx(N,{count:t.summary.guards,label:"guards",color:"text-red-400"}),e.jsx(N,{count:t.summary.gates,label:"gates",color:"text-amber-400"}),e.jsx(N,{count:t.summary.lifecycle,label:"lifecycle",color:"text-cyan-400"}),e.jsx(N,{count:t.summary.observers,label:"observers",color:"text-zinc-400"}),e.jsx("span",{className:"text-border",children:"|"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.totalEdges," edges"]})]})]})}),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 text-left text-[10px] text-muted-foreground uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-1.5 font-medium",children:"Hook"}),e.jsx("th",{className:"px-3 py-1.5 font-medium",children:"Category"}),e.jsx("th",{className:"px-3 py-1.5 font-medium",children:"Level"}),e.jsx("th",{className:"px-3 py-1.5 font-medium",children:"Edges"}),e.jsx("th",{className:"px-3 py-1.5 font-medium text-right",children:"Vio"}),e.jsx("th",{className:"px-3 py-1.5 font-medium text-right",children:"Ovr"}),e.jsx("th",{className:"px-3 py-1.5 font-medium text-right",children:"Fired"})]})}),e.jsx("tbody",{children:t.rules.map(a=>e.jsx(Oe,{rule:a},a.hook.id))})]})})]})}function Oe({rule:t}){var a;const s=Ce[t.hook.category]??T;return e.jsxs("tr",{className:"border-b border-border/30 last:border-0 hover:bg-surface-light/30",children:[e.jsx("td",{className:"px-3 py-1.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(s,{className:"h-3 w-3 text-muted-foreground/50 shrink-0"}),e.jsx("span",{className:"font-medium truncate",children:t.hook.label})]})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx(v,{variant:"outline",className:x("text-[9px] border",K[t.enforcement]),children:t.hook.category})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:x("text-[10px]",(a=K[t.enforcement])==null?void 0:a.split(" ")[0]),children:t.enforcement})}),e.jsx("td",{className:"px-3 py-1.5",children:t.edges.length>0?e.jsxs("div",{className:"flex flex-wrap gap-0.5",children:[t.edges.slice(0,2).map((n,l)=>e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] text-muted-foreground font-mono",children:[n.from,e.jsx(U,{className:"h-2 w-2"}),n.to]},l)),t.edges.length>2&&e.jsxs("span",{className:"text-[9px] text-muted-foreground",children:["+",t.edges.length-2]})]}):e.jsx("span",{className:"text-[9px] text-muted-foreground",children:"-"})}),e.jsx("td",{className:"px-3 py-1.5 text-right font-mono",children:t.stats.violations>0?e.jsx("span",{className:"text-red-400",children:t.stats.violations}):e.jsx("span",{className:"text-muted-foreground/40",children:"0"})}),e.jsx("td",{className:"px-3 py-1.5 text-right font-mono",children:t.stats.overrides>0?e.jsx("span",{className:"text-amber-400",children:t.stats.overrides}):e.jsx("span",{className:"text-muted-foreground/40",children:"0"})}),e.jsx("td",{className:"px-3 py-1.5 text-right text-muted-foreground/60",children:t.stats.last_triggered?L(new Date(t.stats.last_triggered),{addSuffix:!0}):"-"})]})}function N({count:t,label:s,color:a}){return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:x("text-xs font-medium",a),children:t}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:s})]})}function De(){const t=k(),[s,a]=d.useState({byRule:[],byFile:[],overrides:[],totalViolations:0,totalOverrides:0}),n=d.useCallback(async()=>{const i=await fetch(t("/events/violations/summary"));i.ok&&a(await i.json())},[t]),{loading:l}=D(n);return R("event:new",i=>{(i.type==="VIOLATION"||i.type==="OVERRIDE")&&n()},[n]),{...s,loading:l,refetch:n}}const z=[{key:"all",label:"All"},{key:"workflow",label:"Workflow",types:new Set(["SCOPE_STATUS_CHANGED","SCOPE_TRANSITION","SCOPE_GATE_LIFTED","SCOPE_CREATED","SCOPE_COMPLETED","DISPATCH"])},{key:"enforcement",label:"Enforcement",types:new Set(["VIOLATION","OVERRIDE","GATE_PASSED","GATE_FAILED","ALL_GATES_PASSED","REVIEW_FIXES_COMPLETED"])},{key:"sessions",label:"Sessions",types:new Set(["SESSION_START","SESSION_END","AGENT_STARTED","AGENT_COMPLETED","COMMIT","SKILL_INVOKED","SKILL_COMPLETED"])}];function Re(){const t=k(),{scopes:s}=de(),{totalViolations:a,totalOverrides:n,loading:l}=De(),{trend:i,loading:m}=Z(),[r,c]=d.useState([]),[h,f]=d.useState(!0),[u,se]=d.useState("all"),[te,G]=d.useState(null),b=d.useCallback(async()=>{try{const o=await fetch(t("/events?limit=50"));o.ok&&c(await o.json())}catch{}finally{f(!1)}},[t]);d.useEffect(()=>{b()},[b]),d.useEffect(()=>{const o=()=>{b()};return $.on("event:new",o),()=>{$.off("event:new",o)}},[b]);const ae=d.useMemo(()=>{const o=new Map;for(const p of s)o.set(p.id,p.title);return o},[s]),M=d.useMemo(()=>{const o=z.find(p=>p.key===u);return!o||u==="all"?r:r.filter(p=>o.types.has(p.type))},[r,u]),F=a+n>0?Math.round(n/(a+n)*100):0,re=l||m||h;async function ne(o){G(o);try{const p=await fetch(t(`/sessions/${o}/content`));if(!p.ok)return;const V=await p.json();if(!V.claude_session_id)return;await fetch(t(`/sessions/${o}/resume`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claude_session_id:V.claude_session_id})})}catch{}finally{setTimeout(()=>G(null),2e3)}}return e.jsxs(B,{className:"flex-1 min-h-0 flex flex-col",children:[e.jsxs(W,{className:"pb-2 pt-3 px-4 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-red-400"}),e.jsx(X,{className:"text-sm font-medium",children:"Activity"}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto text-xs",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-red-400 font-medium",children:a})," ",e.jsx("span",{className:"text-muted-foreground",children:"violations"})]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-amber-400 font-medium",children:n})," ",e.jsx("span",{className:"text-muted-foreground",children:"overrides"})]}),a+n>0&&e.jsxs("span",{className:x("font-medium",F>50?"text-amber-400":"text-muted-foreground"),children:[F,"%"]})]})]}),e.jsx("div",{className:"flex gap-1 mt-2",children:z.map(o=>e.jsx("button",{onClick:()=>se(o.key),className:x("rounded-full px-2.5 py-0.5 text-[10px] font-medium transition-colors",u===o.key?"bg-primary/15 text-primary border border-primary/30":"text-muted-foreground hover:text-foreground hover:bg-surface-light/50 border border-transparent"),children:o.label},o.key))})]}),e.jsx(q,{className:"px-4 pb-4 flex-1 min-h-0 overflow-y-auto space-y-3",children:re?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.jsx(Me,{trend:i}),M.length===0?e.jsx("p",{className:"text-xs text-muted-foreground py-4 text-center",children:"No events recorded yet"}):e.jsx("div",{className:"space-y-px",children:M.map(o=>e.jsx(Le,{event:o,scopeTitle:o.scope_id?ae.get(o.scope_id)??null:null,onResume:o.session_id?()=>ne(o.session_id):void 0,resuming:te===o.session_id},o.id))})]})})]})}function Le({event:t,scopeTitle:s,onResume:a,resuming:n}){const l=Ae[t.type]??{icon:y,color:"text-muted-foreground",label:t.type},i=l.icon,m=t.data??{};return e.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-1 hover:bg-surface-light/30 group border-l-2 border-transparent hover:border-primary/20",children:[e.jsx(i,{className:x("h-3.5 w-3.5 shrink-0",l.color)}),e.jsx("span",{className:x("text-[11px] font-medium shrink-0",l.color),children:l.label}),t.scope_id&&e.jsxs(v,{variant:"outline",className:"text-[9px] font-mono px-1.5 py-0 h-4 gap-1 border-border/50 shrink-0",children:["#",String(t.scope_id).padStart(3,"0"),s&&e.jsx("span",{className:"font-sans text-muted-foreground truncate max-w-[120px]",children:s})]}),e.jsx(Pe,{type:t.type,data:m}),e.jsx("span",{className:"flex-1 min-w-0",children:e.jsx(Ge,{type:t.type,data:m})}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a&&e.jsxs(me,{size:"sm",variant:"ghost",className:"h-5 px-1.5 text-[10px] gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:a,disabled:n,children:[e.jsx(Q,{className:"h-2.5 w-2.5"}),n?"Opening...":"Resume"]}),e.jsx("span",{className:"text-[9px] text-muted-foreground/40 tabular-nums whitespace-nowrap",children:t.timestamp?L(new Date(t.timestamp),{addSuffix:!0}):""})]})]})}function Pe({type:t,data:s}){const a=[];return s.rule&&a.push({label:String(s.rule),color:"border-red-500/30 text-red-400"}),s.outcome==="blocked"&&a.push({label:"blocked",color:"border-red-500/30 text-red-400"}),s.outcome==="overridden"&&a.push({label:"overridden",color:"border-amber-500/30 text-amber-400"}),s.verdict==="PASS"&&a.push({label:"PASS",color:"border-green-500/30 text-green-400"}),s.verdict==="FAIL"&&a.push({label:"FAIL",color:"border-red-500/30 text-red-400"}),t==="COMMIT"&&s.hash&&a.push({label:String(s.hash).slice(0,7)}),t==="DISPATCH"&&s.command&&a.push({label:String(s.command)}),t==="SCOPE_GATE_LIFTED"&&s.mode&&a.push({label:String(s.mode)}),t==="AGENT_COMPLETED"&&s.action&&a.push({label:String(s.action)}),t==="SKILL_INVOKED"&&s.skill&&a.push({label:String(s.skill)}),a.length===0?null:e.jsx(e.Fragment,{children:a.map((n,l)=>e.jsx(v,{variant:"outline",className:x("text-[9px] px-1 py-0 h-3.5 font-mono",n.color??"border-border/50"),children:n.label},l))})}function Ge({type:t,data:s}){let a=null;switch(t){case"VIOLATION":a=[s.details,s.file].filter(Boolean).join(" — ")||null;break;case"OVERRIDE":a=s.reason?String(s.reason):null;break;case"SCOPE_STATUS_CHANGED":case"SCOPE_TRANSITION":{const n=s.from?String(s.from):null,l=s.to?String(s.to):null,i=s.scope_name?String(s.scope_name):null,m=[];n&&l?m.push(`${n} → ${l}`):l&&m.push(`→ ${l}`),i&&m.push(i),a=m.join(" — ")||null;break}case"COMMIT":a=s.message?String(s.message).slice(0,100):null;break;case"AGENT_COMPLETED":{const n=[];s.outcome&&n.push(String(s.outcome)),s.commit_hash&&n.push(`commit ${String(s.commit_hash).slice(0,7)}`),a=n.join(" — ")||null;break}case"AGENT_STARTED":a=s.agents?String(s.agents):s.mode?String(s.mode):null;break;case"REVIEW_FIXES_COMPLETED":{const n=s.findings_total,l=s.findings_fixed,i=s.agents_used;a=n!=null?`${l}/${n} findings fixed${i?` by ${i} agents`:""}`:null;break}case"GATE_PASSED":case"GATE_FAILED":a=s.gate_name?ee(String(s.gate_name)):null;break;case"DISPATCH":a=null;break;case"SESSION_START":a=s.source?`source: ${s.source}`:null;break;case"SCOPE_GATE_LIFTED":a=s.scope_file?String(s.scope_file).split("/").pop()??null:null;break;default:a=s.details||s.message?String(s.details||s.message).slice(0,100):null}return a?e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:a}):null}function Me({trend:t}){const s=new Map;for(const n of t)s.set(n.day,(s.get(n.day)??0)+n.count);const a=[...s.entries()].map(([n,l])=>({day:n.slice(5),count:l})).slice(-30);return a.length<2?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/50 mb-1.5 block",children:"Violation Trend (30d)"}),e.jsx(S,{width:"100%",height:100,children:e.jsxs(be,{data:a,margin:{left:0,right:10,top:5,bottom:0},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.3}),e.jsx(E,{dataKey:"day",tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),e.jsx(_,{tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},width:30}),e.jsx(A,{contentStyle:O}),e.jsx(Ne,{type:"monotone",dataKey:"count",stroke:"#EF4444",fill:"#EF444420",strokeWidth:1.5})]})})]})}function Fe(t){const s=k(),[a,n]=d.useState([]),[l,i]=d.useState([]),m=d.useCallback(async()=>{const[h,f]=await Promise.all([fetch(s("/gates")),fetch(s("/gates/stats"))]);h.ok&&n(await h.json()),f.ok&&i(await f.json())},[t,s]),{loading:r}=D(m);return R("gate:updated",c=>{n(h=>{const f=h.findIndex(u=>u.gate_name===c.gate_name&&u.scope_id===c.scope_id);if(f>=0){const u=[...h];return u[f]=c,u}return[...h,c]})},[]),{gates:a,stats:l,loading:r,refetch:m}}const Ve={pass:{icon:g,color:"text-bid-green",label:"Pass",glow:"gate-glow-pass glow-green"},fail:{icon:Y,color:"text-ask-red",label:"Fail",glow:"gate-glow-fail glow-red"},running:{icon:ue,color:"text-accent-blue",label:"Running",animate:"animate-spin",glow:"glow-blue"},skipped:{icon:xe,color:"text-muted-foreground",label:"Skipped",glow:""}};function $e({status:t,className:s}){const a=Ve[t],n=a.icon;return e.jsxs("div",{className:x("flex items-center gap-1.5",s),children:[e.jsx(n,{className:x("h-4 w-4",a.color,a.animate,a.glow)}),e.jsx("span",{className:x("text-xs",a.color),children:a.label})]})}function Ke(){const{gates:t,stats:s,loading:a}=Fe(),n=s.reduce((r,c)=>r+c.passed,0),l=s.reduce((r,c)=>r+c.total,0),i=l>0?Math.round(n/l*100):0,m=t.filter(r=>r.status==="pass").length;return e.jsxs(B,{className:"shrink-0 basis-2/5 min-h-0 flex flex-col",children:[e.jsx(W,{className:"pb-2 pt-3 px-4 shrink-0",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(g,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(X,{className:"text-sm font-medium",children:"CI Gates"}),t.length>0&&e.jsxs(v,{variant:"secondary",className:"text-[10px]",children:[m,"/",t.length," passing"]}),l>0&&e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Pass rate"}),e.jsxs("span",{className:"text-sm font-medium",children:[i,"%"]}),e.jsx("div",{className:"h-1.5 w-16 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-bid-green transition-all",style:{width:`${i}%`}})})]})]})}),e.jsx(q,{className:"px-4 pb-4 flex-1 min-h-0 overflow-y-auto",children:a?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.jsxs("p",{className:"text-xs text-muted-foreground text-center py-3",children:["No gate results yet. Run ",e.jsx("code",{className:"rounded bg-muted px-1",children:"/test-checks"})," to populate."]}):e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/50 mb-1.5 block",children:"Latest Run"}),e.jsx("div",{className:"space-y-0.5",children:t.map(r=>e.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-0.5 hover:bg-surface-light/50",children:[e.jsx($e,{status:r.status}),e.jsx("span",{className:"flex-1 text-[11px] truncate",children:ee(r.gate_name)}),r.duration_ms!=null&&e.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground shrink-0",children:[(r.duration_ms/1e3).toFixed(1),"s"]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/50 shrink-0",children:[e.jsx(pe,{className:"inline h-2.5 w-2.5 mr-0.5"}),L(new Date(r.run_at),{addSuffix:!0})]})]},r.id))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/50 mb-1.5 block",children:"Gate History"}),s.length===0?e.jsx(H,{height:100,message:"No history data"}):e.jsx(S,{width:"100%",height:Math.max(100,s.length*16),children:e.jsxs(I,{data:s.map(r=>({name:r.gate_name.replace(/-/g," ").slice(0,12),passed:r.passed,failed:r.failed})),layout:"vertical",margin:{left:0,right:8,top:0,bottom:0},children:[e.jsx(E,{type:"number",hide:!0}),e.jsx(_,{dataKey:"name",type:"category",width:80,tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),e.jsx(A,{contentStyle:O}),e.jsx(w,{dataKey:"passed",stackId:"a",radius:[0,0,0,0],children:s.map((r,c)=>e.jsx(C,{fill:"#00c853"},c))}),e.jsx(w,{dataKey:"failed",stackId:"a",radius:[0,4,4,0],children:s.map((r,c)=>e.jsx(C,{fill:"#ff1744"},c))})]})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/50 mb-1.5 block",children:"Gate Duration"}),t.some(r=>r.duration_ms!=null)?e.jsx(S,{width:"100%",height:Math.max(100,t.filter(r=>r.duration_ms!=null).length*16),children:e.jsxs(I,{data:t.filter(r=>r.duration_ms!=null).map(r=>({name:r.gate_name.replace(/-/g," ").slice(0,12),seconds:Number((r.duration_ms/1e3).toFixed(1)),status:r.status})),layout:"vertical",margin:{left:0,right:8,top:0,bottom:0},children:[e.jsx(E,{type:"number",unit:"s",tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),e.jsx(_,{dataKey:"name",type:"category",width:80,tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),e.jsx(A,{formatter:r=>[`${r}s`,"Duration"],contentStyle:O}),e.jsx(w,{dataKey:"seconds",radius:[0,4,4,0],children:t.filter(r=>r.duration_ms!=null).map((r,c)=>e.jsx(C,{fill:r.status==="pass"?"#00c85340":r.status==="fail"?"#ff174440":"#06b6d440"},c))})]})}):e.jsx(H,{height:100,message:"No duration data"})]})]})]})})]})}function H({height:t,message:s}){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{style:{height:t},className:"opacity-30",children:e.jsx(S,{width:"100%",height:t,children:e.jsxs(I,{data:[{name:"",value:0}],layout:"vertical",margin:{left:10,right:20,top:0,bottom:0},children:[e.jsx(J,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.4}),e.jsx(E,{type:"number",domain:[0,10],tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),e.jsx(_,{dataKey:"name",type:"category",width:80,tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}})]})})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:s})})]})}function Ze(){return e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(he,{}),e.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[e.jsx(fe,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Guards"})]}),e.jsxs("div",{className:"flex flex-1 min-h-0 gap-4",children:[e.jsx("div",{className:"flex w-1/2 min-w-0 flex-col overflow-y-auto rounded-lg border border-border/50",children:e.jsx(Ie,{})}),e.jsxs("div",{className:"flex w-1/2 min-w-0 flex-col space-y-4",children:[e.jsx(Re,{}),e.jsx(Ke,{})]})]})]})}export{Ze as QualityGates};
@@ -0,0 +1 @@
1
+ import{j as e}from"./ui-BmsSg9jU.js";import{a as d}from"./vendor-Bqt8AJn2.js";import{q,ai as J,s as B,w as K,U as D,B as y,g as F,a as T,a9 as b,aj as E,ak as U,a7 as V,h as W,f as Q}from"./index-o4ScMAuR.js";import{F as X}from"./file-text-J1cebZXF.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}=q(),[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}=J(),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(K,{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(V,{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-BmsSg9jU.js";import{a as c}from"./vendor-Bqt8AJn2.js";import{c as Se,q as Te,V as he,s as ye,C as Pe,b as $e,R as M,h as O,al as H,B as xe,a as v,a1 as pe,a3 as fe,a4 as ge,a5 as je,ak as w,am as G,J as Ae,an as be,a6 as Ee,S as Ue,ao as _e,F as we,ap as Ie,aq as Be,T as ze,ar as Ve,a8 as He,E as Je,as as Ge,d as We,at as Ke,au as Le,av as Ye,aw as qe,P as V,X as De,ax as Oe,ay as ke,az as Xe,aA as Qe,aB as Ze,g as et}from"./index-o4ScMAuR.js";import{M as J}from"./minus-CHBsJyjp.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 tt=[["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"}]],Me=Se("archive",tt);/**
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 st=[["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"}]],at=Se("skip-forward",st);function nt(){const{getApiBase:t}=Te(),[r,s]=c.useState(null),[o,n]=c.useState(null),[a,i]=c.useState([]),[h,u]=c.useState(null),[d,j]=c.useState(null),[y,x]=c.useState(null),[l,g]=c.useState(null),[m,S]=c.useState(null),[f,T]=c.useState(null),[U,W]=c.useState(null),[Z,ee]=c.useState(!0),[_,b]=c.useState(null),E=c.useCallback(async()=>{try{const p=await fetch("/api/orbital/aggregate/manifest/status");if(p.ok){const N=await p.json();s(N)}}catch{}finally{ee(!1)}},[]),C=c.useCallback(async p=>{try{const N=await fetch(`${t(p)}/manifest/files`);if(N.ok){const F=await N.json();i(F.data??[])}}catch{}},[t]);c.useEffect(()=>{E()},[E]),he(()=>{E(),o&&C(o)}),c.useEffect(()=>{const p=()=>{E(),o&&C(o)};return ye.on("manifest:changed",p),()=>{ye.off("manifest:changed",p)}},[E,C,o]);const te=c.useCallback(p=>{if(o===p){n(null),i([]);return}n(p),i([]),C(p)},[o,C]),se=c.useCallback(()=>{n(null),i([])},[]),K=c.useCallback(async()=>{b("update-all");try{await fetch("/api/orbital/aggregate/manifest/update-all",{method:"POST",headers:{"Content-Type":"application/json"}}),await E()}catch{}finally{b(null)}},[E]),L=c.useCallback(async p=>{b(`preview:${p}`);try{const N=await fetch(`${t(p)}/manifest/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:!0})});if(N.ok){const F=await N.json();j(F.data),x(p)}}catch{}finally{b(null)}},[t]),ae=c.useCallback(async p=>{b(`update:${p}`);try{(await fetch(`${t(p)}/manifest/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:!1})})).ok&&(j(null),x(null),await E())}catch{}finally{b(null)}},[t,E]),I=c.useCallback(async p=>{b(`init:${p}`);try{await fetch(`${t(p)}/manifest/init`,{method:"POST",headers:{"Content-Type":"application/json"}}),await E()}catch{}finally{b(null)}},[t,E]),ne=c.useCallback(async p=>{b(`validate:${p}`);try{const N=await fetch(`${t(p)}/manifest/validate`);if(N.ok){const F=await N.json();u(F.data)}}catch{}finally{b(null)}},[t]),re=c.useCallback(async(p,N,F)=>{b(`pin:${N}`);try{await fetch(`${t(p)}/manifest/pin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:N,reason:F})})}catch{}finally{b(null)}},[t]),Y=c.useCallback(async(p,N)=>{b(`unpin:${N}`);try{await fetch(`${t(p)}/manifest/unpin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:N})})}catch{}finally{b(null)}},[t]),q=c.useCallback(async(p,N)=>{b(`reset:${N}`);try{await fetch(`${t(p)}/manifest/reset`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:N})})}catch{}finally{b(null)}},[t]),X=c.useCallback(async(p,N)=>{b(`revert:${N}`);try{await fetch(`${t(p)}/manifest/revert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:N})})}catch{}finally{b(null)}},[t]),Q=c.useCallback(async(p,N,F)=>{var Ne;b(`diff:${N}`),S(N),T(F??null),W(p);try{const ve=await fetch(`${t(p)}/manifest/diff?file=${encodeURIComponent(N)}`);if(ve.ok){const Re=await ve.json();g(((Ne=Re.data)==null?void 0:Ne.diff)??null)}}catch{}finally{b(null)}},[t]),k=c.useCallback(()=>{g(null),S(null),T(null),W(null)},[]),P=c.useCallback(()=>{j(null),x(null)},[]),le=c.useCallback(()=>u(null),[]);return{summary:r,loading:Z,actionLoading:_,expandedProjectId:o,projectFiles:a,validation:h,updatePreview:d,updatePreviewProjectId:y,diffContent:l,diffFile:m,diffFileStatus:f,diffProjectId:U,expandProject:te,collapseProject:se,fetchSummary:E,updateAll:K,previewProjectUpdate:L,applyProjectUpdate:ae,clearUpdatePreview:P,initProject:I,validateProject:ne,clearValidation:le,pinFile:re,unpinFile:Y,resetFile:q,revertFile:X,getDiff:Q,clearDiff:k}}function rt({files:t,actionLoading:r,onPin:s,onUnpin:o,onReset:n,onRevert:a,onDiff:i}){const h=t.filter(l=>l.status==="missing"),u=t.filter(l=>l.status==="outdated"),d=t.filter(l=>l.status==="modified"),j=t.filter(l=>l.status==="pinned"),y=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(B,{title:`Missing (${h.length})`,description:"expected but not found on disk",files:h,defaultOpen:!0,renderRow:l=>e.jsx(z,{file:l,children:e.jsx(D,{label:"Restore",variant:"cyan",onClick:()=>n(l.path),loading:r===`reset:${l.path}`})},l.path)}),e.jsx(B,{title:`Outdated (${u.length})`,description:"newer template version available",files:u,defaultOpen:!1,renderRow:l=>e.jsxs(z,{file:l,children:[e.jsx(D,{label:"View changes",onClick:()=>i(l.path,l.status),loading:r===`diff:${l.path}`}),e.jsx(D,{label:"Update",variant:"cyan",onClick:()=>n(l.path),loading:r===`reset:${l.path}`}),l.hasPrev&&e.jsx(D,{label:"Revert",onClick:()=>a(l.path),loading:r===`revert:${l.path}`})]},l.path)}),e.jsx(B,{title:`Modified (${d.length})`,description:"edited by you",files:d,defaultOpen:!1,renderRow:l=>e.jsxs(z,{file:l,children:[e.jsx(D,{label:"View changes",onClick:()=>i(l.path,l.status),loading:r===`diff:${l.path}`}),e.jsx(D,{label:"Reset",onClick:()=>n(l.path),loading:r===`reset:${l.path}`}),e.jsx(D,{label:"Pin",variant:"blue",onClick:()=>s(l.path),loading:r===`pin:${l.path}`}),l.hasPrev&&e.jsx(D,{label:"Revert",onClick:()=>a(l.path),loading:r===`revert:${l.path}`})]},l.path)}),e.jsx(B,{title:`Pinned (${j.length})`,description:"locked from updates",files:j,defaultOpen:!1,renderRow:l=>e.jsxs(z,{file:l,meta:l.pinnedReason?`"${l.pinnedReason}"`:void 0,children:[e.jsx(D,{label:"View changes",onClick:()=>i(l.path,l.status),loading:r===`diff:${l.path}`}),e.jsx(D,{label:"Unpin",onClick:()=>o(l.path),loading:r===`unpin:${l.path}`}),e.jsx(D,{label:"Reset",onClick:()=>n(l.path),loading:r===`reset:${l.path}`}),l.hasPrev&&e.jsx(D,{label:"Revert",onClick:()=>a(l.path),loading:r===`revert:${l.path}`})]},l.path)}),e.jsx(B,{title:`Synced (${y.length})`,description:"matches template",files:y,defaultOpen:!1,renderRow:l=>e.jsx(z,{file:l,children:l.hasPrev&&e.jsx(D,{label:"Revert",onClick:()=>a(l.path),loading:r===`revert:${l.path}`})},l.path)}),e.jsx(B,{title:`User (${x.length})`,description:"your files, not managed",files:x,defaultOpen:!1,renderRow:l=>e.jsx(z,{file:l},l.path)})]})}function B({title:t,description:r,files:s,defaultOpen:o,renderRow:n}){const[a,i]=c.useState(o);return s.length===0?null:e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{onClick:()=>i(!a),className:"flex items-center gap-1.5 text-xs text-muted-foreground/70 hover:text-muted-foreground transition-colors mb-1",children:[a?e.jsx(Pe,{className:"h-3 w-3"}):e.jsx($e,{className:"h-3 w-3"}),e.jsx("span",{children:t}),e.jsx("span",{className:"text-muted-foreground/40 font-normal",children:r})]}),a&&e.jsx("div",{className:"space-y-1.5 ml-4",children:s.map(n)})]})}function z({file:t,meta:r,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}),r&&e.jsx("span",{className:"text-xs text-muted-foreground/40 italic",children:r}),s]})}function D({label:t,variant:r,onClick:s,loading:o}){const n="rounded border px-1.5 py-0 text-[10px] leading-5 transition-colors disabled:opacity-40",a={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:`${n} ${a[r??"default"]}`,children:[o?e.jsx(M,{className:"h-3 w-3 animate-spin inline mr-1"}):null,t]})}function lt({project:t,expanded:r,files:s,actionLoading:o,onToggle:n,onUpdate:a,onInit:i,onPin:h,onUnpin:u,onReset:d,onRevert:j,onDiff:y}){const{projectId:x,projectName:l,projectColor:g,status:m,manifest:S}=t;if(m==="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(${g})`}}),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(O,{size:"sm",variant:"outline",onClick:i,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(M,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(H,{className:"h-3 w-3 mr-1"}),"Initialize"]})]})});if(m==="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(${g})`}}),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 f=S,T=f.files.outdated>0||f.files.missing>0||f.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:n,children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:`hsl(${g})`}}),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",f.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",f.installedVersion]}),f.needsUpdate&&e.jsxs("span",{className:"text-[10px] text-amber-400/60 shrink-0",children:["→ v",f.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",f.files.missing>0?"text-red-400":"text-red-400/25"),children:[f.files.missing," missing"]}),e.jsxs("span",{className:v("w-[80px] text-center",f.files.outdated>0?"text-amber-400":"text-amber-400/25"),children:[f.files.outdated," outdated"]}),e.jsxs("span",{className:v("w-[80px] text-center",f.files.modified>0?"text-orange-400":"text-orange-400/25"),children:[f.files.modified," modified"]}),e.jsxs("span",{className:v("w-[80px] text-center",f.files.pinned>0?"text-blue-400":"text-blue-400/25"),children:[f.files.pinned," pinned"]}),e.jsxs("span",{className:v("w-[80px] text-center",f.files.synced>0?"text-green-400/50":"text-green-400/20"),children:[f.files.synced," synced"]}),e.jsxs("span",{className:v("w-[80px] text-center",f.files.userOwned>0?"text-muted-foreground/40":"text-muted-foreground/20"),children:[f.files.userOwned," user"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs(O,{size:"sm",variant:"outline",onClick:T?a:void 0,disabled:!T||o===`preview:${x}`||o===`update:${x}`,className:v("h-6 px-2 text-xs w-auto sm:w-[130px] justify-center",T?"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(M,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(H,{className:"h-3 w-3 mr-1"}),T?"Update Project":"Up to Date"]}),e.jsx("button",{onClick:n,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:r?e.jsx(Pe,{className:"h-3.5 w-3.5"}):e.jsx($e,{className:"h-3.5 w-3.5"})})]})]}),r&&e.jsx(rt,{files:s,actionLoading:o,onPin:h,onUnpin:u,onReset:d,onRevert:j,onDiff:y})]})}function it({updatePreview:t,projectName:r,updatePreviewProjectId:s,actionLoading:o,onApply:n,onClose:a}){return e.jsx(pe,{open:t!==null,onOpenChange:i=>{i||a()},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 ",r]}),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(G,{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(i=>e.jsx("div",{className:"text-xs font-mono text-cyan-400/70",children:i},i)),t.toAdd.map(i=>e.jsxs("div",{className:"text-xs font-mono text-green-400/70",children:[i," ",e.jsx("span",{className:"text-muted-foreground/40",children:"(new)"})]},i))]})]})]}),t.toRename.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ae,{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(i=>e.jsxs("div",{className:"text-xs font-mono text-purple-400/70",children:[i.from," → ",i.to]},i.from))})]})]}),t.toRemove.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(J,{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(i=>e.jsx("div",{className:"text-xs font-mono text-red-400/70",children:i},i))})]})]}),t.toSkip.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(at,{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(i=>e.jsxs("div",{className:"text-xs font-mono text-muted-foreground/40",children:[i.file," ",e.jsxs("span",{className:"text-muted-foreground/30",children:["(",i.reason,")"]})]},i.file))})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Me,{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(O,{variant:"ghost",size:"sm",children:"Cancel"})}),t&&!t.isEmpty&&s&&e.jsxs(O,{size:"sm",onClick:()=>n(s),disabled:o===`update:${s}`,className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[o===`update:${s}`&&e.jsx(M,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update Project"]})]})]})})}function ot({open:t,onOpenChange:r,summary:s,actionLoading:o,onUpdateAll:n}){return e.jsx(pe,{open:t,onOpenChange:r,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(Ee,{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(G,{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(a=>a.manifest&&(a.manifest.files.outdated>0||a.manifest.files.missing>0)).length," project",s.projects.filter(a=>a.manifest&&(a.manifest.files.outdated>0||a.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(Ue,{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(Me,{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(O,{variant:"ghost",size:"sm",children:"Cancel"})}),e.jsxs(O,{size:"sm",onClick:()=>{r(!1),n()},disabled:o==="update-all",className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[o==="update-all"&&e.jsx(M,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update All Projects"]})]})]})})}function ct(t){const r=t.split(`
12
+ `),s=[];let o=0,n=0;for(const a of r){const i=a.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@(.*)/);if(i){o=parseInt(i[1],10),n=parseInt(i[2],10),s.push({type:"hunk",content:a});continue}if(a.startsWith("diff ")||a.startsWith("index ")||a.startsWith("--- ")||a.startsWith("+++ ")){s.push({type:"meta",content:a});continue}if(a.startsWith("-"))s.push({type:"remove",content:a.slice(1),oldNum:o}),o++;else if(a.startsWith("+"))s.push({type:"add",content:a.slice(1),newNum:n}),n++;else{const h=a.startsWith(" ")?a.slice(1):a;s.push({type:"context",content:h,oldNum:o,newNum:n}),o++,n++}}return s}function dt({diff:t}){const r=ct(t),s=r.reduce((n,a)=>Math.max(n,a.oldNum??0,a.newNum??0),0),o=String(s).length;return e.jsx("div",{className:"text-[11px] font-mono leading-[1.6] pb-1",children:r.map((n,a)=>{if(n.type==="meta")return null;if(n.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:n.content},a);const i=n.oldNum!=null?String(n.oldNum).padStart(o):"".padStart(o),h=n.newNum!=null?String(n.newNum).padStart(o):"".padStart(o),u=v("flex",n.type==="add"&&"bg-green-500/10",n.type==="remove"&&"bg-red-500/10"),d=v("select-none border-r border-border/40 px-2 text-right shrink-0",n.type==="add"&&"text-green-400/40",n.type==="remove"&&"text-red-400/40",n.type==="context"&&"text-muted-foreground/25"),j=v("px-3 whitespace-pre-wrap break-all flex-1 min-w-0",n.type==="add"&&"text-green-400",n.type==="remove"&&"text-red-400",n.type==="context"&&"text-foreground/50"),y=n.type==="add"?"+":n.type==="remove"?"-":" ";return e.jsxs("div",{className:u,children:[e.jsx("span",{className:d,children:i}),e.jsx("span",{className:d,children:h}),e.jsx("span",{className:v("w-4 text-center shrink-0 select-none",n.type==="add"&&"text-green-400/60",n.type==="remove"&&"text-red-400/60",n.type==="context"&&"text-transparent"),children:y}),e.jsx("span",{className:j,children:n.content||" "})]},a)})})}function xt({diffFile:t,diffContent:r,diffFileStatus:s,diffProjectId:o,actionLoading:n,onResetFile:a,onClearDiff:i}){return e.jsx(pe,{open:t!==null,onOpenChange:h=>{h||i()},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(Ee,{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:r?e.jsx(dt,{diff:r}):e.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-sm",children:[e.jsx(M,{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(O,{variant:"ghost",size:"sm",children:"Close"})}),s==="outdated"&&o&&e.jsxs(O,{size:"sm",onClick:()=>{a(o,t),i()},disabled:n===`reset:${t}`,className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[n===`reset:${t}`&&e.jsx(M,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update to latest"]}),s==="modified"&&o&&e.jsxs(O,{size:"sm",onClick:()=>{a(o,t),i()},disabled:n===`reset:${t}`,variant:"outline",children:[n===`reset:${t}`&&e.jsx(M,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Reset to template"]})]})]})})}function mt(){var Q;const{summary:t,loading:r,actionLoading:s,expandedProjectId:o,projectFiles:n,updatePreview:a,updatePreviewProjectId:i,diffContent:h,diffFile:u,diffFileStatus:d,diffProjectId:j,expandProject:y,updateAll:x,previewProjectUpdate:l,applyProjectUpdate:g,clearUpdatePreview:m,initProject:S,pinFile:f,unpinFile:T,resetFile:U,revertFile:W,getDiff:Z,clearDiff:ee}=nt(),{version:_,updateAvailable:b,behindCount:E,updateStage:C,updateError:te,checkForUpdate:se,performUpdate:K}=_e(),L=c.useRef(C);L.current=C;const ae=c.useCallback(async()=>{await K(),L.current!=="error"&&await x()},[K,x]),I=C==="pulling"||C==="installing",ne=C==="checking"||C==="checked",[re,Y]=c.useState(!1);if(r)return e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(M,{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 P;return k.status==="ok"&&!((P=k.manifest)!=null&&P.needsUpdate)})&&t.noManifest===0&&t.totalOutdated===0&&t.totalMissing===0&&t.totalModified===0&&t.totalPinned===0,X=t.projects.filter(k=>{var P;return k.status==="ok"&&((P=k.manifest)==null?void 0:P.needsUpdate)}).length;return e.jsxs(e.Fragment,{children:[_&&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(H,{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",b?"border-emerald-500/30 text-emerald-400 bg-emerald-500/10":"border-green-500/30 text-green-400 bg-green-500/10"),children:["v",_.version]}),b&&e.jsxs("span",{className:"text-xs text-emerald-400/70",children:[E," update",E!==1?"s":""," available"]}),C==="checked"&&!b&&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}),I&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(M,{className:"h-3 w-3 animate-spin"}),C==="pulling"?"Pulling...":"Installing..."]})]}),e.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[e.jsxs(O,{size:"sm",variant:"ghost",onClick:se,disabled:I||ne,className:"h-7 px-2 text-xs",children:[C==="checked"&&!b?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"&&!b?"Latest":"Check"]}),b&&C!=="done"&&e.jsxs(O,{size:"sm",variant:"outline",onClick:ae,disabled:I,className:"h-7 px-2.5 text-xs border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10",children:[I?e.jsx(M,{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"}),_&&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",_.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(O,{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(H,{className:"h-3 w-3 mr-1"}),"Up to Date"]}):e.jsxs(O,{size:"sm",variant:"outline",onClick:()=>Y(!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(M,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(H,{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(lt,{project:k,expanded:o===k.projectId,files:o===k.projectId?n:[],actionLoading:s,onToggle:()=>y(k.projectId),onUpdate:()=>l(k.projectId),onInit:()=>S(k.projectId),onPin:P=>f(k.projectId,P),onUnpin:P=>T(k.projectId,P),onReset:P=>U(k.projectId,P),onRevert:P=>W(k.projectId,P),onDiff:(P,le)=>Z(k.projectId,P,le)},k.projectId))}),e.jsx(it,{updatePreview:a,projectName:(Q=t.projects.find(k=>k.projectId===i))==null?void 0:Q.projectName,updatePreviewProjectId:i,actionLoading:s,onApply:g,onClose:m}),e.jsx(ot,{open:re,onOpenChange:Y,summary:t,actionLoading:s,onUpdateAll:x}),e.jsx(xt,{diffFile:u,diffContent:h,diffFileStatus:d,diffProjectId:j,actionLoading:s,onResetFile:U,onClearDiff:ee})]})}function ut(){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(mt,{})]})}function ht(){const{projects:t}=Te(),[r,s]=c.useState(!1),[o,n]=c.useState(null),[a,i]=c.useState(null),[h,u]=c.useState(null),[d,j]=c.useState(null),y=c.useRef(null);async function x(m,S){i(m),u(null);try{const f=await fetch(`/api/orbital/projects/${m}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)});if(!f.ok){const T=await f.json().catch(()=>({}));u(T.error??`Failed to update project (HTTP ${f.status})`)}}catch{u("Failed to update project")}finally{i(null)}}async function l(m){i(m),u(null);try{const S=await fetch(`/api/orbital/projects/${m}`,{method:"DELETE"});if(!S.ok){const f=await S.json().catch(()=>({}));u(f.error??`Failed to remove project (HTTP ${S.status})`)}}catch{u("Failed to remove project")}finally{i(null),j(null)}}async function g(m){if(!m||m.length===0)return;const f=m[0].webkitRelativePath.split("/")[0];n(null),s(!0);try{const T=await fetch("/api/orbital/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:f})});if(!T.ok){const U=await T.json().catch(()=>({}));throw new Error(U.error??`HTTP ${T.status}`)}}catch(T){n(T instanceof Error?T.message:"Failed to add project")}finally{s(!1),y.current&&(y.current.value="")}}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(m=>e.jsx(pt,{project:m,updating:a===m.id,confirmDelete:d===m.id,onUpdate:S=>x(m.id,S),onDeleteRequest:()=>j(m.id),onDeleteConfirm:()=>l(m.id),onDeleteCancel:()=>j(null)},m.id)),e.jsxs("div",{onClick:()=>{var m;return!r&&((m=y.current)==null?void 0:m.click())},className:v("flex items-center gap-3 rounded border border-dashed border-white/[0.08] px-3 py-2","text-muted-foreground hover:text-foreground hover:border-primary/30 hover:bg-white/[0.03]","transition-colors cursor-pointer",r&&"opacity-50 pointer-events-none"),children:[e.jsx(Ve,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"text-xs",children:r?"Adding...":"Add Project"})]}),e.jsx("input",{ref:y,type:"file",webkitdirectory:"",className:"hidden",onChange:m=>g(m.target.files)}),(o||h)&&e.jsx("p",{className:"text-[11px] text-destructive",children:o||h})]})]})}function pt({project:t,updating:r,confirmDelete:s,onUpdate:o,onDeleteRequest:n,onDeleteConfirm:a,onDeleteCancel:i}){const[h,u]=c.useState(!1),[d,j]=c.useState(t.name),y=c.useRef(null);c.useEffect(()=>{var m;h&&((m=y.current)==null||m.focus())},[h]),c.useEffect(()=>{h||j(t.name)},[t.name,h]);const x=d.trim()!==""&&d.trim()!==t.name,l=c.useCallback(()=>{u(!1);const m=d.trim();m&&m!==t.name?o({name:m}):j(t.name)},[d,t.name,o]),g=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(ft,{value:t.color,onChange:m=>o({color:m}),disabled:r}),e.jsxs("div",{className:"flex-1 min-w-0",children:[h?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{ref:y,value:d,onChange:m=>j(m.target.value),onBlur:()=>{j(t.name),u(!1)},onKeyDown:m=>{m.key==="Enter"&&l(),m.key==="Escape"&&(j(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:m=>{m.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",g),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:a,disabled:r,className:"text-destructive hover:text-destructive/80 font-medium transition-colors disabled:opacity-50",children:"Yes"}),e.jsx("button",{onClick:i,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:r,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:n,disabled:r,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 ft({value:t,onChange:r,disabled:s}){return e.jsxs(Ke,{children:[e.jsx(Le,{asChild:!0,children:e.jsx("button",{disabled:s,className:"h-5 w-5 rounded-full border border-white/20 shrink-0 transition-shadow hover:shadow-[0_0_8px_currentColor] disabled:opacity-50",style:{backgroundColor:`hsl(${t})`},title:"Change color"})}),e.jsx(Ye,{side:"bottom",align:"start",className:"w-auto p-2",children:e.jsx("div",{className:"grid grid-cols-5 gap-2",children:qe.map(o=>e.jsx("button",{onClick:()=>r(o),className:v("h-6 w-6 rounded-full border-2 transition-transform hover:scale-110",o===t?"border-white shadow-[0_0_8px_hsl(var(--primary))]":"border-transparent hover:border-white/40"),style:{backgroundColor:`hsl(${o})`}},o))})})]})}function A({checked:t,onCheckedChange:r,disabled:s}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:s,onClick:()=>r(!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},gt={staleTimeoutMinutes:10,maxBatchSize:20,maxConcurrent:0,envVars:{}},oe="/api/orbital/aggregate/config/dispatch-flags";function jt(){const[t,r]=c.useState(ie),[s,o]=c.useState(!0),[n,a]=c.useState(!1),[i,h]=c.useState(null),u=c.useRef(t);u.current=t;const d=c.useCallback(async()=>{try{const x=await fetch(oe);if(!x.ok)throw new Error(`HTTP ${x.status}`);const{data:l}=await x.json();r(l),h(null)}catch(x){console.warn("[Orbital] Dispatch flags fetch failed:",x),h("Failed to load dispatch settings")}finally{o(!1)}},[]),j=c.useCallback(async x=>{const l={...u.current,...x};r(l),a(!0),h(null);try{const g=await fetch(oe,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!g.ok){const S=await g.json().catch(()=>({}));throw new Error(S.error??`HTTP ${g.status}`)}const{data:m}=await g.json();r(m)}catch(g){console.warn("[Orbital] Dispatch flags update failed:",g),h(g instanceof Error?g.message:"Failed to save"),d()}finally{a(!1)}},[d]),y=c.useCallback(async()=>{r(ie),a(!0),h(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();r(l)}catch(x){console.warn("[Orbital] Dispatch flags reset failed:",x),h("Failed to reset"),d()}finally{a(!1)}},[d]);return c.useEffect(()=>{d()},[d]),he(d),{flags:t,loading:s,saving:n,error:i,updateFlags:j,resetToDefaults:y}}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:r,options:s,disabled:o,label:n}){return e.jsx("div",{role:"group","aria-label":n,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(a=>e.jsx("button",{onClick:()=>r(a.value),disabled:o,"aria-pressed":t===a.value,className:`px-2.5 py-1 text-xs rounded-[3px] transition-all duration-150 ${t===a.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:a.label},a.value))})}function $({label:t,description:r,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:r})]}),e.jsx("div",{className:"flex-shrink-0",children:s})]})}function Ce({label:t,description:r,value:s,onChange:o,disabled:n}){const[a,i]=c.useState(""),h=()=>{const u=a.trim();u&&!s.includes(u)&&(o([...s,u]),i(""))};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:r})]}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{type:"text",value:a,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),h())},disabled:n,placeholder:"Tool name (e.g. Read, Bash)","aria-label":`Add ${t.toLowerCase()}`,className:me}),e.jsx("button",{onClick:h,disabled:n||!a.trim(),"aria-label":`Add tool to ${t.toLowerCase()}`,className:R+" !w-8 !h-8",children:e.jsx(V,{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(d=>d!==u)),disabled:n,"aria-label":`Remove ${u}`,className:"text-muted-foreground/60 hover:text-foreground transition-colors",children:e.jsx(De,{className:"h-3 w-3"})})]},u))})]})}function bt({value:t,onChange:r,disabled:s}){const[o,n]=c.useState(""),[a,i]=c.useState(""),h=Object.entries(t),u=()=>{const d=o.trim();d&&(r({...t,[d]:a}),n(""),i(""))};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:d=>n(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.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:a,onChange:d=>i(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.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(V,{className:"h-3.5 w-3.5"})})]})]}),h.length>0&&e.jsx("div",{className:"flex flex-col gap-1.5",children:h.map(([d,j])=>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:d}),e.jsx("span",{className:"text-xs text-muted-foreground/60",children:"="}),e.jsx("span",{className:"text-xs text-muted-foreground flex-1 truncate",children:j}),e.jsx("button",{onClick:()=>{const y={...t};delete y[d],r(y)},disabled:s,"aria-label":`Remove ${d}`,className:"text-muted-foreground/60 hover:text-foreground transition-colors",children:e.jsx(De,{className:"h-3 w-3"})})]},d))})]})}function Nt(){const{flags:t,loading:r,saving:s,error:o,updateFlags:n,resetToDefaults:a}=jt();return e.jsxs("section",{className:`card-glass settings-panel rounded-xl p-5 ${r?"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:a,disabled:s||r,className:Fe,children:[e.jsx(G,{className:"h-3 w-3"}),"Reset to defaults"]})]}),e.jsx($,{label:"Permission Mode",description:"How permission prompts are handled in dispatched sessions",children:e.jsx(ue,{label:"Permission Mode",value:t.permissionMode,onChange:i=>n({permissionMode:i}),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($,{label:"Verbose Logging",description:"Enable verbose CLI output in dispatched sessions",children:e.jsx(A,{checked:t.verbose,onCheckedChange:i=>n({verbose:i}),disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx($,{label:"No Markdown",description:"Disable markdown rendering in terminal output",children:e.jsx(A,{checked:t.noMarkdown,onCheckedChange:i=>n({noMarkdown:i}),disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx($,{label:"Print Mode",description:"Force non-interactive mode for single dispatches",children:e.jsx(A,{checked:t.printMode,onCheckedChange:i=>n({printMode:i}),disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx($,{label:"Output Format",description:"Output format for non-interactive mode",children:e.jsx(ue,{label:"Output Format",value:t.outputFormat,onChange:i=>n({outputFormat:i}),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:i=>n({allowedTools:i}),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:i=>n({disallowedTools:i}),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:i=>n({appendSystemPrompt:i.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={...gt,terminalAdapter:"auto"},de="/api/orbital/aggregate/config/dispatch-settings";function vt(){const[t,r]=c.useState(ce),[s,o]=c.useState(!0),[n,a]=c.useState(!1),[i,h]=c.useState(null),u=c.useRef(t);u.current=t;const d=c.useCallback(async()=>{try{const x=await fetch(de);if(!x.ok)throw new Error(`HTTP ${x.status}`);const{data:l}=await x.json();r(l),h(null)}catch(x){console.warn("[Orbital] Dispatch settings fetch failed:",x),h("Failed to load dispatch operations")}finally{o(!1)}},[]),j=c.useCallback(async x=>{const l={...u.current,...x};r(l),a(!0),h(null);try{const g=await fetch(de,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!g.ok){const S=await g.json().catch(()=>({}));throw new Error(S.error??`HTTP ${g.status}`)}const{data:m}=await g.json();r(m)}catch(g){console.warn("[Orbital] Dispatch settings update failed:",g),h(g instanceof Error?g.message:"Failed to save"),d()}finally{a(!1)}},[d]),y=c.useCallback(async()=>{r(ce),a(!0),h(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();r(l)}catch(x){console.warn("[Orbital] Dispatch settings reset failed:",x),h("Failed to reset"),d()}finally{a(!1)}},[d]);return c.useEffect(()=>{d()},[d]),he(d),{settings:t,loading:s,saving:n,error:i,updateSettings:j,resetToDefaults:y}}function yt(){const{settings:t,loading:r,saving:s,error:o,updateSettings:n,resetToDefaults:a}=vt();return e.jsxs("section",{className:`card-glass settings-panel rounded-xl p-5 ${r?"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:a,disabled:s||r,className:Fe,children:[e.jsx(G,{className:"h-3 w-3"}),"Reset to defaults"]})]}),e.jsx($,{label:"Terminal Adapter",description:"How dispatch windows are opened",children:e.jsx(ue,{label:"Terminal Adapter",value:t.terminalAdapter,onChange:i=>n({terminalAdapter:i}),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($,{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:()=>n({staleTimeoutMinutes:Math.max(1,t.staleTimeoutMinutes-1)}),disabled:s||t.staleTimeoutMinutes<=1,className:R,children:e.jsx(J,{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:()=>n({staleTimeoutMinutes:t.staleTimeoutMinutes+1}),disabled:s,className:R,children:e.jsx(V,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx($,{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:()=>n({maxBatchSize:Math.max(1,t.maxBatchSize-1)}),disabled:s||t.maxBatchSize<=1,className:R,children:e.jsx(J,{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:()=>n({maxBatchSize:t.maxBatchSize+1}),disabled:s,className:R,children:e.jsx(V,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx($,{label:"Max Concurrent",description:"Limit simultaneous dispatches, 0 = unlimited",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>n({maxConcurrent:Math.max(0,t.maxConcurrent-1)}),disabled:s||t.maxConcurrent<=0,className:R,children:e.jsx(J,{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:()=>n({maxConcurrent:t.maxConcurrent+1}),disabled:s,className:R,children:e.jsx(V,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx(bt,{value:t.envVars,onChange:i=>n({envVars:i}),disabled:s})]})}const wt={monospace:"Monospace","sans-serif":"Sans-Serif",display:"Display"},kt=["monospace","sans-serif","display"];function Ct(){var n;const{settings:t,updateSetting:r}=Oe(),s=()=>{const a=Math.max(.8,Math.round((t.fontScale-.05)*100)/100);r("fontScale",a)},o=()=>{const a=Math.min(1.3,Math.round((t.fontScale+.05)*100)/100);r("fontScale",a)};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($,{label:"Font Family",description:"Typeface used across the dashboard",children:e.jsx("select",{value:t.fontFamily,onChange:a=>r("fontFamily",a.target.value),style:{fontFamily:`'${t.fontFamily}', ${((n=ke.find(a=>a.family===t.fontFamily))==null?void 0:n.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:kt.map(a=>e.jsx("optgroup",{label:wt[a],children:ke.filter(i=>i.category===a).map(i=>e.jsxs("option",{value:i.family,children:[i.label,i.family==="Space Grotesk"?" (default)":""]},i.family))},a))})}),e.jsx(w,{className:"my-4"}),e.jsx($,{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(J,{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(V,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx($,{label:"Reduce Motion",description:"Disable animations and transitions",children:e.jsx(A,{checked:t.reduceMotion,onCheckedChange:a=>r("reduceMotion",a)})}),e.jsx(w,{className:"my-4"}),e.jsx($,{label:"Background Effects",description:"Animated orbs and grid overlay",children:e.jsx(A,{checked:t.showBackgroundEffects,onCheckedChange:a=>r("showBackgroundEffects",a)})})]})}function St(){const{settings:t,updateSetting:r}=Oe();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($,{label:"Status Bar",description:"Scope progress bar at bottom",children:e.jsx(A,{checked:t.showStatusBar,onCheckedChange:s=>r("showStatusBar",s)})}),e.jsx(w,{className:"my-4"}),e.jsx($,{label:"Compact Mode",description:"Reduce spacing for denser layout",children:e.jsx(A,{checked:t.compactMode,onCheckedChange:s=>r("compactMode",s)})})]})}function Ot(){const{restart:t}=Xe();return c.useEffect(()=>{Qe()},[]),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(Ze,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Settings"})]}),e.jsx(et,{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(ut,{})}),e.jsx("div",{className:"lg:[column-span:all]",children:e.jsx(ht,{})}),e.jsx(Nt,{}),e.jsx(yt,{}),e.jsx(Ct,{}),e.jsx(St,{}),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($,{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(G,{className:"h-3 w-3"}),"Restart tour"]})})]})]})})]})}export{Ot as Settings};