@davidbalzan/groundwork-console 0.1.3 → 0.1.5

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 (100) hide show
  1. package/dist/answered.js +35 -2
  2. package/dist/groundwork.js +8 -3
  3. package/dist/mcp.js +12 -1
  4. package/dist/provision.js +23 -2
  5. package/dist/seam.js +4 -0
  6. package/dist/server.js +39 -7
  7. package/package.json +1 -1
  8. package/public/assets/{abnfDiagram-N423BO3Z-B9qt2Lrn.js → abnfDiagram-N423BO3Z-eACBdXEp.js} +1 -1
  9. package/public/assets/{arc-Bu5e98OE.js → arc-C8zPWxct.js} +1 -1
  10. package/public/assets/architecture-TIHT7OUA-CtVIKkxG.js +1 -0
  11. package/public/assets/{architectureDiagram-T3A2C74G-C9YgdNEk.js → architectureDiagram-T3A2C74G-BZqtGnsC.js} +1 -1
  12. package/public/assets/{blockDiagram-VBNYF7ZC-KV2ZfVrI.js → blockDiagram-VBNYF7ZC-D265Ytun.js} +1 -1
  13. package/public/assets/{c4Diagram-5PPSVZJV-BOIhWD29.js → c4Diagram-5PPSVZJV-CodzUBEt.js} +1 -1
  14. package/public/assets/channel-CpTfWcC2.js +1 -0
  15. package/public/assets/{chunk-2GRJ4B5K-BOYqDFv-.js → chunk-2GRJ4B5K-D59ECeXb.js} +1 -1
  16. package/public/assets/{chunk-4I5QYGJK-aPXqNUlF.js → chunk-4I5QYGJK-DlE6ad0r.js} +1 -1
  17. package/public/assets/{chunk-5RXB4S5H-BESU8h4l.js → chunk-5RXB4S5H-Bw4SBOdN.js} +1 -1
  18. package/public/assets/{chunk-6Q2QTUOP-Dy_tviVm.js → chunk-6Q2QTUOP-BD4S6iuB.js} +1 -1
  19. package/public/assets/{chunk-7Z6QIM7H-CViytsd0.js → chunk-7Z6QIM7H-DvwJZM4T.js} +1 -1
  20. package/public/assets/{chunk-GF5L2VYU-Bw_WxctK.js → chunk-GF5L2VYU-BlzSHpI6.js} +1 -1
  21. package/public/assets/{chunk-I66GZJ75-CyLcz-VG.js → chunk-I66GZJ75-DJurmtZ9.js} +1 -1
  22. package/public/assets/{chunk-JQJVKLGR-BehQOyT2.js → chunk-JQJVKLGR-t20LaGIq.js} +1 -1
  23. package/public/assets/{chunk-KBJHAD2P-Cv0WMvkU.js → chunk-KBJHAD2P-Dgjyd4B5.js} +1 -1
  24. package/public/assets/{chunk-NSK5VX7P-Duq5i1Q8.js → chunk-NSK5VX7P-Chchkdi8.js} +1 -1
  25. package/public/assets/{chunk-QR6OTTB3-Xi-RqgB3.js → chunk-QR6OTTB3-CJK67frw.js} +1 -1
  26. package/public/assets/{chunk-RYQCIY6F-pkCoj5q-.js → chunk-RYQCIY6F-sGSUyT6_.js} +1 -1
  27. package/public/assets/{chunk-UBXNYLIW-BRvAYX25.js → chunk-UBXNYLIW-CEzUmAZt.js} +1 -1
  28. package/public/assets/{chunk-W5SLKNZC-Bjt98ztx.js → chunk-W5SLKNZC-Spmh0y1r.js} +1 -1
  29. package/public/assets/{chunk-WRU74C26-a9B5o7qU.js → chunk-WRU74C26-DEsyhzZw.js} +1 -1
  30. package/public/assets/{chunk-XXDRQBXY-KvoTdu-7.js → chunk-XXDRQBXY-Bo1s3Uh5.js} +1 -1
  31. package/public/assets/classDiagram-JCYQIIEL-BSB0boKu.js +1 -0
  32. package/public/assets/classDiagram-v2-OCEON4UE-BSB0boKu.js +1 -0
  33. package/public/assets/{cose-bilkent-JH36ORCC-N6ziZwxK.js → cose-bilkent-JH36ORCC-15pcvj-n.js} +1 -1
  34. package/public/assets/{cynefin-VYW2F7L2-CIULy749.js → cynefin-VYW2F7L2-BZxWqC-g.js} +1 -1
  35. package/public/assets/{cynefinDiagram-MW4NZA55-Du-pmosA.js → cynefinDiagram-MW4NZA55-B_czkRTa.js} +1 -1
  36. package/public/assets/{dagre-VZM6K2ZE-HGby89Zn.js → dagre-VZM6K2ZE-D8bvaK5F.js} +1 -1
  37. package/public/assets/{diagram-7IWD3JNH-B7q3-bCI.js → diagram-7IWD3JNH-_vpWqUu0.js} +1 -1
  38. package/public/assets/{diagram-B4RE2ZJO-YWiWiMdK.js → diagram-B4RE2ZJO-DPfWeSE2.js} +1 -1
  39. package/public/assets/{diagram-LBJQPF4R-BPCYGRvd.js → diagram-LBJQPF4R-Cb7ustRg.js} +1 -1
  40. package/public/assets/{diagram-Q27KOJAE-B2LXUwVb.js → diagram-Q27KOJAE-CRIHo9aN.js} +1 -1
  41. package/public/assets/{diagram-UB23O5K3-BNVtmpPQ.js → diagram-UB23O5K3-CMyiQouk.js} +1 -1
  42. package/public/assets/{dist-BVRuovsg.js → dist-DVdstvf6.js} +1 -1
  43. package/public/assets/{ebnfDiagram-BXEA7PRR-BWXGcOBy.js → ebnfDiagram-BXEA7PRR-UURYMfYm.js} +1 -1
  44. package/public/assets/{erDiagram-JOGREHBK-Bs7Rt9fE.js → erDiagram-JOGREHBK-Dio32huH.js} +1 -1
  45. package/public/assets/eventmodeling-45OFAUF4-DP5rNNNm.js +1 -0
  46. package/public/assets/flowDiagram-UKHOOZJN-DjrqEV81.js +1 -0
  47. package/public/assets/{ganttDiagram-PKOTCBZU-76WOMwTJ.js → ganttDiagram-PKOTCBZU-62etRb4w.js} +1 -1
  48. package/public/assets/{gitGraph-TEB2WS4Q-ChX3jwy9.js → gitGraph-TEB2WS4Q-CfIUb3Fs.js} +1 -1
  49. package/public/assets/{gitGraphDiagram-DS77QQ5N-Df90jw60.js → gitGraphDiagram-DS77QQ5N-DuwZInBC.js} +1 -1
  50. package/public/assets/index-ZvSJKDLe.css +2 -0
  51. package/public/assets/{index-Duxs51eO.js → index-iKIFRUDL.js} +12 -12
  52. package/public/assets/{info-DKCQHKI2-B4sk1tEu.js → info-DKCQHKI2-BfXJHEd1.js} +1 -1
  53. package/public/assets/{infoDiagram-6WML65LV-CwHXQy_Y.js → infoDiagram-6WML65LV-Bmh_7gih.js} +1 -1
  54. package/public/assets/{ishikawaDiagram-WSZJBQD7-9Wx7fEa-.js → ishikawaDiagram-WSZJBQD7-i8-L2rAe.js} +1 -1
  55. package/public/assets/{journeyDiagram-NVQOT4AX-YjyFj4j3.js → journeyDiagram-NVQOT4AX-BtfEqljI.js} +1 -1
  56. package/public/assets/{kanban-definition-27J2QSJJ-CCSVpJmG.js → kanban-definition-27J2QSJJ-pH6QumbR.js} +1 -1
  57. package/public/assets/{line-BNlogVke.js → line-DsGf4Aam.js} +1 -1
  58. package/public/assets/{linear-DtHynSNJ.js → linear-BNSu_43k.js} +1 -1
  59. package/public/assets/{mermaid-parser.core-Tzw7YIHZ.js → mermaid-parser.core-679COn57.js} +3 -3
  60. package/public/assets/{mermaid.core-BYlHVIMn.js → mermaid.core-D_f4AlrR.js} +4 -4
  61. package/public/assets/{mindmap-definition-FAOFIHXS-D3RdOamQ.js → mindmap-definition-FAOFIHXS-D1tM4SRn.js} +1 -1
  62. package/public/assets/{packet-7NZHBO7P-Gg9ynt_Q.js → packet-7NZHBO7P-olELdMgx.js} +1 -1
  63. package/public/assets/{pegDiagram-VL7TDLO6-CF8QpCrl.js → pegDiagram-VL7TDLO6-DgAndH0A.js} +1 -1
  64. package/public/assets/{pie-RZYD4A2V-tZaCjWV1.js → pie-RZYD4A2V-DWj8tY38.js} +1 -1
  65. package/public/assets/{pieDiagram-7S7Q4E2Y-q9v-b_KS.js → pieDiagram-7S7Q4E2Y-DK7c2EvE.js} +1 -1
  66. package/public/assets/{quadrantDiagram-CIZ2JOQS-C1jEdjlT.js → quadrantDiagram-CIZ2JOQS-DI-ZbPxK.js} +1 -1
  67. package/public/assets/{radar-I7S5WNFK-Dq9mh9W6.js → radar-I7S5WNFK-DLsdeAbl.js} +1 -1
  68. package/public/assets/{railroad-3IZDKUUU-Di1R2Dd0.js → railroad-3IZDKUUU-BFUnqJxV.js} +1 -1
  69. package/public/assets/railroad-abnf-AHOZXSZD-B00TU1b8.js +1 -0
  70. package/public/assets/railroad-ebnf-EBAXGLYW-RrXgWJqj.js +1 -0
  71. package/public/assets/railroad-peg-LSFZ7HO6-CsiNSgst.js +1 -0
  72. package/public/assets/{railroadDiagram-AXF67PYL-LvRdE_s1.js → railroadDiagram-AXF67PYL-BcCf-qnq.js} +1 -1
  73. package/public/assets/{requirementDiagram-LRYGKXZP-BnZ07FeK.js → requirementDiagram-LRYGKXZP-CSERzrsB.js} +1 -1
  74. package/public/assets/{sankeyDiagram-W5VNT64P-E8-ON6IS.js → sankeyDiagram-W5VNT64P-BTHdyTAB.js} +1 -1
  75. package/public/assets/{sequenceDiagram-SI44F4Z6-DlVaUXz0.js → sequenceDiagram-SI44F4Z6-DCMbcZQ-.js} +1 -1
  76. package/public/assets/{src-qdf2s-T4.js → src-CWXJqyrc.js} +1 -1
  77. package/public/assets/{stateDiagram-OKZ733FA-B9ThZGE5.js → stateDiagram-OKZ733FA-BhzI_RZ_.js} +1 -1
  78. package/public/assets/stateDiagram-v2-UEYNNEHI-DKG0b0eo.js +1 -0
  79. package/public/assets/{swimlanes-SLNWSIFB-DtPuEFdj.js → swimlanes-SLNWSIFB-DPKSeErn.js} +1 -1
  80. package/public/assets/swimlanesDiagram-ULZ7WXOC-D6CPDB9k.js +8 -0
  81. package/public/assets/{timeline-definition-Z64GVDOM-BR4Z5jFy.js → timeline-definition-Z64GVDOM-BnLvIO3-.js} +1 -1
  82. package/public/assets/{treeView-QDETBFTQ-BgvlYe1u.js → treeView-QDETBFTQ-BgFXBEUi.js} +1 -1
  83. package/public/assets/{treemap-6X3UGDF4-BIP2RMFS.js → treemap-6X3UGDF4-KzlTv1ih.js} +1 -1
  84. package/public/assets/{vennDiagram-T6HMQDX7-DA80iXM-.js → vennDiagram-T6HMQDX7-gsHmzjh9.js} +1 -1
  85. package/public/assets/{wardley-OPB4EBWU-Dcxb0gTX.js → wardley-OPB4EBWU-DyQkbq8g.js} +1 -1
  86. package/public/assets/{wardleyDiagram-T6FBY63Y-i2RYxGIr.js → wardleyDiagram-T6FBY63Y-DqwaVwnv.js} +1 -1
  87. package/public/assets/{xychartDiagram-ELKLHX3M-BWEBGjsc.js → xychartDiagram-ELKLHX3M-DGZxfApD.js} +1 -1
  88. package/public/index.html +2 -2
  89. package/public/assets/architecture-TIHT7OUA-Bga-lAng.js +0 -1
  90. package/public/assets/channel-BdIShFYL.js +0 -1
  91. package/public/assets/classDiagram-JCYQIIEL-D2R4WmWG.js +0 -1
  92. package/public/assets/classDiagram-v2-OCEON4UE-D2R4WmWG.js +0 -1
  93. package/public/assets/eventmodeling-45OFAUF4-DNrXe8VH.js +0 -1
  94. package/public/assets/flowDiagram-UKHOOZJN-Bx68YkAo.js +0 -1
  95. package/public/assets/index-C3zhnM_H.css +0 -2
  96. package/public/assets/railroad-abnf-AHOZXSZD-CUlgmRQa.js +0 -1
  97. package/public/assets/railroad-ebnf-EBAXGLYW-sFLjr1iD.js +0 -1
  98. package/public/assets/railroad-peg-LSFZ7HO6-BjRYu4TF.js +0 -1
  99. package/public/assets/stateDiagram-v2-UEYNNEHI-Bt0yXMXs.js +0 -1
  100. package/public/assets/swimlanesDiagram-ULZ7WXOC-MLUjmCjx.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BYlHVIMn.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-qdf2s-T4.js","assets/chunk-I66GZJ75-CyLcz-VG.js","assets/chunk-NSK5VX7P-Duq5i1Q8.js","assets/dist-BVRuovsg.js","assets/chunk-4I5QYGJK-aPXqNUlF.js","assets/chunk-WRU74C26-a9B5o7qU.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-UBXNYLIW-BRvAYX25.js","assets/chunk-W5SLKNZC-Bjt98ztx.js","assets/chunk-QR6OTTB3-Xi-RqgB3.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-7Z6QIM7H-CViytsd0.js","assets/line-BNlogVke.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-D_f4AlrR.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-CWXJqyrc.js","assets/chunk-I66GZJ75-DJurmtZ9.js","assets/chunk-NSK5VX7P-Chchkdi8.js","assets/dist-DVdstvf6.js","assets/chunk-4I5QYGJK-DlE6ad0r.js","assets/chunk-WRU74C26-DEsyhzZw.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-UBXNYLIW-CEzUmAZt.js","assets/chunk-W5SLKNZC-Spmh0y1r.js","assets/chunk-QR6OTTB3-CJK67frw.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-7Z6QIM7H-DvwJZM4T.js","assets/line-DsGf4Aam.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js"])))=>i.map(i=>d[i]);
2
2
  var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ee(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function P(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var F=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},I={map:ee,forEach:function(e,t,n){ee(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ee(e,function(){t++}),t},toArray:function(e){return ee(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=I,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:P}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,F)}catch(e){F(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),h=o(((e,t)=>{t.exports=m()})),g=o((e=>{var t=p();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),_=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=o((e=>{var t=h(),n=p(),r=_();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,m=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function ee(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?ee(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return ee(e(t))}catch{}}return null}var P=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te={pending:!1,data:null,method:null,action:null},ne=[],re=-1;function L(e){return{current:e}}function R(e){0>re||(e.current=ne[re],ne[re]=null,re--)}function z(e,t){re++,ne[re]=e.current,e.current=t}var ie=L(null),ae=L(null),oe=L(null),se=L(null);function ce(e,t){switch(z(oe,t),z(ae,e),z(ie,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}R(ie),z(ie,e)}function le(){R(ie),R(ae),R(oe)}function ue(e){e.memoizedState!==null&&z(se,e);var t=ie.current,n=Hd(t,e.type);t!==n&&(z(ae,e),z(ie,n))}function de(e){ae.current===e&&(R(ie),R(ae)),se.current===e&&(R(se),Qf._currentValue=te)}var fe,pe;function me(e){if(fe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);fe=t&&t[1]||``,pe=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+fe+e+pe}var he=!1;function ge(e,t){if(!e||he)return``;he=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -21,20 +21,20 @@ Error generating stack: `+e.message+`
21
21
  `),t=t.replace(Dc,`�`),e.src=t}function kc(e){let t;e.inlineMode?(t=new e.Token(`inline`,``,0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}function Ac(e){let t=e.tokens,n=0;for(let e=0;e<t.length;e++)t[e].type!==`reference_definition`&&(e!==n&&(t[n]=t[e]),n++);t.length!==n&&(t.length=n)}function jc(e){let t=e.tokens;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.type===`inline`&&e.md.inline.parse(r.content,e.md,e.env,r.children)}}function Mc(e){return/^<a[>\s]/i.test(e)}function Nc(e){return/^<\/a\s*>/i.test(e)}function Pc(e){let t=e.tokens;if(e.md.options.linkify)for(let n=0,r=t.length;n<r;n++){if(t[n].type!==`inline`||!e.md.linkify.test(t[n].content))continue;let r=t[n].children,i=0;for(let a=r.length-1;a>=0;a--){let o=r[a];if(o.type===`link_close`){for(a--;r[a].level!==o.level&&r[a].type!==`link_open`;)a--;continue}if(o.type===`html_inline`&&(Mc(o.content)&&i>0&&i--,Nc(o.content)&&i++),!(i>0)&&o.type===`text`&&e.md.linkify.test(o.content)){let i=o.content,s=e.md.linkify.match(i),c=[],l=o.level,u=0;s.length>0&&s[0].index===0&&a>0&&r[a-1].type===`text_special`&&(s=s.slice(1));for(let t=0;t<s.length;t++){let n=s[t].url,r=e.md.normalizeLink(n);if(!e.md.validateLink(r))continue;let a=s[t].text;a=s[t].schema?s[t].schema===`mailto:`&&!/^mailto:/i.test(a)?e.md.normalizeLinkText(`mailto:${a}`).replace(/^mailto:/,``):e.md.normalizeLinkText(a):e.md.normalizeLinkText(`http://${a}`).replace(/^http:\/\//,``);let o=s[t].index;if(o>u){let t=new e.Token(`text`,``,0);t.content=i.slice(u,o),t.level=l,c.push(t)}let d=new e.Token(`link_open`,`a`,1);d.attrs=[[`href`,r]],d.level=l++,d.markup=`linkify`,d.info=`auto`,c.push(d);let f=new e.Token(`text`,``,0);f.content=a,f.level=l,c.push(f);let p=new e.Token(`link_close`,`a`,-1);p.level=--l,p.markup=`linkify`,p.info=`auto`,c.push(p),u=s[t].lastIndex}if(u<i.length){let t=new e.Token(`text`,``,0);t.content=i.slice(u),t.level=l,c.push(t)}t[n].children=r=Us(r,a,c)}}}}var Fc=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,Ic=/\((c|tm|r)\)/i,Lc=/\((c|tm|r)\)/gi,Rc={c:`©`,r:`®`,tm:`™`};function zc(e,t){return Rc[t.toLowerCase()]}function Bc(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&(r.content=r.content.replace(Lc,zc)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function Vc(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&Fc.test(r.content)&&(r.content=r.content.replace(/\+-/g,`±`).replace(/\.{2,}/g,`…`).replace(/([?!])…/g,`$1..`).replace(/([?!]){4,}/g,`$1$1$1`).replace(/,{2,}/g,`,`).replace(/(^|[^-])---(?=[^-]|$)/gm,`$1—`).replace(/(^|\s)--(?=\s|$)/gm,`$1–`).replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,`$1–`)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function Hc(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type===`inline`&&(Ic.test(e.tokens[t].content)&&Bc(e.tokens[t].children),Fc.test(e.tokens[t].content)&&Vc(e.tokens[t].children))}var Uc=/['"]/,Wc=/['"]/g,Gc=`’`;function Kc(e,t,n,r){e[t]||(e[t]=[]),e[t].push({pos:n,ch:r})}function qc(e,t){let n=``,r=0;t.sort((e,t)=>e.pos-t.pos);for(let i=0;i<t.length;i++){let a=t[i];n+=e.slice(r,a.pos)+a.ch,r=a.pos+1}return n+e.slice(r)}function Jc(e,t){let n,r=[],i={};for(let a=0;a<e.length;a++){let o=e[a],s=e[a].level;for(n=r.length-1;n>=0&&!(r[n].level<=s);n--);if(r.length=n+1,o.type!==`text`)continue;let c=o.content,l=0,u=c.length;OUTER:for(;l<u;){Wc.lastIndex=l;let o=Wc.exec(c);if(!o)break;let d=!0,f=!0;l=o.index+1;let p=o[0]===`'`,m=32;if(o.index-1>=0)m=c.charCodeAt(o.index-1);else for(n=a-1;n>=0&&e[n].type!==`softbreak`&&e[n].type!==`hardbreak`;n--)if(e[n].content){m=e[n].content.charCodeAt(e[n].content.length-1);break}let h=32;if(l<u)h=c.charCodeAt(l);else for(n=a+1;n<e.length&&e[n].type!==`softbreak`&&e[n].type!==`hardbreak`;n++)if(e[n].content){h=e[n].content.charCodeAt(0);break}let g=lc(m)||cc(m),_=lc(h)||cc(h),v=oc(m),y=oc(h);if(y?d=!1:_&&(v||g||(d=!1)),v?f=!1:g&&(y||_||(f=!1)),h===34&&o[0]===`"`&&m>=48&&m<=57&&(f=d=!1),d&&f&&(d=g,f=_),!d&&!f){p&&Kc(i,a,o.index,Gc);continue}if(f)for(n=r.length-1;n>=0;n--){let e=r[n];if(r[n].level<s)break;if(e.single===p&&r[n].level===s){e=r[n];let s,c;p?(s=t.md.options.quotes[2],c=t.md.options.quotes[3]):(s=t.md.options.quotes[0],c=t.md.options.quotes[1]),Kc(i,a,o.index,c),Kc(i,e.token,e.pos,s),r.length=n;continue OUTER}}d?r.push({token:a,pos:o.index,single:p,level:s}):f&&p&&Kc(i,a,o.index,Gc)}}Object.keys(i).forEach(function(t){let n=Number(t);e[n].content=qc(e[n].content,i[t])})}function Yc(e){if(e.md.options.typographer)for(let t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!==`inline`||!Uc.test(e.tokens[t].content)||Jc(e.tokens[t].children,e)}function Xc(e){let t,n,r=e.length;for(t=0;t<r;t++)e[t].type===`text_special`&&(e[t].type=`text`);for(t=n=0;t<r;t++)e[t].type===`text`&&t+1<r&&e[t+1].type===`text`?e[t+1].content=e[t].content+e[t+1].content:(t!==n&&(e[n]=e[t]),n++);t!==n&&(e.length=n)}function Zc(e){let t,n,r=e.tokens,i=r.length;for(let e=0;e<i;e++){if(r[e].type!==`inline`)continue;let i=r[e].children,a=i.length;for(t=0;t<a;t++)i[t].type===`text_special`&&(i[t].type=`text`),i[t].children&&Xc(i[t].children);for(t=n=0;t<a;t++)i[t].type===`text`&&t+1<a&&i[t+1].type===`text`?i[t+1].content=i[t].content+i[t+1].content:(t!==n&&(i[n]=i[t]),n++);t!==n&&(i.length=n)}}var Qc=[[`normalize`,Oc],[`block`,kc],[`strip_references`,Ac],[`inline`,jc],[`linkify`,Pc],[`replacements`,Hc],[`smartquotes`,Yc],[`text_join`,Zc]],$c=class{constructor(){Y(this,`ruler`,new Sc),Y(this,`State`,Tc);for(let e=0;e<Qc.length;e++)this.ruler.push(Qc[e][0],Qc[e][1])}process(e){let t=this.ruler.getRules(``);for(let n=0,r=t.length;n<r;n++)t[n](e)}},el=class{constructor(e,t,n,r){Y(this,`bMarks`,[]),Y(this,`eMarks`,[]),Y(this,`tShift`,[]),Y(this,`sCount`,[]),Y(this,`bsCount`,[]),Y(this,`blkIndent`,0),Y(this,`line`,0),Y(this,`lineMax`,0),Y(this,`tight`,!1),Y(this,`listIndent`,-1),Y(this,`parentType`,`root`),Y(this,`level`,0),Y(this,`Token`,xc),this.src=e,this.md=t,this.env=n,this.tokens=r;let i=this.src;for(let e=0,t=0,n=0,r=0,a=i.length,o=!1;t<a;t++){let s=i.charCodeAt(t);if(!o){if(ac(s)){n++,s===9?r+=4-r%4:r++;continue}o=!0}(s===10||t===a-1)&&(s!==10&&t++,this.bMarks.push(e),this.eMarks.push(t),this.tShift.push(n),this.sCount.push(r),this.bsCount.push(0),o=!1,n=0,r=0,e=t+1)}this.bMarks.push(i.length),this.eMarks.push(i.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}push(e,t,n){let r=new xc(e,t,n);return r.block=!0,n<0&&this.level--,r.level=this.level,n>0&&this.level++,this.tokens.push(r),r}isEmpty(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]}skipEmptyLines(e){for(let t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e}skipSpaces(e){for(let t=this.src.length;e<t&&ac(this.src.charCodeAt(e));e++);return e}skipSpacesBack(e,t){if(e<=t)return e;for(;e>t;)if(!ac(this.src.charCodeAt(--e)))return e+1;return e}skipChars(e,t){for(let n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e}skipCharsBack(e,t,n){if(e<=n)return e;for(;e>n;)if(t!==this.src.charCodeAt(--e))return e+1;return e}getLines(e,t,n,r){if(e>=t)return``;let i=Array(t-e);for(let a=0,o=e;o<t;o++,a++){let e=0,s=this.bMarks[o],c=s,l;for(l=o+1<t||r?this.eMarks[o]+1:this.eMarks[o];c<l&&e<n;){let t=this.src.charCodeAt(c);if(ac(t))t===9?e+=4-(e+this.bsCount[o])%4:e++;else if(c-s<this.tShift[o])e++;else break;c++}e>n?i[a]=Array(e-n+1).join(` `)+this.src.slice(c,l):i[a]=this.src.slice(c,l)}return i.join(``)}},tl=65536;function nl(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];return e.src.slice(n,r)}function rl(e){let t=[],n=e.length,r=0,i=e.charCodeAt(r),a=!1,o=0,s=``;for(;r<n;)i===124&&(a?(s+=e.substring(o,r-1),o=r):(t.push(s+e.substring(o,r)),s=``,o=r+1)),a=i===92,r++,i=e.charCodeAt(r);return t.push(s+e.substring(o)),t}function il(e,t,n,r){if(t+2>n)return!1;let i=t+1;if(e.sCount[i]<e.blkIndent||e.sCount[i]-e.blkIndent>=4)return!1;let a=e.bMarks[i]+e.tShift[i];if(a>=e.eMarks[i])return!1;let o=e.src.charCodeAt(a++);if(o!==124&&o!==45&&o!==58||a>=e.eMarks[i])return!1;let s=e.src.charCodeAt(a++);if(s!==124&&s!==45&&s!==58&&!ac(s)||o===45&&ac(s))return!1;for(;a<e.eMarks[i];){let t=e.src.charCodeAt(a);if(t!==124&&t!==45&&t!==58&&!ac(t))return!1;a++}let c=nl(e,t+1),l=c.split(`|`),u=[];for(let e=0;e<l.length;e++){let t=l[e].trim();if(!t){if(e===0||e===l.length-1)continue;return!1}if(!/^:?-+:?$/.test(t))return!1;t.charCodeAt(t.length-1)===58?u.push(t.charCodeAt(0)===58?`center`:`right`):t.charCodeAt(0)===58?u.push(`left`):u.push(``)}if(c=nl(e,t).trim(),c.indexOf(`|`)===-1||e.sCount[t]-e.blkIndent>=4)return!1;l=rl(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop();let d=l.length;if(d===0||d!==u.length)return!1;if(r)return!0;let f=e.parentType;e.parentType=`table`;let p=e.md.block.ruler.getRules(`blockquote`),m=e.push(`table_open`,`table`,1),h=[t,0];m.map=h;let g=e.push(`thead_open`,`thead`,1);g.map=[t,t+1];let _=e.push(`tr_open`,`tr`,1);_.map=[t,t+1];for(let t=0;t<l.length;t++){let n=e.push(`th_open`,`th`,1);u[t]&&(n.attrs=[[`style`,`text-align:${u[t]}`]]);let r=e.push(`inline`,``,0);r.content=l[t].trim(),r.children=[],e.push(`th_close`,`th`,-1)}e.push(`tr_close`,`tr`,-1),e.push(`thead_close`,`thead`,-1);let v,y=0;for(i=t+2;i<n&&!(e.sCount[i]<e.blkIndent);i++){let r=!1;for(let t=0,a=p.length;t<a;t++)if(p[t](e,i,n,!0)){r=!0;break}if(r||(c=nl(e,i).trim(),!c)||e.sCount[i]-e.blkIndent>=4||(l=rl(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop(),y+=d-l.length,y>tl))break;if(i===t+2){let n=e.push(`tbody_open`,`tbody`,1);n.map=v=[t+2,0]}let a=e.push(`tr_open`,`tr`,1);a.map=[i,i+1];for(let t=0;t<d;t++){let n=e.push(`td_open`,`td`,1);u[t]&&(n.attrs=[[`style`,`text-align:${u[t]}`]]);let r=e.push(`inline`,``,0);r.content=l[t]?l[t].trim():``,r.children=[],e.push(`td_close`,`td`,-1)}e.push(`tr_close`,`tr`,-1)}return v&&(e.push(`tbody_close`,`tbody`,-1),v[1]=i),e.push(`table_close`,`table`,-1),h[1]=i,e.parentType=f,e.line=i,!0}function al(e,t,n){if(e.sCount[t]-e.blkIndent<4)return!1;let r=t+1,i=r;for(;r<n;){if(e.isEmpty(r)){r++;continue}if(e.sCount[r]-e.blkIndent>=4){r++,i=r;continue}break}e.line=i;let a=e.push(`code_block`,`code`,0);return a.content=e.getLines(t,i,4+e.blkIndent,!1)+`
22
22
  `,a.map=[t,e.line],!0}function ol(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||i+3>a)return!1;let o=e.src.charCodeAt(i);if(o!==126&&o!==96)return!1;let s=i;i=e.skipChars(i,o);let c=i-s;if(c<3)return!1;let l=e.src.slice(s,i),u=e.src.slice(i,a);if(o===96&&u.indexOf(String.fromCharCode(o))>=0)return!1;if(r)return!0;let d=t,f=!1;for(;d++,!(d>=n||(i=s=e.bMarks[d]+e.tShift[d],a=e.eMarks[d],i<a&&e.sCount[d]<e.blkIndent));)if(e.src.charCodeAt(i)===o&&!(e.sCount[d]-e.blkIndent>=4)&&(i=e.skipChars(i,o),!(i-s<c)&&(i=e.skipSpaces(i),!(i<a)))){f=!0;break}c=e.sCount[t],e.line=d+ +!!f;let p=e.push(`fence`,`code`,0);return p.info=u,p.content=e.getLines(t+1,d,c,!0),p.markup=l,p.map=[t,e.line],!0}function sl(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t],o=e.lineMax;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(i)!==62)return!1;if(r)return!0;let s=[],c=[],l=[],u=[],d=e.md.block.ruler.getRules(`blockquote`),f=e.parentType;e.parentType=`blockquote`;let p=!1,m;for(m=t;m<n;m++){let t=e.sCount[m]<e.blkIndent;if(i=e.bMarks[m]+e.tShift[m],a=e.eMarks[m],i>=a)break;if(e.src.charCodeAt(i++)===62&&!t){let t=e.sCount[m]+1,n,r;e.src.charCodeAt(i)===32?(i++,t++,r=!1,n=!0):e.src.charCodeAt(i)===9?(n=!0,(e.bsCount[m]+t)%4==3?(i++,t++,r=!1):r=!0):n=!1;let o=t;for(s.push(e.bMarks[m]),e.bMarks[m]=i;i<a;){let t=e.src.charCodeAt(i);if(ac(t))t===9?o+=4-(o+e.bsCount[m]+ +!!r)%4:o++;else break;i++}p=i>=a,c.push(e.bsCount[m]),e.bsCount[m]=e.sCount[m]+1+ +!!n,l.push(e.sCount[m]),e.sCount[m]=o-t,u.push(e.tShift[m]),e.tShift[m]=i-e.bMarks[m];continue}if(p)break;let r=!1;for(let t=0,i=d.length;t<i;t++)if(d[t](e,m,n,!0)){r=!0;break}if(r){e.lineMax=m,e.blkIndent!==0&&(s.push(e.bMarks[m]),c.push(e.bsCount[m]),u.push(e.tShift[m]),l.push(e.sCount[m]),e.sCount[m]-=e.blkIndent);break}s.push(e.bMarks[m]),c.push(e.bsCount[m]),u.push(e.tShift[m]),l.push(e.sCount[m]),e.sCount[m]=-1}let h=e.blkIndent;e.blkIndent=0;let g=e.push(`blockquote_open`,`blockquote`,1);g.markup=`>`;let _=[t,0];g.map=_,e.md.block.tokenize(e,t,m);let v=e.push(`blockquote_close`,`blockquote`,-1);v.markup=`>`,e.lineMax=o,e.parentType=f,_[1]=e.line;for(let n=0;n<u.length;n++)e.bMarks[n+t]=s[n],e.tShift[n+t]=u[n],e.sCount[n+t]=l[n],e.bsCount[n+t]=c[n];return e.blkIndent=h,!0}function cl(e,t,n,r){let i=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let a=e.bMarks[t]+e.tShift[t],o=e.src.charCodeAt(a++);if(o!==42&&o!==45&&o!==95)return!1;let s=1;for(;a<i;){let t=e.src.charCodeAt(a++);if(t!==o&&!ac(t))return!1;t===o&&s++}if(s<3)return!1;if(r)return!0;e.line=t+1;let c=e.push(`hr`,`hr`,0);return c.map=[t,e.line],c.markup=Array(s+1).join(String.fromCharCode(o)),!0}function ll(e,t){let n=e.eMarks[t],r=e.bMarks[t]+e.tShift[t],i=e.src.charCodeAt(r++);return i!==42&&i!==45&&i!==43||r<n&&!ac(e.src.charCodeAt(r))?-1:r}function ul(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t],i=n;if(i+1>=r)return-1;let a=e.src.charCodeAt(i++);if(a<48||a>57)return-1;for(;;){if(i>=r)return-1;if(a=e.src.charCodeAt(i++),a>=48&&a<=57){if(i-n>=10)return-1;continue}if(a===41||a===46)break;return-1}return i<r&&(a=e.src.charCodeAt(i),!ac(a))?-1:i}function dl(e,t){let n=e.level+2;for(let r=t+2,i=e.tokens.length-2;r<i;r++)e.tokens[r].level===n&&e.tokens[r].type===`paragraph_open`&&(e.tokens[r+2].hidden=!0,e.tokens[r].hidden=!0,r+=2)}function fl(e,t,n,r){let i,a,o,s,c=t,l=!0;if(e.sCount[c]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[c]-e.listIndent>=4&&e.sCount[c]<e.blkIndent)return!1;let u=!1;r&&e.parentType===`paragraph`&&e.sCount[c]>=e.blkIndent&&(u=!0);let d,f,p;if((p=ul(e,c))>=0){if(d=!0,o=e.bMarks[c]+e.tShift[c],f=Number(e.src.slice(o,p-1)),u&&f!==1)return!1}else if((p=ll(e,c))>=0)d=!1;else return!1;if(u&&e.skipSpaces(p)>=e.eMarks[c])return!1;if(r)return!0;let m=e.src.charCodeAt(p-1),h=e.tokens.length;d?(s=e.push(`ordered_list_open`,`ol`,1),f!==1&&(s.attrs=[[`start`,f]])):s=e.push(`bullet_list_open`,`ul`,1);let g=[c,0];s.map=g,s.markup=String.fromCharCode(m);let _=!1,v=e.md.block.ruler.getRules(`list`),y=e.parentType;for(e.parentType=`list`;c<n;){a=p,i=e.eMarks[c];let t=e.sCount[c]+p-(e.bMarks[c]+e.tShift[c]),r=t;for(;a<i;){let t=e.src.charCodeAt(a);if(t===9)r+=4-(r+e.bsCount[c])%4;else if(t===32)r++;else break;a++}let u=a,f;f=u>=i?1:r-t,f>4&&(f=1);let h=t+f;s=e.push(`list_item_open`,`li`,1),s.markup=String.fromCharCode(m);let g=[c,0];s.map=g,d&&(s.info=e.src.slice(o,p-1));let y=e.tight,b=e.tShift[c],x=e.sCount[c],S=e.listIndent;if(e.listIndent=e.blkIndent,e.blkIndent=h,e.tight=!0,e.tShift[c]=u-e.bMarks[c],e.sCount[c]=r,u>=i&&e.isEmpty(c+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,c,n),(!e.tight||_)&&(l=!1),_=e.line-c>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=S,e.tShift[c]=b,e.sCount[c]=x,e.tight=y,s=e.push(`list_item_close`,`li`,-1),s.markup=String.fromCharCode(m),c=e.line,g[1]=c,c>=n||e.sCount[c]<e.blkIndent||e.sCount[c]-e.blkIndent>=4)break;let C=!1;for(let t=0,r=v.length;t<r;t++)if(v[t](e,c,n,!0)){C=!0;break}if(C)break;if(d){if(p=ul(e,c),p<0)break;o=e.bMarks[c]+e.tShift[c]}else if(p=ll(e,c),p<0)break;if(m!==e.src.charCodeAt(p-1))break}return s=d?e.push(`ordered_list_close`,`ol`,-1):e.push(`bullet_list_close`,`ul`,-1),s.markup=String.fromCharCode(m),g[1]=c,e.line=c,e.parentType=y,l&&dl(e,h),!0}function pl(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t],o=t+1;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(i)!==91)return!1;function s(t){let n=e.lineMax;if(t>=n||e.isEmpty(t))return null;let r=!1;if(e.sCount[t]-e.blkIndent>3&&(r=!0),e.sCount[t]<0&&(r=!0),!r){let r=e.md.block.ruler.getRules(`reference`),i=e.parentType;e.parentType=`reference`;let a=!1;for(let i=0,o=r.length;i<o;i++)if(r[i](e,t,n,!0)){a=!0;break}if(e.parentType=i,a)return null}let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];return e.src.slice(i,a+1)}let c=e.src.slice(i,a+1);a=c.length;let l=-1;for(i=1;i<a;i++){let e=c.charCodeAt(i);if(e===91)return!1;if(e===93){l=i;break}if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(e===92&&(i++,i<a&&c.charCodeAt(i)===10)){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}}if(l<0||c.charCodeAt(l+1)!==58)return!1;for(i=l+2;i<a;i++){let e=c.charCodeAt(i);if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(!ac(e))break}let u=e.md.helpers.parseLinkDestination(c,i,a);if(!u.ok)return!1;let d=e.md.normalizeLink(u.str);if(!e.md.validateLink(d))return!1;i=u.pos;let f=i,p=o,m=i;for(;i<a;i++){let e=c.charCodeAt(i);if(e===10){let e=s(o);e!==null&&(c+=e,a=c.length,o++)}else if(!ac(e))break}let h=e.md.helpers.parseLinkTitle(c,i,a);for(;h.can_continue;){let t=s(o);if(t===null)break;c+=t,i=a,a=c.length,o++,h=e.md.helpers.parseLinkTitle(c,i,a,h)}let g;for(i<a&&m!==i&&h.ok?(g=h.str,i=h.pos):(g=``,i=f,o=p);i<a&&ac(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10&&g)for(g=``,i=f,o=p;i<a&&ac(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10)return!1;let _=uc(c.slice(1,l));if(!_)return!1;if(r)return!0;e.env.references===void 0&&(e.env.references={}),e.env.references[_]===void 0&&(e.env.references[_]={title:g,href:d});let v=e.push(`reference_definition`,``,0);v.map=[t,o],v.hidden=!0;let y=Object.create(null);return y.label=_,v.meta=y,e.line=o,!0}var ml=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),hl=`<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>`,gl=`<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>`,_l=RegExp(`^(?:${hl}|${gl}|<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)`),vl=RegExp(`^(?:${hl}|${gl})`),yl=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Za-z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[RegExp(`^</?(${ml.join(`|`)})(?=(\\s|/?>|$))`,`i`),/^$/,!0],[RegExp(`${vl.source}\\s*$`),/^$/,!1]];function bl(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(i)!==60)return!1;let o=e.src.slice(i,a),s=0;for(;s<yl.length&&!yl[s][0].test(o);s++);if(s===yl.length)return!1;if(r)return yl[s][2];let c=t+1,l=yl[s][1].test(``);if(!yl[s][1].test(o)){for(;c<n&&!(e.sCount[c]<e.blkIndent&&(l||!e.isEmpty(c)));c++)if(i=e.bMarks[c]+e.tShift[c],a=e.eMarks[c],o=e.src.slice(i,a),yl[s][1].test(o)){o.length!==0&&c++;break}}e.line=c;let u=e.push(`html_block`,``,0);return u.map=[t,c],u.content=e.getLines(t,c,e.blkIndent,!0),!0}function xl(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let o=e.src.charCodeAt(i);if(o!==35||i>=a)return!1;let s=1;for(o=e.src.charCodeAt(++i);o===35&&i<a&&s<=6;)s++,o=e.src.charCodeAt(++i);if(s>6||i<a&&!ac(o))return!1;if(r)return!0;a=e.skipSpacesBack(a,i);let c=e.skipCharsBack(a,35,i);c>i&&ac(e.src.charCodeAt(c-1))&&(a=c),e.line=t+1;let l=e.push(`heading_open`,`h${s}`,1);l.markup=`########`.slice(0,s),l.map=[t,e.line];let u=e.push(`inline`,``,0);u.content=fc(e.src.slice(i,a)),u.map=[t,e.line],u.children=[];let d=e.push(`heading_close`,`h${s}`,-1);return d.markup=`########`.slice(0,s),!0}function Sl(e,t,n){let r=e.md.block.ruler.getRules(`paragraph`);if(e.sCount[t]-e.blkIndent>=4)return!1;let i=e.parentType;e.parentType=`paragraph`;let a=0,o,s=t+1;for(;s<n&&!e.isEmpty(s);s++){if(e.sCount[s]-e.blkIndent>3)continue;if(e.sCount[s]>=e.blkIndent){let t=e.bMarks[s]+e.tShift[s],n=e.eMarks[s];if(t<n&&(o=e.src.charCodeAt(t),(o===45||o===61)&&(t=e.skipChars(t,o),t=e.skipSpaces(t),t>=n))){a=o===61?1:2;break}}if(e.sCount[s]<0)continue;let t=!1;for(let i=0,a=r.length;i<a;i++)if(r[i](e,s,n,!0)){t=!0;break}if(t)break}if(!a)return e.parentType=i,!1;let c=fc(e.getLines(t,s,e.blkIndent,!1));e.line=s+1;let l=e.push(`heading_open`,`h${a}`,1);l.markup=String.fromCharCode(o),l.map=[t,e.line];let u=e.push(`inline`,``,0);u.content=c,u.map=[t,e.line-1],u.children=[];let d=e.push(`heading_close`,`h${a}`,-1);return d.markup=String.fromCharCode(o),e.parentType=i,!0}function Cl(e,t,n){let r=e.md.block.ruler.getRules(`paragraph`),i=e.parentType,a=t+1;for(e.parentType=`paragraph`;a<n&&!e.isEmpty(a);a++){if(e.sCount[a]-e.blkIndent>3||e.sCount[a]<0)continue;let t=!1;for(let i=0,o=r.length;i<o;i++)if(r[i](e,a,n,!0)){t=!0;break}if(t)break}let o=fc(e.getLines(t,a,e.blkIndent,!1));e.line=a;let s=e.push(`paragraph_open`,`p`,1);s.map=[t,e.line];let c=e.push(`inline`,``,0);return c.content=o,c.map=[t,e.line],c.children=[],e.push(`paragraph_close`,`p`,-1),e.parentType=i,!0}var wl=[[`table`,il,[`paragraph`,`reference`]],[`code`,al],[`fence`,ol,[`paragraph`,`reference`,`blockquote`,`list`]],[`blockquote`,sl,[`paragraph`,`reference`,`blockquote`,`list`]],[`hr`,cl,[`paragraph`,`reference`,`blockquote`,`list`]],[`list`,fl,[`paragraph`,`reference`,`blockquote`]],[`reference`,pl],[`html_block`,bl,[`paragraph`,`reference`,`blockquote`]],[`heading`,xl,[`paragraph`,`reference`,`blockquote`]],[`lheading`,Sl],[`paragraph`,Cl]],Tl=class{constructor(){Y(this,`ruler`,new Sc),Y(this,`State`,el);for(let e=0;e<wl.length;e++)this.ruler.push(wl[e][0],wl[e][1],{alt:(wl[e][2]||[]).slice()})}tokenize(e,t,n){let r=this.ruler.getRules(``),i=r.length,a=e.md.options.maxNesting,o=t,s=!1;for(;o<n&&(e.line=o=e.skipEmptyLines(o),!(o>=n||e.sCount[o]<e.blkIndent));){if(e.level>=a){e.line=n;break}let t=e.line,c=!1;for(let a=0;a<i;a++)if(c=r[a](e,o,n,!1),c){if(t>=e.line)throw Error(`block rule didn't increment state.line`);break}if(!c)throw Error(`none of the block rules matched`);e.tight=!s,e.isEmpty(e.line-1)&&(s=!0),o=e.line,o<n&&e.isEmpty(o)&&(s=!0,o++,e.line=o)}}parse(e,t,n,r){if(!e)return;let i=new this.State(e,t,n,r);this.tokenize(i,i.line,i.lineMax)}},El=class{constructor(e,t,n,r){Y(this,`pos`,0),Y(this,`level`,0),Y(this,`pending`,``),Y(this,`pendingLevel`,0),Y(this,`cache`,{}),Y(this,`backticks`,{}),Y(this,`backticksScanned`,!1),Y(this,`linkLevel`,0),Y(this,`delimiters`,[]),Y(this,`_prev_delimiters`,[]),Y(this,`Token`,xc),this.src=e,this.env=n,this.md=t,this.tokens=r,this.tokens_meta=Array(r.length),this.posMax=this.src.length}pushPending(){let e=new xc(`text`,``,0);return e.content=this.pending,e.level=this.pendingLevel,this.tokens.push(e),this.pending=``,e}push(e,t,n){this.pending&&this.pushPending();let r=new xc(e,t,n),i;return n<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),r.level=this.level,n>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(r),this.tokens_meta.push(i),r}scanDelims(e,t){let n=this.posMax,r=this.src.charCodeAt(e),i;if(e===0)i=32;else if(e===1)i=this.src.charCodeAt(0),(i&63488)==55296&&(i=65533);else if(i=this.src.charCodeAt(e-1),(i&64512)==56320){let t=this.src.charCodeAt(e-2);i=(t&64512)==55296?65536+(t-55296<<10)+(i-56320):65533}else(i&64512)==55296&&(i=65533);let a=e;for(;a<n&&this.src.charCodeAt(a)===r;)a++;let o=a-e,s=a<n?this.src.charCodeAt(a):32;if((s&64512)==55296){let e=this.src.charCodeAt(a+1);s=(e&64512)==56320?65536+(s-55296<<10)+(e-56320):65533}else(s&64512)==56320&&(s=65533);let c=lc(i)||cc(i),l=lc(s)||cc(s),u=oc(i),d=oc(s),f=!d&&(!l||u||c),p=!u&&(!c||d||l);return{can_open:f&&(t||!p||c),can_close:p&&(t||!f||l),length:o}}};function Dl(e){switch(e){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}function Ol(e,t){let n=e.pos;for(;n<e.posMax&&!Dl(e.src.charCodeAt(n));)n++;return n!==e.pos&&(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}var kl=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function Al(e,t){if(!e.md.options.linkify||e.linkLevel>0)return!1;let n=e.pos,r=e.posMax;if(n+3>r||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47)return!1;let i=e.pending.match(kl);if(!i)return!1;let a=i[1],o=e.md.linkify.matchAtStart(e.src.slice(n-a.length));if(!o)return!1;let s=o.url;if(s.length<=a.length)return!1;let c=s.length;for(;c>0&&s.charCodeAt(c-1)===42;)c--;c!==s.length&&(s=s.slice(0,c));let l=e.md.normalizeLink(s);if(!e.md.validateLink(l))return!1;if(!t){e.pending=e.pending.slice(0,-a.length);let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,l]],t.markup=`linkify`,t.info=`auto`;let n=e.push(`text`,``,0);n.content=e.md.normalizeLinkText(s);let r=e.push(`link_close`,`a`,-1);r.markup=`linkify`,r.info=`auto`}return e.pos+=s.length-a.length,!0}function jl(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==10)return!1;let r=e.pending.length-1,i=e.posMax;if(!t){if(r>=0&&e.pending.charCodeAt(r)===32){if(r>=1&&e.pending.charCodeAt(r-1)===32){let t=r-1;for(;t>=1&&e.pending.charCodeAt(t-1)===32;)t--;e.pending=e.pending.slice(0,t),e.push(`hardbreak`,`br`,0)}else e.pending=e.pending.slice(0,-1),e.push(`softbreak`,`br`,0)}else e.push(`softbreak`,`br`,0)}for(n++;n<i&&ac(e.src.charCodeAt(n));)n++;return e.pos=n,!0}var Ml=[];for(let e=0;e<256;e++)Ml.push(0);`\\!"#$%&'()*+,./:;<=>?@[]^_\`{|}~-`.split(``).forEach(function(e){Ml[e.charCodeAt(0)]=1});function Nl(e,t){let n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==92||(n++,n>=r))return!1;let i=e.src.charCodeAt(n);if(i===10){for(t||e.push(`hardbreak`,`br`,0),n++;n<r&&(i=e.src.charCodeAt(n),ac(i));)n++;return e.pos=n,!0}if(i===32){if(!t){let t=e.push(`text_special`,``,0);t.content=`\\`,t.markup=`\\`,t.info=`escape`}return e.pos=n,!0}let a=e.src[n];if(i>=55296&&i<=56319&&n+1<r){let t=e.src.charCodeAt(n+1);t>=56320&&t<=57343&&(a+=e.src[n+1],n++)}let o=`\\`+a;if(!t){let t=e.push(`text_special`,``,0);t.content=i<256&&Ml[i]!==0?a:o,t.markup=o,t.info=`escape`}return e.pos=n+1,!0}function Pl(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==96)return!1;let r=n;n++;let i=e.posMax;for(;n<i&&e.src.charCodeAt(n)===96;)n++;let a=e.src.slice(r,n),o=a.length;if(e.backticksScanned&&(e.backticks[o]||0)<=r)return t||(e.pending+=a),e.pos+=o,!0;let s=n,c;for(;(c=e.src.indexOf("`",s))!==-1;){for(s=c+1;s<i&&e.src.charCodeAt(s)===96;)s++;let r=s-c;if(r===o){if(!t){let t=e.push(`code_inline`,`code`,0);t.markup=a,t.content=e.src.slice(n,c).replace(/\n/g,` `).replace(/^ (.+) $/,`$1`)}return e.pos=s,!0}e.backticks[r]=c}return e.backticksScanned=!0,t||(e.pending+=a),e.pos+=o,!0}function X(e,t){let n=e.pos,r=e.src.charCodeAt(n);if(t||r!==126)return!1;let i=e.scanDelims(e.pos,!0),a=i.length,o=String.fromCharCode(r);if(a<2)return!1;let s;a%2&&(s=e.push(`text`,``,0),s.content=o,a--);for(let t=0;t<a;t+=2)s=e.push(`text`,``,0),s.content=o+o,e.delimiters.push({marker:r,length:0,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return e.pos+=i.length,!0}function Fl(e,t){let n,r=[],i=t.length;for(let a=0;a<i;a++){let i=t[a];if(i.marker!==126||i.end===-1)continue;let o=t[i.end];n=e.tokens[i.token],n.type=`s_open`,n.tag=`s`,n.nesting=1,n.markup=`~~`,n.content=``,n=e.tokens[o.token],n.type=`s_close`,n.tag=`s`,n.nesting=-1,n.markup=`~~`,n.content=``,e.tokens[o.token-1].type===`text`&&e.tokens[o.token-1].content===`~`&&r.push(o.token-1)}for(;r.length;){let t=r.pop(),i=t+1;for(;i<e.tokens.length&&e.tokens[i].type===`s_close`;)i++;i--,t!==i&&(n=e.tokens[i],e.tokens[i]=e.tokens[t],e.tokens[t]=n)}}function Z(e){let t=e.tokens_meta,n=e.tokens_meta.length;Fl(e,e.delimiters);for(let r=0;r<n;r++){let n=t[r]?.delimiters;n&&Fl(e,n)}}var Q={tokenize:X,postProcess:Z};function Il(e,t){let n=e.pos,r=e.src.charCodeAt(n);if(t||r!==95&&r!==42)return!1;let i=e.scanDelims(e.pos,r===42);for(let t=0;t<i.length;t++){let t=e.push(`text`,``,0);t.content=String.fromCharCode(r),e.delimiters.push({marker:r,length:i.length,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close})}return e.pos+=i.length,!0}function Ll(e,t){let n=t.length;for(let r=n-1;r>=0;r--){let n=t[r];if(n.marker!==95&&n.marker!==42||n.end===-1)continue;let i=t[n.end],a=r>0&&t[r-1].end===n.end+1&&t[r-1].marker===n.marker&&t[r-1].token===n.token-1&&t[n.end+1].token===i.token+1,o=String.fromCharCode(n.marker),s=e.tokens[n.token];s.type=a?`strong_open`:`em_open`,s.tag=a?`strong`:`em`,s.nesting=1,s.markup=a?o+o:o,s.content=``;let c=e.tokens[i.token];c.type=a?`strong_close`:`em_close`,c.tag=a?`strong`:`em`,c.nesting=-1,c.markup=a?o+o:o,c.content=``,a&&(e.tokens[t[r-1].token].content=``,e.tokens[t[n.end+1].token].content=``,r--)}}function Rl(e){let t=e.tokens_meta,n=e.tokens_meta.length;Ll(e,e.delimiters);for(let r=0;r<n;r++){let n=t[r]?.delimiters;n&&Ll(e,n)}}var zl={tokenize:Il,postProcess:Rl};function Bl(e,t){let n,r,i,a,o=``,s=``,c=e.pos,l=!0;if(e.src.charCodeAt(e.pos)!==91)return!1;let u=e.pos,d=e.posMax,f=e.pos+1,p=e.md.helpers.parseLinkLabel(e,e.pos,!0);if(p<0)return!1;let m=p+1;if(m<d&&e.src.charCodeAt(m)===40){for(l=!1,m++;m<d&&(n=e.src.charCodeAt(m),!(!ac(n)&&n!==10));m++);if(m>=d)return!1;if(c=m,i=e.md.helpers.parseLinkDestination(e.src,m,e.posMax),i.ok){for(o=e.md.normalizeLink(i.str),e.md.validateLink(o)?m=i.pos:o=``,c=m;m<d&&(n=e.src.charCodeAt(m),!(!ac(n)&&n!==10));m++);if(i=e.md.helpers.parseLinkTitle(e.src,m,e.posMax),m<d&&c!==m&&i.ok)for(s=i.str,m=i.pos;m<d&&(n=e.src.charCodeAt(m),!(!ac(n)&&n!==10));m++);}(m>=d||e.src.charCodeAt(m)!==41)&&(l=!0),m++}if(l){if(e.env.references===void 0)return!1;if(m<d&&e.src.charCodeAt(m)===91?(c=m+1,m=e.md.helpers.parseLinkLabel(e,m),m>=0?r=e.src.slice(c,m++):m=p+1):m=p+1,r||=e.src.slice(f,p),r=uc(r),a=e.env.references[r],!a)return e.pos=u,!1;o=a.href,s=a.title}if(!t){e.pos=f,e.posMax=p;let t=e.push(`link_open`,`a`,1),n=[[`href`,o]];if(t.attrs=n,s&&n.push([`title`,s]),r){let e=Object.create(null);e.label=r,t.meta=e}e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,e.push(`link_close`,`a`,-1)}return e.pos=m,e.posMax=d,!0}function Vl(e,t){let n,r,i,a,o,s,c,l,u=``,d=e.pos,f=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91)return!1;let p=e.pos+2,m=e.md.helpers.parseLinkLabel(e,e.pos+1,!1);if(m<0)return!1;if(a=m+1,a<f&&e.src.charCodeAt(a)===40){for(a++;a<f&&(n=e.src.charCodeAt(a),!(!ac(n)&&n!==10));a++);if(a>=f)return!1;for(l=a,s=e.md.helpers.parseLinkDestination(e.src,a,e.posMax),s.ok&&(u=e.md.normalizeLink(s.str),e.md.validateLink(u)?a=s.pos:u=``),l=a;a<f&&(n=e.src.charCodeAt(a),!(!ac(n)&&n!==10));a++);if(s=e.md.helpers.parseLinkTitle(e.src,a,e.posMax),a<f&&l!==a&&s.ok)for(c=s.str,a=s.pos;a<f&&(n=e.src.charCodeAt(a),!(!ac(n)&&n!==10));a++);else c=``;if(a>=f||e.src.charCodeAt(a)!==41)return e.pos=d,!1;a++}else{if(e.env.references===void 0)return!1;if(a<f&&e.src.charCodeAt(a)===91?(l=a+1,a=e.md.helpers.parseLinkLabel(e,a),a>=0?i=e.src.slice(l,a++):a=m+1):a=m+1,i||=e.src.slice(p,m),i=uc(i),o=e.env.references[i],!o)return e.pos=d,!1;u=o.href,c=o.title}if(!t){r=e.src.slice(p,m);let t=[];e.md.inline.parse(r,e.md,e.env,t);let n=e.push(`image`,`img`,0),a=[[`src`,u],[`alt`,``]];if(n.attrs=a,n.children=t,n.content=r,c&&a.push([`title`,c]),i){let e=Object.create(null);e.label=i,n.meta=e}}return e.pos=a,e.posMax=f,!0}var Hl=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,Ul=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function Wl(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==60)return!1;let r=e.pos,i=e.posMax;for(;;){if(++n>=i)return!1;let t=e.src.charCodeAt(n);if(t===60)return!1;if(t===62)break}let a=e.src.slice(r+1,n);if(Ul.test(a)){let n=e.md.normalizeLink(a);if(!e.md.validateLink(n))return!1;if(!t){let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,n]],t.markup=`autolink`,t.info=`auto`;let r=e.push(`text`,``,0);r.content=e.md.normalizeLinkText(a);let i=e.push(`link_close`,`a`,-1);i.markup=`autolink`,i.info=`auto`}return e.pos+=a.length+2,!0}if(Hl.test(a)){let n=e.md.normalizeLink(`mailto:${a}`);if(!e.md.validateLink(n))return!1;if(!t){let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,n]],t.markup=`autolink`,t.info=`auto`;let r=e.push(`text`,``,0);r.content=e.md.normalizeLinkText(a);let i=e.push(`link_close`,`a`,-1);i.markup=`autolink`,i.info=`auto`}return e.pos+=a.length+2,!0}return!1}function Gl(e){return/^<a[>\s]/i.test(e)}function Kl(e){return/^<\/a\s*>/i.test(e)}function ql(e){let t=e|32;return t>=97&&t<=122}function Jl(e,t){if(!e.md.options.html)return!1;let n=e.posMax,r=e.pos;if(e.src.charCodeAt(r)!==60||r+2>=n)return!1;let i=e.src.charCodeAt(r+1);if(i!==33&&i!==63&&i!==47&&!ql(i))return!1;let a=e.src.slice(r).match(_l);if(!a)return!1;if(!t){let t=e.push(`html_inline`,``,0);t.content=a[0],Gl(t.content)&&e.linkLevel++,Kl(t.content)&&e.linkLevel--}return e.pos+=a[0].length,!0}var Yl=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,Xl=/^&([a-z][a-z0-9]{1,31});/i;function Zl(e,t){let n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==38||n+1>=r)return!1;if(e.src.charCodeAt(n+1)===35){let r=e.src.slice(n).match(Yl);if(r){if(!t){let t=r[1][0].toLowerCase()===`x`?parseInt(r[1].slice(1),16):parseInt(r[1],10),n=e.push(`text_special`,``,0);n.content=Ws(t)?Gs(t):Gs(65533),n.markup=r[0],n.info=`entity`}return e.pos+=r[0].length,!0}}else{let r=e.src.slice(n).match(Xl);if(r){let n=ns(r[0]);if(n!==r[0]){if(!t){let t=e.push(`text_special`,``,0);t.content=n,t.markup=r[0],t.info=`entity`}return e.pos+=r[0].length,!0}}}return!1}function Ql(e){let t={},n=e.length;if(!n)return;let r=0,i=-2,a=[];for(let o=0;o<n;o++){let n=e[o];if(a.push(0),(e[r].marker!==n.marker||i!==n.token-1)&&(r=o),i=n.token,n.length=n.length||0,!n.close)continue;t.hasOwnProperty(n.marker)||(t[n.marker]=[-1,-1,-1,-1,-1,-1]);let s=t[n.marker][(n.open?3:0)+n.length%3],c=r-a[r]-1,l=c;for(;c>s;c-=a[c]+1){let t=e[c];if(t.marker===n.marker&&t.open&&t.end<0){let r=!1;if((t.close||n.open)&&(t.length+n.length)%3==0&&(t.length%3!=0||n.length%3!=0)&&(r=!0),!r){let r=c>0&&!e[c-1].open?a[c-1]+1:0;a[o]=o-c+r,a[c]=r,n.open=!1,t.end=o,t.close=!1,l=-1,i=-2;break}}}l!==-1&&(t[n.marker][(n.open?3:0)+(n.length||0)%3]=l)}}function $l(e){let t=e.tokens_meta,n=e.tokens_meta.length;Ql(e.delimiters);for(let e=0;e<n;e++){let n=t[e]?.delimiters;n&&Ql(n)}}function eu(e){let t,n,r=0,i=e.tokens,a=e.tokens.length;for(t=n=0;t<a;t++)i[t].nesting<0&&r--,i[t].level=r,i[t].nesting>0&&r++,i[t].type===`text`&&t+1<a&&i[t+1].type===`text`?i[t+1].content=i[t].content+i[t+1].content:(t!==n&&(i[n]=i[t]),n++);t!==n&&(i.length=n)}var tu=[[`text`,Ol],[`linkify`,Al],[`newline`,jl],[`escape`,Nl],[`backticks`,Pl],[`strikethrough`,Q.tokenize],[`emphasis`,zl.tokenize],[`link`,Bl],[`image`,Vl],[`autolink`,Wl],[`html_inline`,Jl],[`entity`,Zl]],nu=[[`balance_pairs`,$l],[`strikethrough`,Q.postProcess],[`emphasis`,zl.postProcess],[`fragments_join`,eu]],ru=class{constructor(){Y(this,`ruler`,new Sc),Y(this,`ruler2`,new Sc),Y(this,`State`,El);for(let e=0;e<tu.length;e++)this.ruler.push(tu[e][0],tu[e][1]);for(let e=0;e<nu.length;e++)this.ruler2.push(nu[e][0],nu[e][1])}skipToken(e){let t=e.pos,n=this.ruler.getRules(``),r=n.length,i=e.md.options.maxNesting,a=e.cache;if(a[t]!==void 0){e.pos=a[t];return}let o=!1;if(e.level<i){for(let i=0;i<r;i++)if(e.level++,o=n[i](e,!0),e.level--,o){if(t>=e.pos)throw Error(`inline rule didn't increment state.pos`);break}}else e.pos=e.posMax;o||e.pos++,a[t]=e.pos}tokenize(e){let t=this.ruler.getRules(``),n=t.length,r=e.posMax,i=e.md.options.maxNesting;for(;e.pos<r;){let a=e.pos,o=!1;if(e.level<i){for(let r=0;r<n;r++)if(o=t[r](e,!1),o){if(a>=e.pos)throw Error(`inline rule didn't increment state.pos`);break}}if(o){if(e.pos>=r)break;continue}e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()}parse(e,t,n,r){let i=new this.State(e,t,n,r);this.tokenize(i);let a=this.ruler2.getRules(``),o=a.length;for(let e=0;e<o;e++)a[e](i)}},iu={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:`language-`,linkify:!1,typographer:!1,quotes:`“”‘’`,highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:`language-`,linkify:!1,typographer:!1,quotes:`“”‘’`,highlight:null,maxNesting:20},components:{core:{rules:[`normalize`,`block`,`strip_references`,`inline`,`text_join`]},block:{rules:[`paragraph`]},inline:{rules:[`text`],rules2:[`balance_pairs`,`fragments_join`]}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:`language-`,linkify:!1,typographer:!1,quotes:`“”‘’`,highlight:null,maxNesting:20},components:{core:{rules:[`normalize`,`block`,`strip_references`,`inline`,`text_join`]},block:{rules:[`blockquote`,`code`,`fence`,`heading`,`hr`,`html_block`,`lheading`,`list`,`reference`,`paragraph`]},inline:{rules:[`autolink`,`backticks`,`emphasis`,`entity`,`escape`,`html_inline`,`image`,`link`,`newline`,`text`],rules2:[`balance_pairs`,`emphasis`,`fragments_join`]}}}},au=/^(vbscript|javascript|file|data):/,ou=/^data:image\/(gif|png|jpeg|webp);/,su=[`http:`,`https:`,`mailto:`],cu=class{validateLink(e){let t=e.trim().toLowerCase();return!au.test(t)||ou.test(t)}normalizeLink(e){let t=Ao(e,!0);if(t.hostname&&(!t.protocol||su.indexOf(t.protocol)>=0))try{t.hostname=Rs.toASCII(t.hostname)}catch{}return _o(vo(t))}normalizeLinkText(e){let t=Ao(e,!0);if(t.hostname&&(!t.protocol||su.indexOf(t.protocol)>=0))try{t.hostname=Rs.toUnicode(t.hostname)}catch{}return mo(vo(t),mo.defaultChars+`%`)}constructor(...e){Y(this,`inline`,new ru),Y(this,`block`,new Tl),Y(this,`core`,new $c),Y(this,`renderer`,new wc),Y(this,`linkify`,new ds),Y(this,`utils`,Vs),Y(this,`helpers`,Object.assign({},_c));let[t,n]=e;typeof t==`string`?(this.configure(t),n&&this.set(n)):(this.configure(`default`),this.set(t||{}))}set(e){return Object.assign(this.options,e),this}configure(e){let t;if(typeof e==`string`){let n=e;if(t=iu[n],!t)throw Error(`Wrong 'markdown-it' preset "${n}", check name`)}else t=e;if(!t)throw Error("Wrong `markdown-it` preset, can't be empty");t.options&&(this.options={...t.options});let n=t.components;if(n){[`core`,`block`,`inline`].forEach(e=>{let t=n[e]?.rules;t&&this[e].ruler.enableOnly(t)});let e=n.inline?.rules2;e&&this.inline.ruler2.enableOnly(e)}return this}enable(e,t=!1){let n=[];Array.isArray(e)||(e=[e]),[`core`,`block`,`inline`].forEach(t=>{n=n.concat(this[t].ruler.enable(e,!0))}),n=n.concat(this.inline.ruler2.enable(e,!0));let r=e.filter(e=>n.indexOf(e)<0);if(r.length&&!t)throw Error(`MarkdownIt. Failed to enable unknown rule(s): ${r}`);return this}disable(e,t=!1){let n=[];Array.isArray(e)||(e=[e]),[`core`,`block`,`inline`].forEach(t=>{n=n.concat(this[t].ruler.disable(e,!0))}),n=n.concat(this.inline.ruler2.disable(e,!0));let r=e.filter(e=>n.indexOf(e)<0);if(r.length&&!t)throw Error(`MarkdownIt. Failed to disable unknown rule(s): ${r}`);return this}use(e,...t){return e.apply(e,[this,...t]),this}parse(e,t){if(typeof e!=`string`)throw Error(`Input data should be a String`);let n=new this.core.State(e,this,t);return this.core.process(n),n.tokens}render(e,t={}){return this.renderer.render(this.parse(e,t),this.options,t)}parseInline(e,t){let n=new this.core.State(e,this,t);return n.inlineMode=!0,this.core.process(n),n.tokens}renderInline(e,t={}){return this.renderer.render(this.parseInline(e,t),this.options,t)}};Y(cu,`Token`,xc),Y(cu,`Ruler`,Sc),Y(cu,`Renderer`,wc),Y(cu,`ParserCore`,$c),Y(cu,`StateCore`,Tc),Y(cu,`ParserBlock`,Tl),Y(cu,`StateBlock`,el),Y(cu,`ParserInline`,ru),Y(cu,`StateInline`,El);var lu=new(Hs(cu))({html:!1,linkify:!0,typographer:!1}),uu=0;lu.core.ruler.push(`source_map`,e=>{for(let t of e.tokens)t.map&&t.block&&t.nesting>=0&&t.type!==`inline`&&(t.attrSet(`data-line`,String(t.map[0]+1+uu)),t.attrSet(`data-line-end`,String(t.map[1]+1+uu)))});var du=lu.renderer.rules.fence;lu.renderer.rules.fence=(e,t,n,r,i)=>{let a=e[t],o=a.map?` data-line="${a.map[0]+1+uu}" data-line-end="${a.map[1]+1+uu}"`:``;return a.info.trim()===`mermaid`?`<div class="mermaid"${o}>${lu.utils.escapeHtml(a.content)}</div>`:du(e,t,n,r,i).replace(/^<pre/,`<pre${o}`)};var fu=new Map;function pu(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/);return t?{meta:t[1].split(`
23
23
  `).map(e=>{let t=e.indexOf(`:`);return t>0?[e.slice(0,t).trim(),e.slice(t+1).trim()]:null}).filter(e=>!!e&&!!e[0]),body:e.slice(t[0].length)}:{meta:null,body:e}}function mu(e){let t=fu.get(e);if(t)return t;let{meta:n,body:r}=pu(e),i=e.length-r.length?e.slice(0,e.length-r.length).split(`
24
- `).length-1:0,a=n?`<div class="frontmatter" data-line="1" data-line-end="${i+1}"><table>${n.map(([e,t])=>`<tr><th>${lu.utils.escapeHtml(e)}</th><td>${lu.utils.escapeHtml(t)}</td></tr>`).join(``)}</table></div>`:``;uu=i;let o=a+lu.render(r).replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(e,t,n)=>`<a class="wikilink" href="#/docs/${encodeURIComponent(t)}">${n??t}</a>`).replace(/<li([^>]*)>\[( |x|X)\] /g,(e,t,n)=>`<li${t} class="task"><input type="checkbox" disabled${n.trim()?` checked`:``}> `);return fu.size>200&&fu.clear(),fu.set(e,o),o}var hu={theme:`base`,themeVariables:{primaryColor:`#FFFFFF`,primaryBorderColor:`#2B1D14`,primaryTextColor:`#2B1D14`,lineColor:`#9A7A60`,secondaryColor:`#FBE3D0`,tertiaryColor:`#EFE5D8`,fontFamily:`"Source Sans 3", system-ui, sans-serif`,fontSize:`13px`}};function gu(e){let t=[],n=e.newStart,r=!1;for(let i of e.lines)if(i.startsWith(`+`)){let e=t[t.length-1];e&&e[1]===n?e[1]=n+1:t.push([n,n+1]),n++,r=!1}else i.startsWith(`-`)?r||=(t.push([n,n+1]),!0):(n++,r=!1);return t}function _u(e,t){e.querySelectorAll(`[data-chg]`).forEach(e=>{e.removeAttribute(`data-chg`),e.removeAttribute(`data-hunk`),e.classList.remove(`chg-uncommitted`,`chg-commit`)});let n=[...e.querySelectorAll(`[data-line]`)];t.forEach((e,t)=>e.hunks.forEach((r,i)=>{let a=gu(r),o=n.filter(e=>{let t=+e.dataset.line,n=+e.dataset.lineEnd;return a.some(([e,r])=>t<r&&n>e)});for(let n of o)o.some(e=>e!==n&&n.contains(e))||n.dataset.chg!==`uncommitted`&&(n.dataset.chg=e.kind,n.dataset.hunk=`${t}:${i}`,n.classList.add(e.kind===`uncommitted`?`chg-uncommitted`:`chg-commit`))}))}function vu(e,t){if(t.length===0)return e;let n=document.createElement(`div`);return n.innerHTML=e,_u(n,t),n.innerHTML}var yu=(0,P.memo)(function({html:e,className:t,onOver:n,onLeave:r}){let i=(0,P.useRef)(null);return(0,P.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.querySelectorAll(`.mermaid:not([data-processed])`);if(t.length===0)return;let n=!1;return oi(async()=>{let{default:e}=await import(`./mermaid.core-BYlHVIMn.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])).then(async({default:e})=>{n||(e.initialize({startOnLoad:!1,...hu}),await e.run({nodes:t}))}),()=>{n=!0}},[e]),(0,B.jsx)(`div`,{ref:i,className:`md ${t}`,dangerouslySetInnerHTML:{__html:e},onMouseOver:n,onMouseLeave:r})});function bu({source:e,changes:t=[],className:n=``}){let r=mu(e),[i,a]=(0,P.useState)(null),o=(0,P.useMemo)(()=>vu(r,t),[r,t]),s=(0,P.useRef)(t);s.current=t;let c=(0,P.useCallback)(e=>{let t=e.target.closest(`[data-hunk]`);if(!t){a(e=>e&&null);return}let[n,r]=t.dataset.hunk.split(`:`).map(Number),i=s.current[n],o=i?.hunks[r];if(!i||!o){a(null);return}let c=t.getBoundingClientRect();a({x:Math.min(c.left,window.innerWidth-560),y:c.bottom+6,change:i,hunk:o})},[]),l=(0,P.useCallback)(()=>a(null),[]);return(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(yu,{html:o,className:n,onOver:c,onLeave:l}),i&&(0,B.jsxs)(`div`,{className:`fixed z-50 max-w-[540px] max-h-[50vh] overflow-auto bg-paper border border-sand rounded-kit shadow-panel text-[12px]`,style:{left:i.x,top:i.y},children:[(0,B.jsxs)(`div`,{className:`px-3 py-1.5 border-b border-sand font-mono flex gap-2 items-baseline ${i.change.kind===`uncommitted`?`text-amber`:`text-leaf`}`,children:[(0,B.jsx)(`b`,{children:i.change.kind===`uncommitted`?`uncommitted`:`last commit`}),(0,B.jsx)(`span`,{className:`text-ink3 truncate`,children:i.change.label}),(0,B.jsxs)(`span`,{className:`ml-auto text-tan`,children:[`@@ +`,i.hunk.newStart,`,`,i.hunk.newLines]})]}),(0,B.jsx)(`pre`,{className:`m-0 px-3 py-2 font-mono leading-[1.5] whitespace-pre-wrap`,children:i.hunk.lines.map((e,t)=>(0,B.jsx)(`div`,{className:e.startsWith(`+`)?`bg-moss-wash text-moss`:e.startsWith(`-`)?`bg-brick-wash text-brick line-through decoration-brick/40`:`text-umber`,children:e},t))})]})]})}function xu(e,t){let n=e.trim().replace(/^['"`<(]+|[>'"`)]+$/g,``),r,i=n.match(/:(\d+)$/);i&&(r=Number(i[1]),n=n.slice(0,-i[0].length)),n.startsWith(`[[`)&&n.endsWith(`]]`)&&(n=n.slice(2,-2).split(`|`)[0].trim()),n=n.replace(/\\/g,`/`);let a=n.toLowerCase().lastIndexOf(`/docs/`);a>=0&&(n=n.slice(a+1)),n.startsWith(`./`)&&(n=n.slice(2));let o=n.toLowerCase().startsWith(`docs/`)?n.slice(5):n,s=o.replace(/\.md$/i,``);if(!t.length)return/^[\w./-]+\.md$/i.test(o)?{file:o,line:r}:s&&!s.includes(` `)?{file:`${s}.md`,line:r}:null;let c=t.filter(e=>{let t=e.replace(/\.md$/i,``),n=e.split(`/`).pop()?.replace(/\.md$/i,``);return e===o||e===`${o}.md`||t===s||t.endsWith(`/${s}`)||e.endsWith(`/${o}`)||n===s});return c.length===1?{file:c[0],line:r}:c.includes(o)?{file:o,line:r}:c.includes(`${o}.md`)?{file:`${o}.md`,line:r}:null}var Su=/\[\[([^\]|]+)(?:\|[^\]]+)?\]\](?::\d+)?|(?:(?:~\/|\.{1,2}\/)?(?:[\w.-]+\/)+)?[\w.-]+\.md(?::\d+)?/g;function Cu(e,t,n){return e==null||typeof e==`boolean`||typeof e==`number`?e:typeof e==`string`?wu(e,t,n):Array.isArray(e)?e.map((e,r)=>{let i=Cu(e,t,n);return(0,P.isValidElement)(i)&&i.key==null?(0,P.cloneElement)(i,{key:r}):i}):(0,P.isValidElement)(e)&&e.props.children!=null?(0,P.cloneElement)(e,void 0,Cu(e.props.children,t,n)):e}function wu(e,t,n){if(Su.lastIndex=0,!Su.test(e))return e;Su.lastIndex=0;let r=[],i=0,a,o=0;for(;a=Su.exec(e);){a.index>i&&r.push(e.slice(i,a.index));let s=a[0],c=xu(s,t);c?r.push((0,B.jsx)(`button`,{type:`button`,className:`md-ref`,title:`Open ${c.file}${c.line?`:${c.line}`:``}`,onClick:e=>{e.preventDefault(),e.stopPropagation(),n(c)},children:s},`md-${o++}`)):r.push(s),i=a.index+s.length}return i<e.length&&r.push(e.slice(i)),r.length===1?r[0]:r}var Tu=(0,P.createContext)({files:[],open:()=>{},linkify:e=>e}),Eu=()=>(0,P.useContext)(Tu);function Du({children:e}){let{current:t}=za(),n=ar(),[r,i]=(0,P.useState)(null),a=q(t?`/projects/${t}/docs`:null,3e4).data?.files??[],o=q(r?`/projects/${r.project}/docs/${encodeURIComponent(r.ref.file)}`:null),s=(e,n)=>{let r=n||t;r&&i({ref:e,project:r})};return(0,P.useEffect)(()=>{if(!r)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),e.preventDefault(),i(null))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r]),(0,P.useEffect)(()=>{if(!r||!o.data||!r.ref.line)return;let e=setTimeout(()=>document.getElementById(`L${r.ref.line}`)?.scrollIntoView({block:`center`}),80);return()=>clearTimeout(e)},[r,o.data]),(0,B.jsxs)(Tu.Provider,{value:{files:a,open:s,linkify:(e,n)=>Cu(e,a,e=>s(e,n||t))},children:[e,r&&(0,B.jsx)(`div`,{className:`fixed inset-0 z-[70] bg-walnut/40 flex items-start justify-center pt-[8vh] px-4`,onMouseDown:e=>{e.target===e.currentTarget&&i(null)},children:(0,B.jsxs)(`div`,{className:`w-[min(820px,94vw)] max-h-[84vh] bg-paper border border-sand rounded-kit shadow-panel grid grid-rows-[auto_1fr] overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-sand flex items-center gap-2 min-w-0`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3 truncate`,title:o.data?.path??r.ref.file,children:[o.data?.path??`docs/${r.ref.file}`,r.ref.line?`:${r.ref.line}`:``]}),(0,B.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[(0,B.jsx)(K,{size:`sm`,onClick:()=>{n(`/docs/${encodeURIComponent(r.ref.file)}${r.ref.line?`?view=source&line=${r.ref.line}`:``}`),i(null)},children:`Open in Docs`}),(0,B.jsx)(K,{size:`sm`,onClick:()=>i(null),children:`Close (Esc)`})]})]}),(0,B.jsxs)(`div`,{className:`overflow-auto px-6 py-4`,children:[o.loading&&(0,B.jsx)(`div`,{className:`text-[13px] text-umber`,children:`loading…`}),o.error&&(0,B.jsxs)(`div`,{className:`text-[13px] text-brick`,children:[`Could not load — not in `,r.project,`’s docs/? `,o.error]}),o.data&&(0,B.jsx)(bu,{source:o.data.source})]})]})})]})}var Ou=[`circle`,`square`,`diamond`,`hexagon`,`triangle`,`shield`,`leaf`,`pentagon`];function ku(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}var Au=e=>Ou[ku(e)%Ou.length];function ju(e,t){let n=t/2,r=t/2-1,i=(e,t=-Math.PI/2)=>Array.from({length:e},(i,a)=>{let o=t+a*2*Math.PI/e;return`${(n+r*Math.cos(o)).toFixed(2)},${(n+r*Math.sin(o)).toFixed(2)}`}).join(` `);switch(e){case`circle`:return(0,B.jsx)(`circle`,{cx:n,cy:n,r});case`square`:return(0,B.jsx)(`rect`,{x:1.5,y:1.5,width:t-3,height:t-3,rx:2});case`diamond`:return(0,B.jsx)(`polygon`,{points:i(4)});case`hexagon`:return(0,B.jsx)(`polygon`,{points:i(6,0)});case`triangle`:return(0,B.jsx)(`polygon`,{points:i(3)});case`pentagon`:return(0,B.jsx)(`polygon`,{points:i(5)});case`shield`:return(0,B.jsx)(`path`,{d:`M${n} 1.5 L${t-1.5} ${t*.3} V${t*.55} Q${t-1.5} ${t-2} ${n} ${t-1.5} Q1.5 ${t-2} 1.5 ${t*.55} V${t*.3} Z`});case`leaf`:return(0,B.jsx)(`path`,{d:`M${n} 1.5 Q${t-1.5} ${t*.35} ${t-2.5} ${t-2} Q${t*.35} ${t-1.5} 1.5 ${n} Q${t*.35} 1.5 ${n} 1.5 Z`})}}function Mu({id:e,role:t,size:n=18,state:r,active:i,className:a=``}){let o=td(t),s=Au(e),c=r===`dead`?.35:r===`idle`?.7:1,l=e.replace(/[^a-z0-9]/gi,``).slice(0,1).toUpperCase();return(0,B.jsxs)(`span`,{className:`relative inline-flex shrink-0 ${a}`,style:{width:n,height:n},title:`${e}${t?` · ${t}`:``}`,children:[(0,B.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 ${n} ${n}`,style:{opacity:c},"aria-hidden":!0,children:[(0,B.jsx)(`g`,{fill:o,stroke:o,strokeWidth:`1`,children:ju(s,n)}),(0,B.jsx)(`text`,{x:n/2,y:n/2+n*.22,textAnchor:`middle`,fontSize:n*.55,fontFamily:`JetBrains Mono, monospace`,fontWeight:`700`,fill:`#FCFAF6`,children:l})]}),i&&(0,B.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 w-2 h-2 rounded-full bg-moss ring-2 ring-paper`,children:(0,B.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-moss animate-ping opacity-60`})})]})}var Nu=e=>/done|merged|deployed|complete|closed|✅/i.test(e);function Pu(e){return e?e.workstreams.rows.filter(e=>!(`malformed`in e)).map(e=>e.schema===`workstreams.v1`?{name:e.stream,owner:e.owner,status:e.status,note:e.lastNote??``}:{name:e.lane,owner:e.owner,status:e.state,note:e.currentSlice??``}).map(e=>({...e,done:Nu(e.status)})):[]}var Fu=e=>e.match(/^Task\s+(\d+)\b/i)?.[1]??null;function Iu(e,t,n){if(!n)return null;let r=t.replace(/\./g,`\\.`),i=RegExp(`(^|\\b)(P${r}[-.\\s]?T${n}\\b|Phase\\s*${r}\\b.*\\bT(?:ask)?\\s*${n}\\b)`,`i`);return e.find(e=>i.test(e.name))??null}function Lu(e,t){let n=e.trim().toLowerCase();return t.find(e=>e.toLowerCase()===n)??t.find(e=>n.includes(e.toLowerCase()))??null}function Ru({text:e}){let t=[],n=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[\[([^\]|]+)(?:\|([^\]]+))?\]\])/g,r=0,i,a=0;for(;i=n.exec(e);)i.index>r&&t.push(e.slice(r,i.index)),i[1]?t.push((0,B.jsx)(`code`,{className:`font-mono text-[.92em] px-1 rounded bg-linen text-walnut`,children:i[1].slice(1,-1)},a++)):i[2]?t.push((0,B.jsx)(`b`,{children:i[2].slice(2,-2)},a++)):t.push((0,B.jsx)(V,{to:`/docs/${encodeURIComponent(i[4])}`,onClick:e=>e.stopPropagation(),className:`text-ember-deep`,children:i[5]??i[4]},a++)),r=i.index+i[0].length;return r<e.length&&t.push(e.slice(r)),(0,B.jsx)(B.Fragment,{children:t})}function zu({stream:e,agents:t,size:n=`sm`}){if(!e)return null;let r=Lu(e.owner,t.map(e=>e.agentId));return(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 shrink-0`,title:`${e.name} · ${e.owner} · ${e.status}${e.note?` · ${e.note}`:``}`,children:[r?(0,B.jsx)($u,{id:r,bare:!0,size:n}):(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[11px] text-umber`,children:[(0,B.jsx)(Mu,{id:e.owner,size:14,state:`dead`}),e.owner]}),(0,B.jsx)(G,{tone:e.done?`ok`:/block/i.test(e.status)?`bad`:/queued|hold|wait/i.test(e.status)?`warn`:`neutral`,children:e.status.replace(/^[^\w]+/,``).slice(0,16)})]})}function Bu({project:e,phase:t,highlight:n,maxH:r=`46vh`,compact:i=!1}){let{data:a,error:o}=q(`/projects/${e}/phases/${t.id}/tasks`,15e3),s=q(`/projects/${e}/board`,15e3).data,c=q(`/bus/agents`,2e4).data??[],l=Pu(s),[u,d]=(0,P.useState)({});return o?(0,B.jsx)(`div`,{className:`px-3 py-2 text-[13px] text-brick`,children:o}):a?a.sections.length===0?(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:[`No tasks yet — run `,(0,B.jsx)(`code`,{children:`/plan-phase`}),` (roadmap → Plan).`]}):(0,B.jsx)(`div`,{className:`grid gap-0 overflow-auto min-w-0`,style:{maxHeight:r},children:a.sections.map(e=>{let r=e.tasks.filter(e=>e.done).length,o=r===e.tasks.length,s=Iu(l,t.n,Fu(e.title)),f=!!n&&!!s&&Lu(s.owner,c.map(e=>e.agentId))===n,p=i&&o&&!u[e.line];return(0,B.jsxs)(`div`,{className:`border-b border-sand last:border-b-0 min-w-0 ${f?`bg-ember/[.04]`:``}`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-[1] px-3 py-1.5 min-w-0 ${f?`bg-ember-wash`:`bg-cream`} ${i?`grid gap-0.5`:`flex items-center gap-2`}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[i&&o&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>d(t=>({...t,[e.line]:!t[e.line]})),className:`border-0 bg-transparent p-0 cursor-pointer font-mono text-[11px] text-tan w-3 shrink-0`,title:p?`show done sub-steps`:`collapse`,children:p?`▸`:`▾`}),f&&(0,B.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-ember shrink-0`,title:`this agent's task`}),(0,B.jsx)(V,{to:`/docs/${encodeURIComponent(a.file)}?view=source&line=${e.line}`,className:`font-semibold text-[12px] hover:no-underline hover:text-ember-deep truncate ${o?`text-tan`:`text-umber`}`,children:e.title}),(0,B.jsxs)(`span`,{className:`font-mono text-[11px] shrink-0 ${o?`text-leaf`:`text-tan`}`,children:[r,`/`,e.tasks.length,o?` ✓`:``]}),!i&&(0,B.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[(0,B.jsx)(zu,{stream:s,agents:c}),(0,B.jsx)(`span`,{className:`h-1 w-24 rounded-full bg-linen overflow-hidden`,children:(0,B.jsx)(`span`,{className:`block h-full ${o?`bg-leaf`:`bg-ember`}`,style:{width:`${e.tasks.length?r/e.tasks.length*100:0}%`}})})]})]}),i&&s&&(0,B.jsx)(`div`,{className:`flex items-center gap-2 min-w-0 pl-5`,children:(0,B.jsx)(zu,{stream:s,agents:c})})]}),!p&&e.tasks.map(e=>(0,B.jsxs)(V,{to:`/docs/${encodeURIComponent(a.file)}?view=source&line=${e.line}`,className:`grid grid-cols-[var(--spacing-gutter)_minmax(0,1fr)] items-start hover:no-underline hover:bg-linen/60 text-inherit border-t border-sand/60 min-w-0`,style:{paddingLeft:e.depth*12},children:[(0,B.jsx)(`span`,{className:`self-stretch flex items-start justify-center pt-1.5 font-mono text-[11px] border-r border-sand ${e.done?`text-leaf`:`text-tan`}`,children:e.done?`- [x]`:`- [ ]`}),(0,B.jsx)(`span`,{className:`px-3 py-1.5 min-w-0 break-words ${i?`text-[12px] leading-snug`:`text-[13px]`} ${e.done?`text-tan line-through decoration-dust`:``}`,children:(0,B.jsx)(Ru,{text:e.text})})]},e.line))]},e.line)})}):(0,B.jsx)(`div`,{className:`px-3 py-2 font-mono text-[12px] text-tan`,children:`…`})}function Vu({project:e,phase:t,onClose:n}){let{data:r}=q(`/projects/${e}/phases/${t.id}/tasks`,15e3),i=r?.total?Math.round(r.done/r.total*100):0;return(0,B.jsxs)(`div`,{className:`mt-3 border border-sand rounded-kit bg-paper`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-sand`,children:[(0,B.jsx)(`b`,{className:`text-[13px]`,children:t.title}),(0,B.jsx)(G,{tone:r?.total&&r.done===r.total?`ok`:`neutral`,children:r?`${r.done}/${r.total} · ${i}%`:`…`}),(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-ink3`,children:r?.file??`no tasks file`}),(0,B.jsxs)(`span`,{className:`ml-auto flex gap-1.5`,children:[r?.file&&(0,B.jsx)(V,{to:`/docs/${encodeURIComponent(r.file)}`,className:`hover:no-underline`,children:(0,B.jsx)(K,{size:`sm`,tone:`ghost`,children:`Open doc`})}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:n,children:`✕`})]})]}),(0,B.jsx)(Bu,{project:e,phase:t})]})}var Hu=`/api`,Uu=/\[image: (\S+) · (\S+)\]/g;function Wu(){let[e,t]=(0,P.useState)([]),[n,r]=(0,P.useState)(0),[i,a]=(0,P.useState)(null),o=(0,P.useCallback)(async e=>{let n=e.filter(e=>e.type.startsWith(`image/`));if(n.length){r(e=>e+n.length),a(null);for(let e of n)try{let n=new FormData;n.append(`file`,e,e.name||`paste.png`);let r=await fetch(`${Hu}/uploads`,{method:`POST`,body:n}),i=await r.json();if(!r.ok)throw Error(i.error??`${r.status}`);t(e=>e.some(e=>e.name===i.name)?e:[...e,i])}catch(e){a(e.message)}finally{r(e=>e-1)}}},[]),s=(0,P.useCallback)(e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),o(t))},[o]),c=(0,P.useCallback)(e=>{let t=Array.from(e.dataTransfer?.files??[]);t.length&&(e.preventDefault(),o(t))},[o]),l=(0,P.useCallback)(e=>{e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()},[]);return{items:e,busy:n>0,err:i,onPaste:s,onDrop:c,onDragOver:l,remove:e=>t(t=>t.filter(t=>t.name!==e)),clear:()=>t([]),withRefs:t=>e.length?`${t.trim()}${t.trim()?`
24
+ `).length-1:0,a=n?`<div class="frontmatter" data-line="1" data-line-end="${i+1}"><table>${n.map(([e,t])=>`<tr><th>${lu.utils.escapeHtml(e)}</th><td>${lu.utils.escapeHtml(t)}</td></tr>`).join(``)}</table></div>`:``;uu=i;let o=a+lu.render(r).replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(e,t,n)=>`<a class="wikilink" href="#/docs/${encodeURIComponent(t)}">${n??t}</a>`).replace(/<li([^>]*)>\[( |x|X)\] /g,(e,t,n)=>`<li${t} class="task"><input type="checkbox" disabled${n.trim()?` checked`:``}> `);return fu.size>200&&fu.clear(),fu.set(e,o),o}var hu={theme:`base`,themeVariables:{primaryColor:`#FFFFFF`,primaryBorderColor:`#2B1D14`,primaryTextColor:`#2B1D14`,lineColor:`#9A7A60`,secondaryColor:`#FBE3D0`,tertiaryColor:`#EFE5D8`,fontFamily:`"Source Sans 3", system-ui, sans-serif`,fontSize:`13px`}};function gu(e){let t=[],n=e.newStart,r=!1;for(let i of e.lines)if(i.startsWith(`+`)){let e=t[t.length-1];e&&e[1]===n?e[1]=n+1:t.push([n,n+1]),n++,r=!1}else i.startsWith(`-`)?r||=(t.push([n,n+1]),!0):(n++,r=!1);return t}function _u(e,t){e.querySelectorAll(`[data-chg]`).forEach(e=>{e.removeAttribute(`data-chg`),e.removeAttribute(`data-hunk`),e.classList.remove(`chg-uncommitted`,`chg-commit`)});let n=[...e.querySelectorAll(`[data-line]`)];t.forEach((e,t)=>e.hunks.forEach((r,i)=>{let a=gu(r),o=n.filter(e=>{let t=+e.dataset.line,n=+e.dataset.lineEnd;return a.some(([e,r])=>t<r&&n>e)});for(let n of o)o.some(e=>e!==n&&n.contains(e))||n.dataset.chg!==`uncommitted`&&(n.dataset.chg=e.kind,n.dataset.hunk=`${t}:${i}`,n.classList.add(e.kind===`uncommitted`?`chg-uncommitted`:`chg-commit`))}))}function vu(e,t){if(t.length===0)return e;let n=document.createElement(`div`);return n.innerHTML=e,_u(n,t),n.innerHTML}var yu=(0,P.memo)(function({html:e,className:t,onOver:n,onLeave:r}){let i=(0,P.useRef)(null);return(0,P.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.querySelectorAll(`.mermaid:not([data-processed])`);if(t.length===0)return;let n=!1;return oi(async()=>{let{default:e}=await import(`./mermaid.core-D_f4AlrR.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])).then(async({default:e})=>{n||(e.initialize({startOnLoad:!1,...hu}),await e.run({nodes:t}))}),()=>{n=!0}},[e]),(0,B.jsx)(`div`,{ref:i,className:`md ${t}`,dangerouslySetInnerHTML:{__html:e},onMouseOver:n,onMouseLeave:r})});function bu({source:e,changes:t=[],className:n=``}){let r=mu(e),[i,a]=(0,P.useState)(null),o=(0,P.useMemo)(()=>vu(r,t),[r,t]),s=(0,P.useRef)(t);s.current=t;let c=(0,P.useCallback)(e=>{let t=e.target.closest(`[data-hunk]`);if(!t){a(e=>e&&null);return}let[n,r]=t.dataset.hunk.split(`:`).map(Number),i=s.current[n],o=i?.hunks[r];if(!i||!o){a(null);return}let c=t.getBoundingClientRect();a({x:Math.min(c.left,window.innerWidth-560),y:c.bottom+6,change:i,hunk:o})},[]),l=(0,P.useCallback)(()=>a(null),[]);return(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(yu,{html:o,className:n,onOver:c,onLeave:l}),i&&(0,B.jsxs)(`div`,{className:`fixed z-50 max-w-[540px] max-h-[50vh] overflow-auto bg-paper border border-sand rounded-kit shadow-panel text-[12px]`,style:{left:i.x,top:i.y},children:[(0,B.jsxs)(`div`,{className:`px-3 py-1.5 border-b border-sand font-mono flex gap-2 items-baseline ${i.change.kind===`uncommitted`?`text-amber`:`text-leaf`}`,children:[(0,B.jsx)(`b`,{children:i.change.kind===`uncommitted`?`uncommitted`:`last commit`}),(0,B.jsx)(`span`,{className:`text-ink3 truncate`,children:i.change.label}),(0,B.jsxs)(`span`,{className:`ml-auto text-tan`,children:[`@@ +`,i.hunk.newStart,`,`,i.hunk.newLines]})]}),(0,B.jsx)(`pre`,{className:`m-0 px-3 py-2 font-mono leading-[1.5] whitespace-pre-wrap`,children:i.hunk.lines.map((e,t)=>(0,B.jsx)(`div`,{className:e.startsWith(`+`)?`bg-moss-wash text-moss`:e.startsWith(`-`)?`bg-brick-wash text-brick line-through decoration-brick/40`:`text-umber`,children:e},t))})]})]})}function xu(e,t){let n=e.trim().replace(/^['"`<(]+|[>'"`)]+$/g,``),r,i=n.match(/:(\d+)$/);i&&(r=Number(i[1]),n=n.slice(0,-i[0].length)),n.startsWith(`[[`)&&n.endsWith(`]]`)&&(n=n.slice(2,-2).split(`|`)[0].trim()),n=n.replace(/\\/g,`/`);let a=n.toLowerCase().lastIndexOf(`/docs/`);a>=0&&(n=n.slice(a+1)),n.startsWith(`./`)&&(n=n.slice(2));let o=n.toLowerCase().startsWith(`docs/`)?n.slice(5):n,s=o.replace(/\.md$/i,``);if(!t.length)return/^[\w./-]+\.md$/i.test(o)?{file:o,line:r}:s&&!s.includes(` `)?{file:`${s}.md`,line:r}:null;let c=t.filter(e=>{let t=e.replace(/\.md$/i,``),n=e.split(`/`).pop()?.replace(/\.md$/i,``);return e===o||e===`${o}.md`||t===s||t.endsWith(`/${s}`)||e.endsWith(`/${o}`)||n===s});return c.length===1?{file:c[0],line:r}:c.includes(o)?{file:o,line:r}:c.includes(`${o}.md`)?{file:`${o}.md`,line:r}:null}var Su=/\[\[([^\]|]+)(?:\|[^\]]+)?\]\](?::\d+)?|(?:(?:~\/|\.{1,2}\/)?(?:[\w.-]+\/)+)?[\w.-]+\.md(?::\d+)?/g;function Cu(e,t,n){return e==null||typeof e==`boolean`||typeof e==`number`?e:typeof e==`string`?wu(e,t,n):Array.isArray(e)?e.map((e,r)=>{let i=Cu(e,t,n);return(0,P.isValidElement)(i)&&i.key==null?(0,P.cloneElement)(i,{key:r}):i}):(0,P.isValidElement)(e)&&e.props.children!=null?(0,P.cloneElement)(e,void 0,Cu(e.props.children,t,n)):e}function wu(e,t,n){if(Su.lastIndex=0,!Su.test(e))return e;Su.lastIndex=0;let r=[],i=0,a,o=0;for(;a=Su.exec(e);){a.index>i&&r.push(e.slice(i,a.index));let s=a[0],c=xu(s,t);c?r.push((0,B.jsx)(`button`,{type:`button`,className:`md-ref`,title:`Open ${c.file}${c.line?`:${c.line}`:``}`,onClick:e=>{e.preventDefault(),e.stopPropagation(),n(c)},children:s},`md-${o++}`)):r.push(s),i=a.index+s.length}return i<e.length&&r.push(e.slice(i)),r.length===1?r[0]:r}var Tu=(0,P.createContext)({files:[],open:()=>{},linkify:e=>e}),Eu=()=>(0,P.useContext)(Tu);function Du({children:e}){let{current:t}=za(),n=ar(),[r,i]=(0,P.useState)(null),a=q(t?`/projects/${t}/docs`:null,3e4).data?.files??[],o=q(r?`/projects/${r.project}/docs/${encodeURIComponent(r.ref.file)}`:null),s=(e,n)=>{let r=n||t;r&&i({ref:e,project:r})};return(0,P.useEffect)(()=>{if(!r)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),e.preventDefault(),i(null))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r]),(0,P.useEffect)(()=>{if(!r||!o.data||!r.ref.line)return;let e=setTimeout(()=>document.getElementById(`L${r.ref.line}`)?.scrollIntoView({block:`center`}),80);return()=>clearTimeout(e)},[r,o.data]),(0,B.jsxs)(Tu.Provider,{value:{files:a,open:s,linkify:(e,n)=>Cu(e,a,e=>s(e,n||t))},children:[e,r&&(0,B.jsx)(`div`,{className:`fixed inset-0 z-[70] bg-walnut/40 flex items-start justify-center pt-[8vh] px-4`,onMouseDown:e=>{e.target===e.currentTarget&&i(null)},children:(0,B.jsxs)(`div`,{className:`w-[min(820px,94vw)] max-h-[84vh] bg-paper border border-sand rounded-kit shadow-panel grid grid-rows-[auto_1fr] overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-sand flex items-center gap-2 min-w-0`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3 truncate`,title:o.data?.path??r.ref.file,children:[o.data?.path??`docs/${r.ref.file}`,r.ref.line?`:${r.ref.line}`:``]}),(0,B.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[(0,B.jsx)(K,{size:`sm`,onClick:()=>{n(`/docs/${encodeURIComponent(r.ref.file)}${r.ref.line?`?view=source&line=${r.ref.line}`:``}`),i(null)},children:`Open in Docs`}),(0,B.jsx)(K,{size:`sm`,onClick:()=>i(null),children:`Close (Esc)`})]})]}),(0,B.jsxs)(`div`,{className:`overflow-auto px-6 py-4`,children:[o.loading&&(0,B.jsx)(`div`,{className:`text-[13px] text-umber`,children:`loading…`}),o.error&&(0,B.jsxs)(`div`,{className:`text-[13px] text-brick`,children:[`Could not load — not in `,r.project,`’s docs/? `,o.error]}),o.data&&(0,B.jsx)(bu,{source:o.data.source})]})]})})]})}var Ou=[`circle`,`square`,`diamond`,`hexagon`,`triangle`,`shield`,`leaf`,`pentagon`];function ku(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}var Au=e=>Ou[ku(e)%Ou.length];function ju(e,t){let n=t/2,r=t/2-1,i=(e,t=-Math.PI/2)=>Array.from({length:e},(i,a)=>{let o=t+a*2*Math.PI/e;return`${(n+r*Math.cos(o)).toFixed(2)},${(n+r*Math.sin(o)).toFixed(2)}`}).join(` `);switch(e){case`circle`:return(0,B.jsx)(`circle`,{cx:n,cy:n,r});case`square`:return(0,B.jsx)(`rect`,{x:1.5,y:1.5,width:t-3,height:t-3,rx:2});case`diamond`:return(0,B.jsx)(`polygon`,{points:i(4)});case`hexagon`:return(0,B.jsx)(`polygon`,{points:i(6,0)});case`triangle`:return(0,B.jsx)(`polygon`,{points:i(3)});case`pentagon`:return(0,B.jsx)(`polygon`,{points:i(5)});case`shield`:return(0,B.jsx)(`path`,{d:`M${n} 1.5 L${t-1.5} ${t*.3} V${t*.55} Q${t-1.5} ${t-2} ${n} ${t-1.5} Q1.5 ${t-2} 1.5 ${t*.55} V${t*.3} Z`});case`leaf`:return(0,B.jsx)(`path`,{d:`M${n} 1.5 Q${t-1.5} ${t*.35} ${t-2.5} ${t-2} Q${t*.35} ${t-1.5} 1.5 ${n} Q${t*.35} 1.5 ${n} 1.5 Z`})}}function Mu({id:e,role:t,size:n=18,state:r,active:i,className:a=``}){let o=nd(t),s=Au(e),c=r===`dead`?.35:r===`idle`?.7:1,l=e.replace(/[^a-z0-9]/gi,``).slice(0,1).toUpperCase();return(0,B.jsxs)(`span`,{className:`relative inline-flex shrink-0 ${a}`,style:{width:n,height:n},title:`${e}${t?` · ${t}`:``}`,children:[(0,B.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 ${n} ${n}`,style:{opacity:c},"aria-hidden":!0,children:[(0,B.jsx)(`g`,{fill:o,stroke:o,strokeWidth:`1`,children:ju(s,n)}),(0,B.jsx)(`text`,{x:n/2,y:n/2+n*.22,textAnchor:`middle`,fontSize:n*.55,fontFamily:`JetBrains Mono, monospace`,fontWeight:`700`,fill:`#FCFAF6`,children:l})]}),i&&(0,B.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 w-2 h-2 rounded-full bg-moss ring-2 ring-paper`,children:(0,B.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-moss animate-ping opacity-60`})})]})}var Nu=e=>/done|merged|deployed|complete|closed|✅/i.test(e);function Pu(e){return e?e.workstreams.rows.filter(e=>!(`malformed`in e)).map(e=>e.schema===`workstreams.v1`?{name:e.stream,owner:e.owner,status:e.status,note:e.lastNote??``}:{name:e.lane,owner:e.owner,status:e.state,note:e.currentSlice??``}).map(e=>({...e,done:Nu(e.status)})):[]}var Fu=e=>e.match(/^Task\s+(\d+)\b/i)?.[1]??null;function Iu(e,t,n){if(!n)return null;let r=t.replace(/\./g,`\\.`),i=RegExp(`(^|\\b)(P${r}[-.\\s]?T${n}\\b|Phase\\s*${r}\\b.*\\bT(?:ask)?\\s*${n}\\b)`,`i`);return e.find(e=>i.test(e.name))??null}function Lu(e,t){let n=e.trim().toLowerCase();return t.find(e=>e.toLowerCase()===n)??t.find(e=>n.includes(e.toLowerCase()))??null}function Ru({text:e}){let t=[],n=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[\[([^\]|]+)(?:\|([^\]]+))?\]\])/g,r=0,i,a=0;for(;i=n.exec(e);)i.index>r&&t.push(e.slice(r,i.index)),i[1]?t.push((0,B.jsx)(`code`,{className:`font-mono text-[.92em] px-1 rounded bg-linen text-walnut`,children:i[1].slice(1,-1)},a++)):i[2]?t.push((0,B.jsx)(`b`,{children:i[2].slice(2,-2)},a++)):t.push((0,B.jsx)(V,{to:`/docs/${encodeURIComponent(i[4])}`,onClick:e=>e.stopPropagation(),className:`text-ember-deep`,children:i[5]??i[4]},a++)),r=i.index+i[0].length;return r<e.length&&t.push(e.slice(r)),(0,B.jsx)(B.Fragment,{children:t})}function zu({stream:e,agents:t,size:n=`sm`}){if(!e)return null;let r=Lu(e.owner,t.map(e=>e.agentId));return(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 shrink-0`,title:`${e.name} · ${e.owner} · ${e.status}${e.note?` · ${e.note}`:``}`,children:[r?(0,B.jsx)(ed,{id:r,bare:!0,size:n}):(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[11px] text-umber`,children:[(0,B.jsx)(Mu,{id:e.owner,size:14,state:`dead`}),e.owner]}),(0,B.jsx)(G,{tone:e.done?`ok`:/block/i.test(e.status)?`bad`:/queued|hold|wait/i.test(e.status)?`warn`:`neutral`,children:e.status.replace(/^[^\w]+/,``).slice(0,16)})]})}function Bu({project:e,phase:t,highlight:n,maxH:r=`46vh`,compact:i=!1}){let{data:a,error:o}=q(`/projects/${e}/phases/${t.id}/tasks`,15e3),s=q(`/projects/${e}/board`,15e3).data,c=q(`/bus/agents`,2e4).data??[],l=Pu(s),[u,d]=(0,P.useState)({});return o?(0,B.jsx)(`div`,{className:`px-3 py-2 text-[13px] text-brick`,children:o}):a?a.sections.length===0?(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:[`No tasks yet — run `,(0,B.jsx)(`code`,{children:`/plan-phase`}),` (roadmap → Plan).`]}):(0,B.jsx)(`div`,{className:`grid gap-0 overflow-auto overscroll-contain min-w-0`,style:{maxHeight:r},children:a.sections.map(e=>{let r=e.tasks.filter(e=>e.done).length,o=r===e.tasks.length,s=Iu(l,t.n,Fu(e.title)),f=!!n&&!!s&&Lu(s.owner,c.map(e=>e.agentId))===n,p=i&&o&&!u[e.line];return(0,B.jsxs)(`div`,{className:`border-b border-sand last:border-b-0 min-w-0 ${f?`bg-ember/[.04]`:``}`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-[1] px-3 py-1.5 min-w-0 ${f?`bg-ember-wash`:`bg-cream`} ${i?`grid gap-0.5`:`flex items-center gap-2`}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[i&&o&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>d(t=>({...t,[e.line]:!t[e.line]})),className:`border-0 bg-transparent p-0 cursor-pointer font-mono text-[11px] text-tan w-3 shrink-0`,title:p?`show done sub-steps`:`collapse`,children:p?`▸`:`▾`}),f&&(0,B.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-ember shrink-0`,title:`this agent's task`}),(0,B.jsx)(V,{to:`/docs/${encodeURIComponent(a.file)}?view=source&line=${e.line}`,className:`font-semibold text-[12px] hover:no-underline hover:text-ember-deep truncate ${o?`text-tan`:`text-umber`}`,children:e.title}),(0,B.jsxs)(`span`,{className:`font-mono text-[11px] shrink-0 ${o?`text-leaf`:`text-tan`}`,children:[r,`/`,e.tasks.length,o?` ✓`:``]}),!i&&(0,B.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[(0,B.jsx)(zu,{stream:s,agents:c}),(0,B.jsx)(`span`,{className:`h-1 w-24 rounded-full bg-linen overflow-hidden`,children:(0,B.jsx)(`span`,{className:`block h-full ${o?`bg-leaf`:`bg-ember`}`,style:{width:`${e.tasks.length?r/e.tasks.length*100:0}%`}})})]})]}),i&&s&&(0,B.jsx)(`div`,{className:`flex items-center gap-2 min-w-0 pl-5`,children:(0,B.jsx)(zu,{stream:s,agents:c})})]}),!p&&e.tasks.map(e=>(0,B.jsxs)(V,{to:`/docs/${encodeURIComponent(a.file)}?view=source&line=${e.line}`,className:`grid grid-cols-[var(--spacing-gutter)_minmax(0,1fr)] items-start hover:no-underline hover:bg-linen/60 text-inherit border-t border-sand/60 min-w-0`,style:{paddingLeft:e.depth*12},children:[(0,B.jsx)(`span`,{className:`self-stretch flex items-start justify-center pt-1.5 font-mono text-[11px] border-r border-sand ${e.done?`text-leaf`:`text-tan`}`,children:e.done?`- [x]`:`- [ ]`}),(0,B.jsx)(`span`,{className:`px-3 py-1.5 min-w-0 break-words ${i?`text-[12px] leading-snug`:`text-[13px]`} ${e.done?`text-tan line-through decoration-dust`:``}`,children:(0,B.jsx)(Ru,{text:e.text})})]},e.line))]},e.line)})}):(0,B.jsx)(`div`,{className:`px-3 py-2 font-mono text-[12px] text-tan`,children:`…`})}function Vu({project:e,phase:t,onClose:n}){let{data:r}=q(`/projects/${e}/phases/${t.id}/tasks`,15e3),i=r?.total?Math.round(r.done/r.total*100):0;return(0,B.jsxs)(`div`,{className:`mt-3 border border-sand rounded-kit bg-paper`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-sand`,children:[(0,B.jsx)(`b`,{className:`text-[13px]`,children:t.title}),(0,B.jsx)(G,{tone:r?.total&&r.done===r.total?`ok`:`neutral`,children:r?`${r.done}/${r.total} · ${i}%`:`…`}),(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-ink3`,children:r?.file??`no tasks file`}),(0,B.jsxs)(`span`,{className:`ml-auto flex gap-1.5`,children:[r?.file&&(0,B.jsx)(V,{to:`/docs/${encodeURIComponent(r.file)}`,className:`hover:no-underline`,children:(0,B.jsx)(K,{size:`sm`,tone:`ghost`,children:`Open doc`})}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:n,children:`✕`})]})]}),(0,B.jsx)(Bu,{project:e,phase:t})]})}var Hu=`/api`,Uu=/\[image: (\S+) · (\S+)\]/g,Wu=e=>`${Hu}/uploads/${encodeURIComponent(e.split(`/`).pop()??``)}`;function Gu(){let[e,t]=(0,P.useState)([]),[n,r]=(0,P.useState)(0),[i,a]=(0,P.useState)(null),o=(0,P.useCallback)(async e=>{let n=e.filter(e=>e.type.startsWith(`image/`));if(n.length){r(e=>e+n.length),a(null);for(let e of n)try{let n=new FormData;n.append(`file`,e,e.name||`paste.png`);let r=await fetch(`${Hu}/uploads`,{method:`POST`,body:n}),i=await r.json();if(!r.ok)throw Error(i.error??`${r.status}`);t(e=>e.some(e=>e.name===i.name)?e:[...e,i])}catch(e){a(e.message)}finally{r(e=>e-1)}}},[]),s=(0,P.useCallback)(e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),o(t))},[o]),c=(0,P.useCallback)(e=>{let t=Array.from(e.dataTransfer?.files??[]);t.length&&(e.preventDefault(),o(t))},[o]),l=(0,P.useCallback)(e=>{e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()},[]);return{items:e,busy:n>0,err:i,onPaste:s,onDrop:c,onDragOver:l,remove:e=>t(t=>t.filter(t=>t.name!==e)),clear:()=>t([]),withRefs:t=>e.length?`${t.trim()}${t.trim()?`
25
25
  `:``}${e.map(e=>e.ref).join(`
26
- `)}`:t,hasContent:t=>!!t.trim()||e.length>0}}function Gu({a:e}){return!e.items.length&&!e.busy&&!e.err?null:(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[e.items.map(t=>(0,B.jsxs)(`span`,{className:`relative inline-flex items-center gap-1 border border-sand rounded-kit bg-cream/60 p-0.5`,title:`${t.path}\n${t.url}`,children:[(0,B.jsx)(`img`,{src:t.url,alt:t.name,className:`h-10 w-auto max-w-[120px] rounded object-cover`}),(0,B.jsxs)(`span`,{className:`font-mono text-[10px] text-ink3 pr-1`,children:[Math.round(t.bytes/1024),` KB`]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>e.remove(t.name),className:`absolute -top-1.5 -right-1.5 w-4 h-4 rounded-full bg-walnut text-paper text-[10px] leading-none border-0 cursor-pointer`,title:`remove`,children:`×`})]},t.name)),e.busy&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-ink3`,children:`uploading…`}),e.err&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-brick`,children:e.err})]})}function Ku({text:e}){let t=[],n=0,r,i=0;for(Uu.lastIndex=0;r=Uu.exec(e);){r.index>n&&t.push(e.slice(n,r.index));let[,a,o]=r;t.push((0,B.jsx)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:`inline-block align-top my-1 mr-1 border border-sand rounded-kit p-0.5 bg-cream/60 hover:no-underline`,title:a,children:(0,B.jsx)(`img`,{src:o,alt:a.split(`/`).pop(),className:`max-h-40 max-w-[280px] rounded object-contain`,loading:`lazy`})},i++)),n=r.index+r[0].length}return n<e.length&&t.push(e.slice(n)),(0,B.jsx)(B.Fragment,{children:t})}var qu=`/api`;function Ju({agentId:e,onClose:t}){let{linkify:n}=Eu(),[r,i]=(0,P.useState)(null),[a,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(200),[l,u]=(0,P.useState)(!0),[d,f]=(0,P.useState)(!0),[p,m]=(0,P.useState)(()=>localStorage.getItem(`groundwork-console.pane.tasks`)!==`0`),h=e=>{m(e),localStorage.setItem(`groundwork-console.pane.tasks`,e?`1`:`0`)},{current:g,projects:_}=za(),v=q(`/admin/bus-writes`,1e4).data?.enabled??!1,y=(q(`/bus/agents`,3e4).data??[]).find(t=>t.agentId===e),b=y?.project&&_.some(e=>e.name===y.project||e.room===y.project)?_.find(e=>e.name===y.project||e.room===y.project).name:g,[x,S]=(0,P.useState)(``),[C,w]=(0,P.useState)(null),T=Wu(),E=async()=>{if(T.hasContent(x)){w(`sending`);try{let t=await Fa(`/actions/send`,{as:`david`,to:e,text:T.withRefs(x)});w(t.status===`ok`?`sent — lands in the pane via tmux-push`:t.error??t.log?.slice(-1)[0]??`failed`),t.status===`ok`&&(S(``),T.clear())}catch(e){w(e.message)}}},D=(0,P.useRef)(null);return(0,P.useEffect)(()=>{let t=!0,n=async()=>{try{let n=await fetch(`${qu}/bus/agents/${encodeURIComponent(e)}/pane?lines=${s}${d?`&colors=1`:``}`),r=await n.json();if(!t)return;if(!n.ok){o(r.error??`${n.status}`);return}o(null),i(r)}catch(e){t&&o(e.message)}};n();let r=setInterval(n,3e3);return()=>{t=!1,clearInterval(r)}},[e,s,d]),(0,P.useEffect)(()=>{l&&D.current&&(D.current.scrollTop=D.current.scrollHeight)},[r,l]),(0,P.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex justify-end`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,B.jsxs)(`div`,{className:`${p?`w-[min(1340px,calc(100vw-16px))]`:`w-[min(920px,92vw)]`} h-full max-h-screen bg-paper border-l border-sand shadow-panel grid grid-rows-[auto_minmax(0,1fr)] whitespace-normal text-left transition-[width] duration-200`,style:{borderTop:`4px solid ${td(y?.role)}`},children:[(0,B.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-sand flex items-center gap-2`,children:[(0,B.jsx)(Mu,{id:e,role:y?.role,size:22,state:y?.liveness,active:y?.active}),(0,B.jsx)(`span`,{className:`font-display font-bold text-[16px] text-umber`,children:e}),y?.role&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.06em]`,style:{color:td(y.role)},children:y.role}),r&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,children:[r.pane,` · `,r.command]}),r.active?(0,B.jsx)(G,{tone:`ok`,children:`active`}):(0,B.jsx)(G,{tone:`outline`,children:`quiet`}),(0,B.jsxs)(`span`,{className:`font-mono text-[11px] text-tan`,children:[r.lines,` lines · `,new Date(r.capturedAt).toLocaleTimeString()]})]}),(0,B.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden`,children:[[`colors`,d,()=>f(e=>!e)],[`tasks`,p,()=>h(!p)],[`follow`,l,()=>u(e=>!e)]].map(([e,t,n])=>(0,B.jsx)(`button`,{type:`button`,onClick:n,"aria-pressed":t,className:`px-2 py-[3px] text-[11px] font-mono border-0 cursor-pointer ${t?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:e},e))}),(0,B.jsx)(`select`,{value:s,onChange:e=>c(Number(e.target.value)),className:`font-mono text-[11px] px-1.5 py-1 border border-dust rounded bg-paper text-umber`,children:[100,200,500,1e3,2e3].map(e=>(0,B.jsxs)(`option`,{value:e,children:[e,` lines`]},e))}),(0,B.jsx)(K,{size:`sm`,onClick:t,children:`Close (Esc)`})]})]}),(0,B.jsxs)(`div`,{className:`min-h-0 grid ${p?`grid-cols-[minmax(0,1fr)_minmax(300px,380px)]`:`grid-cols-1`}`,children:[(0,B.jsxs)(`div`,{className:`min-h-0 grid grid-rows-[minmax(0,1fr)_auto]`,children:[(0,B.jsx)(`pre`,{ref:D,className:`m-0 px-4 py-3 min-h-0 overflow-auto font-mono text-[12px] leading-[1.45] whitespace-pre-wrap break-words pane-dark`,children:a?(0,B.jsx)(`span`,{className:`text-brick`,children:a}):r?n(d&&r.ansi?uo(r.ansi):r.text):`capturing…`}),(0,B.jsxs)(`div`,{className:`px-4 py-2 border-t border-sand grid gap-1.5`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2 items-center`,children:[(0,B.jsx)(`input`,{value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v&&E()},onPaste:T.onPaste,onDrop:T.onDrop,onDragOver:T.onDragOver,disabled:!v,placeholder:v?`DM ${e} as david — paste or drop an image, delivered by its tmux-push into this pane`:`DM needs bus writes on (header badge)`,className:`text-[13px] px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:E,disabled:!v||!T.hasContent(x)||T.busy||C===`sending`,children:`Send DM`})]}),(0,B.jsx)(Gu,{a:T}),(0,B.jsxs)(`div`,{className:`font-mono text-[11px] text-tan`,children:[`read-only `,(0,B.jsx)(`code`,{children:`tmux capture-pane`}),` · 3 s refresh · the console never types into panes — the DM goes through the bus (a Run) and the agent's own pusher types it`,C&&C!==`sending`?(0,B.jsxs)(`span`,{className:/^sent/.test(C)?` text-leaf`:` text-brick`,children:[` · `,C]}):null]})]})]}),p&&(0,B.jsx)(Yu,{project:b,agentId:e})]})]})})}function Yu({project:e,agentId:t}){let n=q(e?`/projects/${e}/board`:null,15e3).data,r=q(`/bus/agents`,2e4).data??[],i=n?.phases.find(e=>e.state===`ongoing`)??n?.phases.find(e=>e.state===`planned`),a=Pu(n).filter(e=>!e.done&&Lu(e.owner,r.map(e=>e.agentId))===t);return(0,B.jsxs)(`aside`,{className:`min-h-0 min-w-0 overflow-hidden border-l border-sand bg-cream/40 grid grid-rows-[auto_auto_minmax(0,1fr)]`,children:[(0,B.jsxs)(`div`,{className:`px-3 py-2 border-b border-sand flex items-center gap-2 flex-wrap`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan`,children:`now`}),i?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(V,{to:`/board`,className:`font-semibold text-[13px] text-walnut hover:text-ember-deep hover:no-underline`,children:i.title}),(0,B.jsx)(G,{tone:i.state===`ongoing`?`david`:`neutral`,children:i.state}),(0,B.jsxs)(`span`,{className:`font-mono text-[11px] text-ink3`,children:[i.done,`/`,i.total]})]}):(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:e?`no phase in flight`:`no project selected`})]}),(0,B.jsxs)(`div`,{className:`px-3 py-2 border-b border-sand grid gap-1`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan`,children:[t,` is on`]}),a.length===0&&(0,B.jsx)(`span`,{className:`text-[12px] text-umber`,children:`no active stream owned by this agent`}),a.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px]`,children:[(0,B.jsx)(`span`,{className:`font-mono text-umber truncate`,title:e.note,children:e.name}),(0,B.jsx)(`span`,{className:`ml-auto`,children:(0,B.jsx)(zu,{stream:e,agents:r})})]},e.name))]}),i&&e?(0,B.jsx)(Bu,{project:e,phase:i,highlight:t,maxH:`100%`,compact:!0}):(0,B.jsx)(`div`,{className:`px-3 py-3 text-[12px] text-umber`,children:`Pick a project (header) to see its phase tasks.`})]})}var Xu=`/api`,Zu=e=>{if(!e)return`—`;let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`};function Qu({agentId:e,lines:t=4,className:n=``,label:r}){let[i,a]=(0,P.useState)(null),[o,s]=(0,P.useState)(null),[c,l]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let n=!0,r=async()=>{try{let r=await fetch(`${Xu}/bus/agents/${encodeURIComponent(e)}/pane?lines=${t+6}&colors=1`),i=await r.json();if(!n)return;if(!r.ok){s(i.error??String(r.status));return}s(null),a(i)}catch(e){n&&s(e.message)}};r();let i=setInterval(r,3e3);return()=>{n=!1,clearInterval(i)}},[e,t]);let u=e=>e.split(`
26
+ `)}`:t,hasContent:t=>!!t.trim()||e.length>0}}function Ku({a:e}){return!e.items.length&&!e.busy&&!e.err?null:(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[e.items.map(t=>(0,B.jsxs)(`span`,{className:`relative inline-flex items-center gap-1 border border-sand rounded-kit bg-cream/60 p-0.5`,title:`${t.path}\n${t.url}`,children:[(0,B.jsx)(`img`,{src:Wu(t.name),alt:t.name,className:`h-10 w-auto max-w-[120px] rounded object-cover`}),(0,B.jsxs)(`span`,{className:`font-mono text-[10px] text-ink3 pr-1`,children:[Math.round(t.bytes/1024),` KB`]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>e.remove(t.name),className:`absolute -top-1.5 -right-1.5 w-4 h-4 rounded-full bg-walnut text-paper text-[10px] leading-none border-0 cursor-pointer`,title:`remove`,children:`×`})]},t.name)),e.busy&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-ink3`,children:`uploading…`}),e.err&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-brick`,children:e.err})]})}function qu({text:e}){let t=[],n=0,r,i=0;for(Uu.lastIndex=0;r=Uu.exec(e);){r.index>n&&t.push(e.slice(n,r.index));let[,a,o]=r;t.push((0,B.jsx)(`a`,{href:Wu(o),target:`_blank`,rel:`noreferrer`,className:`inline-block align-top my-1 mr-1 border border-sand rounded-kit p-0.5 bg-cream/60 hover:no-underline`,title:a,children:(0,B.jsx)(`img`,{src:Wu(o),alt:a.split(`/`).pop(),className:`max-h-40 max-w-[280px] rounded object-contain`,loading:`lazy`})},i++)),n=r.index+r[0].length}return n<e.length&&t.push(e.slice(n)),(0,B.jsx)(B.Fragment,{children:t})}var Ju=`/api`;function Yu({agentId:e,onClose:t}){let{linkify:n}=Eu(),[r,i]=(0,P.useState)(null),[a,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(200),[l,u]=(0,P.useState)(!0),[d,f]=(0,P.useState)(!0),[p,m]=(0,P.useState)(()=>localStorage.getItem(`groundwork-console.pane.tasks`)!==`0`),h=e=>{m(e),localStorage.setItem(`groundwork-console.pane.tasks`,e?`1`:`0`)},{current:g,projects:_}=za(),v=q(`/admin/bus-writes`,1e4).data?.enabled??!1,y=(q(`/bus/agents`,3e4).data??[]).find(t=>t.agentId===e),b=y?.project&&_.some(e=>e.name===y.project||e.room===y.project)?_.find(e=>e.name===y.project||e.room===y.project).name:g,[x,S]=(0,P.useState)(``),[C,w]=(0,P.useState)(null),T=Gu(),E=async()=>{if(T.hasContent(x)){w(`sending`);try{let t=await Fa(`/actions/send`,{as:`david`,to:e,text:T.withRefs(x)});w(t.status===`ok`?`sent — lands in the pane via tmux-push`:t.error??t.log?.slice(-1)[0]??`failed`),t.status===`ok`&&(S(``),T.clear())}catch(e){w(e.message)}}},D=(0,P.useRef)(null);return(0,P.useEffect)(()=>{let t=!0,n=async()=>{try{let n=await fetch(`${Ju}/bus/agents/${encodeURIComponent(e)}/pane?lines=${s}${d?`&colors=1`:``}`),r=await n.json();if(!t)return;if(!n.ok){o(r.error??`${n.status}`);return}o(null),i(r)}catch(e){t&&o(e.message)}};n();let r=setInterval(n,3e3);return()=>{t=!1,clearInterval(r)}},[e,s,d]),(0,P.useEffect)(()=>{l&&D.current&&(D.current.scrollTop=D.current.scrollHeight)},[r,l]),(0,P.useEffect)(()=>{let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[]),(0,P.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex justify-end`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,B.jsxs)(`div`,{className:`${p?`w-[min(1340px,calc(100vw-16px))]`:`w-[min(920px,92vw)]`} h-full max-h-screen bg-paper border-l border-sand shadow-panel grid grid-rows-[auto_minmax(0,1fr)] whitespace-normal text-left transition-[width] duration-200`,style:{borderTop:`4px solid ${nd(y?.role)}`},children:[(0,B.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-sand flex items-center gap-2`,children:[(0,B.jsx)(Mu,{id:e,role:y?.role,size:22,state:y?.liveness,active:y?.active}),(0,B.jsx)(`span`,{className:`font-display font-bold text-[16px] text-umber`,children:e}),y?.role&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.06em]`,style:{color:nd(y.role)},children:y.role}),r&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,children:[r.pane,` · `,r.command]}),r.active?(0,B.jsx)(G,{tone:`ok`,children:`active`}):(0,B.jsx)(G,{tone:`outline`,children:`quiet`}),(0,B.jsxs)(`span`,{className:`font-mono text-[11px] text-tan`,children:[r.lines,` lines · `,new Date(r.capturedAt).toLocaleTimeString()]})]}),(0,B.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden`,children:[[`colors`,d,()=>f(e=>!e)],[`tasks`,p,()=>h(!p)],[`follow`,l,()=>u(e=>!e)]].map(([e,t,n])=>(0,B.jsx)(`button`,{type:`button`,onClick:n,"aria-pressed":t,className:`px-2 py-[3px] text-[11px] font-mono border-0 cursor-pointer ${t?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:e},e))}),(0,B.jsx)(`select`,{value:s,onChange:e=>c(Number(e.target.value)),className:`font-mono text-[11px] px-1.5 py-1 border border-dust rounded bg-paper text-umber`,children:[100,200,500,1e3,2e3].map(e=>(0,B.jsxs)(`option`,{value:e,children:[e,` lines`]},e))}),(0,B.jsx)(K,{size:`sm`,onClick:t,children:`Close (Esc)`})]})]}),(0,B.jsxs)(`div`,{className:`min-h-0 grid ${p?`grid-cols-[minmax(0,1fr)_minmax(300px,380px)]`:`grid-cols-1`}`,children:[(0,B.jsxs)(`div`,{className:`min-h-0 grid grid-rows-[minmax(0,1fr)_auto]`,children:[(0,B.jsx)(`pre`,{ref:D,onScroll:()=>{let e=D.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<24;t!==l&&u(t)},className:`m-0 px-4 py-3 min-h-0 overflow-auto overscroll-contain font-mono text-[12px] leading-[1.45] whitespace-pre-wrap break-words pane-dark`,children:a?(0,B.jsx)(`span`,{className:`text-brick`,children:a}):r?n(d&&r.ansi?uo(r.ansi):r.text):`capturing…`}),(0,B.jsxs)(`div`,{className:`px-4 py-2 border-t border-sand grid gap-1.5`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2 items-center`,children:[(0,B.jsx)(`input`,{value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v&&E()},onPaste:T.onPaste,onDrop:T.onDrop,onDragOver:T.onDragOver,disabled:!v,placeholder:v?`DM ${e} as david — paste or drop an image, delivered by its tmux-push into this pane`:`DM needs bus writes on (header badge)`,className:`text-[13px] px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:E,disabled:!v||!T.hasContent(x)||T.busy||C===`sending`,children:`Send DM`})]}),(0,B.jsx)(Ku,{a:T}),(0,B.jsxs)(`div`,{className:`font-mono text-[11px] text-tan`,children:[`read-only `,(0,B.jsx)(`code`,{children:`tmux capture-pane`}),` · 3 s refresh · the console never types into panes — the DM goes through the bus (a Run) and the agent's own pusher types it`,C&&C!==`sending`?(0,B.jsxs)(`span`,{className:/^sent/.test(C)?` text-leaf`:` text-brick`,children:[` · `,C]}):null]})]})]}),p&&(0,B.jsx)(Xu,{project:b,agentId:e})]})]})})}function Xu({project:e,agentId:t}){let n=q(e?`/projects/${e}/board`:null,15e3).data,r=q(`/bus/agents`,2e4).data??[],i=n?.phases.find(e=>e.state===`ongoing`)??n?.phases.find(e=>e.state===`planned`),a=Pu(n).filter(e=>!e.done&&Lu(e.owner,r.map(e=>e.agentId))===t);return(0,B.jsxs)(`aside`,{className:`min-h-0 min-w-0 overflow-hidden overscroll-contain border-l border-sand bg-cream/40 grid grid-rows-[auto_auto_minmax(0,1fr)]`,children:[(0,B.jsxs)(`div`,{className:`px-3 py-2 border-b border-sand flex items-center gap-2 flex-wrap`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan`,children:`now`}),i?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(V,{to:`/board`,className:`font-semibold text-[13px] text-walnut hover:text-ember-deep hover:no-underline`,children:i.title}),(0,B.jsx)(G,{tone:i.state===`ongoing`?`david`:`neutral`,children:i.state}),(0,B.jsxs)(`span`,{className:`font-mono text-[11px] text-ink3`,children:[i.done,`/`,i.total]})]}):(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:e?`no phase in flight`:`no project selected`})]}),(0,B.jsxs)(`div`,{className:`px-3 py-2 border-b border-sand grid gap-1`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan`,children:[t,` is on`]}),a.length===0&&(0,B.jsx)(`span`,{className:`text-[12px] text-umber`,children:`no active stream owned by this agent`}),a.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px]`,children:[(0,B.jsx)(`span`,{className:`font-mono text-umber truncate`,title:e.note,children:e.name}),(0,B.jsx)(`span`,{className:`ml-auto`,children:(0,B.jsx)(zu,{stream:e,agents:r})})]},e.name))]}),i&&e?(0,B.jsx)(Bu,{project:e,phase:i,highlight:t,maxH:`100%`,compact:!0}):(0,B.jsx)(`div`,{className:`px-3 py-3 text-[12px] text-umber`,children:`Pick a project (header) to see its phase tasks.`})]})}var Zu=`/api`,Qu=e=>{if(!e)return`—`;let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`};function $u({agentId:e,lines:t=4,className:n=``,label:r}){let[i,a]=(0,P.useState)(null),[o,s]=(0,P.useState)(null),[c,l]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let n=!0,r=async()=>{try{let r=await fetch(`${Zu}/bus/agents/${encodeURIComponent(e)}/pane?lines=${t+6}&colors=1`),i=await r.json();if(!n)return;if(!r.ok){s(i.error??String(r.status));return}s(null),a(i)}catch(e){n&&s(e.message)}};r();let i=setInterval(r,3e3);return()=>{n=!1,clearInterval(i)}},[e,t]);let u=e=>e.split(`
27
27
  `).filter(e=>e.trim().length>0).slice(-t).join(`
28
- `);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{onClick:()=>l(!0),className:`w-full text-left rounded-[4px] overflow-hidden border border-sand bg-transparent p-0 cursor-pointer group ${n}`,title:`${e} · pane ${i?.pane??``} · click for the full view`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-[3px] bg-linen border-b border-sand`,children:[(0,B.jsx)(`span`,{className:`relative inline-block w-1.5 h-1.5 rounded-full ${i?.active?`bg-moss`:`bg-dust`}`,children:i?.active&&(0,B.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-moss animate-ping opacity-60`})}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-ink3 truncate`,children:r??e}),(0,B.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-tan`,children:i?i.active?`active`:`quiet ${Zu(i.paneActivity)}`:`…`})]}),(0,B.jsx)(`pre`,{className:`m-0 px-2 py-1 pane-dark font-mono text-[10.5px] leading-[1.35] whitespace-pre-wrap break-words max-h-[calc(1.35em*4+8px)] overflow-hidden group-hover:opacity-90`,style:{maxHeight:`calc(1.35em * ${t} + 8px)`},children:o?(0,B.jsx)(`span`,{className:`text-brick`,children:o}):i?i.ansi?uo(u(i.ansi)):u(i.text):`capturing…`})]}),c&&(0,B.jsx)(Ju,{agentId:e,onClose:()=>l(!1)})]})}function $u({id:e,prefix:t,size:n=`sm`,className:r=``,bare:i=!1,noDot:a=!1}){let o=(q(`/bus/agents`,2e4).data??[]).find(t=>t.agentId===e),[s,c]=(0,P.useState)(!1),[l,u]=(0,P.useState)(!1),d=(0,P.useRef)(null),f=()=>{d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>c(!0),250)},p=()=>{d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>c(!1),200)};(0,P.useEffect)(()=>()=>{d.current&&window.clearTimeout(d.current)},[]);let m=!!o?.pane;return(0,B.jsxs)(`span`,{className:`relative inline-flex ${r}`,onMouseEnter:f,onMouseLeave:p,children:[(0,B.jsxs)(`button`,{onClick:()=>m&&u(!0),className:i?`inline-flex items-center gap-1.5 font-mono font-semibold ${n===`sm`?`text-[12px]`:`text-[13px]`} border-0 bg-transparent p-0 text-walnut ${m?`cursor-pointer hover:text-ember-deep`:`cursor-default`}`:`inline-flex items-center gap-1.5 rounded-full border font-mono ${n===`sm`?`text-[11px] px-2 py-0.5`:`text-[12px] px-2.5 py-1`} ${m?`cursor-pointer border-dust bg-paper hover:border-ember`:`cursor-default border-sand bg-linen/60`} text-walnut`,title:m?`${e} · pane ${o.pane} · click to pop out`:`${e}${o?` · ${o.liveness}`:` · not on the bus`}`,children:[t&&(0,B.jsx)(`span`,{className:`text-tan`,children:t}),!a&&(0,B.jsx)(Mu,{id:e,role:o?.role,size:n===`sm`?14:18,state:o?.liveness??`dead`,active:o?.active}),(0,B.jsx)(`span`,{className:`truncate max-w-[220px]`,children:e}),o&&!o.transport&&o.liveness!==`dead`&&(0,B.jsx)(`span`,{className:`text-amber`,title:`not attached — DMs won't reach its pane`,children:`⚠`})]}),s&&m&&(0,B.jsx)(`span`,{className:`absolute left-0 top-[calc(100%+6px)] z-50 w-[420px] whitespace-normal text-left`,onMouseEnter:f,onMouseLeave:p,children:(0,B.jsx)(Qu,{agentId:e,lines:6,label:`${e} · ${o.role??``}`,className:`shadow-panel bg-paper`})}),l&&(0,B.jsx)(Ju,{agentId:e,onClose:()=>u(!1)})]})}var ed=[{re:/coordinator/i,label:`coordinator`,dot:`#4A6A2C`,ring:`#B9CFA0`},{re:/aide|liaison|curator/i,label:`aide`,dot:`#C4587A`,ring:`#F0C2D2`},{re:/\bqa\b|quality/i,label:`qa`,dot:`#C88A1E`,ring:`#F0DFA6`},{re:/\bci\b/i,label:`ci`,dot:`#E8702A`,ring:`#F6C9A6`},{re:/audit/i,label:`audit`,dot:`#7A4A6A`,ring:`#DDBFD3`},{re:/automation/i,label:`automation`,dot:`#8A7660`,ring:`#D9CDBB`},{re:/human|david/i,label:`human`,dot:`#B7521A`,ring:`#F6C9A6`}],td=e=>ed.find(t=>t.re.test(e??``))?.dot??`#5C7A96`,nd=e=>ed.find(t=>t.re.test(e??``))?.label??`worker`;function rd(){let{projects:e,current:t}=za(),n=q(`/bus/agents`,15e3).data??[],r=e.find(e=>e.name===t)?.room,i=n.filter(e=>e.liveness!==`dead`&&![`groundwork-console`,`david`].includes(e.agentId)&&(e.project===t||r&&e.project===r)),a=n.filter(e=>e.liveness!==`dead`&&![`groundwork-console`,`david`].includes(e.agentId)&&!i.includes(e)),o=e=>[`aide`,`coordinator`,`qa`,`ci`,`worker`,`audit`].indexOf(nd(e.role))+1||9,s=[...i].sort((e,t)=>o(e)-o(t)||e.agentId.localeCompare(t.agentId)),[c,l]=(0,P.useState)(!1);return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-1.5 border-b border-sand bg-paper/70 min-h-[34px] whitespace-nowrap overflow-x-auto [scrollbar-width:none]`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan shrink-0`,children:[`online · `,t||`—`]}),s.length===0&&(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`no agents for this project`}),s.map(e=>(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full border border-sand bg-paper`,style:{borderColor:td(e.role)+`66`},title:`${e.agentId} · ${nd(e.role)}${e.pane?` · ${e.pane}`:``}`,children:[(0,B.jsx)(Mu,{id:e.agentId,role:e.role,size:16,state:e.liveness,active:e.active}),(0,B.jsx)($u,{id:e.agentId,bare:!0,noDot:!0,size:`sm`}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.06em]`,style:{color:td(e.role)},children:nd(e.role)})]},e.agentId)),c&&a.map(e=>(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full border border-dashed border-sand bg-cream/60`,title:`${e.agentId} · ${nd(e.role)} · ${e.project??`?`}`,children:[(0,B.jsx)(Mu,{id:e.agentId,role:e.role,size:16,state:e.liveness,active:e.active}),(0,B.jsx)($u,{id:e.agentId,bare:!0,noDot:!0,size:`sm`}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-tan`,children:e.project})]},e.agentId)),a.length>0&&(0,B.jsx)(`button`,{onClick:()=>l(e=>!e),"aria-pressed":c,className:`ml-auto font-mono text-[11px] text-ink3 shrink-0 border-0 bg-transparent cursor-pointer hover:text-umber`,title:c?`show only this project`:a.map(e=>e.agentId).join(`, `),children:c?`only this project`:`+${a.length} elsewhere`}),(0,B.jsx)(`span`,{className:`ml-3 font-mono text-[10px] text-tan shrink-0 hidden xl:inline-flex items-center gap-2`,children:[[`coordinator`,`#4A6A2C`],[`aide`,`#C4587A`],[`qa`,`#C88A1E`],[`ci`,`#E8702A`],[`worker`,`#5C7A96`]].map(([e,t])=>(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full`,style:{background:t}}),e]},e))})]})}var id=(e,t)=>window.dispatchEvent(new CustomEvent(`groundwork-console:summon`,{detail:{agentId:e,answers:t?.answers}})),ad=e=>`groundwork-console.summon.${e}`,od=e=>`groundwork-console.summon.seen.${e}`;function sd(e){let t=rr(),n=t.pathname.match(/^\/docs\/(.+)$/),r=new URLSearchParams(t.search);if(n){let t=decodeURIComponent(n[1]),i=r.get(`line`);return t.startsWith(`kb:`)?{label:`knowledge/${t.slice(3)}${i?`:${i}`:``}`,cite:`groundwork-knowledge/${t.slice(3)}${i?`:${i}`:``}`}:{label:`${t}${i?`:${i}`:``}`,cite:`${e}/docs/${t}${i?`:${i}`:``}`}}let i=t.pathname===`/`?`home`:t.pathname.slice(1).split(`/`)[0];return{label:i,cite:`groundwork-console /${i}${e?` · ${e}`:``}`}}function cd(){let{current:e}=za(),t=q(`/bus/agents`,2e4).data??[],n=q(e?`/projects/${e}/agents`:null,3e4).data,r=t.filter(e=>e.liveness!==`dead`&&e.agentId!==`david`&&e.agentId!==`groundwork-console`),[i,a]=(0,P.useState)(()=>e?localStorage.getItem(ad(e)):null);(0,P.useEffect)(()=>{a(e?localStorage.getItem(ad(e)):null)},[e]);let o=(i&&t.some(e=>e.agentId===i)?i:null)??n?.aide??n?.coordinator??r[0]?.agentId??null,s=t.find(e=>e.agentId===o),[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(!1),f=t=>{a(t),e&&localStorage.setItem(ad(e),t),d(!1),l(!0)},p=q(o?`/bus/dm/${encodeURIComponent(o)}?limit=80`:null,c?4e3:2e4).data,m=q(`/bus/inbox?limit=100`,2e4).data?.decisions??{},[h,g]=(0,P.useState)(0);(0,P.useEffect)(()=>{o&&g(Number(localStorage.getItem(od(o))??0))},[o]),(0,P.useEffect)(()=>{c&&o&&p&&(localStorage.setItem(od(o),String(p.lastFromAgent)),g(p.lastFromAgent))},[c,o,p]);let _=!!p&&p.lastFromAgent>h;(0,P.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(d(!1),l(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[v,y]=(0,P.useState)([]);if((0,P.useEffect)(()=>{let e=e=>{let t=e.detail;y(t?.answers??[]),t?.agentId?f(t.agentId):(l(!1),d(!0))};return window.addEventListener(`groundwork-console:summon`,e),()=>window.removeEventListener(`groundwork-console:summon`,e)}),!o)return null;let b=r.length,x=r,S=e=>{let t=(b===1?.5:e/(b-1))*(Math.PI/2);return{x:-Math.sin(t)*96,y:-Math.cos(t)*96}};return(0,B.jsxs)(B.Fragment,{children:[c&&(0,B.jsx)(dd,{agentId:o,me:s,project:e,thread:p??void 0,answers:v,onAnswered:()=>y([]),onClose:()=>l(!1),onSwitch:()=>{d(!0)}}),(0,B.jsxs)(`div`,{className:`fixed right-5 bottom-5 z-[55]`,style:{width:52,height:52},children:[u&&(0,B.jsxs)(`div`,{className:`absolute inset-0`,"aria-label":`pick an agent`,children:[x.map((e,t)=>{let n=S(t);return(0,B.jsxs)(`button`,{onClick:()=>f(e.agentId),title:`${e.agentId} · ${nd(e.role)}`,className:`absolute rounded-full border-2 bg-paper shadow-panel cursor-pointer p-[3px] transition-transform hover:scale-110`,style:{left:26+n.x-17,top:26+n.y-17,borderColor:td(e.role),width:34,height:34,animation:`summon-pop .18s ease-out ${t*30}ms both`},children:[(0,B.jsx)(Mu,{id:e.agentId,role:e.role,size:26,state:e.liveness,active:e.active}),m[e.agentId]?(0,B.jsx)(ld,{n:m[e.agentId],small:!0}):null]},e.agentId)}),x.length===0&&(0,B.jsx)(`span`,{className:`absolute right-0 bottom-14 whitespace-nowrap font-mono text-[11px] text-tan bg-paper border border-sand rounded-kit px-2 py-1`,children:`no live agents`})]}),(0,B.jsxs)(`button`,{onClick:()=>u?d(!1):l(e=>!e),title:`${o} · ${nd(s?.role)} — click to chat`,className:`absolute inset-0 rounded-full border-2 bg-paper shadow-panel cursor-pointer p-1 hover:scale-105 transition-transform`,style:{borderColor:td(s?.role)},children:[(0,B.jsx)(Mu,{id:o,role:s?.role,size:40,state:s?.liveness??`dead`,active:s?.active}),m[o]?(0,B.jsx)(ld,{n:m[o]}):_&&(0,B.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 w-3 h-3 rounded-full bg-ember border-2 border-paper`,title:`new message`})]}),(0,B.jsx)(`button`,{onClick:()=>d(e=>!e),"aria-pressed":u,title:`pick another agent`,className:`absolute -left-2 -top-2 w-6 h-6 rounded-full border border-dust shadow-panel cursor-pointer text-[13px] leading-none flex items-center justify-center ${u?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:u?`×`:`+`})]}),(0,B.jsx)(`style`,{children:`.summon-dots{display:inline-flex;gap:3px}.summon-dots i{width:5px;height:5px;border-radius:50%;background:currentColor;opacity:.25;animation:summon-dot 1.2s infinite}.summon-dots i:nth-child(2){animation-delay:.2s}.summon-dots i:nth-child(3){animation-delay:.4s}@keyframes summon-dot{0%,80%,100%{opacity:.25}40%{opacity:1}}@keyframes summon-pop{from{transform:scale(.4);opacity:0}to{transform:scale(1);opacity:1}}@keyframes summon-pulse{0%,100%{box-shadow:0 0 0 0 rgba(200,120,42,.55)}50%{box-shadow:0 0 0 6px rgba(200,120,42,0)}}`})]})}function ld({n:e,small:t=!1}){return(0,B.jsx)(`span`,{className:`absolute -top-1 -right-1 rounded-full bg-ember text-paper border-2 border-paper font-mono font-bold flex items-center justify-center leading-none ${t?`w-4 h-4 text-[9px]`:`w-5 h-5 text-[10px]`}`,title:`${e} decision${e===1?``:`s`} waiting on you`,style:{animation:`summon-pulse 1.6s ease-in-out infinite`},children:`★`})}var ud=e=>{let t=Math.round(e/1e3);return t<60?`${t} s`:t<3600?`${Math.floor(t/60)} min`:`${Math.floor(t/3600)} h`};function dd({agentId:e,me:t,project:n,thread:r,answers:i=[],onAnswered:a,onClose:o,onSwitch:s}){let c=q(`/admin/bus-writes`,1e4).data?.enabled??!1,l=sd(n),[u,d]=(0,P.useState)(!0),[f,p]=(0,P.useState)(``),[m,h]=(0,P.useState)(null),[g,_]=(0,P.useState)(!1),[v,y]=(0,P.useState)(()=>localStorage.getItem(`groundwork-console.summon.max`)===`1`),b=()=>y(e=>(localStorage.setItem(`groundwork-console.summon.max`,e?`0`:`1`),!e)),x=Wu(),S=(0,P.useRef)(null),[C,w]=(0,P.useState)([]),T=r?.messages??[],E=C.filter(e=>!T.some(t=>t.from===`david`&&Number(t.ts??0)>=Number(e.ts??0)-2e3&&(t.text??``)===(e.text??``))),D=[...T,...E],[O,k]=(0,P.useState)(0);(0,P.useEffect)(()=>{let e=setInterval(()=>k(e=>e+1),1e3);return()=>clearInterval(e)},[]);let A=(q(`/bus/agents`,4e3).data??[]).find(t=>t.agentId===e)??t,j=A?.paneActivity?Date.now()-A.paneActivity:1/0,M=j<2e4,N=([...D].reverse().find(e=>e.from===`david`)?.ts??0)>([...D].reverse().find(e=>e.from!==`david`)?.ts??0);(0,P.useEffect)(()=>{S.current&&(S.current.scrollTop=S.current.scrollHeight)},[D.length,M,N]);let ee=async()=>{if(!x.hasContent(f))return;h(`sending`);let t=x.withRefs(f.trim()),n=u?`${t}\n(context: ${l.cite})`:t,r={id:`local-${Date.now()}`,ts:Date.now(),from:`david`,to:e,text:n,prefix:null,pending:!0};w(e=>[...e,r]),p(``),x.clear();try{let t=await Fa(`/actions/send`,{as:`david`,to:e,text:n,answers:i.length?i:void 0});if(t.status===`ok`)h(null),a?.();else{let e=t.error??t.log?.slice(-1)[0]??`failed`;h(e),w(t=>t.map(t=>t.id===r.id?{...t,failed:e}:t))}}catch(e){let t=e.message;h(t),w(e=>e.map(e=>e.id===r.id?{...e,failed:t}:e))}},F=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``,I=(0,P.useMemo)(()=>D,[D]);return(0,B.jsxs)(B.Fragment,{children:[g&&(0,B.jsx)(Ju,{agentId:e,onClose:()=>_(!1)}),(0,B.jsxs)(`div`,{className:`fixed z-[54] bg-paper border border-sand rounded-kit shadow-panel grid grid-rows-[auto_minmax(0,1fr)_auto] whitespace-normal text-left transition-[width,height] duration-150 ${v?`right-5 bottom-[84px] w-[min(1100px,calc(100vw-40px))] h-[calc(100vh-110px)]`:`right-5 bottom-[84px] w-[min(400px,calc(100vw-40px))] h-[min(560px,calc(100vh-140px))]`}`,style:{borderTop:`3px solid ${td(t?.role)}`},children:[(0,B.jsxs)(`div`,{className:`px-3 py-2 border-b border-sand flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(Mu,{id:e,role:t?.role,size:22,state:t?.liveness??`dead`,active:t?.active}),(0,B.jsx)(`span`,{className:`font-display font-bold text-[14px] text-umber truncate`,children:e}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.06em]`,style:{color:td(t?.role)},children:nd(t?.role)}),t?(0,B.jsx)(G,{tone:t.liveness===`live`?`ok`:t.liveness===`idle`?`warn`:`bad`,children:t.active?`active`:t.liveness}):(0,B.jsx)(G,{tone:`bad`,children:`offline`}),(0,B.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[t?.pane&&(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>_(!0),title:`open its pane`,children:`pane`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:s,title:`summon another agent`,children:`switch`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:b,title:v?`restore`:`maximize`,children:v?`⇲`:`⇱`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:o,children:`✕`})]})]}),(0,B.jsxs)(`div`,{ref:S,className:`min-h-0 overflow-auto px-3 py-2 grid gap-1.5 content-start bg-cream/40`,children:[!r&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`loading thread…`}),r&&I.length===0&&(0,B.jsxs)(`span`,{className:`text-[12px] text-umber`,children:[`No DMs with `,e,` yet. Say what you need — it lands in its pane via tmux-push.`]}),I.map((e,t)=>{let n=e.from===`david`,r=String(e.text??``),i=e.prefix?r.replace(RegExp(`^${e.prefix}:?\\s*`),``):r;return(0,B.jsxs)(`div`,{className:`${e.pending?`opacity-70`:``} ${v?`max-w-[70%]`:`max-w-[88%]`} rounded-kit px-2.5 py-1.5 text-[12.5px] leading-snug whitespace-pre-wrap break-words border ${n?`justify-self-end bg-paper border-sand`:`justify-self-start bg-linen/70 border-sand/70`}`,children:[e.prefix&&(0,B.jsx)(Da,{prefix:e.prefix}),(0,B.jsx)(Ku,{text:i}),(0,B.jsx)(`div`,{className:`font-mono text-[10px] mt-0.5 ${n?`text-right`:``} ${e.failed?`text-brick`:`text-tan`}`,children:e.failed?`not sent · ${e.failed}`:e.pending?`sending…`:F(e.ts)})]},e.id??t)}),(M||N)&&(0,B.jsx)(`div`,{className:`justify-self-start inline-flex items-center gap-2 px-2.5 py-1.5 rounded-kit border border-sand/70 bg-linen/50 font-mono text-[11px] text-ink3`,title:A?.paneActivity?`last pane output ${Math.round(j/1e3)} s ago`:`no pane activity`,children:M?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`summon-dots`,"aria-hidden":!0,children:[(0,B.jsx)(`i`,{}),(0,B.jsx)(`i`,{}),(0,B.jsx)(`i`,{})]}),(0,B.jsxs)(`span`,{children:[e.split(`-`)[0],` is working`]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-tan`}),(0,B.jsxs)(`span`,{children:[`delivered · quiet for `,j===1/0?`a while`:ud(j)]})]})})]}),(0,B.jsxs)(`div`,{className:`px-3 py-2 border-t border-sand grid gap-1.5`,children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-1.5 font-mono text-[11px] text-ink3 min-w-0`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),(0,B.jsx)(`span`,{className:`shrink-0`,children:`context:`}),(0,B.jsx)(`span`,{className:`truncate text-umber`,title:l.cite,children:l.label})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-1.5 items-center`,children:[(0,B.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&c&&(e.preventDefault(),ee())},onPaste:x.onPaste,onDrop:x.onDrop,onDragOver:x.onDragOver,disabled:!c,rows:v?4:2,placeholder:c?`DM ${e} as david — Enter to send, ⇧Enter newline, paste images`:`bus writes are off (header badge)`,className:`text-[13px] px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut resize-none min-w-0`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:ee,disabled:!c||!x.hasContent(f)||x.busy||m===`sending`,children:m===`sending`?`…`:`Send`})]}),(0,B.jsx)(Gu,{a:x}),m&&m!==`sending`&&(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-brick`,children:m})]})]})]})}var fd={h:`/`,b:`/board`,m:`/monitor`,u:`/bus`,d:`/docs`,o:`/ops`},pd=e=>{let t=e;return!!t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)};function md(){let e=ar(),[t,n]=(0,P.useState)(!1);return(0,P.useEffect)(()=>{let t=0,r=r=>{if(!(r.metaKey||r.ctrlKey||r.altKey||pd(r.target))){if(r.key===`Escape`){n(!1);return}if(r.key===`?`){n(e=>!e);return}if(r.key===`/`){r.preventDefault(),id(``);return}if(r.key===`g`){t=Date.now();return}Date.now()-t<900&&fd[r.key]&&(r.preventDefault(),e(fd[r.key]),t=0)}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e]),t?(0,B.jsx)(`div`,{className:`fixed inset-0 z-[70] bg-walnut/30 flex items-center justify-center`,onMouseDown:()=>n(!1),children:(0,B.jsxs)(`div`,{className:`bg-paper border border-sand rounded-kit shadow-panel p-4 grid gap-2 min-w-[320px]`,onMouseDown:e=>e.stopPropagation(),children:[(0,B.jsx)(`div`,{className:`font-display font-bold text-[15px] text-umber`,children:`Keyboard`}),[[`/`,`summon an agent (picker)`],[`g h`,`Home`],[`g b`,`Board`],[`g m`,`Monitor`],[`g u`,`Bus`],[`g d`,`Docs`],[`g o`,`Ops`],[`Esc`,`close drawer / picker / this`],[`?`,`toggle this list`]].map(([e,t])=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[64px_1fr] gap-3 items-baseline text-[13px]`,children:[(0,B.jsx)(`kbd`,{className:`font-mono text-[12px] px-1.5 py-0.5 border border-dust rounded bg-cream text-walnut justify-self-start`,children:e}),(0,B.jsx)(`span`,{className:`text-umber`,children:t})]},e)),(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan mt-1`,children:`In the Summon drawer: Enter sends · ⇧Enter newline · paste images.`})]})}):null}var hd=`/api`;function gd({children:e}){let[t,n]=(0,P.useState)(`checking`),[r,i]=(0,P.useState)(``),[a,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(!1),l=async()=>{try{let e=await(await fetch(`${hd}/auth/status`)).json();n(e.authed?`in`:`out`)}catch{n(`offline`)}};(0,P.useEffect)(()=>{l()},[]),(0,P.useEffect)(()=>{let e=()=>n(`out`);return window.addEventListener(`groundwork-console:unauthorized`,e),()=>window.removeEventListener(`groundwork-console:unauthorized`,e)},[]);let u=async()=>{c(!0),o(null);try{let e=await fetch(`${hd}/auth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:r})}),t=await e.json();if(!e.ok)throw Error(t.error??`${e.status}`);i(``),n(`in`)}catch(e){o(e.message)}finally{c(!1)}};return t===`in`?(0,B.jsx)(B.Fragment,{children:e}):t===`checking`?(0,B.jsx)(`div`,{className:`min-h-screen grid place-items-center font-mono text-[12px] text-tan`,children:`checking session…`}):(0,B.jsx)(`div`,{className:`min-h-screen grid place-items-center bg-cream p-6`,children:(0,B.jsxs)(`div`,{className:`w-[380px] bg-paper border border-sand rounded-kit shadow-panel`,children:[(0,B.jsxs)(`div`,{className:`px-5 py-4 border-b border-sand flex items-center gap-2 font-display font-bold text-[18px] text-ember`,children:[(0,B.jsx)(Na,{}),` Groundwork Console`]}),(0,B.jsx)(`div`,{className:`p-5 grid gap-3 text-[13px]`,children:t===`offline`?(0,B.jsxs)(`div`,{className:`text-brick`,children:[`API unreachable — start it with `,(0,B.jsx)(`code`,{children:`pnpm dev:api`}),`, then `,(0,B.jsx)(`button`,{className:`underline border-0 bg-transparent p-0 cursor-pointer text-ember-deep`,onClick:l,children:`retry`}),`.`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`text-umber`,children:[`This console can write to your bus and docs. Enter the console token — it's in `,(0,B.jsx)(`code`,{className:`font-mono text-[12px]`,children:`~/.groundwork-console/token`}),` on the machine running the API (or `,(0,B.jsx)(`code`,{className:`font-mono text-[12px]`,children:`GROUNDWORK_CONSOLE_TOKEN`}),`).`]}),(0,B.jsx)(`input`,{type:`password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r&&u()},placeholder:`token`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`}),a&&(0,B.jsx)(`div`,{className:`text-brick`,children:a}),(0,B.jsx)(K,{tone:`primary`,onClick:u,disabled:!r||s,children:s?`Signing in…`:`Sign in`}),(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`Cookie lasts 30 days on this browser. Single shared token — no accounts.`})]})})]})})}var _d=[{to:`/`,label:`Home`,icon:`home`},{to:`/board`,label:`Board`,icon:`board`},{to:`/bus`,label:`Bus`,icon:`bus`},{to:`/monitor`,label:`Monitor`,icon:`monitor`},{to:`/docs`,label:`Docs`,icon:`docs`},{to:`/ops`,label:`Ops`,icon:`fleet`}];function vd(){let{error:e}=za(),{running:t}=Ha(),n=q(`/bus/unread`,3e4).data?.inbox??0,r=q(`/kit`).data,i=r?.packages?`${r.name} ${r.kitVersion} · seam ${r.packages.seam?.version} · mcp ${r.packages.mcp?.version}`:`kit · offline`;return(0,B.jsx)(gd,{children:(0,B.jsx)(Du,{children:(0,B.jsxs)(`div`,{className:`grid grid-rows-[48px_auto_1fr] min-h-screen`,children:[(0,B.jsxs)(`header`,{className:`grid grid-cols-[auto_auto_1fr] items-center gap-4 px-4 border-b border-sand bg-cream min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 font-display font-bold text-[16px] text-ember whitespace-nowrap`,title:i,children:[(0,B.jsx)(Na,{}),` Groundwork Console`]}),(0,B.jsx)(`nav`,{className:`flex gap-0.5 whitespace-nowrap`,children:_d.map(e=>(0,B.jsxs)(ji,{to:e.to===`/bus`&&n>0?`/bus?view=inbox`:e.to,end:e.to===`/`,className:({isActive:e})=>`inline-flex items-center gap-1.5 px-3 py-2 rounded-kit font-medium ${e?`bg-paper text-walnut shadow-[inset_0_0_0_1px_var(--color-sand)]`:`text-umber hover:no-underline hover:bg-linen`}`,children:[(0,B.jsx)(`span`,{className:`text-tan`,children:Ca[e.icon]({size:16})}),(0,B.jsx)(`span`,{className:`hidden xl:inline`,children:e.label}),e.to===`/ops`&&t>0?(0,B.jsxs)(`span`,{className:`ml-1.5 inline-flex items-center gap-1 text-amber`,children:[(0,B.jsx)(Ma,{size:12}),(0,B.jsx)(G,{tone:`warn`,children:t})]}):null,e.to===`/bus`&&n>0?(0,B.jsx)(`span`,{className:`ml-1.5 inline-flex`,title:`${n} unread DM(s) to david`,children:(0,B.jsx)(G,{tone:`david`,children:n})}):null,e.badge?(0,B.jsx)(`span`,{className:`ml-1.5 inline-flex`,children:(0,B.jsx)(G,{tone:`david`,children:e.badge})}):null]},e.to))}),(0,B.jsxs)(`div`,{className:`flex gap-0.5 items-center justify-end min-w-0 whitespace-nowrap`,children:[e&&(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-brick mr-2`,title:e,children:`api offline`}),(0,B.jsx)(Ga,{}),(0,B.jsx)(Ya,{}),(0,B.jsx)(Ja,{}),(0,B.jsx)(J,{}),(0,B.jsx)(`button`,{onClick:async()=>{await fetch(`/api/auth/logout`,{method:`POST`}),window.dispatchEvent(new Event(`groundwork-console:unauthorized`))},className:`ml-1 font-mono text-[11px] text-tan border-0 bg-transparent cursor-pointer hover:text-umber`,title:`sign out (clears the session cookie)`,children:`⎋`})]})]}),(0,B.jsx)(rd,{}),(0,B.jsx)(Rr,{}),(0,B.jsx)(ao,{}),(0,B.jsx)(cd,{}),(0,B.jsx)(md,{})]})})})}function $(e,t=Date.now()){let n=Math.max(0,(t-e)/1e3)/60,r=n/60,i=r/24;if(n<1)return`just now`;if(r<1)return`${Math.floor(n)} min ago`;if(i<1)return`${Math.floor(r)} h ago`;if(i<2)return`yesterday`;if(i<7)return`${Math.floor(i)} days ago`;let a=i/7;if(a<2)return`last week`;if(i<30)return`${Math.floor(a)} weeks ago`;let o=i/30;return o<2?`last month`:i<365?`${Math.floor(o)} months ago`:i<730?`last year`:`${Math.floor(i/365)} years ago`}function yd(e,t=Date.now()){let n=(t-e)/864e5;return n<1?`text-tan`:n<7?`text-amber`:`text-brick font-semibold`}var bd=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),xd=e=>!!e&&Ta.includes(e),Sd={"state.fact.stale":`warn`,"state.board.malformed":`bad`,"state.decision.open":`david`,"state.phase.active":`neutral`,"phase.completed":`ok`,"phase.started":`ok`,"phase.progress":`neutral`,"done.appended":`ok`,"queue.item.added":`neutral`,"queue.item.closed":`ok`,"fact.stale":`warn`,"board.malformed":`bad`,"decision.posted":`david`};function Cd(){let{data:e,refresh:t}=q(`/events?limit=40`,15e3),[n,r]=(0,P.useState)(!1),[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),c=async(e,n)=>{s(!0);try{await Fa(`/events/config`,{rule:e,enabled:n}),t()}finally{s(!1)}},l=async e=>{s(!0);try{await Fa(`/events/config`,{dryRun:e,confirm:e?void 0:i}),t(),r(!1),a(``)}finally{s(!1)}},[u,d]=(0,P.useState)([]);(0,P.useEffect)(()=>{let e=new EventSource(`/api/events/stream`);return e.onmessage=e=>{let t=JSON.parse(e.data);t.type!==`hello`&&d(e=>{let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=e.slice();return r[n]=t,r}return[t,...e].slice(0,40)})},()=>e.close()},[]);let f=[...u,...(e?.recent??[]).filter(e=>!u.some(t=>t.id===e.id)).slice().reverse()].slice(0,40),p=e?.config;return(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Events`,icon:`health`,path:p?`${p.identity.displayName??p.identity.agentId} · ${p.rules.filter(e=>e.enabled).length}/${p.rules.length} rules enabled · dedupe ${p.limits?.dedupeTtlHours??72} h · max ${p.limits?.maxPerRulePerProjectPerHour??3}/h`:`detector`,children:[p&&(p.live?(0,B.jsx)(G,{tone:`bad`,children:`LIVE — sending`}):p.dryRun?(0,B.jsx)(G,{tone:`outline`,children:`dry-run`}):(0,B.jsx)(G,{tone:`warn`,children:`armed · bus writes off`})),p&&(p.dryRun?(0,B.jsx)(K,{size:`sm`,onClick:()=>r(!0),disabled:o,children:`Go live…`}):(0,B.jsx)(K,{size:`sm`,onClick:()=>l(!0),disabled:o,children:`Back to dry-run`}))]}),p&&(0,B.jsxs)(`div`,{className:`px-3 py-2 border-b border-sand grid gap-1`,children:[p.rules.map(e=>(0,B.jsxs)(`label`,{className:`grid grid-cols-[auto_1fr] gap-2 items-baseline font-mono text-[12px] text-ink3 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!e.enabled,disabled:o||e.action.type===`none`,onChange:t=>c(e.id,t.target.checked),title:e.action.type===`none`?`informational rule — nothing to send`:`enable this rule`}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-walnut`,children:e.on}),` → `,e.action.type===`none`?(0,B.jsx)(`span`,{className:`text-tan`,children:e.action.note}):(0,B.jsxs)(B.Fragment,{children:[e.action.to?e.action.to:`#${e.action.room}`,` · `,xd(e.action.prefix)&&(0,B.jsx)(Da,{prefix:e.action.prefix}),(0,B.jsx)(`span`,{className:`text-umber`,children:e.action.text})]})]})]},e.id)),(0,B.jsxs)(`div`,{className:`text-[11px] font-mono text-tan`,children:[`a rule sends only when: bus writes ON (header) · dry-run OFF · rule enabled · not a duplicate (key, `,p.limits?.dedupeTtlHours??72,` h) · under the rate limit · a live coordinator exists for the project. Baseline state.* events never trigger rules.`]})]}),n&&(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[12vh]`,onMouseDown:e=>{e.target===e.currentTarget&&r(!1)},children:(0,B.jsxs)(`div`,{className:`w-[520px] bg-paper border border-brick rounded-kit shadow-panel`,children:[(0,B.jsx)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] text-brick`,children:`Turn dry-run off`}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px] text-umber`,children:[(0,B.jsxs)(`div`,{children:[`Enabled rules will really `,(0,B.jsx)(`code`,{children:`send_message`}),` as `,(0,B.jsx)(`b`,{className:`text-walnut`,children:`groundwork-console`}),` (automation) whenever bus writes are on. Dedupe + rate limit apply; every send is a Run. Persisted in `,(0,B.jsx)(`code`,{children:`groundwork-console.rules.json`}),`.`]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Type LIVE to confirm`}),(0,B.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]})]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:()=>r(!1),children:`Cancel`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>l(!1),disabled:i!==`LIVE`||o,children:`Go live`})]})]})}),f.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`Watching seam files + rooms every 15 s. Nothing dirty at baseline and nothing changed since.`}),f.map(e=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[var(--spacing-gutter)_1fr] border-b border-sand last:border-b-0`,children:[(0,B.jsx)(`div`,{className:`py-2.5 flex justify-center font-mono text-[12px] text-tan border-r border-sand`,children:`⚡`}),(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-baseline mb-0.5 flex-wrap`,children:[(0,B.jsx)(G,{tone:Sd[e.type]??`neutral`,children:e.type}),e.data.baseline?(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`baseline · no action`}):null,(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-umber`,children:e.project}),(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-ink3`,children:bd(e.ts)})]}),(0,B.jsx)(`div`,{className:`font-mono text-[12px] text-umber break-all`,children:Object.entries(e.data).filter(([e])=>![`project`,`room`].includes(e)).map(([e,t])=>`${e}=${String(t)}`).join(` · `)}),e.actions.filter(e=>e.type!==`none`).map(e=>(0,B.jsxs)(`div`,{className:`mt-1 text-[13px] pl-2 border-l-2 ${e.sent?`border-leaf`:e.skipped?`border-amber`:`border-dust`}`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.06em] mr-1.5 ${e.sent?`text-leaf`:e.skipped?`text-amber`:`text-tan`}`,children:e.sent?`sent`:e.skipped?`skipped · ${e.skipped}`:e.dryRun?`would send`:`sending`}),xd(e.prefix)&&(0,B.jsx)(Da,{prefix:e.prefix}),(0,B.jsx)(`span`,{className:`text-walnut`,children:e.text}),` `,(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,children:[`→ `,e.to??`#${e.room}`]}),e.runId&&(0,B.jsx)(`span`,{className:`ml-2 font-mono text-[11px] text-tan`,children:e.runId})]},e.ruleId))]})]},e.id))]})}function wd(){let{data:e}=q(`/events?limit=40`,3e4),t=e?.config;if(!t)return null;let n=t.rules.filter(e=>e.enabled).length,r=Date.now()-864e5,i=(e?.recent??[]).filter(e=>e.ts>r).flatMap(e=>e.actions).filter(e=>e.sent).length;return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[11px] text-ink3 px-1`,children:[(0,B.jsx)(`span`,{className:`uppercase tracking-[.1em] text-tan`,children:`events`}),t.live?(0,B.jsx)(G,{tone:`bad`,children:`live`}):t.dryRun?(0,B.jsx)(G,{tone:`outline`,children:`dry-run`}):(0,B.jsx)(G,{tone:`warn`,children:`armed · bus writes off`}),(0,B.jsxs)(`span`,{children:[n,`/`,t.rules.length,` rules on · `,i,` sent in 24 h`]}),(0,B.jsx)(V,{to:`/ops/events`,className:`ml-auto text-ember-deep`,children:`Ops → Events`})]})}var Td={complete:{label:`complete`,tone:`ok`,dot:`bg-leaf border-leaf`,ring:`text-leaf`,hint:`all tasks ticked`},ongoing:{label:`ongoing`,tone:`david`,dot:`bg-ember border-ember`,ring:`text-ember`,hint:`streams in flight or tasks ticked`},planned:{label:`planned`,tone:`neutral`,dot:`bg-paper border-umber`,ring:`text-umber`,hint:`tasks written, none started`},pending:{label:`pending`,tone:`outline`,dot:`bg-paper border-dust border-dashed`,ring:`text-tan`,hint:`no PHASE*_TASKS.md yet — run /plan-phase`}};function Ed({pct:e,cls:t,size:n=44}){let r=(n-6)/2,i=2*Math.PI*r;return(0,B.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:t,"aria-hidden":!0,children:[(0,B.jsx)(`circle`,{cx:n/2,cy:n/2,r,fill:`none`,stroke:`currentColor`,strokeOpacity:`.18`,strokeWidth:`4`}),(0,B.jsx)(`circle`,{cx:n/2,cy:n/2,r,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${e/100*i} ${i}`,transform:`rotate(-90 ${n/2} ${n/2})`})]})}function Dd({project:e,phases:t,canWrite:n}){let r=q(`/projects/${e}/agents`,3e4).data,[i,a]=(0,P.useState)(null),[o,s]=(0,P.useState)(null),[c,l]=(0,P.useState)(null),u=`groundwork-console.roadmap.last.${e}`,[d,f]=(0,P.useState)(()=>{try{return JSON.parse(localStorage.getItem(u)??`{}`)}catch{return{}}}),p=(e,t,n)=>f(r=>{let i={...r,[e]:{verb:t,to:n,ts:Date.now()}};return localStorage.setItem(u,JSON.stringify(i)),i}),m=e=>{let t=Math.floor((Date.now()-e)/6e4);return t<1?`just now`:t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`},h=async(t,i)=>{if(!n){s(`bus writes are off — click the header badge (read-only · v0.1) and type ENABLE, then retry`);return}if(i===`plan`&&!r?.aide){s(`no live aide for ${e} — start one (coord-aide) in #room, or DM the coordinator from Bus`);return}if(i!==`plan`&&!r?.coordinator){s(`no live coordinator for ${e}`);return}a(`${t.id}:${i}`),s(null);try{let n=await Fa(`/actions/phase/${e}/${t.id}/${i}`),r=n.args?.to??``;n.status===`ok`&&p(t.id,i,r),s(n.status===`ok`?`sent → ${r}`:n.error??n.log?.slice(-1)[0]??`failed`)}catch(e){s(e.message)}finally{a(null)}},g=t.filter(e=>e.state===`complete`).length,_=t.find(e=>e.state===`ongoing`)??t.find(e=>e.state===`planned`)??t.find(e=>e.state===`pending`);return(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Roadmap`,icon:`phases`,eyebrow:`PRODUCTION_ROADMAP · phases/`,path:`${g}/${t.length} complete${_?` · next: ${_.title}`:``}`,children:(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 flex-wrap`,children:[r?.aide?(0,B.jsx)($u,{id:r.aide,prefix:`aide`}):(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`no live aide`}),r?.coordinator?(0,B.jsx)($u,{id:r.coordinator,prefix:`coord`}):(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`no live coordinator`})]})}),t.length===0&&(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:[`No `,(0,B.jsx)(`code`,{children:`docs/phases/`}),` yet — run `,(0,B.jsx)(`code`,{children:`/kickstart`}),` or `,(0,B.jsx)(`code`,{children:`/plan-phase 1`}),`.`]}),t.length>0&&(0,B.jsxs)(`div`,{className:`px-3 pt-3 pb-2 overflow-x-auto`,children:[(0,B.jsx)(`ol`,{className:`flex items-start gap-0 min-w-max`,children:t.map((e,n)=>{let r=Td[e.state],a=e.total?Math.round(e.done/e.total*100):0,o=n===t.length-1;return(0,B.jsxs)(`li`,{className:`flex items-start`,children:[(0,B.jsxs)(`div`,{className:`w-[190px] grid gap-1.5 justify-items-center text-center`,children:[(0,B.jsxs)(`button`,{onClick:()=>l(t=>t===e.id?null:e.id),className:`relative border-0 bg-transparent p-0 cursor-pointer rounded-full ${c===e.id?`ring-2 ring-ember ring-offset-2 ring-offset-paper`:``}`,title:`show tasks`,children:[(0,B.jsx)(Ed,{pct:e.state===`complete`?100:a,cls:r.ring}),(0,B.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center font-mono font-bold text-[12px] ${r.ring}`,children:e.state===`complete`?`✓`:e.n})]}),(0,B.jsx)(`button`,{onClick:()=>l(t=>t===e.id?null:e.id),className:`font-semibold text-[13px] leading-tight line-clamp-2 px-1 border-0 bg-transparent cursor-pointer text-walnut hover:text-ember-deep`,title:e.title,children:e.title}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(G,{tone:r.tone,children:r.label}),(0,B.jsxs)(`span`,{className:`font-mono text-[11px] text-ink3`,children:[e.total?`${e.done}/${e.total}`:`—`,e.streams?` · ${e.streams} stream${e.streams===1?``:`s`}`:``]})]}),d[e.id]&&(0,B.jsxs)(`div`,{className:`font-mono text-[10px] text-ink3 flex items-center gap-1 justify-center flex-wrap`,title:new Date(d[e.id].ts).toLocaleString(),children:[(0,B.jsx)(`span`,{className:`uppercase tracking-[.06em]`,children:d[e.id].verb===`kickoff`?`kicked off`:d[e.id].verb===`plan`?`plan requested`:`audit requested`}),(0,B.jsx)(`span`,{children:`→`}),(0,B.jsx)($u,{id:d[e.id].to,bare:!0}),(0,B.jsx)(`span`,{className:`text-tan`,children:m(d[e.id].ts)})]}),(0,B.jsxs)(`div`,{className:`flex gap-1 flex-wrap justify-center`,children:[(e.tasks||e.readme)&&(0,B.jsx)(V,{to:`/docs/${encodeURIComponent(e.tasks??e.readme)}`,className:`hover:no-underline`,children:(0,B.jsx)(K,{size:`sm`,tone:`ghost`,children:`Open`})}),e.state===`pending`&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,disabled:!!i,title:`DM the aide: run /plan-phase`,onClick:()=>h(e,`plan`),children:i===`${e.id}:plan`?(0,B.jsx)(Ma,{size:12}):`Plan`}),e.state===`planned`&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,disabled:!!i,title:`GO to the coordinator`,onClick:()=>h(e,`kickoff`),children:i===`${e.id}:kickoff`?(0,B.jsx)(Ma,{size:12}):`Kick off`}),e.state===`ongoing`&&(0,B.jsx)(K,{size:`sm`,disabled:!!i,title:`ask the coordinator to run /coord-audit`,onClick:()=>h(e,`audit`),children:i===`${e.id}:audit`?(0,B.jsx)(Ma,{size:12}):`Audit`})]})]}),!o&&(0,B.jsx)(`div`,{className:`mt-[21px] h-[3px] w-6 rounded ${e.state===`complete`?`bg-leaf`:`bg-sand`}`})]},e.id)})}),c&&(0,B.jsx)(Vu,{project:e,phase:t.find(e=>e.id===c),onClose:()=>l(null)}),o&&(0,B.jsx)(`div`,{className:`mt-2 font-mono text-[12px] flex items-center gap-2 ${/^sent/.test(o)?`text-leaf`:`text-brick`}`,children:/^sent → /.test(o)?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{children:`sent →`}),(0,B.jsx)($u,{id:o.replace(/^sent → /,``),bare:!0})]}):o}),(0,B.jsx)(`div`,{className:`mt-2 font-mono text-[11px] text-tan flex gap-3 flex-wrap`,children:Object.keys(Td).map(e=>(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full border mr-1 align-middle ${Td[e].dot}`}),Td[e].label,` — `,Td[e].hint]},e))})]})]})}function Od({phases:e}){return e?.length?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:e.map(e=>`${e.n}: ${e.state}${e.total?` ${e.done}/${e.total}`:``}`).join(` · `),children:[e.map((e,t)=>(0,B.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full border ${Td[e.state].dot}`},t)),(0,B.jsxs)(`span`,{className:`ml-1 font-mono text-[11px] text-ink3`,children:[e.filter(e=>e.state===`complete`).length,`/`,e.length]})]}):(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`no phases`})}function kd({project:e,canWrite:t,onClose:n,initialRole:r}){let{data:i}=q(`/actions/spawn/options?project=${encodeURIComponent(e)}`),[a,o]=(0,P.useState)(r??`worker`),[s,c]=(0,P.useState)(`claude`),[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),[p,m]=(0,P.useState)(``),[h,g]=(0,P.useState)(``),[_,v]=(0,P.useState)(8),[y,b]=(0,P.useState)(!1),[x,S]=(0,P.useState)(null),[C,w]=(0,P.useState)(null),T=ar(),{runs:E}=Ha(),D=x?E.find(e=>e.id===x.id)??x:null;(0,P.useEffect)(()=>{i&&!l&&u(i.suggest[a]??``)},[i,a,l]),(0,P.useEffect)(()=>{i&&u(i.suggest[a]??``)},[a]);let O=async()=>{b(!0),w(null);try{let t=await Fa(`/actions/spawn`,{project:e,role:a,harness:s,agentId:l,lane:d||void 0,model:p||void 0,note:h||void 0,waitSeconds:_});if(!t.status)throw Error(t.error??`failed`);S(t)}catch(e){w(e.message)}finally{b(!1)}},k=i?.roles.find(e=>e.id===a)?.skill??``;return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[8vh] whitespace-normal text-left`,onMouseDown:e=>{e.target===e.currentTarget&&!y&&n()},children:(0,B.jsxs)(`div`,{className:`w-[640px] bg-paper border border-sand rounded-kit shadow-panel`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] text-umber`,children:[`Spawn agent · `,e]}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px]`,children:[(0,B.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap items-center text-umber`,children:[(0,B.jsx)(G,{tone:t?`warn`:`outline`,children:t?`bus writes on`:`bus writes OFF`}),(0,B.jsxs)(`span`,{children:[`tmux window `,(0,B.jsxs)(`code`,{children:[`fleet-`,e]}),` · cwd `,(0,B.jsx)(`code`,{children:i?.repoPath?.replace(/^\/Users\/[^/]+/,`~`)}),i?.room?(0,B.jsxs)(B.Fragment,{children:[` · room `,(0,B.jsxs)(`code`,{children:[`#`,i.room]})]}):` · no room linked`]})]}),!t&&(0,B.jsx)(`div`,{className:`text-brick`,children:`Turn on bus writes (header toggle) first — spawning launches a process and types the role invocation into the new pane.`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Role · playbook card`}),(0,B.jsx)(`select`,{value:a,onChange:e=>o(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`,children:(i?.roles??[]).map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.id,` · `,e.skill]},e.id))})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Harness`}),(0,B.jsx)(`select`,{value:s,onChange:e=>c(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`,children:(i?.harnesses??[]).map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.id,` · `,e.cmd]},e.id))})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Agent id`}),(0,B.jsx)(`input`,{value:l,onChange:e=>u(e.target.value.trim()),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]}),a===`worker`?(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Lane`}),(0,B.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`repo-owner · rendering · api`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]}):(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Model (Claude only, optional)`}),(0,B.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`claude-sonnet-4-6`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Extra instruction (optional, injected after the skill)`}),(0,B.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`e.g. mission: re-verify the design doc after PR4`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 text-umber`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Start wait`}),(0,B.jsx)(`input`,{type:`range`,min:3,max:30,value:_,onChange:e=>v(Number(e.target.value))}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px]`,children:[_,` s`]}),(0,B.jsx)(`span`,{className:`text-[12px]`,children:`before injecting the skill`})]}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3 bg-linen rounded px-2 py-1.5`,children:[`will type: `,(0,B.jsx)(`b`,{className:`text-walnut`,children:i?.harnesses.find(e=>e.id===s)?.cmd}),` → wait `,_,` s → `,s===`claude`?`/color · `:``,(0,B.jsxs)(`b`,{className:`text-walnut`,children:[k,` --id=`,l||`…`,d?` --lane=${d}`:``,i?.room?` --room=${i.room}`:``]}),` → wait for register (≤ 90 s)`]}),C&&(0,B.jsx)(`div`,{className:`text-brick`,children:C}),D&&(0,B.jsxs)(`div`,{className:`p-2 rounded-kit border ${D.status===`ok`?`border-moss-line bg-moss-wash/50`:D.status===`failed`?`border-brick-line bg-brick-wash/50`:`border-amber-line bg-amber-wash/40`}`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px]`,children:[D.status===`running`?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-amber`,children:[(0,B.jsx)(Ma,{}),` `,(0,B.jsx)(G,{tone:`warn`,children:`running`})]}):(0,B.jsx)(G,{tone:D.status===`ok`?`ok`:`bad`,children:D.status}),` `,(0,B.jsx)(`b`,{children:D.label}),D.status===`running`&&(0,B.jsx)(`span`,{className:`ml-2 text-tan`,children:`live — you can close this; it keeps running (see Runs)`})]}),(0,B.jsxs)(`pre`,{className:`m-0 mt-1 font-mono text-[12px] whitespace-pre-wrap max-h-[30vh] overflow-auto`,children:[D.log.join(`
28
+ `);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{onClick:()=>l(!0),className:`w-full text-left rounded-[4px] overflow-hidden border border-sand bg-transparent p-0 cursor-pointer group ${n}`,title:`${e} · pane ${i?.pane??``} · click for the full view`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-[3px] bg-linen border-b border-sand`,children:[(0,B.jsx)(`span`,{className:`relative inline-block w-1.5 h-1.5 rounded-full ${i?.active?`bg-moss`:`bg-dust`}`,children:i?.active&&(0,B.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-moss animate-ping opacity-60`})}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-ink3 truncate`,children:r??e}),(0,B.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-tan`,children:i?i.active?`active`:`quiet ${Qu(i.paneActivity)}`:`…`})]}),(0,B.jsx)(`pre`,{className:`m-0 px-2 py-1 pane-dark font-mono text-[10.5px] leading-[1.35] whitespace-pre-wrap break-words max-h-[calc(1.35em*4+8px)] overflow-hidden group-hover:opacity-90`,style:{maxHeight:`calc(1.35em * ${t} + 8px)`},children:o?(0,B.jsx)(`span`,{className:`text-brick`,children:o}):i?i.ansi?uo(u(i.ansi)):u(i.text):`capturing…`})]}),c&&(0,B.jsx)(Yu,{agentId:e,onClose:()=>l(!1)})]})}function ed({id:e,prefix:t,size:n=`sm`,className:r=``,bare:i=!1,noDot:a=!1}){let o=(q(`/bus/agents`,2e4).data??[]).find(t=>t.agentId===e),[s,c]=(0,P.useState)(!1),[l,u]=(0,P.useState)(!1),d=(0,P.useRef)(null),f=()=>{d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>c(!0),250)},p=()=>{d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>c(!1),200)};(0,P.useEffect)(()=>()=>{d.current&&window.clearTimeout(d.current)},[]);let m=!!o?.pane;return(0,B.jsxs)(`span`,{className:`relative inline-flex ${r}`,onMouseEnter:f,onMouseLeave:p,children:[(0,B.jsxs)(`button`,{onClick:()=>m&&u(!0),className:i?`inline-flex items-center gap-1.5 font-mono font-semibold ${n===`sm`?`text-[12px]`:`text-[13px]`} border-0 bg-transparent p-0 text-walnut ${m?`cursor-pointer hover:text-ember-deep`:`cursor-default`}`:`inline-flex items-center gap-1.5 rounded-full border font-mono ${n===`sm`?`text-[11px] px-2 py-0.5`:`text-[12px] px-2.5 py-1`} ${m?`cursor-pointer border-dust bg-paper hover:border-ember`:`cursor-default border-sand bg-linen/60`} text-walnut`,title:m?`${e} · pane ${o.pane} · click to pop out`:`${e}${o?` · ${o.liveness}`:` · not on the bus`}`,children:[t&&(0,B.jsx)(`span`,{className:`text-tan`,children:t}),!a&&(0,B.jsx)(Mu,{id:e,role:o?.role,size:n===`sm`?14:18,state:o?.liveness??`dead`,active:o?.active}),(0,B.jsx)(`span`,{className:`truncate max-w-[220px]`,children:e}),o&&!o.transport&&o.liveness!==`dead`&&(0,B.jsx)(`span`,{className:`text-amber`,title:`not attached — DMs won't reach its pane`,children:`⚠`})]}),s&&m&&(0,B.jsx)(`span`,{className:`absolute left-0 top-[calc(100%+6px)] z-50 w-[420px] whitespace-normal text-left`,onMouseEnter:f,onMouseLeave:p,children:(0,B.jsx)($u,{agentId:e,lines:6,label:`${e} · ${o.role??``}`,className:`shadow-panel bg-paper`})}),l&&(0,B.jsx)(Yu,{agentId:e,onClose:()=>u(!1)})]})}var td=[{re:/coordinator/i,label:`coordinator`,dot:`#4A6A2C`,ring:`#B9CFA0`},{re:/aide|liaison|curator/i,label:`aide`,dot:`#C4587A`,ring:`#F0C2D2`},{re:/\bqa\b|quality/i,label:`qa`,dot:`#C88A1E`,ring:`#F0DFA6`},{re:/\bci\b/i,label:`ci`,dot:`#E8702A`,ring:`#F6C9A6`},{re:/audit/i,label:`audit`,dot:`#7A4A6A`,ring:`#DDBFD3`},{re:/automation/i,label:`automation`,dot:`#8A7660`,ring:`#D9CDBB`},{re:/human|david/i,label:`human`,dot:`#B7521A`,ring:`#F6C9A6`}],nd=e=>td.find(t=>t.re.test(e??``))?.dot??`#5C7A96`,rd=e=>td.find(t=>t.re.test(e??``))?.label??`worker`;function id(){let{projects:e,current:t}=za(),n=q(`/bus/agents`,15e3).data??[],r=e.find(e=>e.name===t)?.room,i=n.filter(e=>e.liveness!==`dead`&&![`groundwork-console`,`david`].includes(e.agentId)&&(e.project===t||r&&e.project===r)),a=n.filter(e=>e.liveness!==`dead`&&![`groundwork-console`,`david`].includes(e.agentId)&&!i.includes(e)),o=e=>[`aide`,`coordinator`,`qa`,`ci`,`worker`,`audit`].indexOf(rd(e.role))+1||9,s=[...i].sort((e,t)=>o(e)-o(t)||e.agentId.localeCompare(t.agentId)),[c,l]=(0,P.useState)(!1);return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-1.5 border-b border-sand bg-paper/70 min-h-[34px] whitespace-nowrap overflow-x-auto [scrollbar-width:none]`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan shrink-0`,children:[`online · `,t||`—`]}),s.length===0&&(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`no agents for this project`}),s.map(e=>(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full border border-sand bg-paper`,style:{borderColor:nd(e.role)+`66`},title:`${e.agentId} · ${rd(e.role)}${e.pane?` · ${e.pane}`:``}`,children:[(0,B.jsx)(Mu,{id:e.agentId,role:e.role,size:16,state:e.liveness,active:e.active}),(0,B.jsx)(ed,{id:e.agentId,bare:!0,noDot:!0,size:`sm`}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.06em]`,style:{color:nd(e.role)},children:rd(e.role)})]},e.agentId)),c&&a.map(e=>(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full border border-dashed border-sand bg-cream/60`,title:`${e.agentId} · ${rd(e.role)} · ${e.project??`?`}`,children:[(0,B.jsx)(Mu,{id:e.agentId,role:e.role,size:16,state:e.liveness,active:e.active}),(0,B.jsx)(ed,{id:e.agentId,bare:!0,noDot:!0,size:`sm`}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-tan`,children:e.project})]},e.agentId)),a.length>0&&(0,B.jsx)(`button`,{onClick:()=>l(e=>!e),"aria-pressed":c,className:`ml-auto font-mono text-[11px] text-ink3 shrink-0 border-0 bg-transparent cursor-pointer hover:text-umber`,title:c?`show only this project`:a.map(e=>e.agentId).join(`, `),children:c?`only this project`:`+${a.length} elsewhere`}),(0,B.jsx)(`span`,{className:`ml-3 font-mono text-[10px] text-tan shrink-0 hidden xl:inline-flex items-center gap-2`,children:[[`coordinator`,`#4A6A2C`],[`aide`,`#C4587A`],[`qa`,`#C88A1E`],[`ci`,`#E8702A`],[`worker`,`#5C7A96`]].map(([e,t])=>(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full`,style:{background:t}}),e]},e))})]})}var ad=(e,t)=>window.dispatchEvent(new CustomEvent(`groundwork-console:summon`,{detail:{agentId:e,answers:t?.answers}})),od=e=>`groundwork-console.summon.${e}`,sd=e=>`groundwork-console.summon.seen.${e}`;function cd(e){let t=rr(),n=t.pathname.match(/^\/docs\/(.+)$/),r=new URLSearchParams(t.search);if(n){let t=decodeURIComponent(n[1]),i=r.get(`line`);return t.startsWith(`kb:`)?{label:`knowledge/${t.slice(3)}${i?`:${i}`:``}`,cite:`groundwork-knowledge/${t.slice(3)}${i?`:${i}`:``}`}:{label:`${t}${i?`:${i}`:``}`,cite:`${e}/docs/${t}${i?`:${i}`:``}`}}let i=t.pathname===`/`?`home`:t.pathname.slice(1).split(`/`)[0];return{label:i,cite:`groundwork-console /${i}${e?` · ${e}`:``}`}}function ld(){let{current:e}=za(),t=q(`/bus/agents`,2e4).data??[],n=q(e?`/projects/${e}/agents`:null,3e4).data,r=t.filter(e=>e.liveness!==`dead`&&e.agentId!==`david`&&e.agentId!==`groundwork-console`),[i,a]=(0,P.useState)(()=>e?localStorage.getItem(od(e)):null);(0,P.useEffect)(()=>{a(e?localStorage.getItem(od(e)):null)},[e]);let o=(i&&t.some(e=>e.agentId===i)?i:null)??n?.aide??n?.coordinator??r[0]?.agentId??null,s=t.find(e=>e.agentId===o),[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(!1),f=t=>{a(t),e&&localStorage.setItem(od(e),t),d(!1),l(!0)},p=q(o?`/bus/dm/${encodeURIComponent(o)}?limit=80`:null,c?4e3:2e4).data,m=q(`/bus/inbox?limit=100`,2e4).data?.decisions??{},[h,g]=(0,P.useState)(0);(0,P.useEffect)(()=>{o&&g(Number(localStorage.getItem(sd(o))??0))},[o]),(0,P.useEffect)(()=>{c&&o&&p&&(localStorage.setItem(sd(o),String(p.lastFromAgent)),g(p.lastFromAgent))},[c,o,p]);let _=!!p&&p.lastFromAgent>h;(0,P.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(d(!1),l(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[v,y]=(0,P.useState)([]);if((0,P.useEffect)(()=>{let e=e=>{let t=e.detail;y(t?.answers??[]),t?.agentId?f(t.agentId):(l(!1),d(!0))};return window.addEventListener(`groundwork-console:summon`,e),()=>window.removeEventListener(`groundwork-console:summon`,e)}),!o)return null;let b=r.length,x=r,S=e=>{let t=(b===1?.5:e/(b-1))*(Math.PI/2);return{x:-Math.sin(t)*96,y:-Math.cos(t)*96}};return(0,B.jsxs)(B.Fragment,{children:[c&&(0,B.jsx)(fd,{agentId:o,me:s,project:e,thread:p??void 0,answers:v,onAnswered:()=>y([]),onClose:()=>l(!1),onSwitch:()=>{d(!0)}}),(0,B.jsxs)(`div`,{className:`fixed right-5 bottom-5 z-[55]`,style:{width:52,height:52},children:[u&&(0,B.jsxs)(`div`,{className:`absolute inset-0`,"aria-label":`pick an agent`,children:[x.map((e,t)=>{let n=S(t);return(0,B.jsxs)(`button`,{onClick:()=>f(e.agentId),title:`${e.agentId} · ${rd(e.role)}`,className:`absolute rounded-full border-2 bg-paper shadow-panel cursor-pointer p-[3px] transition-transform hover:scale-110`,style:{left:26+n.x-17,top:26+n.y-17,borderColor:nd(e.role),width:34,height:34,animation:`summon-pop .18s ease-out ${t*30}ms both`},children:[(0,B.jsx)(Mu,{id:e.agentId,role:e.role,size:26,state:e.liveness,active:e.active}),m[e.agentId]?(0,B.jsx)(ud,{n:m[e.agentId],small:!0}):null]},e.agentId)}),x.length===0&&(0,B.jsx)(`span`,{className:`absolute right-0 bottom-14 whitespace-nowrap font-mono text-[11px] text-tan bg-paper border border-sand rounded-kit px-2 py-1`,children:`no live agents`})]}),(0,B.jsxs)(`button`,{onClick:()=>u?d(!1):l(e=>!e),title:`${o} · ${rd(s?.role)} — click to chat`,className:`absolute inset-0 rounded-full border-2 bg-paper shadow-panel cursor-pointer p-1 hover:scale-105 transition-transform`,style:{borderColor:nd(s?.role)},children:[(0,B.jsx)(Mu,{id:o,role:s?.role,size:40,state:s?.liveness??`dead`,active:s?.active}),m[o]?(0,B.jsx)(ud,{n:m[o]}):_&&(0,B.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 w-3 h-3 rounded-full bg-ember border-2 border-paper`,title:`new message`})]}),(0,B.jsx)(`button`,{onClick:()=>d(e=>!e),"aria-pressed":u,title:`pick another agent`,className:`absolute -left-2 -top-2 w-6 h-6 rounded-full border border-dust shadow-panel cursor-pointer text-[13px] leading-none flex items-center justify-center ${u?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:u?`×`:`+`})]}),(0,B.jsx)(`style`,{children:`.summon-dots{display:inline-flex;gap:3px}.summon-dots i{width:5px;height:5px;border-radius:50%;background:currentColor;opacity:.25;animation:summon-dot 1.2s infinite}.summon-dots i:nth-child(2){animation-delay:.2s}.summon-dots i:nth-child(3){animation-delay:.4s}@keyframes summon-dot{0%,80%,100%{opacity:.25}40%{opacity:1}}@keyframes summon-pop{from{transform:scale(.4);opacity:0}to{transform:scale(1);opacity:1}}@keyframes summon-pulse{0%,100%{box-shadow:0 0 0 0 rgba(200,120,42,.55)}50%{box-shadow:0 0 0 6px rgba(200,120,42,0)}}`})]})}function ud({n:e,small:t=!1}){return(0,B.jsx)(`span`,{className:`absolute -top-1 -right-1 rounded-full bg-ember text-paper border-2 border-paper font-mono font-bold flex items-center justify-center leading-none ${t?`w-4 h-4 text-[9px]`:`w-5 h-5 text-[10px]`}`,title:`${e} decision${e===1?``:`s`} waiting on you`,style:{animation:`summon-pulse 1.6s ease-in-out infinite`},children:`★`})}var dd=e=>{let t=Math.round(e/1e3);return t<60?`${t} s`:t<3600?`${Math.floor(t/60)} min`:`${Math.floor(t/3600)} h`};function fd({agentId:e,me:t,project:n,thread:r,answers:i=[],onAnswered:a,onClose:o,onSwitch:s}){let c=q(`/admin/bus-writes`,1e4).data?.enabled??!1,l=cd(n),[u,d]=(0,P.useState)(!0),[f,p]=(0,P.useState)(``),[m,h]=(0,P.useState)(null),[g,_]=(0,P.useState)(!1),[v,y]=(0,P.useState)(()=>localStorage.getItem(`groundwork-console.summon.max`)===`1`),b=()=>y(e=>(localStorage.setItem(`groundwork-console.summon.max`,e?`0`:`1`),!e)),x=Gu(),S=(0,P.useRef)(null),[C,w]=(0,P.useState)([]),T=r?.messages??[],E=C.filter(e=>!T.some(t=>t.from===`david`&&Number(t.ts??0)>=Number(e.ts??0)-2e3&&(t.text??``)===(e.text??``))),D=[...T,...E],[O,k]=(0,P.useState)(0);(0,P.useEffect)(()=>{let e=setInterval(()=>k(e=>e+1),1e3);return()=>clearInterval(e)},[]);let A=(q(`/bus/agents`,4e3).data??[]).find(t=>t.agentId===e)??t,j=A?.paneActivity?Date.now()-A.paneActivity:1/0,M=j<2e4,N=([...D].reverse().find(e=>e.from===`david`)?.ts??0)>([...D].reverse().find(e=>e.from!==`david`)?.ts??0);(0,P.useEffect)(()=>{S.current&&(S.current.scrollTop=S.current.scrollHeight)},[D.length,M,N]);let ee=async()=>{if(!x.hasContent(f))return;h(`sending`);let t=x.withRefs(f.trim()),n=u?`${t}\n(context: ${l.cite})`:t,r={id:`local-${Date.now()}`,ts:Date.now(),from:`david`,to:e,text:n,prefix:null,pending:!0};w(e=>[...e,r]),p(``),x.clear();try{let t=await Fa(`/actions/send`,{as:`david`,to:e,text:n,answers:i.length?i:void 0});if(t.status===`ok`)h(null),a?.();else{let e=t.error??t.log?.slice(-1)[0]??`failed`;h(e),w(t=>t.map(t=>t.id===r.id?{...t,failed:e}:t))}}catch(e){let t=e.message;h(t),w(e=>e.map(e=>e.id===r.id?{...e,failed:t}:e))}},F=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``,I=(0,P.useMemo)(()=>D,[D]);return(0,B.jsxs)(B.Fragment,{children:[g&&(0,B.jsx)(Yu,{agentId:e,onClose:()=>_(!1)}),(0,B.jsxs)(`div`,{className:`fixed z-[54] bg-paper border border-sand rounded-kit shadow-panel grid grid-rows-[auto_minmax(0,1fr)_auto] whitespace-normal text-left transition-[width,height] duration-150 ${v?`right-5 bottom-[84px] w-[min(1100px,calc(100vw-40px))] h-[calc(100vh-110px)]`:`right-5 bottom-[84px] w-[min(400px,calc(100vw-40px))] h-[min(560px,calc(100vh-140px))]`}`,style:{borderTop:`3px solid ${nd(t?.role)}`},children:[(0,B.jsxs)(`div`,{className:`px-3 py-2 border-b border-sand flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(Mu,{id:e,role:t?.role,size:22,state:t?.liveness??`dead`,active:t?.active}),(0,B.jsx)(`span`,{className:`font-display font-bold text-[14px] text-umber truncate`,children:e}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.06em]`,style:{color:nd(t?.role)},children:rd(t?.role)}),t?(0,B.jsx)(G,{tone:t.liveness===`live`?`ok`:t.liveness===`idle`?`warn`:`bad`,children:t.active?`active`:t.liveness}):(0,B.jsx)(G,{tone:`bad`,children:`offline`}),(0,B.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[t?.pane&&(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>_(!0),title:`open its pane`,children:`pane`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:s,title:`summon another agent`,children:`switch`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:b,title:v?`restore`:`maximize`,children:v?`⇲`:`⇱`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:o,children:`✕`})]})]}),(0,B.jsxs)(`div`,{ref:S,className:`min-h-0 overflow-auto overscroll-contain px-3 py-2 grid gap-1.5 content-start bg-cream/40`,children:[!r&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`loading thread…`}),r&&I.length===0&&(0,B.jsxs)(`span`,{className:`text-[12px] text-umber`,children:[`No DMs with `,e,` yet. Say what you need — it lands in its pane via tmux-push.`]}),I.map((e,t)=>{let n=e.from===`david`,r=String(e.text??``),i=e.prefix?r.replace(RegExp(`^${e.prefix}:?\\s*`),``):r;return(0,B.jsxs)(`div`,{className:`${e.pending?`opacity-70`:``} ${v?`max-w-[70%]`:`max-w-[88%]`} rounded-kit px-2.5 py-1.5 text-[12.5px] leading-snug whitespace-pre-wrap break-words border ${n?`justify-self-end bg-paper border-sand`:`justify-self-start bg-linen/70 border-sand/70`}`,children:[e.prefix&&(0,B.jsx)(Da,{prefix:e.prefix}),(0,B.jsx)(qu,{text:i}),(0,B.jsx)(`div`,{className:`font-mono text-[10px] mt-0.5 ${n?`text-right`:``} ${e.failed?`text-brick`:`text-tan`}`,children:e.failed?`not sent · ${e.failed}`:e.pending?`sending…`:F(e.ts)})]},e.id??t)}),(M||N)&&(0,B.jsx)(`div`,{className:`justify-self-start inline-flex items-center gap-2 px-2.5 py-1.5 rounded-kit border border-sand/70 bg-linen/50 font-mono text-[11px] text-ink3`,title:A?.paneActivity?`last pane output ${Math.round(j/1e3)} s ago`:`no pane activity`,children:M?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`summon-dots`,"aria-hidden":!0,children:[(0,B.jsx)(`i`,{}),(0,B.jsx)(`i`,{}),(0,B.jsx)(`i`,{})]}),(0,B.jsxs)(`span`,{children:[e.split(`-`)[0],` is working`]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-tan`}),(0,B.jsxs)(`span`,{children:[`delivered · quiet for `,j===1/0?`a while`:dd(j)]})]})})]}),(0,B.jsxs)(`div`,{className:`px-3 py-2 border-t border-sand grid gap-1.5`,children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-1.5 font-mono text-[11px] text-ink3 min-w-0`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),(0,B.jsx)(`span`,{className:`shrink-0`,children:`context:`}),(0,B.jsx)(`span`,{className:`truncate text-umber`,title:l.cite,children:l.label})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-1.5 items-center`,children:[(0,B.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&c&&(e.preventDefault(),ee())},onPaste:x.onPaste,onDrop:x.onDrop,onDragOver:x.onDragOver,disabled:!c,rows:v?4:2,placeholder:c?`DM ${e} as david — Enter to send, ⇧Enter newline, paste images`:`bus writes are off (header badge)`,className:`text-[13px] px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut resize-none min-w-0`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:ee,disabled:!c||!x.hasContent(f)||x.busy||m===`sending`,children:m===`sending`?`…`:`Send`})]}),(0,B.jsx)(Ku,{a:x}),m&&m!==`sending`&&(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-brick`,children:m})]})]})]})}var pd={h:`/`,b:`/board`,m:`/monitor`,u:`/bus`,d:`/docs`,o:`/ops`},md=e=>{let t=e;return!!t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)};function hd(){let e=ar(),[t,n]=(0,P.useState)(!1);return(0,P.useEffect)(()=>{let t=0,r=r=>{if(!(r.metaKey||r.ctrlKey||r.altKey||md(r.target))){if(r.key===`Escape`){n(!1);return}if(r.key===`?`){n(e=>!e);return}if(r.key===`/`){r.preventDefault(),ad(``);return}if(r.key===`g`){t=Date.now();return}Date.now()-t<900&&pd[r.key]&&(r.preventDefault(),e(pd[r.key]),t=0)}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e]),t?(0,B.jsx)(`div`,{className:`fixed inset-0 z-[70] bg-walnut/30 flex items-center justify-center`,onMouseDown:()=>n(!1),children:(0,B.jsxs)(`div`,{className:`bg-paper border border-sand rounded-kit shadow-panel p-4 grid gap-2 min-w-[320px]`,onMouseDown:e=>e.stopPropagation(),children:[(0,B.jsx)(`div`,{className:`font-display font-bold text-[15px] text-umber`,children:`Keyboard`}),[[`/`,`summon an agent (picker)`],[`g h`,`Home`],[`g b`,`Board`],[`g m`,`Monitor`],[`g u`,`Bus`],[`g d`,`Docs`],[`g o`,`Ops`],[`Esc`,`close drawer / picker / this`],[`?`,`toggle this list`]].map(([e,t])=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[64px_1fr] gap-3 items-baseline text-[13px]`,children:[(0,B.jsx)(`kbd`,{className:`font-mono text-[12px] px-1.5 py-0.5 border border-dust rounded bg-cream text-walnut justify-self-start`,children:e}),(0,B.jsx)(`span`,{className:`text-umber`,children:t})]},e)),(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan mt-1`,children:`In the Summon drawer: Enter sends · ⇧Enter newline · paste images.`})]})}):null}var gd=`/api`;function _d({children:e}){let[t,n]=(0,P.useState)(`checking`),[r,i]=(0,P.useState)(``),[a,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(!1),l=async()=>{try{let e=await(await fetch(`${gd}/auth/status`)).json();n(e.authed?`in`:`out`)}catch{n(`offline`)}};(0,P.useEffect)(()=>{l()},[]),(0,P.useEffect)(()=>{t!==`in`&&fetch(`${gd}/health`).then(e=>e.json()).then(e=>{document.title=e.hostname?`Sign in · ${e.hostname}`:`Sign in · Groundwork Console`}).catch(()=>{document.title=`Sign in · Groundwork Console`})},[t]),(0,P.useEffect)(()=>{let e=()=>n(`out`);return window.addEventListener(`groundwork-console:unauthorized`,e),()=>window.removeEventListener(`groundwork-console:unauthorized`,e)},[]);let u=async()=>{c(!0),o(null);try{let e=await fetch(`${gd}/auth/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:r})}),t=await e.json();if(!e.ok)throw Error(t.error??`${e.status}`);i(``),n(`in`)}catch(e){o(e.message)}finally{c(!1)}};return t===`in`?(0,B.jsx)(B.Fragment,{children:e}):t===`checking`?(0,B.jsx)(`div`,{className:`min-h-screen grid place-items-center font-mono text-[12px] text-tan`,children:`checking session…`}):(0,B.jsx)(`div`,{className:`min-h-screen grid place-items-center bg-cream p-6`,children:(0,B.jsxs)(`div`,{className:`w-[380px] bg-paper border border-sand rounded-kit shadow-panel`,children:[(0,B.jsxs)(`div`,{className:`px-5 py-4 border-b border-sand flex items-center gap-2 font-display font-bold text-[18px] text-ember`,children:[(0,B.jsx)(Na,{}),` Groundwork Console`]}),(0,B.jsx)(`div`,{className:`p-5 grid gap-3 text-[13px]`,children:t===`offline`?(0,B.jsxs)(`div`,{className:`text-brick`,children:[`API unreachable — start it with `,(0,B.jsx)(`code`,{children:`pnpm dev:api`}),`, then `,(0,B.jsx)(`button`,{className:`underline border-0 bg-transparent p-0 cursor-pointer text-ember-deep`,onClick:l,children:`retry`}),`.`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`text-umber`,children:[`This console can write to your bus and docs. Enter the console token — it's in `,(0,B.jsx)(`code`,{className:`font-mono text-[12px]`,children:`~/.groundwork-console/token`}),` on the machine running the API (or `,(0,B.jsx)(`code`,{className:`font-mono text-[12px]`,children:`GROUNDWORK_CONSOLE_TOKEN`}),`).`]}),(0,B.jsx)(`input`,{type:`password`,autoFocus:!0,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r&&u()},placeholder:`token`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`}),a&&(0,B.jsx)(`div`,{className:`text-brick`,children:a}),(0,B.jsx)(K,{tone:`primary`,onClick:u,disabled:!r||s,children:s?`Signing in…`:`Sign in`}),(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`Cookie lasts 30 days on this browser. Single shared token — no accounts.`})]})})]})})}var vd=[{to:`/`,label:`Home`,icon:`home`},{to:`/board`,label:`Board`,icon:`board`},{to:`/bus`,label:`Bus`,icon:`bus`},{to:`/monitor`,label:`Monitor`,icon:`monitor`},{to:`/docs`,label:`Docs`,icon:`docs`},{to:`/ops`,label:`Ops`,icon:`fleet`}];function $(){let{error:e}=za(),{running:t}=Ha(),n=q(`/bus/unread`,3e4).data?.inbox??0,r=q(`/kit`).data,i=q(`/health`,6e4).data?.hostname,a=rr();(0,P.useEffect)(()=>{let e=a.pathname===`/`?``:a.pathname.split(`/`)[1],t=vd.find(t=>t.to===`/`?e===``:t.to===`/${e}`)?.label??(e?e[0].toUpperCase()+e.slice(1):`Home`);document.title=i?`${t} · ${i}`:t},[a.pathname,i]);let o=r?.packages?`${r.name} ${r.kitVersion} · seam ${r.packages.seam?.version} · mcp ${r.packages.mcp?.version}`:`kit · offline`;return(0,B.jsx)(_d,{children:(0,B.jsx)(Du,{children:(0,B.jsxs)(`div`,{className:`grid grid-rows-[48px_auto_1fr] min-h-screen`,children:[(0,B.jsxs)(`header`,{className:`grid grid-cols-[auto_auto_1fr] items-center gap-4 px-4 border-b border-sand bg-cream min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 font-display font-bold text-[16px] text-ember whitespace-nowrap`,title:o,children:[(0,B.jsx)(Na,{}),` Groundwork Console`]}),(0,B.jsx)(`nav`,{className:`flex gap-0.5 whitespace-nowrap`,children:vd.map(e=>(0,B.jsxs)(ji,{to:e.to===`/bus`&&n>0?`/bus?view=inbox`:e.to,end:e.to===`/`,className:({isActive:e})=>`inline-flex items-center gap-1.5 px-3 py-2 rounded-kit font-medium ${e?`bg-paper text-walnut shadow-[inset_0_0_0_1px_var(--color-sand)]`:`text-umber hover:no-underline hover:bg-linen`}`,children:[(0,B.jsx)(`span`,{className:`text-tan`,children:Ca[e.icon]({size:16})}),(0,B.jsx)(`span`,{className:`hidden xl:inline`,children:e.label}),e.to===`/ops`&&t>0?(0,B.jsxs)(`span`,{className:`ml-1.5 inline-flex items-center gap-1 text-amber`,children:[(0,B.jsx)(Ma,{size:12}),(0,B.jsx)(G,{tone:`warn`,children:t})]}):null,e.to===`/bus`&&n>0?(0,B.jsx)(`span`,{className:`ml-1.5 inline-flex`,title:`${n} unread DM(s) to david`,children:(0,B.jsx)(G,{tone:`david`,children:n})}):null,e.badge?(0,B.jsx)(`span`,{className:`ml-1.5 inline-flex`,children:(0,B.jsx)(G,{tone:`david`,children:e.badge})}):null]},e.to))}),(0,B.jsxs)(`div`,{className:`flex gap-0.5 items-center justify-end min-w-0 whitespace-nowrap`,children:[e&&(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-brick mr-2`,title:e,children:`api offline`}),(0,B.jsx)(Ga,{}),(0,B.jsx)(Ya,{}),(0,B.jsx)(Ja,{}),(0,B.jsx)(J,{}),(0,B.jsx)(`button`,{onClick:async()=>{await fetch(`/api/auth/logout`,{method:`POST`}),window.dispatchEvent(new Event(`groundwork-console:unauthorized`))},className:`ml-1 font-mono text-[11px] text-tan border-0 bg-transparent cursor-pointer hover:text-umber`,title:`sign out (clears the session cookie)`,children:`⎋`})]})]}),(0,B.jsx)(id,{}),(0,B.jsx)(Rr,{}),(0,B.jsx)(ao,{}),(0,B.jsx)(ld,{}),(0,B.jsx)(hd,{})]})})})}function yd(e,t=Date.now()){let n=Math.max(0,(t-e)/1e3)/60,r=n/60,i=r/24;if(n<1)return`just now`;if(r<1)return`${Math.floor(n)} min ago`;if(i<1)return`${Math.floor(r)} h ago`;if(i<2)return`yesterday`;if(i<7)return`${Math.floor(i)} days ago`;let a=i/7;if(a<2)return`last week`;if(i<30)return`${Math.floor(a)} weeks ago`;let o=i/30;return o<2?`last month`:i<365?`${Math.floor(o)} months ago`:i<730?`last year`:`${Math.floor(i/365)} years ago`}function bd(e,t=Date.now()){let n=(t-e)/864e5;return n<1?`text-tan`:n<7?`text-amber`:`text-brick font-semibold`}var xd=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),Sd=e=>!!e&&Ta.includes(e),Cd={"state.fact.stale":`warn`,"state.board.malformed":`bad`,"state.decision.open":`david`,"state.phase.active":`neutral`,"phase.completed":`ok`,"phase.started":`ok`,"phase.progress":`neutral`,"done.appended":`ok`,"queue.item.added":`neutral`,"queue.item.closed":`ok`,"fact.stale":`warn`,"board.malformed":`bad`,"decision.posted":`david`};function wd(){let{data:e,refresh:t}=q(`/events?limit=40`,15e3),[n,r]=(0,P.useState)(!1),[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),c=async(e,n)=>{s(!0);try{await Fa(`/events/config`,{rule:e,enabled:n}),t()}finally{s(!1)}},l=async e=>{s(!0);try{await Fa(`/events/config`,{dryRun:e,confirm:e?void 0:i}),t(),r(!1),a(``)}finally{s(!1)}},[u,d]=(0,P.useState)([]);(0,P.useEffect)(()=>{let e=new EventSource(`/api/events/stream`);return e.onmessage=e=>{let t=JSON.parse(e.data);t.type!==`hello`&&d(e=>{let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=e.slice();return r[n]=t,r}return[t,...e].slice(0,40)})},()=>e.close()},[]);let f=[...u,...(e?.recent??[]).filter(e=>!u.some(t=>t.id===e.id)).slice().reverse()].slice(0,40),p=e?.config;return(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Events`,icon:`health`,path:p?`${p.identity.displayName??p.identity.agentId} · ${p.rules.filter(e=>e.enabled).length}/${p.rules.length} rules enabled · dedupe ${p.limits?.dedupeTtlHours??72} h · max ${p.limits?.maxPerRulePerProjectPerHour??3}/h`:`detector`,children:[p&&(p.live?(0,B.jsx)(G,{tone:`bad`,children:`LIVE — sending`}):p.dryRun?(0,B.jsx)(G,{tone:`outline`,children:`dry-run`}):(0,B.jsx)(G,{tone:`warn`,children:`armed · bus writes off`})),p&&(p.dryRun?(0,B.jsx)(K,{size:`sm`,onClick:()=>r(!0),disabled:o,children:`Go live…`}):(0,B.jsx)(K,{size:`sm`,onClick:()=>l(!0),disabled:o,children:`Back to dry-run`}))]}),p&&(0,B.jsxs)(`div`,{className:`px-3 py-2 border-b border-sand grid gap-1`,children:[p.rules.map(e=>(0,B.jsxs)(`label`,{className:`grid grid-cols-[auto_1fr] gap-2 items-baseline font-mono text-[12px] text-ink3 cursor-pointer`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!e.enabled,disabled:o||e.action.type===`none`,onChange:t=>c(e.id,t.target.checked),title:e.action.type===`none`?`informational rule — nothing to send`:`enable this rule`}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`text-walnut`,children:e.on}),` → `,e.action.type===`none`?(0,B.jsx)(`span`,{className:`text-tan`,children:e.action.note}):(0,B.jsxs)(B.Fragment,{children:[e.action.to?e.action.to:`#${e.action.room}`,` · `,Sd(e.action.prefix)&&(0,B.jsx)(Da,{prefix:e.action.prefix}),(0,B.jsx)(`span`,{className:`text-umber`,children:e.action.text})]})]})]},e.id)),(0,B.jsxs)(`div`,{className:`text-[11px] font-mono text-tan`,children:[`a rule sends only when: bus writes ON (header) · dry-run OFF · rule enabled · not a duplicate (key, `,p.limits?.dedupeTtlHours??72,` h) · under the rate limit · a live coordinator exists for the project. Baseline state.* events never trigger rules.`]})]}),n&&(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[12vh]`,onMouseDown:e=>{e.target===e.currentTarget&&r(!1)},children:(0,B.jsxs)(`div`,{className:`w-[520px] bg-paper border border-brick rounded-kit shadow-panel`,children:[(0,B.jsx)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] text-brick`,children:`Turn dry-run off`}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px] text-umber`,children:[(0,B.jsxs)(`div`,{children:[`Enabled rules will really `,(0,B.jsx)(`code`,{children:`send_message`}),` as `,(0,B.jsx)(`b`,{className:`text-walnut`,children:`groundwork-console`}),` (automation) whenever bus writes are on. Dedupe + rate limit apply; every send is a Run. Persisted in `,(0,B.jsx)(`code`,{children:`groundwork-console.rules.json`}),`.`]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Type LIVE to confirm`}),(0,B.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]})]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:()=>r(!1),children:`Cancel`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>l(!1),disabled:i!==`LIVE`||o,children:`Go live`})]})]})}),f.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`Watching seam files + rooms every 15 s. Nothing dirty at baseline and nothing changed since.`}),f.map(e=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[var(--spacing-gutter)_1fr] border-b border-sand last:border-b-0`,children:[(0,B.jsx)(`div`,{className:`py-2.5 flex justify-center font-mono text-[12px] text-tan border-r border-sand`,children:`⚡`}),(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-baseline mb-0.5 flex-wrap`,children:[(0,B.jsx)(G,{tone:Cd[e.type]??`neutral`,children:e.type}),e.data.baseline?(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`baseline · no action`}):null,(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-umber`,children:e.project}),(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-ink3`,children:xd(e.ts)})]}),(0,B.jsx)(`div`,{className:`font-mono text-[12px] text-umber break-all`,children:Object.entries(e.data).filter(([e])=>![`project`,`room`].includes(e)).map(([e,t])=>`${e}=${String(t)}`).join(` · `)}),e.actions.filter(e=>e.type!==`none`).map(e=>(0,B.jsxs)(`div`,{className:`mt-1 text-[13px] pl-2 border-l-2 ${e.sent?`border-leaf`:e.skipped?`border-amber`:`border-dust`}`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.06em] mr-1.5 ${e.sent?`text-leaf`:e.skipped?`text-amber`:`text-tan`}`,children:e.sent?`sent`:e.skipped?`skipped · ${e.skipped}`:e.dryRun?`would send`:`sending`}),Sd(e.prefix)&&(0,B.jsx)(Da,{prefix:e.prefix}),(0,B.jsx)(`span`,{className:`text-walnut`,children:e.text}),` `,(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,children:[`→ `,e.to??`#${e.room}`]}),e.runId&&(0,B.jsx)(`span`,{className:`ml-2 font-mono text-[11px] text-tan`,children:e.runId})]},e.ruleId))]})]},e.id))]})}function Td(){let{data:e}=q(`/events?limit=40`,3e4),t=e?.config;if(!t)return null;let n=t.rules.filter(e=>e.enabled).length,r=Date.now()-864e5,i=(e?.recent??[]).filter(e=>e.ts>r).flatMap(e=>e.actions).filter(e=>e.sent).length;return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[11px] text-ink3 px-1`,children:[(0,B.jsx)(`span`,{className:`uppercase tracking-[.1em] text-tan`,children:`events`}),t.live?(0,B.jsx)(G,{tone:`bad`,children:`live`}):t.dryRun?(0,B.jsx)(G,{tone:`outline`,children:`dry-run`}):(0,B.jsx)(G,{tone:`warn`,children:`armed · bus writes off`}),(0,B.jsxs)(`span`,{children:[n,`/`,t.rules.length,` rules on · `,i,` sent in 24 h`]}),(0,B.jsx)(V,{to:`/ops/events`,className:`ml-auto text-ember-deep`,children:`Ops → Events`})]})}var Ed={complete:{label:`complete`,tone:`ok`,dot:`bg-leaf border-leaf`,ring:`text-leaf`,hint:`all tasks ticked`},ongoing:{label:`ongoing`,tone:`david`,dot:`bg-ember border-ember`,ring:`text-ember`,hint:`streams in flight or tasks ticked`},planned:{label:`planned`,tone:`neutral`,dot:`bg-paper border-umber`,ring:`text-umber`,hint:`tasks written, none started`},pending:{label:`pending`,tone:`outline`,dot:`bg-paper border-dust border-dashed`,ring:`text-tan`,hint:`no PHASE*_TASKS.md yet — run /plan-phase`}};function Dd({pct:e,cls:t,size:n=44}){let r=(n-6)/2,i=2*Math.PI*r;return(0,B.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:t,"aria-hidden":!0,children:[(0,B.jsx)(`circle`,{cx:n/2,cy:n/2,r,fill:`none`,stroke:`currentColor`,strokeOpacity:`.18`,strokeWidth:`4`}),(0,B.jsx)(`circle`,{cx:n/2,cy:n/2,r,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${e/100*i} ${i}`,transform:`rotate(-90 ${n/2} ${n/2})`})]})}function Od({project:e,phases:t,canWrite:n,prd:r}){let i=q(`/projects/${e}/agents`,3e4).data,[a,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(null),d=`groundwork-console.roadmap.last.${e}`,[f,p]=(0,P.useState)(()=>{try{return JSON.parse(localStorage.getItem(d)??`{}`)}catch{return{}}}),m=(e,t,n)=>p(r=>{let i={...r,[e]:{verb:t,to:n,ts:Date.now()}};return localStorage.setItem(d,JSON.stringify(i)),i}),h=e=>{let t=Math.floor((Date.now()-e)/6e4);return t<1?`just now`:t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`},g=async(t,r)=>{if(!n){c(`bus writes are off — click the header badge (read-only · v0.1) and type ENABLE, then retry`);return}if(r===`plan`&&!i?.aide){c(`no live aide for ${e} — start one (coord-aide) in #room, or DM the coordinator from Bus`);return}if(r!==`plan`&&!i?.coordinator){c(`no live coordinator for ${e}`);return}o(`${t.id}:${r}`),c(null);try{let n=await Fa(`/actions/phase/${e}/${t.id}/${r}`),i=n.args?.to??``;n.status===`ok`&&m(t.id,r,i),c(n.status===`ok`?`sent → ${i}`:n.error??n.log?.slice(-1)[0]??`failed`)}catch(e){c(e.message)}finally{o(null)}},_=async t=>{if(!n){c(`bus writes are off — switch them on in the header, then retry`);return}o(t),c(null);try{let n=await Fa(`/actions/project/${e}/${t}`),r=n.args?.to??``;c(n.status===`ok`?`sent → ${r} — continue in its thread`:n.error??n.log?.slice(-1)[0]??`failed`),n.status===`ok`&&r&&ad(r)}catch(e){c(e.message)}finally{o(null)}},v=t.filter(e=>e.state===`complete`).length,y=t.find(e=>e.state===`ongoing`)??t.find(e=>e.state===`planned`)??t.find(e=>e.state===`pending`);return(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Roadmap`,icon:`phases`,eyebrow:`PRODUCTION_ROADMAP · phases/`,path:`${v}/${t.length} complete${y?` · next: ${y.title}`:``}`,children:(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 flex-wrap`,children:[i?.aide?(0,B.jsx)(ed,{id:i.aide,prefix:`aide`}):(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`no live aide`}),i?.coordinator?(0,B.jsx)(ed,{id:i.coordinator,prefix:`coord`}):(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`no live coordinator`})]})}),t.length===0&&(0,B.jsxs)(`div`,{className:`px-3 py-3 grid gap-2 text-[13px]`,children:[r==null?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`text-walnut`,children:[`No PRD yet. The roadmap starts from `,(0,B.jsx)(`code`,{children:`docs/PRD.md`}),` — write it with your aide (it runs `,(0,B.jsx)(`code`,{children:`/create-prd`}),` and asks you what it needs).`]}),(0,B.jsxs)(`div`,{className:`flex gap-2 items-center flex-wrap`,children:[(0,B.jsx)(K,{size:`sm`,tone:`primary`,disabled:!!a||!i?.aide,title:i?.aide?`DM ${i.aide}: run /create-prd with me`:`no live aide — spawn one under Ops → Fleets`,onClick:()=>_(`create-prd`),children:a===`create-prd`?(0,B.jsx)(Ma,{size:12}):`Write the PRD with the aide`}),i?.aide&&(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>ad(i.aide),children:`Open the aide's thread`}),!i?.aide&&(0,B.jsx)(V,{to:`/ops/fleets`,className:`hover:no-underline`,children:(0,B.jsx)(K,{size:`sm`,children:`Spawn aide`})})]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`text-walnut`,children:[`PRD is `,(0,B.jsx)(`b`,{children:r.status??`present`}),r.roadmap?` and a roadmap exists`:``,` — no `,(0,B.jsx)(`code`,{children:`docs/phases/`}),` yet. Kickstart builds the roadmap + doc scaffold (roadmap, tech stack, architecture, decisions, workstreams, queue, done, facts); phases follow with `,(0,B.jsx)(`code`,{children:`/plan-phase 1`}),`.`]}),(0,B.jsxs)(`div`,{className:`flex gap-2 items-center flex-wrap`,children:[(0,B.jsx)(K,{size:`sm`,tone:`primary`,disabled:!!a||!i?.aide,title:i?.aide?`DM ${i.aide}: run /kickstart in ${e}`:`no live aide — spawn one under Ops → Fleets`,onClick:()=>_(`kickstart`),children:a===`kickstart`?(0,B.jsx)(Ma,{size:12}):`Kickstart with the aide`}),i?.aide&&(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>ad(i.aide),children:`Open the aide's thread`}),!i?.aide&&(0,B.jsx)(V,{to:`/ops/fleets`,className:`hover:no-underline`,children:(0,B.jsx)(K,{size:`sm`,children:`Spawn aide`})})]})]}),s&&(0,B.jsx)(`div`,{className:`font-mono text-[12px] ${/^sent/.test(s)?`text-leaf`:`text-brick`}`,children:s})]}),t.length>0&&(0,B.jsxs)(`div`,{className:`px-3 pt-3 pb-2 overflow-x-auto`,children:[(0,B.jsx)(`ol`,{className:`flex items-start gap-0 min-w-max`,children:t.map((e,n)=>{let r=Ed[e.state],i=e.total?Math.round(e.done/e.total*100):0,o=n===t.length-1;return(0,B.jsxs)(`li`,{className:`flex items-start`,children:[(0,B.jsxs)(`div`,{className:`w-[190px] grid gap-1.5 justify-items-center text-center`,children:[(0,B.jsxs)(`button`,{onClick:()=>u(t=>t===e.id?null:e.id),className:`relative border-0 bg-transparent p-0 cursor-pointer rounded-full ${l===e.id?`ring-2 ring-ember ring-offset-2 ring-offset-paper`:``}`,title:`show tasks`,children:[(0,B.jsx)(Dd,{pct:e.state===`complete`?100:i,cls:r.ring}),(0,B.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center font-mono font-bold text-[12px] ${r.ring}`,children:e.state===`complete`?`✓`:e.n})]}),(0,B.jsx)(`button`,{onClick:()=>u(t=>t===e.id?null:e.id),className:`font-semibold text-[13px] leading-tight line-clamp-2 px-1 border-0 bg-transparent cursor-pointer text-walnut hover:text-ember-deep`,title:e.title,children:e.title}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(G,{tone:r.tone,children:r.label}),(0,B.jsxs)(`span`,{className:`font-mono text-[11px] text-ink3`,children:[e.total?`${e.done}/${e.total}`:`—`,e.streams?` · ${e.streams} stream${e.streams===1?``:`s`}`:``]})]}),f[e.id]&&(0,B.jsxs)(`div`,{className:`font-mono text-[10px] text-ink3 flex items-center gap-1 justify-center flex-wrap`,title:new Date(f[e.id].ts).toLocaleString(),children:[(0,B.jsx)(`span`,{className:`uppercase tracking-[.06em]`,children:f[e.id].verb===`kickoff`?`kicked off`:f[e.id].verb===`plan`?`plan requested`:`audit requested`}),(0,B.jsx)(`span`,{children:`→`}),(0,B.jsx)(ed,{id:f[e.id].to,bare:!0}),(0,B.jsx)(`span`,{className:`text-tan`,children:h(f[e.id].ts)})]}),(0,B.jsxs)(`div`,{className:`flex gap-1 flex-wrap justify-center`,children:[(e.tasks||e.readme)&&(0,B.jsx)(V,{to:`/docs/${encodeURIComponent(e.tasks??e.readme)}`,className:`hover:no-underline`,children:(0,B.jsx)(K,{size:`sm`,tone:`ghost`,children:`Open`})}),e.state===`pending`&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,disabled:!!a,title:`DM the aide: run /plan-phase`,onClick:()=>g(e,`plan`),children:a===`${e.id}:plan`?(0,B.jsx)(Ma,{size:12}):`Plan`}),e.state===`planned`&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,disabled:!!a,title:`GO to the coordinator`,onClick:()=>g(e,`kickoff`),children:a===`${e.id}:kickoff`?(0,B.jsx)(Ma,{size:12}):`Kick off`}),e.state===`ongoing`&&(0,B.jsx)(K,{size:`sm`,disabled:!!a,title:`ask the coordinator to run /coord-audit`,onClick:()=>g(e,`audit`),children:a===`${e.id}:audit`?(0,B.jsx)(Ma,{size:12}):`Audit`})]})]}),!o&&(0,B.jsx)(`div`,{className:`mt-[21px] h-[3px] w-6 rounded ${e.state===`complete`?`bg-leaf`:`bg-sand`}`})]},e.id)})}),l&&(0,B.jsx)(Vu,{project:e,phase:t.find(e=>e.id===l),onClose:()=>u(null)}),s&&(0,B.jsx)(`div`,{className:`mt-2 font-mono text-[12px] flex items-center gap-2 ${/^sent/.test(s)?`text-leaf`:`text-brick`}`,children:/^sent → /.test(s)?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{children:`sent →`}),(0,B.jsx)(ed,{id:s.replace(/^sent → /,``),bare:!0})]}):s}),(0,B.jsx)(`div`,{className:`mt-2 font-mono text-[11px] text-tan flex gap-3 flex-wrap`,children:Object.keys(Ed).map(e=>(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full border mr-1 align-middle ${Ed[e].dot}`}),Ed[e].label,` — `,Ed[e].hint]},e))})]})]})}function kd({phases:e}){return e?.length?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:e.map(e=>`${e.n}: ${e.state}${e.total?` ${e.done}/${e.total}`:``}`).join(` · `),children:[e.map((e,t)=>(0,B.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full border ${Ed[e.state].dot}`},t)),(0,B.jsxs)(`span`,{className:`ml-1 font-mono text-[11px] text-ink3`,children:[e.filter(e=>e.state===`complete`).length,`/`,e.length]})]}):(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`no phases`})}function Ad({project:e,canWrite:t,onClose:n,initialRole:r}){let{data:i}=q(`/actions/spawn/options?project=${encodeURIComponent(e)}`),[a,o]=(0,P.useState)(r??`worker`),[s,c]=(0,P.useState)(`claude`),[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),[p,m]=(0,P.useState)(``),[h,g]=(0,P.useState)(``),[_,v]=(0,P.useState)(8),[y,b]=(0,P.useState)(!1),[x,S]=(0,P.useState)(null),[C,w]=(0,P.useState)(null),T=ar(),{runs:E}=Ha(),D=x?E.find(e=>e.id===x.id)??x:null;(0,P.useEffect)(()=>{i&&!l&&u(i.suggest[a]??``)},[i,a,l]),(0,P.useEffect)(()=>{i&&u(i.suggest[a]??``)},[a]);let O=async()=>{b(!0),w(null);try{let t=await Fa(`/actions/spawn`,{project:e,role:a,harness:s,agentId:l,lane:d||void 0,model:p||void 0,note:h||void 0,waitSeconds:_});if(!t.status)throw Error(t.error??`failed`);S(t)}catch(e){w(e.message)}finally{b(!1)}},k=i?.roles.find(e=>e.id===a)?.skill??``;return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[8vh] whitespace-normal text-left`,onMouseDown:e=>{e.target===e.currentTarget&&!y&&n()},children:(0,B.jsxs)(`div`,{className:`w-[640px] bg-paper border border-sand rounded-kit shadow-panel`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] text-umber`,children:[`Spawn agent · `,e]}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px]`,children:[(0,B.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap items-center text-umber`,children:[(0,B.jsx)(G,{tone:t?`warn`:`outline`,children:t?`bus writes on`:`bus writes OFF`}),(0,B.jsxs)(`span`,{children:[`tmux window `,(0,B.jsxs)(`code`,{children:[`fleet-`,e]}),` · cwd `,(0,B.jsx)(`code`,{children:i?.repoPath?.replace(/^\/Users\/[^/]+/,`~`)}),i?.room?(0,B.jsxs)(B.Fragment,{children:[` · room `,(0,B.jsxs)(`code`,{children:[`#`,i.room]})]}):` · no room linked`]})]}),!t&&(0,B.jsx)(`div`,{className:`text-brick`,children:`Turn on bus writes (header toggle) first — spawning launches a process and types the role invocation into the new pane.`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Role · playbook card`}),(0,B.jsx)(`select`,{value:a,onChange:e=>o(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`,children:(i?.roles??[]).map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.id,` · `,e.skill]},e.id))})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Harness`}),(0,B.jsx)(`select`,{value:s,onChange:e=>c(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`,children:(i?.harnesses??[]).map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.id,` · `,e.cmd]},e.id))})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Agent id`}),(0,B.jsx)(`input`,{value:l,onChange:e=>u(e.target.value.trim()),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]}),a===`worker`?(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Lane`}),(0,B.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`repo-owner · rendering · api`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]}):(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Model (Claude only, optional)`}),(0,B.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`claude-sonnet-4-6`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Extra instruction (optional, injected after the skill)`}),(0,B.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`e.g. mission: re-verify the design doc after PR4`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 text-umber`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Start wait`}),(0,B.jsx)(`input`,{type:`range`,min:3,max:30,value:_,onChange:e=>v(Number(e.target.value))}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px]`,children:[_,` s`]}),(0,B.jsx)(`span`,{className:`text-[12px]`,children:`before injecting the skill`})]}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3 bg-linen rounded px-2 py-1.5`,children:[`will type: `,(0,B.jsx)(`b`,{className:`text-walnut`,children:i?.harnesses.find(e=>e.id===s)?.cmd}),` → wait `,_,` s → `,s===`claude`?`/color · `:``,(0,B.jsxs)(`b`,{className:`text-walnut`,children:[k,` --id=`,l||`…`,d?` --lane=${d}`:``,i?.room?` --room=${i.room}`:``]}),` → wait for register (≤ 90 s)`]}),C&&(0,B.jsx)(`div`,{className:`text-brick`,children:C}),D&&(0,B.jsxs)(`div`,{className:`p-2 rounded-kit border ${D.status===`ok`?`border-moss-line bg-moss-wash/50`:D.status===`failed`?`border-brick-line bg-brick-wash/50`:`border-amber-line bg-amber-wash/40`}`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px]`,children:[D.status===`running`?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-amber`,children:[(0,B.jsx)(Ma,{}),` `,(0,B.jsx)(G,{tone:`warn`,children:`running`})]}):(0,B.jsx)(G,{tone:D.status===`ok`?`ok`:`bad`,children:D.status}),` `,(0,B.jsx)(`b`,{children:D.label}),D.status===`running`&&(0,B.jsx)(`span`,{className:`ml-2 text-tan`,children:`live — you can close this; it keeps running (see Runs)`})]}),(0,B.jsxs)(`pre`,{className:`m-0 mt-1 font-mono text-[12px] whitespace-pre-wrap max-h-[30vh] overflow-auto`,children:[D.log.join(`
29
29
  `),D.error?`
30
- `+D.error:``]})]})]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:n,disabled:y,children:D?D.status===`running`?`Close (keeps running)`:`Close`:`Cancel`}),D&&(0,B.jsx)(K,{size:`sm`,onClick:()=>{n(),T(`/monitor`)},children:`Open Monitor`}),!D&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:O,disabled:!t||y||!l,children:y?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Ma,{}),` Starting…`]}):`Spawn`})]})]})})}function Ad({project:e,fleet:t,canWrite:n,compact:r=!1}){let i=q(`/bus/agents`,2e4).data??[],[a,o]=(0,P.useState)(null),s=e=>e?i.find(t=>t.agentId===e):void 0,c=({role:e,id:t,wide:n})=>{let r=s(t);return t?(0,B.jsxs)(`div`,{className:`px-2.5 py-1.5 rounded-kit border border-sand bg-paper ${n?``:`min-w-[170px]`}`,children:[(0,B.jsx)($u,{id:t,size:`md`,bare:!0}),(0,B.jsxs)(`span`,{className:`block font-mono text-[10px] uppercase tracking-[.08em] text-tan mt-0.5`,children:[e,r?.pane?` · ${r.pane}`:``]})]}):(0,B.jsxs)(`button`,{onClick:()=>o(e),className:`grid grid-cols-[auto_1fr] gap-2 items-center px-2.5 py-1.5 rounded-kit border border-dashed border-dust bg-transparent text-left cursor-pointer hover:border-ember ${n?``:`min-w-[150px]`}`,title:`spawn a ${e}`,children:[(0,B.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full border border-dashed border-dust`}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`block font-mono text-[12px] text-tan`,children:`missing`}),(0,B.jsxs)(`span`,{className:`block font-mono text-[10px] uppercase tracking-[.08em] text-tan`,children:[e,` · spawn`]})]})]})},l=({v:e=!1})=>(0,B.jsx)(`span`,{className:e?`w-px h-4 bg-dust mx-auto`:`h-px w-5 bg-dust self-center`}),u=t.roles.workers;return(0,B.jsxs)(`div`,{className:`grid gap-1 ${r?`text-[12px]`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsx)(`div`,{className:`px-2.5 py-1.5 rounded-kit border border-ember bg-ember-wash/40 font-mono font-semibold text-[12px] text-ember-deep`,children:`David`}),(0,B.jsx)(l,{}),(0,B.jsx)(c,{role:`aide`,id:t.roles.aide}),(0,B.jsx)(l,{}),(0,B.jsx)(c,{role:`coordinator`,id:t.roles.coordinator}),(0,B.jsx)(l,{}),(0,B.jsxs)(`div`,{className:`grid gap-1`,children:[(0,B.jsxs)(`div`,{className:`flex gap-1 flex-wrap`,children:[(0,B.jsx)(c,{role:`qa`,id:t.roles.qa}),(0,B.jsx)(c,{role:`ci`,id:t.roles.ci})]}),(0,B.jsxs)(`div`,{className:`flex gap-1 flex-wrap`,children:[u.map(e=>(0,B.jsx)(c,{role:`worker`,id:e},e)),(0,B.jsx)(c,{role:`worker`,id:null})]})]})]}),!r&&(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`you talk to the aide · the coordinator faces the fleet · qa gates · ci ships · workers own lanes. Click a filled slot to watch its pane, a dashed one to spawn that role.`}),a&&(0,B.jsx)(kd,{project:e,canWrite:n,initialRole:a,onClose:()=>o(null)})]})}var jd={absent:`bad`,partial:`warn`,present:`ok`};function Md({fleet:e}){if(!e)return null;let t=e.state===`absent`?`no fleet`:e.state===`partial`?`fleet partial · missing ${e.missing.join(`, `)}`:`fleet · ${e.live.length} live`;return(0,B.jsx)(G,{tone:jd[e.state],children:t})}function Nd({project:e,canWrite:t}){let{data:n,refresh:r}=q(`/projects/${e}/fleet`,2e4),[i,a]=(0,P.useState)(!1);return!n||n.state===`present`?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`rounded-kit border px-4 py-3 grid gap-2 ${n.state===`absent`?`border-brick-line bg-brick-wash/40`:`border-amber-line bg-amber-wash/50`}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,B.jsx)(Md,{fleet:n}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:n.state===`absent`?(0,B.jsxs)(B.Fragment,{children:[`No agents are live for `,(0,B.jsx)(`b`,{className:`text-walnut`,children:e}),`. Boards and docs still read fine; Plan / Fix / Kick off need someone to talk to.`]}):(0,B.jsxs)(B.Fragment,{children:[`Missing `,(0,B.jsx)(`b`,{className:`text-walnut`,children:n.missing.join(`, `)}),`.`]})}),(0,B.jsxs)(`span`,{className:`ml-auto flex gap-1.5`,children:[(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>a(!0),children:`Spawn fleet…`}),(0,B.jsx)(V,{to:`/ops/fleets`,className:`hover:no-underline`,children:(0,B.jsx)(K,{size:`sm`,children:`Fleets`})})]})]}),(0,B.jsx)(Ad,{project:e,fleet:n,canWrite:t,compact:!0})]}),i&&(0,B.jsx)(Pd,{project:e,templates:n.templates,missing:n.missing,canWrite:t,onClose:()=>{a(!1),r()}})]})}function Pd({project:e,templates:t,missing:n,canWrite:r,onClose:i}){let[a,o]=(0,P.useState)(t.find(e=>e.id===`standard`)?.id??t[0]?.id??`standard`),[s,c]=(0,P.useState)(`claude`),[l,u]=(0,P.useState)(`claude`),[d,f]=(0,P.useState)(null),[p,m]=(0,P.useState)(``),[h,g]=(0,P.useState)(8),[_,v]=(0,P.useState)(!1),[y,b]=(0,P.useState)(null),[x,S]=(0,P.useState)(null),{runs:C}=Ha(),w=y?C.find(e=>e.id===y.id)??y:null,T=t.find(e=>e.id===a),E=d??T?.workers??0;return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[8vh] whitespace-normal text-left`,onMouseDown:e=>{e.target===e.currentTarget&&!_&&i()},children:(0,B.jsxs)(`div`,{className:`w-[680px] bg-paper border border-sand rounded-kit shadow-panel`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] text-umber`,children:[`Spawn a fleet · `,e]}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px]`,children:[(0,B.jsxs)(`div`,{className:`text-umber`,children:[`Shapes from the playbook layout. Agents are launched one after another in tmux window `,(0,B.jsxs)(`code`,{children:[`fleet-`,e]}),`, each injected with its role card and `,(0,B.jsx)(`code`,{children:`--id`}),`, and the console waits for each to register.`,n.length>0&&(0,B.jsxs)(B.Fragment,{children:[` Currently missing: `,(0,B.jsx)(`b`,{className:`text-walnut`,children:n.join(`, `)}),`.`]})]}),!r&&(0,B.jsx)(`div`,{className:`text-brick`,children:`Turn on bus writes (header toggle) first.`}),(0,B.jsx)(`div`,{className:`grid gap-1.5`,children:t.map(e=>(0,B.jsxs)(`label`,{className:`grid grid-cols-[auto_1fr] gap-2 items-start px-3 py-2 rounded-kit border cursor-pointer ${a===e.id?`border-ember bg-ember-wash/40`:`border-sand`}`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`tpl`,checked:a===e.id,onChange:()=>{o(e.id),f(null)}}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:e.label}),(0,B.jsx)(`span`,{className:`block text-[12px] text-umber`,children:e.hint}),(0,B.jsx)(`span`,{className:`block font-mono text-[11px] text-tan`,children:[...e.roles,...Array.from({length:e.workers},(e,t)=>`worker-${t+1}`)].join(` · `)})]})]},e.id))}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Harness`}),(0,B.jsx)(`select`,{value:s,onChange:e=>c(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`,children:[`claude`,`grok`,`codex`,`opencode`].map(e=>(0,B.jsx)(`option`,{children:e},e))})]}),T?.roles.includes(`ci`)&&(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`CI harness (cheap)`}),(0,B.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`,children:[`claude`,`grok`,`codex`,`opencode`].map(e=>(0,B.jsx)(`option`,{children:e},e))})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Workers`}),(0,B.jsx)(`input`,{type:`number`,min:0,max:8,value:E,onChange:e=>f(Number(e.target.value)),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]})]}),E>0&&(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Lanes (comma-separated, optional)`}),(0,B.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`rendering, gameplay, infra`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 text-umber`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Start wait`}),(0,B.jsx)(`input`,{type:`range`,min:3,max:30,value:h,onChange:e=>g(Number(e.target.value))}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px]`,children:[h,` s per agent`]}),(0,B.jsxs)(`span`,{className:`text-[12px]`,children:[`· total ≈ `,(T?.roles.length??0)+E,` × (`,h,` s + register)`]})]}),x&&(0,B.jsx)(`div`,{className:`text-brick`,children:x}),w&&(0,B.jsxs)(`div`,{className:`p-2 rounded-kit border ${w.status===`ok`?`border-moss-line bg-moss-wash/50`:w.status===`failed`?`border-brick-line bg-brick-wash/50`:`border-amber-line bg-amber-wash/40`}`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px]`,children:[w.status===`running`?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-amber`,children:[(0,B.jsx)(Ma,{}),` `,(0,B.jsx)(G,{tone:`warn`,children:`running`})]}):(0,B.jsx)(G,{tone:w.status===`ok`?`ok`:`bad`,children:w.status}),` `,(0,B.jsx)(`b`,{children:w.label})]}),(0,B.jsx)(`pre`,{className:`m-0 mt-1 font-mono text-[12px] whitespace-pre-wrap max-h-[30vh] overflow-auto`,children:w.log.join(`
31
- `)})]})]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:i,disabled:_,children:w?`Close (keeps running)`:`Cancel`}),!w&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:async()=>{v(!0),S(null);try{let t=await Fa(`/actions/spawn-fleet`,{project:e,template:a,harness:s,ciHarness:l,workers:E,lanes:p.split(`,`).map(e=>e.trim()).filter(Boolean),waitSeconds:h});if(!t.status)throw Error(t.error??`failed`);b(t)}catch(e){S(e.message)}finally{v(!1)}},disabled:!r||_||!T,children:_?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Ma,{}),` Starting…`]}):`Spawn ${(T?.roles.length??0)+E} agents`})]})]})})}var Fd=e=>{let t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n} min ago`;let r=Math.floor(n/60);return r<24?`${r} h ago`:`${Math.floor(r/24)} d ago`},Id=e=>e===`workstreams.v1`?[e,`ok`]:e===`workstreams.lanes-v0`?[`lanes-v0 · legacy`,`warn`]:e===`unknown`?[`unknown workstreams grammar`,`bad`]:[`no WORKSTREAMS.md`,`outline`];function Ld(){let{projects:e,setCurrent:t,error:n,refresh:r}=za(),i=q(`/kit`).data,a=q(`/bus/agents`,3e4).data??[],o=a.filter(e=>e.liveness===`live`).length,s=a.filter(e=>e.liveness===`dead`),c=q(`/needs-david`,3e4).data??[],[l,u]=(0,P.useState)(!1);return(0,B.jsxs)(`div`,{className:`p-4 pb-10 grid gap-[18px] content-start`,children:[l&&(0,B.jsx)(qa,{onClose:()=>{u(!1),r()}}),(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline gap-3 flex-wrap`,children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Projects`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>u(!0),title:`register a repo path with the console`,children:`Add project`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[`Groundwork-managed repos with a seam in `,(0,B.jsx)(`code`,{children:`docs/`}),` · from `,(0,B.jsx)(`code`,{children:`groundwork-console.config.json`})]})]}),(0,B.jsxs)(`div`,{className:`flex gap-2.5 items-center flex-wrap`,children:[i?.requires&&!i.requires.ok&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] px-2 py-1 rounded-full bg-ember-wash text-ember-deep border border-ember/40`,title:Object.entries(i.requires).filter(([e])=>[`seam`,`mcp`,`groundwork`,`playbook`].includes(e)).map(([e,t])=>`${e}: has ${t.installed??`none`}, needs ${t.required}`).join(`
32
- `),children:`kit version mismatch`}),i?.source===`installed packages`&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,title:`no kit checkout on this machine — versions come from the installed npm packages`,children:`npm-installed`}),i?.packages?Object.entries({kit:{version:i.kitVersion},...i.packages}).map(([e,t])=>(0,B.jsxs)(`span`,{className:`font-mono font-medium text-[12px] px-[9px] py-1.5 border border-sand rounded-kit bg-paper text-umber`,children:[e,` `,(0,B.jsx)(`b`,{className:`text-walnut`,children:t.version})]},e)):(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:`kit.json unavailable`}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:`· from kit.json`})]})]}),n&&(0,B.jsxs)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:[`API unreachable (`,n,`) — start it with `,(0,B.jsx)(`code`,{children:`pnpm dev:api`}),`.`]}),(0,B.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(300px,1fr))] gap-3.5`,children:[...e].sort((e,t)=>(t.lastActive??0)-(e.lastActive??0)).map(e=>{let[n,r]=Id(e.schema);return(0,B.jsx)(V,{to:`/board`,onClick:()=>t(e.name),className:`block hover:no-underline text-inherit h-full`,children:(0,B.jsxs)(U,{className:`px-4 py-3.5 hover:border-dust h-full flex flex-col`,children:[(0,B.jsx)(`div`,{className:`font-display font-bold text-[20px] text-ember break-words`,title:e.name,children:e.name}),(0,B.jsxs)(`div`,{className:`mt-1 flex gap-1.5 flex-wrap`,children:[(0,B.jsx)(Md,{fleet:e.fleet}),e.versionMarker?e.behind?(0,B.jsxs)(G,{tone:`warn`,children:[`groundwork `,e.versionMarker,` → `,e.kitGroundwork]}):(0,B.jsxs)(G,{tone:`ok`,children:[`groundwork `,e.versionMarker]}):(0,B.jsx)(G,{tone:`outline`,children:`no groundwork marker`})]}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] leading-[1.6] text-ink3 mt-0.5 mb-2.5 truncate`,title:e.path,children:[e.path.replace(/^\/Users\/[^/]+/,`~`),e.room?` · #${e.room}`:``]}),(0,B.jsxs)(`div`,{className:`font-mono text-[11px] text-tan -mt-2 mb-2 flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{children:e.lastActive?`active ${Fd(e.lastActive)} · ${e.lastActiveSource}`:`no activity recorded`}),(0,B.jsx)(Od,{phases:e.phaseStrip??[]})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,children:[[`streams`,e.counts.streams],[`queue`,e.counts.queue],[`done`,e.counts.done],[`stale facts`,e.counts.staleFacts]].map(([e,t])=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`block font-bold text-[20px] leading-none text-walnut`,children:t}),(0,B.jsx)(`span`,{className:`font-mono font-medium text-[11px] uppercase tracking-[.06em] text-ink3`,children:e})]},e))}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap mt-auto pt-2.5`,children:[(0,B.jsx)(G,{tone:r,children:n}),e.files.queue?(0,B.jsx)(G,{tone:`ok`,children:`queue.v1`}):(0,B.jsx)(G,{tone:`outline`,children:`no QUEUE.md`}),e.files.done?(0,B.jsx)(G,{tone:`ok`,children:`done.v1`}):(0,B.jsx)(G,{tone:`outline`,children:`no DONE.md`}),e.files.facts?(0,B.jsxs)(G,{tone:e.counts.staleFacts?`warn`:`ok`,children:[`facts.v1`,e.counts.staleFacts?` · ${e.counts.staleFacts} stale`:``]}):(0,B.jsx)(G,{tone:`outline`,children:`no FACTS.md`}),e.counts.malformed?(0,B.jsxs)(G,{tone:`bad`,children:[e.counts.malformed,` malformed`]}):null]})]})},e.name)})}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 max-[980px]:grid-cols-1`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Needs David`,icon:`needsDavid`,path:`${c.length} open · WORKSTREAMS ## Needs David + DAVID_DECISION`}),c.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-2.5 text-[13px] text-umber`,children:`Nothing waiting on you.`}),c.slice(0,8).map((e,t)=>(0,B.jsx)(Oa,{glyph:`★`,children:(0,B.jsxs)(`div`,{className:`py-2 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-baseline`,children:[(0,B.jsx)(`b`,{className:`font-mono text-[13px]`,children:e.project}),(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan truncate`,children:e.source}),e.ts?(0,B.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[11px] ${yd(e.ts)}`,title:new Date(e.ts).toLocaleString(),children:$(e.ts)}):null]}),(0,B.jsx)(`div`,{className:`text-[14px] break-words line-clamp-2`,title:e.title,children:e.title}),e.detail&&(0,B.jsx)(`div`,{className:`text-[13px] text-umber break-words line-clamp-2`,children:e.detail}),e.msgId&&e.room?(0,B.jsx)(V,{className:`font-mono text-[12px]`,to:`/bus?room=${e.room}&msg=${e.msgId}`,children:`Open packet →`}):e.from?(0,B.jsx)(`button`,{className:`font-mono text-[12px] text-ember-deep border-0 bg-transparent p-0 cursor-pointer`,onClick:t=>{t.preventDefault(),id(e.from,{answers:e.msgId?[e.msgId]:void 0})},children:`Reply →`}):null]})},t))]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Bus health`,icon:`health`,path:`agents.json · transports · status`}),(0,B.jsx)(Oa,{glyph:`✓`,children:(0,B.jsxs)(`div`,{className:`py-2 flex items-center gap-2`,children:[(0,B.jsx)(G,{tone:a.length?`ok`:`warn`,children:a.length?`reachable`:`no store`}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[a.length,` registered · `,o,` live · `,s.length,` dead`]})]})}),s.length>0&&(0,B.jsx)(Oa,{glyph:`!`,children:(0,B.jsxs)(`div`,{className:`py-2 flex items-center gap-2 min-w-0`,children:[(0,B.jsxs)(G,{tone:`warn`,children:[s.length,` stale agents`]}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber truncate`,children:[s.slice(0,4).map(e=>e.agentId).join(`, `),s.length>4?`…`:``,` — `,(0,B.jsx)(V,{to:`/ops/fleets`,children:`fleet`})]})]})})]})]}),(0,B.jsx)(wd,{})]})}function Rd({scope:e}){return e?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[12px] text-ink3`,title:e.note??``,children:[(0,B.jsx)(`span`,{className:`text-tan`,children:`✎`}),e.owner,(0,B.jsxs)(`span`,{className:`text-tan`,children:[`· `,e.mode]})]}):(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,title:`no scope declared`,children:`unscoped`})}function zd({project:e,req:t,seamOn:n,scope:r,onClose:i}){let[a,o]=(0,P.useState)(`P2`),[s,c]=(0,P.useState)(``),[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(t.kind===`fact`?t.claim??``:``),[p,m]=(0,P.useState)(!1),[h,g]=(0,P.useState)(null),[_,v]=(0,P.useState)(null),y=async()=>{m(!0),v(null);try{let n=t.kind===`add`?await Fa(`/actions/queue-add/${e}`,{priority:a,text:s}):await Fa(`/actions/fact-reverify/${e}`,{id:t.id,method:l,claim:d||void 0});if(n.error&&!n.status)throw Error(n.error);g(n)}catch(e){v(e.message)}finally{m(!1)}},b=t.kind===`add`?`Add queue item · ${e}`:`Re-verify fact · ${t.id}`;return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[10vh] whitespace-normal text-left`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:(0,B.jsxs)(`div`,{className:`w-[600px] bg-paper border border-sand rounded-kit shadow-panel`,children:[(0,B.jsx)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] text-umber`,children:b}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px]`,children:[(0,B.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap items-center text-umber`,children:[(0,B.jsx)(G,{tone:n?`warn`:`outline`,children:n?`seam writes on`:`seam writes OFF`}),(0,B.jsxs)(`span`,{children:[`scope: `,r?`${r.owner} · ${r.mode}`:`unscoped`]}),(0,B.jsx)(`span`,{children:`· round-trip guard · re-parse after write · a Run`})]}),!n&&(0,B.jsxs)(`div`,{className:`text-brick`,children:[`Enable seam writes in the header (`,(0,B.jsx)(`code`,{children:`seam`}),` badge, type SEAM) first.`]}),t.kind===`add`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Priority`}),(0,B.jsx)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden w-max`,children:[`P1`,`P2`,`P3`].map(e=>(0,B.jsx)(`button`,{onClick:()=>o(e),"aria-pressed":a===e,className:`px-3 py-1.5 font-mono text-[12px] border-0 cursor-pointer ${a===e?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:e},e))})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:[`Item (one line · queue.v1: `,(0,B.jsxs)(`code`,{children:[`- [ ] (`,a,`) …`]}),`)`]}),(0,B.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:3,placeholder:`Short imperative — see [[phases/phaseN/PHASEN_TASKS]] · acceptance: …`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`})]}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3 bg-linen rounded px-2 py-1.5`,children:[`- [ ] (`,a,`) `,s.trim().replace(/\s+/g,` `)||`…`]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Claim (leave as is unless it changed)`}),(0,B.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Method — how you verified it just now`}),(0,B.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`curl 200 · checked dashboard · ran script`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`})]}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3 bg-linen rounded px-2 py-1.5`,children:["- `",t.id,"` — ",d||`…`,(0,B.jsx)(`br`,{}),` verified: now · by: david · method: `,l||`…`]})]}),_&&(0,B.jsx)(`div`,{className:`text-brick`,children:_}),h&&(0,B.jsxs)(`div`,{className:`p-2 rounded-kit border ${h.status===`ok`?`border-moss-line bg-moss-wash/50`:`border-brick-line bg-brick-wash/50`}`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px]`,children:[(0,B.jsx)(G,{tone:h.status===`ok`?`ok`:`bad`,children:h.status}),` `,(0,B.jsx)(`b`,{children:h.label})]}),(0,B.jsxs)(`pre`,{className:`m-0 mt-1 font-mono text-[12px] whitespace-pre-wrap`,children:[h.log.join(`
30
+ `+D.error:``]})]})]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:n,disabled:y,children:D?D.status===`running`?`Close (keeps running)`:`Close`:`Cancel`}),D&&(0,B.jsx)(K,{size:`sm`,onClick:()=>{n(),T(`/monitor`)},children:`Open Monitor`}),!D&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:O,disabled:!t||y||!l,children:y?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Ma,{}),` Starting…`]}):`Spawn`})]})]})})}function jd({project:e,fleet:t,canWrite:n,compact:r=!1}){let i=q(`/bus/agents`,2e4).data??[],[a,o]=(0,P.useState)(null),s=e=>e?i.find(t=>t.agentId===e):void 0,c=({role:e,id:t,wide:n})=>{let r=s(t);return t?(0,B.jsxs)(`div`,{className:`px-2.5 py-1.5 rounded-kit border border-sand bg-paper ${n?``:`min-w-[170px]`}`,children:[(0,B.jsx)(ed,{id:t,size:`md`,bare:!0}),(0,B.jsxs)(`span`,{className:`block font-mono text-[10px] uppercase tracking-[.08em] text-tan mt-0.5`,children:[e,r?.pane?` · ${r.pane}`:``]})]}):(0,B.jsxs)(`button`,{onClick:()=>o(e),className:`grid grid-cols-[auto_1fr] gap-2 items-center px-2.5 py-1.5 rounded-kit border border-dashed border-dust bg-transparent text-left cursor-pointer hover:border-ember ${n?``:`min-w-[150px]`}`,title:`spawn a ${e}`,children:[(0,B.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full border border-dashed border-dust`}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`block font-mono text-[12px] text-tan`,children:`missing`}),(0,B.jsxs)(`span`,{className:`block font-mono text-[10px] uppercase tracking-[.08em] text-tan`,children:[e,` · spawn`]})]})]})},l=({v:e=!1})=>(0,B.jsx)(`span`,{className:e?`w-px h-4 bg-dust mx-auto`:`h-px w-5 bg-dust self-center`}),u=t.roles.workers;return(0,B.jsxs)(`div`,{className:`grid gap-1 ${r?`text-[12px]`:``}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsx)(`div`,{className:`px-2.5 py-1.5 rounded-kit border border-ember bg-ember-wash/40 font-mono font-semibold text-[12px] text-ember-deep`,children:`David`}),(0,B.jsx)(l,{}),(0,B.jsx)(c,{role:`aide`,id:t.roles.aide}),(0,B.jsx)(l,{}),(0,B.jsx)(c,{role:`coordinator`,id:t.roles.coordinator}),(0,B.jsx)(l,{}),(0,B.jsxs)(`div`,{className:`grid gap-1`,children:[(0,B.jsxs)(`div`,{className:`flex gap-1 flex-wrap`,children:[(0,B.jsx)(c,{role:`qa`,id:t.roles.qa}),(0,B.jsx)(c,{role:`ci`,id:t.roles.ci})]}),(0,B.jsxs)(`div`,{className:`flex gap-1 flex-wrap`,children:[u.map(e=>(0,B.jsx)(c,{role:`worker`,id:e},e)),(0,B.jsx)(c,{role:`worker`,id:null})]})]})]}),!r&&(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`you talk to the aide · the coordinator faces the fleet · qa gates · ci ships · workers own lanes. Click a filled slot to watch its pane, a dashed one to spawn that role.`}),a&&(0,B.jsx)(Ad,{project:e,canWrite:n,initialRole:a,onClose:()=>o(null)})]})}var Md={absent:`bad`,partial:`warn`,present:`ok`};function Nd({fleet:e}){if(!e)return null;let t=e.state===`absent`?`no fleet`:e.state===`partial`?`fleet partial · missing ${e.missing.join(`, `)}`:`fleet · ${e.live.length} live`;return(0,B.jsx)(G,{tone:Md[e.state],children:t})}function Pd({project:e,canWrite:t}){let{data:n,refresh:r}=q(`/projects/${e}/fleet`,2e4),[i,a]=(0,P.useState)(!1);return!n||n.state===`present`?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`rounded-kit border px-4 py-3 grid gap-2 ${n.state===`absent`?`border-brick-line bg-brick-wash/40`:`border-amber-line bg-amber-wash/50`}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,B.jsx)(Nd,{fleet:n}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:n.state===`absent`?(0,B.jsxs)(B.Fragment,{children:[`No agents are live for `,(0,B.jsx)(`b`,{className:`text-walnut`,children:e}),`. Boards and docs still read fine; Plan / Fix / Kick off need someone to talk to.`]}):(0,B.jsxs)(B.Fragment,{children:[`Missing `,(0,B.jsx)(`b`,{className:`text-walnut`,children:n.missing.join(`, `)}),`.`]})}),(0,B.jsxs)(`span`,{className:`ml-auto flex gap-1.5`,children:[(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>a(!0),children:`Spawn fleet…`}),(0,B.jsx)(V,{to:`/ops/fleets`,className:`hover:no-underline`,children:(0,B.jsx)(K,{size:`sm`,children:`Fleets`})})]})]}),(0,B.jsx)(jd,{project:e,fleet:n,canWrite:t,compact:!0})]}),i&&(0,B.jsx)(Fd,{project:e,templates:n.templates,missing:n.missing,canWrite:t,onClose:()=>{a(!1),r()}})]})}function Fd({project:e,templates:t,missing:n,canWrite:r,onClose:i}){let[a,o]=(0,P.useState)(t.find(e=>e.id===`standard`)?.id??t[0]?.id??`standard`),[s,c]=(0,P.useState)(`claude`),[l,u]=(0,P.useState)(`claude`),[d,f]=(0,P.useState)(null),[p,m]=(0,P.useState)(``),[h,g]=(0,P.useState)(8),[_,v]=(0,P.useState)(!1),[y,b]=(0,P.useState)(null),[x,S]=(0,P.useState)(null),{runs:C}=Ha(),w=y?C.find(e=>e.id===y.id)??y:null,T=t.find(e=>e.id===a),E=d??T?.workers??0;return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[8vh] whitespace-normal text-left`,onMouseDown:e=>{e.target===e.currentTarget&&!_&&i()},children:(0,B.jsxs)(`div`,{className:`w-[680px] bg-paper border border-sand rounded-kit shadow-panel`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] text-umber`,children:[`Spawn a fleet · `,e]}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px]`,children:[(0,B.jsxs)(`div`,{className:`text-umber`,children:[`Shapes from the playbook layout. Agents are launched one after another in tmux window `,(0,B.jsxs)(`code`,{children:[`fleet-`,e]}),`, each injected with its role card and `,(0,B.jsx)(`code`,{children:`--id`}),`, and the console waits for each to register.`,n.length>0&&(0,B.jsxs)(B.Fragment,{children:[` Currently missing: `,(0,B.jsx)(`b`,{className:`text-walnut`,children:n.join(`, `)}),`.`]})]}),!r&&(0,B.jsx)(`div`,{className:`text-brick`,children:`Turn on bus writes (header toggle) first.`}),(0,B.jsx)(`div`,{className:`grid gap-1.5`,children:t.map(e=>(0,B.jsxs)(`label`,{className:`grid grid-cols-[auto_1fr] gap-2 items-start px-3 py-2 rounded-kit border cursor-pointer ${a===e.id?`border-ember bg-ember-wash/40`:`border-sand`}`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`tpl`,checked:a===e.id,onChange:()=>{o(e.id),f(null)}}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:e.label}),(0,B.jsx)(`span`,{className:`block text-[12px] text-umber`,children:e.hint}),(0,B.jsx)(`span`,{className:`block font-mono text-[11px] text-tan`,children:[...e.roles,...Array.from({length:e.workers},(e,t)=>`worker-${t+1}`)].join(` · `)})]})]},e.id))}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Harness`}),(0,B.jsx)(`select`,{value:s,onChange:e=>c(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`,children:[`claude`,`grok`,`codex`,`opencode`].map(e=>(0,B.jsx)(`option`,{children:e},e))})]}),T?.roles.includes(`ci`)&&(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`CI harness (cheap)`}),(0,B.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`,children:[`claude`,`grok`,`codex`,`opencode`].map(e=>(0,B.jsx)(`option`,{children:e},e))})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Workers`}),(0,B.jsx)(`input`,{type:`number`,min:0,max:8,value:E,onChange:e=>f(Number(e.target.value)),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]})]}),E>0&&(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Lanes (comma-separated, optional)`}),(0,B.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`rendering, gameplay, infra`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-3 text-umber`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Start wait`}),(0,B.jsx)(`input`,{type:`range`,min:3,max:30,value:h,onChange:e=>g(Number(e.target.value))}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px]`,children:[h,` s per agent`]}),(0,B.jsxs)(`span`,{className:`text-[12px]`,children:[`· total ≈ `,(T?.roles.length??0)+E,` × (`,h,` s + register)`]})]}),x&&(0,B.jsx)(`div`,{className:`text-brick`,children:x}),w&&(0,B.jsxs)(`div`,{className:`p-2 rounded-kit border ${w.status===`ok`?`border-moss-line bg-moss-wash/50`:w.status===`failed`?`border-brick-line bg-brick-wash/50`:`border-amber-line bg-amber-wash/40`}`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px]`,children:[w.status===`running`?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-amber`,children:[(0,B.jsx)(Ma,{}),` `,(0,B.jsx)(G,{tone:`warn`,children:`running`})]}):(0,B.jsx)(G,{tone:w.status===`ok`?`ok`:`bad`,children:w.status}),` `,(0,B.jsx)(`b`,{children:w.label})]}),(0,B.jsx)(`pre`,{className:`m-0 mt-1 font-mono text-[12px] whitespace-pre-wrap max-h-[30vh] overflow-auto`,children:w.log.join(`
31
+ `)})]})]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:i,disabled:_,children:w?`Close (keeps running)`:`Cancel`}),!w&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:async()=>{v(!0),S(null);try{let t=await Fa(`/actions/spawn-fleet`,{project:e,template:a,harness:s,ciHarness:l,workers:E,lanes:p.split(`,`).map(e=>e.trim()).filter(Boolean),waitSeconds:h});if(!t.status)throw Error(t.error??`failed`);b(t)}catch(e){S(e.message)}finally{v(!1)}},disabled:!r||_||!T,children:_?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Ma,{}),` Starting…`]}):`Spawn ${(T?.roles.length??0)+E} agents`})]})]})})}var Id=e=>{let t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n} min ago`;let r=Math.floor(n/60);return r<24?`${r} h ago`:`${Math.floor(r/24)} d ago`},Ld=e=>e===`workstreams.v1`?[e,`ok`]:e===`workstreams.lanes-v0`?[`lanes-v0 · legacy`,`warn`]:e===`unknown`?[`unknown workstreams grammar`,`bad`]:[`no WORKSTREAMS.md`,`outline`];function Rd(){let{projects:e,setCurrent:t,error:n,refresh:r}=za(),i=q(`/kit`).data,a=q(`/bus/agents`,3e4).data??[],o=a.filter(e=>e.liveness===`live`).length,s=a.filter(e=>e.liveness===`dead`),c=q(`/needs-david`,3e4).data??[],[l,u]=(0,P.useState)(!1);return(0,B.jsxs)(`div`,{className:`p-4 pb-10 grid gap-[18px] content-start`,children:[l&&(0,B.jsx)(qa,{onClose:()=>{u(!1),r()}}),(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline gap-3 flex-wrap`,children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Projects`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>u(!0),title:`register a repo path with the console`,children:`Add project`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[`Groundwork-managed repos with a seam in `,(0,B.jsx)(`code`,{children:`docs/`}),` · from `,(0,B.jsx)(`code`,{children:`groundwork-console.config.json`})]})]}),(0,B.jsxs)(`div`,{className:`flex gap-2.5 items-center flex-wrap`,children:[i?.requires&&!i.requires.ok&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] px-2 py-1 rounded-full bg-ember-wash text-ember-deep border border-ember/40`,title:Object.entries(i.requires).filter(([e])=>[`seam`,`mcp`,`groundwork`,`playbook`].includes(e)).map(([e,t])=>`${e}: has ${t.installed??`none`}, needs ${t.required}`).join(`
32
+ `),children:`kit version mismatch`}),i?.source===`installed packages`&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,title:`no kit checkout on this machine — versions come from the installed npm packages`,children:`npm-installed`}),i?.packages?Object.entries({kit:{version:i.kitVersion},...i.packages}).map(([e,t])=>(0,B.jsxs)(`span`,{className:`font-mono font-medium text-[12px] px-[9px] py-1.5 border border-sand rounded-kit bg-paper text-umber`,children:[e,` `,(0,B.jsx)(`b`,{className:`text-walnut`,children:t.version})]},e)):(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:`kit.json unavailable`}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:`· from kit.json`})]})]}),n&&(0,B.jsxs)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:[`API unreachable (`,n,`) — start it with `,(0,B.jsx)(`code`,{children:`pnpm dev:api`}),`.`]}),(0,B.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(300px,1fr))] gap-3.5`,children:[...e].sort((e,t)=>(t.lastActive??0)-(e.lastActive??0)).map(e=>{let[n,r]=Ld(e.schema);return(0,B.jsx)(V,{to:`/board`,onClick:()=>t(e.name),className:`block hover:no-underline text-inherit h-full`,children:(0,B.jsxs)(U,{className:`px-4 py-3.5 hover:border-dust h-full flex flex-col`,children:[(0,B.jsx)(`div`,{className:`font-display font-bold text-[20px] text-ember break-words`,title:e.name,children:e.name}),(0,B.jsxs)(`div`,{className:`mt-1 flex gap-1.5 flex-wrap`,children:[(0,B.jsx)(Nd,{fleet:e.fleet}),e.versionMarker?e.behind?(0,B.jsxs)(G,{tone:`warn`,children:[`groundwork `,e.versionMarker,` → `,e.kitGroundwork]}):(0,B.jsxs)(G,{tone:`ok`,children:[`groundwork `,e.versionMarker]}):(0,B.jsx)(G,{tone:`outline`,children:`no groundwork marker`})]}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] leading-[1.6] text-ink3 mt-0.5 mb-2.5 truncate`,title:e.path,children:[e.path.replace(/^\/Users\/[^/]+/,`~`),e.room?` · #${e.room}`:``]}),(0,B.jsxs)(`div`,{className:`font-mono text-[11px] text-tan -mt-2 mb-2 flex items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{children:e.lastActive?`active ${Id(e.lastActive)} · ${e.lastActiveSource}`:`no activity recorded`}),(0,B.jsx)(kd,{phases:e.phaseStrip??[]})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,children:[[`streams`,e.counts.streams],[`queue`,e.counts.queue],[`done`,e.counts.done],[`stale facts`,e.counts.staleFacts]].map(([e,t])=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`block font-bold text-[20px] leading-none text-walnut`,children:t}),(0,B.jsx)(`span`,{className:`font-mono font-medium text-[11px] uppercase tracking-[.06em] text-ink3`,children:e})]},e))}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap mt-auto pt-2.5`,children:[(0,B.jsx)(G,{tone:r,children:n}),e.files.queue?(0,B.jsx)(G,{tone:`ok`,children:`queue.v1`}):(0,B.jsx)(G,{tone:`outline`,children:`no QUEUE.md`}),e.files.done?(0,B.jsx)(G,{tone:`ok`,children:`done.v1`}):(0,B.jsx)(G,{tone:`outline`,children:`no DONE.md`}),e.files.facts?(0,B.jsxs)(G,{tone:e.counts.staleFacts?`warn`:`ok`,children:[`facts.v1`,e.counts.staleFacts?` · ${e.counts.staleFacts} stale`:``]}):(0,B.jsx)(G,{tone:`outline`,children:`no FACTS.md`}),e.counts.malformed?(0,B.jsxs)(G,{tone:`bad`,children:[e.counts.malformed,` malformed`]}):null]})]})},e.name)})}),(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 max-[980px]:grid-cols-1`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Needs David`,icon:`needsDavid`,path:`${c.length} open · WORKSTREAMS ## Needs David + DAVID_DECISION`}),c.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-2.5 text-[13px] text-umber`,children:`Nothing waiting on you.`}),c.slice(0,8).map((e,t)=>(0,B.jsx)(Oa,{glyph:`★`,children:(0,B.jsxs)(`div`,{className:`py-2 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-baseline`,children:[(0,B.jsx)(`b`,{className:`font-mono text-[13px]`,children:e.project}),(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan truncate`,children:e.source}),e.ts?(0,B.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[11px] ${bd(e.ts)}`,title:new Date(e.ts).toLocaleString(),children:yd(e.ts)}):null]}),(0,B.jsx)(`div`,{className:`text-[14px] break-words line-clamp-2`,title:e.title,children:e.title}),e.detail&&(0,B.jsx)(`div`,{className:`text-[13px] text-umber break-words line-clamp-2`,children:e.detail}),e.msgId&&e.room?(0,B.jsx)(V,{className:`font-mono text-[12px]`,to:`/bus?room=${e.room}&msg=${e.msgId}`,children:`Open packet →`}):e.from?(0,B.jsx)(`button`,{className:`font-mono text-[12px] text-ember-deep border-0 bg-transparent p-0 cursor-pointer`,onClick:t=>{t.preventDefault(),ad(e.from,{answers:e.msgId?[e.msgId]:void 0})},children:`Reply →`}):null]})},t))]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Bus health`,icon:`health`,path:`agents.json · transports · status`}),(0,B.jsx)(Oa,{glyph:`✓`,children:(0,B.jsxs)(`div`,{className:`py-2 flex items-center gap-2`,children:[(0,B.jsx)(G,{tone:a.length?`ok`:`warn`,children:a.length?`reachable`:`no store`}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[a.length,` registered · `,o,` live · `,s.length,` dead`]})]})}),s.length>0&&(0,B.jsx)(Oa,{glyph:`!`,children:(0,B.jsxs)(`div`,{className:`py-2 flex items-center gap-2 min-w-0`,children:[(0,B.jsxs)(G,{tone:`warn`,children:[s.length,` stale agents`]}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber truncate`,children:[s.slice(0,4).map(e=>e.agentId).join(`, `),s.length>4?`…`:``,` — `,(0,B.jsx)(V,{to:`/ops/fleets`,children:`fleet`})]})]})})]})]}),(0,B.jsx)(Td,{})]})}function zd({scope:e}){return e?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[12px] text-ink3`,title:e.note??``,children:[(0,B.jsx)(`span`,{className:`text-tan`,children:`✎`}),e.owner,(0,B.jsxs)(`span`,{className:`text-tan`,children:[`· `,e.mode]})]}):(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,title:`no scope declared`,children:`unscoped`})}function Bd({project:e,req:t,seamOn:n,scope:r,onClose:i}){let[a,o]=(0,P.useState)(`P2`),[s,c]=(0,P.useState)(``),[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(t.kind===`fact`?t.claim??``:``),[p,m]=(0,P.useState)(!1),[h,g]=(0,P.useState)(null),[_,v]=(0,P.useState)(null),y=async()=>{m(!0),v(null);try{let n=t.kind===`add`?await Fa(`/actions/queue-add/${e}`,{priority:a,text:s}):await Fa(`/actions/fact-reverify/${e}`,{id:t.id,method:l,claim:d||void 0});if(n.error&&!n.status)throw Error(n.error);g(n)}catch(e){v(e.message)}finally{m(!1)}},b=t.kind===`add`?`Add queue item · ${e}`:`Re-verify fact · ${t.id}`;return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[10vh] whitespace-normal text-left`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:(0,B.jsxs)(`div`,{className:`w-[600px] bg-paper border border-sand rounded-kit shadow-panel`,children:[(0,B.jsx)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] text-umber`,children:b}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px]`,children:[(0,B.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap items-center text-umber`,children:[(0,B.jsx)(G,{tone:n?`warn`:`outline`,children:n?`seam writes on`:`seam writes OFF`}),(0,B.jsxs)(`span`,{children:[`scope: `,r?`${r.owner} · ${r.mode}`:`unscoped`]}),(0,B.jsx)(`span`,{children:`· round-trip guard · re-parse after write · a Run`})]}),!n&&(0,B.jsxs)(`div`,{className:`text-brick`,children:[`Enable seam writes in the header (`,(0,B.jsx)(`code`,{children:`seam`}),` badge, type SEAM) first.`]}),t.kind===`add`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Priority`}),(0,B.jsx)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden w-max`,children:[`P1`,`P2`,`P3`].map(e=>(0,B.jsx)(`button`,{onClick:()=>o(e),"aria-pressed":a===e,className:`px-3 py-1.5 font-mono text-[12px] border-0 cursor-pointer ${a===e?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:e},e))})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:[`Item (one line · queue.v1: `,(0,B.jsxs)(`code`,{children:[`- [ ] (`,a,`) …`]}),`)`]}),(0,B.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:3,placeholder:`Short imperative — see [[phases/phaseN/PHASEN_TASKS]] · acceptance: …`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`})]}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3 bg-linen rounded px-2 py-1.5`,children:[`- [ ] (`,a,`) `,s.trim().replace(/\s+/g,` `)||`…`]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Claim (leave as is unless it changed)`}),(0,B.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`})]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Method — how you verified it just now`}),(0,B.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`curl 200 · checked dashboard · ran script`,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`})]}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3 bg-linen rounded px-2 py-1.5`,children:["- `",t.id,"` — ",d||`…`,(0,B.jsx)(`br`,{}),` verified: now · by: david · method: `,l||`…`]})]}),_&&(0,B.jsx)(`div`,{className:`text-brick`,children:_}),h&&(0,B.jsxs)(`div`,{className:`p-2 rounded-kit border ${h.status===`ok`?`border-moss-line bg-moss-wash/50`:`border-brick-line bg-brick-wash/50`}`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px]`,children:[(0,B.jsx)(G,{tone:h.status===`ok`?`ok`:`bad`,children:h.status}),` `,(0,B.jsx)(`b`,{children:h.label})]}),(0,B.jsxs)(`pre`,{className:`m-0 mt-1 font-mono text-[12px] whitespace-pre-wrap`,children:[h.log.join(`
33
33
  `),h.error?`
34
- `+h.error:``]}),h.status===`ok`&&(0,B.jsx)(`div`,{className:`mt-1 text-[12px] text-umber`,children:`Written to the working tree (uncommitted). Review the diff in Docs, then commit in the repo.`})]})]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:i,children:h?`Close`:`Cancel`}),!h&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:y,disabled:!n||p||(t.kind===`add`?!s.trim():!l.trim()),children:p?`Writing…`:t.kind===`add`?`Append to QUEUE.md`:`Write to FACTS.md`})]})]})})}var Bd=`1.6fr 1.1fr 1.4fr 1fr 1fr 2fr`,Vd=`1.4fr 1fr 1fr 1.6fr 1.6fr`,Hd=e=>/block/i.test(e)?`bad`:/done|merged|deployed|✅/i.test(e)||/watch|soak/i.test(e)?`ok`:`neutral`,Ud=({k:e})=>(0,B.jsx)(`kbd`,{className:`ml-1 font-mono text-[12px] border border-dust border-b-2 rounded px-1 text-umber bg-paper`,children:e});function Wd({r:e,raw:t,cols:n}){return`malformed`in e?(0,B.jsx)(Oa,{glyph:`|`,malformed:!0,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`py-2 flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(G,{tone:`solid`,children:`MalformedRow`}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,children:e.issue??`line ${e.line??`?`} · expected ${e.expected??`?`} columns, found ${e.actual??`?`} — kept byte-exact, not parsed.`}),e.line?(0,B.jsx)(V,{className:`text-[13px]`,to:`/docs/WORKSTREAMS.md?view=source&line=${e.line}`,children:`Show line`}):null]})}):e.schema===`workstreams.v1`?(0,B.jsx)(Oa,{glyph:`|`,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`grid gap-3 items-center py-1.5`,style:{gridTemplateColumns:n},children:[(0,B.jsx)(`b`,{className:`truncate`,title:e.stream,children:e.stream}),(0,B.jsx)(`span`,{className:`font-mono font-medium text-[13px] text-umber truncate`,children:e.owner}),(0,B.jsx)(`span`,{className:`font-mono text-[13px] truncate`,children:e.branchWorktree}),(0,B.jsx)(`span`,{className:`min-w-0`,children:(0,B.jsx)(G,{tone:Hd(e.status),children:e.status})}),(0,B.jsx)(`span`,{className:`min-w-0 truncate`,children:/david/i.test(e.blocker)?(0,B.jsx)(G,{tone:`david`,children:e.blocker}):(0,B.jsx)(`span`,{className:e.blocker===`—`?`font-mono text-tan`:`text-[13px]`,children:e.blocker})}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,title:e.lastNote,children:e.lastNote})]})}):(0,B.jsx)(Oa,{glyph:`|`,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`grid gap-3 items-center py-1.5`,style:{gridTemplateColumns:n},children:[(0,B.jsx)(`b`,{className:`truncate`,children:e.lane}),(0,B.jsx)(`span`,{className:`font-mono font-medium text-[13px] text-umber truncate`,children:e.owner}),(0,B.jsx)(`span`,{className:`min-w-0`,children:(0,B.jsx)(G,{tone:Hd(e.state),children:e.state})}),(0,B.jsx)(`span`,{className:`text-[13px] truncate`,children:e.currentSlice}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,children:e.nextGo})]})})}function Gd(){let{current:e}=za(),[t,n]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let e=e=>{e.key===`s`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!(e.target instanceof HTMLInputElement)&&!(e.target instanceof HTMLTextAreaElement)&&!(e.target instanceof HTMLSelectElement)&&n(e=>!e)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let{data:r,error:i,loading:a}=q(e?`/projects/${e}/board`:null,15e3),o=q(e?`/projects/${e}/doctor`:null,6e4),s=o.data,c=q(e?`/projects/${e}/doctor/fixers`:null,3e4).data?.fixers??{},[l,u]=(0,P.useState)(null),[d,f]=(0,P.useState)({}),p=async(t,n)=>{if(!m){f(e=>({...e,[t]:`bus writes are off — toggle in the header`}));return}u(t);try{let r=await Fa(`/actions/doctor-fix/${e}`,{check:t,items:n});f(e=>({...e,[t]:r.status===`ok`?`sent → ${r.args?.to}`:r.error??`failed`}))}catch(e){f(n=>({...n,[t]:e.message}))}finally{u(null)}},m=q(`/admin/bus-writes`,1e4).data?.enabled??!1,h=q(`/admin/seam-writes`,1e4).data?.enabled??!1,[g,_]=(0,P.useState)(()=>{try{return JSON.parse(localStorage.getItem(`groundwork-console.board.fold`)??``)}catch{return{done:!1,facts:!1}}}),v=e=>_(t=>{let n={...t,[e]:!t[e]};return localStorage.setItem(`groundwork-console.board.fold`,JSON.stringify(n)),n}),y=(r?.facts?.entries.filter(e=>e.stale).length??0)+(r?.facts?.issues.length??0),[b,x]=(0,P.useState)(null),[S,C]=(0,P.useState)(!1),w=async()=>{C(!0);try{await Fa(`/actions/project-doctor/${e}`),o.refresh()}finally{C(!1)}};if(!e)return(0,B.jsx)(`div`,{className:`p-4 text-umber`,children:`No project selected.`});if(i)return(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsxs)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:[`API error: `,i]})});if(!r)return(0,B.jsx)(`div`,{className:`p-4 text-umber`,children:a?`Reading seam…`:``});let T=r.workstreams.schema,E=T===`workstreams.v1`,D=E?Bd:Vd,O=e=>r.scopes[e]?{path:e,owner:r.scopes[e].owner,mode:r.scopes[e].mode??`shared`,note:r.scopes[e].note}:void 0,k=r.phases.find(e=>e.state===`ongoing`);return(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_340px] gap-4 p-4 max-[980px]:grid-cols-1`,children:[b&&(0,B.jsx)(zd,{project:e,req:b,seamOn:h,scope:b.kind===`add`?O(`docs/QUEUE.md`):O(`docs/FACTS.md`),onClose:()=>{x(null)}}),(0,B.jsxs)(`div`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:e}),k&&(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[k.title,` · `,k.done,`/`,k.total]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:a?`refreshing…`:`read from disk · 15 s`}),(0,B.jsx)(K,{size:`sm`,onClick:w,disabled:S,children:S?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Ma,{size:12}),` Doctor`]}):`Doctor`})]})]}),(0,B.jsx)(Nd,{project:e,canWrite:m}),(0,B.jsx)(Dd,{project:e,phases:r.phases,canWrite:m}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Active Streams`,icon:`streams`,eyebrow:T??`no WORKSTREAMS.md`,path:`docs/WORKSTREAMS.md`,children:[(0,B.jsx)(Rd,{scope:O(`docs/WORKSTREAMS.md`)}),(0,B.jsxs)(K,{tone:`ghost`,size:`sm`,onClick:()=>n(e=>!e),"aria-pressed":t,children:[t?`Rendered`:`View source`,(0,B.jsx)(Ud,{k:`s`})]})]}),T===`unknown`&&(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px]`,children:[(0,B.jsx)(G,{tone:`bad`,children:`unknown workstreams grammar`}),(0,B.jsx)(`span`,{className:`ml-2 text-umber`,children:`expected workstreams.v1 (6-col Active Streams). Never auto-migrated — coordinator rewrites to v1.`})]}),T===`workstreams.lanes-v0`&&(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[13px]`,children:[(0,B.jsx)(G,{tone:`warn`,children:`lanes-v0 · legacy`}),(0,B.jsx)(`span`,{className:`ml-2 text-umber`,children:`5-col Lanes parses read-only; new writes should be workstreams.v1.`})]}),r.workstreams.rows.length>0&&(E?(0,B.jsxs)(ka,{cols:D,children:[(0,B.jsx)(`span`,{children:`Stream`}),(0,B.jsx)(`span`,{children:`Owner / Agent`}),(0,B.jsx)(`span`,{children:`Branch · Worktree`}),(0,B.jsx)(`span`,{children:`Status`}),(0,B.jsx)(`span`,{children:`Blocker`}),(0,B.jsx)(`span`,{children:`Last note`})]}):(0,B.jsxs)(ka,{cols:D,children:[(0,B.jsx)(`span`,{children:`Lane`}),(0,B.jsx)(`span`,{children:`Owner`}),(0,B.jsx)(`span`,{children:`State`}),(0,B.jsx)(`span`,{children:`Current slice`}),(0,B.jsx)(`span`,{children:`Next GO`})]})),r.workstreams.rows.map((e,n)=>(0,B.jsx)(Wd,{r:e,raw:t,cols:D},n)),r.workstreams.issues.length>0&&(0,B.jsxs)(`div`,{className:`px-3 py-2 border-t border-sand text-[12px] font-mono text-ink3`,children:[r.workstreams.issues.length,` parser issue`,r.workstreams.issues.length>1?`s`:``,`: `,r.workstreams.issues.slice(0,3).join(` · `),r.workstreams.issues.length>3?` …`:``]})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Queue`,icon:`queue`,eyebrow:`queue.v1`,path:`docs/QUEUE.md`,children:[(0,B.jsx)(Rd,{scope:O(`docs/QUEUE.md`)}),(0,B.jsx)(K,{size:`sm`,tone:h?`primary`:`default`,onClick:()=>x({kind:`add`}),title:h?`append a queue.v1 item through the seam`:`seam writes are off — enable in the header`,children:`Add item…`}),!h&&(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-tan ml-1`,title:`seam & docs writes are off`,children:`seam & docs off · header`})]}),r.queue.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`Queue empty.`}),r.queue.map(e=>(0,B.jsx)(Oa,{glyph:e.done?`- [x]`:`- [ ]`,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-[44px_1fr] gap-2.5 items-baseline py-2`,children:[(0,B.jsx)(`span`,{className:`font-mono font-bold text-[12px] px-[7px] py-[3px] rounded text-center ${e.priority===`P1`?`bg-ember-wash text-ember-deep`:e.priority===`P2`?`bg-amber-wash text-amber`:`bg-slate-wash text-slate`}`,children:e.priority}),(0,B.jsx)(`span`,{className:e.done?`line-through text-tan`:``,children:e.text})]})},e.id))]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Done`,icon:`done`,eyebrow:`done.v1 · append-only`,path:`docs/DONE.md · ${r.done.length}`,children:[(0,B.jsx)(Rd,{scope:O(`docs/DONE.md`)}),(0,B.jsx)(Kd,{k:`done`,open:g.done,onToggle:v})]}),g.done&&r.done.slice(-8).reverse().map(e=>(0,B.jsx)(Oa,{glyph:`—`,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-3 items-baseline py-2`,children:[(0,B.jsx)(`span`,{className:`truncate`,title:e.text,children:e.text}),(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-ink3`,children:e.date??``})]})},e.id))]})]}),(0,B.jsxs)(`aside`,{className:`grid gap-3.5 content-start bg-cream -m-4 ml-0 p-4 border-l border-sand min-w-0`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Facts`,icon:`facts`,path:`docs/FACTS.md · ${r.facts?.entries.length??0}${y?` · ${y} need attention`:``}`,children:[(0,B.jsx)(Rd,{scope:O(`docs/FACTS.md`)}),(0,B.jsx)(Kd,{k:`facts`,open:g.facts||y>0,onToggle:v})]}),(g.facts||y>0)&&!r.facts&&(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:[`No FACTS.md yet (run `,(0,B.jsx)(`code`,{children:`groundwork update --docs`}),`).`]}),(g.facts||y>0)&&r.facts?.entries.map(e=>(0,B.jsx)(Oa,{glyph:`##`,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`py-2 grid grid-cols-[1fr_auto] gap-2 items-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`font-mono font-medium text-[13px] truncate`,children:[e.id,e.stale&&(0,B.jsx)(`span`,{className:`ml-2 inline-flex`,children:(0,B.jsx)(G,{tone:`warn`,children:`stale`})})]}),e.value&&(0,B.jsx)(`div`,{className:`text-umber truncate`,title:e.value,children:e.value}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3`,children:[e.ageDays===null?`unverified`:`${e.ageDays} d`,e.by?` · ${e.by}`:``,e.method?` · ${e.method}`:``]})]}),(0,B.jsx)(K,{size:`sm`,tone:e.stale?`primary`:`ghost`,onClick:()=>x({kind:`fact`,id:e.id,claim:e.value}),title:`upsert this fact through the seam with a fresh timestamp`,children:`Re-verify…`})]})},e.id)),r.facts&&r.facts.issues.length>0&&(0,B.jsxs)(`div`,{className:`px-3 py-2 border-t border-sand text-[12px] font-mono text-ink3`,children:[r.facts.issues.length,` issue`,r.facts.issues.length>1?`s`:``,`: `,r.facts.issues[0]]})]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Project doctor`,icon:`doctor`,path:s?`groundwork doctor --json · ${s.checks.filter(e=>e.level!==`ok`).length} flagged`:`groundwork doctor`}),!s&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`running…`}),s?.error&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-brick`,children:s.error}),s?.checks.map(e=>(0,B.jsx)(Oa,{glyph:e.level===`ok`?`✓`:`!`,children:(0,B.jsxs)(`div`,{className:`py-1.5 text-[13px] min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsxs)(G,{tone:e.level===`ok`?`ok`:e.level===`error`?`bad`:`warn`,children:[e.check,e.level!==`ok`&&e.items.length>1?` · ${e.items.length}`:``]}),e.level!==`ok`&&(e.check===`version-marker`?(0,B.jsx)(V,{to:`/ops/skills`,className:`ml-auto font-mono text-[11px]`,children:`Update via Skills →`}):c[e.check]?c[e.check].agent?(0,B.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1`,children:[(0,B.jsx)(`button`,{onClick:()=>p(e.check,e.items),disabled:l===e.check,className:`font-mono text-[11px] px-2 py-0.5 rounded-full border cursor-pointer ${m?`bg-ember-wash text-ember-deep border-ember-line`:`bg-paper text-umber border-dust`}`,title:`DM ${c[e.check].agent} as david: ${c[e.check].how}`,children:l===e.check?(0,B.jsx)(Ma,{size:11}):`Fix →`}),(0,B.jsx)($u,{id:c[e.check].agent})]}):(0,B.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-tan`,title:`needs a live ${c[e.check].role} for this project`,children:[`no `,c[e.check].role,` online`]}):null)]}),(0,B.jsxs)(`div`,{className:`text-umber mt-1 grid gap-0.5`,children:[e.items.slice(0,e.level===`ok`?1:3).map((e,t)=>(0,B.jsx)(`div`,{className:`truncate`,title:e,children:e},t)),e.level!==`ok`&&e.items.length>3&&(0,B.jsxs)(`div`,{className:`text-tan`,children:[`+`,e.items.length-3,` more`]})]}),d[e.check]&&(0,B.jsx)(`div`,{className:`mt-1 font-mono text-[11px] flex items-center gap-1.5 ${/^sent/.test(d[e.check])?`text-leaf`:`text-brick`}`,children:/^sent → /.test(d[e.check])?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{children:`sent →`}),(0,B.jsx)($u,{id:d[e.check].replace(/^sent → /,``)})]}):d[e.check]})]})},e.check))]})]})]})}function Kd({k:e,open:t,onToggle:n}){return(0,B.jsx)(`button`,{onClick:()=>n(e),className:`ml-1 font-mono text-[11px] text-tan border-0 bg-transparent cursor-pointer hover:text-umber`,title:t?`collapse`:`expand`,children:t?`▾`:`▸`})}var qd=({children:e})=>(0,B.jsx)(`div`,{className:`font-mono font-semibold text-[11px] uppercase tracking-[.1em] text-ink3 mx-2 mt-3.5 mb-1.5`,children:e}),Jd=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``,Yd=e=>e?new Date(e).toLocaleDateString([],{month:`short`,day:`numeric`}):``,Xd=e=>!!e&&Ta.includes(e),Zd=(e,t)=>t&&e.startsWith(t)?e.slice(t.length).replace(/^:?\s*/,``):e,Qd=`/api`;function $d(){let{projects:e,current:t}=za(),[n,r]=Fi(),i=q(`/bus/rooms`,2e4).data??[],[a,o]=(0,P.useState)(!1),[s,c]=(0,P.useState)(!1),l=q(`/bus/agents`,3e4).data??[],u=e.find(e=>e.name===t)?.room??i[0]?.room??`general`,d=n.get(`view`)===`status`?`status`:n.get(`view`)===`inbox`?`inbox`:`room`,f=n.get(`room`)??u,p=[...i].sort((e,t)=>t.lastTs-e.lastTs),m=p.filter(e=>Date.now()-e.lastTs>6048e5&&e.room!==f),h=a?p:p.filter(e=>!m.includes(e)),g=n.get(`msg`),_=i.find(e=>e.room===f),{data:v,error:y}=q(d===`room`&&f?`/bus/rooms/${f}/messages?limit=80`:null,1e4),b=q(d===`status`?`/bus/status?limit=100`:null,15e3).data??[],x=q(d===`inbox`?`/bus/inbox?limit=200`:null,2e4),[S,C]=(0,P.useState)(!1),w=async()=>{C(!0);try{await Fa(`/bus/inbox/read`),x.refresh()}finally{C(!1)}},[T,E]=(0,P.useState)([]),[D,O]=(0,P.useState)(!1);(0,P.useEffect)(()=>{E([])},[f]);let k=(0,P.useMemo)(()=>{let e=new Set;return[...T,...v?.messages??[]].filter(t=>{let n=t.id??`${t.ts}-${t.from}`;return!e.has(n)&&(e.add(n),!0)})},[T,v]),A=k.filter(e=>!e.system).slice().reverse(),j=async()=>{let e=k[0]?.ts;if(e){O(!0);try{let t=await(await fetch(`${Qd}/bus/rooms/${f}/messages?limit=80&before=${e}`)).json();E(e=>[...t.messages,...e])}finally{O(!1)}}};(0,P.useEffect)(()=>{if(!g)return;let e=document.getElementById(`msg-${g}`);e&&(e.scrollIntoView({block:`center`}),e.classList.add(`ring-2`,`ring-ember`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-ember`),2500))},[g,A.length]);let M=A.filter(e=>e.prefix===`DAVID_DECISION`&&!e.answered),N=(_?.members??[]).map(e=>l.find(t=>t.agentId===e)??{agentId:e,liveness:`dead`,pane:null,role:void 0,active:!1}),ee=e=>Date.now()-e.lastTs<3e5,F=e=>{let t=new URLSearchParams(n);for(let[n,r]of Object.entries(e))r===null?t.delete(n):t.set(n,r);r(t,{replace:!0})},I=!!v&&k.length<v.total,te=!!q(`/admin/bus-writes`,1e4).data?.enabled,[ne,re]=(0,P.useState)(`david`),[L,R]=(0,P.useState)(``),[z,ie]=(0,P.useState)(!1),[ae,oe]=(0,P.useState)(null),[se,ce]=(0,P.useState)(null),le=Wu(),[ue,de]=(0,P.useState)(null),fe=q(`/bus/unread`,3e4).data?.inbox??0,pe=`#${f}`,me=async()=>{ie(!0),oe(null);try{let e=pe.startsWith(`#`)?{room:pe.slice(1)}:{to:pe.replace(/^@/,``)},t=await Fa(`/actions/send`,{as:ne,...e,text:le.withRefs(L),answers:se?.id?[se.id]:void 0,kind:/^DAVID_DECISION/.test(L)?`decision`:void 0});if(t.status!==`ok`)throw Error(t.error??t.log?.slice(-1)[0]??`failed`);R(``),ce(null),le.clear()}catch(e){oe(e.message)}finally{ie(!1)}};return(0,B.jsxs)(`div`,{className:`grid ${M.length>0?`grid-cols-[240px_1fr_320px]`:`grid-cols-[240px_1fr]`} gap-4 p-4 max-[980px]:grid-cols-1`,children:[ue&&(0,B.jsx)(Ju,{agentId:ue,onClose:()=>de(null)}),(0,B.jsxs)(`aside`,{className:`bg-cream -m-4 mr-0 px-2 py-4 border-r border-sand min-w-0 overflow-auto`,children:[(0,B.jsx)(qd,{children:`Rooms · list_rooms`}),h.map(e=>(0,B.jsxs)(`button`,{onClick:()=>F({room:e.room,view:null,msg:null}),className:`w-full text-left grid grid-cols-[1fr_auto] gap-2 px-2 py-1.5 rounded-kit font-mono text-[13px] border-0 cursor-pointer ${d===`room`&&e.room===f?`bg-paper text-walnut shadow-[inset_0_0_0_1px_var(--color-sand)]`:`bg-transparent text-umber hover:bg-linen`}`,children:[(0,B.jsxs)(`span`,{className:`truncate flex items-center gap-1.5`,children:[ee(e)&&(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-moss`,title:`message in the last 5 min`}),`#`,e.room]}),(0,B.jsx)(`span`,{className:`font-semibold text-[11px] px-1.5 py-0.5 rounded-full bg-linen text-umber`,children:e.messageCount})]},e.room)),m.length>0&&(0,B.jsxs)(`button`,{onClick:()=>o(e=>!e),className:`w-full text-left px-2 py-1 font-mono text-[11px] text-tan border-0 bg-transparent cursor-pointer hover:text-umber`,children:[a?`▾ hide`:`▸ show`,` `,m.length,` quiet room`,m.length===1?``:`s`,` (no traffic in 7 d)`]}),(0,B.jsx)(qd,{children:`Direct · inbox`}),(0,B.jsxs)(`button`,{onClick:()=>F({view:`inbox`,msg:null}),className:`w-full text-left grid grid-cols-[1fr_auto] gap-2 px-2 py-1.5 rounded-kit font-mono text-[13px] border-0 cursor-pointer ${d===`inbox`?`bg-paper text-walnut shadow-[inset_0_0_0_1px_var(--color-sand)]`:`bg-transparent text-umber hover:bg-linen`}`,children:[(0,B.jsx)(`span`,{children:`@david · my DMs`}),fe>0&&(0,B.jsxs)(`span`,{className:`font-semibold text-[11px] px-1.5 py-0.5 rounded-full bg-ember-wash text-ember-deep`,children:[fe,` unread`]})]}),(0,B.jsx)(qd,{children:`Status stream`}),(0,B.jsx)(`button`,{onClick:()=>F({view:`status`,msg:null}),className:`w-full text-left px-2 py-1.5 rounded-kit font-mono text-[13px] border-0 cursor-pointer ${d===`status`?`bg-paper text-walnut shadow-[inset_0_0_0_1px_var(--color-sand)]`:`bg-transparent text-umber hover:bg-linen`}`,children:`post_status feed`})]}),d===`inbox`?(0,B.jsxs)(U,{className:`min-w-0`,children:[(0,B.jsxs)(W,{title:`Inbox · david`,icon:`bus`,path:`read_messages source=inbox · unread = bus cursor`,children:[x.data&&(x.data.unread>0?(0,B.jsxs)(G,{tone:`david`,children:[x.data.unread,` unread`]}):(0,B.jsx)(G,{tone:`outline`,children:`all read`})),x.data&&x.data.unread>0&&(0,B.jsx)(K,{size:`sm`,onClick:w,disabled:S,children:S?`…`:`Mark all read`})]}),x.error&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-brick`,children:x.error}),x.data&&x.data.messages.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`No DMs to david.`}),(x.data?.messages??[]).slice().reverse().map((e,t)=>{let n=String(e.text??``),r=n.match(/^(BLOCKER|RISK|DONE|FYI|AGENT_ACTION|GO|SCOPE CHANGE|VERDICT|DAVID_DECISION)\b/)?.[1]??null;return(0,B.jsxs)(`div`,{className:`grid grid-cols-[var(--spacing-gutter)_1fr] border-b border-sand last:border-b-0 ${e.unread?`bg-ember-wash/35`:``}`,children:[(0,B.jsx)(`div`,{className:`py-2.5 flex justify-center font-mono text-[12px] border-r border-sand ${e.unread?`text-ember font-bold`:`text-tan`}`,children:e.unread?`●`:`@`}),(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-baseline mb-0.5`,children:[(0,B.jsx)(`span`,{className:`font-semibold text-[13px]`,children:e.from}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,children:[Yd(e.ts),` `,Jd(e.ts)]}),te&&e.from&&(0,B.jsx)(`button`,{className:`ml-auto font-mono text-[12px] text-ember-deep bg-transparent border-0 cursor-pointer`,onClick:()=>id(e.from),title:`open the DM thread with this agent (Summon)`,children:`reply →`})]}),(0,B.jsxs)(`div`,{className:`whitespace-pre-wrap break-words text-[14px]`,children:[Xd(r)&&(0,B.jsx)(Da,{prefix:r,fail:r===`VERDICT`&&/FAIL/.test(n)}),Zd(n,r)]})]})]},e.id??t)})]}):d===`status`?(0,B.jsxs)(U,{className:`min-w-0`,children:[(0,B.jsx)(W,{title:`Status stream`,icon:`health`,path:`~/agent-coord/status.jsonl · post_status`}),b.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`empty`}),b.slice().reverse().map((e,t)=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[var(--spacing-gutter)_1fr] border-b border-sand last:border-b-0`,children:[(0,B.jsx)(`div`,{className:`py-2.5 flex justify-center font-mono text-[12px] text-tan border-r border-sand`,children:`◌`}),(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-baseline mb-0.5`,children:[(0,B.jsx)(`span`,{className:`font-semibold text-[13px]`,children:e.agentId??e.from}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,children:[Yd(e.ts),` `,Jd(e.ts)]})]}),(0,B.jsxs)(`div`,{className:`text-[14px]`,children:[(0,B.jsx)(G,{tone:`outline`,children:e.status??`?`}),e.detail&&(0,B.jsx)(`span`,{className:`ml-2 text-umber`,children:e.detail})]})]})]},t))]}):(0,B.jsxs)(U,{className:`grid grid-rows-[auto_auto_1fr_auto] min-h-0 min-w-0`,children:[(0,B.jsx)(W,{title:`#${f}`,icon:`room`,path:v?`${v.total} messages`:``,children:(0,B.jsxs)(G,{tone:`outline`,children:[_?.members?.length??0,` members`]})}),fe>0&&(0,B.jsxs)(`button`,{onClick:()=>F({view:`inbox`,msg:null}),className:`mx-3 mb-1.5 text-left bg-ember-wash/60 border border-ember-line rounded-kit px-3 py-2 text-[13px] text-ember-deep cursor-pointer flex items-center gap-2`,children:[(0,B.jsxs)(`span`,{className:`font-semibold`,children:[fe,` unread DM`,fe===1?``:`s`,` to david`]}),(0,B.jsx)(`span`,{className:`text-umber`,children:`— open your inbox →`})]}),N.length>0&&(0,B.jsxs)(`div`,{className:`mx-3 mb-1.5 flex items-center gap-1.5 flex-wrap font-mono text-[11px] text-tan`,children:[(0,B.jsx)(`span`,{className:`uppercase tracking-[.08em]`,children:`members`}),N.map(e=>(0,B.jsxs)(`button`,{onClick:()=>id(e.agentId),title:`${e.agentId} · DM`,className:`inline-flex items-center gap-1 border-0 bg-transparent p-0 cursor-pointer text-umber`,children:[(0,B.jsx)(Mu,{id:e.agentId,role:e.role,size:14,state:e.liveness,active:e.active}),(0,B.jsx)(`span`,{children:e.agentId})]},e.agentId)),(0,B.jsx)(`span`,{className:`ml-auto`,children:(0,B.jsx)(`button`,{onClick:()=>c(e=>!e),className:`border border-dust rounded-full w-5 h-5 text-[11px] bg-paper text-umber cursor-pointer`,title:`prefix key`,children:`?`})})]}),s&&(0,B.jsxs)(`div`,{className:`mx-3 mb-1.5 flex flex-wrap gap-1.5 items-center`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan mr-1`,children:`rooms need a prefix:`}),Ta.map(e=>(0,B.jsx)(Da,{prefix:e},e))]}),(_?.topic||_?.motd)&&(0,B.jsxs)(`div`,{className:`mx-3 mb-1.5 bg-linen border-l-[3px] border-dust px-3 py-2 text-[13px] leading-[1.5] text-umber`,children:[_.topic&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{children:`Topic`}),` · `,_.topic]}),_.motd&&(0,B.jsxs)(`div`,{className:`mt-1 whitespace-pre-line line-clamp-4`,children:[(0,B.jsx)(`b`,{children:`MOTD`}),` · `,_.motd]})]}),(0,B.jsx)(`div`,{className:`overflow-auto max-h-[70vh] flex flex-col-reverse`,children:(0,B.jsxs)(`div`,{children:[I&&(0,B.jsx)(`div`,{className:`px-3 py-2 border-b border-sand text-center`,children:(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:j,disabled:D,children:D?`loading…`:`Load older (${v.total-k.length} more)`})}),y&&(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px] text-brick`,children:[`API error: `,y]}),A.length===0&&!y&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`No messages yet.`}),A.slice().reverse().map((e,t)=>{let n=e.prefix===`DAVID_DECISION`&&!e.answered,r=n||e.kind===`decision`,i=typeof e.text==`string`?e.text:e.raw??``;return(0,B.jsxs)(`div`,{id:e.id?`msg-${e.id}`:void 0,className:`grid grid-cols-[var(--spacing-gutter)_1fr] border-b border-sand transition-shadow ${n?`bg-ember-wash/45`:r?`bg-linen/50`:``}`,children:[(0,B.jsx)(`div`,{className:`py-2.5 flex justify-center font-mono font-medium text-[12px] border-r border-sand select-none ${n?`text-ember`:r?`text-umber`:`text-tan`}`,children:n?`★`:r?`◆`:e.to?`@`:`#`}),(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-center mb-0.5`,children:[(0,B.jsx)(Mu,{id:e.from??`?`,role:l.find(t=>t.agentId===e.from)?.role,size:14,state:l.find(t=>t.agentId===e.from)?.liveness??`dead`}),(0,B.jsx)(`span`,{className:`font-semibold text-[13px]`,children:e.from}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,title:new Date(e.ts??0).toLocaleString(),children:[Yd(e.ts),` `,Jd(e.ts)]}),n&&(0,B.jsx)(G,{tone:`david`,children:`needs David`}),e.kind&&e.kind!==`chatter`&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:e.kind})]}),(0,B.jsxs)(`div`,{className:`whitespace-pre-wrap break-words text-[14px]`,children:[Xd(e.prefix)&&(0,B.jsx)(Da,{prefix:e.prefix,fail:e.prefix===`VERDICT`&&/FAIL/.test(i)}),e.prefix===`DAVID_DECISION`&&e.answered&&(0,B.jsx)(G,{tone:`ok`,children:`answered`}),(0,B.jsx)(Ku,{text:Zd(i,e.prefix)})]})]})]},e.id??t)})]})}),(0,B.jsxs)(`div`,{className:`border-t border-sand px-3 py-2.5 grid gap-1.5`,children:[se&&(0,B.jsxs)(`div`,{className:`text-[12px] text-umber flex gap-2 items-center`,children:[(0,B.jsxs)(`span`,{className:`font-mono`,children:[`replying to `,se.from,` · `,Jd(se.ts)]}),(0,B.jsx)(`button`,{className:`border-0 bg-transparent text-ink3 cursor-pointer`,onClick:()=>{ce(null),R(``)},children:`✕`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-[auto_auto_1fr_auto] gap-2 items-center`,children:[(0,B.jsxs)(`select`,{value:ne,onChange:e=>re(e.target.value),disabled:!te,className:`text-[13px] px-2 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`,title:`send as`,children:[(0,B.jsx)(`option`,{value:`david`,children:`as david`}),(0,B.jsx)(`option`,{value:`groundwork-console`,children:`as groundwork-console`})]}),(0,B.jsxs)(`span`,{className:`font-mono text-[13px] px-2 py-2 border border-dust rounded-kit bg-cream text-umber`,title:`rooms post here; DMs go through Summon (bottom-right)`,children:[`#`,f]}),(0,B.jsx)(`input`,{value:L,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&te&&le.hasContent(L)&&me()},onPaste:le.onPaste,onDrop:le.onDrop,onDragOver:le.onDragOver,disabled:!te,className:`text-[13px] px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`,placeholder:te?pe.startsWith(`#`)?`FYI: … (rooms need a prefix)`:`message…`:`bus writes are off — enable in the header`}),(0,B.jsx)(K,{tone:`primary`,size:`sm`,onClick:me,disabled:!te||z||le.busy||!le.hasContent(L),children:z?`Sending…`:`Send`})]}),(0,B.jsx)(Gu,{a:le}),ae&&(0,B.jsx)(`div`,{className:`text-[12px] text-brick`,children:ae}),te&&(0,B.jsxs)(`div`,{className:`text-[11px] font-mono text-tan`,children:[`every send is a Run · rooms require a prefix · `,(0,B.jsx)(`span`,{className:`text-ember-deep`,children:`DAVID_DECISION:`}),` replies are pinned (kind: decision)`]})]})]}),M.length>0&&(0,B.jsx)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:M.slice(0,1).map(e=>(0,B.jsxs)(`div`,{className:`border border-ember border-l-4 rounded-kit bg-paper`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between items-center px-3 py-2 border-b border-sand`,children:[(0,B.jsx)(Da,{prefix:`DAVID_DECISION`}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[Jd(e.ts),` · `,e.from]})]}),(0,B.jsx)(`div`,{className:`px-3 py-2.5 text-[13px] whitespace-pre-wrap break-words line-clamp-6`,children:Zd(e.text??``,e.prefix)}),(0,B.jsxs)(`div`,{className:`flex gap-2 px-3 py-2 border-t border-sand`,children:[(0,B.jsx)(K,{tone:`primary`,size:`sm`,disabled:!te,onClick:()=>{ce(e),re(`david`),R(`DAVID_DECISION: `)},children:`Reply as David`}),!te&&(0,B.jsx)(Aa,{})]})]},e.id))})]})}var ef=[[/^PRD\.md$/i,`PRD`,`docs`],[/^CONTEXT(-MAP)?\.md$/i,`Context`,`docs`],[/^TECH_STACK\.md$/i,`Tech stack`,`kit`],[/^STACK_MAP\.md$/i,`Stack map`,`kit`],[/^ARCHITECTURE_GUIDE\.md$/i,`Architecture guide`,`board`],[/^DECISIONS\.md$/i,`Decisions (ADRs)`,`decisions`],[/^PRODUCTION_ROADMAP\.md$/i,`Roadmap`,`phases`],[/^WORKSTREAMS\.md$/i,`Workstreams`,`streams`],[/^QUEUE\.md$/i,`Queue`,`queue`],[/^DONE\.md$/i,`Done`,`done`],[/^FACTS\.md$/i,`Facts`,`facts`],[/^DESIGN_SYSTEM\.md$/i,`Design system`,`skills`],[/^GROUNDWORK_METHODOLOGY\.md$/i,`Methodology`,`knowledge`],[/^COMMANDS\.md$/i,`Commands`,`gates`],[/^_INDEX\.md$/i,`Index`,`home`],[/^ARTIFACTS\.md$/i,`Artifacts`,`kit`]],tf=/^(templates\/|phases\/templates\/|\.groundwork\/)/,nf=/^(QUEUE|DONE|WORKSTREAMS|FACTS)\.md$/i,rf=e=>ef.find(([t])=>t.test(e)),af=({children:e})=>(0,B.jsx)(`div`,{className:`font-mono font-semibold text-[11px] uppercase tracking-[.1em] text-ink3 mt-4 mb-1.5 first:mt-0`,children:e}),of=e=>{if(!e)return``;let t=Date.now()-Date.parse(e),n=Math.floor(t/864e5);return n>0?`${n} d ago`:`${Math.max(1,Math.floor(t/36e5))} h ago`};function sf(){let{current:e}=za(),{doc:t}=lr(),n=q(e?`/projects/${e}/docs`:null,2e4),r=n.data,i=r?.files??[],a=t?decodeURIComponent(t):i.find(e=>/^(README|_INDEX|DESIGN|PRD)\.md$/i.test(e))??i[0],o=!!a&&a.startsWith(`kb:`),s=q(`/knowledge`,6e4).data,c=q(a?o?`/knowledge/doc/${encodeURIComponent(a.slice(3))}`:e?`/projects/${e}/docs/${encodeURIComponent(a)}`:null:null,15e3),{data:l,error:u,loading:d}=c,f=!!a&&(nf.test(a)||o),p=q(`/admin/seam-writes`,1e4).data?.enabled??!1,[m,h]=(0,P.useState)(!1),[g,_]=(0,P.useState)(``),[v,y]=(0,P.useState)(``),[b,x]=(0,P.useState)(``),[S,C]=(0,P.useState)(null),w=m&&g!==v,[T,E]=(0,P.useState)(!0),[D,O]=(0,P.useState)(!0),[k]=Fi(),A=ar(),j=e=>{let t=e.replace(/^#\/docs\//,``).split(`#`)[0];if(!t||/^(https?:|mailto:)/.test(e))return null;let n=(a??``).split(`/`).slice(0,-1).join(`/`),r=(t.startsWith(`/`)?t.slice(1):(n?n+`/`:``)+t).split(`/`).reduce((e,t)=>(t===`..`?e.pop():t&&t!==`.`&&e.push(t),e),[]).join(`/`),o=[r,`${r}.md`,decodeURIComponent(r),`${decodeURIComponent(r)}.md`];return i.find(e=>o.some(t=>e.toLowerCase()===t.toLowerCase()))??null},M=e=>{let t=e.target.closest(`a`);if(!t)return;let n=t.getAttribute(`href`)??``;if(/^(https?:|mailto:)/.test(n))return;let r=j(n);if(e.preventDefault(),r){if(m&&w&&!window.confirm(`Discard unsaved edits?`))return;A(`/docs/${encodeURIComponent(r)}`)}else t.classList.add(`no-target`)},[N,ee]=(0,P.useState)(k.get(`view`)??`rendered`),F=k.get(`line`)?Number(k.get(`line`)):null;(0,P.useEffect)(()=>{let e=k.get(`view`);(e===`source`||e===`split`||e===`rendered`)&&ee(e)},[k]),(0,P.useEffect)(()=>{if(!F||!l)return;let e=setTimeout(()=>{document.getElementById(`L${F}`)?.scrollIntoView({block:`center`})},100);return()=>clearTimeout(e)},[F,l,N]),(0,P.useEffect)(()=>{h(!1),_(``),y(``),x(``),C(null)},[a,e]),(0,P.useEffect)(()=>{!m||w||!l||l.source===v||(_(l.source),y(l.source),x(l.sha))},[l,m,w,v]),(0,P.useEffect)(()=>{if(!w)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[w]);let I=()=>{!l||f||(_(l.source),y(l.source),x(l.sha),h(!0),ee(`split`),C(null))},te=()=>{h(!1),_(``),y(``),x(``),C(null)},ne=(0,P.useCallback)(async()=>{if(!(!e||!a||!b)){C(`saving`);try{let t=await Ia(e,a,{content:g,ifMatch:b});x(t.sha),y(g),C(`saved`),c.refresh(),n.refresh()}catch(e){C(e.message)}}},[e,a,b,g,c,n]);(0,P.useEffect)(()=>{if(!m)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),p&&w&&S!==`saving`&&ne())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m,p,w,S,ne]);let re=e=>{m&&w&&!window.confirm(`Discard unsaved edits?`)&&e.preventDefault()},L=m?g:l?.source??``,R=l?.git,z=(0,P.useMemo)(()=>{let e=[];return R?.lastCommit&&D&&e.push({kind:`commit`,label:`${R.lastCommit.short} · ${R.lastCommit.subject} · ${R.lastCommit.author} · ${of(R.lastCommit.date)}`,hunks:R.lastCommit.hunks}),R&&T&&R.uncommitted.length&&e.push({kind:`uncommitted`,label:`working tree vs HEAD`,hunks:R.uncommitted}),e},[R,D,T]),ie=new Set(r?.lastCommit?.files??[]),ae=q(e?`/projects/${e}/agents`:null,3e4).data??{aide:null,coordinator:null};return(0,B.jsxs)(`div`,{className:`grid grid-cols-[260px_1fr_320px] min-h-full max-[1100px]:grid-cols-1`,children:[(0,B.jsxs)(`nav`,{className:`bg-cream border-r border-sand px-4 py-[18px] max-[1100px]:hidden overflow-auto max-h-[calc(100vh-48px)]`,children:[(0,B.jsx)(af,{children:`${e||`project`} · docs/`}),i.length===0&&(0,B.jsx)(`div`,{className:`text-[12px] text-umber px-1.5`,children:`no docs/ found`}),(()=>{let e=i.filter(e=>!tf.test(e)),t=ef.map(([t])=>e.find(e=>t.test(e))).filter(e=>!!e),n=e.filter(e=>/^phases\//.test(e)&&!t.includes(e)),o=e.filter(e=>!t.includes(e)&&!n.includes(e)),s=({f:e,label:t,icon:n})=>{let i=r?.status[e];return(0,B.jsxs)(V,{to:`/docs/${encodeURIComponent(e)}`,onClick:re,className:`grid grid-cols-[16px_1fr_auto] gap-2 items-center text-[13px] leading-[1.75] px-1.5 py-0.5 rounded hover:no-underline ${e===a?`text-walnut bg-linen`:`text-ink3`}`,title:e,children:[(0,B.jsx)(`span`,{className:`${e===a?`text-umber`:`text-tan`}`,children:n?Ca[n]({size:14}):Ca.docs({size:14})}),(0,B.jsx)(`span`,{className:`truncate ${t?`font-sans`:`font-mono`}`,children:t??e.replace(/^phases\//,``)}),(0,B.jsxs)(`span`,{className:`flex gap-1 items-center`,children:[i===`??`?(0,B.jsx)(`span`,{className:`text-[10px] font-mono font-semibold text-tan`,children:`new`}):i?(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-amber`,title:`uncommitted (${i})`}):null,ie.has(e)&&(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-leaf`,title:`in last commit ${r?.lastCommit?.short}`})]})]},e)};return(0,B.jsxs)(B.Fragment,{children:[t.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-2 mb-1 px-1.5`,children:`Kit docs`}),t.map(e=>{let t=rf(e);return(0,B.jsx)(s,{f:e,label:t[1],icon:t[2]},e)})]}),n.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-3 mb-1 px-1.5`,children:`Phases`}),n.map(e=>(0,B.jsx)(s,{f:e,icon:`phases`},e))]}),o.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-3 mb-1 px-1.5`,children:[`Other docs · `,o.length]}),o.map(e=>(0,B.jsx)(s,{f:e},e))]}),i.length!==e.length&&(0,B.jsxs)(`div`,{className:`font-mono text-[10px] text-tan mt-2 px-1.5`,children:[i.length-e.length,` hidden (templates/, .groundwork/)`]})]})})(),r?.lastCommit&&(0,B.jsxs)(`div`,{className:`mt-3 px-1.5 text-[11px] font-mono text-ink3 leading-[1.5]`,children:[(0,B.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full bg-leaf mr-1`}),`last docs commit `,(0,B.jsx)(`b`,{className:`text-walnut`,children:r.lastCommit.short}),` · `,of(r.lastCommit.date),(0,B.jsx)(`div`,{className:`truncate text-tan`,title:r.lastCommit.subject,children:r.lastCommit.subject})]}),(0,B.jsx)(af,{children:`Knowledge · global${s?.exists?``:` · not configured`}`}),s&&!s.exists&&(0,B.jsxs)(`div`,{className:`text-[12px] text-umber px-1.5`,children:[`No knowledge repo — run `,(0,B.jsx)(`code`,{children:`groundwork knowledge init`}),` (or `,(0,B.jsx)(`code`,{children:`link <dir>`}),`).`]}),s?.exists&&(()=>{let e=({file:e,label:t,sub:n,icon:r=`knowledge`})=>{let i=`kb:${e}`;return(0,B.jsxs)(V,{to:`/docs/${encodeURIComponent(i)}`,onClick:re,className:`grid grid-cols-[16px_1fr_auto] gap-2 items-center text-[13px] leading-[1.6] px-1.5 py-0.5 rounded hover:no-underline ${i===a?`text-walnut bg-linen`:`text-ink3`}`,title:e,children:[(0,B.jsx)(`span`,{className:i===a?`text-umber`:`text-tan`,children:Ca[r]({size:14})}),(0,B.jsx)(`span`,{className:`truncate`,children:t}),n&&(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-tan`,children:n})]},i)};return(0,B.jsxs)(B.Fragment,{children:[s.index&&(0,B.jsx)(e,{file:s.index,label:`ADR index`,icon:`board`}),s.sections.map(t=>{let n=s.adrs.filter(e=>e.section===t);return n.length?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-2 mb-0.5 px-1.5`,children:t}),n.map(t=>(0,B.jsx)(e,{file:t.file,label:`${t.id} · ${t.title}`,sub:t.enf??void 0},t.file))]},t):null}),s.adrs.some(e=>e.section===`(not in INDEX)`)&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-2 mb-0.5 px-1.5`,children:`ADRs not in index`}),s.adrs.filter(e=>e.section===`(not in INDEX)`).map(t=>(0,B.jsx)(e,{file:t.file,label:`${t.id} · ${t.title}`},t.file))]}),s.notes.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-2 mb-0.5 px-1.5`,children:[`Notes · `,s.notes.length]}),s.notes.map(t=>(0,B.jsx)(e,{file:t.file,label:t.title??t.file.replace(/^notes\//,``),icon:`docs`},t.file))]}),(0,B.jsx)(`div`,{className:`font-mono text-[10px] text-tan mt-2 px-1.5 truncate`,title:`${s.path} · ${s.source}`,children:s.path?.replace(/^\/Users\/[^/]+/,`~`)})]})})()]}),(0,B.jsxs)(`main`,{className:`px-10 py-7 pb-16 bg-paper min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-2 flex-wrap`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3 truncate`,children:[l?.path??a??``,d&&` · loading…`,m&&w&&` · unsaved`]}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 items-center flex-wrap`,children:[R&&!R.repo&&(0,B.jsx)(G,{tone:`outline`,children:`not a git repo`}),R?.repo&&R.untracked&&(0,B.jsx)(G,{tone:`warn`,children:`untracked file`}),R?.repo&&R.tracked&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{onClick:()=>E(e=>!e),"aria-pressed":T,className:`inline-flex items-center gap-1.5 font-mono text-[12px] px-2 py-1 rounded-full border cursor-pointer ${T&&R.uncommitted.length?`bg-amber-wash text-amber border-amber-line`:`bg-paper text-umber border-dust`}`,title:`working tree vs HEAD`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-amber`}),`uncommitted · `,R.uncommitted.length,` hunk`,R.uncommitted.length===1?``:`s`]}),R.lastCommit&&(0,B.jsxs)(`button`,{onClick:()=>O(e=>!e),"aria-pressed":D,className:`inline-flex items-center gap-1.5 font-mono text-[12px] px-2 py-1 rounded-full border cursor-pointer ${D?`bg-moss-wash text-moss border-moss-line`:`bg-paper text-umber border-dust`}`,title:`${R.lastCommit.subject} · ${R.lastCommit.author}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-leaf`}),`last commit `,R.lastCommit.short,` · `,of(R.lastCommit.date)]})]}),(0,B.jsx)(`span`,{className:`w-px h-5 bg-sand mx-1`}),(0,B.jsx)(K,{tone:`ghost`,size:`sm`,"aria-pressed":N===`rendered`,onClick:()=>ee(`rendered`),children:`Rendered`}),(0,B.jsx)(K,{tone:`ghost`,size:`sm`,"aria-pressed":N===`source`,onClick:()=>ee(`source`),children:`Source`}),(0,B.jsx)(K,{tone:`ghost`,size:`sm`,"aria-pressed":N===`split`,onClick:()=>ee(`split`),children:`Split`}),(0,B.jsx)(`span`,{className:`w-px h-5 bg-sand mx-1`}),o?(0,B.jsxs)(`span`,{className:`font-mono text-[11px] text-tan`,title:s?.path??``,children:[`global knowledge · read-only here · edit in `,s?.path?.replace(/^\/Users\/[^/]+/,`~`)]}):f?(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,title:`QUEUE/DONE/WORKSTREAMS/FACTS write through the Board (seam)`,children:`seam file · edit on Board`}):m?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(K,{size:`sm`,onClick:te,children:`Discard`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>void ne(),disabled:!p||!w||S===`saving`||!b,title:p?`Save to docs/ (⌘S)`:`seam writes are off (header → seam)`,children:S===`saving`?`Saving…`:`Save`}),!p&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`seam writes are off (header → seam)`}),S===`saved`&&!w&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-moss`,children:`saved`}),S&&S!==`saving`&&S!==`saved`&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-brick max-w-[28ch] truncate`,title:S,children:S})]}):(0,B.jsx)(K,{size:`sm`,onClick:I,disabled:!l,title:`Edit this file in Split (source + preview). Save writes docs/ as a Run.`,children:`Edit`})]})]}),u&&(0,B.jsxs)(`div`,{className:`text-[13px] text-brick`,children:[`Could not load: `,u]}),l&&N===`rendered`&&(0,B.jsx)(`div`,{onClick:M,children:(0,B.jsx)(bu,{source:L,changes:m?[]:z})}),l&&N===`source`&&(m?(0,B.jsx)(cf,{value:g,onChange:_,readOnly:!p}):(0,B.jsx)(lf,{src:l.source,g:R,showUncommitted:T,showCommit:D,jumpLine:F})),l&&N===`split`&&(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 items-start`,children:[(0,B.jsx)(`div`,{className:`min-w-0`,onClick:M,children:(0,B.jsx)(bu,{source:L,changes:m?[]:z})}),(0,B.jsx)(`div`,{className:`min-w-0 sticky top-2`,children:m?(0,B.jsx)(cf,{value:g,onChange:_,readOnly:!p}):(0,B.jsx)(lf,{src:l.source,g:R,showUncommitted:T,showCommit:D,jumpLine:F})})]}),l&&z.length>0&&(0,B.jsxs)(`div`,{className:`mt-6 text-[12px] font-mono text-ink3`,children:[`Hover a highlighted block for its diff · `,(0,B.jsx)(`span`,{className:`text-amber`,children:`amber`}),` = uncommitted, `,(0,B.jsx)(`span`,{className:`text-leaf`,children:`green`}),` = last commit touching this file.`]})]}),(0,B.jsxs)(`aside`,{className:`bg-cream border-l border-sand p-3.5 max-[1100px]:hidden`,children:[(0,B.jsx)(`div`,{className:`flex justify-between items-center px-1 pt-1.5 pb-2`,children:(0,B.jsx)(`span`,{className:`font-semibold text-[13px] uppercase tracking-[.08em] text-umber`,children:`Ask an agent`})}),(0,B.jsxs)(`div`,{className:`grid gap-2 px-1 text-[13px]`,children:[(0,B.jsxs)(`div`,{className:`text-[12px] text-umber`,children:[`Summon opens the DM thread with its context line set to `,(0,B.jsxs)(`code`,{className:`font-mono text-[11px]`,children:[o?`groundwork-knowledge/${a.slice(3)}`:`${e}/docs/${a}`,F?`:${F}`:``]}),F?``:` — select a line in Source view (or Show line) to cite it`,`.`]}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap`,children:[(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>id(ae.aide??``),disabled:!ae.aide,title:ae.aide?`DM ${ae.aide} about this doc`:`no live aide`,children:`Aide`}),(0,B.jsx)(K,{size:`sm`,onClick:()=>id(ae.coordinator??``),disabled:!ae.coordinator,title:ae.coordinator?`DM ${ae.coordinator}`:`no live coordinator`,children:`Coordinator`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>id(``),title:`pick from the radial`,children:`Other…`})]})]}),R?.lastCommit&&(0,B.jsxs)(`div`,{className:`mt-4 px-1 text-[12px] font-mono text-ink3 leading-[1.6]`,children:[(0,B.jsx)(`div`,{className:`text-umber font-sans font-semibold text-[13px] mb-1`,children:`Last change to this file`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:R.lastCommit.short}),` · `,R.lastCommit.author]}),(0,B.jsx)(`div`,{children:new Date(R.lastCommit.date).toLocaleString()}),(0,B.jsx)(`div`,{className:`text-walnut mt-1 font-sans`,children:R.lastCommit.subject}),(0,B.jsxs)(`div`,{className:`mt-1 text-tan`,children:[R.lastCommit.hunks.length,` hunk`,R.lastCommit.hunks.length===1?``:`s`]})]})]})]})}function cf({value:e,onChange:t,readOnly:n}){return(0,B.jsx)(`textarea`,{value:e,onChange:e=>t(e.target.value),readOnly:n,spellCheck:!1,"aria-label":`Document source`,className:`w-full min-h-[70vh] font-mono text-[13px] leading-[1.6] whitespace-pre bg-linen border border-sand rounded-kit p-4 text-walnut resize-y ${n?`opacity-80`:``}`})}function lf({src:e,g:t,showUncommitted:n,showCommit:r,jumpLine:i}){let a=(e,t)=>!!e?.some(e=>gu(e).some(([e,n])=>t>=e&&t<n));return(0,B.jsx)(`pre`,{className:`font-mono text-[13px] leading-[1.6] whitespace-pre-wrap bg-linen border border-sand rounded-kit p-4 m-0 max-h-[80vh] overflow-auto`,children:e.split(`
35
- `).map((e,o)=>{let s=o+1,c=n&&a(t?.uncommitted,s),l=r&&a(t?.lastCommit?.hunks,s),u=i===s;return(0,B.jsxs)(`div`,{id:`L${s}`,className:`grid grid-cols-[3.5ch_1fr] gap-3 rounded-[2px] ${u?`bg-ember-wash ring-1 ring-ember`:c?`bg-amber-wash/60`:l?`bg-moss-wash/50`:``}`,children:[(0,B.jsx)(`span`,{className:`text-right select-none ${u?`text-ember font-semibold`:`text-tan`}`,children:s}),(0,B.jsx)(`span`,{children:e||` `})]},o)})})}var uf=e=>/done|merged|deployed|complete|closed|✅/i.test(e),df=e=>uf(e)?`ok`:/block/i.test(e)?`bad`:/queued|hold|wait/i.test(e)?`warn`:`neutral`;function ff({project:e}){let t=q(e?`/projects/${e}/board`:null,15e3).data,n=q(`/bus/agents`,2e4).data??[];if(!t)return null;let r=t.phases.find(e=>e.state===`ongoing`)??t.phases.find(e=>e.state===`planned`),i=t.workstreams.rows.filter(e=>!(`malformed`in e)).map(e=>e.schema===`workstreams.v1`?{name:e.stream,owner:e.owner,status:e.status,note:e.lastNote}:{name:e.lane,owner:e.owner,status:e.state,note:e.currentSlice}).filter(e=>!uf(e.status)),a=e=>n.find(t=>t.agentId===e||e.includes(t.agentId))?.agentId??null;return(0,B.jsxs)(`div`,{className:`border border-sand rounded-kit bg-paper px-3 py-2 grid gap-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan`,children:`now`}),r?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(V,{to:`/board`,className:`font-semibold text-[13px] hover:no-underline text-walnut hover:text-ember-deep`,children:r.title}),(0,B.jsx)(G,{tone:r.state===`ongoing`?`david`:`neutral`,children:r.state}),(0,B.jsxs)(`span`,{className:`font-mono text-[11px] text-ink3`,children:[r.done,`/`,r.total,` tasks`,r.streams?` · ${r.streams} streams`:``]})]}):(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:`no phase in flight`}),(0,B.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-ink3`,children:[i.length,` active stream`,i.length===1?``:`s`]})]}),i.length>0&&(0,B.jsx)(`div`,{className:`flex gap-1.5 flex-wrap`,children:i.slice(0,8).map(e=>{let t=a(e.owner);return(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-kit border border-sand bg-cream/60 max-w-[360px]`,title:`${e.name} · ${e.owner} · ${e.status}${e.note?` · ${e.note}`:``}`,children:[t?(0,B.jsx)($u,{id:t,bare:!0,size:`sm`}):(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[12px] text-umber`,children:[(0,B.jsx)(Mu,{id:e.owner,size:14,state:`dead`}),e.owner]}),(0,B.jsx)(`span`,{className:`text-[12px] truncate`,children:e.name}),(0,B.jsx)(G,{tone:df(e.status),children:e.status.replace(/^[^\w]+/,``).slice(0,18)})]},e.name)})})]})}var pf=`/api`,mf=e=>{if(!e)return`—`;let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t} s`:t<3600?`${Math.floor(t/60)} min`:`${Math.floor(t/3600)} h`};function hf(){let{current:e}=za(),{linkify:t}=Eu(),[n,r]=(0,P.useState)(`project`),[i,a]=(0,P.useState)(40),[o,s]=(0,P.useState)(2),[c,l]=(0,P.useState)(()=>localStorage.getItem(`groundwork-console.monitor.layout`)??`grid`),[u,d]=(0,P.useState)(()=>Number(localStorage.getItem(`groundwork-console.monitor.tileW`)??520));(0,P.useEffect)(()=>{localStorage.setItem(`groundwork-console.monitor.layout`,c),localStorage.setItem(`groundwork-console.monitor.tileW`,String(u))},[c,u]);let[f,p]=(0,P.useState)([]),[m,h]=(0,P.useState)(null),[g,_]=(0,P.useState)(null),[v,y]=(0,P.useState)(!1),[b,x]=(0,P.useState)(!0),[S,C]=(0,P.useState)(0),w=q(n===`project`&&e?`/projects/${e}/board`:null,2e4).data,T=e=>(w?.workstreams.rows.filter(e=>!(`malformed`in e))??[]).map(e=>e.schema===`workstreams.v1`?{name:e.stream,owner:e.owner,status:e.status}:{name:e.lane,owner:e.owner,status:e.state}).filter(t=>(t.owner===e||t.owner.includes(e))&&!/done|merged|deployed|complete|closed|✅/i.test(t.status)),E=(0,P.useRef)({}),D=(0,P.useRef)([]),O=(()=>{let e=f.map(e=>e.agentId),t=D.current.filter(t=>e.includes(t)),n=f.filter(e=>!t.includes(e.agentId)).sort((e,t)=>!!/coordinator/i.test(t.role??``)-+!!/coordinator/i.test(e.role??``)||e.agentId.localeCompare(t.agentId)).map(e=>e.agentId);return D.current=[...t,...n],D.current.map(e=>f.find(t=>t.agentId===e)).filter(Boolean)})(),k=(0,P.useRef)({}),A=(0,P.useRef)({});(0,P.useLayoutEffect)(()=>{let e={};for(let[t,n]of Object.entries(k.current)){if(!n)continue;let r=n.getBoundingClientRect();e[t]=r;let i=A.current[t];if(i&&(i.left!==r.left||i.top!==r.top)){let e=i.left-r.left,t=i.top-r.top;n.style.transition=`none`,n.style.transform=`translate(${e}px,${t}px)`,requestAnimationFrame(()=>{n.style.transition=`transform 320ms cubic-bezier(.2,.7,.2,1)`,n.style.transform=``})}}A.current=e}),(0,P.useEffect)(()=>{let t=!0,r=async()=>{if(!v)try{let r=await fetch(`${pf}/bus/panes?lines=${i}${b?`&colors=1`:``}${n===`project`&&e?`&project=${encodeURIComponent(e)}`:``}`),a=await r.json();if(!t)return;if(!r.ok)throw Error(String(a.error??r.status));p(a),h(null),C(e=>e+1)}catch(e){t&&h(e.message)}};r();let a=setInterval(r,3e3);return()=>{t=!1,clearInterval(a)}},[n,e,i,v,b]),(0,P.useEffect)(()=>{for(let e of Object.values(E.current))e&&(e.scrollTop=e.scrollHeight)},[S]);let j=f.filter(e=>e.active).length;return(0,B.jsxs)(`div`,{className:`p-4 grid gap-3.5 content-start`,children:[g&&(0,B.jsx)(Ju,{agentId:g,onClose:()=>_(null)}),(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between flex-wrap gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Monitor`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[n===`project`?e:`all projects`,` · `,f.length,` pane`,f.length===1?``:`s`,` · `,j,` active · read-only capture every 3 s`]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsxs)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden`,children:[(0,B.jsx)(`button`,{onClick:()=>r(`project`),"aria-pressed":n===`project`,className:`px-2.5 py-[5px] text-[12px] font-medium border-0 cursor-pointer ${n===`project`?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:e||`project`}),(0,B.jsx)(`button`,{onClick:()=>r(`all`),"aria-pressed":n===`all`,className:`px-2.5 py-[5px] text-[12px] font-medium border-0 cursor-pointer ${n===`all`?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:`all`})]}),(0,B.jsxs)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden`,children:[(0,B.jsx)(`button`,{onClick:()=>l(`grid`),"aria-pressed":c===`grid`,className:`px-2.5 py-[5px] text-[12px] font-mono border-0 cursor-pointer ${c===`grid`?`bg-walnut text-paper`:`bg-paper text-umber`}`,title:`wrapping grid`,children:`grid`}),(0,B.jsx)(`button`,{onClick:()=>l(`row`),"aria-pressed":c===`row`,className:`px-2.5 py-[5px] text-[12px] font-mono border-0 cursor-pointer ${c===`row`?`bg-walnut text-paper`:`bg-paper text-umber`}`,title:`one row, scroll sideways`,children:`row`})]}),c===`grid`&&(0,B.jsx)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden`,children:[1,2,3].map(e=>(0,B.jsxs)(`button`,{onClick:()=>s(e),"aria-pressed":o===e,className:`px-2.5 py-[5px] text-[12px] font-mono border-0 cursor-pointer ${o===e?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:[e,`×`]},e))}),c===`row`&&(0,B.jsx)(`select`,{value:u,onChange:e=>d(Number(e.target.value)),className:`font-mono text-[12px] px-2 py-[5px] border border-dust rounded-kit bg-paper text-umber`,title:`tile width`,children:[420,520,640,800].map(e=>(0,B.jsxs)(`option`,{value:e,children:[e,`px`]},e))}),(0,B.jsx)(`select`,{value:i,onChange:e=>a(Number(e.target.value)),className:`font-mono text-[12px] px-2 py-[5px] border border-dust rounded-kit bg-paper text-umber`,children:[20,40,80,150].map(e=>(0,B.jsxs)(`option`,{value:e,children:[e,` lines`]},e))}),(0,B.jsxs)(`label`,{className:`font-mono text-[11px] text-ink3 flex items-center gap-1`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked)}),`colors`]}),(0,B.jsx)(K,{size:`sm`,onClick:()=>y(e=>!e),"aria-pressed":v,children:v?`Resume`:`Pause`})]})]}),n===`project`&&e&&(0,B.jsx)(ff,{project:e}),m&&(0,B.jsx)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:m}),f.length===0&&!m&&(0,B.jsxs)(U,{className:`px-4 py-4 text-[13px] text-umber`,children:[`No pane-attached agents`,n===`project`?` for ${e}`:``,`. Agents appear here when their transport is tmux-push (attach_agent) and the pane is alive.`,n===`project`&&(0,B.jsxs)(B.Fragment,{children:[` Try `,(0,B.jsx)(`button`,{className:`underline text-ember-deep bg-transparent border-0 p-0 cursor-pointer`,onClick:()=>r(`all`),children:`all projects`}),`.`]})]}),(0,B.jsx)(`div`,{className:c===`grid`?`grid gap-3.5`:`flex gap-3.5 overflow-x-auto pb-2 snap-x snap-mandatory [scrollbar-width:thin]`,style:c===`grid`?{gridTemplateColumns:`repeat(${o}, minmax(0, 1fr))`}:void 0,children:O.map(e=>(0,B.jsx)(`div`,{ref:t=>{k.current[e.agentId]=t},className:c===`row`?`shrink-0 snap-start`:`min-w-0`,style:c===`row`?{width:u}:void 0,children:(0,B.jsxs)(U,{className:`grid grid-rows-[auto_1fr_auto]`,children:[(0,B.jsx)(`div`,{style:{height:4,background:td(e.role)}}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-sand min-w-0`,children:[(0,B.jsx)(Mu,{id:e.agentId,role:e.role,size:20,state:e.liveness,active:e.active}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`block font-mono font-semibold text-[13px] truncate leading-tight`,children:e.agentId}),(0,B.jsxs)(`span`,{className:`block font-mono text-[10px] uppercase tracking-[.06em] leading-tight`,style:{color:td(e.role)},children:[nd(e.role),n===`project`&&T(e.agentId).length>0?(0,B.jsxs)(`span`,{className:`text-ink3 normal-case tracking-normal`,children:[` · `,T(e.agentId).map(e=>e.name).join(` · `)]}):``]})]}),n===`all`&&e.project&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan truncate`,children:e.project}),(0,B.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-ink3`,title:`last pane output`,children:e.active?(0,B.jsx)(G,{tone:`ok`,children:`active`}):(0,B.jsxs)(`span`,{className:`text-tan`,children:[`quiet `,mf(e.paneActivity)]})}),(0,B.jsx)(`button`,{className:`font-mono text-[11px] text-ember-deep bg-transparent border-0 cursor-pointer`,onClick:()=>id(e.agentId),title:`DM this agent (Summon)`,children:`DM`}),(0,B.jsx)(`button`,{className:`font-mono text-[11px] text-ember-deep bg-transparent border-0 cursor-pointer underline decoration-dotted`,onClick:()=>_(e.agentId),title:`open full pane`,children:e.pane})]})]}),(0,B.jsx)(`pre`,{ref:t=>{E.current[e.agentId]=t},className:`m-0 px-3 py-2 overflow-auto font-mono text-[11.5px] leading-[1.4] whitespace-pre-wrap break-words pane-dark`,style:{height:`${Math.min(i,80)*16+16}px`},children:e.capture?t(b&&e.capture.ansi?uo(e.capture.ansi):e.capture.text,e.project??void 0):`—`})]})},e.agentId))}),(0,B.jsxs)(`div`,{className:`font-mono text-[11px] text-tan`,children:[`pulsing dot = output in the last 60 s · `,c===`row`?`row: scroll sideways (shift+wheel / trackpad), tiles snap`:`grid wraps; switch to row for 8+ agents`,` · tiles auto-scroll to the bottom · click a pane id for the full, follow-able view · the console never types into panes — DM opens the agent's thread (Summon)`]})]})}var gf=[{to:`fleets`,label:`Fleets`,icon:`fleet`,hint:`presence · spawn · unregister · prune · decommission`},{to:`skills`,label:`Skills`,icon:`skills`,hint:`groundwork / playbook skills · updates`},{to:`release`,label:`Release`,icon:`release`,hint:`kit versions · PRs · gates`},{to:`runs`,label:`Runs`,icon:`health`,hint:`every action the console performed`},{to:`events`,label:`Events`,icon:`bus`,hint:`mechanical rules → coordinator (dry-run by default)`}];function _f(){let{running:e}=Ha(),t=rr(),n=gf.find(e=>t.pathname.startsWith(`/ops/${e.to}`));return(0,B.jsxs)(`div`,{className:`grid grid-rows-[auto_1fr] min-h-0`,children:[(0,B.jsxs)(`div`,{className:`px-4 pt-3 flex items-end gap-1 border-b border-sand bg-cream/60`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mr-2 pb-2.5`,children:`ops`}),gf.map(t=>(0,B.jsxs)(ji,{to:t.to,className:({isActive:e})=>`inline-flex items-center gap-1.5 px-3 py-2 -mb-px border-b-2 text-[13px] font-medium hover:no-underline ${e?`border-ember text-walnut`:`border-transparent text-ink3 hover:text-umber`}`,title:t.hint,children:[(0,B.jsx)(`span`,{className:`text-tan`,children:Ca[t.icon]({size:14})}),t.label,t.to===`runs`&&e>0?(0,B.jsx)(`span`,{className:`ml-1 inline-flex items-center justify-center min-w-4 h-4 px-1 rounded-full bg-ember text-paper font-mono text-[10px]`,children:e}):null]},t.to)),n&&(0,B.jsx)(`span`,{className:`ml-auto pb-2.5 font-mono text-[11px] text-tan hidden lg:inline`,children:n.hint})]}),(0,B.jsx)(Rr,{})]})}function vf(){return(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsx)(Cd,{})})}function yf({title:e,danger:t,body:n,confirmWord:r,action:i,payload:a,preview:o,onClose:s}){let[c,l]=(0,P.useState)(``),[u,d]=(0,P.useState)(!1),[f,p]=(0,P.useState)(null),[m,h]=(0,P.useState)(null),g=async()=>{d(!0);try{p(await Fa(i,{...a,confirm:c}))}finally{d(!1)}},_=async()=>{if(o){d(!0);try{h(await o())}finally{d(!1)}}},v=e=>(0,B.jsxs)(`div`,{className:`p-2 rounded-kit border ${e.status===`ok`?`border-moss-line bg-moss-wash/50`:`border-brick-line bg-brick-wash/50`}`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px]`,children:[(0,B.jsx)(G,{tone:e.status===`ok`?`ok`:`bad`,children:e.status}),` `,(0,B.jsx)(`b`,{children:e.label})]}),(0,B.jsxs)(`pre`,{className:`m-0 mt-1 font-mono text-[12px] whitespace-pre-wrap max-h-[30vh] overflow-auto`,children:[e.log.join(`
34
+ `+h.error:``]}),h.status===`ok`&&(0,B.jsx)(`div`,{className:`mt-1 text-[12px] text-umber`,children:`Written to the working tree (uncommitted). Review the diff in Docs, then commit in the repo.`})]})]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:i,children:h?`Close`:`Cancel`}),!h&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:y,disabled:!n||p||(t.kind===`add`?!s.trim():!l.trim()),children:p?`Writing…`:t.kind===`add`?`Append to QUEUE.md`:`Write to FACTS.md`})]})]})})}var Vd=`1.6fr 1.1fr 1.4fr 1fr 1fr 2fr`,Hd=`1.4fr 1fr 1fr 1.6fr 1.6fr`,Ud=e=>/block/i.test(e)?`bad`:/done|merged|deployed|✅/i.test(e)||/watch|soak/i.test(e)?`ok`:`neutral`,Wd=({k:e})=>(0,B.jsx)(`kbd`,{className:`ml-1 font-mono text-[12px] border border-dust border-b-2 rounded px-1 text-umber bg-paper`,children:e});function Gd({r:e,raw:t,cols:n}){return`malformed`in e?(0,B.jsx)(Oa,{glyph:`|`,malformed:!0,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`py-2 flex items-center gap-2 min-w-0`,children:[(0,B.jsx)(G,{tone:`solid`,children:`MalformedRow`}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,children:e.issue??`line ${e.line??`?`} · expected ${e.expected??`?`} columns, found ${e.actual??`?`} — kept byte-exact, not parsed.`}),e.line?(0,B.jsx)(V,{className:`text-[13px]`,to:`/docs/WORKSTREAMS.md?view=source&line=${e.line}`,children:`Show line`}):null]})}):e.schema===`workstreams.v1`?(0,B.jsx)(Oa,{glyph:`|`,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`grid gap-3 items-center py-1.5`,style:{gridTemplateColumns:n},children:[(0,B.jsx)(`b`,{className:`truncate`,title:e.stream,children:e.stream}),(0,B.jsx)(`span`,{className:`font-mono font-medium text-[13px] text-umber truncate`,children:e.owner}),(0,B.jsx)(`span`,{className:`font-mono text-[13px] truncate`,children:e.branchWorktree}),(0,B.jsx)(`span`,{className:`min-w-0`,children:(0,B.jsx)(G,{tone:Ud(e.status),children:e.status})}),(0,B.jsx)(`span`,{className:`min-w-0 truncate`,children:/david/i.test(e.blocker)?(0,B.jsx)(G,{tone:`david`,children:e.blocker}):(0,B.jsx)(`span`,{className:e.blocker===`—`?`font-mono text-tan`:`text-[13px]`,children:e.blocker})}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,title:e.lastNote,children:e.lastNote})]})}):(0,B.jsx)(Oa,{glyph:`|`,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`grid gap-3 items-center py-1.5`,style:{gridTemplateColumns:n},children:[(0,B.jsx)(`b`,{className:`truncate`,children:e.lane}),(0,B.jsx)(`span`,{className:`font-mono font-medium text-[13px] text-umber truncate`,children:e.owner}),(0,B.jsx)(`span`,{className:`min-w-0`,children:(0,B.jsx)(G,{tone:Ud(e.state),children:e.state})}),(0,B.jsx)(`span`,{className:`text-[13px] truncate`,children:e.currentSlice}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,children:e.nextGo})]})})}function Kd(){let{current:e}=za(),[t,n]=(0,P.useState)(!1);(0,P.useEffect)(()=>{let e=e=>{e.key===`s`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!(e.target instanceof HTMLInputElement)&&!(e.target instanceof HTMLTextAreaElement)&&!(e.target instanceof HTMLSelectElement)&&n(e=>!e)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let{data:r,error:i,loading:a}=q(e?`/projects/${e}/board`:null,15e3),o=q(e?`/projects/${e}/doctor`:null,6e4),s=o.data,c=q(e?`/projects/${e}/doctor/fixers`:null,3e4).data?.fixers??{},[l,u]=(0,P.useState)(null),[d,f]=(0,P.useState)({}),p=async(t,n)=>{if(!m){f(e=>({...e,[t]:`bus writes are off — toggle in the header`}));return}u(t);try{let r=await Fa(`/actions/doctor-fix/${e}`,{check:t,items:n});f(e=>({...e,[t]:r.status===`ok`?`sent → ${r.args?.to}`:r.error??`failed`}))}catch(e){f(n=>({...n,[t]:e.message}))}finally{u(null)}},m=q(`/admin/bus-writes`,1e4).data?.enabled??!1,h=q(`/admin/seam-writes`,1e4).data?.enabled??!1,[g,_]=(0,P.useState)(()=>{try{return JSON.parse(localStorage.getItem(`groundwork-console.board.fold`)??``)}catch{return{done:!1,facts:!1}}}),v=e=>_(t=>{let n={...t,[e]:!t[e]};return localStorage.setItem(`groundwork-console.board.fold`,JSON.stringify(n)),n}),y=(r?.facts?.entries.filter(e=>e.stale).length??0)+(r?.facts?.issues.length??0),[b,x]=(0,P.useState)(null),[S,C]=(0,P.useState)(!1),w=async()=>{C(!0);try{await Fa(`/actions/project-doctor/${e}`),o.refresh()}finally{C(!1)}};if(!e)return(0,B.jsx)(`div`,{className:`p-4 text-umber`,children:`No project selected.`});if(i)return(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsxs)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:[`API error: `,i]})});if(!r)return(0,B.jsx)(`div`,{className:`p-4 text-umber`,children:a?`Reading seam…`:``});let T=r.workstreams.schema,E=T===`workstreams.v1`,D=E?Vd:Hd,O=e=>r.scopes[e]?{path:e,owner:r.scopes[e].owner,mode:r.scopes[e].mode??`shared`,note:r.scopes[e].note}:void 0,k=r.phases.find(e=>e.state===`ongoing`);return(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_340px] gap-4 p-4 max-[980px]:grid-cols-1`,children:[b&&(0,B.jsx)(Bd,{project:e,req:b,seamOn:h,scope:b.kind===`add`?O(`docs/QUEUE.md`):O(`docs/FACTS.md`),onClose:()=>{x(null)}}),(0,B.jsxs)(`div`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:e}),k&&(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[k.title,` · `,k.done,`/`,k.total]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:a?`refreshing…`:`read from disk · 15 s`}),(0,B.jsx)(K,{size:`sm`,onClick:w,disabled:S,children:S?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Ma,{size:12}),` Doctor`]}):`Doctor`})]})]}),(0,B.jsx)(Pd,{project:e,canWrite:m}),(0,B.jsx)(Od,{project:e,phases:r.phases,canWrite:m,prd:r.prd}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Active Streams`,icon:`streams`,eyebrow:T??`no WORKSTREAMS.md`,path:`docs/WORKSTREAMS.md`,children:[(0,B.jsx)(zd,{scope:O(`docs/WORKSTREAMS.md`)}),(0,B.jsxs)(K,{tone:`ghost`,size:`sm`,onClick:()=>n(e=>!e),"aria-pressed":t,children:[t?`Rendered`:`View source`,(0,B.jsx)(Wd,{k:`s`})]})]}),T===`unknown`&&(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px]`,children:[(0,B.jsx)(G,{tone:`bad`,children:`unknown workstreams grammar`}),(0,B.jsx)(`span`,{className:`ml-2 text-umber`,children:`expected workstreams.v1 (6-col Active Streams). Never auto-migrated — coordinator rewrites to v1.`})]}),T===`workstreams.lanes-v0`&&(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[13px]`,children:[(0,B.jsx)(G,{tone:`warn`,children:`lanes-v0 · legacy`}),(0,B.jsx)(`span`,{className:`ml-2 text-umber`,children:`5-col Lanes parses read-only; new writes should be workstreams.v1.`})]}),r.workstreams.rows.length>0&&(E?(0,B.jsxs)(ka,{cols:D,children:[(0,B.jsx)(`span`,{children:`Stream`}),(0,B.jsx)(`span`,{children:`Owner / Agent`}),(0,B.jsx)(`span`,{children:`Branch · Worktree`}),(0,B.jsx)(`span`,{children:`Status`}),(0,B.jsx)(`span`,{children:`Blocker`}),(0,B.jsx)(`span`,{children:`Last note`})]}):(0,B.jsxs)(ka,{cols:D,children:[(0,B.jsx)(`span`,{children:`Lane`}),(0,B.jsx)(`span`,{children:`Owner`}),(0,B.jsx)(`span`,{children:`State`}),(0,B.jsx)(`span`,{children:`Current slice`}),(0,B.jsx)(`span`,{children:`Next GO`})]})),r.workstreams.rows.map((e,n)=>(0,B.jsx)(Gd,{r:e,raw:t,cols:D},n)),r.workstreams.issues.length>0&&(0,B.jsxs)(`div`,{className:`px-3 py-2 border-t border-sand text-[12px] font-mono text-ink3`,children:[r.workstreams.issues.length,` parser issue`,r.workstreams.issues.length>1?`s`:``,`: `,r.workstreams.issues.slice(0,3).join(` · `),r.workstreams.issues.length>3?` …`:``]})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Queue`,icon:`queue`,eyebrow:`queue.v1`,path:`docs/QUEUE.md`,children:[(0,B.jsx)(zd,{scope:O(`docs/QUEUE.md`)}),(0,B.jsx)(K,{size:`sm`,tone:h?`primary`:`default`,onClick:()=>x({kind:`add`}),title:h?`append a queue.v1 item through the seam`:`seam writes are off — enable in the header`,children:`Add item…`}),!h&&(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-tan ml-1`,title:`seam & docs writes are off`,children:`seam & docs off · header`})]}),r.queue.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`Queue empty.`}),r.queue.map(e=>(0,B.jsx)(Oa,{glyph:e.done?`- [x]`:`- [ ]`,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-[44px_1fr] gap-2.5 items-baseline py-2`,children:[(0,B.jsx)(`span`,{className:`font-mono font-bold text-[12px] px-[7px] py-[3px] rounded text-center ${e.priority===`P1`?`bg-ember-wash text-ember-deep`:e.priority===`P2`?`bg-amber-wash text-amber`:`bg-slate-wash text-slate`}`,children:e.priority}),(0,B.jsx)(`span`,{className:e.done?`line-through text-tan`:``,children:e.text})]})},e.id))]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Done`,icon:`done`,eyebrow:`done.v1 · append-only`,path:`docs/DONE.md · ${r.done.length}`,children:[(0,B.jsx)(zd,{scope:O(`docs/DONE.md`)}),(0,B.jsx)(qd,{k:`done`,open:g.done,onToggle:v})]}),g.done&&r.done.slice(-8).reverse().map(e=>(0,B.jsx)(Oa,{glyph:`—`,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-3 items-baseline py-2`,children:[(0,B.jsx)(`span`,{className:`truncate`,title:e.text,children:e.text}),(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-ink3`,children:e.date??``})]})},e.id))]})]}),(0,B.jsxs)(`aside`,{className:`grid gap-3.5 content-start bg-cream -m-4 ml-0 p-4 border-l border-sand min-w-0`,children:[(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Facts`,icon:`facts`,path:`docs/FACTS.md · ${r.facts?.entries.length??0}${y?` · ${y} need attention`:``}`,children:[(0,B.jsx)(zd,{scope:O(`docs/FACTS.md`)}),(0,B.jsx)(qd,{k:`facts`,open:g.facts||y>0,onToggle:v})]}),(g.facts||y>0)&&!r.facts&&(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:[`No FACTS.md yet (run `,(0,B.jsx)(`code`,{children:`groundwork update --docs`}),`).`]}),(g.facts||y>0)&&r.facts?.entries.map(e=>(0,B.jsx)(Oa,{glyph:`##`,raw:e.raw,showRaw:t,children:(0,B.jsxs)(`div`,{className:`py-2 grid grid-cols-[1fr_auto] gap-2 items-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`font-mono font-medium text-[13px] truncate`,children:[e.id,e.stale&&(0,B.jsx)(`span`,{className:`ml-2 inline-flex`,children:(0,B.jsx)(G,{tone:`warn`,children:`stale`})})]}),e.value&&(0,B.jsx)(`div`,{className:`text-umber truncate`,title:e.value,children:e.value}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3`,children:[e.ageDays===null?`unverified`:`${e.ageDays} d`,e.by?` · ${e.by}`:``,e.method?` · ${e.method}`:``]})]}),(0,B.jsx)(K,{size:`sm`,tone:e.stale?`primary`:`ghost`,onClick:()=>x({kind:`fact`,id:e.id,claim:e.value}),title:`upsert this fact through the seam with a fresh timestamp`,children:`Re-verify…`})]})},e.id)),r.facts&&r.facts.issues.length>0&&(0,B.jsxs)(`div`,{className:`px-3 py-2 border-t border-sand text-[12px] font-mono text-ink3`,children:[r.facts.issues.length,` issue`,r.facts.issues.length>1?`s`:``,`: `,r.facts.issues[0]]})]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Project doctor`,icon:`doctor`,path:s?`groundwork doctor --json · ${s.checks.filter(e=>e.level!==`ok`).length} flagged`:`groundwork doctor`}),!s&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`running…`}),s?.error&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-brick`,children:s.error}),s?.checks.map(e=>(0,B.jsx)(Oa,{glyph:e.level===`ok`?`✓`:`!`,children:(0,B.jsxs)(`div`,{className:`py-1.5 text-[13px] min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsxs)(G,{tone:e.level===`ok`?`ok`:e.level===`error`?`bad`:`warn`,children:[e.check,e.level!==`ok`&&e.items.length>1?` · ${e.items.length}`:``]}),e.level!==`ok`&&(e.check===`version-marker`?(0,B.jsx)(V,{to:`/ops/skills`,className:`ml-auto font-mono text-[11px]`,children:`Update via Skills →`}):c[e.check]?c[e.check].agent?(0,B.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1`,children:[(0,B.jsx)(`button`,{onClick:()=>p(e.check,e.items),disabled:l===e.check,className:`font-mono text-[11px] px-2 py-0.5 rounded-full border cursor-pointer ${m?`bg-ember-wash text-ember-deep border-ember-line`:`bg-paper text-umber border-dust`}`,title:`DM ${c[e.check].agent} as david: ${c[e.check].how}`,children:l===e.check?(0,B.jsx)(Ma,{size:11}):`Fix →`}),(0,B.jsx)(ed,{id:c[e.check].agent})]}):(0,B.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-tan`,title:`needs a live ${c[e.check].role} for this project`,children:[`no `,c[e.check].role,` online`]}):null)]}),(0,B.jsxs)(`div`,{className:`text-umber mt-1 grid gap-0.5`,children:[e.items.slice(0,e.level===`ok`?1:3).map((e,t)=>(0,B.jsx)(`div`,{className:`truncate`,title:e,children:e},t)),e.level!==`ok`&&e.items.length>3&&(0,B.jsxs)(`div`,{className:`text-tan`,children:[`+`,e.items.length-3,` more`]})]}),d[e.check]&&(0,B.jsx)(`div`,{className:`mt-1 font-mono text-[11px] flex items-center gap-1.5 ${/^sent/.test(d[e.check])?`text-leaf`:`text-brick`}`,children:/^sent → /.test(d[e.check])?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{children:`sent →`}),(0,B.jsx)(ed,{id:d[e.check].replace(/^sent → /,``)})]}):d[e.check]})]})},e.check))]})]})]})}function qd({k:e,open:t,onToggle:n}){return(0,B.jsx)(`button`,{onClick:()=>n(e),className:`ml-1 font-mono text-[11px] text-tan border-0 bg-transparent cursor-pointer hover:text-umber`,title:t?`collapse`:`expand`,children:t?`▾`:`▸`})}var Jd=({children:e})=>(0,B.jsx)(`div`,{className:`font-mono font-semibold text-[11px] uppercase tracking-[.1em] text-ink3 mx-2 mt-3.5 mb-1.5`,children:e}),Yd=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``,Xd=e=>e?new Date(e).toLocaleDateString([],{month:`short`,day:`numeric`}):``,Zd=e=>!!e&&Ta.includes(e),Qd=(e,t)=>t&&e.startsWith(t)?e.slice(t.length).replace(/^:?\s*/,``):e,$d=`/api`;function ef(){let{projects:e,current:t}=za(),[n,r]=Fi(),i=q(`/bus/rooms`,2e4).data??[],[a,o]=(0,P.useState)(!1),[s,c]=(0,P.useState)(!1),l=q(`/bus/agents`,3e4).data??[],u=e.find(e=>e.name===t)?.room??i[0]?.room??`general`,d=n.get(`view`)===`status`?`status`:n.get(`view`)===`inbox`?`inbox`:`room`,f=n.get(`room`)??u,p=[...i].sort((e,t)=>t.lastTs-e.lastTs),m=p.filter(e=>Date.now()-e.lastTs>6048e5&&e.room!==f),h=a?p:p.filter(e=>!m.includes(e)),g=n.get(`msg`),_=i.find(e=>e.room===f),{data:v,error:y}=q(d===`room`&&f?`/bus/rooms/${f}/messages?limit=80`:null,1e4),b=q(d===`status`?`/bus/status?limit=100`:null,15e3).data??[],x=q(d===`inbox`?`/bus/inbox?limit=200`:null,2e4),[S,C]=(0,P.useState)(!1),w=async()=>{C(!0);try{await Fa(`/bus/inbox/read`),x.refresh()}finally{C(!1)}},[T,E]=(0,P.useState)([]),[D,O]=(0,P.useState)(!1);(0,P.useEffect)(()=>{E([])},[f]);let k=(0,P.useMemo)(()=>{let e=new Set;return[...T,...v?.messages??[]].filter(t=>{let n=t.id??`${t.ts}-${t.from}`;return!e.has(n)&&(e.add(n),!0)})},[T,v]),A=k.filter(e=>!e.system).slice().reverse(),j=async()=>{let e=k[0]?.ts;if(e){O(!0);try{let t=await(await fetch(`${$d}/bus/rooms/${f}/messages?limit=80&before=${e}`)).json();E(e=>[...t.messages,...e])}finally{O(!1)}}};(0,P.useEffect)(()=>{if(!g)return;let e=document.getElementById(`msg-${g}`);e&&(e.scrollIntoView({block:`center`}),e.classList.add(`ring-2`,`ring-ember`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-ember`),2500))},[g,A.length]);let M=A.filter(e=>e.prefix===`DAVID_DECISION`&&!e.answered),N=(_?.members??[]).map(e=>l.find(t=>t.agentId===e)??{agentId:e,liveness:`dead`,pane:null,role:void 0,active:!1}),ee=e=>Date.now()-e.lastTs<3e5,F=e=>{let t=new URLSearchParams(n);for(let[n,r]of Object.entries(e))r===null?t.delete(n):t.set(n,r);r(t,{replace:!0})},I=!!v&&k.length<v.total,te=!!q(`/admin/bus-writes`,1e4).data?.enabled,[ne,re]=(0,P.useState)(`david`),[L,R]=(0,P.useState)(``),[z,ie]=(0,P.useState)(!1),[ae,oe]=(0,P.useState)(null),[se,ce]=(0,P.useState)(null),le=Gu(),[ue,de]=(0,P.useState)(null),fe=q(`/bus/unread`,3e4).data?.inbox??0,pe=`#${f}`,me=async()=>{ie(!0),oe(null);try{let e=pe.startsWith(`#`)?{room:pe.slice(1)}:{to:pe.replace(/^@/,``)},t=await Fa(`/actions/send`,{as:ne,...e,text:le.withRefs(L),answers:se?.id?[se.id]:void 0,kind:/^DAVID_DECISION/.test(L)?`decision`:void 0});if(t.status!==`ok`)throw Error(t.error??t.log?.slice(-1)[0]??`failed`);R(``),ce(null),le.clear()}catch(e){oe(e.message)}finally{ie(!1)}};return(0,B.jsxs)(`div`,{className:`grid ${M.length>0?`grid-cols-[240px_1fr_320px]`:`grid-cols-[240px_1fr]`} gap-4 p-4 max-[980px]:grid-cols-1`,children:[ue&&(0,B.jsx)(Yu,{agentId:ue,onClose:()=>de(null)}),(0,B.jsxs)(`aside`,{className:`bg-cream -m-4 mr-0 px-2 py-4 border-r border-sand min-w-0 overflow-auto`,children:[(0,B.jsx)(Jd,{children:`Rooms · list_rooms`}),h.map(e=>(0,B.jsxs)(`button`,{onClick:()=>F({room:e.room,view:null,msg:null}),className:`w-full text-left grid grid-cols-[1fr_auto] gap-2 px-2 py-1.5 rounded-kit font-mono text-[13px] border-0 cursor-pointer ${d===`room`&&e.room===f?`bg-paper text-walnut shadow-[inset_0_0_0_1px_var(--color-sand)]`:`bg-transparent text-umber hover:bg-linen`}`,children:[(0,B.jsxs)(`span`,{className:`truncate flex items-center gap-1.5`,children:[ee(e)&&(0,B.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-moss`,title:`message in the last 5 min`}),`#`,e.room]}),(0,B.jsx)(`span`,{className:`font-semibold text-[11px] px-1.5 py-0.5 rounded-full bg-linen text-umber`,children:e.messageCount})]},e.room)),m.length>0&&(0,B.jsxs)(`button`,{onClick:()=>o(e=>!e),className:`w-full text-left px-2 py-1 font-mono text-[11px] text-tan border-0 bg-transparent cursor-pointer hover:text-umber`,children:[a?`▾ hide`:`▸ show`,` `,m.length,` quiet room`,m.length===1?``:`s`,` (no traffic in 7 d)`]}),(0,B.jsx)(Jd,{children:`Direct · inbox`}),(0,B.jsxs)(`button`,{onClick:()=>F({view:`inbox`,msg:null}),className:`w-full text-left grid grid-cols-[1fr_auto] gap-2 px-2 py-1.5 rounded-kit font-mono text-[13px] border-0 cursor-pointer ${d===`inbox`?`bg-paper text-walnut shadow-[inset_0_0_0_1px_var(--color-sand)]`:`bg-transparent text-umber hover:bg-linen`}`,children:[(0,B.jsx)(`span`,{children:`@david · my DMs`}),fe>0&&(0,B.jsxs)(`span`,{className:`font-semibold text-[11px] px-1.5 py-0.5 rounded-full bg-ember-wash text-ember-deep`,children:[fe,` unread`]})]}),(0,B.jsx)(Jd,{children:`Status stream`}),(0,B.jsx)(`button`,{onClick:()=>F({view:`status`,msg:null}),className:`w-full text-left px-2 py-1.5 rounded-kit font-mono text-[13px] border-0 cursor-pointer ${d===`status`?`bg-paper text-walnut shadow-[inset_0_0_0_1px_var(--color-sand)]`:`bg-transparent text-umber hover:bg-linen`}`,children:`post_status feed`})]}),d===`inbox`?(0,B.jsxs)(U,{className:`min-w-0`,children:[(0,B.jsxs)(W,{title:`Inbox · david`,icon:`bus`,path:`read_messages source=inbox · unread = bus cursor`,children:[x.data&&(x.data.unread>0?(0,B.jsxs)(G,{tone:`david`,children:[x.data.unread,` unread`]}):(0,B.jsx)(G,{tone:`outline`,children:`all read`})),x.data&&x.data.unread>0&&(0,B.jsx)(K,{size:`sm`,onClick:w,disabled:S,children:S?`…`:`Mark all read`})]}),x.error&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-brick`,children:x.error}),x.data&&x.data.messages.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`No DMs to david.`}),(x.data?.messages??[]).slice().reverse().map((e,t)=>{let n=String(e.text??``),r=n.match(/^(BLOCKER|RISK|DONE|FYI|AGENT_ACTION|GO|SCOPE CHANGE|VERDICT|DAVID_DECISION)\b/)?.[1]??null;return(0,B.jsxs)(`div`,{className:`grid grid-cols-[var(--spacing-gutter)_1fr] border-b border-sand last:border-b-0 ${e.unread?`bg-ember-wash/35`:``}`,children:[(0,B.jsx)(`div`,{className:`py-2.5 flex justify-center font-mono text-[12px] border-r border-sand ${e.unread?`text-ember font-bold`:`text-tan`}`,children:e.unread?`●`:`@`}),(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-baseline mb-0.5`,children:[(0,B.jsx)(`span`,{className:`font-semibold text-[13px]`,children:e.from}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,children:[Xd(e.ts),` `,Yd(e.ts)]}),te&&e.from&&(0,B.jsx)(`button`,{className:`ml-auto font-mono text-[12px] text-ember-deep bg-transparent border-0 cursor-pointer`,onClick:()=>ad(e.from),title:`open the DM thread with this agent (Summon)`,children:`reply →`})]}),(0,B.jsxs)(`div`,{className:`whitespace-pre-wrap break-words text-[14px]`,children:[Zd(r)&&(0,B.jsx)(Da,{prefix:r,fail:r===`VERDICT`&&/FAIL/.test(n)}),Qd(n,r)]})]})]},e.id??t)})]}):d===`status`?(0,B.jsxs)(U,{className:`min-w-0`,children:[(0,B.jsx)(W,{title:`Status stream`,icon:`health`,path:`~/agent-coord/status.jsonl · post_status`}),b.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`empty`}),b.slice().reverse().map((e,t)=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[var(--spacing-gutter)_1fr] border-b border-sand last:border-b-0`,children:[(0,B.jsx)(`div`,{className:`py-2.5 flex justify-center font-mono text-[12px] text-tan border-r border-sand`,children:`◌`}),(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-baseline mb-0.5`,children:[(0,B.jsx)(`span`,{className:`font-semibold text-[13px]`,children:e.agentId??e.from}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,children:[Xd(e.ts),` `,Yd(e.ts)]})]}),(0,B.jsxs)(`div`,{className:`text-[14px]`,children:[(0,B.jsx)(G,{tone:`outline`,children:e.status??`?`}),e.detail&&(0,B.jsx)(`span`,{className:`ml-2 text-umber`,children:e.detail})]})]})]},t))]}):(0,B.jsxs)(U,{className:`grid grid-rows-[auto_auto_1fr_auto] min-h-0 min-w-0`,children:[(0,B.jsx)(W,{title:`#${f}`,icon:`room`,path:v?`${v.total} messages`:``,children:(0,B.jsxs)(G,{tone:`outline`,children:[_?.members?.length??0,` members`]})}),fe>0&&(0,B.jsxs)(`button`,{onClick:()=>F({view:`inbox`,msg:null}),className:`mx-3 mb-1.5 text-left bg-ember-wash/60 border border-ember-line rounded-kit px-3 py-2 text-[13px] text-ember-deep cursor-pointer flex items-center gap-2`,children:[(0,B.jsxs)(`span`,{className:`font-semibold`,children:[fe,` unread DM`,fe===1?``:`s`,` to david`]}),(0,B.jsx)(`span`,{className:`text-umber`,children:`— open your inbox →`})]}),N.length>0&&(0,B.jsxs)(`div`,{className:`mx-3 mb-1.5 flex items-center gap-1.5 flex-wrap font-mono text-[11px] text-tan`,children:[(0,B.jsx)(`span`,{className:`uppercase tracking-[.08em]`,children:`members`}),N.map(e=>(0,B.jsxs)(`button`,{onClick:()=>ad(e.agentId),title:`${e.agentId} · DM`,className:`inline-flex items-center gap-1 border-0 bg-transparent p-0 cursor-pointer text-umber`,children:[(0,B.jsx)(Mu,{id:e.agentId,role:e.role,size:14,state:e.liveness,active:e.active}),(0,B.jsx)(`span`,{children:e.agentId})]},e.agentId)),(0,B.jsx)(`span`,{className:`ml-auto`,children:(0,B.jsx)(`button`,{onClick:()=>c(e=>!e),className:`border border-dust rounded-full w-5 h-5 text-[11px] bg-paper text-umber cursor-pointer`,title:`prefix key`,children:`?`})})]}),s&&(0,B.jsxs)(`div`,{className:`mx-3 mb-1.5 flex flex-wrap gap-1.5 items-center`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan mr-1`,children:`rooms need a prefix:`}),Ta.map(e=>(0,B.jsx)(Da,{prefix:e},e))]}),(_?.topic||_?.motd)&&(0,B.jsxs)(`div`,{className:`mx-3 mb-1.5 bg-linen border-l-[3px] border-dust px-3 py-2 text-[13px] leading-[1.5] text-umber`,children:[_.topic&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{children:`Topic`}),` · `,_.topic]}),_.motd&&(0,B.jsxs)(`div`,{className:`mt-1 whitespace-pre-line line-clamp-4`,children:[(0,B.jsx)(`b`,{children:`MOTD`}),` · `,_.motd]})]}),(0,B.jsx)(`div`,{className:`overflow-auto max-h-[70vh] flex flex-col-reverse`,children:(0,B.jsxs)(`div`,{children:[I&&(0,B.jsx)(`div`,{className:`px-3 py-2 border-b border-sand text-center`,children:(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:j,disabled:D,children:D?`loading…`:`Load older (${v.total-k.length} more)`})}),y&&(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px] text-brick`,children:[`API error: `,y]}),A.length===0&&!y&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`No messages yet.`}),A.slice().reverse().map((e,t)=>{let n=e.prefix===`DAVID_DECISION`&&!e.answered,r=n||e.kind===`decision`,i=typeof e.text==`string`?e.text:e.raw??``;return(0,B.jsxs)(`div`,{id:e.id?`msg-${e.id}`:void 0,className:`grid grid-cols-[var(--spacing-gutter)_1fr] border-b border-sand transition-shadow ${n?`bg-ember-wash/45`:r?`bg-linen/50`:``}`,children:[(0,B.jsx)(`div`,{className:`py-2.5 flex justify-center font-mono font-medium text-[12px] border-r border-sand select-none ${n?`text-ember`:r?`text-umber`:`text-tan`}`,children:n?`★`:r?`◆`:e.to?`@`:`#`}),(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-center mb-0.5`,children:[(0,B.jsx)(Mu,{id:e.from??`?`,role:l.find(t=>t.agentId===e.from)?.role,size:14,state:l.find(t=>t.agentId===e.from)?.liveness??`dead`}),(0,B.jsx)(`span`,{className:`font-semibold text-[13px]`,children:e.from}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,title:new Date(e.ts??0).toLocaleString(),children:[Xd(e.ts),` `,Yd(e.ts)]}),n&&(0,B.jsx)(G,{tone:`david`,children:`needs David`}),e.kind&&e.kind!==`chatter`&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:e.kind})]}),(0,B.jsxs)(`div`,{className:`whitespace-pre-wrap break-words text-[14px]`,children:[Zd(e.prefix)&&(0,B.jsx)(Da,{prefix:e.prefix,fail:e.prefix===`VERDICT`&&/FAIL/.test(i)}),e.prefix===`DAVID_DECISION`&&e.answered&&(0,B.jsx)(G,{tone:`ok`,children:`answered`}),e.inReplyTo&&(0,B.jsx)(`button`,{onClick:()=>F({msg:e.inReplyTo}),className:`ml-1 font-mono text-[11px] text-ember-deep border-0 bg-transparent p-0 cursor-pointer`,title:`in reply to ${e.inReplyTo}`,children:`↩ reply`}),(0,B.jsx)(qu,{text:Qd(i,e.prefix)})]})]})]},e.id??t)})]})}),(0,B.jsxs)(`div`,{className:`border-t border-sand px-3 py-2.5 grid gap-1.5`,children:[se&&(0,B.jsxs)(`div`,{className:`text-[12px] text-umber flex gap-2 items-center`,children:[(0,B.jsxs)(`span`,{className:`font-mono`,children:[`replying to `,se.from,` · `,Yd(se.ts)]}),(0,B.jsx)(`button`,{className:`border-0 bg-transparent text-ink3 cursor-pointer`,onClick:()=>{ce(null),R(``)},children:`✕`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-[auto_auto_1fr_auto] gap-2 items-center`,children:[(0,B.jsxs)(`select`,{value:ne,onChange:e=>re(e.target.value),disabled:!te,className:`text-[13px] px-2 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`,title:`send as`,children:[(0,B.jsx)(`option`,{value:`david`,children:`as david`}),(0,B.jsx)(`option`,{value:`groundwork-console`,children:`as groundwork-console`})]}),(0,B.jsxs)(`span`,{className:`font-mono text-[13px] px-2 py-2 border border-dust rounded-kit bg-cream text-umber`,title:`rooms post here; DMs go through Summon (bottom-right)`,children:[`#`,f]}),(0,B.jsx)(`input`,{value:L,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&te&&le.hasContent(L)&&me()},onPaste:le.onPaste,onDrop:le.onDrop,onDragOver:le.onDragOver,disabled:!te,className:`text-[13px] px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`,placeholder:te?pe.startsWith(`#`)?`FYI: … (rooms need a prefix)`:`message…`:`bus writes are off — enable in the header`}),(0,B.jsx)(K,{tone:`primary`,size:`sm`,onClick:me,disabled:!te||z||le.busy||!le.hasContent(L),children:z?`Sending…`:`Send`})]}),(0,B.jsx)(Ku,{a:le}),ae&&(0,B.jsx)(`div`,{className:`text-[12px] text-brick`,children:ae}),te&&(0,B.jsxs)(`div`,{className:`text-[11px] font-mono text-tan`,children:[`every send is a Run · rooms require a prefix · `,(0,B.jsx)(`span`,{className:`text-ember-deep`,children:`DAVID_DECISION:`}),` replies are pinned (kind: decision)`]})]})]}),M.length>0&&(0,B.jsx)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:M.slice(0,1).map(e=>(0,B.jsxs)(`div`,{className:`border border-ember border-l-4 rounded-kit bg-paper`,children:[(0,B.jsxs)(`div`,{className:`flex justify-between items-center px-3 py-2 border-b border-sand`,children:[(0,B.jsx)(Da,{prefix:`DAVID_DECISION`}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[Yd(e.ts),` · `,e.from]})]}),(0,B.jsx)(`div`,{className:`px-3 py-2.5 text-[13px] whitespace-pre-wrap break-words line-clamp-6`,children:Qd(e.text??``,e.prefix)}),(0,B.jsxs)(`div`,{className:`flex gap-2 px-3 py-2 border-t border-sand`,children:[(0,B.jsx)(K,{tone:`primary`,size:`sm`,disabled:!te,onClick:()=>{ce(e),re(`david`),R(`DAVID_DECISION: `)},children:`Reply as David`}),!te&&(0,B.jsx)(Aa,{})]})]},e.id))})]})}var tf=[[/^PRD\.md$/i,`PRD`,`docs`],[/^CONTEXT(-MAP)?\.md$/i,`Context`,`docs`],[/^TECH_STACK\.md$/i,`Tech stack`,`kit`],[/^STACK_MAP\.md$/i,`Stack map`,`kit`],[/^ARCHITECTURE_GUIDE\.md$/i,`Architecture guide`,`board`],[/^DECISIONS\.md$/i,`Decisions (ADRs)`,`decisions`],[/^PRODUCTION_ROADMAP\.md$/i,`Roadmap`,`phases`],[/^WORKSTREAMS\.md$/i,`Workstreams`,`streams`],[/^QUEUE\.md$/i,`Queue`,`queue`],[/^DONE\.md$/i,`Done`,`done`],[/^FACTS\.md$/i,`Facts`,`facts`],[/^DESIGN_SYSTEM\.md$/i,`Design system`,`skills`],[/^GROUNDWORK_METHODOLOGY\.md$/i,`Methodology`,`knowledge`],[/^COMMANDS\.md$/i,`Commands`,`gates`],[/^_INDEX\.md$/i,`Index`,`home`],[/^ARTIFACTS\.md$/i,`Artifacts`,`kit`]],nf=/^(templates\/|phases\/templates\/|\.groundwork\/)/,rf=/^(QUEUE|DONE|WORKSTREAMS|FACTS)\.md$/i,af=e=>tf.find(([t])=>t.test(e)),of=({children:e})=>(0,B.jsx)(`div`,{className:`font-mono font-semibold text-[11px] uppercase tracking-[.1em] text-ink3 mt-4 mb-1.5 first:mt-0`,children:e}),sf=e=>{if(!e)return``;let t=Date.now()-Date.parse(e),n=Math.floor(t/864e5);return n>0?`${n} d ago`:`${Math.max(1,Math.floor(t/36e5))} h ago`};function cf(){let{current:e}=za(),{doc:t}=lr(),n=q(e?`/projects/${e}/docs`:null,2e4),r=n.data,i=r?.files??[],a=t?decodeURIComponent(t):i.find(e=>/^(README|_INDEX|DESIGN|PRD)\.md$/i.test(e))??i[0],o=!!a&&a.startsWith(`kb:`),s=q(`/knowledge`,6e4).data,c=q(a?o?`/knowledge/doc/${encodeURIComponent(a.slice(3))}`:e?`/projects/${e}/docs/${encodeURIComponent(a)}`:null:null,15e3),{data:l,error:u,loading:d}=c,f=!!a&&(rf.test(a)||o),p=q(`/admin/seam-writes`,1e4).data?.enabled??!1,[m,h]=(0,P.useState)(!1),[g,_]=(0,P.useState)(``),[v,y]=(0,P.useState)(``),[b,x]=(0,P.useState)(``),[S,C]=(0,P.useState)(null),w=m&&g!==v,[T,E]=(0,P.useState)(!0),[D,O]=(0,P.useState)(!0),[k]=Fi(),A=ar(),j=e=>{let t=e.replace(/^#\/docs\//,``).split(`#`)[0];if(!t||/^(https?:|mailto:)/.test(e))return null;let n=(a??``).split(`/`).slice(0,-1).join(`/`),r=(t.startsWith(`/`)?t.slice(1):(n?n+`/`:``)+t).split(`/`).reduce((e,t)=>(t===`..`?e.pop():t&&t!==`.`&&e.push(t),e),[]).join(`/`),o=[r,`${r}.md`,decodeURIComponent(r),`${decodeURIComponent(r)}.md`];return i.find(e=>o.some(t=>e.toLowerCase()===t.toLowerCase()))??null},M=e=>{let t=e.target.closest(`a`);if(!t)return;let n=t.getAttribute(`href`)??``;if(/^(https?:|mailto:)/.test(n))return;let r=j(n);if(e.preventDefault(),r){if(m&&w&&!window.confirm(`Discard unsaved edits?`))return;A(`/docs/${encodeURIComponent(r)}`)}else t.classList.add(`no-target`)},[N,ee]=(0,P.useState)(k.get(`view`)??`rendered`),F=k.get(`line`)?Number(k.get(`line`)):null;(0,P.useEffect)(()=>{let e=k.get(`view`);(e===`source`||e===`split`||e===`rendered`)&&ee(e)},[k]),(0,P.useEffect)(()=>{if(!F||!l)return;let e=setTimeout(()=>{document.getElementById(`L${F}`)?.scrollIntoView({block:`center`})},100);return()=>clearTimeout(e)},[F,l,N]),(0,P.useEffect)(()=>{h(!1),_(``),y(``),x(``),C(null)},[a,e]),(0,P.useEffect)(()=>{!m||w||!l||l.source===v||(_(l.source),y(l.source),x(l.sha))},[l,m,w,v]),(0,P.useEffect)(()=>{if(!w)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[w]);let I=()=>{!l||f||(_(l.source),y(l.source),x(l.sha),h(!0),ee(`split`),C(null))},te=()=>{h(!1),_(``),y(``),x(``),C(null)},ne=(0,P.useCallback)(async()=>{if(!(!e||!a||!b)){C(`saving`);try{let t=await Ia(e,a,{content:g,ifMatch:b});x(t.sha),y(g),C(`saved`),c.refresh(),n.refresh()}catch(e){C(e.message)}}},[e,a,b,g,c,n]);(0,P.useEffect)(()=>{if(!m)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),p&&w&&S!==`saving`&&ne())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m,p,w,S,ne]);let re=e=>{m&&w&&!window.confirm(`Discard unsaved edits?`)&&e.preventDefault()},L=m?g:l?.source??``,R=l?.git,z=(0,P.useMemo)(()=>{let e=[];return R?.lastCommit&&D&&e.push({kind:`commit`,label:`${R.lastCommit.short} · ${R.lastCommit.subject} · ${R.lastCommit.author} · ${sf(R.lastCommit.date)}`,hunks:R.lastCommit.hunks}),R&&T&&R.uncommitted.length&&e.push({kind:`uncommitted`,label:`working tree vs HEAD`,hunks:R.uncommitted}),e},[R,D,T]),ie=new Set(r?.lastCommit?.files??[]),ae=q(e?`/projects/${e}/agents`:null,3e4).data??{aide:null,coordinator:null};return(0,B.jsxs)(`div`,{className:`grid grid-cols-[260px_1fr_320px] min-h-full max-[1100px]:grid-cols-1`,children:[(0,B.jsxs)(`nav`,{className:`bg-cream border-r border-sand px-4 py-[18px] max-[1100px]:hidden overflow-auto max-h-[calc(100vh-48px)]`,children:[(0,B.jsx)(of,{children:`${e||`project`} · docs/`}),i.length===0&&(0,B.jsx)(`div`,{className:`text-[12px] text-umber px-1.5`,children:`no docs/ found`}),(()=>{let e=i.filter(e=>!nf.test(e)),t=tf.map(([t])=>e.find(e=>t.test(e))).filter(e=>!!e),n=e.filter(e=>/^phases\//.test(e)&&!t.includes(e)),o=e.filter(e=>!t.includes(e)&&!n.includes(e)),s=({f:e,label:t,icon:n})=>{let i=r?.status[e];return(0,B.jsxs)(V,{to:`/docs/${encodeURIComponent(e)}`,onClick:re,className:`grid grid-cols-[16px_1fr_auto] gap-2 items-center text-[13px] leading-[1.75] px-1.5 py-0.5 rounded hover:no-underline ${e===a?`text-walnut bg-linen`:`text-ink3`}`,title:e,children:[(0,B.jsx)(`span`,{className:`${e===a?`text-umber`:`text-tan`}`,children:n?Ca[n]({size:14}):Ca.docs({size:14})}),(0,B.jsx)(`span`,{className:`truncate ${t?`font-sans`:`font-mono`}`,children:t??e.replace(/^phases\//,``)}),(0,B.jsxs)(`span`,{className:`flex gap-1 items-center`,children:[i===`??`?(0,B.jsx)(`span`,{className:`text-[10px] font-mono font-semibold text-tan`,children:`new`}):i?(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-amber`,title:`uncommitted (${i})`}):null,ie.has(e)&&(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-leaf`,title:`in last commit ${r?.lastCommit?.short}`})]})]},e)};return(0,B.jsxs)(B.Fragment,{children:[t.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-2 mb-1 px-1.5`,children:`Kit docs`}),t.map(e=>{let t=af(e);return(0,B.jsx)(s,{f:e,label:t[1],icon:t[2]},e)})]}),n.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-3 mb-1 px-1.5`,children:`Phases`}),n.map(e=>(0,B.jsx)(s,{f:e,icon:`phases`},e))]}),o.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-3 mb-1 px-1.5`,children:[`Other docs · `,o.length]}),o.map(e=>(0,B.jsx)(s,{f:e},e))]}),i.length!==e.length&&(0,B.jsxs)(`div`,{className:`font-mono text-[10px] text-tan mt-2 px-1.5`,children:[i.length-e.length,` hidden (templates/, .groundwork/)`]})]})})(),r?.lastCommit&&(0,B.jsxs)(`div`,{className:`mt-3 px-1.5 text-[11px] font-mono text-ink3 leading-[1.5]`,children:[(0,B.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full bg-leaf mr-1`}),`last docs commit `,(0,B.jsx)(`b`,{className:`text-walnut`,children:r.lastCommit.short}),` · `,sf(r.lastCommit.date),(0,B.jsx)(`div`,{className:`truncate text-tan`,title:r.lastCommit.subject,children:r.lastCommit.subject})]}),(0,B.jsx)(of,{children:`Knowledge · global${s?.exists?``:` · not configured`}`}),s&&!s.exists&&(0,B.jsxs)(`div`,{className:`text-[12px] text-umber px-1.5`,children:[`No knowledge repo — run `,(0,B.jsx)(`code`,{children:`groundwork knowledge init`}),` (or `,(0,B.jsx)(`code`,{children:`link <dir>`}),`).`]}),s?.exists&&(()=>{let e=({file:e,label:t,sub:n,icon:r=`knowledge`})=>{let i=`kb:${e}`;return(0,B.jsxs)(V,{to:`/docs/${encodeURIComponent(i)}`,onClick:re,className:`grid grid-cols-[16px_1fr_auto] gap-2 items-center text-[13px] leading-[1.6] px-1.5 py-0.5 rounded hover:no-underline ${i===a?`text-walnut bg-linen`:`text-ink3`}`,title:e,children:[(0,B.jsx)(`span`,{className:i===a?`text-umber`:`text-tan`,children:Ca[r]({size:14})}),(0,B.jsx)(`span`,{className:`truncate`,children:t}),n&&(0,B.jsx)(`span`,{className:`font-mono text-[10px] text-tan`,children:n})]},i)};return(0,B.jsxs)(B.Fragment,{children:[s.index&&(0,B.jsx)(e,{file:s.index,label:`ADR index`,icon:`board`}),s.sections.map(t=>{let n=s.adrs.filter(e=>e.section===t);return n.length?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-2 mb-0.5 px-1.5`,children:t}),n.map(t=>(0,B.jsx)(e,{file:t.file,label:`${t.id} · ${t.title}`,sub:t.enf??void 0},t.file))]},t):null}),s.adrs.some(e=>e.section===`(not in INDEX)`)&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-2 mb-0.5 px-1.5`,children:`ADRs not in index`}),s.adrs.filter(e=>e.section===`(not in INDEX)`).map(t=>(0,B.jsx)(e,{file:t.file,label:`${t.id} · ${t.title}`},t.file))]}),s.notes.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mt-2 mb-0.5 px-1.5`,children:[`Notes · `,s.notes.length]}),s.notes.map(t=>(0,B.jsx)(e,{file:t.file,label:t.title??t.file.replace(/^notes\//,``),icon:`docs`},t.file))]}),(0,B.jsx)(`div`,{className:`font-mono text-[10px] text-tan mt-2 px-1.5 truncate`,title:`${s.path} · ${s.source}`,children:s.path?.replace(/^\/Users\/[^/]+/,`~`)})]})})()]}),(0,B.jsxs)(`main`,{className:`px-10 py-7 pb-16 bg-paper min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-2 flex-wrap`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3 truncate`,children:[l?.path??a??``,d&&` · loading…`,m&&w&&` · unsaved`]}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 items-center flex-wrap`,children:[R&&!R.repo&&(0,B.jsx)(G,{tone:`outline`,children:`not a git repo`}),R?.repo&&R.untracked&&(0,B.jsx)(G,{tone:`warn`,children:`untracked file`}),R?.repo&&R.tracked&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{onClick:()=>E(e=>!e),"aria-pressed":T,className:`inline-flex items-center gap-1.5 font-mono text-[12px] px-2 py-1 rounded-full border cursor-pointer ${T&&R.uncommitted.length?`bg-amber-wash text-amber border-amber-line`:`bg-paper text-umber border-dust`}`,title:`working tree vs HEAD`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-amber`}),`uncommitted · `,R.uncommitted.length,` hunk`,R.uncommitted.length===1?``:`s`]}),R.lastCommit&&(0,B.jsxs)(`button`,{onClick:()=>O(e=>!e),"aria-pressed":D,className:`inline-flex items-center gap-1.5 font-mono text-[12px] px-2 py-1 rounded-full border cursor-pointer ${D?`bg-moss-wash text-moss border-moss-line`:`bg-paper text-umber border-dust`}`,title:`${R.lastCommit.subject} · ${R.lastCommit.author}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-leaf`}),`last commit `,R.lastCommit.short,` · `,sf(R.lastCommit.date)]})]}),(0,B.jsx)(`span`,{className:`w-px h-5 bg-sand mx-1`}),(0,B.jsx)(K,{tone:`ghost`,size:`sm`,"aria-pressed":N===`rendered`,onClick:()=>ee(`rendered`),children:`Rendered`}),(0,B.jsx)(K,{tone:`ghost`,size:`sm`,"aria-pressed":N===`source`,onClick:()=>ee(`source`),children:`Source`}),(0,B.jsx)(K,{tone:`ghost`,size:`sm`,"aria-pressed":N===`split`,onClick:()=>ee(`split`),children:`Split`}),(0,B.jsx)(`span`,{className:`w-px h-5 bg-sand mx-1`}),o?(0,B.jsxs)(`span`,{className:`font-mono text-[11px] text-tan`,title:s?.path??``,children:[`global knowledge · read-only here · edit in `,s?.path?.replace(/^\/Users\/[^/]+/,`~`)]}):f?(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,title:`QUEUE/DONE/WORKSTREAMS/FACTS write through the Board (seam)`,children:`seam file · edit on Board`}):m?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(K,{size:`sm`,onClick:te,children:`Discard`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>void ne(),disabled:!p||!w||S===`saving`||!b,title:p?`Save to docs/ (⌘S)`:`seam writes are off (header → seam)`,children:S===`saving`?`Saving…`:`Save`}),!p&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:`seam writes are off (header → seam)`}),S===`saved`&&!w&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-moss`,children:`saved`}),S&&S!==`saving`&&S!==`saved`&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-brick max-w-[28ch] truncate`,title:S,children:S})]}):(0,B.jsx)(K,{size:`sm`,onClick:I,disabled:!l,title:`Edit this file in Split (source + preview). Save writes docs/ as a Run.`,children:`Edit`})]})]}),u&&(0,B.jsxs)(`div`,{className:`text-[13px] text-brick`,children:[`Could not load: `,u]}),l&&N===`rendered`&&(0,B.jsx)(`div`,{onClick:M,children:(0,B.jsx)(bu,{source:L,changes:m?[]:z})}),l&&N===`source`&&(m?(0,B.jsx)(lf,{value:g,onChange:_,readOnly:!p}):(0,B.jsx)(uf,{src:l.source,g:R,showUncommitted:T,showCommit:D,jumpLine:F})),l&&N===`split`&&(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 items-start`,children:[(0,B.jsx)(`div`,{className:`min-w-0`,onClick:M,children:(0,B.jsx)(bu,{source:L,changes:m?[]:z})}),(0,B.jsx)(`div`,{className:`min-w-0 sticky top-2`,children:m?(0,B.jsx)(lf,{value:g,onChange:_,readOnly:!p}):(0,B.jsx)(uf,{src:l.source,g:R,showUncommitted:T,showCommit:D,jumpLine:F})})]}),l&&z.length>0&&(0,B.jsxs)(`div`,{className:`mt-6 text-[12px] font-mono text-ink3`,children:[`Hover a highlighted block for its diff · `,(0,B.jsx)(`span`,{className:`text-amber`,children:`amber`}),` = uncommitted, `,(0,B.jsx)(`span`,{className:`text-leaf`,children:`green`}),` = last commit touching this file.`]})]}),(0,B.jsxs)(`aside`,{className:`bg-cream border-l border-sand p-3.5 max-[1100px]:hidden`,children:[(0,B.jsx)(`div`,{className:`flex justify-between items-center px-1 pt-1.5 pb-2`,children:(0,B.jsx)(`span`,{className:`font-semibold text-[13px] uppercase tracking-[.08em] text-umber`,children:`Ask an agent`})}),(0,B.jsxs)(`div`,{className:`grid gap-2 px-1 text-[13px]`,children:[(0,B.jsxs)(`div`,{className:`text-[12px] text-umber`,children:[`Summon opens the DM thread with its context line set to `,(0,B.jsxs)(`code`,{className:`font-mono text-[11px]`,children:[o?`groundwork-knowledge/${a.slice(3)}`:`${e}/docs/${a}`,F?`:${F}`:``]}),F?``:` — select a line in Source view (or Show line) to cite it`,`.`]}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 flex-wrap`,children:[(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>ad(ae.aide??``),disabled:!ae.aide,title:ae.aide?`DM ${ae.aide} about this doc`:`no live aide`,children:`Aide`}),(0,B.jsx)(K,{size:`sm`,onClick:()=>ad(ae.coordinator??``),disabled:!ae.coordinator,title:ae.coordinator?`DM ${ae.coordinator}`:`no live coordinator`,children:`Coordinator`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>ad(``),title:`pick from the radial`,children:`Other…`})]})]}),R?.lastCommit&&(0,B.jsxs)(`div`,{className:`mt-4 px-1 text-[12px] font-mono text-ink3 leading-[1.6]`,children:[(0,B.jsx)(`div`,{className:`text-umber font-sans font-semibold text-[13px] mb-1`,children:`Last change to this file`}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:R.lastCommit.short}),` · `,R.lastCommit.author]}),(0,B.jsx)(`div`,{children:new Date(R.lastCommit.date).toLocaleString()}),(0,B.jsx)(`div`,{className:`text-walnut mt-1 font-sans`,children:R.lastCommit.subject}),(0,B.jsxs)(`div`,{className:`mt-1 text-tan`,children:[R.lastCommit.hunks.length,` hunk`,R.lastCommit.hunks.length===1?``:`s`]})]})]})]})}function lf({value:e,onChange:t,readOnly:n}){return(0,B.jsx)(`textarea`,{value:e,onChange:e=>t(e.target.value),readOnly:n,spellCheck:!1,"aria-label":`Document source`,className:`w-full min-h-[70vh] font-mono text-[13px] leading-[1.6] whitespace-pre bg-linen border border-sand rounded-kit p-4 text-walnut resize-y ${n?`opacity-80`:``}`})}function uf({src:e,g:t,showUncommitted:n,showCommit:r,jumpLine:i}){let a=(e,t)=>!!e?.some(e=>gu(e).some(([e,n])=>t>=e&&t<n));return(0,B.jsx)(`pre`,{className:`font-mono text-[13px] leading-[1.6] whitespace-pre-wrap bg-linen border border-sand rounded-kit p-4 m-0 max-h-[80vh] overflow-auto`,children:e.split(`
35
+ `).map((e,o)=>{let s=o+1,c=n&&a(t?.uncommitted,s),l=r&&a(t?.lastCommit?.hunks,s),u=i===s;return(0,B.jsxs)(`div`,{id:`L${s}`,className:`grid grid-cols-[3.5ch_1fr] gap-3 rounded-[2px] ${u?`bg-ember-wash ring-1 ring-ember`:c?`bg-amber-wash/60`:l?`bg-moss-wash/50`:``}`,children:[(0,B.jsx)(`span`,{className:`text-right select-none ${u?`text-ember font-semibold`:`text-tan`}`,children:s}),(0,B.jsx)(`span`,{children:e||` `})]},o)})})}var df=e=>/done|merged|deployed|complete|closed|✅/i.test(e),ff=e=>df(e)?`ok`:/block/i.test(e)?`bad`:/queued|hold|wait/i.test(e)?`warn`:`neutral`;function pf({project:e}){let t=q(e?`/projects/${e}/board`:null,15e3).data,n=q(`/bus/agents`,2e4).data??[];if(!t)return null;let r=t.phases.find(e=>e.state===`ongoing`)??t.phases.find(e=>e.state===`planned`),i=t.workstreams.rows.filter(e=>!(`malformed`in e)).map(e=>e.schema===`workstreams.v1`?{name:e.stream,owner:e.owner,status:e.status,note:e.lastNote}:{name:e.lane,owner:e.owner,status:e.state,note:e.currentSlice}).filter(e=>!df(e.status)),a=e=>n.find(t=>t.agentId===e||e.includes(t.agentId))?.agentId??null;return(0,B.jsxs)(`div`,{className:`border border-sand rounded-kit bg-paper px-3 py-2 grid gap-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan`,children:`now`}),r?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(V,{to:`/board`,className:`font-semibold text-[13px] hover:no-underline text-walnut hover:text-ember-deep`,children:r.title}),(0,B.jsx)(G,{tone:r.state===`ongoing`?`david`:`neutral`,children:r.state}),(0,B.jsxs)(`span`,{className:`font-mono text-[11px] text-ink3`,children:[r.done,`/`,r.total,` tasks`,r.streams?` · ${r.streams} streams`:``]})]}):(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:`no phase in flight`}),(0,B.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-ink3`,children:[i.length,` active stream`,i.length===1?``:`s`]})]}),i.length>0&&(0,B.jsx)(`div`,{className:`flex gap-1.5 flex-wrap`,children:i.slice(0,8).map(e=>{let t=a(e.owner);return(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-kit border border-sand bg-cream/60 max-w-[360px]`,title:`${e.name} · ${e.owner} · ${e.status}${e.note?` · ${e.note}`:``}`,children:[t?(0,B.jsx)(ed,{id:t,bare:!0,size:`sm`}):(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[12px] text-umber`,children:[(0,B.jsx)(Mu,{id:e.owner,size:14,state:`dead`}),e.owner]}),(0,B.jsx)(`span`,{className:`text-[12px] truncate`,children:e.name}),(0,B.jsx)(G,{tone:ff(e.status),children:e.status.replace(/^[^\w]+/,``).slice(0,18)})]},e.name)})})]})}var mf=`/api`,hf=e=>{if(!e)return`—`;let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t} s`:t<3600?`${Math.floor(t/60)} min`:`${Math.floor(t/3600)} h`};function gf(){let{current:e}=za(),{linkify:t}=Eu(),[n,r]=(0,P.useState)(`project`),[i,a]=(0,P.useState)(40),[o,s]=(0,P.useState)(2),[c,l]=(0,P.useState)(()=>localStorage.getItem(`groundwork-console.monitor.layout`)??`grid`),[u,d]=(0,P.useState)(()=>Number(localStorage.getItem(`groundwork-console.monitor.tileW`)??520));(0,P.useEffect)(()=>{localStorage.setItem(`groundwork-console.monitor.layout`,c),localStorage.setItem(`groundwork-console.monitor.tileW`,String(u))},[c,u]);let[f,p]=(0,P.useState)([]),[m,h]=(0,P.useState)(null),[g,_]=(0,P.useState)(null),[v,y]=(0,P.useState)(!1),[b,x]=(0,P.useState)(!0),[S,C]=(0,P.useState)(0),w=q(n===`project`&&e?`/projects/${e}/board`:null,2e4).data,T=e=>(w?.workstreams.rows.filter(e=>!(`malformed`in e))??[]).map(e=>e.schema===`workstreams.v1`?{name:e.stream,owner:e.owner,status:e.status}:{name:e.lane,owner:e.owner,status:e.state}).filter(t=>(t.owner===e||t.owner.includes(e))&&!/done|merged|deployed|complete|closed|✅/i.test(t.status)),E=(0,P.useRef)({}),D=(0,P.useRef)([]),O=(()=>{let e=f.map(e=>e.agentId),t=D.current.filter(t=>e.includes(t)),n=f.filter(e=>!t.includes(e.agentId)).sort((e,t)=>!!/coordinator/i.test(t.role??``)-+!!/coordinator/i.test(e.role??``)||e.agentId.localeCompare(t.agentId)).map(e=>e.agentId);return D.current=[...t,...n],D.current.map(e=>f.find(t=>t.agentId===e)).filter(Boolean)})(),k=(0,P.useRef)({}),A=(0,P.useRef)({});(0,P.useLayoutEffect)(()=>{let e={};for(let[t,n]of Object.entries(k.current)){if(!n)continue;let r=n.getBoundingClientRect();e[t]=r;let i=A.current[t];if(i&&(i.left!==r.left||i.top!==r.top)){let e=i.left-r.left,t=i.top-r.top;n.style.transition=`none`,n.style.transform=`translate(${e}px,${t}px)`,requestAnimationFrame(()=>{n.style.transition=`transform 320ms cubic-bezier(.2,.7,.2,1)`,n.style.transform=``})}}A.current=e}),(0,P.useEffect)(()=>{let t=!0,r=async()=>{if(!v)try{let r=await fetch(`${mf}/bus/panes?lines=${i}${b?`&colors=1`:``}${n===`project`&&e?`&project=${encodeURIComponent(e)}`:``}`),a=await r.json();if(!t)return;if(!r.ok)throw Error(String(a.error??r.status));p(a),h(null),C(e=>e+1)}catch(e){t&&h(e.message)}};r();let a=setInterval(r,3e3);return()=>{t=!1,clearInterval(a)}},[n,e,i,v,b]),(0,P.useEffect)(()=>{for(let e of Object.values(E.current))e&&(e.scrollTop=e.scrollHeight)},[S]);let j=f.filter(e=>e.active).length;return(0,B.jsxs)(`div`,{className:`p-4 grid gap-3.5 content-start`,children:[g&&(0,B.jsx)(Yu,{agentId:g,onClose:()=>_(null)}),(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between flex-wrap gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Monitor`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[n===`project`?e:`all projects`,` · `,f.length,` pane`,f.length===1?``:`s`,` · `,j,` active · read-only capture every 3 s`]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsxs)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden`,children:[(0,B.jsx)(`button`,{onClick:()=>r(`project`),"aria-pressed":n===`project`,className:`px-2.5 py-[5px] text-[12px] font-medium border-0 cursor-pointer ${n===`project`?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:e||`project`}),(0,B.jsx)(`button`,{onClick:()=>r(`all`),"aria-pressed":n===`all`,className:`px-2.5 py-[5px] text-[12px] font-medium border-0 cursor-pointer ${n===`all`?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:`all`})]}),(0,B.jsxs)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden`,children:[(0,B.jsx)(`button`,{onClick:()=>l(`grid`),"aria-pressed":c===`grid`,className:`px-2.5 py-[5px] text-[12px] font-mono border-0 cursor-pointer ${c===`grid`?`bg-walnut text-paper`:`bg-paper text-umber`}`,title:`wrapping grid`,children:`grid`}),(0,B.jsx)(`button`,{onClick:()=>l(`row`),"aria-pressed":c===`row`,className:`px-2.5 py-[5px] text-[12px] font-mono border-0 cursor-pointer ${c===`row`?`bg-walnut text-paper`:`bg-paper text-umber`}`,title:`one row, scroll sideways`,children:`row`})]}),c===`grid`&&(0,B.jsx)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden`,children:[1,2,3].map(e=>(0,B.jsxs)(`button`,{onClick:()=>s(e),"aria-pressed":o===e,className:`px-2.5 py-[5px] text-[12px] font-mono border-0 cursor-pointer ${o===e?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:[e,`×`]},e))}),c===`row`&&(0,B.jsx)(`select`,{value:u,onChange:e=>d(Number(e.target.value)),className:`font-mono text-[12px] px-2 py-[5px] border border-dust rounded-kit bg-paper text-umber`,title:`tile width`,children:[420,520,640,800].map(e=>(0,B.jsxs)(`option`,{value:e,children:[e,`px`]},e))}),(0,B.jsx)(`select`,{value:i,onChange:e=>a(Number(e.target.value)),className:`font-mono text-[12px] px-2 py-[5px] border border-dust rounded-kit bg-paper text-umber`,children:[20,40,80,150].map(e=>(0,B.jsxs)(`option`,{value:e,children:[e,` lines`]},e))}),(0,B.jsxs)(`label`,{className:`font-mono text-[11px] text-ink3 flex items-center gap-1`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked)}),`colors`]}),(0,B.jsx)(K,{size:`sm`,onClick:()=>y(e=>!e),"aria-pressed":v,children:v?`Resume`:`Pause`})]})]}),n===`project`&&e&&(0,B.jsx)(pf,{project:e}),m&&(0,B.jsx)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:m}),f.length===0&&!m&&(0,B.jsxs)(U,{className:`px-4 py-4 text-[13px] text-umber`,children:[`No pane-attached agents`,n===`project`?` for ${e}`:``,`. Agents appear here when their transport is tmux-push (attach_agent) and the pane is alive.`,n===`project`&&(0,B.jsxs)(B.Fragment,{children:[` Try `,(0,B.jsx)(`button`,{className:`underline text-ember-deep bg-transparent border-0 p-0 cursor-pointer`,onClick:()=>r(`all`),children:`all projects`}),`.`]})]}),(0,B.jsx)(`div`,{className:c===`grid`?`grid gap-3.5`:`flex gap-3.5 overflow-x-auto pb-2 snap-x snap-mandatory [scrollbar-width:thin]`,style:c===`grid`?{gridTemplateColumns:`repeat(${o}, minmax(0, 1fr))`}:void 0,children:O.map(e=>(0,B.jsx)(`div`,{ref:t=>{k.current[e.agentId]=t},className:c===`row`?`shrink-0 snap-start`:`min-w-0`,style:c===`row`?{width:u}:void 0,children:(0,B.jsxs)(U,{className:`grid grid-rows-[auto_1fr_auto]`,children:[(0,B.jsx)(`div`,{style:{height:4,background:nd(e.role)}}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-sand min-w-0`,children:[(0,B.jsx)(Mu,{id:e.agentId,role:e.role,size:20,state:e.liveness,active:e.active}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`block font-mono font-semibold text-[13px] truncate leading-tight`,children:e.agentId}),(0,B.jsxs)(`span`,{className:`block font-mono text-[10px] uppercase tracking-[.06em] leading-tight`,style:{color:nd(e.role)},children:[rd(e.role),n===`project`&&T(e.agentId).length>0?(0,B.jsxs)(`span`,{className:`text-ink3 normal-case tracking-normal`,children:[` · `,T(e.agentId).map(e=>e.name).join(` · `)]}):``]})]}),n===`all`&&e.project&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan truncate`,children:e.project}),(0,B.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-ink3`,title:`last pane output`,children:e.active?(0,B.jsx)(G,{tone:`ok`,children:`active`}):(0,B.jsxs)(`span`,{className:`text-tan`,children:[`quiet `,hf(e.paneActivity)]})}),(0,B.jsx)(`button`,{className:`font-mono text-[11px] text-ember-deep bg-transparent border-0 cursor-pointer`,onClick:()=>ad(e.agentId),title:`DM this agent (Summon)`,children:`DM`}),(0,B.jsx)(`button`,{className:`font-mono text-[11px] text-ember-deep bg-transparent border-0 cursor-pointer underline decoration-dotted`,onClick:()=>_(e.agentId),title:`open full pane`,children:e.pane})]})]}),(0,B.jsx)(`pre`,{ref:t=>{E.current[e.agentId]=t},className:`m-0 px-3 py-2 overflow-auto font-mono text-[11.5px] leading-[1.4] whitespace-pre-wrap break-words pane-dark`,style:{height:`${Math.min(i,80)*16+16}px`},children:e.capture?t(b&&e.capture.ansi?uo(e.capture.ansi):e.capture.text,e.project??void 0):`—`})]})},e.agentId))}),(0,B.jsxs)(`div`,{className:`font-mono text-[11px] text-tan`,children:[`pulsing dot = output in the last 60 s · `,c===`row`?`row: scroll sideways (shift+wheel / trackpad), tiles snap`:`grid wraps; switch to row for 8+ agents`,` · tiles auto-scroll to the bottom · click a pane id for the full, follow-able view · the console never types into panes — DM opens the agent's thread (Summon)`]})]})}var _f=[{to:`fleets`,label:`Fleets`,icon:`fleet`,hint:`presence · spawn · unregister · prune · decommission`},{to:`skills`,label:`Skills`,icon:`skills`,hint:`groundwork / playbook skills · updates`},{to:`release`,label:`Release`,icon:`release`,hint:`kit versions · PRs · gates`},{to:`runs`,label:`Runs`,icon:`health`,hint:`every action the console performed`},{to:`events`,label:`Events`,icon:`bus`,hint:`mechanical rules → coordinator (dry-run by default)`}];function vf(){let{running:e}=Ha(),t=rr(),n=_f.find(e=>t.pathname.startsWith(`/ops/${e.to}`));return(0,B.jsxs)(`div`,{className:`grid grid-rows-[auto_1fr] min-h-0`,children:[(0,B.jsxs)(`div`,{className:`px-4 pt-3 flex items-end gap-1 border-b border-sand bg-cream/60`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.1em] text-tan mr-2 pb-2.5`,children:`ops`}),_f.map(t=>(0,B.jsxs)(ji,{to:t.to,className:({isActive:e})=>`inline-flex items-center gap-1.5 px-3 py-2 -mb-px border-b-2 text-[13px] font-medium hover:no-underline ${e?`border-ember text-walnut`:`border-transparent text-ink3 hover:text-umber`}`,title:t.hint,children:[(0,B.jsx)(`span`,{className:`text-tan`,children:Ca[t.icon]({size:14})}),t.label,t.to===`runs`&&e>0?(0,B.jsx)(`span`,{className:`ml-1 inline-flex items-center justify-center min-w-4 h-4 px-1 rounded-full bg-ember text-paper font-mono text-[10px]`,children:e}):null]},t.to)),n&&(0,B.jsx)(`span`,{className:`ml-auto pb-2.5 font-mono text-[11px] text-tan hidden lg:inline`,children:n.hint})]}),(0,B.jsx)(Rr,{})]})}function yf(){return(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsx)(wd,{})})}function bf({title:e,danger:t,body:n,confirmWord:r,action:i,payload:a,preview:o,onClose:s}){let[c,l]=(0,P.useState)(``),[u,d]=(0,P.useState)(!1),[f,p]=(0,P.useState)(null),[m,h]=(0,P.useState)(null),g=async()=>{d(!0);try{p(await Fa(i,{...a,confirm:c}))}finally{d(!1)}},_=async()=>{if(o){d(!0);try{h(await o())}finally{d(!1)}}},v=e=>(0,B.jsxs)(`div`,{className:`p-2 rounded-kit border ${e.status===`ok`?`border-moss-line bg-moss-wash/50`:`border-brick-line bg-brick-wash/50`}`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px]`,children:[(0,B.jsx)(G,{tone:e.status===`ok`?`ok`:`bad`,children:e.status}),` `,(0,B.jsx)(`b`,{children:e.label})]}),(0,B.jsxs)(`pre`,{className:`m-0 mt-1 font-mono text-[12px] whitespace-pre-wrap max-h-[30vh] overflow-auto`,children:[e.log.join(`
36
36
  `),e.result===void 0?``:`
37
37
  `+JSON.stringify(e.result,null,1).slice(0,2e3),e.error?`
38
- `+e.error:``]})]});return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[10vh]`,onMouseDown:e=>{e.target===e.currentTarget&&s()},children:(0,B.jsxs)(`div`,{className:`w-[600px] bg-paper border rounded-kit shadow-panel ${t?`border-brick`:`border-sand`}`,children:[(0,B.jsx)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] ${t?`text-brick`:`text-umber`}`,children:e}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px] text-umber`,children:[n,o&&!m&&(0,B.jsx)(`div`,{children:(0,B.jsx)(K,{size:`sm`,onClick:_,disabled:u,children:u?`…`:`Preview (dry-run)`})}),m&&v(m),!f&&(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:[`Type `,r,` to confirm`]}),(0,B.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]}),f&&v(f)]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:s,children:f?`Close`:`Cancel`}),!f&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:g,disabled:c!==r||u,children:u?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Ma,{}),` Running…`]}):`Run`})]})]})})}var bf=`18px 1.6fr 1fr 1fr 1fr 1.2fr auto`,xf=[[`automation`,`groundwork-console: reads + prefixed sends only; no record authority`],[`coordinator`,`routes work, noise sink, faces the fleet`],[`coord-worker`,`lane owner, own worktree, cites every DONE`],[`coord-qa`,`quality gate; PASS/FAIL @ head`],[`coord-ci`,`release operator; merges on cited PASS`],[`coord-aide`,`David’s comms point; owns QUEUE`],[`coord-audit`,`read-only architecture drift`],[`coord-fleet`,`stands up a fleet in tmux`],[`coord-handover`,`context-clear snapshot`]],Sf=e=>e===null?`—`:e<6e4?`just now`:e<36e5?`${Math.round(e/6e4)} min`:e<864e5?`${Math.round(e/36e5)} h`:`${Math.round(e/864e5)} d`;function Cf(){let{current:e,projects:t}=za(),{data:n,error:r,loading:i}=q(`/bus/agents`,2e4),[a,o]=(0,P.useState)(`project`),{runs:s}=Ha(),c=q(`/kit`).data,[l,u]=(0,P.useState)(!1),d=s.find(e=>e.label===`bus doctor`&&e.status===`ok`),f=d?.result,p=async()=>{u(!0);try{await Fa(`/actions/bus-doctor`)}finally{u(!1)}},[m,h]=(0,P.useState)(!1),[g,_]=(0,P.useState)(null),[v,y]=(0,P.useState)(null),[b,x]=(0,P.useState)(!1),[S,C]=(0,P.useState)(!1),w=q(a===`project`&&e?`/projects/${e}/fleet`:null,2e4).data,T=q(`/admin/bus-writes`,1e4).data?.enabled??!1,E=ar(),D=n??[],O=t.find(t=>t.name===e)?.room,k=D.filter(t=>t.project===e||O&&t.project===O),A=a===`project`?k:D,j=A.filter(e=>e.liveness===`dead`&&![`groundwork-console`,`david`].includes(e.agentId)).map(e=>e.agentId),M=A.filter(e=>e.liveness===`live`).length,N=e=>t.find(t=>t.name===e.project||t.room&&t.room===e.project)?.name,ee=e=>N(e)??`~${e.project??`—`}`,F=a===`all`?[...new Set(D.map(ee))].sort((e,t)=>!!e.startsWith(`~`)-+!!t.startsWith(`~`)||e.localeCompare(t)):[e],I=e=>{if(e.startsWith(`~`))return{title:`#${e.slice(1)}`,path:`not registered as a project`,registered:!1};let n=t.find(t=>t.name===e);return{title:e,path:n?.room?`#${n.room}`:`no room linked`,registered:!0}};return(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_340px] gap-4 p-4 max-[980px]:grid-cols-1`,children:[(0,B.jsxs)(`div`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3 flex-wrap`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Fleets`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber whitespace-nowrap`,children:[a===`project`?`${e} · `:`all projects · `,A.length,` registered · `,M,` live`]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap justify-end`,children:[(0,B.jsxs)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden whitespace-nowrap`,children:[(0,B.jsxs)(`button`,{onClick:()=>o(`project`),"aria-pressed":a===`project`,className:`px-2.5 py-[5px] text-[12px] font-medium border-0 cursor-pointer ${a===`project`?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:[e||`project`,` · `,k.length]}),(0,B.jsxs)(`button`,{onClick:()=>o(`all`),"aria-pressed":a===`all`,className:`px-2.5 py-[5px] text-[12px] font-medium border-0 cursor-pointer ${a===`all`?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:[`all · `,D.length]})]}),(0,B.jsx)(K,{size:`sm`,onClick:()=>E(`/monitor`),children:`Monitor`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>x(!0),title:`spawn an agent into tmux for this project`,children:`Spawn agent…`}),(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(K,{size:`sm`,onClick:()=>C(e=>!e),"aria-expanded":S,children:`Admin ▾`}),S&&(0,B.jsxs)(`div`,{className:`absolute right-0 top-[calc(100%+6px)] z-40 w-[260px] bg-paper border border-sand rounded-kit shadow-panel whitespace-normal text-left`,onMouseLeave:()=>C(!1),children:[(0,B.jsxs)(`button`,{className:`w-full text-left px-3 py-2 text-[13px] border-0 bg-transparent cursor-pointer hover:bg-linen border-b border-sand`,onClick:()=>{C(!1),p()},disabled:l,children:[l?`Running doctor…`:`Run bus doctor`,(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`MCP doctor as groundwork-console · read-only`})]}),(0,B.jsxs)(`button`,{className:`w-full text-left px-3 py-2 text-[13px] border-0 bg-transparent cursor-pointer hover:bg-linen border-b border-sand`,onClick:()=>{C(!1),_({kind:`prune`})},children:[`Prune bus data…`,(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`old messages/status/inbox · dry-run first`})]}),(0,B.jsxs)(`button`,{className:`w-full text-left px-3 py-2 text-[13px] border-0 bg-transparent cursor-pointer hover:bg-linen border-b border-sand disabled:opacity-50`,onClick:()=>{C(!1),_({kind:`dead`})},disabled:j.length===0,children:[`Unregister dead (`,j.length,a===`project`?` in ${e}`:``,`)…`,(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`force_unregister agents inactive > 24 h`})]}),O&&(0,B.jsxs)(`button`,{className:`w-full text-left px-3 py-2 text-[13px] border-0 bg-transparent cursor-pointer hover:bg-linen text-brick`,onClick:()=>{C(!1),h(!0)},children:[`Decommission fleet + #`,O,`…`,(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`unregister members + delete room`})]}),!T&&(0,B.jsx)(`div`,{className:`px-3 py-2 font-mono text-[11px] text-tan border-t border-sand`,children:`bus writes are off — admin actions dry-run / refuse`})]})]})]})]}),b&&(0,B.jsx)(kd,{project:e,canWrite:T,onClose:()=>{x(!1)}}),v&&(0,B.jsx)(Ju,{agentId:v,onClose:()=>y(null)}),g?.kind===`prune`&&(0,B.jsx)(yf,{title:`Prune bus data`,confirmWord:`PRUNE`,action:`/actions/prune`,payload:{dryRun:!1,olderThanDays:30,targets:[`rooms`,`status`,`inbox`,`receipts`,`members`],removeOrphanInboxes:!0},preview:()=>Fa(`/actions/prune`,{dryRun:!0,olderThanDays:30,targets:[`rooms`,`status`,`inbox`,`receipts`,`members`],removeOrphanInboxes:!0}),onClose:()=>_(null),body:(0,B.jsxs)(`div`,{children:[`MCP `,(0,B.jsx)(`code`,{children:`prune`}),`: removes room messages / status entries / inbox items / receipts older than `,(0,B.jsx)(`b`,{children:`30 days`}),` (decisions kept longer), orphan inboxes and stale memberships. Preview first — the tool has a native dry-run. Requires bus writes on.`]})}),g?.kind===`dead`&&(0,B.jsx)(yf,{danger:!0,title:`Unregister ${j.length} dead agent${j.length===1?``:`s`}`,confirmWord:`UNREGISTER`,action:`/actions/unregister-dead`,payload:{agentIds:j},onClose:()=>_(null),body:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`code`,{children:`force_unregister`}),` for every agent in `,(0,B.jsx)(`b`,{children:a===`project`?e:`all projects`}),` whose last activity is over 24 h old: `,(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-walnut break-words`,children:j.join(`, `)}),`. Registry entries, transports and inbox markers go; room history stays. Requires bus writes on.`]})}),g?.kind===`one`&&(0,B.jsx)(yf,{danger:!0,title:`Unregister ${g.id}`,confirmWord:g.id,action:`/actions/unregister`,payload:{agentId:g.id},onClose:()=>_(null),body:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`code`,{children:`force_unregister`}),` `,(0,B.jsx)(`b`,{children:g.id}),`. Requires bus writes on.`]})}),m&&O&&(0,B.jsx)(wf,{room:O,project:e,agents:k.map(e=>e.agentId),onClose:()=>h(!1)}),r&&(0,B.jsxs)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:[`API error: `,r]}),a===`project`&&w?.state===`present`&&(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Fleet`,icon:`fleet`,path:`${w.live.length} live · topology`}),(0,B.jsx)(`div`,{className:`px-3 py-3`,children:(0,B.jsx)(Ad,{project:e,fleet:w,canWrite:T,onOpenPane:e=>y(e)})})]}),a===`project`&&(0,B.jsx)(Nd,{project:e,canWrite:T}),A.length===0&&!i&&a===`all`&&(0,B.jsx)(U,{className:`px-4 py-3 text-[13px] text-umber`,children:`No agents registered on the bus.`}),F.filter(e=>a!==`all`||A.some(t=>ee(t)===e)).map(e=>{let t=I(e),n=a===`all`?A.filter(t=>ee(t)===e):A;return(0,B.jsxs)(U,{children:[a===`all`&&(0,B.jsx)(W,{title:t.title,icon:`fleet`,path:`${t.path} · ${n.length} agent${n.length===1?``:`s`}`,children:!t.registered&&(0,B.jsx)(G,{tone:`outline`,children:`not registered`})}),(0,B.jsxs)(ka,{cols:bf,children:[(0,B.jsx)(`span`,{}),(0,B.jsx)(`span`,{children:`Agent`}),(0,B.jsx)(`span`,{children:`Role`}),(0,B.jsx)(`span`,{children:`Project`}),(0,B.jsx)(`span`,{children:`Transport`}),(0,B.jsx)(`span`,{children:`Pane · last seen`}),(0,B.jsx)(`span`,{})]}),n.map(e=>(0,B.jsxs)(`div`,{className:`grid gap-3 items-center px-3 min-h-10 border-b border-sand last:border-b-0 hover:bg-linen/60`,style:{gridTemplateColumns:bf},children:[(0,B.jsx)(ja,{state:e.liveness,active:e.active}),(0,B.jsx)(`span`,{className:`font-mono font-medium text-[13px] truncate`,children:e.agentId}),(0,B.jsx)(`span`,{className:`text-umber text-[13px] truncate`,children:e.role??`—`}),(0,B.jsx)(`span`,{className:`font-mono text-[13px] truncate`,children:e.project??`—`}),(0,B.jsx)(`span`,{className:`justify-self-start`,children:e.transport?(0,B.jsx)(G,{tone:`outline`,children:e.transport}):e.liveness===`dead`?(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`—`}):(0,B.jsx)(G,{tone:`warn`,children:`not attached`})}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,children:[e.pane?(0,B.jsx)(`button`,{className:`border-0 bg-transparent p-0 font-mono text-[12px] text-ember-deep cursor-pointer underline decoration-dotted`,onClick:()=>y(e.agentId),title:`view pane`,children:e.pane}):`—`,` · `,Sf(e.heartbeatAgeMs),e.paneCommand?(0,B.jsxs)(`span`,{className:`text-tan`,children:[` · `,e.paneCommand]}):``]}),e.liveness===`dead`?(0,B.jsx)(K,{tone:`ghost`,size:`sm`,onClick:()=>_({kind:`one`,id:e.agentId}),children:`Unregister`}):(0,B.jsx)(K,{tone:`ghost`,size:`sm`,onClick:()=>id(e.agentId),children:`DM`})]},e.agentId))]},e)})]}),(0,B.jsxs)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Liveness rule`,icon:`health`,path:`pane activity ∨ heartbeat`}),(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[13px] text-umber`,children:[`last seen = freshest of tmux `,(0,B.jsx)(`code`,{children:`window_activity`}),`, heartbeat, transport/inbox mtimes · `,(0,B.jsx)(`b`,{className:`text-walnut`,children:`live`}),` < 15 min · idle < 24 h · dead beyond. Pulsing dot = pane output in the last 60 s. Click a pane id to watch it (read-only).`]})]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Roles`,icon:`fleet`,path:`playbook ${c?.packages?.playbook?.version??`…`}`}),(0,B.jsx)(`div`,{className:`px-3 pt-1.5 pb-2.5 grid gap-1 text-[13px] text-umber`,children:xf.map(([e,t])=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:e}),` — `,t]},e))})]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Bus doctor`,icon:`doctor`,path:f?`mcp doctor · ${new Date(d.endedAt??d.startedAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`:`mcp doctor as groundwork-console`,children:f&&(0,B.jsx)(G,{tone:f.healthy?`ok`:`warn`,children:f.healthy?`healthy`:`${f.summary.warn} warn · ${f.summary.error} error`})}),!f&&(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[13px] text-umber`,children:[`Press `,(0,B.jsx)(`b`,{children:`Run doctor`}),` — calls the MCP `,(0,B.jsx)(`code`,{children:`doctor`}),` tool as `,(0,B.jsx)(`code`,{children:`groundwork-console`}),` (automation). Read-only; `,(0,B.jsx)(`code`,{children:`fix`}),` stays gated.`]}),f?.findings.filter(e=>e.level!==`ok`).map(e=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[var(--spacing-gutter)_1fr] min-h-10 items-center border-b border-sand last:border-b-0`,children:[(0,B.jsx)(`div`,{className:`self-stretch flex items-center justify-center font-mono text-[12px] text-tan border-r border-sand`,children:`!`}),(0,B.jsxs)(`div`,{className:`px-3 py-2 min-w-0`,children:[(0,B.jsx)(G,{tone:e.level===`error`?`bad`:`warn`,children:e.check}),e.fixable&&(0,B.jsx)(`span`,{className:`ml-1.5 inline-flex`,children:(0,B.jsx)(G,{tone:`outline`,children:`fixable`})}),e.detail&&(0,B.jsx)(`div`,{className:`text-[13px] text-umber mt-1 break-words`,children:e.detail})]})]},e.check)),f&&(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[12px] font-mono text-ink3`,children:[f.summary.ok,` ok · `,f.summary.warn,` warn · `,f.summary.error,` error`]})]})]})]})}function wf({room:e,project:t,agents:n,onClose:r}){let[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(null);return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[12vh]`,onMouseDown:e=>{e.target===e.currentTarget&&r()},children:(0,B.jsxs)(`div`,{className:`w-[560px] bg-paper border border-brick rounded-kit shadow-panel`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] text-brick`,children:[`Decommission fleet + channel #`,e]}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px]`,children:[(0,B.jsxs)(`div`,{className:`text-umber`,children:[`This will `,(0,B.jsxs)(`b`,{className:`text-walnut`,children:[`force_unregister `,n.length,` agent`,n.length===1?``:`s`]}),` (`,n.slice(0,6).join(`, `),n.length>6?`…`:``,`), then `,(0,B.jsxs)(`b`,{className:`text-walnut`,children:[`delete_room #`,e]}),` (message history is kept in `,(0,B.jsx)(`code`,{children:`~/agent-coord/history`}),`). Repo and seam files are never touched.`]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),` also remove `,(0,B.jsx)(`b`,{children:t}),` from groundwork-console.config.json`]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Type the room name to confirm`}),(0,B.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:e,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]}),(0,B.jsxs)(`div`,{className:`text-[12px] text-umber`,children:[`Bus writes are gated: without `,(0,B.jsx)(`code`,{children:`GROUNDWORK_CONSOLE_BUS_WRITES=1`}),` on the API this runs as a `,(0,B.jsx)(`b`,{children:`dry-run`}),` and records what it would do (see Runs). With the switch on, it executes as `,(0,B.jsx)(`code`,{children:`groundwork-console`}),`.`]}),u&&(0,B.jsxs)(`div`,{className:`p-2 rounded-kit border ${u.status===`ok`?`border-moss-line bg-moss-wash/50`:`border-brick-line bg-brick-wash/50`}`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px]`,children:[(0,B.jsx)(G,{tone:u.status===`ok`?`ok`:`bad`,children:u.status}),` `,(0,B.jsx)(`b`,{children:u.label})]}),(0,B.jsx)(`pre`,{className:`m-0 mt-1 font-mono text-[12px] whitespace-pre-wrap`,children:u.log.join(`
39
- `)})]})]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:r,children:u?`Close`:`Cancel`}),!u&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:async()=>{l(!0);try{d(await Fa(`/actions/decommission`,{room:e,confirm:i,removeProject:o}))}finally{l(!1)}},disabled:i!==e||c,children:c?`Running…`:`Decommission`})]})]})})}var Tf=`1.4fr .6fr .9fr .9fr 1.2fr 2fr`,Ef=({on:e,label:t})=>(0,B.jsx)(`span`,{className:`font-mono text-[11px] px-1.5 py-0.5 rounded ${e?`bg-linen text-umber`:`text-tan line-through opacity-60`}`,children:t});function Df(){let{current:e}=za(),{data:t,error:n,refresh:r}=q(e?`/projects/${e}/skills`:null,6e4),[i,a]=(0,P.useState)(null);if(n)return(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsxs)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:[`API error: `,n]})});if(!t)return(0,B.jsx)(`div`,{className:`p-4 text-umber`,children:`Scanning skills…`});let o=t.groundwork,s=t.playbook,c=o.skills.filter(e=>e.installed&&e.inSync===!1).length+s.cards.filter(e=>e.installed&&(e.inSync===!1||e.legacyEssay)).length+ +!!o.driftedVersion+s.legacyDirs.length;return(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_340px] gap-4 p-4 max-[980px]:grid-cols-1`,children:[i===`gwinit`&&(0,B.jsx)(yf,{title:`groundwork init · ${e}`,confirmWord:e,action:`/actions/groundwork-init/${e}`,payload:{},onClose:()=>{a(null),r()},body:(0,B.jsxs)(`div`,{children:[`Runs `,(0,B.jsx)(`code`,{children:`groundwork init <repo>`}),` — installs the skills, IDE mirrors and the `,(0,B.jsx)(`code`,{children:`docs/`}),` scaffold (WORKSTREAMS/QUEUE/DONE/FACTS, methodology, templates, phases/) into the working tree. Nothing is committed; review with `,(0,B.jsx)(`code`,{children:`git status`}),`. Only offered when `,(0,B.jsx)(`code`,{children:`docs/.groundwork/VERSION`}),` is missing.`]})}),i===`gw`&&(0,B.jsx)(yf,{title:`groundwork update · ${e}`,confirmWord:e,action:`/actions/groundwork-update/${e}`,payload:{all:!0,docs:!0},onClose:()=>{a(null),r()},body:(0,B.jsxs)(`div`,{children:[`Runs `,(0,B.jsxs)(`code`,{children:[`groundwork update `,`<repo>`,` --all --docs`]}),` from the kit (`,o.kitVersion,`): refreshes installed skills + IDE mirrors, adds skills added upstream, refreshes the generic reference docs (methodology, COMMANDS, _INDEX), bumps `,(0,B.jsx)(`code`,{children:`docs/.groundwork/VERSION`}),`. `,(0,B.jsx)(`b`,{className:`text-walnut`,children:`Writes into the repo working tree`}),` (uncommitted — review in Docs, which highlights the changes). Project docs (PRD, WORKSTREAMS…) are left alone.`]})}),i===`pb`&&(0,B.jsx)(yf,{title:`agent-coordination update (global)`,confirmWord:`UPDATE`,action:`/actions/playbook-update`,payload:{dryRun:!1},preview:()=>Fa(`/actions/playbook-update`,{dryRun:!0}),onClose:()=>{a(null),r()},body:(0,B.jsxs)(`div`,{children:[`Re-syncs the playbook field cards into `,(0,B.jsx)(`code`,{children:`~/.claude/skills`}),` (+ essay + slices, all harness mirrors) from the kit (`,s.kitVersion,`); removes legacy dirs. Machine-global. Preview shows the exact plan.`]})}),(0,B.jsxs)(`div`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Skills`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[`what each harness can run — `,e,` and globally · byte-compared to the kit`]})]}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[c,` need attention`]})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Groundwork · per repo`,icon:`skills`,eyebrow:`payload/skills · .claude/skills`,path:`marker ${o.versionMarker??`—`} · kit ${o.kitVersion}`,children:[o.driftedVersion&&(0,B.jsxs)(G,{tone:`warn`,children:[`behind `,o.kitVersion]}),!o.versionMarker&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>a(`gwinit`),title:`this repo has no docs/.groundwork/VERSION — install Groundwork`,children:`groundwork init…`}),o.versionMarker&&(0,B.jsx)(K,{size:`sm`,tone:o.driftedVersion?`primary`:`default`,onClick:()=>a(`gw`),children:`groundwork update…`})]}),(0,B.jsxs)(ka,{cols:Tf,children:[(0,B.jsx)(`span`,{children:`Skill`}),(0,B.jsx)(`span`,{children:`Tier`}),(0,B.jsx)(`span`,{children:`Installed`}),(0,B.jsx)(`span`,{children:`In sync`}),(0,B.jsx)(`span`,{children:`Mirrors`}),(0,B.jsx)(`span`,{children:`Description`})]}),o.skills.map(e=>(0,B.jsxs)(`div`,{className:`grid gap-3 items-center px-3 min-h-10 border-b border-sand last:border-b-0 hover:bg-linen/60`,style:{gridTemplateColumns:Tf},children:[(0,B.jsxs)(`span`,{className:`font-mono font-medium text-[13px]`,children:[`/`,e.name]}),(0,B.jsx)(`span`,{children:(0,B.jsx)(G,{tone:e.tier===`min`?`neutral`:`outline`,children:e.tier===`min`?`core`:`optional`})}),(0,B.jsx)(`span`,{children:e.installed?(0,B.jsx)(G,{tone:`ok`,children:`installed`}):(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`—`})}),(0,B.jsx)(`span`,{children:e.installed?e.inSync?(0,B.jsx)(G,{tone:`ok`,children:`= kit`}):(0,B.jsx)(G,{tone:`warn`,children:`differs`}):(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`—`})}),(0,B.jsxs)(`span`,{className:`flex gap-1`,children:[(0,B.jsx)(Ef,{on:e.mirrors.cursor,label:`cursor`}),(0,B.jsx)(Ef,{on:e.mirrors.vscode,label:`vscode`})]}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,title:e.description,children:e.description})]},e.name))]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Playbook · machine-global`,icon:`skills`,eyebrow:`field cards`,path:`${(s.homes??[]).map(e=>`${e.harness}: ${e.dir.replace(/^\/Users\/[^/]+/,`~`)}`).join(` · `)||`~/.claude/skills`} · kit ${s.kitVersion}`,children:(0,B.jsx)(K,{size:`sm`,onClick:()=>a(`pb`),children:`agent-coordination update…`})}),(0,B.jsxs)(ka,{cols:Tf,children:[(0,B.jsx)(`span`,{children:`Card`}),(0,B.jsx)(`span`,{children:`Slices`}),(0,B.jsx)(`span`,{children:`Installed`}),(0,B.jsx)(`span`,{children:`In sync`}),(0,B.jsx)(`span`,{children:`Mirrors`}),(0,B.jsx)(`span`,{children:`Description`})]}),s.cards.map(e=>(0,B.jsxs)(`div`,{className:`grid gap-3 items-center px-3 min-h-10 border-b border-sand last:border-b-0 hover:bg-linen/60`,style:{gridTemplateColumns:Tf},children:[(0,B.jsxs)(`span`,{className:`font-mono font-medium text-[13px]`,children:[`/`,e.name]}),(0,B.jsx)(`span`,{children:e.legacyEssay?(0,B.jsx)(G,{tone:`warn`,children:`775-line essay`}):(0,B.jsxs)(G,{tone:`outline`,children:[e.slices,` slice`,e.slices===1?``:`s`]})}),(0,B.jsx)(`span`,{children:e.installed?(0,B.jsx)(G,{tone:`ok`,children:`installed`}):(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`—`})}),(0,B.jsx)(`span`,{children:e.installed?e.inSync?(0,B.jsx)(G,{tone:`ok`,children:`= kit`}):(0,B.jsx)(G,{tone:`warn`,children:`differs`}):(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`—`})}),(0,B.jsxs)(`span`,{className:`flex gap-1 flex-wrap`,children:[(0,B.jsx)(Ef,{on:e.installed,label:`claude`}),(0,B.jsx)(Ef,{on:!!e.homes?.grok?.installed,label:`grok${e.homes?.grok?.installed&&e.homes.grok.inSync===!1?` ≠`:``}`}),(0,B.jsx)(Ef,{on:e.mirrors.cursor,label:`cursor`}),(0,B.jsx)(Ef,{on:e.mirrors.vscode,label:`vscode`}),(0,B.jsx)(Ef,{on:e.mirrors.opencode,label:`opencode`})]}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,title:e.description,children:e.description})]},e.name)),s.legacyDirs.length>0&&(0,B.jsxs)(`div`,{className:`px-3 py-2 border-t border-sand text-[13px]`,children:[(0,B.jsx)(G,{tone:`warn`,children:`legacy dirs`}),` `,(0,B.jsxs)(`span`,{className:`text-umber`,children:[s.legacyDirs.join(`, `),` still in `,s.globalDir,` — installer removes them`]})]})]})]}),(0,B.jsxs)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`How this is measured`,icon:`doctor`}),(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[13px] text-umber grid gap-1.5`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`In sync`}),` — SHA-1 of the installed `,(0,B.jsx)(`code`,{children:`SKILL.md`}),` equals the kit source (installers copy verbatim).`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`Mirrors`}),` — presence of `,(0,B.jsx)(`code`,{children:`.cursor/commands/<n>.md`}),`, `,(0,B.jsx)(`code`,{children:`.vscode/prompts/<n>.prompt.md`}),`, `,(0,B.jsx)(`code`,{children:`~/.config/opencode/skills/<n>`}),`.`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`Marker`}),` — `,(0,B.jsx)(`code`,{children:`docs/.groundwork/VERSION`}),` vs the kit’s groundwork version.`]}),(0,B.jsxs)(`div`,{children:[`Asked grok for `,(0,B.jsx)(`code`,{children:`groundwork list --json`}),` / `,(0,B.jsx)(`code`,{children:`agent-coordination list --json`}),` to replace the scan.`]})]})]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Harness mirrors`,icon:`skills`,path:`seam skills-mirror`}),(0,B.jsxs)(`div`,{className:`px-3 py-2 grid gap-2 text-[13px] text-umber`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`Claude Code`}),` — canonical `,(0,B.jsx)(`code`,{children:`SKILL.md`}),`; playbook global.`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`Cursor`}),` — `,(0,B.jsx)(`code`,{children:`.cursor/commands`}),`, GENERATED banner.`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`VS Code`}),` — `,(0,B.jsx)(`code`,{children:`.vscode/prompts`}),`, mode from allowed-tools.`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`OpenCode`}),` — auto-discovers `,(0,B.jsx)(`code`,{children:`~/.claude/skills`}),`; templated MCP tool names.`]})]})]})]})]})}var Of=[[`Tier 0 · QA gate`,`typecheck · build · real tests · independent behaviour check → VERDICT PASS @ head`,`coord-qa`],[`Tier 1 · merge → qa`,`CI merges on cited PASS, squash-verify, auto-deploy to qa in < 10 min, smoke`,`coord-ci`],[`Tier 2 · async`,`long suites, perf, security — never blocking; results chased by ci`,`coord-ci`],[`Prod · promotion`,`David only. Fix-forward on qa.`,`david`]],kf={"Open PRs":`prs`,"Cutover Gates":`gates`,"Needs David":`needsDavid`,Risks:`risks`,Rooms:`rooms`,"Decisions Recorded":`decisions`},Af=e=>/pass|merged|deployed|✅|green|done/i.test(e)?`ok`:/fail|red|blocked/i.test(e)?`bad`:/david/i.test(e)?`david`:/hold|risk|pending|open/i.test(e)?`warn`:`neutral`,jf=e=>!!e&&Ta.includes(e),Mf=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;function Nf({s:e}){let t=e.table?e.table.headers.map(()=>`1fr`).join(` `):``;return(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:e.title,icon:kf[e.title],eyebrow:`## ${e.title} · coordinator-only`,path:`docs/WORKSTREAMS.md`}),e.table&&e.table.rows.length>0&&(0,B.jsx)(ka,{cols:t,children:e.table.headers.map(e=>(0,B.jsx)(`span`,{children:e},e))}),e.table&&e.table.rows.length===1&&Object.values(e.table.rows[0]).every(e=>/^(—|-|none|n\/a|)$/i.test(e.trim())||/none open/i.test(e))?(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`none open`}):e.table?.rows.map((n,r)=>(0,B.jsx)(Oa,{glyph:`|`,raw:Object.values(n).join(` | `),children:(0,B.jsx)(`div`,{className:`grid gap-3 items-center py-1.5`,style:{gridTemplateColumns:t},children:e.table.headers.map((e,t)=>{let r=n[e]??``,i=/status|state|gate|verdict/i.test(e),a=r.length<=28&&!/[`(]/.test(r);return(0,B.jsx)(`span`,{className:`min-w-0 truncate ${t===0?`font-medium`:`text-[13px] text-umber`}`,title:r,children:i&&r&&a?(0,B.jsx)(G,{tone:Af(r),children:r}):r||(0,B.jsx)(`span`,{className:`text-tan`,children:`—`})},e)})})},r)),e.bullets?.map((e,t)=>(0,B.jsx)(Oa,{glyph:`-`,children:(0,B.jsx)(`div`,{className:`py-2 text-[14px]`,children:e})},t)),!e.table?.rows.length&&!e.bullets?.length&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`empty`})]})}function Pf(){let{current:e}=za(),{data:t,error:n}=q(e?`/projects/${e}/release`:null,3e4),r=q(`/kit`).data;if(n)return(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsxs)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:[`API error: `,n]})});let i=t?.extensions??[],a=i.filter(e=>e.title!==`Rooms`);return(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_340px] gap-4 p-4 max-[980px]:grid-cols-1`,children:[(0,B.jsxs)(`div`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Release`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[e,` · coordinator-extension sections of docs/WORKSTREAMS.md + bus VERDICT/DONE`]})]}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:`tier-1 ceiling 10 min · prod = David`})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-4 border border-sand rounded-kit overflow-hidden max-[980px]:grid-cols-2`,children:Of.map(([e,t,n],r)=>(0,B.jsxs)(`div`,{className:`px-3.5 py-3 border-r border-sand last:border-r-0 ${r===3?`bg-ember-wash`:`bg-paper`}`,children:[(0,B.jsx)(`b`,{className:`block font-bold text-[13px] mb-1 ${r===3?`text-ember-deep`:`text-umber`}`,children:e}),(0,B.jsx)(`span`,{className:`text-[12px] leading-[1.5]`,children:t}),(0,B.jsx)(`span`,{className:`block font-mono font-medium text-[11px] text-ink3 mt-1.5`,children:n})]},e))}),!t&&(0,B.jsx)(`div`,{className:`text-umber text-[13px]`,children:`Reading WORKSTREAMS…`}),t&&i.length===0&&(0,B.jsx)(U,{className:`px-4 py-3 text-[13px] text-umber`,children:`No coordinator-extension sections in this project’s WORKSTREAMS.md (solo project, or not adopted yet).`}),a.map(e=>(0,B.jsx)(Nf,{s:e},e.title))]}),(0,B.jsxs)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Dock telemetry`,icon:`bus`,path:`VERDICT / DONE from the room`}),(t?.telemetry??[]).length===0&&(0,B.jsx)(`div`,{className:`px-3 py-2 text-[13px] text-umber`,children:`no VERDICT/DONE messages yet`}),(t?.telemetry??[]).map((e,t)=>{let n=String(e.text??``),r=e.prefix??n.split(/[:\s]/)[0];return(0,B.jsxs)(`div`,{className:`grid grid-cols-[var(--spacing-gutter)_1fr] border-b border-sand last:border-b-0`,children:[(0,B.jsx)(`div`,{className:`py-2.5 flex justify-center font-mono text-[12px] text-tan border-r border-sand`,children:`#`}),(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-baseline mb-0.5`,children:[(0,B.jsx)(`span`,{className:`font-semibold text-[13px]`,children:e.from}),(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-ink3`,children:Mf(e.ts)})]}),(0,B.jsxs)(`div`,{className:`text-[13px] break-words line-clamp-3`,children:[jf(r)&&(0,B.jsx)(Da,{prefix:r,fail:/FAIL/.test(n)}),n.replace(/^\w[\w ]*:?\s*/,``)]})]})]},e.id??t)})]}),i.find(e=>e.title===`Rooms`)&&(0,B.jsx)(Nf,{s:i.find(e=>e.title===`Rooms`)}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Kit versions`,icon:`kit`,path:`kit.json`}),(0,B.jsx)(`div`,{className:`px-3 py-2 grid gap-1 font-mono text-[12px] text-umber`,children:r?.packages?Object.entries(r.packages).map(([e,t])=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,B.jsx)(`span`,{children:t.name}),(0,B.jsx)(`b`,{className:`text-walnut`,children:t.version})]},e)):`—`})]}),t&&(0,B.jsx)(`div`,{className:`text-[11px] font-mono text-tan px-1`,children:t.source})]})]})}var Ff={queued:`outline`,running:`warn`,ok:`ok`,failed:`bad`,cancelled:`neutral`},If={mcp:`MCP tool`,cli:`CLI`,bus:`bus send`,shell:`shell`,seam:`seam write`},Lf=e=>{let t=(e.endedAt??Date.now())-e.startedAt;return t<1e3?`${t} ms`:`${(t/1e3).toFixed(1)} s`},Rf=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`});function zf(){let{runs:e,running:t}=Ha(),[n]=Fi(),[r,i]=(0,P.useState)(n.get(`run`));(0,P.useEffect)(()=>{let e=n.get(`run`);e&&i(e)},[n]);let a=e.find(e=>e.id===r)??e[0];return(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_480px] gap-4 p-4 max-[1100px]:grid-cols-1`,children:[(0,B.jsxs)(`div`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Runs`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[`every action the console performs — MCP tools, CLIs, bus sends, shells · `,t,` running`]})]}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[`last `,e.length]})]}),(0,B.jsxs)(U,{children:[e.length===0&&(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:[`Nothing has run yet. Try `,(0,B.jsx)(`b`,{children:`Run doctor`}),` on Fleets or `,(0,B.jsx)(`b`,{children:`Doctor`}),` on the Board.`]}),e.map(e=>(0,B.jsxs)(`button`,{onClick:()=>i(e.id),className:`w-full text-left grid grid-cols-[var(--spacing-gutter)_1fr_auto] items-center min-h-10 border-b border-sand last:border-b-0 border-0 bg-transparent cursor-pointer hover:bg-linen/60 ${a?.id===e.id?`bg-linen/70`:``}`,children:[(0,B.jsx)(`span`,{className:`self-stretch flex items-center justify-center font-mono text-[12px] border-r border-sand ${e.status===`running`?`text-amber animate-pulse`:e.status===`failed`?`text-brick`:`text-tan`}`,children:e.status===`running`?(0,B.jsx)(Ma,{size:12}):e.status===`ok`?`✓`:e.status===`failed`?`✗`:`○`}),(0,B.jsx)(`span`,{className:`px-3 py-1.5 min-w-0`,children:(0,B.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,B.jsx)(G,{tone:Ff[e.status],children:e.status}),(0,B.jsx)(`b`,{className:`text-[13px] truncate`,children:e.label}),(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:If[e.kind]}),e.project&&(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-ink3`,children:e.project}),e.sideEffects&&(0,B.jsx)(G,{tone:`david`,children:`side effects`})]})}),(0,B.jsxs)(`span`,{className:`px-3 font-mono text-[12px] text-ink3 whitespace-nowrap`,children:[Rf(e.startedAt),` · `,Lf(e)]})]},e.id))]})]}),(0,B.jsxs)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:[a?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:a.label,icon:`health`,path:`${a.id} · ${If[a.kind]}`,children:(0,B.jsx)(G,{tone:Ff[a.status],children:a.status})}),a.args&&(0,B.jsx)(`div`,{className:`px-3 py-2 font-mono text-[12px] text-ink3 border-b border-sand break-all`,children:JSON.stringify(a.args)}),(0,B.jsx)(`pre`,{className:`m-0 px-3 py-2 font-mono text-[12px] leading-[1.6] text-umber whitespace-pre-wrap max-h-[40vh] overflow-auto`,children:a.log.join(`
40
- `)||`—`}),a.error&&(0,B.jsx)(`div`,{className:`px-3 py-2 border-t border-sand text-[13px] text-brick`,children:a.error})]}),a.result!==void 0&&(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Result`,icon:`docs`}),(0,B.jsx)(`pre`,{className:`m-0 px-3 py-2 font-mono text-[12px] leading-[1.55] text-walnut whitespace-pre-wrap max-h-[45vh] overflow-auto`,children:typeof a.result==`string`?a.result:JSON.stringify(a.result,null,2)})]})]}):(0,B.jsx)(U,{className:`px-4 py-3 text-[13px] text-umber`,children:`Select a run to see its log and result.`}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`What can run`,icon:`gates`}),(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[13px] text-umber grid gap-1`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`now`}),` — read-only MCP tools (doctor, list_*, status, read_messages…) as `,(0,B.jsx)(`code`,{children:`groundwork-console`}),` / automation; read-only CLIs (groundwork doctor/status/list).`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`gated`}),` — bus sends (rules engine, replies), prune / unregister, seam writes, shells. Each will appear here with a `,(0,B.jsx)(`span`,{className:`inline-flex`,children:(0,B.jsx)(G,{tone:`david`,children:`side effects`})}),` marker.`]}),(0,B.jsx)(`div`,{className:`text-tan`,children:`Runs are in-memory (last 200) in v0.1.`})]})]})]})]})}var Bf=Oi([{path:`/`,Component:vd,children:[{index:!0,Component:Ld},{path:`board`,Component:Gd},{path:`bus`,Component:$d},{path:`monitor`,Component:hf},{path:`ops`,Component:_f,children:[{index:!0,element:(0,B.jsx)(Lr,{to:`/ops/fleets`,replace:!0})},{path:`fleets`,Component:Cf},{path:`skills`,Component:Df},{path:`release`,Component:Pf},{path:`runs`,Component:zf},{path:`events`,Component:vf}]},{path:`fleet`,element:(0,B.jsx)(Lr,{to:`/ops/fleets`,replace:!0})},{path:`release`,element:(0,B.jsx)(Lr,{to:`/ops/release`,replace:!0})},{path:`skills`,element:(0,B.jsx)(Lr,{to:`/ops/skills`,replace:!0})},{path:`runs`,element:(0,B.jsx)(Lr,{to:`/ops/runs`,replace:!0})},{path:`docs/:doc?`,Component:sf}]}]);try{for(let e of Object.keys(localStorage))if(e.startsWith(`kit-console.`)){let t=`groundwork-console.`+e.slice(12);localStorage.getItem(t)===null&&localStorage.setItem(t,localStorage.getItem(e)),localStorage.removeItem(e)}}catch{}(0,ni.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(P.StrictMode,{children:(0,B.jsx)(Ra,{children:(0,B.jsx)(Va,{children:(0,B.jsx)(eo,{children:(0,B.jsx)(Nr,{router:Bf})})})})}));export{o as n,l as r,oi as t};
38
+ `+e.error:``]})]});return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[10vh]`,onMouseDown:e=>{e.target===e.currentTarget&&s()},children:(0,B.jsxs)(`div`,{className:`w-[600px] bg-paper border rounded-kit shadow-panel ${t?`border-brick`:`border-sand`}`,children:[(0,B.jsx)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] ${t?`text-brick`:`text-umber`}`,children:e}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px] text-umber`,children:[n,o&&!m&&(0,B.jsx)(`div`,{children:(0,B.jsx)(K,{size:`sm`,onClick:_,disabled:u,children:u?`…`:`Preview (dry-run)`})}),m&&v(m),!f&&(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:[`Type `,r,` to confirm`]}),(0,B.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]}),f&&v(f)]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:s,children:f?`Close`:`Cancel`}),!f&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:g,disabled:c!==r||u,children:u?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Ma,{}),` Running…`]}):`Run`})]})]})})}var xf=`18px 1.6fr 1fr 1fr 1fr 1.2fr auto`,Sf=[[`automation`,`groundwork-console: reads + prefixed sends only; no record authority`],[`coordinator`,`routes work, noise sink, faces the fleet`],[`coord-worker`,`lane owner, own worktree, cites every DONE`],[`coord-qa`,`quality gate; PASS/FAIL @ head`],[`coord-ci`,`release operator; merges on cited PASS`],[`coord-aide`,`David’s comms point; owns QUEUE`],[`coord-audit`,`read-only architecture drift`],[`coord-fleet`,`stands up a fleet in tmux`],[`coord-handover`,`context-clear snapshot`]],Cf=e=>e===null?`—`:e<6e4?`just now`:e<36e5?`${Math.round(e/6e4)} min`:e<864e5?`${Math.round(e/36e5)} h`:`${Math.round(e/864e5)} d`;function wf(){let{current:e,projects:t}=za(),{data:n,error:r,loading:i}=q(`/bus/agents`,2e4),[a,o]=(0,P.useState)(`project`),{runs:s}=Ha(),c=q(`/kit`).data,[l,u]=(0,P.useState)(!1),d=s.find(e=>e.label===`bus doctor`&&e.status===`ok`),f=d?.result,p=async()=>{u(!0);try{await Fa(`/actions/bus-doctor`)}finally{u(!1)}},[m,h]=(0,P.useState)(!1),[g,_]=(0,P.useState)(null),[v,y]=(0,P.useState)(null),[b,x]=(0,P.useState)(!1),[S,C]=(0,P.useState)(!1),w=q(a===`project`&&e?`/projects/${e}/fleet`:null,2e4).data,T=q(`/admin/bus-writes`,1e4).data?.enabled??!1,E=ar(),D=n??[],O=t.find(t=>t.name===e)?.room,k=D.filter(t=>t.project===e||O&&t.project===O),A=a===`project`?k:D,j=A.filter(e=>e.liveness===`dead`&&![`groundwork-console`,`david`].includes(e.agentId)).map(e=>e.agentId),M=A.filter(e=>e.liveness===`live`).length,N=e=>t.find(t=>t.name===e.project||t.room&&t.room===e.project)?.name,ee=e=>N(e)??`~${e.project??`—`}`,F=a===`all`?[...new Set(D.map(ee))].sort((e,t)=>!!e.startsWith(`~`)-+!!t.startsWith(`~`)||e.localeCompare(t)):[e],I=e=>{if(e.startsWith(`~`))return{title:`#${e.slice(1)}`,path:`not registered as a project`,registered:!1};let n=t.find(t=>t.name===e);return{title:e,path:n?.room?`#${n.room}`:`no room linked`,registered:!0}};return(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_340px] gap-4 p-4 max-[980px]:grid-cols-1`,children:[(0,B.jsxs)(`div`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3 flex-wrap`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Fleets`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber whitespace-nowrap`,children:[a===`project`?`${e} · `:`all projects · `,A.length,` registered · `,M,` live`]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap justify-end`,children:[(0,B.jsxs)(`span`,{className:`inline-flex border border-dust rounded-kit overflow-hidden whitespace-nowrap`,children:[(0,B.jsxs)(`button`,{onClick:()=>o(`project`),"aria-pressed":a===`project`,className:`px-2.5 py-[5px] text-[12px] font-medium border-0 cursor-pointer ${a===`project`?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:[e||`project`,` · `,k.length]}),(0,B.jsxs)(`button`,{onClick:()=>o(`all`),"aria-pressed":a===`all`,className:`px-2.5 py-[5px] text-[12px] font-medium border-0 cursor-pointer ${a===`all`?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:[`all · `,D.length]})]}),(0,B.jsx)(K,{size:`sm`,onClick:()=>E(`/monitor`),children:`Monitor`}),(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>x(!0),title:`spawn an agent into tmux for this project`,children:`Spawn agent…`}),(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(K,{size:`sm`,onClick:()=>C(e=>!e),"aria-expanded":S,children:`Admin ▾`}),S&&(0,B.jsxs)(`div`,{className:`absolute right-0 top-[calc(100%+6px)] z-40 w-[260px] bg-paper border border-sand rounded-kit shadow-panel whitespace-normal text-left`,onMouseLeave:()=>C(!1),children:[(0,B.jsxs)(`button`,{className:`w-full text-left px-3 py-2 text-[13px] border-0 bg-transparent cursor-pointer hover:bg-linen border-b border-sand`,onClick:()=>{C(!1),p()},disabled:l,children:[l?`Running doctor…`:`Run bus doctor`,(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`MCP doctor as groundwork-console · read-only`})]}),(0,B.jsxs)(`button`,{className:`w-full text-left px-3 py-2 text-[13px] border-0 bg-transparent cursor-pointer hover:bg-linen border-b border-sand`,onClick:()=>{C(!1),_({kind:`prune`})},children:[`Prune bus data…`,(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`old messages/status/inbox · dry-run first`})]}),(0,B.jsxs)(`button`,{className:`w-full text-left px-3 py-2 text-[13px] border-0 bg-transparent cursor-pointer hover:bg-linen border-b border-sand disabled:opacity-50`,onClick:()=>{C(!1),_({kind:`dead`})},disabled:j.length===0,children:[`Unregister dead (`,j.length,a===`project`?` in ${e}`:``,`)…`,(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`force_unregister agents inactive > 24 h`})]}),O&&(0,B.jsxs)(`button`,{className:`w-full text-left px-3 py-2 text-[13px] border-0 bg-transparent cursor-pointer hover:bg-linen text-brick`,onClick:()=>{C(!1),h(!0)},children:[`Decommission fleet + #`,O,`…`,(0,B.jsx)(`div`,{className:`font-mono text-[11px] text-tan`,children:`unregister members + delete room`})]}),!T&&(0,B.jsx)(`div`,{className:`px-3 py-2 font-mono text-[11px] text-tan border-t border-sand`,children:`bus writes are off — admin actions dry-run / refuse`})]})]})]})]}),b&&(0,B.jsx)(Ad,{project:e,canWrite:T,onClose:()=>{x(!1)}}),v&&(0,B.jsx)(Yu,{agentId:v,onClose:()=>y(null)}),g?.kind===`prune`&&(0,B.jsx)(bf,{title:`Prune bus data`,confirmWord:`PRUNE`,action:`/actions/prune`,payload:{dryRun:!1,olderThanDays:30,targets:[`rooms`,`status`,`inbox`,`receipts`,`members`],removeOrphanInboxes:!0},preview:()=>Fa(`/actions/prune`,{dryRun:!0,olderThanDays:30,targets:[`rooms`,`status`,`inbox`,`receipts`,`members`],removeOrphanInboxes:!0}),onClose:()=>_(null),body:(0,B.jsxs)(`div`,{children:[`MCP `,(0,B.jsx)(`code`,{children:`prune`}),`: removes room messages / status entries / inbox items / receipts older than `,(0,B.jsx)(`b`,{children:`30 days`}),` (decisions kept longer), orphan inboxes and stale memberships. Preview first — the tool has a native dry-run. Requires bus writes on.`]})}),g?.kind===`dead`&&(0,B.jsx)(bf,{danger:!0,title:`Unregister ${j.length} dead agent${j.length===1?``:`s`}`,confirmWord:`UNREGISTER`,action:`/actions/unregister-dead`,payload:{agentIds:j},onClose:()=>_(null),body:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`code`,{children:`force_unregister`}),` for every agent in `,(0,B.jsx)(`b`,{children:a===`project`?e:`all projects`}),` whose last activity is over 24 h old: `,(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-walnut break-words`,children:j.join(`, `)}),`. Registry entries, transports and inbox markers go; room history stays. Requires bus writes on.`]})}),g?.kind===`one`&&(0,B.jsx)(bf,{danger:!0,title:`Unregister ${g.id}`,confirmWord:g.id,action:`/actions/unregister`,payload:{agentId:g.id},onClose:()=>_(null),body:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`code`,{children:`force_unregister`}),` `,(0,B.jsx)(`b`,{children:g.id}),`. Requires bus writes on.`]})}),m&&O&&(0,B.jsx)(Tf,{room:O,project:e,agents:k.map(e=>e.agentId),onClose:()=>h(!1)}),r&&(0,B.jsxs)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:[`API error: `,r]}),a===`project`&&w?.state===`present`&&(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Fleet`,icon:`fleet`,path:`${w.live.length} live · topology`}),(0,B.jsx)(`div`,{className:`px-3 py-3`,children:(0,B.jsx)(jd,{project:e,fleet:w,canWrite:T,onOpenPane:e=>y(e)})})]}),a===`project`&&(0,B.jsx)(Pd,{project:e,canWrite:T}),A.length===0&&!i&&a===`all`&&(0,B.jsx)(U,{className:`px-4 py-3 text-[13px] text-umber`,children:`No agents registered on the bus.`}),F.filter(e=>a!==`all`||A.some(t=>ee(t)===e)).map(e=>{let t=I(e),n=a===`all`?A.filter(t=>ee(t)===e):A;return(0,B.jsxs)(U,{children:[a===`all`&&(0,B.jsx)(W,{title:t.title,icon:`fleet`,path:`${t.path} · ${n.length} agent${n.length===1?``:`s`}`,children:!t.registered&&(0,B.jsx)(G,{tone:`outline`,children:`not registered`})}),(0,B.jsxs)(ka,{cols:xf,children:[(0,B.jsx)(`span`,{}),(0,B.jsx)(`span`,{children:`Agent`}),(0,B.jsx)(`span`,{children:`Role`}),(0,B.jsx)(`span`,{children:`Project`}),(0,B.jsx)(`span`,{children:`Transport`}),(0,B.jsx)(`span`,{children:`Pane · last seen`}),(0,B.jsx)(`span`,{})]}),n.map(e=>(0,B.jsxs)(`div`,{className:`grid gap-3 items-center px-3 min-h-10 border-b border-sand last:border-b-0 hover:bg-linen/60`,style:{gridTemplateColumns:xf},children:[(0,B.jsx)(ja,{state:e.liveness,active:e.active}),(0,B.jsx)(`span`,{className:`font-mono font-medium text-[13px] truncate`,children:e.agentId}),(0,B.jsx)(`span`,{className:`text-umber text-[13px] truncate`,children:e.role??`—`}),(0,B.jsx)(`span`,{className:`font-mono text-[13px] truncate`,children:e.project??`—`}),(0,B.jsx)(`span`,{className:`justify-self-start`,children:e.transport?(0,B.jsx)(G,{tone:`outline`,children:e.transport}):e.liveness===`dead`?(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`—`}):(0,B.jsx)(G,{tone:`warn`,children:`not attached`})}),(0,B.jsxs)(`span`,{className:`font-mono text-[12px] text-ink3`,children:[e.pane?(0,B.jsx)(`button`,{className:`border-0 bg-transparent p-0 font-mono text-[12px] text-ember-deep cursor-pointer underline decoration-dotted`,onClick:()=>y(e.agentId),title:`view pane`,children:e.pane}):`—`,` · `,Cf(e.heartbeatAgeMs),e.paneCommand?(0,B.jsxs)(`span`,{className:`text-tan`,children:[` · `,e.paneCommand]}):``]}),e.liveness===`dead`?(0,B.jsx)(K,{tone:`ghost`,size:`sm`,onClick:()=>_({kind:`one`,id:e.agentId}),children:`Unregister`}):(0,B.jsx)(K,{tone:`ghost`,size:`sm`,onClick:()=>ad(e.agentId),children:`DM`})]},e.agentId))]},e)})]}),(0,B.jsxs)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Liveness rule`,icon:`health`,path:`pane activity ∨ heartbeat`}),(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[13px] text-umber`,children:[`last seen = freshest of tmux `,(0,B.jsx)(`code`,{children:`window_activity`}),`, heartbeat, transport/inbox mtimes · `,(0,B.jsx)(`b`,{className:`text-walnut`,children:`live`}),` < 15 min · idle < 24 h · dead beyond. Pulsing dot = pane output in the last 60 s. Click a pane id to watch it (read-only).`]})]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Roles`,icon:`fleet`,path:`playbook ${c?.packages?.playbook?.version??`…`}`}),(0,B.jsx)(`div`,{className:`px-3 pt-1.5 pb-2.5 grid gap-1 text-[13px] text-umber`,children:Sf.map(([e,t])=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:e}),` — `,t]},e))})]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Bus doctor`,icon:`doctor`,path:f?`mcp doctor · ${new Date(d.endedAt??d.startedAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`:`mcp doctor as groundwork-console`,children:f&&(0,B.jsx)(G,{tone:f.healthy?`ok`:`warn`,children:f.healthy?`healthy`:`${f.summary.warn} warn · ${f.summary.error} error`})}),!f&&(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[13px] text-umber`,children:[`Press `,(0,B.jsx)(`b`,{children:`Run doctor`}),` — calls the MCP `,(0,B.jsx)(`code`,{children:`doctor`}),` tool as `,(0,B.jsx)(`code`,{children:`groundwork-console`}),` (automation). Read-only; `,(0,B.jsx)(`code`,{children:`fix`}),` stays gated.`]}),f?.findings.filter(e=>e.level!==`ok`).map(e=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[var(--spacing-gutter)_1fr] min-h-10 items-center border-b border-sand last:border-b-0`,children:[(0,B.jsx)(`div`,{className:`self-stretch flex items-center justify-center font-mono text-[12px] text-tan border-r border-sand`,children:`!`}),(0,B.jsxs)(`div`,{className:`px-3 py-2 min-w-0`,children:[(0,B.jsx)(G,{tone:e.level===`error`?`bad`:`warn`,children:e.check}),e.fixable&&(0,B.jsx)(`span`,{className:`ml-1.5 inline-flex`,children:(0,B.jsx)(G,{tone:`outline`,children:`fixable`})}),e.detail&&(0,B.jsx)(`div`,{className:`text-[13px] text-umber mt-1 break-words`,children:e.detail})]})]},e.check)),f&&(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[12px] font-mono text-ink3`,children:[f.summary.ok,` ok · `,f.summary.warn,` warn · `,f.summary.error,` error`]})]})]})]})}function Tf({room:e,project:t,agents:n,onClose:r}){let[i,a]=(0,P.useState)(``),[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(null);return(0,B.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-walnut/30 flex items-start justify-center pt-[12vh]`,onMouseDown:e=>{e.target===e.currentTarget&&r()},children:(0,B.jsxs)(`div`,{className:`w-[560px] bg-paper border border-brick rounded-kit shadow-panel`,children:[(0,B.jsxs)(`div`,{className:`px-4 py-3 border-b border-sand font-display font-bold text-[18px] text-brick`,children:[`Decommission fleet + channel #`,e]}),(0,B.jsxs)(`div`,{className:`p-4 grid gap-3 text-[13px]`,children:[(0,B.jsxs)(`div`,{className:`text-umber`,children:[`This will `,(0,B.jsxs)(`b`,{className:`text-walnut`,children:[`force_unregister `,n.length,` agent`,n.length===1?``:`s`]}),` (`,n.slice(0,6).join(`, `),n.length>6?`…`:``,`), then `,(0,B.jsxs)(`b`,{className:`text-walnut`,children:[`delete_room #`,e]}),` (message history is kept in `,(0,B.jsx)(`code`,{children:`~/agent-coord/history`}),`). Repo and seam files are never touched.`]}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),` also remove `,(0,B.jsx)(`b`,{children:t}),` from groundwork-console.config.json`]}),(0,B.jsxs)(`label`,{className:`grid gap-1`,children:[(0,B.jsx)(`span`,{className:`font-mono text-[11px] uppercase tracking-[.08em] text-ink3`,children:`Type the room name to confirm`}),(0,B.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:e,className:`px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut font-mono`})]}),(0,B.jsxs)(`div`,{className:`text-[12px] text-umber`,children:[`Bus writes are gated: without `,(0,B.jsx)(`code`,{children:`GROUNDWORK_CONSOLE_BUS_WRITES=1`}),` on the API this runs as a `,(0,B.jsx)(`b`,{children:`dry-run`}),` and records what it would do (see Runs). With the switch on, it executes as `,(0,B.jsx)(`code`,{children:`groundwork-console`}),`.`]}),u&&(0,B.jsxs)(`div`,{className:`p-2 rounded-kit border ${u.status===`ok`?`border-moss-line bg-moss-wash/50`:`border-brick-line bg-brick-wash/50`}`,children:[(0,B.jsxs)(`div`,{className:`font-mono text-[12px]`,children:[(0,B.jsx)(G,{tone:u.status===`ok`?`ok`:`bad`,children:u.status}),` `,(0,B.jsx)(`b`,{children:u.label})]}),(0,B.jsx)(`pre`,{className:`m-0 mt-1 font-mono text-[12px] whitespace-pre-wrap`,children:u.log.join(`
39
+ `)})]})]}),(0,B.jsxs)(`div`,{className:`px-4 py-3 border-t border-sand flex justify-end gap-2`,children:[(0,B.jsx)(K,{size:`sm`,onClick:r,children:u?`Close`:`Cancel`}),!u&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:async()=>{l(!0);try{d(await Fa(`/actions/decommission`,{room:e,confirm:i,removeProject:o}))}finally{l(!1)}},disabled:i!==e||c,children:c?`Running…`:`Decommission`})]})]})})}var Ef=`1.4fr .6fr .9fr .9fr 1.2fr 2fr`,Df=({on:e,label:t})=>(0,B.jsx)(`span`,{className:`font-mono text-[11px] px-1.5 py-0.5 rounded ${e?`bg-linen text-umber`:`text-tan line-through opacity-60`}`,children:t});function Of(){let{current:e}=za(),{data:t,error:n,refresh:r}=q(e?`/projects/${e}/skills`:null,6e4),[i,a]=(0,P.useState)(null);if(n)return(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsxs)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:[`API error: `,n]})});if(!t)return(0,B.jsx)(`div`,{className:`p-4 text-umber`,children:`Scanning skills…`});let o=t.groundwork,s=t.playbook,c=o.skills.filter(e=>e.installed&&e.inSync===!1).length+s.cards.filter(e=>e.installed&&(e.inSync===!1||e.legacyEssay)).length+ +!!o.driftedVersion+s.legacyDirs.length;return(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_340px] gap-4 p-4 max-[980px]:grid-cols-1`,children:[i===`gwinit`&&(0,B.jsx)(bf,{title:`groundwork init · ${e}`,confirmWord:e,action:`/actions/groundwork-init/${e}`,payload:{},onClose:()=>{a(null),r()},body:(0,B.jsxs)(`div`,{children:[`Runs `,(0,B.jsx)(`code`,{children:`groundwork init <repo>`}),` — installs the skills, IDE mirrors and the `,(0,B.jsx)(`code`,{children:`docs/`}),` scaffold (WORKSTREAMS/QUEUE/DONE/FACTS, methodology, templates, phases/) into the working tree. Nothing is committed; review with `,(0,B.jsx)(`code`,{children:`git status`}),`. Only offered when `,(0,B.jsx)(`code`,{children:`docs/.groundwork/VERSION`}),` is missing.`]})}),i===`gw`&&(0,B.jsx)(bf,{title:`groundwork update · ${e}`,confirmWord:e,action:`/actions/groundwork-update/${e}`,payload:{all:!0,docs:!0},onClose:()=>{a(null),r()},body:(0,B.jsxs)(`div`,{children:[`Runs `,(0,B.jsxs)(`code`,{children:[`groundwork update `,`<repo>`,` --all --docs`]}),` from the kit (`,o.kitVersion,`): refreshes installed skills + IDE mirrors, adds skills added upstream, refreshes the generic reference docs (methodology, COMMANDS, _INDEX), bumps `,(0,B.jsx)(`code`,{children:`docs/.groundwork/VERSION`}),`. `,(0,B.jsx)(`b`,{className:`text-walnut`,children:`Writes into the repo working tree`}),` (uncommitted — review in Docs, which highlights the changes). Project docs (PRD, WORKSTREAMS…) are left alone.`]})}),i===`pb`&&(0,B.jsx)(bf,{title:`agent-coordination update (global)`,confirmWord:`UPDATE`,action:`/actions/playbook-update`,payload:{dryRun:!1},preview:()=>Fa(`/actions/playbook-update`,{dryRun:!0}),onClose:()=>{a(null),r()},body:(0,B.jsxs)(`div`,{children:[`Re-syncs the playbook field cards into `,(0,B.jsx)(`code`,{children:`~/.claude/skills`}),` (+ essay + slices, all harness mirrors) from the kit (`,s.kitVersion,`); removes legacy dirs. Machine-global. Preview shows the exact plan.`]})}),(0,B.jsxs)(`div`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Skills`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[`what each harness can run — `,e,` and globally · byte-compared to the kit`]})]}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[c,` need attention`]})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Groundwork · per repo`,icon:`skills`,eyebrow:`payload/skills · .claude/skills`,path:`marker ${o.versionMarker??`—`} · kit ${o.kitVersion}`,children:[o.driftedVersion&&(0,B.jsxs)(G,{tone:`warn`,children:[`behind `,o.kitVersion]}),!o.versionMarker&&(0,B.jsx)(K,{size:`sm`,tone:`primary`,onClick:()=>a(`gwinit`),title:`this repo has no docs/.groundwork/VERSION — install Groundwork`,children:`groundwork init…`}),o.versionMarker&&(0,B.jsx)(K,{size:`sm`,tone:o.driftedVersion?`primary`:`default`,onClick:()=>a(`gw`),children:`groundwork update…`})]}),(0,B.jsxs)(ka,{cols:Ef,children:[(0,B.jsx)(`span`,{children:`Skill`}),(0,B.jsx)(`span`,{children:`Tier`}),(0,B.jsx)(`span`,{children:`Installed`}),(0,B.jsx)(`span`,{children:`In sync`}),(0,B.jsx)(`span`,{children:`Mirrors`}),(0,B.jsx)(`span`,{children:`Description`})]}),o.skills.map(e=>(0,B.jsxs)(`div`,{className:`grid gap-3 items-center px-3 min-h-10 border-b border-sand last:border-b-0 hover:bg-linen/60`,style:{gridTemplateColumns:Ef},children:[(0,B.jsxs)(`span`,{className:`font-mono font-medium text-[13px]`,children:[`/`,e.name]}),(0,B.jsx)(`span`,{children:(0,B.jsx)(G,{tone:e.tier===`min`?`neutral`:`outline`,children:e.tier===`min`?`core`:`optional`})}),(0,B.jsx)(`span`,{children:e.installed?(0,B.jsx)(G,{tone:`ok`,children:`installed`}):(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`—`})}),(0,B.jsx)(`span`,{children:e.installed?e.inSync?(0,B.jsx)(G,{tone:`ok`,children:`= kit`}):(0,B.jsx)(G,{tone:`warn`,children:`differs`}):(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`—`})}),(0,B.jsxs)(`span`,{className:`flex gap-1`,children:[(0,B.jsx)(Df,{on:e.mirrors.cursor,label:`cursor`}),(0,B.jsx)(Df,{on:e.mirrors.vscode,label:`vscode`})]}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,title:e.description,children:e.description})]},e.name))]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Playbook · machine-global`,icon:`skills`,eyebrow:`field cards`,path:`${(s.homes??[]).map(e=>`${e.harness}: ${e.dir.replace(/^\/Users\/[^/]+/,`~`)}`).join(` · `)||`~/.claude/skills`} · kit ${s.kitVersion}`,children:(0,B.jsx)(K,{size:`sm`,onClick:()=>a(`pb`),children:`agent-coordination update…`})}),(0,B.jsxs)(ka,{cols:Ef,children:[(0,B.jsx)(`span`,{children:`Card`}),(0,B.jsx)(`span`,{children:`Slices`}),(0,B.jsx)(`span`,{children:`Installed`}),(0,B.jsx)(`span`,{children:`In sync`}),(0,B.jsx)(`span`,{children:`Mirrors`}),(0,B.jsx)(`span`,{children:`Description`})]}),s.cards.map(e=>(0,B.jsxs)(`div`,{className:`grid gap-3 items-center px-3 min-h-10 border-b border-sand last:border-b-0 hover:bg-linen/60`,style:{gridTemplateColumns:Ef},children:[(0,B.jsxs)(`span`,{className:`font-mono font-medium text-[13px]`,children:[`/`,e.name]}),(0,B.jsx)(`span`,{children:e.legacyEssay?(0,B.jsx)(G,{tone:`warn`,children:`775-line essay`}):(0,B.jsxs)(G,{tone:`outline`,children:[e.slices,` slice`,e.slices===1?``:`s`]})}),(0,B.jsx)(`span`,{children:e.installed?(0,B.jsx)(G,{tone:`ok`,children:`installed`}):(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`—`})}),(0,B.jsx)(`span`,{children:e.installed?e.inSync?(0,B.jsx)(G,{tone:`ok`,children:`= kit`}):(0,B.jsx)(G,{tone:`warn`,children:`differs`}):(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`—`})}),(0,B.jsxs)(`span`,{className:`flex gap-1 flex-wrap`,children:[(0,B.jsx)(Df,{on:e.installed,label:`claude`}),(0,B.jsx)(Df,{on:!!e.homes?.grok?.installed,label:`grok${e.homes?.grok?.installed&&e.homes.grok.inSync===!1?` ≠`:``}`}),(0,B.jsx)(Df,{on:e.mirrors.cursor,label:`cursor`}),(0,B.jsx)(Df,{on:e.mirrors.vscode,label:`vscode`}),(0,B.jsx)(Df,{on:e.mirrors.opencode,label:`opencode`})]}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,title:e.description,children:e.description})]},e.name)),s.legacyDirs.length>0&&(0,B.jsxs)(`div`,{className:`px-3 py-2 border-t border-sand text-[13px]`,children:[(0,B.jsx)(G,{tone:`warn`,children:`legacy dirs`}),` `,(0,B.jsxs)(`span`,{className:`text-umber`,children:[s.legacyDirs.join(`, `),` still in `,s.globalDir,` — installer removes them`]})]})]})]}),(0,B.jsxs)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`How this is measured`,icon:`doctor`}),(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[13px] text-umber grid gap-1.5`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`In sync`}),` — SHA-1 of the installed `,(0,B.jsx)(`code`,{children:`SKILL.md`}),` equals the kit source (installers copy verbatim).`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`Mirrors`}),` — presence of `,(0,B.jsx)(`code`,{children:`.cursor/commands/<n>.md`}),`, `,(0,B.jsx)(`code`,{children:`.vscode/prompts/<n>.prompt.md`}),`, `,(0,B.jsx)(`code`,{children:`~/.config/opencode/skills/<n>`}),`.`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`Marker`}),` — `,(0,B.jsx)(`code`,{children:`docs/.groundwork/VERSION`}),` vs the kit’s groundwork version.`]}),(0,B.jsxs)(`div`,{children:[`Asked grok for `,(0,B.jsx)(`code`,{children:`groundwork list --json`}),` / `,(0,B.jsx)(`code`,{children:`agent-coordination list --json`}),` to replace the scan.`]})]})]}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Harness mirrors`,icon:`skills`,path:`seam skills-mirror`}),(0,B.jsxs)(`div`,{className:`px-3 py-2 grid gap-2 text-[13px] text-umber`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`Claude Code`}),` — canonical `,(0,B.jsx)(`code`,{children:`SKILL.md`}),`; playbook global.`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`Cursor`}),` — `,(0,B.jsx)(`code`,{children:`.cursor/commands`}),`, GENERATED banner.`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`VS Code`}),` — `,(0,B.jsx)(`code`,{children:`.vscode/prompts`}),`, mode from allowed-tools.`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`OpenCode`}),` — auto-discovers `,(0,B.jsx)(`code`,{children:`~/.claude/skills`}),`; templated MCP tool names.`]})]})]})]})]})}var kf=[[`Tier 0 · QA gate`,`typecheck · build · real tests · independent behaviour check → VERDICT PASS @ head`,`coord-qa`],[`Tier 1 · merge → qa`,`CI merges on cited PASS, squash-verify, auto-deploy to qa in < 10 min, smoke`,`coord-ci`],[`Tier 2 · async`,`long suites, perf, security — never blocking; results chased by ci`,`coord-ci`],[`Prod · promotion`,`David only. Fix-forward on qa.`,`david`]],Af={"Open PRs":`prs`,"Cutover Gates":`gates`,"Needs David":`needsDavid`,Risks:`risks`,Rooms:`rooms`,"Decisions Recorded":`decisions`},jf=e=>/pass|merged|deployed|✅|green|done/i.test(e)?`ok`:/fail|red|blocked/i.test(e)?`bad`:/david/i.test(e)?`david`:/hold|risk|pending|open/i.test(e)?`warn`:`neutral`,Mf=e=>!!e&&Ta.includes(e),Nf=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``;function Pf({s:e}){let t=e.table?e.table.headers.map(()=>`1fr`).join(` `):``;return(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:e.title,icon:Af[e.title],eyebrow:`## ${e.title} · coordinator-only`,path:`docs/WORKSTREAMS.md`}),e.table&&e.table.rows.length>0&&(0,B.jsx)(ka,{cols:t,children:e.table.headers.map(e=>(0,B.jsx)(`span`,{children:e},e))}),e.table&&e.table.rows.length===1&&Object.values(e.table.rows[0]).every(e=>/^(—|-|none|n\/a|)$/i.test(e.trim())||/none open/i.test(e))?(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`none open`}):e.table?.rows.map((n,r)=>(0,B.jsx)(Oa,{glyph:`|`,raw:Object.values(n).join(` | `),children:(0,B.jsx)(`div`,{className:`grid gap-3 items-center py-1.5`,style:{gridTemplateColumns:t},children:e.table.headers.map((e,t)=>{let r=n[e]??``,i=/status|state|gate|verdict/i.test(e),a=r.length<=28&&!/[`(]/.test(r);return(0,B.jsx)(`span`,{className:`min-w-0 truncate ${t===0?`font-medium`:`text-[13px] text-umber`}`,title:r,children:i&&r&&a?(0,B.jsx)(G,{tone:jf(r),children:r}):r||(0,B.jsx)(`span`,{className:`text-tan`,children:`—`})},e)})})},r)),e.bullets?.map((e,t)=>(0,B.jsx)(Oa,{glyph:`-`,children:(0,B.jsx)(`div`,{className:`py-2 text-[14px]`,children:e})},t)),!e.table?.rows.length&&!e.bullets?.length&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`empty`})]})}function Ff(){let{current:e}=za(),{data:t,error:n}=q(e?`/projects/${e}/release`:null,3e4),r=q(`/kit`).data;if(n)return(0,B.jsx)(`div`,{className:`p-4`,children:(0,B.jsxs)(U,{className:`px-4 py-3 text-[13px] text-brick`,children:[`API error: `,n]})});let i=t?.extensions??[],a=i.filter(e=>e.title!==`Rooms`);return(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_340px] gap-4 p-4 max-[980px]:grid-cols-1`,children:[(0,B.jsxs)(`div`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Release`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[e,` · coordinator-extension sections of docs/WORKSTREAMS.md + bus VERDICT/DONE`]})]}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:`tier-1 ceiling 10 min · prod = David`})]}),(0,B.jsx)(`div`,{className:`grid grid-cols-4 border border-sand rounded-kit overflow-hidden max-[980px]:grid-cols-2`,children:kf.map(([e,t,n],r)=>(0,B.jsxs)(`div`,{className:`px-3.5 py-3 border-r border-sand last:border-r-0 ${r===3?`bg-ember-wash`:`bg-paper`}`,children:[(0,B.jsx)(`b`,{className:`block font-bold text-[13px] mb-1 ${r===3?`text-ember-deep`:`text-umber`}`,children:e}),(0,B.jsx)(`span`,{className:`text-[12px] leading-[1.5]`,children:t}),(0,B.jsx)(`span`,{className:`block font-mono font-medium text-[11px] text-ink3 mt-1.5`,children:n})]},e))}),!t&&(0,B.jsx)(`div`,{className:`text-umber text-[13px]`,children:`Reading WORKSTREAMS…`}),t&&i.length===0&&(0,B.jsx)(U,{className:`px-4 py-3 text-[13px] text-umber`,children:`No coordinator-extension sections in this project’s WORKSTREAMS.md (solo project, or not adopted yet).`}),a.map(e=>(0,B.jsx)(Pf,{s:e},e.title))]}),(0,B.jsxs)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Dock telemetry`,icon:`bus`,path:`VERDICT / DONE from the room`}),(t?.telemetry??[]).length===0&&(0,B.jsx)(`div`,{className:`px-3 py-2 text-[13px] text-umber`,children:`no VERDICT/DONE messages yet`}),(t?.telemetry??[]).map((e,t)=>{let n=String(e.text??``),r=e.prefix??n.split(/[:\s]/)[0];return(0,B.jsxs)(`div`,{className:`grid grid-cols-[var(--spacing-gutter)_1fr] border-b border-sand last:border-b-0`,children:[(0,B.jsx)(`div`,{className:`py-2.5 flex justify-center font-mono text-[12px] text-tan border-r border-sand`,children:`#`}),(0,B.jsxs)(`div`,{className:`px-3 pt-2 pb-2.5 min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex gap-2 items-baseline mb-0.5`,children:[(0,B.jsx)(`span`,{className:`font-semibold text-[13px]`,children:e.from}),(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-ink3`,children:Nf(e.ts)})]}),(0,B.jsxs)(`div`,{className:`text-[13px] break-words line-clamp-3`,children:[Mf(r)&&(0,B.jsx)(Da,{prefix:r,fail:/FAIL/.test(n)}),n.replace(/^\w[\w ]*:?\s*/,``)]})]})]},e.id??t)})]}),i.find(e=>e.title===`Rooms`)&&(0,B.jsx)(Pf,{s:i.find(e=>e.title===`Rooms`)}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Kit versions`,icon:`kit`,path:`kit.json`}),(0,B.jsx)(`div`,{className:`px-3 py-2 grid gap-1 font-mono text-[12px] text-umber`,children:r?.packages?Object.entries(r.packages).map(([e,t])=>(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,B.jsx)(`span`,{children:t.name}),(0,B.jsx)(`b`,{className:`text-walnut`,children:t.version})]},e)):`—`})]}),t&&(0,B.jsx)(`div`,{className:`text-[11px] font-mono text-tan px-1`,children:t.source})]})]})}var If={queued:`outline`,running:`warn`,ok:`ok`,failed:`bad`,cancelled:`neutral`},Lf={mcp:`MCP tool`,cli:`CLI`,bus:`bus send`,shell:`shell`,seam:`seam write`},Rf=e=>{let t=(e.endedAt??Date.now())-e.startedAt;return t<1e3?`${t} ms`:`${(t/1e3).toFixed(1)} s`},zf=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`});function Bf(){let{runs:e,running:t}=Ha(),[n]=Fi(),[r,i]=(0,P.useState)(n.get(`run`));(0,P.useEffect)(()=>{let e=n.get(`run`);e&&i(e)},[n]);let a=e.find(e=>e.id===r)??e[0];return(0,B.jsxs)(`div`,{className:`grid grid-cols-[1fr_480px] gap-4 p-4 max-[1100px]:grid-cols-1`,children:[(0,B.jsxs)(`div`,{className:`grid gap-3.5 content-start min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-display font-bold text-[34px] leading-[1.1] tracking-[-.015em] text-ember`,children:`Runs`}),(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[`every action the console performs — MCP tools, CLIs, bus sends, shells · `,t,` running`]})]}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[`last `,e.length]})]}),(0,B.jsxs)(U,{children:[e.length===0&&(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:[`Nothing has run yet. Try `,(0,B.jsx)(`b`,{children:`Run doctor`}),` on Fleets or `,(0,B.jsx)(`b`,{children:`Doctor`}),` on the Board.`]}),e.map(e=>(0,B.jsxs)(`button`,{onClick:()=>i(e.id),className:`w-full text-left grid grid-cols-[var(--spacing-gutter)_1fr_auto] items-center min-h-10 border-b border-sand last:border-b-0 border-0 bg-transparent cursor-pointer hover:bg-linen/60 ${a?.id===e.id?`bg-linen/70`:``}`,children:[(0,B.jsx)(`span`,{className:`self-stretch flex items-center justify-center font-mono text-[12px] border-r border-sand ${e.status===`running`?`text-amber animate-pulse`:e.status===`failed`?`text-brick`:`text-tan`}`,children:e.status===`running`?(0,B.jsx)(Ma,{size:12}):e.status===`ok`?`✓`:e.status===`failed`?`✗`:`○`}),(0,B.jsx)(`span`,{className:`px-3 py-1.5 min-w-0`,children:(0,B.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,B.jsx)(G,{tone:If[e.status],children:e.status}),(0,B.jsx)(`b`,{className:`text-[13px] truncate`,children:e.label}),(0,B.jsx)(`span`,{className:`font-mono text-[11px] text-tan`,children:Lf[e.kind]}),e.project&&(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-ink3`,children:e.project}),e.sideEffects&&(0,B.jsx)(G,{tone:`david`,children:`side effects`})]})}),(0,B.jsxs)(`span`,{className:`px-3 font-mono text-[12px] text-ink3 whitespace-nowrap`,children:[zf(e.startedAt),` · `,Rf(e)]})]},e.id))]})]}),(0,B.jsxs)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:[a?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:a.label,icon:`health`,path:`${a.id} · ${Lf[a.kind]}`,children:(0,B.jsx)(G,{tone:If[a.status],children:a.status})}),a.args&&(0,B.jsx)(`div`,{className:`px-3 py-2 font-mono text-[12px] text-ink3 border-b border-sand break-all`,children:JSON.stringify(a.args)}),(0,B.jsx)(`pre`,{className:`m-0 px-3 py-2 font-mono text-[12px] leading-[1.6] text-umber whitespace-pre-wrap max-h-[40vh] overflow-auto`,children:a.log.join(`
40
+ `)||`—`}),a.error&&(0,B.jsx)(`div`,{className:`px-3 py-2 border-t border-sand text-[13px] text-brick`,children:a.error})]}),a.result!==void 0&&(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Result`,icon:`docs`}),(0,B.jsx)(`pre`,{className:`m-0 px-3 py-2 font-mono text-[12px] leading-[1.55] text-walnut whitespace-pre-wrap max-h-[45vh] overflow-auto`,children:typeof a.result==`string`?a.result:JSON.stringify(a.result,null,2)})]})]}):(0,B.jsx)(U,{className:`px-4 py-3 text-[13px] text-umber`,children:`Select a run to see its log and result.`}),(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`What can run`,icon:`gates`}),(0,B.jsxs)(`div`,{className:`px-3 py-2 text-[13px] text-umber grid gap-1`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`now`}),` — read-only MCP tools (doctor, list_*, status, read_messages…) as `,(0,B.jsx)(`code`,{children:`groundwork-console`}),` / automation; read-only CLIs (groundwork doctor/status/list).`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`b`,{className:`text-walnut`,children:`gated`}),` — bus sends (rules engine, replies), prune / unregister, seam writes, shells. Each will appear here with a `,(0,B.jsx)(`span`,{className:`inline-flex`,children:(0,B.jsx)(G,{tone:`david`,children:`side effects`})}),` marker.`]}),(0,B.jsx)(`div`,{className:`text-tan`,children:`Runs are in-memory (last 200) in v0.1.`})]})]})]})]})}var Vf=Oi([{path:`/`,Component:$,children:[{index:!0,Component:Rd},{path:`board`,Component:Kd},{path:`bus`,Component:ef},{path:`monitor`,Component:gf},{path:`ops`,Component:vf,children:[{index:!0,element:(0,B.jsx)(Lr,{to:`/ops/fleets`,replace:!0})},{path:`fleets`,Component:wf},{path:`skills`,Component:Of},{path:`release`,Component:Ff},{path:`runs`,Component:Bf},{path:`events`,Component:yf}]},{path:`fleet`,element:(0,B.jsx)(Lr,{to:`/ops/fleets`,replace:!0})},{path:`release`,element:(0,B.jsx)(Lr,{to:`/ops/release`,replace:!0})},{path:`skills`,element:(0,B.jsx)(Lr,{to:`/ops/skills`,replace:!0})},{path:`runs`,element:(0,B.jsx)(Lr,{to:`/ops/runs`,replace:!0})},{path:`docs/:doc?`,Component:cf}]}]);try{for(let e of Object.keys(localStorage))if(e.startsWith(`kit-console.`)){let t=`groundwork-console.`+e.slice(12);localStorage.getItem(t)===null&&localStorage.setItem(t,localStorage.getItem(e)),localStorage.removeItem(e)}}catch{}(0,ni.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(P.StrictMode,{children:(0,B.jsx)(Ra,{children:(0,B.jsx)(Va,{children:(0,B.jsx)(eo,{children:(0,B.jsx)(Nr,{router:Vf})})})})}));export{o as n,l as r,oi as t};