@davidbalzan/groundwork-console 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bus.js +28 -5
- package/dist/mcp.js +1 -1
- package/dist/server.js +16 -2
- package/package.json +1 -1
- package/public/assets/{abnfDiagram-N423BO3Z-CxWt6pmv.js → abnfDiagram-N423BO3Z-4d2uv_Bq.js} +1 -1
- package/public/assets/{arc-D5-I_DjS.js → arc-CsO5oHRF.js} +1 -1
- package/public/assets/architecture-TIHT7OUA-ChM--lpn.js +1 -0
- package/public/assets/{architectureDiagram-T3A2C74G-BGmT60on.js → architectureDiagram-T3A2C74G-DMmZHzpW.js} +1 -1
- package/public/assets/{blockDiagram-VBNYF7ZC-PVAr34Dh.js → blockDiagram-VBNYF7ZC-BypTIZaz.js} +1 -1
- package/public/assets/{c4Diagram-5PPSVZJV-CLEl06cP.js → c4Diagram-5PPSVZJV-DvCrTZm6.js} +1 -1
- package/public/assets/channel-CTT-B1Jd.js +1 -0
- package/public/assets/{chunk-2GRJ4B5K-BqqD7kMu.js → chunk-2GRJ4B5K-iIMSEuYT.js} +1 -1
- package/public/assets/{chunk-4I5QYGJK-DK_fIVHN.js → chunk-4I5QYGJK-DE7yI8Ek.js} +1 -1
- package/public/assets/{chunk-5RXB4S5H-DgstcPFg.js → chunk-5RXB4S5H-GX_WxHPA.js} +1 -1
- package/public/assets/{chunk-6Q2QTUOP-DO9RKXCT.js → chunk-6Q2QTUOP-CY62du0c.js} +1 -1
- package/public/assets/{chunk-7Z6QIM7H-BA33EzDX.js → chunk-7Z6QIM7H--U6-3mMF.js} +1 -1
- package/public/assets/{chunk-GF5L2VYU-CRW6rE0L.js → chunk-GF5L2VYU-CYC_rSaq.js} +1 -1
- package/public/assets/{chunk-I66GZJ75-C5_NbBqn.js → chunk-I66GZJ75-Czc6RDTX.js} +1 -1
- package/public/assets/{chunk-JQJVKLGR-CdSZSVu-.js → chunk-JQJVKLGR-CcM1wERy.js} +1 -1
- package/public/assets/{chunk-KBJHAD2P-CRCRrXrk.js → chunk-KBJHAD2P-Bc86tmO-.js} +1 -1
- package/public/assets/{chunk-NSK5VX7P-DIVqgBu4.js → chunk-NSK5VX7P-9_tkKeKf.js} +1 -1
- package/public/assets/{chunk-QR6OTTB3-sKyKNPgl.js → chunk-QR6OTTB3-B9-c0tqf.js} +1 -1
- package/public/assets/{chunk-RYQCIY6F-P19k1JhZ.js → chunk-RYQCIY6F-CyxQKlO3.js} +1 -1
- package/public/assets/{chunk-UBXNYLIW-DxiLGa8n.js → chunk-UBXNYLIW-DsDjYE1H.js} +1 -1
- package/public/assets/{chunk-W5SLKNZC-CMnFpaIo.js → chunk-W5SLKNZC-DBT8eyiL.js} +1 -1
- package/public/assets/{chunk-WRU74C26-BzhPgtRt.js → chunk-WRU74C26-BkBE-ufW.js} +1 -1
- package/public/assets/{chunk-XXDRQBXY-BrE4EAhD.js → chunk-XXDRQBXY-C-4dWLfF.js} +1 -1
- package/public/assets/classDiagram-JCYQIIEL-hiXee6Eo.js +1 -0
- package/public/assets/classDiagram-v2-OCEON4UE-hiXee6Eo.js +1 -0
- package/public/assets/{cose-bilkent-JH36ORCC-Dt6PDdrZ.js → cose-bilkent-JH36ORCC-D43fgxak.js} +1 -1
- package/public/assets/{cynefin-VYW2F7L2-Dpyi5ItX.js → cynefin-VYW2F7L2-C11FHLih.js} +1 -1
- package/public/assets/{cynefinDiagram-MW4NZA55-B2yGLd8X.js → cynefinDiagram-MW4NZA55-CT3s9Cvn.js} +1 -1
- package/public/assets/{dagre-VZM6K2ZE-Dntfcg-X.js → dagre-VZM6K2ZE-LvZVEXM6.js} +1 -1
- package/public/assets/{diagram-7IWD3JNH-BPxK9-c4.js → diagram-7IWD3JNH-Cw0TOqRI.js} +1 -1
- package/public/assets/{diagram-B4RE2ZJO-DsUBXKVA.js → diagram-B4RE2ZJO-B8CLj1IC.js} +1 -1
- package/public/assets/{diagram-LBJQPF4R-qP08Jdv_.js → diagram-LBJQPF4R-C9jjsjqA.js} +1 -1
- package/public/assets/{diagram-Q27KOJAE-1TdMfJjf.js → diagram-Q27KOJAE-zmK9KaIF.js} +1 -1
- package/public/assets/{diagram-UB23O5K3-cK29jWGW.js → diagram-UB23O5K3-D9FLjjFN.js} +1 -1
- package/public/assets/{dist-Bp1jCq1s.js → dist-D4PgRFT8.js} +1 -1
- package/public/assets/{ebnfDiagram-BXEA7PRR-CJRoip6W.js → ebnfDiagram-BXEA7PRR-gsjjs_XZ.js} +1 -1
- package/public/assets/{erDiagram-JOGREHBK-salUqYy9.js → erDiagram-JOGREHBK-CTT6y-7Y.js} +1 -1
- package/public/assets/eventmodeling-45OFAUF4-se4AzYWu.js +1 -0
- package/public/assets/flowDiagram-UKHOOZJN-CykShUMb.js +1 -0
- package/public/assets/{ganttDiagram-PKOTCBZU-zgcauP2k.js → ganttDiagram-PKOTCBZU-Co40RJeV.js} +1 -1
- package/public/assets/{gitGraph-TEB2WS4Q-D8twe_B6.js → gitGraph-TEB2WS4Q-K4j3kGfP.js} +1 -1
- package/public/assets/{gitGraphDiagram-DS77QQ5N-mpQTM4Fs.js → gitGraphDiagram-DS77QQ5N-C7egTGgK.js} +1 -1
- package/public/assets/{index-0OCDcZ1F.js → index-DKFIHr9f.js} +4 -4
- package/public/assets/{info-DKCQHKI2-NlG3PDiK.js → info-DKCQHKI2-B12S9dur.js} +1 -1
- package/public/assets/{infoDiagram-6WML65LV-DNlytqqs.js → infoDiagram-6WML65LV-Cr2CrVeL.js} +1 -1
- package/public/assets/{ishikawaDiagram-WSZJBQD7-CLbOZsbe.js → ishikawaDiagram-WSZJBQD7-DYFpwuke.js} +1 -1
- package/public/assets/{journeyDiagram-NVQOT4AX-BFYvvwGf.js → journeyDiagram-NVQOT4AX-CiANQSH5.js} +1 -1
- package/public/assets/{kanban-definition-27J2QSJJ-Dg-9h3d2.js → kanban-definition-27J2QSJJ-BPEtkdf6.js} +1 -1
- package/public/assets/{line-C3fZyPMI.js → line-Dlv0QupC.js} +1 -1
- package/public/assets/{linear-Bg74_IwO.js → linear-DP-JyCeQ.js} +1 -1
- package/public/assets/{mermaid-parser.core-wU8rV0JZ.js → mermaid-parser.core-m5Z6GHDK.js} +3 -3
- package/public/assets/{mermaid.core-Cqu2TmEc.js → mermaid.core-BhJBKv0J.js} +4 -4
- package/public/assets/{mindmap-definition-FAOFIHXS-DocCU_OY.js → mindmap-definition-FAOFIHXS-DpwEU_bQ.js} +1 -1
- package/public/assets/{packet-7NZHBO7P-CJ18AmJI.js → packet-7NZHBO7P-ElpZJWUo.js} +1 -1
- package/public/assets/{pegDiagram-VL7TDLO6-BKmrK3N_.js → pegDiagram-VL7TDLO6-B4UAE4d-.js} +1 -1
- package/public/assets/{pie-RZYD4A2V-BzZwhKll.js → pie-RZYD4A2V-CXsn8HRS.js} +1 -1
- package/public/assets/{pieDiagram-7S7Q4E2Y-BrADNAEN.js → pieDiagram-7S7Q4E2Y-Cg9oK3mU.js} +1 -1
- package/public/assets/{quadrantDiagram-CIZ2JOQS-7-El3SnP.js → quadrantDiagram-CIZ2JOQS-jq_OdvvR.js} +1 -1
- package/public/assets/{radar-I7S5WNFK-BiznqFD1.js → radar-I7S5WNFK-BkzfZxFa.js} +1 -1
- package/public/assets/{railroad-3IZDKUUU-DgnMfEWG.js → railroad-3IZDKUUU-B3THFlyo.js} +1 -1
- package/public/assets/railroad-abnf-AHOZXSZD-h1yNvons.js +1 -0
- package/public/assets/railroad-ebnf-EBAXGLYW-D_YJ8F3o.js +1 -0
- package/public/assets/railroad-peg-LSFZ7HO6-5Fq3k5T9.js +1 -0
- package/public/assets/{railroadDiagram-AXF67PYL-yqboeuy1.js → railroadDiagram-AXF67PYL-YLfOS1Ub.js} +1 -1
- package/public/assets/{requirementDiagram-LRYGKXZP-DtEXQN5L.js → requirementDiagram-LRYGKXZP-Bdu77Te0.js} +1 -1
- package/public/assets/{sankeyDiagram-W5VNT64P-CzdkrepT.js → sankeyDiagram-W5VNT64P-7HO0TSNW.js} +1 -1
- package/public/assets/{sequenceDiagram-SI44F4Z6-Z2e0D63k.js → sequenceDiagram-SI44F4Z6-CQcwlLyD.js} +1 -1
- package/public/assets/{src-FX1L97V2.js → src-_jO5__EL.js} +1 -1
- package/public/assets/{stateDiagram-OKZ733FA-CMy-EwvM.js → stateDiagram-OKZ733FA-C64YdGh1.js} +1 -1
- package/public/assets/stateDiagram-v2-UEYNNEHI-BQX29486.js +1 -0
- package/public/assets/{swimlanes-SLNWSIFB-B4L51W7W.js → swimlanes-SLNWSIFB-MD924CgH.js} +1 -1
- package/public/assets/swimlanesDiagram-ULZ7WXOC-Bc9cfxpb.js +8 -0
- package/public/assets/{timeline-definition-Z64GVDOM-qGeZo2i4.js → timeline-definition-Z64GVDOM-BwmMNgBf.js} +1 -1
- package/public/assets/{treeView-QDETBFTQ-CENBPnul.js → treeView-QDETBFTQ-Di_P_CHe.js} +1 -1
- package/public/assets/{treemap-6X3UGDF4-Db3FvIgt.js → treemap-6X3UGDF4-BI4XvsgT.js} +1 -1
- package/public/assets/{vennDiagram-T6HMQDX7-BzOcljxT.js → vennDiagram-T6HMQDX7-D_BFpD2j.js} +1 -1
- package/public/assets/{wardley-OPB4EBWU-BCjI5d0A.js → wardley-OPB4EBWU-CSCluGr0.js} +1 -1
- package/public/assets/{wardleyDiagram-T6FBY63Y-BxMi8v_W.js → wardleyDiagram-T6FBY63Y-IUT_hnBA.js} +1 -1
- package/public/assets/{xychartDiagram-ELKLHX3M-D9iLw6GM.js → xychartDiagram-ELKLHX3M-CPlrFIYm.js} +1 -1
- package/public/index.html +1 -1
- package/public/assets/architecture-TIHT7OUA-qas-fLcU.js +0 -1
- package/public/assets/channel-CPtW5HV2.js +0 -1
- package/public/assets/classDiagram-JCYQIIEL-Ca4Olyo-.js +0 -1
- package/public/assets/classDiagram-v2-OCEON4UE-Ca4Olyo-.js +0 -1
- package/public/assets/eventmodeling-45OFAUF4-vG8tmD-p.js +0 -1
- package/public/assets/flowDiagram-UKHOOZJN-B8KA04Jj.js +0 -1
- package/public/assets/railroad-abnf-AHOZXSZD-BJx969N4.js +0 -1
- package/public/assets/railroad-ebnf-EBAXGLYW-vSQ0SM-G.js +0 -1
- package/public/assets/railroad-peg-LSFZ7HO6-CIn0Sk7Q.js +0 -1
- package/public/assets/stateDiagram-v2-UEYNNEHI-FIj7i3no.js +0 -1
- package/public/assets/swimlanesDiagram-ULZ7WXOC-D8KvDdSc.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BhJBKv0J.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-_jO5__EL.js","assets/chunk-I66GZJ75-Czc6RDTX.js","assets/chunk-NSK5VX7P-9_tkKeKf.js","assets/dist-D4PgRFT8.js","assets/chunk-4I5QYGJK-DE7yI8Ek.js","assets/chunk-WRU74C26-BkBE-ufW.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-UBXNYLIW-DsDjYE1H.js","assets/chunk-W5SLKNZC-DBT8eyiL.js","assets/chunk-QR6OTTB3-B9-c0tqf.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-7Z6QIM7H--U6-3mMF.js","assets/line-Dlv0QupC.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 ie(e){0>re||(e.current=ne[re],ne[re]=null,re--)}function R(e,t){re++,ne[re]=e.current,e.current=t}var z=L(null),ae=L(null),oe=L(null),se=L(null);function ce(e,t){switch(R(oe,t),R(ae,e),R(z,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}}ie(z),R(z,e)}function le(){ie(z),ie(ae),ie(oe)}function ue(e){e.memoizedState!==null&&R(se,e);var t=z.current,n=Hd(t,e.type);t!==n&&(R(ae,e),R(z,n))}function de(e){ae.current===e&&(ie(z),ie(ae)),se.current===e&&(ie(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,18 +21,18 @@ Error generating stack: `+e.message+`
|
|
|
21
21
|
`),t=t.replace(Ac,`�`),e.src=t}function Mc(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 Nc(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 Pc(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 Fc(e){return/^<a[>\s]/i.test(e)}function Ic(e){return/^<\/a\s*>/i.test(e)}function Lc(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`&&(Fc(o.content)&&i>0&&i--,Ic(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=Ks(r,a,c)}}}}var Rc=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,zc=/\((c|tm|r)\)/i,Bc=/\((c|tm|r)\)/gi,Vc={c:`©`,r:`®`,tm:`™`};function Hc(e,t){return Vc[t.toLowerCase()]}function Uc(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(Bc,Hc)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function Wc(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&Rc.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 Gc(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type===`inline`&&(zc.test(e.tokens[t].content)&&Uc(e.tokens[t].children),Rc.test(e.tokens[t].content)&&Wc(e.tokens[t].children))}var Kc=/['"]/,qc=/['"]/g,Jc=`’`;function Yc(e,t,n,r){e[t]||(e[t]=[]),e[t].push({pos:n,ch:r})}function Xc(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 Zc(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;){qc.lastIndex=l;let o=qc.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=fc(m)||dc(m),_=fc(h)||dc(h),v=lc(m),y=lc(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&&Yc(i,a,o.index,Jc);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]),Yc(i,a,o.index,c),Yc(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&&Yc(i,a,o.index,Jc)}}Object.keys(i).forEach(function(t){let n=Number(t);e[n].content=Xc(e[n].content,i[t])})}function Qc(e){if(e.md.options.typographer)for(let t=e.tokens.length-1;t>=0;t--)e.tokens[t].type!==`inline`||!Kc.test(e.tokens[t].content)||Zc(e.tokens[t].children,e)}function $c(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 el(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&&$c(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 tl=[[`normalize`,jc],[`block`,Mc],[`strip_references`,Nc],[`inline`,Pc],[`linkify`,Lc],[`replacements`,Gc],[`smartquotes`,Qc],[`text_join`,el]],nl=class{constructor(){Y(this,`ruler`,new Tc),Y(this,`State`,Oc);for(let e=0;e<tl.length;e++)this.ruler.push(tl[e][0],tl[e][1])}process(e){let t=this.ruler.getRules(``);for(let n=0,r=t.length;n<r;n++)t[n](e)}},rl=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`,wc),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(cc(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 wc(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&&cc(this.src.charCodeAt(e));e++);return e}skipSpacesBack(e,t){if(e<=t)return e;for(;e>t;)if(!cc(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(cc(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(``)}},il=65536;function al(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];return e.src.slice(n,r)}function ol(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 sl(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&&!cc(s)||o===45&&cc(s))return!1;for(;a<e.eMarks[i];){let t=e.src.charCodeAt(a);if(t!==124&&t!==45&&t!==58&&!cc(t))return!1;a++}let c=al(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=al(e,t).trim(),c.indexOf(`|`)===-1||e.sCount[t]-e.blkIndent>=4)return!1;l=ol(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=al(e,i).trim(),!c)||e.sCount[i]-e.blkIndent>=4||(l=ol(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop(),y+=d-l.length,y>il))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 cl(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 ll(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 ul(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(cc(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 dl(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&&!cc(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 fl(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&&!cc(e.src.charCodeAt(r))?-1:r}function pl(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),!cc(a))?-1:i}function ml(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 hl(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=pl(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=fl(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=pl(e,c),p<0)break;o=e.bMarks[c]+e.tShift[c]}else if(p=fl(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&&ml(e,h),!0}function gl(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(!cc(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(!cc(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&&cc(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10&&g)for(g=``,i=f,o=p;i<a&&cc(c.charCodeAt(i));)i++;if(i<a&&c.charCodeAt(i)!==10)return!1;let _=pc(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 _l=`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(`.`),vl=`<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>`,yl=`<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>`,bl=RegExp(`^(?:${vl}|${yl}|<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)`),xl=RegExp(`^(?:${vl}|${yl})`),Sl=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Za-z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[RegExp(`^</?(${_l.join(`|`)})(?=(\\s|/?>|$))`,`i`),/^$/,!0],[RegExp(`${xl.source}\\s*$`),/^$/,!1]];function Cl(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<Sl.length&&!Sl[s][0].test(o);s++);if(s===Sl.length)return!1;if(r)return Sl[s][2];let c=t+1,l=Sl[s][1].test(``);if(!Sl[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),Sl[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 wl(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&&!cc(o))return!1;if(r)return!0;a=e.skipSpacesBack(a,i);let c=e.skipCharsBack(a,35,i);c>i&&cc(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=hc(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 Tl(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=hc(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 El(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=hc(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 Dl=[[`table`,sl,[`paragraph`,`reference`]],[`code`,cl],[`fence`,ll,[`paragraph`,`reference`,`blockquote`,`list`]],[`blockquote`,ul,[`paragraph`,`reference`,`blockquote`,`list`]],[`hr`,dl,[`paragraph`,`reference`,`blockquote`,`list`]],[`list`,hl,[`paragraph`,`reference`,`blockquote`]],[`reference`,gl],[`html_block`,Cl,[`paragraph`,`reference`,`blockquote`]],[`heading`,wl,[`paragraph`,`reference`,`blockquote`]],[`lheading`,Tl],[`paragraph`,El]],Ol=class{constructor(){Y(this,`ruler`,new Tc),Y(this,`State`,rl);for(let e=0;e<Dl.length;e++)this.ruler.push(Dl[e][0],Dl[e][1],{alt:(Dl[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)}},kl=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`,wc),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 wc(`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 wc(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=fc(i)||dc(i),l=fc(s)||dc(s),u=lc(i),d=lc(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 Al(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 jl(e,t){let n=e.pos;for(;n<e.posMax&&!Al(e.src.charCodeAt(n));)n++;return n!==e.pos&&(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}var Ml=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function Nl(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(Ml);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 Pl(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&&cc(e.src.charCodeAt(n));)n++;return e.pos=n,!0}var X=[];for(let e=0;e<256;e++)X.push(0);`\\!"#$%&'()*+,./:;<=>?@[]^_\`{|}~-`.split(``).forEach(function(e){X[e.charCodeAt(0)]=1});function Fl(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),cc(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&&X[i]!==0?a:o,t.markup=o,t.info=`escape`}return e.pos=n+1,!0}function Z(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 Q(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 Il(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 Ll(e){let t=e.tokens_meta,n=e.tokens_meta.length;Il(e,e.delimiters);for(let r=0;r<n;r++){let n=t[r]?.delimiters;n&&Il(e,n)}}var Rl={tokenize:Q,postProcess:Ll};function zl(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 Bl(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 Vl(e){let t=e.tokens_meta,n=e.tokens_meta.length;Bl(e,e.delimiters);for(let r=0;r<n;r++){let n=t[r]?.delimiters;n&&Bl(e,n)}}var Hl={tokenize:zl,postProcess:Vl};function Ul(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),!(!cc(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),!(!cc(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),!(!cc(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=pc(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 Wl(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),!(!cc(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),!(!cc(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),!(!cc(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=pc(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 Gl=/^([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])?)*)$/,Kl=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function ql(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(Kl.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(Gl.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 Jl(e){return/^<a[>\s]/i.test(e)}function Yl(e){return/^<\/a\s*>/i.test(e)}function Xl(e){let t=e|32;return t>=97&&t<=122}function Zl(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&&!Xl(i))return!1;let a=e.src.slice(r).match(bl);if(!a)return!1;if(!t){let t=e.push(`html_inline`,``,0);t.content=a[0],Jl(t.content)&&e.linkLevel++,Yl(t.content)&&e.linkLevel--}return e.pos+=a[0].length,!0}var Ql=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,$l=/^&([a-z][a-z0-9]{1,31});/i;function eu(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(Ql);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=qs(t)?Js(t):Js(65533),n.markup=r[0],n.info=`entity`}return e.pos+=r[0].length,!0}}else{let r=e.src.slice(n).match($l);if(r){let n=as(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 tu(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 nu(e){let t=e.tokens_meta,n=e.tokens_meta.length;tu(e.delimiters);for(let e=0;e<n;e++){let n=t[e]?.delimiters;n&&tu(n)}}function ru(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 iu=[[`text`,jl],[`linkify`,Nl],[`newline`,Pl],[`escape`,Fl],[`backticks`,Z],[`strikethrough`,Rl.tokenize],[`emphasis`,Hl.tokenize],[`link`,Ul],[`image`,Wl],[`autolink`,ql],[`html_inline`,Zl],[`entity`,eu]],au=[[`balance_pairs`,nu],[`strikethrough`,Rl.postProcess],[`emphasis`,Hl.postProcess],[`fragments_join`,ru]],ou=class{constructor(){Y(this,`ruler`,new Tc),Y(this,`ruler2`,new Tc),Y(this,`State`,kl);for(let e=0;e<iu.length;e++)this.ruler.push(iu[e][0],iu[e][1]);for(let e=0;e<au.length;e++)this.ruler2.push(au[e][0],au[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)}},su={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`]}}}},cu=/^(vbscript|javascript|file|data):/,lu=/^data:image\/(gif|png|jpeg|webp);/,uu=[`http:`,`https:`,`mailto:`],du=class{validateLink(e){let t=e.trim().toLowerCase();return!cu.test(t)||lu.test(t)}normalizeLink(e){let t=No(e,!0);if(t.hostname&&(!t.protocol||uu.indexOf(t.protocol)>=0))try{t.hostname=Vs.toASCII(t.hostname)}catch{}return bo(xo(t))}normalizeLinkText(e){let t=No(e,!0);if(t.hostname&&(!t.protocol||uu.indexOf(t.protocol)>=0))try{t.hostname=Vs.toUnicode(t.hostname)}catch{}return _o(xo(t),_o.defaultChars+`%`)}constructor(...e){Y(this,`inline`,new ou),Y(this,`block`,new Ol),Y(this,`core`,new nl),Y(this,`renderer`,new Dc),Y(this,`linkify`,new ms),Y(this,`utils`,Ws),Y(this,`helpers`,Object.assign({},bc));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=su[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(du,`Token`,wc),Y(du,`Ruler`,Tc),Y(du,`Renderer`,Dc),Y(du,`ParserCore`,nl),Y(du,`StateCore`,Oc),Y(du,`ParserBlock`,Ol),Y(du,`StateBlock`,rl),Y(du,`ParserInline`,ou),Y(du,`StateInline`,kl);var fu=new(Gs(du))({html:!1,linkify:!0,typographer:!1}),pu=0;fu.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+pu)),t.attrSet(`data-line-end`,String(t.map[1]+1+pu)))});var mu=e=>e.toLowerCase().replace(/<[^>]+>/g,``).replace(/[`*_~]/g,``).replace(/[^\p{L}\p{N}\s-]/gu,``).trim().replace(/\s+/g,`-`).slice(0,80)||`section`,hu=new Map;fu.renderer.rules.heading_open=(e,t,n,r,i)=>{let a=e[t+1],o=mu(a?.type===`inline`?a.content:``),s=hu.get(o)??0;return hu.set(o,s+1),s&&(o=`${o}-${s+1}`),e[t].attrSet(`id`,o),i.renderToken(e,t,n)};var gu=fu.renderer.rules.fence;fu.renderer.rules.fence=(e,t,n,r,i)=>{let a=e[t],o=a.map?` data-line="${a.map[0]+1+pu}" data-line-end="${a.map[1]+1+pu}"`:``;return a.info.trim()===`mermaid`?`<div class="mermaid"${o}>${fu.utils.escapeHtml(a.content)}</div>`:gu(e,t,n,r,i).replace(/^<pre/,`<pre${o}`)};var _u=new Map;function vu(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 yu(e){let t=_u.get(e);if(t)return t;let{meta:n,body:r}=vu(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>${fu.utils.escapeHtml(e)}</th><td>${fu.utils.escapeHtml(t)}</td></tr>`).join(``)}</table></div>`:``;pu=i,hu=new Map;let o=a+fu.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 _u.size>200&&_u.clear(),_u.set(e,o),o}var bu={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 xu(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 Su(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=xu(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 Cu(e,t){if(t.length===0)return e;let n=document.createElement(`div`);return n.innerHTML=e,Su(n,t),n.innerHTML}var wu=(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-Cqu2TmEc.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,...bu}),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 Tu({source:e,changes:t=[],className:n=``}){let r=yu(e),[i,a]=(0,P.useState)(null),o=(0,P.useMemo)(()=>Cu(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)(wu,{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 Eu(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 Du=/\[\[([^\]|]+)(?:\|[^\]]+)?\]\](?::\d+)?|(?:(?:~\/|\.{1,2}\/)?(?:[\w.-]+\/)+)?[\w.-]+\.md(?::\d+)?/g;function Ou(e,t,n){return e==null||typeof e==`boolean`||typeof e==`number`?e:typeof e==`string`?ku(e,t,n):Array.isArray(e)?e.map((e,r)=>{let i=Ou(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,Ou(e.props.children,t,n)):e}function ku(e,t,n){if(Du.lastIndex=0,!Du.test(e))return e;Du.lastIndex=0;let r=[],i=0,a,o=0;for(;a=Du.exec(e);){a.index>i&&r.push(e.slice(i,a.index));let s=a[0],c=Eu(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 Au=(0,P.createContext)({files:[],open:()=>{},linkify:e=>e}),ju=()=>(0,P.useContext)(Au);function Mu({children:e}){let{current:t}=Ha(),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)(Au.Provider,{value:{files:a,open:s,linkify:(e,n)=>Ou(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)(Tu,{source:o.data.source})]})]})})]})}var Nu=[`circle`,`square`,`diamond`,`hexagon`,`triangle`,`shield`,`leaf`,`pentagon`];function Pu(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 Fu=e=>Nu[Pu(e)%Nu.length];function Iu(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 Lu({id:e,role:t,size:n=18,state:r,active:i,className:a=``}){let o=dd(t),s=Fu(e),c=r===`dead`?.35:r===`dormant`?.5: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:Iu(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 Ru=e=>/done|merged|deployed|complete|closed|✅/i.test(e);function zu(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:Ru(e.status)})):[]}var Bu=e=>e.match(/^Task\s+(\d+)\b/i)?.[1]??null;function Vu(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 Hu(e,t){let n=e.trim().toLowerCase();return t.find(e=>e.toLowerCase()===n)??t.find(e=>n.includes(e.toLowerCase()))??null}var Uu=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(~~[^~\n]+~~)|(\[\[([^\]|\n]+)(?:\|([^\]\n]+))?\]\])|(\[([^\]\n]+)\]\((https?:\/\/[^)\s]+)\))|(\bhttps?:\/\/[^\s<>()"']+[^\s<>()"'.,;:!?])|((?<![\w*])\*(?!\s)([^*\n]+?)(?<!\s)\*(?![\w*]))|((?<![\w_])_(?!\s)([^_\n]+?)(?<!\s)_(?![\w_]))/g;function Wu({text:e,className:t}){let n=[],r=0,i,a=0;for(Uu.lastIndex=0;i=Uu.exec(e);)i.index>r&&n.push(e.slice(r,i.index)),i[1]?n.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]?n.push((0,B.jsx)(`b`,{children:i[2].slice(2,-2)},a++)):i[3]?n.push((0,B.jsx)(`s`,{className:`text-tan`,children:i[3].slice(2,-2)},a++)):i[4]?n.push((0,B.jsx)(V,{to:`/docs/${encodeURIComponent(i[5])}`,onClick:e=>e.stopPropagation(),className:`text-ember-deep`,children:i[6]??i[5]},a++)):i[7]?n.push((0,B.jsx)(`a`,{href:i[9],target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`text-ember-deep`,children:i[8]},a++)):i[10]?n.push((0,B.jsxs)(`a`,{href:i[10],target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`text-ember-deep break-all`,children:[i[10].replace(/^https?:\/\//,``).slice(0,60),i[10].replace(/^https?:\/\//,``).length>60?`…`:``]},a++)):i[11]?n.push((0,B.jsx)(`i`,{children:i[12]},a++)):i[13]&&n.push((0,B.jsx)(`i`,{children:i[14]},a++)),r=i.index+i[0].length;return r<e.length&&n.push(e.slice(r)),t?(0,B.jsx)(`span`,{className:t,children:n}):(0,B.jsx)(B.Fragment,{children:n})}var Gu=({text:e})=>(0,B.jsx)(Wu,{text:e});function Ku({stream:e,agents:t,size:n=`sm`}){if(!e)return null;let r=Hu(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)(ld,{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)(Lu,{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 qu({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=zu(s),[u,d]=(0,P.useState)({}),f=q(`/admin/bus-writes`,1e4).data?.enabled??!1,[p,m]=(0,P.useState)({}),h=async(n,r)=>{m(e=>({...e,[n]:{to:r??`aide`,ts:Date.now()}}));try{let i=await Ia(`/actions/task/${e}/${t.id}/${n}`,{owner:r??void 0});if(i.status!==`ok`)throw Error(i.error??i.log?.slice(-1)[0]??`failed`);m(e=>({...e,[n]:{to:i.owner??r??`aide`,ts:Date.now()}}))}catch(e){m(t=>({...t,[n]:{err:e.message}}))}};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=Vu(l,t.n,Bu(e.title)),m=!!n&&!!s&&Hu(s.owner,c.map(e=>e.agentId))===n,g=u[e.line]===void 0?o:!u[e.line];return(0,B.jsxs)(`div`,{className:`border-b border-sand last:border-b-0 min-w-0 ${m?`bg-ember/[.04]`:``}`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-[1] px-3 py-1.5 min-w-0 ${m?`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:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>d(t=>({...t,[e.line]:g})),className:`border-0 bg-transparent p-0 cursor-pointer font-mono text-[11px] text-tan w-3 shrink-0 hover:text-umber`,title:g?`expand`:`collapse`,"aria-expanded":!g,children:g?`▸`:`▾`}),m&&(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)(Ku,{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)(Ku,{stream:s,agents:c})})]}),!g&&e.tasks.map(e=>(0,B.jsxs)(`div`,{className:`group grid grid-cols-[var(--spacing-gutter)_minmax(0,1fr)_auto] items-start hover:bg-linen/60 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`:p[e.line]&&!(`err`in p[e.line])?`text-amber`:`text-tan`}`,title:p[e.line]&&!(`err`in p[e.line])?`asked ${p[e.line].to} to tick it`:void 0,children:e.done?`- [x]`:p[e.line]&&!(`err`in p[e.line])?`- [~]`:`- [ ]`}),(0,B.jsxs)(V,{to:`/docs/${encodeURIComponent(a.file)}?view=source&line=${e.line}`,className:`px-3 py-1.5 min-w-0 break-words hover:no-underline text-inherit ${i?`text-[12px] leading-snug`:`text-[13px]`} ${e.done?`text-tan line-through decoration-dust`:``}`,children:[(0,B.jsx)(Gu,{text:e.text}),p[e.line]&&`err`in p[e.line]&&(0,B.jsx)(`span`,{className:`ml-2 font-mono text-[10px] text-brick`,children:p[e.line].err})]}),(0,B.jsx)(`span`,{className:`pr-2 pt-1 shrink-0`,children:!e.done&&(p[e.line]&&!(`err`in p[e.line])?(0,B.jsxs)(`span`,{className:`font-mono text-[10px] text-amber whitespace-nowrap`,title:`the owner was asked to run /check-task; the tick appears when it does`,children:[`asked · `,p[e.line].to.split(`-`).slice(-1)[0]]}):(0,B.jsx)(`button`,{type:`button`,disabled:!f,onClick:()=>h(e.line,s?Hu(s.owner,c.map(e=>e.agentId)):null),className:`opacity-0 group-hover:opacity-100 focus:opacity-100 font-mono text-[10px] px-1.5 py-0.5 rounded border ${f?`border-dust text-umber bg-paper hover:text-leaf hover:border-leaf cursor-pointer`:`border-dashed border-dust text-tan cursor-not-allowed`}`,title:f?`ask ${s?s.owner:`the aide`} to run /check-task for this line`:`bus writes are off (header) — mark done DMs the owner`,children:`✓ done`}))})]},e.line))]},e.line)})}):(0,B.jsx)(`div`,{className:`px-3 py-2 font-mono text-[12px] text-tan`,children:`…`})}function Ju({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)(qu,{project:e,phase:t})]})}var Yu=`/api`,Xu=/\[image: (\S+) · (\S+)\]/g,Zu=e=>`${Yu}/uploads/${encodeURIComponent(e.split(`/`).pop()??``)}`;function Qu(e){let t=e?.persistKey,[n,r]=(0,P.useState)(()=>{if(!t)return[];try{return JSON.parse(localStorage.getItem(t)??`[]`)}catch{return[]}}),i=(0,P.useCallback)(e=>r(n=>{let r=e(n);if(t)try{r.length?localStorage.setItem(t,JSON.stringify(r)):localStorage.removeItem(t)}catch{}return r}),[t]);(0,P.useEffect)(()=>{if(t)try{r(JSON.parse(localStorage.getItem(t)??`[]`))}catch{r([])}},[t]);let[a,o]=(0,P.useState)(0),[s,c]=(0,P.useState)(null),l=(0,P.useCallback)(async e=>{let t=e.filter(e=>e.type.startsWith(`image/`));if(t.length){o(e=>e+t.length),c(null);for(let e of t)try{let t=new FormData;t.append(`file`,e,e.name||`paste.png`);let n=await fetch(`${Yu}/uploads`,{method:`POST`,body:t}),r=await n.json();if(!n.ok)throw Error(r.error??`${n.status}`);i(e=>e.some(e=>e.name===r.name)?e:[...e,r])}catch(e){c(e.message)}finally{o(e=>e-1)}}},[]),u=(0,P.useCallback)(e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),l(t))},[l]),d=(0,P.useCallback)(e=>{let t=Array.from(e.dataTransfer?.files??[]);t.length&&(e.preventDefault(),l(t))},[l]),f=(0,P.useCallback)(e=>{e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()},[]);return{items:n,busy:a>0,err:s,onPaste:u,onDrop:d,onDragOver:f,remove:e=>i(t=>t.filter(t=>t.name!==e)),clear:()=>i(()=>[]),withRefs:e=>n.length?`${e.trim()}${e.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>${fu.utils.escapeHtml(e)}</th><td>${fu.utils.escapeHtml(t)}</td></tr>`).join(``)}</table></div>`:``;pu=i,hu=new Map;let o=a+fu.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 _u.size>200&&_u.clear(),_u.set(e,o),o}var bu={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 xu(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 Su(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=xu(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 Cu(e,t){if(t.length===0)return e;let n=document.createElement(`div`);return n.innerHTML=e,Su(n,t),n.innerHTML}var wu=(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-BhJBKv0J.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,...bu}),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 Tu({source:e,changes:t=[],className:n=``}){let r=yu(e),[i,a]=(0,P.useState)(null),o=(0,P.useMemo)(()=>Cu(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)(wu,{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 Eu(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 Du=/\[\[([^\]|]+)(?:\|[^\]]+)?\]\](?::\d+)?|(?:(?:~\/|\.{1,2}\/)?(?:[\w.-]+\/)+)?[\w.-]+\.md(?::\d+)?/g;function Ou(e,t,n){return e==null||typeof e==`boolean`||typeof e==`number`?e:typeof e==`string`?ku(e,t,n):Array.isArray(e)?e.map((e,r)=>{let i=Ou(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,Ou(e.props.children,t,n)):e}function ku(e,t,n){if(Du.lastIndex=0,!Du.test(e))return e;Du.lastIndex=0;let r=[],i=0,a,o=0;for(;a=Du.exec(e);){a.index>i&&r.push(e.slice(i,a.index));let s=a[0],c=Eu(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 Au=(0,P.createContext)({files:[],open:()=>{},linkify:e=>e}),ju=()=>(0,P.useContext)(Au);function Mu({children:e}){let{current:t}=Ha(),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)(Au.Provider,{value:{files:a,open:s,linkify:(e,n)=>Ou(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)(Tu,{source:o.data.source})]})]})})]})}var Nu=[`circle`,`square`,`diamond`,`hexagon`,`triangle`,`shield`,`leaf`,`pentagon`];function Pu(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 Fu=e=>Nu[Pu(e)%Nu.length];function Iu(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 Lu({id:e,role:t,size:n=18,state:r,active:i,className:a=``}){let o=dd(t),s=Fu(e),c=r===`dead`?.35:r===`dormant`?.5: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:Iu(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 Ru=e=>/done|merged|deployed|complete|closed|✅/i.test(e);function zu(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:Ru(e.status)})):[]}var Bu=e=>e.match(/^Task\s+(\d+)\b/i)?.[1]??null;function Vu(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 Hu(e,t){let n=e.trim().toLowerCase();return t.find(e=>e.toLowerCase()===n)??t.find(e=>n.includes(e.toLowerCase()))??null}var Uu=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(~~[^~\n]+~~)|(\[\[([^\]|\n]+)(?:\|([^\]\n]+))?\]\])|(\[([^\]\n]+)\]\((https?:\/\/[^)\s]+)\))|(\bhttps?:\/\/[^\s<>()"']+[^\s<>()"'.,;:!?])|((?<![\w*])\*(?!\s)([^*\n]+?)(?<!\s)\*(?![\w*]))|((?<![\w_])_(?!\s)([^_\n]+?)(?<!\s)_(?![\w_]))/g;function Wu({text:e,className:t}){let n=[],r=0,i,a=0;for(Uu.lastIndex=0;i=Uu.exec(e);)i.index>r&&n.push(e.slice(r,i.index)),i[1]?n.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]?n.push((0,B.jsx)(`b`,{children:i[2].slice(2,-2)},a++)):i[3]?n.push((0,B.jsx)(`s`,{className:`text-tan`,children:i[3].slice(2,-2)},a++)):i[4]?n.push((0,B.jsx)(V,{to:`/docs/${encodeURIComponent(i[5])}`,onClick:e=>e.stopPropagation(),className:`text-ember-deep`,children:i[6]??i[5]},a++)):i[7]?n.push((0,B.jsx)(`a`,{href:i[9],target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`text-ember-deep`,children:i[8]},a++)):i[10]?n.push((0,B.jsxs)(`a`,{href:i[10],target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`text-ember-deep break-all`,children:[i[10].replace(/^https?:\/\//,``).slice(0,60),i[10].replace(/^https?:\/\//,``).length>60?`…`:``]},a++)):i[11]?n.push((0,B.jsx)(`i`,{children:i[12]},a++)):i[13]&&n.push((0,B.jsx)(`i`,{children:i[14]},a++)),r=i.index+i[0].length;return r<e.length&&n.push(e.slice(r)),t?(0,B.jsx)(`span`,{className:t,children:n}):(0,B.jsx)(B.Fragment,{children:n})}var Gu=({text:e})=>(0,B.jsx)(Wu,{text:e});function Ku({stream:e,agents:t,size:n=`sm`}){if(!e)return null;let r=Hu(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)(ld,{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)(Lu,{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 qu({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=zu(s),[u,d]=(0,P.useState)({}),f=q(`/admin/bus-writes`,1e4).data?.enabled??!1,[p,m]=(0,P.useState)({}),h=async(n,r)=>{m(e=>({...e,[n]:{to:r??`aide`,ts:Date.now()}}));try{let i=await Ia(`/actions/task/${e}/${t.id}/${n}`,{owner:r??void 0});if(i.status!==`ok`)throw Error(i.error??i.log?.slice(-1)[0]??`failed`);m(e=>({...e,[n]:{to:i.owner??r??`aide`,ts:Date.now()}}))}catch(e){m(t=>({...t,[n]:{err:e.message}}))}};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=Vu(l,t.n,Bu(e.title)),m=!!n&&!!s&&Hu(s.owner,c.map(e=>e.agentId))===n,g=u[e.line]===void 0?o:!u[e.line];return(0,B.jsxs)(`div`,{className:`border-b border-sand last:border-b-0 min-w-0 ${m?`bg-ember/[.04]`:``}`,children:[(0,B.jsxs)(`div`,{className:`sticky top-0 z-[1] px-3 py-1.5 min-w-0 ${m?`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:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>d(t=>({...t,[e.line]:g})),className:`border-0 bg-transparent p-0 cursor-pointer font-mono text-[11px] text-tan w-3 shrink-0 hover:text-umber`,title:g?`expand`:`collapse`,"aria-expanded":!g,children:g?`▸`:`▾`}),m&&(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)(Ku,{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)(Ku,{stream:s,agents:c})})]}),!g&&e.tasks.map(e=>(0,B.jsxs)(`div`,{className:`group grid grid-cols-[var(--spacing-gutter)_minmax(0,1fr)_auto] items-start hover:bg-linen/60 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`:p[e.line]&&!(`err`in p[e.line])?`text-amber`:`text-tan`}`,title:p[e.line]&&!(`err`in p[e.line])?`asked ${p[e.line].to} to tick it`:void 0,children:e.done?`- [x]`:p[e.line]&&!(`err`in p[e.line])?`- [~]`:`- [ ]`}),(0,B.jsxs)(V,{to:`/docs/${encodeURIComponent(a.file)}?view=source&line=${e.line}`,className:`px-3 py-1.5 min-w-0 break-words hover:no-underline text-inherit ${i?`text-[12px] leading-snug`:`text-[13px]`} ${e.done?`text-tan line-through decoration-dust`:``}`,children:[(0,B.jsx)(Gu,{text:e.text}),p[e.line]&&`err`in p[e.line]&&(0,B.jsx)(`span`,{className:`ml-2 font-mono text-[10px] text-brick`,children:p[e.line].err})]}),(0,B.jsx)(`span`,{className:`pr-2 pt-1 shrink-0`,children:!e.done&&(p[e.line]&&!(`err`in p[e.line])?(0,B.jsxs)(`span`,{className:`font-mono text-[10px] text-amber whitespace-nowrap`,title:`the owner was asked to run /check-task; the tick appears when it does`,children:[`asked · `,p[e.line].to.split(`-`).slice(-1)[0]]}):(0,B.jsx)(`button`,{type:`button`,disabled:!f,onClick:()=>h(e.line,s?Hu(s.owner,c.map(e=>e.agentId)):null),className:`opacity-0 group-hover:opacity-100 focus:opacity-100 font-mono text-[10px] px-1.5 py-0.5 rounded border ${f?`border-dust text-umber bg-paper hover:text-leaf hover:border-leaf cursor-pointer`:`border-dashed border-dust text-tan cursor-not-allowed`}`,title:f?`ask ${s?s.owner:`the aide`} to run /check-task for this line`:`bus writes are off (header) — mark done DMs the owner`,children:`✓ done`}))})]},e.line))]},e.line)})}):(0,B.jsx)(`div`,{className:`px-3 py-2 font-mono text-[12px] text-tan`,children:`…`})}function Ju({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)(qu,{project:e,phase:t})]})}var Yu=`/api`,Xu=/\[image: (\S+) · (\S+)\]/g,Zu=e=>`${Yu}/uploads/${encodeURIComponent(e.split(`/`).pop()??``)}`;function Qu(e){let t=e?.persistKey,[n,r]=(0,P.useState)(()=>{if(!t)return[];try{return JSON.parse(localStorage.getItem(t)??`[]`)}catch{return[]}}),i=(0,P.useCallback)(e=>r(n=>{let r=e(n);if(t)try{r.length?localStorage.setItem(t,JSON.stringify(r)):localStorage.removeItem(t)}catch{}return r}),[t]);(0,P.useEffect)(()=>{if(t)try{r(JSON.parse(localStorage.getItem(t)??`[]`))}catch{r([])}},[t]);let[a,o]=(0,P.useState)(0),[s,c]=(0,P.useState)(null),l=(0,P.useCallback)(async e=>{let t=e.filter(e=>e.type.startsWith(`image/`));if(t.length){o(e=>e+t.length),c(null);for(let e of t)try{let t=new FormData;t.append(`file`,e,e.name||`paste.png`);let n=await fetch(`${Yu}/uploads`,{method:`POST`,body:t}),r=await n.json();if(!n.ok)throw Error(r.error??`${n.status}`);i(e=>e.some(e=>e.name===r.name)?e:[...e,r])}catch(e){c(e.message)}finally{o(e=>e-1)}}},[]),u=(0,P.useCallback)(e=>{let t=Array.from(e.clipboardData?.files??[]);t.length&&(e.preventDefault(),l(t))},[l]),d=(0,P.useCallback)(e=>{let t=Array.from(e.dataTransfer?.files??[]);t.length&&(e.preventDefault(),l(t))},[l]),f=(0,P.useCallback)(e=>{e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()},[]);return{items:n,busy:a>0,err:s,onPaste:u,onDrop:d,onDragOver:f,remove:e=>i(t=>t.filter(t=>t.name!==e)),clear:()=>i(()=>[]),withRefs:e=>n.length?`${e.trim()}${e.trim()?`
|
|
25
25
|
`:``}${n.map(e=>e.ref).join(`
|
|
26
26
|
`)}`:e,hasContent:e=>!!e.trim()||n.length>0}}function $u({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:Zu(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})]})}var ed=/(^|\n)\s*(#{1,6}\s|[-*+]\s|\d+[.)]\s|\|.*\||```|~~~|>\s|(-{3,}|\*{3,})\s*$)/;function td({text:e}){return ed.test(e)?(0,B.jsx)(`div`,{className:`md md-bubble whitespace-normal min-w-0`,dangerouslySetInnerHTML:{__html:yu(e)}}):(0,B.jsx)(Wu,{text:e})}function nd({text:e}){let t=[],n=0,r,i=0;for(Xu.lastIndex=0;r=Xu.exec(e);){r.index>n&&t.push((0,B.jsx)(td,{text:e.slice(n,r.index)},`t${i++}`));let[,a,o]=r;t.push((0,B.jsx)(`a`,{href:Zu(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:Zu(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((0,B.jsx)(td,{text:e.slice(n)},`t${i++}`)),(0,B.jsx)(B.Fragment,{children:t})}var rd=`/api`;function id({agentId:e,onClose:t}){let{linkify:n}=ju(),[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:_}=Ha(),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=Qu(),E=async()=>{if(T.hasContent(x)){w(`sending`);try{let t=await Ia(`/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(`${rd}/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 ${dd(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)(Lu,{id:e,role:y?.role,size:22,state:y?.reachability,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:dd(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?mo(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)($u,{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)(ad,{project:b,agentId:e})]})]})})}function ad({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=zu(n).filter(e=>!e.done&&Hu(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)(Ku,{stream:e,agents:r})})]},e.name))]}),i&&e?(0,B.jsx)(qu,{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 od=`/api`,sd=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 cd({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(`${od}/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 ${sd(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?mo(u(i.ansi)):u(i.text):`capturing…`})]}),c&&(0,B.jsx)(id,{agentId:e,onClose:()=>l(!1)})]})}function ld({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.reachability}`:` · not on the bus`}`,children:[t&&(0,B.jsx)(`span`,{className:`text-tan`,children:t}),!a&&(0,B.jsx)(Lu,{id:e,role:o?.role,size:n===`sm`?14:18,state:o?.reachability??`dead`,active:o?.active}),(0,B.jsx)(`span`,{className:`truncate max-w-[220px]`,children:e}),o&&!o.transport&&o.reachability!==`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)(cd,{agentId:e,lines:6,label:`${e} · ${o.role??``}`,className:`shadow-panel bg-paper`})}),l&&(0,B.jsx)(id,{agentId:e,onClose:()=>u(!1)})]})}var ud=[{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`}],dd=e=>ud.find(t=>t.re.test(e??``))?.dot??`#5C7A96`,fd=e=>ud.find(t=>t.re.test(e??``))?.label??`worker`;function pd(e,t,n){return e.project===t||!!n&&e.project===n}function md(e){return e.agentId===`groundwork-console`||e.agentId===`david`}function hd(){let{projects:e,current:t}=Ha(),n=q(`/bus/agents`,15e3).data??[],r=e.find(e=>e.name===t)?.room,i=n.filter(e=>!md(e)&&e.reachability!==`dead`&&pd(e,t,r)),a=n.filter(e=>!md(e)&&e.reachability!==`dead`&&!i.includes(e)),o=e=>[`aide`,`coordinator`,`qa`,`ci`,`worker`,`audit`].indexOf(fd(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:dd(e.role)+`66`},title:`${e.agentId} · ${fd(e.role)}${e.pane?` · ${e.pane}`:``}`,children:[(0,B.jsx)(Lu,{id:e.agentId,role:e.role,size:16,state:e.reachability,active:e.active}),(0,B.jsx)(ld,{id:e.agentId,bare:!0,noDot:!0,size:`sm`}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.06em]`,style:{color:dd(e.role)},children:fd(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} · ${fd(e.role)} · ${e.project??`?`}`,children:[(0,B.jsx)(Lu,{id:e.agentId,role:e.role,size:16,state:e.reachability,active:e.active}),(0,B.jsx)(ld,{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))})]})}function gd(e){let[t,n]=(0,P.useState)(!1),r=(0,P.useRef)(e);return(0,P.useEffect)(()=>{let e=()=>{let e=document.getSelection();n(!!e&&!e.isCollapsed)};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[]),t||(r.current=e),r.current}var _d={clear:`reset the agent's context — typed raw into its CLI via send_command`,compact:`compact the agent's context — typed raw into its CLI via send_command`,"reload-skills":`reload the agent's skills after a playbook update — typed raw into its CLI via send_command`},vd=e=>e.map(e=>e.replace(/^\//,``)).map(e=>({name:e,description:_d[e]??`typed raw into the agent's CLI via send_command`,source:`built-in`}));function $(e,t){let n=e.slice(0,t),r=n.match(/(^|\s)\/([\w-]*)$/);return r?{start:n.length-r[2].length-1,query:r[2]}:null}function yd(e){let t=q(e?`/projects/${e}/skills`:null,6e4).data,n=za();return(0,P.useMemo)(()=>[...vd(n),...(t?.groundwork.skills??[]).map(e=>({name:e.name,description:e.description,source:`groundwork`})),...(t?.playbook.cards??[]).map(e=>({name:e.name,description:e.description,source:`playbook`}))],[t,n])}function bd({skills:e,query:t,onPick:n,onClose:r,bind:i}){let a=(0,P.useMemo)(()=>{let n=t.toLowerCase(),r=e.filter(e=>e.name.toLowerCase().includes(n));return(r.length?r:e.filter(e=>e.description.toLowerCase().includes(n))).sort((e,t)=>Number(t.name.toLowerCase().startsWith(n))-Number(e.name.toLowerCase().startsWith(n))||e.name.localeCompare(t.name)).slice(0,12)},[e,t]),[o,s]=(0,P.useState)(0),c=(0,P.useRef)(null);return(0,P.useEffect)(()=>{s(0)},[t]),(0,P.useEffect)(()=>(i(e=>e.key===`ArrowDown`?(s(e=>Math.min(e+1,a.length-1)),!0):e.key===`ArrowUp`?(s(e=>Math.max(e-1,0)),!0):(e.key===`Enter`||e.key===`Tab`)&&a[o]?(n(a[o].name),!0):e.key===`Escape`&&(r(),!0)),()=>i(null)),[i,a,o,n,r]),(0,P.useEffect)(()=>{c.current?.querySelector(`[data-i="${o}"]`)?.scrollIntoView({block:`nearest`})},[o]),a.length===0?(0,B.jsxs)(`div`,{className:`absolute left-0 right-0 bottom-full mb-1 bg-paper border border-sand rounded-kit shadow-panel px-2 py-1.5 font-mono text-[11px] text-tan`,children:[`no skill matches “/`,t,`” — Enter sends the text as typed`]}):(0,B.jsxs)(`div`,{ref:c,role:`listbox`,"aria-label":`slash commands`,className:`absolute left-0 right-0 bottom-full mb-1 max-h-[240px] overflow-auto overscroll-contain bg-paper border border-sand rounded-kit shadow-panel grid`,children:[a.map((e,t)=>(0,B.jsxs)(`button`,{"data-i":t,type:`button`,role:`option`,"aria-selected":t===o,onMouseDown:t=>{t.preventDefault(),n(e.name)},onMouseEnter:()=>s(t),className:`grid grid-cols-[auto_1fr_auto] gap-2 items-baseline px-2 py-1 text-left border-0 cursor-pointer ${t===o?`bg-linen`:`bg-transparent`}`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[12px] font-semibold text-walnut`,children:[`/`,e.name]}),(0,B.jsx)(`span`,{className:`text-[12px] text-umber truncate`,title:e.description,children:e.description}),(0,B.jsx)(G,{tone:e.source===`built-in`?`warn`:e.source===`playbook`?`neutral`:`outline`,children:e.source===`built-in`?`built-in · raw`:e.source})]},`${e.source}:${e.name}`)),(0,B.jsx)(`div`,{className:`px-2 py-1 font-mono text-[10px] text-tan border-t border-sand`,children:`↑↓ move · Enter/Tab insert · Esc close · sent as a text DM; the agent runs the skill`})]})}var xd=(e,t)=>window.dispatchEvent(new CustomEvent(`groundwork-console:summon`,{detail:{agentId:e,answers:t?.answers}})),Sd=e=>`groundwork-console.summon.${e}`,Cd=e=>`groundwork-console.summon.seen.${e}`;function wd(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 Td(){let{current:e,projects:t}=Ha(),n=q(`/bus/agents`,2e4).data??[],r=q(e?`/projects/${e}/agents`:null,3e4).data,i=n.filter(e=>e.reachability!==`dead`&&!md(e)),a=t.find(t=>t.name===e)?.room,o=e?i.filter(t=>pd(t,e,a)):i,[s,c]=(0,P.useState)(()=>e?localStorage.getItem(Sd(e)):null);(0,P.useEffect)(()=>{c(e?localStorage.getItem(Sd(e)):null)},[e]);let l=(s&&i.some(e=>e.agentId===s)?s:null)??r?.aide??r?.coordinator??o[0]?.agentId??null,u=n.find(e=>e.agentId===l),[d,f]=(0,P.useState)(!1),[p,m]=(0,P.useState)(!1),h=t=>{c(t),e&&localStorage.setItem(Sd(e),t),m(!1),f(!0)},g=gd(q(l?`/bus/dm/${encodeURIComponent(l)}?limit=80`:null,d?4e3:2e4).data),_=q(`/bus/inbox?limit=100`,2e4).data?.decisions??{},[v,y]=(0,P.useState)(0);(0,P.useEffect)(()=>{l&&y(Number(localStorage.getItem(Cd(l))??0))},[l]),(0,P.useEffect)(()=>{d&&l&&g&&(localStorage.setItem(Cd(l),String(g.lastFromAgent)),y(g.lastFromAgent))},[d,l,g]);let b=!!g&&g.lastFromAgent>v;(0,P.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(m(!1),f(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[x,S]=(0,P.useState)([]);(0,P.useEffect)(()=>{let e=e=>{let t=e.detail;S(t?.answers??[]),t?.agentId?h(t.agentId):(f(!1),m(!0))};return window.addEventListener(`groundwork-console:summon`,e),()=>window.removeEventListener(`groundwork-console:summon`,e)});let[C,w]=(0,P.useState)(``);if((0,P.useEffect)(()=>{p||w(``)},[p]),!l)return null;let T=e=>Math.max(e.paneActivity??0,e.lastSeen??0,e.lastHeartbeat??0),E=[...o].sort((e,t)=>Number(/aide/i.test(t.role??``))-Number(/aide/i.test(e.role??``))||T(t)-T(e)),D=o.length>6||i.length>o.length,O=D?E.slice(0,6):E,k=C.trim()?i.filter(e=>`${e.agentId} ${e.role??``} ${e.project??``}`.toLowerCase().includes(C.trim().toLowerCase())):E.slice(6),A=O.length,j=e=>{let t=(A===1?.5:e/(A-1))*(Math.PI/2);return{x:-Math.sin(t)*96,y:-Math.cos(t)*96}};return(0,B.jsxs)(B.Fragment,{children:[d&&(0,B.jsx)(kd,{agentId:l,me:u,project:e,thread:g??void 0,answers:x,onAnswered:()=>S([]),onClose:()=>f(!1),onSwitch:()=>{m(!0)}}),(0,B.jsxs)(`div`,{className:`fixed right-5 bottom-5 z-[55]`,style:{width:52,height:52},children:[p&&(0,B.jsxs)(`div`,{className:`absolute inset-0`,"aria-label":`pick an agent`,children:[O.map((e,t)=>{let n=j(t);return(0,B.jsxs)(`button`,{onClick:()=>h(e.agentId),title:`${e.agentId} · ${fd(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:dd(e.role),width:34,height:34,animation:`summon-pop .18s ease-out ${t*30}ms both`},children:[(0,B.jsx)(Lu,{id:e.agentId,role:e.role,size:26,state:e.reachability,active:e.active}),_[e.agentId]?(0,B.jsx)(Ed,{n:_[e.agentId],small:!0}):null]},e.agentId)}),O.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`}),D&&(0,B.jsxs)(`div`,{className:`absolute right-0 bottom-[130px] w-[300px] bg-paper border border-sand rounded-kit shadow-panel p-2 grid gap-1`,onMouseDown:e=>e.stopPropagation(),children:[(0,B.jsx)(`input`,{autoFocus:!0,value:C,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k[0]&&h(k[0].agentId),e.key===`Escape`&&m(!1)},placeholder:e?`${o.length} live in ${e} — type to search all projects`:`${o.length} live — type to filter (id · role · project)`,className:`text-[12px] px-2 py-1.5 border border-dust rounded-kit bg-paper text-walnut font-mono`}),(0,B.jsxs)(`div`,{className:`max-h-[220px] overflow-auto overscroll-contain grid`,children:[k.slice(0,40).map((e,t)=>(0,B.jsxs)(`button`,{onClick:()=>h(e.agentId),className:`grid grid-cols-[auto_1fr_auto] items-center gap-2 px-1.5 py-1 rounded border-0 cursor-pointer text-left ${t===0&&C.trim()?`bg-linen`:`bg-transparent hover:bg-linen/60`}`,title:`${e.agentId} · ${fd(e.role)} · ${e.project??``}`,children:[(0,B.jsx)(Lu,{id:e.agentId,role:e.role,size:16,state:e.reachability,active:e.active}),(0,B.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-[12px] text-walnut`,children:[e.agentId,(0,B.jsxs)(`span`,{className:`text-tan`,children:[` · `,fd(e.role),e.project?` · ${e.project}`:``]})]}),_[e.agentId]?(0,B.jsxs)(`span`,{className:`font-mono text-[10px] text-ember`,children:[`★`,_[e.agentId]]}):null]},e.agentId)),k.length===0&&(0,B.jsx)(`span`,{className:`px-1.5 py-1 font-mono text-[11px] text-tan`,children:C.trim()?`no match`:`${o.length===1?`the only ${e||`bus`} agent is`:`all ${o.length} ${e||`bus`} agents are`} on the ring — type to search other projects`})]}),(0,B.jsxs)(`span`,{className:`font-mono text-[10px] text-tan px-1`,children:[`ring = aide + `,5,` most recent · Enter picks the first match`]})]})]}),(0,B.jsxs)(`button`,{onClick:()=>p?m(!1):f(e=>!e),title:`${l} · ${fd(u?.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:dd(u?.role)},children:[(0,B.jsx)(Lu,{id:l,role:u?.role,size:40,state:u?.reachability??`dead`,active:u?.active}),_[l]?(0,B.jsx)(Ed,{n:_[l]}):b&&(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:()=>m(e=>!e),"aria-pressed":p,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 ${p?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:p?`×`:`+`})]}),(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 Ed({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`},Od=(0,P.memo)(function({m:e,mine:t,maxed:n}){let r=String(e.text??``),i=e.prefix?r.replace(RegExp(`^${e.prefix}:?\\s*`),``):r;return(0,B.jsxs)(`div`,{className:`${e.pending?`opacity-70`:``} ${n?`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 ${t?`justify-self-end bg-paper border-sand`:`justify-self-start bg-linen/70 border-sand/70`}`,children:[e.prefix&&(0,B.jsx)(Oa,{prefix:e.prefix}),(0,B.jsx)(nd,{text:i}),(0,B.jsx)(`div`,{className:`font-mono text-[10px] mt-0.5 ${t?`text-right`:``} ${e.failed?`text-brick`:`text-tan`}`,children:e.failed?`not sent · ${e.failed}`:e.pending?`sending…`:e.ts?new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``})]})},(e,t)=>e.m===t.m&&e.mine===t.mine&&e.maxed===t.maxed);function kd({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=wd(n),[u,d]=(0,P.useState)(!0),f=`groundwork-console.summon.draft.${e}`,[p,m]=(0,P.useState)(()=>localStorage.getItem(f)??``),[h,g]=(0,P.useState)(null),_=e=>{m(e);try{e?localStorage.setItem(f,e):localStorage.removeItem(f)}catch{}};(0,P.useEffect)(()=>{m(localStorage.getItem(`groundwork-console.summon.draft.${e}`)??``)},[e]);let[v,y]=(0,P.useState)(!1),[b,x]=(0,P.useState)(()=>localStorage.getItem(`groundwork-console.summon.max`)===`1`),S=()=>x(e=>(localStorage.setItem(`groundwork-console.summon.max`,e?`0`:`1`),!e)),C=Qu({persistKey:`groundwork-console.summon.att.${e}`}),w=yd(n),T=new Set(za()),E=(0,P.useRef)(null),[D,O]=(0,P.useState)(0),[k,A]=(0,P.useState)(!0),j=k?$(p,D):null,M=(0,P.useRef)(null),N=(0,P.useCallback)(e=>{M.current=e},[]),ee=(0,P.useRef)(null),F=(0,P.useCallback)(e=>{let t=$(p,D);if(!t)return;let n=`${p.slice(0,t.start)}/${e} ${p.slice(D)}`,r=t.start+e.length+2;_(n),O(r),ee.current=r},[p,D]);(0,P.useEffect)(()=>{if(ee.current!==null&&E.current){let e=ee.current;ee.current=null,E.current.focus(),E.current.setSelectionRange(e,e)}},[p]);let I=(0,P.useRef)(null),[te,ne]=(0,P.useState)([]),re=r?.messages??[],L=e=>ie.current.get(`${e.text??``}`)??null,ie=(0,P.useRef)(new Map),R=te.filter(e=>!re.some(t=>t.from===`david`&&Number(t.ts??0)>=Number(e.ts??0)-2e3&&(t.text??``)===(e.text??``))),z=[...re,...R],ae=new Set,oe=(e,t)=>{let n=e.pending?String(e.id):(e.from===`david`?L(e):null)??e.id??`${e.ts??`t`}-${t}`;return ae.has(n)&&(n=e.id??`${n}-${t}`),ae.add(n),n},[se,ce]=(0,P.useState)(0);(0,P.useEffect)(()=>{let e=setInterval(()=>ce(e=>e+1),1e3);return()=>clearInterval(e)},[]);let le=(q(`/bus/agents`,4e3).data??[]).find(t=>t.agentId===e)??t,ue=le?.paneActivity?Date.now()-le.paneActivity:1/0,de=ue<2e4,fe=([...z].reverse().find(e=>e.from===`david`)?.ts??0)>([...z].reverse().find(e=>e.from!==`david`)?.ts??0),[pe,me]=(0,P.useState)(!0),he=()=>{let e=I.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<32;t!==pe&&me(t)};(0,P.useEffect)(()=>{pe&&I.current&&(I.current.scrollTop=I.current.scrollHeight)},[z.length,pe]);let ge=async()=>{if(!C.hasContent(p))return;g(`sending`);let t=p.trim(),n=T.has(t),r=n?t:t.startsWith(`/`)?`AGENT_ACTION: run ${t}`:t,o=n?t:C.withRefs(r),s=n?t:u?`${o}\n(context: ${l.cite})`:o,c={id:`local-${Date.now()}`,ts:Date.now(),from:`david`,to:e,text:s,prefix:null,pending:!0};ie.current.set(String(c.text??``),String(c.id)),ie.current.size>50&&ie.current.delete(ie.current.keys().next().value),ne(e=>[...e,c]),_(``),C.clear();try{let n=await Ia(`/actions/send`,{as:`david`,to:e,text:s,answers:i.length?i:void 0});if(n.status===`ok`)g(n.raw?n.delivery===`confirmed`?`${t} typed into the pane (delivery confirmed)`:n.warning??`${t}: delivery ${n.delivery??`unknown`}`:n.warning??null),a?.();else{let e=n.error??n.log?.slice(-1)[0]??`failed`;g(e),ne(t=>t.map(t=>t.id===c.id?{...t,failed:e}:t))}}catch(e){let t=e.message;g(t),ne(e=>e.map(e=>e.id===c.id?{...e,failed:t}:e))}},_e=(0,P.useMemo)(()=>z,[z]);return(0,B.jsxs)(B.Fragment,{children:[v&&(0,B.jsx)(id,{agentId:e,onClose:()=>y(!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 ${b?`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 ${dd(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)(Lu,{id:e,role:t?.role,size:22,state:t?.reachability??`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:dd(t?.role)},children:fd(t?.role)}),t?(0,B.jsx)(G,{tone:t.reachability===`live`?`ok`:t.reachability===`idle`||t.reachability===`dormant`?`warn`:`bad`,children:t.active?`active`:t.reachability}):(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:()=>y(!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:S,title:b?`restore`:`maximize`,children:b?`⇲`:`⇱`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:o,children:`✕`})]})]}),(0,B.jsxs)(`div`,{ref:I,onScroll:he,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&&_e.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.`]}),_e.map((e,t)=>(0,B.jsx)(Od,{m:e,mine:e.from===`david`,maxed:b},oe(e,t))),(de||fe)&&(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:le?.paneActivity?`last pane output ${Math.round(ue/1e3)} s ago`:`no pane activity`,children:de?(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 `,ue===1/0?`a while`:Dd(ue)]})]})})]}),(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:`relative grid grid-cols-[1fr_auto] gap-1.5 items-center`,children:[(0,B.jsx)(`textarea`,{ref:E,value:p,onChange:e=>{_(e.target.value),O(e.target.selectionStart??e.target.value.length),A(!0)},onClick:e=>O(e.target.selectionStart??0),onKeyUp:e=>O(e.target.selectionStart??0),onKeyDown:e=>{if(j&&M.current&&M.current(e)){e.preventDefault();return}e.key===`Enter`&&!e.shiftKey&&c&&(e.preventDefault(),ge())},onPaste:C.onPaste,onDrop:C.onDrop,onDragOver:C.onDragOver,disabled:!c,rows:b?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:ge,disabled:!c||!C.hasContent(p)||C.busy||h===`sending`,children:h===`sending`?`…`:`Send`}),j&&c&&(0,B.jsx)(bd,{skills:w,query:j.query,onPick:F,onClose:()=>A(!1),bind:N})]}),(0,B.jsx)($u,{a:C}),T.has(p.trim())?(0,B.jsxs)(`div`,{className:`font-mono text-[11px] text-ink3`,children:[(0,B.jsx)(`span`,{className:`text-umber`,children:p.trim()}),` is sent `,(0,B.jsx)(`b`,{children:`raw`}),` (no banner, no context) via the bus send_command — the agent's CLI runs it; delivery is confirmed by its pusher`]}):p.trim().startsWith(`/`)&&(0,B.jsxs)(`div`,{className:`font-mono text-[11px] text-ink3`,children:[`sends as `,(0,B.jsxs)(`span`,{className:`text-umber`,children:[`AGENT_ACTION: run `,p.trim().split(/\s/)[0],` …`]}),` — the bus pusher drops raw leading-slash DMs (only the MCP's allowlist — `,[...T].join(` `),` — goes raw); the agent runs the skill from the request`]}),h&&h!==`sending`&&(0,B.jsx)(`div`,{className:`font-mono text-[11px] ${/delivery confirmed/.test(h)?`text-leaf`:`text-brick`}`,children:h})]})]})]})}var Ad={h:`/`,b:`/board`,m:`/monitor`,u:`/bus`,d:`/docs`,g:`/git`,o:`/ops`},jd=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||jd(r.target))){if(r.key===`Escape`){n(!1);return}if(r.key===`?`){n(e=>!e);return}if(r.key===`/`){r.preventDefault(),xd(``);return}if(r.key===`g`&&!(Date.now()-t<900)){t=Date.now();return}Date.now()-t<900&&Ad[r.key]&&(r.preventDefault(),e(Ad[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 g`,`Git`],[`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 Nd=`/api`;function Pd({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(`${Nd}/auth/status`)).json();n(e.authed?`in`:`out`)}catch{n(`offline`)}};(0,P.useEffect)(()=>{l()},[]),(0,P.useEffect)(()=>{t!==`in`&&fetch(`${Nd}/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(`${Nd}/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)(Pa,{}),` 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 Fd=[{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:`/git`,label:`Git`,icon:`git`},{to:`/ops`,label:`Ops`,icon:`fleet`}];function Id(){let{error:e}=Ha(),{running:t}=Ga(),n=q(`/bus/unread`,3e4).data?.inbox??0,r=q(`/kit`).data,i=q(`/health`,6e4).data,a=i?.hostname,o=!!i?.version&&i.version!==`0.1.16`,s=rr();(0,P.useEffect)(()=>{let e=s.pathname===`/`?``:s.pathname.split(`/`)[1],t=Fd.find(t=>t.to===`/`?e===``:t.to===`/${e}`)?.label??(e?e[0].toUpperCase()+e.slice(1):`Home`);document.title=a?`${t} · ${a}`:t},[s.pathname,a]);let c=r?.packages?`${r.name} ${r.kitVersion} · seam ${r.packages.seam?.version} · mcp ${r.packages.mcp?.version}`:`kit · offline`;return(0,B.jsx)(Pd,{children:(0,B.jsx)(Mu,{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:c,children:[(0,B.jsx)(Pa,{}),` Groundwork Console`]}),(0,B.jsx)(`nav`,{className:`flex gap-0.5 whitespace-nowrap`,children:Fd.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:wa[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)(Na,{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)(Ja,{}),(0,B.jsx)(Qa,{}),(0,B.jsx)(Za,{}),o&&(0,B.jsxs)(`button`,{onClick:()=>location.reload(),className:`mr-1 font-mono text-[11px] px-2 py-1 rounded-full bg-amber-wash text-amber border border-amber-line cursor-pointer`,title:`this tab runs 0.1.16, the API is ${i?.version} — reload to get the new UI`,children:[`new version `,i?.version,` — reload`]}),(0,B.jsx)(so,{}),(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)(hd,{}),(0,B.jsx)(Rr,{}),(0,B.jsx)(co,{}),(0,B.jsx)(Td,{}),(0,B.jsx)(Md,{})]})})})}function Ld(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 Rd(e,t=Date.now()){let n=(t-e)/864e5;return n<1?`text-tan`:n<7?`text-amber`:`text-brick font-semibold`}var zd=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),Bd=e=>!!e&&Ea.includes(e),Vd={"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 Hd(){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 Ia(`/events/config`,{rule:e,enabled:n}),t()}finally{s(!1)}},l=async e=>{s(!0);try{await Ia(`/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}`,` · `,Bd(e.action.prefix)&&(0,B.jsx)(Oa,{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:Vd[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:zd(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`}),Bd(e.prefix)&&(0,B.jsx)(Oa,{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 Ud(){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 Wd={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 Gd({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 Kd({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 Ia(`/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 Ia(`/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&&xd(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)(ld,{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)(ld,{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)(Na,{size:12}):`Write the PRD with the aide`}),i?.aide&&(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>xd(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)(Na,{size:12}):`Kickstart with the aide`}),i?.aide&&(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>xd(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 min-w-0`,children:[(0,B.jsx)(`div`,{className:`overflow-x-auto overscroll-x-contain [scrollbar-width:thin]`,children:(0,B.jsx)(`ol`,{className:`flex items-start gap-0 min-w-max`,children:t.map((e,n)=>{let r=Wd[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)(Gd,{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)(ld,{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)(Na,{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)(Na,{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)(Na,{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)(Ju,{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)(ld,{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(Wd).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 ${Wd[e].dot}`}),Wd[e].label,` — `,Wd[e].hint]},e))})]})]})}function qd({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 ${Wd[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 Jd({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}=Ga(),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 Ia(`/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 min-w-0 max-w-full ${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)(Na,{}),` `,(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 min-w-0 max-w-full break-words overscroll-contain`,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 ${sd(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?mo(u(i.ansi)):u(i.text):`capturing…`})]}),c&&(0,B.jsx)(id,{agentId:e,onClose:()=>l(!1)})]})}function ld({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.reachability}`:` · not on the bus`}`,children:[t&&(0,B.jsx)(`span`,{className:`text-tan`,children:t}),!a&&(0,B.jsx)(Lu,{id:e,role:o?.role,size:n===`sm`?14:18,state:o?.reachability??`dead`,active:o?.active}),(0,B.jsx)(`span`,{className:`truncate max-w-[220px]`,children:e}),o&&!o.transport&&o.reachability!==`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)(cd,{agentId:e,lines:6,label:`${e} · ${o.role??``}`,className:`shadow-panel bg-paper`})}),l&&(0,B.jsx)(id,{agentId:e,onClose:()=>u(!1)})]})}var ud=[{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`}],dd=e=>ud.find(t=>t.re.test(e??``))?.dot??`#5C7A96`,fd=e=>ud.find(t=>t.re.test(e??``))?.label??`worker`;function pd(e,t,n){return e.project===t||!!n&&e.project===n}function md(e){return e.agentId===`groundwork-console`||e.agentId===`david`}function hd(){let{projects:e,current:t}=Ha(),n=q(`/bus/agents`,15e3).data??[],r=e.find(e=>e.name===t)?.room,i=n.filter(e=>!md(e)&&e.reachability!==`dead`&&pd(e,t,r)),a=n.filter(e=>!md(e)&&e.reachability!==`dead`&&!i.includes(e)),o=e=>[`aide`,`coordinator`,`qa`,`ci`,`worker`,`audit`].indexOf(fd(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:dd(e.role)+`66`},title:`${e.agentId} · ${fd(e.role)}${e.pane?` · ${e.pane}`:``}`,children:[(0,B.jsx)(Lu,{id:e.agentId,role:e.role,size:16,state:e.reachability,active:e.active}),(0,B.jsx)(ld,{id:e.agentId,bare:!0,noDot:!0,size:`sm`}),(0,B.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[.06em]`,style:{color:dd(e.role)},children:fd(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} · ${fd(e.role)} · ${e.project??`?`}`,children:[(0,B.jsx)(Lu,{id:e.agentId,role:e.role,size:16,state:e.reachability,active:e.active}),(0,B.jsx)(ld,{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))})]})}function gd(e){let[t,n]=(0,P.useState)(!1),r=(0,P.useRef)(e);return(0,P.useEffect)(()=>{let e=()=>{let e=document.getSelection();n(!!e&&!e.isCollapsed)};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[]),t||(r.current=e),r.current}var _d={clear:`reset the agent's context — typed raw into its CLI via send_command`,compact:`compact the agent's context — typed raw into its CLI via send_command`,"reload-skills":`reload the agent's skills after a playbook update — typed raw into its CLI via send_command`},vd=e=>e.map(e=>e.replace(/^\//,``)).map(e=>({name:e,description:_d[e]??`typed raw into the agent's CLI via send_command`,source:`built-in`}));function $(e,t){let n=e.slice(0,t),r=n.match(/(^|\s)\/([\w-]*)$/);return r?{start:n.length-r[2].length-1,query:r[2]}:null}function yd(e){let t=q(e?`/projects/${e}/skills`:null,6e4).data,n=za();return(0,P.useMemo)(()=>[...vd(n),...(t?.groundwork.skills??[]).map(e=>({name:e.name,description:e.description,source:`groundwork`})),...(t?.playbook.cards??[]).map(e=>({name:e.name,description:e.description,source:`playbook`}))],[t,n])}function bd({skills:e,query:t,onPick:n,onClose:r,bind:i}){let a=(0,P.useMemo)(()=>{let n=t.toLowerCase(),r=e.filter(e=>e.name.toLowerCase().includes(n));return(r.length?r:e.filter(e=>e.description.toLowerCase().includes(n))).sort((e,t)=>Number(t.name.toLowerCase().startsWith(n))-Number(e.name.toLowerCase().startsWith(n))||e.name.localeCompare(t.name)).slice(0,12)},[e,t]),[o,s]=(0,P.useState)(0),c=(0,P.useRef)(null);return(0,P.useEffect)(()=>{s(0)},[t]),(0,P.useEffect)(()=>(i(e=>e.key===`ArrowDown`?(s(e=>Math.min(e+1,a.length-1)),!0):e.key===`ArrowUp`?(s(e=>Math.max(e-1,0)),!0):(e.key===`Enter`||e.key===`Tab`)&&a[o]?(n(a[o].name),!0):e.key===`Escape`&&(r(),!0)),()=>i(null)),[i,a,o,n,r]),(0,P.useEffect)(()=>{c.current?.querySelector(`[data-i="${o}"]`)?.scrollIntoView({block:`nearest`})},[o]),a.length===0?(0,B.jsxs)(`div`,{className:`absolute left-0 right-0 bottom-full mb-1 bg-paper border border-sand rounded-kit shadow-panel px-2 py-1.5 font-mono text-[11px] text-tan`,children:[`no skill matches “/`,t,`” — Enter sends the text as typed`]}):(0,B.jsxs)(`div`,{ref:c,role:`listbox`,"aria-label":`slash commands`,className:`absolute left-0 right-0 bottom-full mb-1 max-h-[240px] overflow-auto overscroll-contain bg-paper border border-sand rounded-kit shadow-panel grid`,children:[a.map((e,t)=>(0,B.jsxs)(`button`,{"data-i":t,type:`button`,role:`option`,"aria-selected":t===o,onMouseDown:t=>{t.preventDefault(),n(e.name)},onMouseEnter:()=>s(t),className:`grid grid-cols-[auto_1fr_auto] gap-2 items-baseline px-2 py-1 text-left border-0 cursor-pointer ${t===o?`bg-linen`:`bg-transparent`}`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-[12px] font-semibold text-walnut`,children:[`/`,e.name]}),(0,B.jsx)(`span`,{className:`text-[12px] text-umber truncate`,title:e.description,children:e.description}),(0,B.jsx)(G,{tone:e.source===`built-in`?`warn`:e.source===`playbook`?`neutral`:`outline`,children:e.source===`built-in`?`built-in · raw`:e.source})]},`${e.source}:${e.name}`)),(0,B.jsx)(`div`,{className:`px-2 py-1 font-mono text-[10px] text-tan border-t border-sand`,children:`↑↓ move · Enter/Tab insert · Esc close · sent as a text DM; the agent runs the skill`})]})}var xd=(e,t)=>window.dispatchEvent(new CustomEvent(`groundwork-console:summon`,{detail:{agentId:e,answers:t?.answers}})),Sd=e=>`groundwork-console.summon.${e}`,Cd=e=>`groundwork-console.summon.seen.${e}`;function wd(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 Td(){let{current:e,projects:t}=Ha(),n=q(`/bus/agents`,2e4).data??[],r=q(e?`/projects/${e}/agents`:null,3e4).data,i=n.filter(e=>e.reachability!==`dead`&&!md(e)),a=t.find(t=>t.name===e)?.room,o=e?i.filter(t=>pd(t,e,a)):i,[s,c]=(0,P.useState)(()=>e?localStorage.getItem(Sd(e)):null);(0,P.useEffect)(()=>{c(e?localStorage.getItem(Sd(e)):null)},[e]);let l=(s&&i.some(e=>e.agentId===s)?s:null)??r?.aide??r?.coordinator??o[0]?.agentId??null,u=n.find(e=>e.agentId===l),[d,f]=(0,P.useState)(!1),[p,m]=(0,P.useState)(!1),h=t=>{c(t),e&&localStorage.setItem(Sd(e),t),m(!1),f(!0)},g=gd(q(l?`/bus/dm/${encodeURIComponent(l)}?limit=80`:null,d?4e3:2e4).data),_=q(`/bus/inbox?limit=100`,2e4).data?.decisions??{},[v,y]=(0,P.useState)(0);(0,P.useEffect)(()=>{l&&y(Number(localStorage.getItem(Cd(l))??0))},[l]),(0,P.useEffect)(()=>{d&&l&&g&&(localStorage.setItem(Cd(l),String(g.lastFromAgent)),y(g.lastFromAgent))},[d,l,g]);let b=!!g&&g.lastFromAgent>v;(0,P.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(m(!1),f(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[x,S]=(0,P.useState)([]);(0,P.useEffect)(()=>{let e=e=>{let t=e.detail;S(t?.answers??[]),t?.agentId?h(t.agentId):(f(!1),m(!0))};return window.addEventListener(`groundwork-console:summon`,e),()=>window.removeEventListener(`groundwork-console:summon`,e)});let[C,w]=(0,P.useState)(``);if((0,P.useEffect)(()=>{p||w(``)},[p]),!l)return null;let T=e=>Math.max(e.paneActivity??0,e.lastSeen??0,e.lastHeartbeat??0),E=[...o].sort((e,t)=>Number(/aide/i.test(t.role??``))-Number(/aide/i.test(e.role??``))||T(t)-T(e)),D=o.length>6||i.length>o.length,O=D?E.slice(0,6):E,k=C.trim()?i.filter(e=>`${e.agentId} ${e.role??``} ${e.project??``}`.toLowerCase().includes(C.trim().toLowerCase())):E.slice(6),A=O.length,j=e=>{let t=(A===1?.5:e/(A-1))*(Math.PI/2);return{x:-Math.sin(t)*96,y:-Math.cos(t)*96}};return(0,B.jsxs)(B.Fragment,{children:[d&&(0,B.jsx)(kd,{agentId:l,me:u,project:e,thread:g??void 0,answers:x,onAnswered:()=>S([]),onClose:()=>f(!1),onSwitch:()=>{m(!0)}}),(0,B.jsxs)(`div`,{className:`fixed right-5 bottom-5 z-[55]`,style:{width:52,height:52},children:[p&&(0,B.jsxs)(`div`,{className:`absolute inset-0`,"aria-label":`pick an agent`,children:[O.map((e,t)=>{let n=j(t);return(0,B.jsxs)(`button`,{onClick:()=>h(e.agentId),title:`${e.agentId} · ${fd(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:dd(e.role),width:34,height:34,animation:`summon-pop .18s ease-out ${t*30}ms both`},children:[(0,B.jsx)(Lu,{id:e.agentId,role:e.role,size:26,state:e.reachability,active:e.active}),_[e.agentId]?(0,B.jsx)(Ed,{n:_[e.agentId],small:!0}):null]},e.agentId)}),O.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`}),D&&(0,B.jsxs)(`div`,{className:`absolute right-0 bottom-[130px] w-[300px] bg-paper border border-sand rounded-kit shadow-panel p-2 grid gap-1`,onMouseDown:e=>e.stopPropagation(),children:[(0,B.jsx)(`input`,{autoFocus:!0,value:C,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k[0]&&h(k[0].agentId),e.key===`Escape`&&m(!1)},placeholder:e?`${o.length} live in ${e} — type to search all projects`:`${o.length} live — type to filter (id · role · project)`,className:`text-[12px] px-2 py-1.5 border border-dust rounded-kit bg-paper text-walnut font-mono`}),(0,B.jsxs)(`div`,{className:`max-h-[220px] overflow-auto overscroll-contain grid`,children:[k.slice(0,40).map((e,t)=>(0,B.jsxs)(`button`,{onClick:()=>h(e.agentId),className:`grid grid-cols-[auto_1fr_auto] items-center gap-2 px-1.5 py-1 rounded border-0 cursor-pointer text-left ${t===0&&C.trim()?`bg-linen`:`bg-transparent hover:bg-linen/60`}`,title:`${e.agentId} · ${fd(e.role)} · ${e.project??``}`,children:[(0,B.jsx)(Lu,{id:e.agentId,role:e.role,size:16,state:e.reachability,active:e.active}),(0,B.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-[12px] text-walnut`,children:[e.agentId,(0,B.jsxs)(`span`,{className:`text-tan`,children:[` · `,fd(e.role),e.project?` · ${e.project}`:``]})]}),_[e.agentId]?(0,B.jsxs)(`span`,{className:`font-mono text-[10px] text-ember`,children:[`★`,_[e.agentId]]}):null]},e.agentId)),k.length===0&&(0,B.jsx)(`span`,{className:`px-1.5 py-1 font-mono text-[11px] text-tan`,children:C.trim()?`no match`:`${o.length===1?`the only ${e||`bus`} agent is`:`all ${o.length} ${e||`bus`} agents are`} on the ring — type to search other projects`})]}),(0,B.jsxs)(`span`,{className:`font-mono text-[10px] text-tan px-1`,children:[`ring = aide + `,5,` most recent · Enter picks the first match`]})]})]}),(0,B.jsxs)(`button`,{onClick:()=>p?m(!1):f(e=>!e),title:`${l} · ${fd(u?.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:dd(u?.role)},children:[(0,B.jsx)(Lu,{id:l,role:u?.role,size:40,state:u?.reachability??`dead`,active:u?.active}),_[l]?(0,B.jsx)(Ed,{n:_[l]}):b&&(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:()=>m(e=>!e),"aria-pressed":p,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 ${p?`bg-walnut text-paper`:`bg-paper text-umber`}`,children:p?`×`:`+`})]}),(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 Ed({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`},Od=(0,P.memo)(function({m:e,mine:t,maxed:n}){let r=String(e.text??``),i=e.prefix?r.replace(RegExp(`^${e.prefix}:?\\s*`),``):r;return(0,B.jsxs)(`div`,{className:`${e.pending?`opacity-70`:``} ${n?`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 ${t?`justify-self-end bg-paper border-sand`:`justify-self-start bg-linen/70 border-sand/70`}`,children:[e.prefix&&(0,B.jsx)(Oa,{prefix:e.prefix}),(0,B.jsx)(nd,{text:i}),(0,B.jsx)(`div`,{className:`font-mono text-[10px] mt-0.5 ${t?`text-right`:``} ${e.failed?`text-brick`:`text-tan`}`,children:e.failed?`not sent · ${e.failed}`:e.pending?`sending…`:e.ts?new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``})]})},(e,t)=>e.m===t.m&&e.mine===t.mine&&e.maxed===t.maxed);function kd({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=wd(n),[u,d]=(0,P.useState)(!0),f=`groundwork-console.summon.draft.${e}`,[p,m]=(0,P.useState)(()=>localStorage.getItem(f)??``),[h,g]=(0,P.useState)(null),_=e=>{m(e);try{e?localStorage.setItem(f,e):localStorage.removeItem(f)}catch{}};(0,P.useEffect)(()=>{m(localStorage.getItem(`groundwork-console.summon.draft.${e}`)??``)},[e]);let[v,y]=(0,P.useState)(!1),[b,x]=(0,P.useState)(()=>localStorage.getItem(`groundwork-console.summon.max`)===`1`),S=()=>x(e=>(localStorage.setItem(`groundwork-console.summon.max`,e?`0`:`1`),!e)),C=Qu({persistKey:`groundwork-console.summon.att.${e}`}),w=yd(n),T=new Set(za()),E=(0,P.useRef)(null),[D,O]=(0,P.useState)(0),[k,A]=(0,P.useState)(!0),j=k?$(p,D):null,M=(0,P.useRef)(null),N=(0,P.useCallback)(e=>{M.current=e},[]),ee=(0,P.useRef)(null),F=(0,P.useCallback)(e=>{let t=$(p,D);if(!t)return;let n=`${p.slice(0,t.start)}/${e} ${p.slice(D)}`,r=t.start+e.length+2;_(n),O(r),ee.current=r},[p,D]);(0,P.useEffect)(()=>{if(ee.current!==null&&E.current){let e=ee.current;ee.current=null,E.current.focus(),E.current.setSelectionRange(e,e)}},[p]);let I=(0,P.useRef)(null),[te,ne]=(0,P.useState)([]),re=r?.messages??[],L=e=>ie.current.get(`${e.text??``}`)??null,ie=(0,P.useRef)(new Map),R=te.filter(e=>!re.some(t=>t.from===`david`&&Number(t.ts??0)>=Number(e.ts??0)-2e3&&(t.text??``)===(e.text??``))),z=[...re,...R],ae=new Set,oe=(e,t)=>{let n=e.pending?String(e.id):(e.from===`david`?L(e):null)??e.id??`${e.ts??`t`}-${t}`;return ae.has(n)&&(n=e.id??`${n}-${t}`),ae.add(n),n},[se,ce]=(0,P.useState)(0);(0,P.useEffect)(()=>{let e=setInterval(()=>ce(e=>e+1),1e3);return()=>clearInterval(e)},[]);let le=(q(`/bus/agents`,4e3).data??[]).find(t=>t.agentId===e)??t,ue=le?.paneActivity?Date.now()-le.paneActivity:1/0,de=ue<2e4,fe=([...z].reverse().find(e=>e.from===`david`)?.ts??0)>([...z].reverse().find(e=>e.from!==`david`)?.ts??0),[pe,me]=(0,P.useState)(!0),he=()=>{let e=I.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<32;t!==pe&&me(t)};(0,P.useEffect)(()=>{pe&&I.current&&(I.current.scrollTop=I.current.scrollHeight)},[z.length,pe]);let ge=async()=>{if(!C.hasContent(p))return;g(`sending`);let t=p.trim(),n=T.has(t),r=n?t:t.startsWith(`/`)?`AGENT_ACTION: run ${t}`:t,o=n?t:C.withRefs(r),s=n?t:u?`${o}\n(context: ${l.cite})`:o,c={id:`local-${Date.now()}`,ts:Date.now(),from:`david`,to:e,text:s,prefix:null,pending:!0};ie.current.set(String(c.text??``),String(c.id)),ie.current.size>50&&ie.current.delete(ie.current.keys().next().value),ne(e=>[...e,c]),_(``),C.clear();try{let n=await Ia(`/actions/send`,{as:`david`,to:e,text:s,answers:i.length?i:void 0});if(n.status===`ok`)g(n.raw?n.delivery===`confirmed`?`${t} typed into the pane (delivery confirmed)`:n.warning??`${t}: delivery ${n.delivery??`unknown`}`:n.warning??null),a?.();else{let e=n.error??n.log?.slice(-1)[0]??`failed`;g(e),ne(t=>t.map(t=>t.id===c.id?{...t,failed:e}:t))}}catch(e){let t=e.message;g(t),ne(e=>e.map(e=>e.id===c.id?{...e,failed:t}:e))}},_e=(0,P.useMemo)(()=>z,[z]);return(0,B.jsxs)(B.Fragment,{children:[v&&(0,B.jsx)(id,{agentId:e,onClose:()=>y(!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 ${b?`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 ${dd(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)(Lu,{id:e,role:t?.role,size:22,state:t?.reachability??`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:dd(t?.role)},children:fd(t?.role)}),t?(0,B.jsx)(G,{tone:t.reachability===`live`?`ok`:t.reachability===`idle`||t.reachability===`dormant`?`warn`:`bad`,children:t.active?`active`:t.reachability}):(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:()=>y(!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:S,title:b?`restore`:`maximize`,children:b?`⇲`:`⇱`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:o,children:`✕`})]})]}),(0,B.jsxs)(`div`,{ref:I,onScroll:he,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&&_e.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.`]}),_e.map((e,t)=>(0,B.jsx)(Od,{m:e,mine:e.from===`david`,maxed:b},oe(e,t))),(de||fe)&&(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:le?.paneActivity?`last pane output ${Math.round(ue/1e3)} s ago`:`no pane activity`,children:de?(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 `,ue===1/0?`a while`:Dd(ue)]})]})})]}),(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:`relative grid grid-cols-[1fr_auto] gap-1.5 items-center`,children:[(0,B.jsx)(`textarea`,{ref:E,value:p,onChange:e=>{_(e.target.value),O(e.target.selectionStart??e.target.value.length),A(!0)},onClick:e=>O(e.target.selectionStart??0),onKeyUp:e=>O(e.target.selectionStart??0),onKeyDown:e=>{if(j&&M.current&&M.current(e)){e.preventDefault();return}e.key===`Enter`&&!e.shiftKey&&c&&(e.preventDefault(),ge())},onPaste:C.onPaste,onDrop:C.onDrop,onDragOver:C.onDragOver,disabled:!c,rows:b?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:ge,disabled:!c||!C.hasContent(p)||C.busy||h===`sending`,children:h===`sending`?`…`:`Send`}),j&&c&&(0,B.jsx)(bd,{skills:w,query:j.query,onPick:F,onClose:()=>A(!1),bind:N})]}),(0,B.jsx)($u,{a:C}),T.has(p.trim())?(0,B.jsxs)(`div`,{className:`font-mono text-[11px] text-ink3`,children:[(0,B.jsx)(`span`,{className:`text-umber`,children:p.trim()}),` is sent `,(0,B.jsx)(`b`,{children:`raw`}),` (no banner, no context) via the bus send_command — the agent's CLI runs it; delivery is confirmed by its pusher`]}):p.trim().startsWith(`/`)&&(0,B.jsxs)(`div`,{className:`font-mono text-[11px] text-ink3`,children:[`sends as `,(0,B.jsxs)(`span`,{className:`text-umber`,children:[`AGENT_ACTION: run `,p.trim().split(/\s/)[0],` …`]}),` — the bus pusher drops raw leading-slash DMs (only the MCP's allowlist — `,[...T].join(` `),` — goes raw); the agent runs the skill from the request`]}),h&&h!==`sending`&&(0,B.jsx)(`div`,{className:`font-mono text-[11px] ${/delivery confirmed/.test(h)?`text-leaf`:`text-brick`}`,children:h})]})]})]})}var Ad={h:`/`,b:`/board`,m:`/monitor`,u:`/bus`,d:`/docs`,g:`/git`,o:`/ops`},jd=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||jd(r.target))){if(r.key===`Escape`){n(!1);return}if(r.key===`?`){n(e=>!e);return}if(r.key===`/`){r.preventDefault(),xd(``);return}if(r.key===`g`&&!(Date.now()-t<900)){t=Date.now();return}Date.now()-t<900&&Ad[r.key]&&(r.preventDefault(),e(Ad[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 g`,`Git`],[`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 Nd=`/api`;function Pd({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(`${Nd}/auth/status`)).json();n(e.authed?`in`:`out`)}catch{n(`offline`)}};(0,P.useEffect)(()=>{l()},[]),(0,P.useEffect)(()=>{t!==`in`&&fetch(`${Nd}/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(`${Nd}/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)(Pa,{}),` 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 Fd=[{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:`/git`,label:`Git`,icon:`git`},{to:`/ops`,label:`Ops`,icon:`fleet`}];function Id(){let{error:e}=Ha(),{running:t}=Ga(),n=q(`/bus/unread`,3e4).data?.inbox??0,r=q(`/kit`).data,i=q(`/health`,6e4).data,a=i?.hostname,o=!!i?.version&&i.version!==`0.1.17`,s=rr();(0,P.useEffect)(()=>{let e=s.pathname===`/`?``:s.pathname.split(`/`)[1],t=Fd.find(t=>t.to===`/`?e===``:t.to===`/${e}`)?.label??(e?e[0].toUpperCase()+e.slice(1):`Home`);document.title=a?`${t} · ${a}`:t},[s.pathname,a]);let c=r?.packages?`${r.name} ${r.kitVersion} · seam ${r.packages.seam?.version} · mcp ${r.packages.mcp?.version}`:`kit · offline`;return(0,B.jsx)(Pd,{children:(0,B.jsx)(Mu,{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:c,children:[(0,B.jsx)(Pa,{}),` Groundwork Console`]}),(0,B.jsx)(`nav`,{className:`flex gap-0.5 whitespace-nowrap`,children:Fd.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:wa[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)(Na,{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)(Ja,{}),(0,B.jsx)(Qa,{}),(0,B.jsx)(Za,{}),o&&(0,B.jsxs)(`button`,{onClick:()=>location.reload(),className:`mr-1 font-mono text-[11px] px-2 py-1 rounded-full bg-amber-wash text-amber border border-amber-line cursor-pointer`,title:`this tab runs 0.1.17, the API is ${i?.version} — reload to get the new UI`,children:[`new version `,i?.version,` — reload`]}),(0,B.jsx)(so,{}),(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)(hd,{}),(0,B.jsx)(Rr,{}),(0,B.jsx)(co,{}),(0,B.jsx)(Td,{}),(0,B.jsx)(Md,{})]})})})}function Ld(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 Rd(e,t=Date.now()){let n=(t-e)/864e5;return n<1?`text-tan`:n<7?`text-amber`:`text-brick font-semibold`}var zd=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),Bd=e=>!!e&&Ea.includes(e),Vd={"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 Hd(){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 Ia(`/events/config`,{rule:e,enabled:n}),t()}finally{s(!1)}},l=async e=>{s(!0);try{await Ia(`/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}`,` · `,Bd(e.action.prefix)&&(0,B.jsx)(Oa,{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:Vd[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:zd(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`}),Bd(e.prefix)&&(0,B.jsx)(Oa,{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 Ud(){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 Wd={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 Gd({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 Kd({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 Ia(`/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 Ia(`/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&&xd(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)(ld,{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)(ld,{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)(Na,{size:12}):`Write the PRD with the aide`}),i?.aide&&(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>xd(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)(Na,{size:12}):`Kickstart with the aide`}),i?.aide&&(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>xd(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 min-w-0`,children:[(0,B.jsx)(`div`,{className:`overflow-x-auto overscroll-x-contain [scrollbar-width:thin]`,children:(0,B.jsx)(`ol`,{className:`flex items-start gap-0 min-w-max`,children:t.map((e,n)=>{let r=Wd[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)(Gd,{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)(ld,{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)(Na,{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)(Na,{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)(Na,{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)(Ju,{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)(ld,{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(Wd).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 ${Wd[e].dot}`}),Wd[e].label,` — `,Wd[e].hint]},e))})]})]})}function qd({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 ${Wd[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 Jd({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}=Ga(),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 Ia(`/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 min-w-0 max-w-full ${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)(Na,{}),` `,(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 min-w-0 max-w-full break-words overscroll-contain`,children:[D.log.join(`
|
|
29
29
|
`),D.error?`
|
|
30
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)(Na,{}),` Starting…`]}):`Spawn`})]})]})})}function Yd({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)(ld,{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)(Jd,{project:e,canWrite:n,initialRole:a,onClose:()=>o(null)})]})}var Xd={absent:`bad`,partial:`warn`,present:`ok`};function Zd({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:Xd[e.state],children:t})}function Qd({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)(Zd,{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)(Yd,{project:e,fleet:n,canWrite:t,compact:!0})]}),i&&(0,B.jsx)($d,{project:e,templates:n.templates,missing:n.missing,canWrite:t,onClose:()=>{a(!1),r()}})]})}function $d({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}=Ga(),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 min-w-0 max-w-full ${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)(Na,{}),` `,(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 min-w-0 max-w-full break-words overscroll-contain`,children:w.log.join(`
|
|
31
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 Ia(`/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)(Na,{}),` Starting…`]}):`Spawn ${(T?.roles.length??0)+E} agents`})]})]})})}var ef=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`},tf=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 nf(){let{projects:e,setCurrent:t,error:n,refresh:r}=Ha(),i=q(`/kit`).data,a=q(`/bus/agents`,3e4).data??[],o=a.filter(e=>e.reachability===`live`).length,s=a.filter(e=>e.reachability===`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)(Xa,{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
32
|
`),children:`kit version mismatch`}),(i?.requires?.mcp.warnings?.length??0)>0&&(0,B.jsx)(`span`,{className:`font-mono text-[11px] px-2 py-1 rounded-full bg-amber-wash text-amber border border-amber-line`,title:i.requires.mcp.warnings.join(`
|
|
33
33
|
`),children:`mcp: inReplyTo missing`}),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]=tf(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)(Zd,{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 ${ef(e.lastActive)} · ${e.lastActiveSource}`:`no activity recorded`}),(0,B.jsx)(qd,{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)(ka,{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] ${Rd(e.ts)}`,title:new Date(e.ts).toLocaleString(),children:Ld(e.ts)}):null]}),(0,B.jsx)(`div`,{className:`text-[14px] break-words line-clamp-2`,title:e.title,children:(0,B.jsx)(Wu,{text:e.title})}),e.detail&&(0,B.jsx)(`div`,{className:`text-[13px] text-umber break-words line-clamp-2`,children:(0,B.jsx)(Wu,{text: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(),xd(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)(ka,{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)(ka,{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)(Ud,{})]})}function rf({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 af({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 Ia(`/actions/queue-add/${e}`,{priority:a,text:s}):await Ia(`/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 min-w-0 max-w-full ${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 min-w-0 max-w-full break-words overflow-auto overscroll-contain max-h-[30vh]`,children:[h.log.join(`
|
|
34
34
|
`),h.error?`
|
|
35
|
-
`+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`})]})]})})}function of(){let{data:e}=q(`/bus/conditions`,2e4);if(!e)return null;let{halt:t,away:n,subscriptions:r}=e;return!t.active&&!n.active&&r.neverEvaluated===0?null:(0,B.jsxs)(`div`,{className:`grid gap-2`,children:[t.active&&(0,B.jsxs)(`div`,{className:`rounded-kit border border-brick-line bg-brick-wash/40 px-4 py-3 flex items-center gap-3 flex-wrap`,children:[(0,B.jsx)(G,{tone:`solid`,children:`BUS HALTED`}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[t.reason?(0,B.jsx)(`b`,{className:`text-walnut font-normal`,children:t.reason}):(0,B.jsx)(`i`,{children:`no reason recorded — a halt stops every lane and should name why`}),t.by&&(0,B.jsxs)(`span`,{className:`text-tan`,children:[` · set by `,t.by]})]}),(0,B.jsx)(`span`,{className:`ml-auto font-mono text-[12px] text-brick`,children:`every lane is blocked`})]}),(n.active||r.neverEvaluated>0)&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap font-mono text-[12px] text-umber`,children:[n.active&&(0,B.jsxs)(G,{tone:`outline`,children:[`coordinator away`,n.agentId?` · ${n.agentId}`:``]}),n.active&&n.note&&(0,B.jsx)(`span`,{className:`text-tan`,children:n.note}),r.neverEvaluated>0&&(0,B.jsx)(`span`,{title:`A subscription that has never been evaluated has not run — that is different from having no events, and only one of the two is healthy.`,children:(0,B.jsxs)(G,{tone:`warn`,children:[r.neverEvaluated,` of `,r.total,` subscription`,r.total===1?``:`s`,` never evaluated`]})}),r.neverEvaluated>0&&r.agents.length>0&&(0,B.jsx)(`span`,{className:`text-tan`,children:r.agents.join(`, `)})]})]})}var sf=[[/⛔|\bblocked\s+by\b|\bblocker\b|^\s*blocked\b/i,`bad`],[/^\s*⏭|\bskipped\b/i,`neutral`],[/^\s*◻|\bno[-\s]?downstream\b/i,`neutral`],[/^\s*🚧|\bclaimed\b|\bin progress\b/i,`warn`],[/^\s*✅|\bdone\b|\bmerged\b|\bdeployed\b/i,`ok`],[/\bwatch\b|\bsoak\b/i,`ok`]],cf=e=>sf.find(([t])=>t.test(e))?.[1]??`neutral`,lf=(e,t)=>e??(t?`no Active Streams table`:`no WORKSTREAMS.md`),uf=(e,t=3)=>{if(e.length===0)return null;let n=e.slice(0,t).join(` · `);return`${e.length} parser issue${e.length>1?`s`:``}: ${n}${e.length>t?` …`:``}`},df=6,ff=`1.6fr 1.1fr 1.4fr 1fr 1fr 2fr`,pf=`1.4fr 1fr 1fr 1.6fr 1.6fr`;function mf({priority:e,raw:t}){return(0,B.jsx)(`span`,{className:`font-mono font-bold text-[12px] px-[7px] py-[3px] rounded text-center ${e===`P1`?`bg-ember-wash text-ember-deep`:e===`P2`?`bg-amber-wash text-amber`:e===`P3`?`bg-slate-wash text-slate`:`bg-brick-wash text-brick border border-brick-line`}`,title:e?void 0:`invalid priority ${JSON.stringify(t??``)} — kept verbatim; valid tags are P1, P2, P3`,children:e??t??`?`})}function hf({issues:e}){let t=uf(e);return t===null?null:(0,B.jsx)(`div`,{className:`px-3 py-2 border-t border-sand text-[12px] font-mono text-ink3`,children:t})}var gf=({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 _f({r:e,raw:t,cols:n}){return`malformed`in e?(0,B.jsx)(ka,{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)(ka,{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:(0,B.jsx)(Wu,{text: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:cf(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:(0,B.jsx)(Wu,{text:e.blocker})})}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,title:e.lastNote,children:(0,B.jsx)(Wu,{text:e.lastNote})})]})}):(0,B.jsx)(ka,{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:(0,B.jsx)(Wu,{text: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:cf(e.state),children:e.state})}),(0,B.jsx)(`span`,{className:`text-[13px] truncate`,children:(0,B.jsx)(Wu,{text:e.currentSlice})}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,children:(0,B.jsx)(Wu,{text:e.nextGo})})]})})}function vf(){let{current:e}=Ha(),[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 Ia(`/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)(!1),S=[...r?.facts?.entries??[]].sort((e,t)=>Number(!!t.stale)-Number(!!e.stale)),C=b?S:S.slice(0,df),[w,T]=(0,P.useState)(null),[E,D]=(0,P.useState)(!1),O=async()=>{D(!0);try{await Ia(`/actions/project-doctor/${e}`),o.refresh()}finally{D(!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 k=r.workstreams.schema,A=k===`workstreams.v1`,j=A?ff:pf,M=e=>r.scopes[e]?{path:e,owner:r.scopes[e].owner,mode:r.scopes[e].mode??`shared`,note:r.scopes[e].note}:void 0,N=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:[w&&(0,B.jsx)(af,{project:e,req:w,seamOn:h,scope:w.kind===`add`?M(`docs/QUEUE.md`):M(`docs/FACTS.md`),onClose:()=>{T(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}),N&&(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[N.title,` · `,N.done,`/`,N.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:O,disabled:E,children:E?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Na,{size:12}),` Doctor`]}):`Doctor`})]})]}),(0,B.jsx)(of,{}),(0,B.jsx)(Qd,{project:e,canWrite:m}),(0,B.jsx)(Kd,{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:lf(k,r.files.workstreams),path:`docs/WORKSTREAMS.md`,children:[(0,B.jsx)(rf,{scope:M(`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)(gf,{k:`s`})]})]}),k===`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.`})]}),k===`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&&(A?(0,B.jsxs)(Aa,{cols:j,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)(Aa,{cols:j,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)(_f,{r:e,raw:t,cols:j},n)),(0,B.jsx)(hf,{issues:r.workstreams.issues})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Queue`,icon:`queue`,eyebrow:`queue.v1`,path:`docs/QUEUE.md`,children:[(0,B.jsx)(rf,{scope:M(`docs/QUEUE.md`)}),(0,B.jsx)(K,{size:`sm`,tone:h?`primary`:`default`,onClick:()=>T({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)(ka,{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)(mf,{priority:e.priority,raw:e.priorityRaw}),(0,B.jsx)(`span`,{className:e.done?`line-through text-tan`:``,children:(0,B.jsx)(Wu,{text:e.text})})]})},e.id)),(0,B.jsx)(hf,{issues:r.queueIssues})]}),(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)(rf,{scope:M(`docs/DONE.md`)}),(0,B.jsx)(yf,{k:`done`,open:g.done,onToggle:v})]}),g.done&&r.done.slice(-8).reverse().map(e=>(0,B.jsx)(ka,{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:(0,B.jsx)(Wu,{text:e.text})}),(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-ink3`,children:e.date??``})]})},e.id)),(0,B.jsx)(hf,{issues:r.doneIssues})]})]}),(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)(rf,{scope:M(`docs/FACTS.md`)}),(0,B.jsx)(yf,{k:`facts`,open:g.facts,onToggle:v})]}),g.facts&&!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&&r.facts&&(0,B.jsx)(`div`,{className:`max-h-[26rem] overflow-y-auto overscroll-contain`,children:C.map(e=>(0,B.jsx)(ka,{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:(0,B.jsx)(Wu,{text:e.value})}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3 truncate`,title:`${e.ageDays===null?`unverified`:`${e.ageDays} d`}${e.by?` · ${e.by}`:``}${e.method?` · ${e.method}`:``}`,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:()=>T({kind:`fact`,id:e.id,claim:e.value}),title:`upsert this fact through the seam with a fresh timestamp`,children:`Re-verify…`})]})},e.id))}),g.facts&&S.length>df&&(0,B.jsx)(`button`,{onClick:()=>x(e=>!e),className:`w-full text-left px-3 py-1.5 border-t border-sand font-mono text-[12px] text-tan hover:text-umber cursor-pointer`,children:b?`show fewer`:`+${S.length-df} more`}),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)(ka,{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)(Na,{size:11}):`Fix →`}),(0,B.jsx)(ld,{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)(ld,{id:d[e.check].replace(/^sent → /,``)})]}):d[e.check]})]})},e.check))]})]})]})}function yf({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 bf=e=>{let t=/^([\w.-]+\/[\w.-]+)#(\d+)$/.exec(e.trim());return t?`https://github.com/${t[1]}/pull/${t[2]}`:null},xf=e=>{let t=e.trim().replace(/^\.\//,``);return/^docs\/[\w./-]+\.md(#.*)?$/i.test(t)?t.split(`#`)[0]:null},Sf=`font-mono text-[11px] px-1.5 py-0.5 rounded border border-dust bg-linen/70 text-umber`;function Cf({cites:e}){return e?.length?(0,B.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 items-center`,children:e.map((e,t)=>{let n=`${e.kind}:${e.ref}:${t}`;if(e.kind===`url`)return(0,B.jsx)(`a`,{className:`${Sf} hover:border-ember hover:text-ember-deep`,href:e.ref,target:`_blank`,rel:`noreferrer`,children:e.ref.replace(/^https?:\/\//,``).slice(0,48)},n);if(e.kind===`pr`){let t=bf(e.ref);return t?(0,B.jsx)(`a`,{className:`${Sf} hover:border-ember hover:text-ember-deep`,href:t,target:`_blank`,rel:`noreferrer`,title:e.ref,children:e.ref},n):(0,B.jsx)(`span`,{className:Sf,title:`unqualified ref — every repository has this number, so it is shown rather than linked to a guess`,children:e.ref},n)}if(e.kind===`file`){let t=xf(e.ref);return t?(0,B.jsx)(V,{className:`${Sf} hover:border-ember hover:text-ember-deep`,to:`/docs/${encodeURIComponent(t)}`,title:e.ref,children:e.ref},n):(0,B.jsx)(`span`,{className:Sf,title:`not a docs path this console can open`,children:e.ref},n)}return(0,B.jsx)(`button`,{type:`button`,className:`${Sf} cursor-pointer hover:border-ember`,title:`copy ${e.ref}`,onClick:()=>void navigator.clipboard?.writeText(e.ref),children:e.ref.slice(0,12)},n)})}):null}var wf=({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}),Tf=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``,Ef=e=>e?new Date(e).toLocaleDateString([],{month:`short`,day:`numeric`}):``,Df=e=>!!e&&Ea.includes(e),Of=(e,t)=>t&&e.startsWith(t)?e.slice(t.length).replace(/^:?\s*/,``):e,kf=`/api`;function Af(){let{projects:e,current:t}=Ha(),[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),v=q(d===`room`&&f?`/bus/rooms/${f}/messages?limit=80`:null,1e4),y=gd(v.data),b=v.error,x=q(d===`status`?`/bus/status?limit=100`:null,15e3).data??[],S=q(d===`inbox`?`/bus/inbox?limit=200`:null,2e4),C={data:gd(S.data),refresh:S.refresh,error:S.error},[w,T]=(0,P.useState)(!1),E=async()=>{T(!0);try{await Ia(`/bus/inbox/read`),C.refresh()}finally{T(!1)}},[D,O]=(0,P.useState)([]),[k,A]=(0,P.useState)(!1);(0,P.useEffect)(()=>{O([])},[f]);let j=(0,P.useMemo)(()=>{let e=new Set;return[...D,...y?.messages??[]].filter(t=>{let n=t.id??`${t.ts}-${t.from}`;return!e.has(n)&&(e.add(n),!0)})},[D,y]),M=j.filter(e=>!e.system).slice().reverse(),N=async()=>{let e=j[0]?.ts;if(e){A(!0);try{let t=await(await fetch(`${kf}/bus/rooms/${f}/messages?limit=80&before=${e}`)).json();O(e=>[...t.messages,...e])}finally{A(!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,M.length]);let ee=M.filter(e=>e.prefix===`DAVID_DECISION`&&!e.answered),F=(_?.members??[]).map(e=>l.find(t=>t.agentId===e)??{agentId:e,reachability:`dead`,pane:null,role:void 0,active:!1}),I=e=>Date.now()-e.lastTs<3e5,te=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})},ne=!!y&&j.length<y.total,re=!!q(`/admin/bus-writes`,1e4).data?.enabled,[L,ie]=(0,P.useState)(`david`),[R,z]=(0,P.useState)(``),[ae,oe]=(0,P.useState)(!1),[se,ce]=(0,P.useState)(null),[le,ue]=(0,P.useState)(null),de=Qu(),[fe,pe]=(0,P.useState)(null),me=q(`/bus/unread`,3e4).data?.inbox??0,he=`#${f}`,ge=async()=>{oe(!0),ce(null);try{let e=he.startsWith(`#`)?{room:he.slice(1)}:{to:he.replace(/^@/,``)},t=await Ia(`/actions/send`,{as:L,...e,text:de.withRefs(R),answers:le?.id?[le.id]:void 0,kind:/^DAVID_DECISION/.test(R)?`decision`:void 0});if(t.status!==`ok`)throw Error(t.error??t.log?.slice(-1)[0]??`failed`);z(``),ue(null),de.clear()}catch(e){ce(e.message)}finally{oe(!1)}};return(0,B.jsxs)(`div`,{className:`grid ${ee.length>0?`grid-cols-[240px_1fr_320px]`:`grid-cols-[240px_1fr]`} gap-4 p-4 max-[980px]:grid-cols-1`,children:[fe&&(0,B.jsx)(id,{agentId:fe,onClose:()=>pe(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)(wf,{children:`Rooms · list_rooms`}),h.map(e=>(0,B.jsxs)(`button`,{onClick:()=>te({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:[I(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)(wf,{children:`Direct · inbox`}),(0,B.jsxs)(`button`,{onClick:()=>te({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`}),me>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:[me,` unread`]})]}),(0,B.jsx)(wf,{children:`Status stream`}),(0,B.jsx)(`button`,{onClick:()=>te({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:[C.data&&(C.data.unread>0?(0,B.jsxs)(G,{tone:`david`,children:[C.data.unread,` unread`]}):(0,B.jsx)(G,{tone:`outline`,children:`all read`})),C.data&&C.data.unread>0&&(0,B.jsx)(K,{size:`sm`,onClick:E,disabled:w,children:w?`…`:`Mark all read`})]}),C.error&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-brick`,children:C.error}),C.data&&C.data.messages.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`No DMs to david.`}),(C.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:[Ef(e.ts),` `,Tf(e.ts)]}),re&&e.from&&(0,B.jsx)(`button`,{className:`ml-auto font-mono text-[12px] text-ember-deep bg-transparent border-0 cursor-pointer`,onClick:()=>xd(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:[Df(r)&&(0,B.jsx)(Oa,{prefix:r,fail:r===`VERDICT`&&/FAIL/.test(n)}),(0,B.jsx)(nd,{text:Of(n,r)}),(0,B.jsx)(Cf,{cites:e.record?.cites})]})]})]},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`}),x.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`empty`}),x.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:[Ef(e.ts),` `,Tf(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:y?`${y.total} messages`:``,children:(0,B.jsxs)(G,{tone:`outline`,children:[_?.members?.length??0,` members`]})}),me>0&&(0,B.jsxs)(`button`,{onClick:()=>te({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:[me,` unread DM`,me===1?``:`s`,` to david`]}),(0,B.jsx)(`span`,{className:`text-umber`,children:`— open your inbox →`})]}),F.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`}),F.map(e=>(0,B.jsxs)(`button`,{onClick:()=>xd(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)(Lu,{id:e.agentId,role:e.role,size:14,state:e.reachability,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:`}),Ea.map(e=>(0,B.jsx)(Oa,{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:[ne&&(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:N,disabled:k,children:k?`loading…`:`Load older (${y.total-j.length} more)`})}),b&&(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px] text-brick`,children:[`API error: `,b]}),M.length===0&&!b&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`No messages yet.`}),M.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)(Lu,{id:e.from??`?`,role:l.find(t=>t.agentId===e.from)?.role,size:14,state:l.find(t=>t.agentId===e.from)?.reachability??`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:[Ef(e.ts),` `,Tf(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:[Df(e.prefix)&&(0,B.jsx)(Oa,{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:()=>te({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)(nd,{text:Of(i,e.prefix)}),(0,B.jsx)(Cf,{cites:e.record?.cites})]})]})]},e.id??t)})]})}),(0,B.jsxs)(`div`,{className:`border-t border-sand px-3 py-2.5 grid gap-1.5`,children:[le&&(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 `,le.from,` · `,Tf(le.ts)]}),(0,B.jsx)(`button`,{className:`border-0 bg-transparent text-ink3 cursor-pointer`,onClick:()=>{ue(null),z(``)},children:`✕`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-[auto_auto_1fr_auto] gap-2 items-center`,children:[(0,B.jsxs)(`select`,{value:L,onChange:e=>ie(e.target.value),disabled:!re,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:R,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&re&&de.hasContent(R)&&ge()},onPaste:de.onPaste,onDrop:de.onDrop,onDragOver:de.onDragOver,disabled:!re,className:`text-[13px] px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`,placeholder:re?he.startsWith(`#`)?`FYI: … (rooms need a prefix)`:`message…`:`bus writes are off — enable in the header`}),(0,B.jsx)(K,{tone:`primary`,size:`sm`,onClick:ge,disabled:!re||ae||de.busy||!de.hasContent(R),children:ae?`Sending…`:`Send`})]}),(0,B.jsx)($u,{a:de}),se&&(0,B.jsx)(`div`,{className:`text-[12px] text-brick`,children:se}),re&&(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)`]})]})]}),ee.length>0&&(0,B.jsx)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:ee.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)(Oa,{prefix:`DAVID_DECISION`}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[Tf(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:(0,B.jsx)(nd,{text:Of(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:!re,onClick:()=>{ue(e),ie(`david`),z(`DAVID_DECISION: `)},children:`Reply as David`}),!re&&(0,B.jsx)(ja,{})]})]},e.id))})]})}function jf({root:e,min:t=4,deps:n=[]}){let[r,i]=(0,P.useState)([]),[a,o]=(0,P.useState)(null);if((0,P.useEffect)(()=>{let n=e();if(!n){i([]);return}let r=Array.from(n.querySelectorAll(`h2[id], h3[id]`)).map(e=>({id:e.id,text:e.textContent??``,level:e.tagName===`H2`?2:3}));if(i(r),r.length<t)return;let a=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).map(e=>e.target.id);if(t.length)o(r.find(e=>t.includes(e.id))?.id??t[0]);else{let e=r.filter(e=>(n.querySelector(`#${CSS.escape(e.id)}`)?.getBoundingClientRect().top??1)<80);e.length&&o(e[e.length-1].id)}},{rootMargin:`-72px 0px -70% 0px`,threshold:[0,1]});for(let e of r){let t=n.querySelector(`#${CSS.escape(e.id)}`);t&&a.observe(t)}return()=>a.disconnect()},[e,t,...n]),r.length<t)return null;let s=t=>{let n=e()?.querySelector(`#${CSS.escape(t)}`);if(n){let e=n.getBoundingClientRect().top+window.scrollY-64;window.scrollTo({top:e}),o(t)}};return(0,B.jsxs)(`nav`,{"aria-label":`document outline`,className:`grid gap-0.5`,children:[(0,B.jsxs)(`div`,{className:`font-semibold text-[13px] uppercase tracking-[.08em] text-umber px-1 pt-1.5 pb-1`,children:[`Outline · `,r.length]}),(0,B.jsx)(`div`,{className:`max-h-[50vh] overflow-auto overscroll-contain grid gap-0 border-l border-sand ml-1`,children:r.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),className:`text-left border-0 bg-transparent cursor-pointer text-[12px] leading-[1.6] py-0.5 pr-1 -ml-px border-l-2 hover:text-ember-deep ${e.level===3?`pl-5`:`pl-2.5`} ${a===e.id?`border-ember text-walnut font-medium`:`border-transparent text-ink3`}`,title:e.text,"aria-current":a===e.id?`location`:void 0,children:(0,B.jsx)(`span`,{className:`block truncate`,children:e.text})},e.id))})]})}var Mf=[[/^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\/)/,Pf=/^(QUEUE|DONE|WORKSTREAMS|FACTS)\.md$/i,Ff=e=>Mf.find(([t])=>t.test(e)),If=({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}),Lf=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 Rf(){let{current:e}=Ha(),{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&&(Pf.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 La(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??``,ie=(0,P.useRef)(null),R=(0,P.useCallback)(()=>N===`source`?null:ie.current?.querySelector(`.md`)??null,[N]),z=l?.git,ae=(0,P.useMemo)(()=>{let e=[];return z?.lastCommit&&D&&e.push({kind:`commit`,label:`${z.lastCommit.short} · ${z.lastCommit.subject} · ${z.lastCommit.author} · ${Lf(z.lastCommit.date)}`,hunks:z.lastCommit.hunks}),z&&T&&z.uncommitted.length&&e.push({kind:`uncommitted`,label:`working tree vs HEAD`,hunks:z.uncommitted}),e},[z,D,T]),oe=new Set(r?.lastCommit?.files??[]),se=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)(If,{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=Mf.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?wa[n]({size:14}):wa.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,oe.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=Ff(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}),` · `,Lf(r.lastCommit.date),(0,B.jsx)(`div`,{className:`truncate text-tan`,title:r.lastCommit.subject,children:r.lastCommit.subject})]}),(0,B.jsx)(If,{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:wa[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`,{ref:ie,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:[z&&!z.repo&&(0,B.jsx)(G,{tone:`outline`,children:`not a git repo`}),z?.repo&&z.untracked&&(0,B.jsx)(G,{tone:`warn`,children:`untracked file`}),z?.repo&&z.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&&z.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 · `,z.uncommitted.length,` hunk`,z.uncommitted.length===1?``:`s`]}),z.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:`${z.lastCommit.subject} · ${z.lastCommit.author}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-leaf`}),`last commit `,z.lastCommit.short,` · `,Lf(z.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)(Tu,{source:L,changes:m?[]:ae})}),l&&N===`source`&&(m?(0,B.jsx)(zf,{value:g,onChange:_,readOnly:!p}):(0,B.jsx)(Bf,{src:l.source,g:z,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)(Tu,{source:L,changes:m?[]:ae})}),(0,B.jsx)(`div`,{className:`min-w-0 sticky top-2`,children:m?(0,B.jsx)(zf,{value:g,onChange:_,readOnly:!p}):(0,B.jsx)(Bf,{src:l.source,g:z,showUncommitted:T,showCommit:D,jumpLine:F})})]}),l&&ae.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:[N!==`source`&&(0,B.jsx)(`div`,{className:`mb-3`,children:(0,B.jsx)(jf,{root:R,deps:[L,N,a]})}),(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:()=>xd(se.aide??``),disabled:!se.aide,title:se.aide?`DM ${se.aide} about this doc`:`no live aide`,children:`Aide`}),(0,B.jsx)(K,{size:`sm`,onClick:()=>xd(se.coordinator??``),disabled:!se.coordinator,title:se.coordinator?`DM ${se.coordinator}`:`no live coordinator`,children:`Coordinator`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>xd(``),title:`pick from the radial`,children:`Other…`})]})]}),z?.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:z.lastCommit.short}),` · `,z.lastCommit.author]}),(0,B.jsx)(`div`,{children:new Date(z.lastCommit.date).toLocaleString()}),(0,B.jsx)(`div`,{className:`text-walnut mt-1 font-sans`,children:z.lastCommit.subject}),(0,B.jsxs)(`div`,{className:`mt-1 text-tan`,children:[z.lastCommit.hunks.length,` hunk`,z.lastCommit.hunks.length===1?``:`s`]})]})]})]})}function zf({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 Bf({src:e,g:t,showUncommitted:n,showCommit:r,jumpLine:i}){let a=(e,t)=>!!e?.some(e=>xu(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
|
+
`+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`})]})]})})}function of(){let{data:e}=q(`/bus/conditions`,2e4);if(!e)return null;let{halt:t,away:n,subscriptions:r}=e;return!t.active&&!n.active&&r.byLevel.error===0&&r.total<=r.visible?null:(0,B.jsxs)(`div`,{className:`grid gap-2`,children:[t.active&&(0,B.jsxs)(`div`,{className:`rounded-kit border border-brick-line bg-brick-wash/40 px-4 py-3 flex items-center gap-3 flex-wrap`,children:[(0,B.jsx)(G,{tone:`solid`,children:`BUS HALTED`}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[t.reason?(0,B.jsx)(`b`,{className:`text-walnut font-normal`,children:t.reason}):(0,B.jsx)(`i`,{children:`no reason recorded — a halt stops every lane and should name why`}),t.by&&(0,B.jsxs)(`span`,{className:`text-tan`,children:[` · set by `,t.by]})]}),(0,B.jsx)(`span`,{className:`ml-auto font-mono text-[12px] text-brick`,children:`every lane is blocked`})]}),(n.active||r.byLevel.error>0||r.total>r.visible)&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap font-mono text-[12px] text-umber`,children:[n.active&&(0,B.jsxs)(G,{tone:`outline`,children:[`coordinator away`,n.agentId?` · ${n.agentId}`:``]}),n.active&&n.note&&(0,B.jsx)(`span`,{className:`text-tan`,children:n.note}),r.byLevel.error>0&&(0,B.jsx)(`span`,{title:`The bus reports these as never scanned — genuinely broken, its verdict not ours.`,children:(0,B.jsxs)(G,{tone:`warn`,children:[r.byLevel.error,` subscription`,r.byLevel.error===1?``:`s`,` never scanned`]})}),r.total>r.visible&&(0,B.jsx)(`span`,{title:`list_subscriptions is agent-scoped: it returns only this console's own rows. The bus reports the total; their health belongs to the agents that own them and cannot be read from here.`,children:(0,B.jsxs)(G,{tone:`outline`,children:[r.total-r.visible,` of `,r.total,` not visible to this console`]})})]})]})}var sf=[[/⛔|\bblocked\s+by\b|\bblocker\b|^\s*blocked\b/i,`bad`],[/^\s*⏭|\bskipped\b/i,`neutral`],[/^\s*◻|\bno[-\s]?downstream\b/i,`neutral`],[/^\s*🚧|\bclaimed\b|\bin progress\b/i,`warn`],[/^\s*✅|\bdone\b|\bmerged\b|\bdeployed\b/i,`ok`],[/\bwatch\b|\bsoak\b/i,`ok`]],cf=e=>sf.find(([t])=>t.test(e))?.[1]??`neutral`,lf=(e,t)=>e??(t?`no Active Streams table`:`no WORKSTREAMS.md`),uf=(e,t=3)=>{if(e.length===0)return null;let n=e.slice(0,t).join(` · `);return`${e.length} parser issue${e.length>1?`s`:``}: ${n}${e.length>t?` …`:``}`},df=6,ff=`1.6fr 1.1fr 1.4fr 1fr 1fr 2fr`,pf=`1.4fr 1fr 1fr 1.6fr 1.6fr`;function mf({priority:e,raw:t}){return(0,B.jsx)(`span`,{className:`font-mono font-bold text-[12px] px-[7px] py-[3px] rounded text-center ${e===`P1`?`bg-ember-wash text-ember-deep`:e===`P2`?`bg-amber-wash text-amber`:e===`P3`?`bg-slate-wash text-slate`:`bg-brick-wash text-brick border border-brick-line`}`,title:e?void 0:`invalid priority ${JSON.stringify(t??``)} — kept verbatim; valid tags are P1, P2, P3`,children:e??t??`?`})}function hf({issues:e}){let t=uf(e);return t===null?null:(0,B.jsx)(`div`,{className:`px-3 py-2 border-t border-sand text-[12px] font-mono text-ink3`,children:t})}var gf=({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 _f({r:e,raw:t,cols:n}){return`malformed`in e?(0,B.jsx)(ka,{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)(ka,{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:(0,B.jsx)(Wu,{text: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:cf(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:(0,B.jsx)(Wu,{text:e.blocker})})}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,title:e.lastNote,children:(0,B.jsx)(Wu,{text:e.lastNote})})]})}):(0,B.jsx)(ka,{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:(0,B.jsx)(Wu,{text: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:cf(e.state),children:e.state})}),(0,B.jsx)(`span`,{className:`text-[13px] truncate`,children:(0,B.jsx)(Wu,{text:e.currentSlice})}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber truncate`,children:(0,B.jsx)(Wu,{text:e.nextGo})})]})})}function vf(){let{current:e}=Ha(),[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 Ia(`/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)(!1),S=[...r?.facts?.entries??[]].sort((e,t)=>Number(!!t.stale)-Number(!!e.stale)),C=b?S:S.slice(0,df),[w,T]=(0,P.useState)(null),[E,D]=(0,P.useState)(!1),O=async()=>{D(!0);try{await Ia(`/actions/project-doctor/${e}`),o.refresh()}finally{D(!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 k=r.workstreams.schema,A=k===`workstreams.v1`,j=A?ff:pf,M=e=>r.scopes[e]?{path:e,owner:r.scopes[e].owner,mode:r.scopes[e].mode??`shared`,note:r.scopes[e].note}:void 0,N=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:[w&&(0,B.jsx)(af,{project:e,req:w,seamOn:h,scope:w.kind===`add`?M(`docs/QUEUE.md`):M(`docs/FACTS.md`),onClose:()=>{T(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}),N&&(0,B.jsxs)(`span`,{className:`ml-3 text-[13px] text-umber`,children:[N.title,` · `,N.done,`/`,N.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:O,disabled:E,children:E?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(Na,{size:12}),` Doctor`]}):`Doctor`})]})]}),(0,B.jsx)(of,{}),(0,B.jsx)(Qd,{project:e,canWrite:m}),(0,B.jsx)(Kd,{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:lf(k,r.files.workstreams),path:`docs/WORKSTREAMS.md`,children:[(0,B.jsx)(rf,{scope:M(`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)(gf,{k:`s`})]})]}),k===`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.`})]}),k===`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&&(A?(0,B.jsxs)(Aa,{cols:j,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)(Aa,{cols:j,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)(_f,{r:e,raw:t,cols:j},n)),(0,B.jsx)(hf,{issues:r.workstreams.issues})]}),(0,B.jsxs)(U,{children:[(0,B.jsxs)(W,{title:`Queue`,icon:`queue`,eyebrow:`queue.v1`,path:`docs/QUEUE.md`,children:[(0,B.jsx)(rf,{scope:M(`docs/QUEUE.md`)}),(0,B.jsx)(K,{size:`sm`,tone:h?`primary`:`default`,onClick:()=>T({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)(ka,{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)(mf,{priority:e.priority,raw:e.priorityRaw}),(0,B.jsx)(`span`,{className:e.done?`line-through text-tan`:``,children:(0,B.jsx)(Wu,{text:e.text})})]})},e.id)),(0,B.jsx)(hf,{issues:r.queueIssues})]}),(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)(rf,{scope:M(`docs/DONE.md`)}),(0,B.jsx)(yf,{k:`done`,open:g.done,onToggle:v})]}),g.done&&r.done.slice(-8).reverse().map(e=>(0,B.jsx)(ka,{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:(0,B.jsx)(Wu,{text:e.text})}),(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-ink3`,children:e.date??``})]})},e.id)),(0,B.jsx)(hf,{issues:r.doneIssues})]})]}),(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)(rf,{scope:M(`docs/FACTS.md`)}),(0,B.jsx)(yf,{k:`facts`,open:g.facts,onToggle:v})]}),g.facts&&!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&&r.facts&&(0,B.jsx)(`div`,{className:`max-h-[26rem] overflow-y-auto overscroll-contain`,children:C.map(e=>(0,B.jsx)(ka,{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:(0,B.jsx)(Wu,{text:e.value})}),(0,B.jsxs)(`div`,{className:`font-mono text-[12px] text-ink3 truncate`,title:`${e.ageDays===null?`unverified`:`${e.ageDays} d`}${e.by?` · ${e.by}`:``}${e.method?` · ${e.method}`:``}`,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:()=>T({kind:`fact`,id:e.id,claim:e.value}),title:`upsert this fact through the seam with a fresh timestamp`,children:`Re-verify…`})]})},e.id))}),g.facts&&S.length>df&&(0,B.jsx)(`button`,{onClick:()=>x(e=>!e),className:`w-full text-left px-3 py-1.5 border-t border-sand font-mono text-[12px] text-tan hover:text-umber cursor-pointer`,children:b?`show fewer`:`+${S.length-df} more`}),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)(ka,{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)(Na,{size:11}):`Fix →`}),(0,B.jsx)(ld,{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)(ld,{id:d[e.check].replace(/^sent → /,``)})]}):d[e.check]})]})},e.check))]})]})]})}function yf({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 bf=e=>{let t=/^([\w.-]+\/[\w.-]+)#(\d+)$/.exec(e.trim());return t?`https://github.com/${t[1]}/pull/${t[2]}`:null},xf=e=>{let t=e.trim().replace(/^\.\//,``);return/^docs\/[\w./-]+\.md(#.*)?$/i.test(t)?t.split(`#`)[0]:null},Sf=`font-mono text-[11px] px-1.5 py-0.5 rounded border border-dust bg-linen/70 text-umber`;function Cf({cites:e}){return e?.length?(0,B.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 items-center`,children:e.map((e,t)=>{let n=`${e.kind}:${e.ref}:${t}`;if(e.kind===`url`)return(0,B.jsx)(`a`,{className:`${Sf} hover:border-ember hover:text-ember-deep`,href:e.ref,target:`_blank`,rel:`noreferrer`,children:e.ref.replace(/^https?:\/\//,``).slice(0,48)},n);if(e.kind===`pr`){let t=bf(e.ref);return t?(0,B.jsx)(`a`,{className:`${Sf} hover:border-ember hover:text-ember-deep`,href:t,target:`_blank`,rel:`noreferrer`,title:e.ref,children:e.ref},n):(0,B.jsx)(`span`,{className:Sf,title:`unqualified ref — every repository has this number, so it is shown rather than linked to a guess`,children:e.ref},n)}if(e.kind===`file`){let t=xf(e.ref);return t?(0,B.jsx)(V,{className:`${Sf} hover:border-ember hover:text-ember-deep`,to:`/docs/${encodeURIComponent(t)}`,title:e.ref,children:e.ref},n):(0,B.jsx)(`span`,{className:Sf,title:`not a docs path this console can open`,children:e.ref},n)}return(0,B.jsx)(`button`,{type:`button`,className:`${Sf} cursor-pointer hover:border-ember`,title:`copy ${e.ref}`,onClick:()=>void navigator.clipboard?.writeText(e.ref),children:e.ref.slice(0,12)},n)})}):null}var wf=({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}),Tf=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``,Ef=e=>e?new Date(e).toLocaleDateString([],{month:`short`,day:`numeric`}):``,Df=e=>!!e&&Ea.includes(e),Of=(e,t)=>t&&e.startsWith(t)?e.slice(t.length).replace(/^:?\s*/,``):e,kf=`/api`;function Af(){let{projects:e,current:t}=Ha(),[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),v=q(d===`room`&&f?`/bus/rooms/${f}/messages?limit=80`:null,1e4),y=gd(v.data),b=v.error,x=q(d===`status`?`/bus/status?limit=100`:null,15e3).data??[],S=q(d===`inbox`?`/bus/inbox?limit=200`:null,2e4),C={data:gd(S.data),refresh:S.refresh,error:S.error},[w,T]=(0,P.useState)(!1),E=async()=>{T(!0);try{await Ia(`/bus/inbox/read`),C.refresh()}finally{T(!1)}},[D,O]=(0,P.useState)([]),[k,A]=(0,P.useState)(!1);(0,P.useEffect)(()=>{O([])},[f]);let j=(0,P.useMemo)(()=>{let e=new Set;return[...D,...y?.messages??[]].filter(t=>{let n=t.id??`${t.ts}-${t.from}`;return!e.has(n)&&(e.add(n),!0)})},[D,y]),M=j.filter(e=>!e.system).slice().reverse(),N=async()=>{let e=j[0]?.ts;if(e){A(!0);try{let t=await(await fetch(`${kf}/bus/rooms/${f}/messages?limit=80&before=${e}`)).json();O(e=>[...t.messages,...e])}finally{A(!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,M.length]);let ee=M.filter(e=>e.prefix===`DAVID_DECISION`&&!e.answered),F=(_?.members??[]).map(e=>l.find(t=>t.agentId===e)??{agentId:e,reachability:`dead`,pane:null,role:void 0,active:!1}),I=e=>Date.now()-e.lastTs<3e5,te=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})},ne=!!y&&j.length<y.total,re=!!q(`/admin/bus-writes`,1e4).data?.enabled,[L,ie]=(0,P.useState)(`david`),[R,z]=(0,P.useState)(``),[ae,oe]=(0,P.useState)(!1),[se,ce]=(0,P.useState)(null),[le,ue]=(0,P.useState)(null),de=Qu(),[fe,pe]=(0,P.useState)(null),me=q(`/bus/unread`,3e4).data?.inbox??0,he=`#${f}`,ge=async()=>{oe(!0),ce(null);try{let e=he.startsWith(`#`)?{room:he.slice(1)}:{to:he.replace(/^@/,``)},t=await Ia(`/actions/send`,{as:L,...e,text:de.withRefs(R),answers:le?.id?[le.id]:void 0,kind:/^DAVID_DECISION/.test(R)?`decision`:void 0});if(t.status!==`ok`)throw Error(t.error??t.log?.slice(-1)[0]??`failed`);z(``),ue(null),de.clear()}catch(e){ce(e.message)}finally{oe(!1)}};return(0,B.jsxs)(`div`,{className:`grid ${ee.length>0?`grid-cols-[240px_1fr_320px]`:`grid-cols-[240px_1fr]`} gap-4 p-4 max-[980px]:grid-cols-1`,children:[fe&&(0,B.jsx)(id,{agentId:fe,onClose:()=>pe(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)(wf,{children:`Rooms · list_rooms`}),h.map(e=>(0,B.jsxs)(`button`,{onClick:()=>te({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:[I(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)(wf,{children:`Direct · inbox`}),(0,B.jsxs)(`button`,{onClick:()=>te({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`}),me>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:[me,` unread`]})]}),(0,B.jsx)(wf,{children:`Status stream`}),(0,B.jsx)(`button`,{onClick:()=>te({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:[C.data&&(C.data.unread>0?(0,B.jsxs)(G,{tone:`david`,children:[C.data.unread,` unread`]}):(0,B.jsx)(G,{tone:`outline`,children:`all read`})),C.data&&C.data.unread>0&&(0,B.jsx)(K,{size:`sm`,onClick:E,disabled:w,children:w?`…`:`Mark all read`})]}),C.error&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-brick`,children:C.error}),C.data&&C.data.messages.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`No DMs to david.`}),(C.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:[Ef(e.ts),` `,Tf(e.ts)]}),re&&e.from&&(0,B.jsx)(`button`,{className:`ml-auto font-mono text-[12px] text-ember-deep bg-transparent border-0 cursor-pointer`,onClick:()=>xd(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:[Df(r)&&(0,B.jsx)(Oa,{prefix:r,fail:r===`VERDICT`&&/FAIL/.test(n)}),(0,B.jsx)(nd,{text:Of(n,r)}),(0,B.jsx)(Cf,{cites:e.record?.cites})]})]})]},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`}),x.length===0&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`empty`}),x.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:[Ef(e.ts),` `,Tf(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:y?`${y.total} messages`:``,children:(0,B.jsxs)(G,{tone:`outline`,children:[_?.members?.length??0,` members`]})}),me>0&&(0,B.jsxs)(`button`,{onClick:()=>te({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:[me,` unread DM`,me===1?``:`s`,` to david`]}),(0,B.jsx)(`span`,{className:`text-umber`,children:`— open your inbox →`})]}),F.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`}),F.map(e=>(0,B.jsxs)(`button`,{onClick:()=>xd(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)(Lu,{id:e.agentId,role:e.role,size:14,state:e.reachability,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:`}),Ea.map(e=>(0,B.jsx)(Oa,{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:[ne&&(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:N,disabled:k,children:k?`loading…`:`Load older (${y.total-j.length} more)`})}),b&&(0,B.jsxs)(`div`,{className:`px-3 py-3 text-[13px] text-brick`,children:[`API error: `,b]}),M.length===0&&!b&&(0,B.jsx)(`div`,{className:`px-3 py-3 text-[13px] text-umber`,children:`No messages yet.`}),M.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)(Lu,{id:e.from??`?`,role:l.find(t=>t.agentId===e.from)?.role,size:14,state:l.find(t=>t.agentId===e.from)?.reachability??`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:[Ef(e.ts),` `,Tf(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:[Df(e.prefix)&&(0,B.jsx)(Oa,{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:()=>te({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)(nd,{text:Of(i,e.prefix)}),(0,B.jsx)(Cf,{cites:e.record?.cites})]})]})]},e.id??t)})]})}),(0,B.jsxs)(`div`,{className:`border-t border-sand px-3 py-2.5 grid gap-1.5`,children:[le&&(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 `,le.from,` · `,Tf(le.ts)]}),(0,B.jsx)(`button`,{className:`border-0 bg-transparent text-ink3 cursor-pointer`,onClick:()=>{ue(null),z(``)},children:`✕`})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-[auto_auto_1fr_auto] gap-2 items-center`,children:[(0,B.jsxs)(`select`,{value:L,onChange:e=>ie(e.target.value),disabled:!re,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:R,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&re&&de.hasContent(R)&&ge()},onPaste:de.onPaste,onDrop:de.onDrop,onDragOver:de.onDragOver,disabled:!re,className:`text-[13px] px-2.5 py-2 border border-dust rounded-kit bg-paper text-walnut`,placeholder:re?he.startsWith(`#`)?`FYI: … (rooms need a prefix)`:`message…`:`bus writes are off — enable in the header`}),(0,B.jsx)(K,{tone:`primary`,size:`sm`,onClick:ge,disabled:!re||ae||de.busy||!de.hasContent(R),children:ae?`Sending…`:`Send`})]}),(0,B.jsx)($u,{a:de}),se&&(0,B.jsx)(`div`,{className:`text-[12px] text-brick`,children:se}),re&&(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)`]})]})]}),ee.length>0&&(0,B.jsx)(`aside`,{className:`grid gap-3.5 content-start min-w-0`,children:ee.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)(Oa,{prefix:`DAVID_DECISION`}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[Tf(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:(0,B.jsx)(nd,{text:Of(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:!re,onClick:()=>{ue(e),ie(`david`),z(`DAVID_DECISION: `)},children:`Reply as David`}),!re&&(0,B.jsx)(ja,{})]})]},e.id))})]})}function jf({root:e,min:t=4,deps:n=[]}){let[r,i]=(0,P.useState)([]),[a,o]=(0,P.useState)(null);if((0,P.useEffect)(()=>{let n=e();if(!n){i([]);return}let r=Array.from(n.querySelectorAll(`h2[id], h3[id]`)).map(e=>({id:e.id,text:e.textContent??``,level:e.tagName===`H2`?2:3}));if(i(r),r.length<t)return;let a=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).map(e=>e.target.id);if(t.length)o(r.find(e=>t.includes(e.id))?.id??t[0]);else{let e=r.filter(e=>(n.querySelector(`#${CSS.escape(e.id)}`)?.getBoundingClientRect().top??1)<80);e.length&&o(e[e.length-1].id)}},{rootMargin:`-72px 0px -70% 0px`,threshold:[0,1]});for(let e of r){let t=n.querySelector(`#${CSS.escape(e.id)}`);t&&a.observe(t)}return()=>a.disconnect()},[e,t,...n]),r.length<t)return null;let s=t=>{let n=e()?.querySelector(`#${CSS.escape(t)}`);if(n){let e=n.getBoundingClientRect().top+window.scrollY-64;window.scrollTo({top:e}),o(t)}};return(0,B.jsxs)(`nav`,{"aria-label":`document outline`,className:`grid gap-0.5`,children:[(0,B.jsxs)(`div`,{className:`font-semibold text-[13px] uppercase tracking-[.08em] text-umber px-1 pt-1.5 pb-1`,children:[`Outline · `,r.length]}),(0,B.jsx)(`div`,{className:`max-h-[50vh] overflow-auto overscroll-contain grid gap-0 border-l border-sand ml-1`,children:r.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),className:`text-left border-0 bg-transparent cursor-pointer text-[12px] leading-[1.6] py-0.5 pr-1 -ml-px border-l-2 hover:text-ember-deep ${e.level===3?`pl-5`:`pl-2.5`} ${a===e.id?`border-ember text-walnut font-medium`:`border-transparent text-ink3`}`,title:e.text,"aria-current":a===e.id?`location`:void 0,children:(0,B.jsx)(`span`,{className:`block truncate`,children:e.text})},e.id))})]})}var Mf=[[/^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\/)/,Pf=/^(QUEUE|DONE|WORKSTREAMS|FACTS)\.md$/i,Ff=e=>Mf.find(([t])=>t.test(e)),If=({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}),Lf=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 Rf(){let{current:e}=Ha(),{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&&(Pf.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 La(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??``,ie=(0,P.useRef)(null),R=(0,P.useCallback)(()=>N===`source`?null:ie.current?.querySelector(`.md`)??null,[N]),z=l?.git,ae=(0,P.useMemo)(()=>{let e=[];return z?.lastCommit&&D&&e.push({kind:`commit`,label:`${z.lastCommit.short} · ${z.lastCommit.subject} · ${z.lastCommit.author} · ${Lf(z.lastCommit.date)}`,hunks:z.lastCommit.hunks}),z&&T&&z.uncommitted.length&&e.push({kind:`uncommitted`,label:`working tree vs HEAD`,hunks:z.uncommitted}),e},[z,D,T]),oe=new Set(r?.lastCommit?.files??[]),se=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)(If,{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=Mf.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?wa[n]({size:14}):wa.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,oe.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=Ff(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}),` · `,Lf(r.lastCommit.date),(0,B.jsx)(`div`,{className:`truncate text-tan`,title:r.lastCommit.subject,children:r.lastCommit.subject})]}),(0,B.jsx)(If,{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:wa[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`,{ref:ie,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:[z&&!z.repo&&(0,B.jsx)(G,{tone:`outline`,children:`not a git repo`}),z?.repo&&z.untracked&&(0,B.jsx)(G,{tone:`warn`,children:`untracked file`}),z?.repo&&z.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&&z.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 · `,z.uncommitted.length,` hunk`,z.uncommitted.length===1?``:`s`]}),z.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:`${z.lastCommit.subject} · ${z.lastCommit.author}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-leaf`}),`last commit `,z.lastCommit.short,` · `,Lf(z.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)(Tu,{source:L,changes:m?[]:ae})}),l&&N===`source`&&(m?(0,B.jsx)(zf,{value:g,onChange:_,readOnly:!p}):(0,B.jsx)(Bf,{src:l.source,g:z,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)(Tu,{source:L,changes:m?[]:ae})}),(0,B.jsx)(`div`,{className:`min-w-0 sticky top-2`,children:m?(0,B.jsx)(zf,{value:g,onChange:_,readOnly:!p}):(0,B.jsx)(Bf,{src:l.source,g:z,showUncommitted:T,showCommit:D,jumpLine:F})})]}),l&&ae.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:[N!==`source`&&(0,B.jsx)(`div`,{className:`mb-3`,children:(0,B.jsx)(jf,{root:R,deps:[L,N,a]})}),(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:()=>xd(se.aide??``),disabled:!se.aide,title:se.aide?`DM ${se.aide} about this doc`:`no live aide`,children:`Aide`}),(0,B.jsx)(K,{size:`sm`,onClick:()=>xd(se.coordinator??``),disabled:!se.coordinator,title:se.coordinator?`DM ${se.coordinator}`:`no live coordinator`,children:`Coordinator`}),(0,B.jsx)(K,{size:`sm`,tone:`ghost`,onClick:()=>xd(``),title:`pick from the radial`,children:`Other…`})]})]}),z?.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:z.lastCommit.short}),` · `,z.lastCommit.author]}),(0,B.jsx)(`div`,{children:new Date(z.lastCommit.date).toLocaleString()}),(0,B.jsx)(`div`,{className:`text-walnut mt-1 font-sans`,children:z.lastCommit.subject}),(0,B.jsxs)(`div`,{className:`mt-1 text-tan`,children:[z.lastCommit.hunks.length,` hunk`,z.lastCommit.hunks.length===1?``:`s`]})]})]})]})}function zf({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 Bf({src:e,g:t,showUncommitted:n,showCommit:r,jumpLine:i}){let a=(e,t)=>!!e?.some(e=>xu(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(`
|
|
36
36
|
`).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 Vf=e=>/done|merged|deployed|complete|closed|✅/i.test(e),Hf=e=>Vf(e)?`ok`:/block/i.test(e)?`bad`:/queued|hold|wait/i.test(e)?`warn`:`neutral`;function Uf({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=>!Vf(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)(ld,{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)(Lu,{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:Hf(e.status),children:e.status.replace(/^[^\w]+/,``).slice(0,18)})]},e.name)})})]})}var Wf=`/api`,Gf=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 Kf(){let{current:e}=Ha(),{linkify:t}=ju(),[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(`${Wf}/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]);let[j,M]=(0,P.useState)({}),N=e=>j[e]!==!1;(0,P.useEffect)(()=>{for(let[e,t]of Object.entries(E.current))if(t&&N(e)){let e=t.scrollHeight-t.clientHeight;Math.abs(t.scrollTop-e)>1&&(t.scrollTop=e)}},[S]);let ee=e=>t=>{let n=t.currentTarget,r=n.scrollHeight-n.scrollTop-n.clientHeight<24;r!==N(e)&&M(t=>({...t,[e]:r}))},F=e=>{M(t=>({...t,[e]:!0}));let t=E.current[e];if(t){let e=t.scrollHeight-t.clientHeight;Math.abs(t.scrollTop-e)>1&&(t.scrollTop=e)}},I=f.filter(e=>e.active).length;return(0,B.jsxs)(`div`,{className:`p-4 grid gap-3.5 content-start [overflow-anchor:none]`,children:[g&&(0,B.jsx)(id,{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`,` · `,I,` 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)(Uf,{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:dd(e.role)}}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-3 border-b border-sand min-w-0 h-[46px]`,children:[(0,B.jsx)(Lu,{id:e.agentId,role:e.role,size:20,state:e.reachability,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:dd(e.role)},children:[fd(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}),e.windowName&&(0,B.jsxs)(`span`,{className:`font-mono text-[10px] text-tan truncate shrink-0`,title:`tmux window ${e.windowName}`,children:[`⧉ `,e.windowName]}),(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 `,Gf(e.paneActivity)]})}),!N(e.agentId)&&(0,B.jsx)(`button`,{className:`font-mono text-[11px] px-1.5 py-0.5 rounded-full bg-amber-wash text-amber border border-amber-line cursor-pointer`,onClick:()=>F(e.agentId),title:`follow paused while you read — click to jump to the bottom and follow again`,children:`↓ follow`}),(0,B.jsx)(`button`,{className:`font-mono text-[11px] text-ember-deep bg-transparent border-0 cursor-pointer`,onClick:()=>xd(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},onScroll:ee(e.agentId),className:`m-0 px-3 py-2 overflow-auto overscroll-contain 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?mo(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 = pane content changed in the last 60 s (status-bar/timer redraws don't count) · `,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 qf=[{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 Jf(){let{running:e}=Ga(),t=rr(),n=qf.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`}),qf.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:wa[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)(Hd,{})})}var Xf=e=>{let t=Math.floor(e/6e4);return t<1?`just now`:t<60?`${t} min ago`:t<1440?`${Math.floor(t/60)} h ago`:`${Math.floor(t/1440)} d ago`},Zf=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),Qf=36e5;function $f(){let{data:e}=q(`/bus/conditions`,2e4),t=e?.stallClock;if(!t?.inUse)return null;let n=t.ageMs===null||t.ageMs>Qf;return(0,B.jsxs)(U,{children:[(0,B.jsx)(W,{title:`Stall clock`,icon:`fleet`,eyebrow:`agent-coord · stall_check`,path:t.last?`${t.runs.length} run${t.runs.length===1?``:`s`} recorded`:void 0}),(0,B.jsxs)(`div`,{className:`px-3 py-2.5 grid gap-2`,children:[t.last?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsx)(G,{tone:n?`outline`:t.last.hits>0?`warn`:`ok`,children:Xf(t.ageMs)}),(0,B.jsxs)(`span`,{className:`text-[13px] text-umber`,children:[`last run found `,(0,B.jsx)(`b`,{className:`text-walnut`,children:t.last.hits}),` of `,(0,B.jsx)(`b`,{className:`text-walnut`,children:t.last.checked}),` checked`]}),n&&(0,B.jsx)(`span`,{className:`font-mono text-[12px] text-tan`,children:`— too old to describe the fleet now`})]}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.runs.map(e=>(0,B.jsxs)(`span`,{className:`font-mono text-[11px] px-1.5 py-0.5 rounded border ${e.hits>0?`border-amber-line bg-amber-wash/60 text-amber`:`border-dust bg-linen/70 text-umber`}`,title:`${Zf(e.at)} · ${e.hits} of ${e.checked} checked`,children:[e.hits,`/`,e.checked]},e.at))})]}):(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsx)(G,{tone:`bad`,children:`never run`}),(0,B.jsx)(`span`,{className:`text-[13px] text-umber`,children:`The clock is installed and has never evaluated. That is not the same as finding nothing — no verdict exists to read.`})]}),(0,B.jsxs)(`div`,{className:`text-[12px] text-tan border-t border-sand pt-2`,children:[`Measures `,(0,B.jsx)(`b`,{className:`text-umber font-normal`,children:`repository activity`}),` and is written by the bus, not by this console. The `,(0,B.jsx)(`b`,{className:`text-umber font-normal`,children:`progress`}),` column on agents measures what an agent has emitted on the bus — a different question, so the two can disagree without either being wrong.`]})]})]})}function ep({title:e,danger:t,body:n,confirmWord:r,action:i,payload:a,preview:o,onClose:s,onDone:c}){let[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(!1),[p,m]=(0,P.useState)(null),[h,g]=(0,P.useState)(null),_=async()=>{f(!0);try{let e=await Ia(i,{...a,confirm:l});m(e),e.status===`ok`&&c?.(e)}finally{f(!1)}},v=async()=>{if(o){f(!0);try{g(await o())}finally{f(!1)}}},y=(e,t)=>(0,B.jsxs)(`div`,{className:`p-2 rounded-kit border min-w-0 max-w-full ${t===`preview`?`border-dust bg-sand/40`: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:[t===`preview`?(0,B.jsx)(G,{tone:`warn`,children:`preview · nothing written`}):(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 min-w-0 max-w-full break-words overscroll-contain`,children:[e.log.join(`
|
|
37
37
|
`),e.result===void 0?``:`
|
|
38
38
|
`+JSON.stringify(e.result,null,1).slice(0,2e3),e.error?`
|