@spexcode/spec-dashboard 0.6.8 → 0.7.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/assets/{App-DANZYsFg.js → App-BBoP1IyU.js} +2 -2
  2. package/{dist-public/assets/EmptyView-CX3NC0Nq.js → dist/assets/EmptyView-DvUslJmJ.js} +1 -1
  3. package/dist/assets/EvalsPage-DBVkF_F0.js +2 -0
  4. package/dist/assets/FileView-BqSwsBx0.js +2 -0
  5. package/dist/assets/GraphView-DmtM56Gf.js +26 -0
  6. package/dist/assets/IssuesPage-BZ36PpJ-.js +1 -0
  7. package/dist/assets/MobileApp-DuXKCmKv.js +2 -0
  8. package/dist/assets/Modal-oF4JAL6H.js +1 -0
  9. package/dist/assets/{NodeView-D6JZc3ap.js → NodeView-CZYwYCCu.js} +1 -1
  10. package/dist/assets/ProjectsPage-DUpxEHcM.js +1 -0
  11. package/dist/assets/ProseActions-CSG_3k1b.js +8 -0
  12. package/dist/assets/Settings-qIX2_HmP.js +1 -0
  13. package/dist/assets/SpecView-CM3BOtTy.js +1 -0
  14. package/dist/assets/Thread-4tohzgUo.js +9 -0
  15. package/dist/assets/WorkspaceSurface-BysfRmg3.js +2 -0
  16. package/dist/assets/index-B948v2sT.css +1 -0
  17. package/dist/assets/index-Co8kmYQY.js +40 -0
  18. package/dist/assets/index-cI0gAOhx.js +13 -0
  19. package/dist/assets/{tabs-BxFTq-sB.js → tabs-C4phsoFs.js} +58 -57
  20. package/dist/index.html +2 -2
  21. package/dist-public/assets/{App-Bz1E7Es7.js → App-DI39ygL3.js} +2 -2
  22. package/{dist/assets/EmptyView-xnSRh3XP.js → dist-public/assets/EmptyView-BdrTMUAy.js} +1 -1
  23. package/dist-public/assets/EvalsPage-DIfyOQXb.js +2 -0
  24. package/dist-public/assets/FileView-BmDYhU9C.js +2 -0
  25. package/dist-public/assets/GraphView-nuH0yFnk.js +26 -0
  26. package/dist-public/assets/IssuesPage-0kQamj5x.js +1 -0
  27. package/dist-public/assets/MobileApp-DxiBJpdL.js +2 -0
  28. package/dist-public/assets/Modal-DvHG_lvi.js +1 -0
  29. package/dist-public/assets/{NodeView-cN_xZ1kR.js → NodeView-BQwIXw15.js} +1 -1
  30. package/dist-public/assets/ProjectsPage-Ctzz8z3E.js +1 -0
  31. package/dist-public/assets/ProseActions-3FcAR01Y.js +8 -0
  32. package/dist-public/assets/Settings-GX7a1idU.js +1 -0
  33. package/dist-public/assets/SpecView-OcNkvuaj.js +1 -0
  34. package/dist-public/assets/Thread-UIOe-Brh.js +9 -0
  35. package/dist-public/assets/WorkspaceSurface-r01RoZft.js +2 -0
  36. package/dist-public/assets/index-B948v2sT.css +1 -0
  37. package/dist-public/assets/index-DkZ_7FOT.js +40 -0
  38. package/dist-public/assets/index-Ix7HFN0I.js +13 -0
  39. package/dist-public/assets/{tabs-BL3Okd06.js → tabs-Dv9P0FBJ.js} +58 -57
  40. package/dist-public/index.html +2 -2
  41. package/package.json +5 -3
  42. package/dist/assets/EvalsPage-DDxIUAuR.js +0 -2
  43. package/dist/assets/FileView-DZaiEPRK.js +0 -2
  44. package/dist/assets/GraphView-DHEhg_eI.js +0 -26
  45. package/dist/assets/IssuesPage-B5qjvpP1.js +0 -1
  46. package/dist/assets/MobileApp-fvc4gfCx.js +0 -2
  47. package/dist/assets/PageScroll-DE6nL5p-.js +0 -1
  48. package/dist/assets/ProjectsPage-I7XFn8kG.js +0 -1
  49. package/dist/assets/ProseActions-LG4ve4AO.js +0 -7
  50. package/dist/assets/Settings-D7NeDdd1.js +0 -1
  51. package/dist/assets/SpecView-mkyrBxLO.js +0 -1
  52. package/dist/assets/Thread-Cx5fJkFO.js +0 -9
  53. package/dist/assets/WorkspaceSurface-DgbzdTEl.js +0 -2
  54. package/dist/assets/index-B-qrQ2QS.js +0 -40
  55. package/dist/assets/index-RoVUefLX.js +0 -13
  56. package/dist/assets/index-nweIph9V.css +0 -1
  57. package/dist-public/assets/EvalsPage-BBzomD1v.js +0 -2
  58. package/dist-public/assets/FileView-Cf5bY14h.js +0 -2
  59. package/dist-public/assets/GraphView-5dgjv4t6.js +0 -26
  60. package/dist-public/assets/IssuesPage-B_knZkH6.js +0 -1
  61. package/dist-public/assets/MobileApp-BpnF0xSz.js +0 -2
  62. package/dist-public/assets/PageScroll-CEYT-x2I.js +0 -1
  63. package/dist-public/assets/ProjectsPage-CWaOO-Y7.js +0 -1
  64. package/dist-public/assets/ProseActions-rr5Mm1WB.js +0 -7
  65. package/dist-public/assets/Settings-louVIHfW.js +0 -1
  66. package/dist-public/assets/SpecView-qZMzQH75.js +0 -1
  67. package/dist-public/assets/Thread-Ca_r1oDT.js +0 -9
  68. package/dist-public/assets/WorkspaceSurface-bsUptX-4.js +0 -2
  69. package/dist-public/assets/index-3mcnUCQ1.js +0 -40
  70. package/dist-public/assets/index-BmOx7kVX.js +0 -13
  71. package/dist-public/assets/index-nweIph9V.css +0 -1
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EvalsPage-DBVkF_F0.js","assets/index-Co8kmYQY.js","assets/index-B948v2sT.css","assets/Thread-4tohzgUo.js","assets/tabs-C4phsoFs.js","assets/App-BBoP1IyU.js","assets/Modal-oF4JAL6H.js","assets/tabs-Brk4lg7l.css","assets/IssuesPage-BZ36PpJ-.js","assets/NodeView-CZYwYCCu.js","assets/ProseActions-CSG_3k1b.js","assets/Settings-qIX2_HmP.js"])))=>i.map(i=>d[i]);
2
+ import{u as P,r as o,j as s,_ as O,I as H}from"./index-Co8kmYQY.js";import{a9 as D,J as M,aa as $,x as K,ab as B,ac as U,ad as J,ae as Q,S as L,af as W,a2 as Z,ag as q,ah as G,I as X,K as Y,P as ss,ai as es,aj as as,ak as ns}from"./tabs-C4phsoFs.js";import{p as ts,u as ls,S as is,H as cs,I as os,E as rs,a as ms}from"./NodeView-CZYwYCCu.js";import{n as I}from"./App-BBoP1IyU.js";import"./Modal-oF4JAL6H.js";import"./Thread-4tohzgUo.js";import"./ProseActions-CSG_3k1b.js";const ds=o.lazy(()=>O(()=>import("./EvalsPage-DBVkF_F0.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]))),us=o.lazy(()=>O(()=>import("./IssuesPage-BZ36PpJ-.js"),__vite__mapDeps([8,1,2,4,5,6,7,9,3,10]))),hs=o.lazy(()=>O(()=>import("./Settings-qIX2_HmP.js"),__vite__mapDeps([11,1,2,5,4,6,7]))),bs={spec:"nodeView.paneSpec",history:"nodeView.paneHistory",issues:"nodeView.paneIssues",eval:"nodeView.paneEval",edit:"nodeView.paneEdit"},z=(e,l)=>l.filter(r=>{var m;return(m=r.ops)==null?void 0:m.some(c=>c.nodeId===e.id)});function R({status:e}){const l=L[e]||L.pending;return s.jsx("span",{className:"m-dot",style:{background:l.color}})}function ps({node:e,kids:l,editors:r,onTap:m}){return s.jsxs("button",{className:"m-row",onClick:m,children:[s.jsx(R,{status:e.status}),s.jsx("span",{className:"m-row-title",children:e.title}),r.length>0&&s.jsx("span",{className:"m-row-faces",children:r.slice(0,3).map(c=>s.jsx(D,{seed:c.id,status:c.status,title:M(c)},c.id))}),e.version?s.jsxs("span",{className:"m-row-ver",children:["v",e.version]}):null,l>0&&s.jsxs("span",{className:"m-row-kids",children:["▸",l]}),s.jsx("span",{className:"m-row-chev",children:"›"})]})}function xs({node:e,childrenOf:l,sessions:r,onOpenChild:m}){const c=P(),u=l(e.id),b=ts(e),h=[...u.length?[{key:"children",label:c("mobile.childrenTab",{n:u.length})}]:[],...b.map(a=>({key:a.key,label:c(bs[a.key])}))],[j,N]=o.useState(null),[p,k]=o.useState({issues:{},eval:{}});o.useEffect(()=>{N(null),k({issues:{},eval:{}})},[e.id]);const x=(a,S)=>k(y=>({...y,[a]:W(y[a],S)})),n=j&&h.some(a=>a.key===j)?j:h[0].key,v=ls(e.id,n==="history"),i=z(e,r);return s.jsxs("div",{className:"m-node",children:[s.jsxs("div",{className:"m-node-head",children:[s.jsx(R,{status:e.status}),s.jsx("span",{className:"m-node-title",children:e.title}),e.version?s.jsxs("span",{className:"m-node-ver",children:["v",e.version]}):null,s.jsx("span",{className:"m-node-status",children:c(`status.${e.status}`)}),i.length>0&&s.jsx("span",{className:"m-node-faces",title:c("mobile.liveEditors",{n:i.length}),children:i.map(a=>s.jsx(D,{seed:a.id,status:a.status,title:M(a)},a.id))})]}),e.desc&&s.jsx("div",{className:"m-node-desc",children:e.desc}),s.jsx("div",{className:"m-tabs",children:h.map(a=>s.jsx("button",{className:a.key===n?"m-tab on":"m-tab",onClick:()=>N(a.key),children:a.label},a.key))}),s.jsxs("div",{className:n==="history"?"m-pane-host fixed":"m-pane-host",children:[n==="children"&&s.jsx("div",{className:"m-children",children:u.map(a=>s.jsx(ps,{node:a,kids:l(a.id).length,editors:z(a,r),onTap:()=>m(a.id)},a.id))}),n==="spec"&&s.jsx(is,{node:e}),n==="history"&&s.jsx(cs,{node:e,rows:v}),n==="issues"&&s.jsx(os,{node:e,sessions:r,filter:p.issues,onFilter:a=>x("issues",a)}),n==="eval"&&s.jsx(rs,{node:e,sessions:r,filter:p.eval,onFilter:a=>x("eval",a)}),n==="edit"&&s.jsx(ms,{node:e})]})]})}function js({s:e,sessions:l,onBack:r}){const m=P();return s.jsxs("div",{className:"m-sessdetail chat",children:[s.jsxs("div",{className:"m-sess-card",children:[s.jsx("button",{className:"m-sess-back",onClick:r,"aria-label":m("mobile.back"),children:"‹"}),s.jsxs("div",{className:"m-sess-meta",children:[s.jsx("span",{className:"m-sess-name",children:X(e)}),s.jsxs("span",{className:"m-sess-status",style:{color:Y[e.status]},children:[m(`status.${e.status}`),e.merges?` · ×${e.merges}`:""," · ",s.jsx("span",{className:"m-sess-id8",children:e.id.slice(0,8)})]})]}),s.jsx("a",{className:"m-sess-evalbtn",href:ss(es(e.id)),title:m("sessionEval.btnTitle"),children:m("sessionEval.btn")})]}),s.jsx(as,{s:e,sessions:l})]})}function fs({draft:e,setDraft:l,onBack:r,onLaunched:m}){const c=P(),{launchers:u,launcher:b,pickLauncher:h}=Z(),[j,N]=o.useState(!1),[p,k]=o.useState(null),x=async()=>{const n=e.trim();if(!n||j)return;N(!0),k(null);const v=await ns(n,b);N(!1),v.ok?(l(""),m()):k(v.error||c("mobile.launchFailed"))};return s.jsxs("div",{className:"m-sessdetail m-new",children:[s.jsxs("div",{className:"m-sess-card",children:[s.jsx("button",{className:"m-sess-back",onClick:r,"aria-label":c("mobile.back"),children:"‹"}),s.jsx("div",{className:"m-sess-meta",children:s.jsx("span",{className:"m-sess-name",children:c("mobile.newSession")})})]}),s.jsxs("div",{className:"m-new-body",children:[s.jsx(q,{className:"m-input m-new-input",rows:5,placeholder:c("mobile.newPlaceholder"),value:e,onKeyDown:n=>{n.key!=="Enter"||n.shiftKey||G(n)||(n.preventDefault(),n.stopPropagation(),x())},onChange:n=>l(n.target.value)}),u.length>0&&s.jsxs("label",{className:"m-new-launcher",children:[s.jsx("span",{className:"m-new-launcher-label",children:c("session.launcherLabel")}),s.jsx("select",{className:"m-new-launcher-select",value:b,onChange:n=>h(n.target.value),children:u.map(n=>s.jsx("option",{value:n.name,children:n.name},n.name))})]}),p&&s.jsx("div",{className:"m-senderr",children:p}),s.jsx("button",{className:"m-send m-new-go",disabled:!e.trim()||j,onClick:x,children:c(j?"mobile.launching":"mobile.launch")})]})]})}function Ns({specs:e,sessions:l,openId:r,setOpenId:m,creating:c,setCreating:u,newDraft:b,setNewDraft:h}){const j=P(),N=r?l.find(i=>i.id===r):null,{expanded:p,toggle:k}=$(),[x,n]=o.useState(!1),v=o.useMemo(()=>K(l,i=>p.has(i),{zoneFolded:i=>i==="offline"&&!x}),[l,p,x]);return c?s.jsx(fs,{draft:b,setDraft:h,onBack:()=>u(!1),onLaunched:()=>u(!1)}):N?s.jsx(js,{s:N,sessions:l,onBack:()=>m(null)}):s.jsxs("div",{className:"m-sesslist",children:[s.jsxs("button",{className:"m-new-btn",onClick:()=>u(!0),children:[s.jsx(H,{name:"plus",size:16,strokeWidth:1.9,"aria-hidden":"true"}),s.jsx("span",{children:j("mobile.newSession")})]}),!l.length&&s.jsx("div",{className:"m-empty big",children:j("mobile.noSessions")}),v.map(i=>{if(i.type==="zone")return s.jsx(B,{item:i,baseClass:"m-zone",onToggle:()=>n(y=>!y)},`z-${i.zone}`);const a=i.s,S=i.expandable||i.depth?s.jsx(U,{guides:i.guides,expandable:i.expandable,kin:i.kin}):null;return s.jsxs("div",{className:"sess-tree-row m-sess-tree-row",style:{"--sess-fold-indent":`${i.depth*14}px`},children:[s.jsx("button",{type:"button",className:"m-sess-row",onClick:()=>m(a.id),children:s.jsx(J,{s:a,locked:!1,showAvatar:!1,lead:S})}),i.expandable&&s.jsx(Q,{expanded:i.expanded,rollup:i.rollup,kin:i.kin,onToggle:()=>k(a.id)})]},a.id)})]})}function Ps({specs:e,sessions:l,issuesStamp:r,reloadBoard:m,route:c={}}){const u=P(),b=o.useMemo(()=>Object.fromEntries(e.map(t=>[t.id,t])),[e]),h=o.useMemo(()=>e.find(t=>!t.parent)||e[0],[e]),j=o.useMemo(()=>{const t={};return e.forEach(d=>{var _;d.parent&&(t[_=d.parent]??(t[_]=[])).push(d)}),d=>t[d]||[]},[e]),[N,p]=o.useState("specs"),[k,x]=o.useState(()=>h?[h.id]:[]),[n,v]=o.useState(null),[i,a]=o.useState(!1),[S,y]=o.useState(""),{page:f="graph",param:w=null}=c,g=f==="evals"||f==="issues"||f==="settings"?f:N;o.useEffect(()=>{f==="sessions"&&w&&(p("sessions"),v(w))},[f,w]),o.useLayoutEffect(()=>{if(f!=="graph"||!w)return;if(p("specs"),!b[w]){x(h?[h.id]:[]);return}const t=[];for(let d=b[w];d;d=d.parent?b[d.parent]:null)t.unshift(d.id);x(t)},[f,w,b,h]);const T=t=>{if(t==="evals"||t==="issues"){I(t);return}p(t),(f==="evals"||f==="issues"||f==="settings")&&I(t==="specs"?"graph":"sessions")},A=t=>{p("sessions"),v(t),I("sessions",t)},E=k.filter(t=>b[t]),F=E[E.length-1]||(h==null?void 0:h.id),C=F?b[F]:null,V=t=>x(d=>[...d.filter(_=>b[_]),t]);return s.jsxs("div",{className:"m-app",children:[s.jsx("main",{className:"m-main",children:g==="evals"||g==="issues"||g==="settings"?s.jsx("div",{className:"m-review",children:s.jsx(o.Suspense,{fallback:s.jsx("div",{className:"m-empty",children:u("common.loading")}),children:g==="settings"?s.jsx(hs,{}):g==="evals"?s.jsx(ds,{specs:e,sessions:l,issuesStamp:r,reloadBoard:m,onOpenSession:A}):s.jsx(us,{specs:e,sessions:l,issuesStamp:r,onOpenSession:A})})}):g==="specs"?s.jsxs("div",{className:"m-specs",children:[s.jsx("nav",{className:"m-crumbs",children:E.map((t,d)=>s.jsxs("span",{className:"m-crumb",children:[d>0&&s.jsx("span",{className:"m-crumb-sep",children:"›"}),s.jsx("button",{className:d===E.length-1?"m-crumb-btn cur":"m-crumb-btn",onClick:()=>x(E.slice(0,d+1)),children:b[t].title})]},t))}),C&&s.jsx(xs,{node:C,childrenOf:j,sessions:l,onOpenChild:V},C.id)]}):s.jsx(Ns,{specs:e,sessions:l,openId:n,setOpenId:v,creating:i,setCreating:a,newDraft:S,setNewDraft:y})}),s.jsxs("nav",{className:"m-tabbar",children:[s.jsxs("button",{className:g==="specs"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("specs"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"❯_"}),u("mobile.specsTab")]}),s.jsxs("button",{className:g==="sessions"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("sessions"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"◐"}),u("mobile.sessionsTab"),l.length>0&&s.jsx("span",{className:"m-tabbar-badge",children:l.length})]}),s.jsxs("button",{className:g==="evals"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("evals"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"✓"}),u("mobile.evalsTab")]}),s.jsxs("button",{className:g==="issues"?"m-tabbar-btn on":"m-tabbar-btn",onClick:()=>T("issues"),children:[s.jsx("span",{className:"m-tabbar-ico",children:"◎"}),u("mobile.issuesTab")]})]})]})}export{Ps as default};
@@ -0,0 +1 @@
1
+ import{r as b,j as i,a as L}from"./index-Co8kmYQY.js";import{N as k}from"./App-BBoP1IyU.js";let w=null;const T=e=>!!(e&&e.closest&&e.closest("[data-focus-overlay]")),P=e=>e!=null&&e.getClientRects().length?typeof e.checkVisibility=="function"?e.checkVisibility({visibilityProperty:!0}):getComputedStyle(e).visibility!=="hidden"&&getComputedStyle(e).display!=="none":!1,E=e=>!!(e&&e.isConnected&&!e.disabled&&P(e));typeof window<"u"&&window.addEventListener("focusin",e=>{const t=e.target;t&&t!==document.body&&!T(t)&&(w=t)},!0);function R(){requestAnimationFrame(()=>{if(T(document.activeElement))return;if(E(w)){w.focus();return}const e=[...document.querySelectorAll("[data-focus-sink]")].find(E);E(e)&&e.focus()})}const N='input, textarea, select, [contenteditable=""], [contenteditable="true"], .xterm',$="[data-selectable]",j=(e,t)=>{if(!(e instanceof HTMLElement))return!1;const s=e.getBoundingClientRect();return t.clientX-s.left-e.clientLeft>=e.clientWidth||t.clientY-s.top-e.clientTop>=e.clientHeight};function I(e){const t=e.target;t instanceof Element&&(t.closest(N)||t.closest($)||j(t,e)||e.preventDefault())}const A="spex.page-scroll:",C=()=>typeof window>"u"?"":`${window.location.pathname}${window.location.search}${window.location.hash}`,F=e=>{try{return Number(sessionStorage.getItem(`${A}${e}`))||0}catch{return 0}},y=(e,t)=>{try{sessionStorage.setItem(`${A}${e}`,String(t))}catch{}};function _({className:e="",scrollKey:t,children:s,...d}){const p=k(),o=t??p??C(),x=b.useRef(null);return b.useLayoutEffect(()=>{const n=x.current;if(!n)return;const a=F(o);let l=a,f=a>0,g=0,r=0,u;const v=()=>{f=!1,r&&cancelAnimationFrame(r),r=0,u==null||u.disconnect()},m=()=>{if(r=0,!f)return;const S=Math.max(0,n.scrollHeight-n.clientHeight);if(n.scrollTop=Math.min(a,S),S<a){g=0;return}if(Math.abs(n.scrollTop-a)>1){g=0,r=requestAnimationFrame(m);return}l=n.scrollTop,y(o,l),++g<2?r=requestAnimationFrame(m):v()},h=()=>{f||(l=n.scrollTop,y(o,l))},c=()=>{v(),h()};return n.scrollTop=a,f&&(u=new MutationObserver(()=>{r||(r=requestAnimationFrame(m))}),u.observe(n,{childList:!0,subtree:!0,characterData:!0}),r=requestAnimationFrame(m)),n.addEventListener("scroll",h,{passive:!0}),n.addEventListener("pointerdown",c,!0),n.addEventListener("wheel",c,{passive:!0,capture:!0}),n.addEventListener("keydown",c,!0),()=>{n.removeEventListener("scroll",h),n.removeEventListener("pointerdown",c,!0),n.removeEventListener("wheel",c,!0),n.removeEventListener("keydown",c,!0),v(),y(o,l)}},[o]),i.jsx("div",{ref:x,className:`page-scroll${e?` ${e}`:""}`,...d,children:s})}function G({title:e,closeLabel:t,onClose:s,className:d,children:p}){return b.useEffect(()=>()=>R(),[]),i.jsx("div",{className:"legend-backdrop","data-focus-overlay":!0,onClick:s,children:i.jsxs("div",{className:d?`legend ${d}`:"legend",role:"dialog","aria-modal":"true","aria-label":e,onClick:o=>o.stopPropagation(),children:[i.jsxs("div",{className:"legend-head",children:[i.jsx("span",{className:"legend-title",children:e}),i.jsx(L,{icon:"x",size:13,className:"legend-close",label:t,onClick:s})]}),i.jsx("div",{className:"legend-body",children:p})]})})}export{G as M,_ as P,I as i,R as r};
@@ -1,3 +1,3 @@
1
- import{j as e,r as v,ai as Q,u as f,I as $,h as re,m as ce}from"./index-B-qrQ2QS.js";import{U as oe,T as de,Q as y,an as he,R as Y,O as J,aS as X,aT as Z,a6 as ee,aE as ue,aU as pe,aV as me,aW as ve,k as I,aX as fe,aJ as xe,V as je,aY as k,ag as Ne}from"./tabs-BxFTq-sB.js";import{f as se,E as L,c as ge,e as we}from"./Thread-Cx5fJkFO.js";import{r as R,d as be,O as ye,S as U}from"./App-DANZYsFg.js";import{u as Ve,l as q,P as ke}from"./ProseActions-LG4ve4AO.js";const M=s=>{const a=String(s||"").trim().replace(/^#/,"");return/^(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(a)?`#${(a.length===3?[...a].map(n=>`${n}${n}`).join(""):a).toLowerCase()}`:null},Le=s=>{const a=[1,3,5].map(t=>parseInt(s.slice(t,t+2),16));return(a[0]*299+a[1]*587+a[2]*114)/1e3>=150?"#1f2328":"#ffffff"};function Se({labels:s,onSelect:a=null}){return!Array.isArray(s)||!s.length?null:e.jsx("span",{className:"issue-labels",children:s.map((t,n)=>{const i=typeof t=="string"?{name:t}:t||{},l=String(i.name||"").trim();if(!l)return null;const c=M(i.color),o=M(i.textColor)||(c?Le(c):null),u=c?{"--issue-label-bg":c,"--issue-label-fg":o,"--issue-label-border":c}:void 0,x={key:`${l}-${n}`,className:`issue-label${a?" selectable":""}`,style:u,title:l};return a?e.jsx("button",{type:"button",...x,onClick:()=>a(l),children:l}):e.jsx("span",{...x,children:l})})})}function O({issue:s,onNavigateAddress:a}){const t=(s==null?void 0:s.store)||"local",n=(s==null?void 0:s.status)||"open",i=oe(s.id);return e.jsxs("a",{className:"issue-card",href:y(i),"data-tip":s.concern||s.id,onClick:a?l=>{l.defaultPrevented||l.button!==0||l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||(l.preventDefault(),a(i))}:void 0,children:[e.jsxs("span",{className:"issue-card-top",children:[e.jsx("span",{className:"issue-num",children:s.id}),e.jsx("span",{className:`fv-store fv-store-${t==="local"?"local":"forge"}`,children:t}),e.jsx(de,{kind:"issue",state:n,showLabel:!0,size:12,className:"issue-card-state"})]}),e.jsx("span",{className:"issue-card-title",children:s.concern}),e.jsx(Se,{labels:s.labels})]})}const G=[{key:"spec",label:"spec"},{key:"history",label:"history"},{key:"issues",label:"issues"},{key:"eval",label:"eval"}];function Ee(s,a=!1){var t;return a?[{key:"spec",label:"spec"}]:(t=s==null?void 0:s.overlays)!=null&&t.length?[{key:"edit",label:"edit"},...G]:G}const ae=(s,a,t={})=>{let n=`${s==="issue"?"is:issue":ye}${t.q?` ${String(t.q).trim()}`:""}`.trim();const i=s==="issue"?{state:"state",author:"author",store:"store",session:"session"}:{verdict:"verdict",review:"state",freshness:"freshness",kind:"evidence",filer:"filer",session:"session"};for(const[l,c]of Object.entries(i))t[l]&&(n=U(n,c,t[l]));return U(n,"node",a)},$e={state:"reviewList.facetState",verdict:"reviewList.facetVerdict",author:"reviewList.facetAuthor",store:"reviewList.facetStore",review:"reviewList.facetReview",freshness:"reviewList.facetFreshness",kind:"reviewList.facetKind",filer:"reviewList.facetFiler",session:"reviewList.facetSession"},ne=(s,a)=>{const t=n=>n&&{...n,label:a($e[n.key]||n.label||n.key)};return{section:t(s==null?void 0:s.section),facets:Object.fromEntries(Object.entries((s==null?void 0:s.facets)||{}).map(([n,i])=>[n,t(i)]))}};function C({body:s,lineBase:a=0}){if(!s)return null;const{source:t,removedLines:n}=pe(s),i=a>0?a+n:0;return e.jsx(me,{className:"doc-body",lineBase:i,renderSpecRef:(l,c,o)=>{const u=R("spec",l);return e.jsx("a",{className:"doc-link",href:u,...o,onClick:x=>I(x,u),children:l})},renderEvidence:(l,c,o)=>e.jsx("span",{className:"rich-evidence","data-evidence-hash":l.hash,...o,children:e.jsx(ve,{hash:l.hash,alt:l.alt})}),children:t})}function z({kind:s,title:a,owner:t,ownerLabel:n,note:i,children:l}){return e.jsxs("section",{className:`spec-part part-${s}`,children:[e.jsxs("header",{className:"part-head",children:[e.jsx("span",{className:"part-title",children:a}),e.jsx("span",{className:`part-owner owner-${t}`,children:n}),i&&e.jsx("span",{className:"part-note",children:i})]}),e.jsx("div",{className:"part-body",children:l})]})}function Ce({parts:s,body:a}){const t=f(),n=q(a,s.rawSource),i=q(a,s.expandedSpec);return e.jsxs("div",{className:"spec-parts",children:[e.jsx(z,{kind:"raw",title:t("nodeView.rawTitle"),owner:"human",ownerLabel:t("nodeView.rawOwner"),note:t("nodeView.rawNote"),children:e.jsx(C,{body:s.rawSource,lineBase:(n==null?void 0:n.startLine)||0})}),e.jsx(z,{kind:"expanded",title:t("nodeView.expandedTitle"),owner:"agent",ownerLabel:t("nodeView.expandedOwner"),note:t("nodeView.expandedNote"),children:e.jsx(C,{body:s.expandedSpec,lineBase:(i==null?void 0:i.startLine)||0})})]})}function Ie({files:s,count:a}){const t=f(),n=i=>i.split("#")[0];return e.jsxs("div",{className:"doc-gov",children:[e.jsxs("span",{className:"doc-gov-h",children:[t("nodeView.governs")," ",e.jsx("b",{children:a})]}),e.jsx("div",{className:"doc-gov-files",children:s.map(i=>{const l=n(i),c=R("file",l);return e.jsx("a",{className:"gov-f",href:c,onClick:o=>I(o,c),children:i},i)})})]})}const Re=(s,a)=>`.spec/${s}/${a}`;function Te({nodeId:s,enabled:a}){const t=f(),[n,i]=v.useState(null);return v.useEffect(()=>{if(!a)return;let l=!0;return re(s).then(c=>l&&i(c)).catch(()=>l&&i([])),()=>{l=!1}},[s,a]),n!=null&&n.length?e.jsxs("div",{className:"doc-gov doc-att",children:[e.jsxs("span",{className:"doc-gov-h",children:[t("nodeView.carries")," ",e.jsx("b",{children:n.length})]}),e.jsx("div",{className:"doc-gov-files",children:n.map(l=>{const c=R("file",Re(s,l.name));return e.jsx("a",{className:"gov-f",href:c,"data-tip":`${(l.size/1024).toFixed(1)} KB`,onClick:o=>I(o,c),children:l.name},l.name)})})]}):null}function De({node:s,graphOnly:a=!1}){var l,c;const t=f(),n=Ve(s.id,s.version,{embedded:s.body!=null,publicGraph:a}),i=(s.driftFiles||[]).map(o=>`${o.file}: ${t("specNode.driftAhead",{n:o.behind})}`).join(`
1
+ import{j as e,r as v,al as Q,u as f,I as $,h as re,m as ce}from"./index-Co8kmYQY.js";import{T as oe,R as de,P as y,am as he,Q as Y,N as J,aR as X,aS as Z,a5 as ee,aD as ue,aT as pe,aU as me,aV as ve,k as I,aW as fe,aI as xe,U as je,aX as k,af as Ne}from"./tabs-C4phsoFs.js";import{f as se,E as L,c as ge,e as we}from"./Thread-4tohzgUo.js";import{r as R,d as be,O as ye,S as U}from"./App-BBoP1IyU.js";import{u as Ve,l as q,P as ke}from"./ProseActions-CSG_3k1b.js";const M=s=>{const a=String(s||"").trim().replace(/^#/,"");return/^(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(a)?`#${(a.length===3?[...a].map(n=>`${n}${n}`).join(""):a).toLowerCase()}`:null},Le=s=>{const a=[1,3,5].map(t=>parseInt(s.slice(t,t+2),16));return(a[0]*299+a[1]*587+a[2]*114)/1e3>=150?"#1f2328":"#ffffff"};function Se({labels:s,onSelect:a=null}){return!Array.isArray(s)||!s.length?null:e.jsx("span",{className:"issue-labels",children:s.map((t,n)=>{const i=typeof t=="string"?{name:t}:t||{},l=String(i.name||"").trim();if(!l)return null;const c=M(i.color),o=M(i.textColor)||(c?Le(c):null),u=c?{"--issue-label-bg":c,"--issue-label-fg":o,"--issue-label-border":c}:void 0,x={key:`${l}-${n}`,className:`issue-label${a?" selectable":""}`,style:u,title:l};return a?e.jsx("button",{type:"button",...x,onClick:()=>a(l),children:l}):e.jsx("span",{...x,children:l})})})}function O({issue:s,onNavigateAddress:a}){const t=(s==null?void 0:s.store)||"local",n=(s==null?void 0:s.status)||"open",i=oe(s.id);return e.jsxs("a",{className:"issue-card",href:y(i),"data-tip":s.concern||s.id,onClick:a?l=>{l.defaultPrevented||l.button!==0||l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||(l.preventDefault(),a(i))}:void 0,children:[e.jsxs("span",{className:"issue-card-top",children:[e.jsx("span",{className:"issue-num",children:s.id}),e.jsx("span",{className:`fv-store fv-store-${t==="local"?"local":"forge"}`,children:t}),e.jsx(de,{kind:"issue",state:n,showLabel:!0,size:12,className:"issue-card-state"})]}),e.jsx("span",{className:"issue-card-title",children:s.concern}),e.jsx(Se,{labels:s.labels})]})}const G=[{key:"spec",label:"spec"},{key:"history",label:"history"},{key:"issues",label:"issues"},{key:"eval",label:"eval"}];function Ee(s,a=!1){var t;return a?[{key:"spec",label:"spec"}]:(t=s==null?void 0:s.overlays)!=null&&t.length?[{key:"edit",label:"edit"},...G]:G}const ae=(s,a,t={})=>{let n=`${s==="issue"?"is:issue":ye}${t.q?` ${String(t.q).trim()}`:""}`.trim();const i=s==="issue"?{state:"state",author:"author",store:"store",session:"session"}:{verdict:"verdict",review:"state",freshness:"freshness",kind:"evidence",filer:"filer",session:"session"};for(const[l,c]of Object.entries(i))t[l]&&(n=U(n,c,t[l]));return U(n,"node",a)},$e={state:"reviewList.facetState",verdict:"reviewList.facetVerdict",author:"reviewList.facetAuthor",store:"reviewList.facetStore",review:"reviewList.facetReview",freshness:"reviewList.facetFreshness",kind:"reviewList.facetKind",filer:"reviewList.facetFiler",session:"reviewList.facetSession"},ne=(s,a)=>{const t=n=>n&&{...n,label:a($e[n.key]||n.label||n.key)};return{section:t(s==null?void 0:s.section),facets:Object.fromEntries(Object.entries((s==null?void 0:s.facets)||{}).map(([n,i])=>[n,t(i)]))}};function C({body:s,lineBase:a=0}){if(!s)return null;const{source:t,removedLines:n}=pe(s),i=a>0?a+n:0;return e.jsx(me,{className:"doc-body",lineBase:i,renderSpecRef:(l,c,o)=>{const u=R("spec",l);return e.jsx("a",{className:"doc-link",href:u,...o,onClick:x=>I(x,u),children:l})},renderEvidence:(l,c,o)=>e.jsx("span",{className:"rich-evidence","data-evidence-hash":l.hash,...o,children:e.jsx(ve,{hash:l.hash,alt:l.alt})}),children:t})}function z({kind:s,title:a,owner:t,ownerLabel:n,note:i,children:l}){return e.jsxs("section",{className:`spec-part part-${s}`,children:[e.jsxs("header",{className:"part-head",children:[e.jsx("span",{className:"part-title",children:a}),e.jsx("span",{className:`part-owner owner-${t}`,children:n}),i&&e.jsx("span",{className:"part-note",children:i})]}),e.jsx("div",{className:"part-body",children:l})]})}function Ce({parts:s,body:a}){const t=f(),n=q(a,s.rawSource),i=q(a,s.expandedSpec);return e.jsxs("div",{className:"spec-parts",children:[e.jsx(z,{kind:"raw",title:t("nodeView.rawTitle"),owner:"human",ownerLabel:t("nodeView.rawOwner"),note:t("nodeView.rawNote"),children:e.jsx(C,{body:s.rawSource,lineBase:(n==null?void 0:n.startLine)||0})}),e.jsx(z,{kind:"expanded",title:t("nodeView.expandedTitle"),owner:"agent",ownerLabel:t("nodeView.expandedOwner"),note:t("nodeView.expandedNote"),children:e.jsx(C,{body:s.expandedSpec,lineBase:(i==null?void 0:i.startLine)||0})})]})}function Ie({files:s,count:a}){const t=f(),n=i=>i.split("#")[0];return e.jsxs("div",{className:"doc-gov",children:[e.jsxs("span",{className:"doc-gov-h",children:[t("nodeView.governs")," ",e.jsx("b",{children:a})]}),e.jsx("div",{className:"doc-gov-files",children:s.map(i=>{const l=n(i),c=R("file",l);return e.jsx("a",{className:"gov-f",href:c,onClick:o=>I(o,c),children:i},i)})})]})}const Re=(s,a)=>`.spec/${s}/${a}`;function Te({nodeId:s,enabled:a}){const t=f(),[n,i]=v.useState(null);return v.useEffect(()=>{if(!a)return;let l=!0;return re(s).then(c=>l&&i(c)).catch(()=>l&&i([])),()=>{l=!1}},[s,a]),n!=null&&n.length?e.jsxs("div",{className:"doc-gov doc-att",children:[e.jsxs("span",{className:"doc-gov-h",children:[t("nodeView.carries")," ",e.jsx("b",{children:n.length})]}),e.jsx("div",{className:"doc-gov-files",children:n.map(l=>{const c=R("file",Re(s,l.name));return e.jsx("a",{className:"gov-f",href:c,"data-tip":`${(l.size/1024).toFixed(1)} KB`,onClick:o=>I(o,c),children:l.name},l.name)})})]}):null}function De({node:s,graphOnly:a=!1}){var l,c;const t=f(),n=Ve(s.id,s.version,{embedded:s.body!=null,publicGraph:a}),i=(s.driftFiles||[]).map(o=>`${o.file}: ${t("specNode.driftAhead",{n:o.behind})}`).join(`
2
2
  `);return e.jsxs("div",{className:"pane-doc",children:[e.jsx("h1",{className:"doc-title",children:s.title}),e.jsx("blockquote",{className:"doc-desc",children:s.desc}),e.jsxs("div",{className:"doc-stat",children:[e.jsxs("span",{className:`stat-status st-${s.status}`,"data-tip":t("nodeView.statusLabel"),children:[e.jsx("i",{className:"stat-dot"}),t(`status.${s.status}`)]}),e.jsxs("span",{className:"stat-chip","data-tip":t("nodeView.versionLabel"),children:["v",s.version||0]}),e.jsx(he,{summary:(l=s.reviewSummary)==null?void 0:l.evals,href:y(Y(s.id))}),s.drift>0&&e.jsxs("span",{className:"stat-chip stat-drift","data-tip":i,children:["⚠",s.drift]}),e.jsxs("span",{className:"stat-sess","data-tip":t("nodeView.lastEditedBy"),children:["✎ ",e.jsx("b",{children:s.session||t("common.none")})]})]}),((c=s.code)==null?void 0:c.length)>0?e.jsx(Ie,{files:s.code,count:s.code.length}):e.jsx("div",{className:"doc-gov prose",children:e.jsx("span",{className:"doc-gov-h",children:t("nodeView.proseNode")})}),!a&&e.jsx(Te,{nodeId:s.id,enabled:!0}),(()=>{if(n===null&&s.body==null)return e.jsx("div",{className:"pane-loading",children:e.jsx("span",{className:"spinner","aria-label":t("common.loading")})});const o=s.body??(n==null?void 0:n.body)??"",u=s.parts??(n==null?void 0:n.parts)??null;return u?e.jsx(Ce,{parts:u,body:o}):e.jsx(C,{body:o,lineBase:1})})()]})}function Fe(s,a=!0){const[t,n]=v.useState(null);return v.useEffect(()=>{if(!a)return;let i=!0;return fetch(Q(s,"history")).then(l=>l.json()).then(l=>{i&&n(l)}).catch(()=>i&&n([])),()=>{i=!1}},[s,a]),t}const S=new Map;function Pe(s,a,t){const n=`${s}/${a}`,[i,l]=v.useState(()=>S.get(n)??null);return v.useEffect(()=>{const c=S.get(n);if(c){l(c);return}let o=!0;return fetch(Q(s,"diff",a)).then(u=>u.json()).then(u=>{S.set(n,u),o&&l(u)}).catch(()=>o&&l({patch:""})),()=>{o=!1}},[s,a,t,n]),i}function Ae(s){const a=[];let t=!1;for(const n of s.split(`
3
3
  `)){if(n.startsWith("@@")){t=!0,a.push({t:"hunk",s:n});continue}!t||n.startsWith("\\")||(n.startsWith("+")?a.push({t:"add",s:n.slice(1)}):n.startsWith("-")?a.push({t:"del",s:n.slice(1)}):a.push({t:"ctx",s:n.slice(1)}))}for(;a.length&&a[a.length-1].t==="ctx"&&a[a.length-1].s==="";)a.pop();return a}function te({diff:s}){const a=f();if(s==null)return e.jsx("figcaption",{className:"ev-note",children:a("nodeView.loadingChange")});const t=s.patch?Ae(s.patch):[];return t.length?e.jsxs(e.Fragment,{children:[e.jsx("figcaption",{className:"ev-difflabel",children:a("nodeView.diffLabel")}),e.jsx("pre",{className:"ev-diff",children:t.map((n,i)=>e.jsx("div",{className:`dl dl-${n.t}`,children:n.s||" "},i))})]}):e.jsx("figcaption",{className:"ev-note",children:a("nodeView.noChange")})}function ie({items:s,itemKey:a,classes:t,rowClass:n,renderHeader:i,renderEvidence:l,renderAction:c,leading:o,trailing:u,resetKey:x}){const j=v.useRef(null),[g,w]=v.useState(()=>new Set([0]));v.useEffect(()=>{x!==void 0&&w(new Set([0]))},[x]);const b=v.useCallback(d=>w(r=>{const h=new Set(r);return h.has(d)?h.delete(d):h.add(d),h}),[]),N=v.useCallback(()=>w(d=>{const r=j.current;if(!r)return d;let h=-1;for(;d.has(h+1);)h++;if(h<0||h>=s.length-1)return d;const p=r.querySelector(`[data-i="${h}"]`);return!p||p.getBoundingClientRect().bottom-r.getBoundingClientRect().top>r.clientHeight+40?d:new Set(d).add(h+1)}),[s]);return v.useEffect(()=>{const d=j.current;if(!d)return;let r=d.scrollTop;const h=()=>{const p=d.scrollTop,V=p>r;r=p,V&&N()};return d.addEventListener("scroll",h,{passive:!0}),()=>d.removeEventListener("scroll",h)},[N]),be(d=>{if(d.key!=="j"&&d.key!=="ArrowDown")return!1;const r=j.current;return!r||r.scrollHeight-r.clientHeight-r.scrollTop>1?!1:(d.preventDefault(),N(),!0)},5),e.jsxs("div",{className:t.pane,ref:j,children:[o,s.map((d,r)=>{const h=g.has(r),p=n?n(d,r):"";return e.jsxs("div",{"data-i":r,className:`${t.row}${p?` ${p}`:""}${h?" open":""}`,children:[e.jsx("button",{className:t.head,onClick:()=>b(r),"aria-expanded":h,children:i(d,r,h)}),c==null?void 0:c(d,r),h&&e.jsx("figure",{className:t.evidence,children:l(d,r)})]},a(d,r))}),u]})}function Be({node:s,r:a,latest:t}){const n=Pe(s.id,a.hash,!0);return e.jsx(te,{diff:n})}function He({node:s,rows:a}){const t=f();return a?a.length?e.jsx(ie,{items:a,itemKey:n=>n.hash,classes:{pane:"pane-hist",row:"ver-row",head:"rec-toggle",evidence:"rec-evidence"},rowClass:(n,i)=>i===0?"latest":"",renderHeader:(n,i,l)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rec-head",children:[e.jsx("span",{className:"rec-caret",children:l?"▾":"▸"}),e.jsxs("span",{className:"rec-v",children:["v",a.length-i]}),e.jsx("code",{className:"rec-hash",children:n.hash.slice(0,7)}),e.jsx("span",{className:"rec-date",children:(n.date||"").slice(0,10)}),e.jsxs("span",{className:"rec-diff",children:[e.jsxs("b",{className:"rec-add",children:["+",n.additions??0]}),e.jsxs("b",{className:"rec-del",children:["−",n.deletions??0]})]})]}),e.jsx("div",{className:"rec-msg",children:n.reason}),e.jsxs("div",{className:"rec-sub",children:[t("nodeView.filesChanged",{n:n.files??0})," · ",n.session||t("common.idle")]})]}),renderEvidence:(n,i)=>e.jsx(Be,{node:s,r:n,latest:i===0})}):e.jsx("div",{className:"pane-hist empty",children:t("common.noVersions")}):e.jsx("div",{className:"pane-hist empty",children:t("nodeView.loadingHistory")})}function Ke({node:s,sessions:a=[],filter:t={},onFilter:n=()=>{}}){var b,N,d,r,h;const i=f(),l=ae("issue",s.id,t),c=J("issues",l,1,{pollMs:0});if(c.loading)return e.jsx("div",{className:"pane-issues pane-loading",children:e.jsx("span",{className:"spinner","aria-label":i("common.loading")})});if(c.error)return e.jsx("div",{className:"pane-issues empty",children:c.error});const o=((b=c.data)==null?void 0:b.items)||[],u=(((d=(N=s.reviewSummary)==null?void 0:N.issues)==null?void 0:d.open)||0)+(((h=(r=s.reviewSummary)==null?void 0:r.issues)==null?void 0:h.closed)||0);if(!u)return e.jsx("div",{className:"pane-issues empty",children:i("nodeView.noIssues")});const x=ne(c.data,i),j=o.filter(p=>p.status==="open"),g=o.filter(p=>p.status!=="open"),w=se(x,n,["section","author","store","session"]);return e.jsxs("div",{className:"pane-issues",children:[u>4&&e.jsx(X,{value:t.q||"",onChange:p=>n({q:p||null}),summary:{shown:o.length,total:c.data.total},placeholder:i("nodeView.filterIssues"),searchLabel:i("reviewList.searchIssues"),filterLabel:i("reviewList.filters"),clearLabel:i("reviewList.all"),clearSearchLabel:i("reviewList.clearSearch"),groups:w}),!o.length&&e.jsx("div",{className:"pane-filter-none",children:i("nodeView.filterNone")}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"issue-group-head",children:i("nodeView.openIssues",{n:j.length})}),j.map(p=>e.jsx(O,{issue:p},p.id))]}),g.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"issue-group-head closed",children:i("nodeView.closedIssues",{n:g.length})}),g.map(p=>e.jsx(O,{issue:p},p.id))]}),c.data.total>o.length&&e.jsxs("a",{className:"pane-view-all",href:y(Z("issues",l)),children:[i("reviewList.showing",{shown:o.length,total:c.data.total})," ",e.jsx($,{name:"chevron-right",size:13})]})]})}const E=new Map;function Ue(s,a,t){const n=`${s} ${a}`,[i,l]=v.useState(()=>E.get(n)??null);return v.useEffect(()=>{if(!s||!a)return;const c=E.get(n);c&&l(c);let o=!0;return fetch(ce(`/api/edit?source=${encodeURIComponent(s)}&path=${encodeURIComponent(a)}`)).then(u=>u.json()).then(u=>{E.set(n,u),o&&l(u)}).catch(()=>o&&l(u=>u??{patch:""})),()=>{o=!1}},[s,a,t,n]),i}function qe({node:s,ov:a}){const t=f(),n=Ue(a.source,s.path,!0);return e.jsxs("figure",{className:"edit-rev",children:[e.jsxs("figcaption",{className:"edit-by",children:[e.jsx("span",{className:`ov-mark ov-${a.op}`,children:je[a.op]||"•"}),e.jsx("span",{className:"edit-by-label",children:a.label}),e.jsx("span",{className:"edit-state",children:a.committed?t("nodeView.editCommitted"):t("nodeView.editDirty")})]}),e.jsx(te,{diff:n})]})}function Me({node:s}){const a=f(),t=s.overlays||[];return t.length?e.jsx("div",{className:"pane-edit",children:t.map((n,i)=>e.jsx(qe,{node:s,ov:n},i))}):e.jsx("div",{className:"pane-edit empty",children:a("nodeView.noEdit")})}function Oe({verdict:s}){const a=f();return s?s.status==="pass"?e.jsx("span",{className:"eval-verdict pass",children:a("nodeView.eval.pass")}):s.status==="fail"?e.jsx("span",{className:"eval-verdict fail",children:a("nodeView.eval.fail")}):e.jsx("span",{className:"eval-verdict note","data-tip":s.note,children:a("nodeView.eval.note")}):e.jsx("span",{className:"eval-verdict legacy",children:a("nodeView.eval.legacy")})}function Ge({r:s}){var n;const a=f(),t=we(s);return e.jsxs(e.Fragment,{children:[s.expected&&e.jsxs("div",{className:"eval-expected",children:[e.jsx("span",{className:"eval-expected-label",children:a("nodeView.eval.expected")})," ",s.expected]}),((n=s.verdict)==null?void 0:n.note)&&e.jsxs("div",{className:"eval-note",children:[e.jsx("span",{className:"eval-expected-label",children:a("nodeView.eval.noteLabel")})," ",s.verdict.note]}),t.length>0?e.jsx("div",{className:"eval-gallery",style:{display:"flex",flexDirection:"column",gap:8},children:t.map((i,l)=>e.jsx(xe,{e:i,alt:a("nodeView.eval.shotAlt",{scenario:s.scenario})},`${i.hash}-${l}`))}):e.jsx("figcaption",{className:"eval-noimg",children:s.blobState==="miss"?a("nodeView.eval.miss"):a("nodeView.eval.noImage")})]})}function _({s}){var t;const a=f();return e.jsxs("div",{className:"eval-row eval-declared-row",children:[e.jsxs("span",{className:"eval-top",children:[e.jsx(ee,{state:"empty",title:a("score.missing")}),e.jsx("span",{className:"eval-scenario",children:s.name}),e.jsx(fe,{tags:s.tags}),((t=s.code)==null?void 0:t.length)>0&&e.jsx("code",{className:"eval-tracks",children:s.code.join(", ")})]}),s.expected&&e.jsxs("div",{className:"eval-expected",children:[e.jsx("span",{className:"eval-expected-label",children:a("nodeView.eval.expected")})," ",s.expected]})]})}function W({track:s}){const a=f();return e.jsxs("div",{className:"eval-row eval-dangling-row",children:[e.jsxs("span",{className:"eval-top",children:[e.jsx("span",{className:"eval-dangling-badge","data-tip":a("nodeView.eval.danglingTitle"),children:"⚠"}),e.jsx("span",{className:"eval-scenario eval-dangling-name",children:s.scenario}),e.jsx("span",{className:"eval-dangling-tag",children:a("nodeView.eval.danglingGone")})]}),e.jsx("div",{className:"eval-dangling-remarks",children:e.jsx(ge,{replies:s.remarks})})]})}function ze({node:s,sessions:a=[],filter:t={},onFilter:n=()=>{}}){var d;const i=f(),l=ae("eval",s.id,t),c=J("evals",l,1,{pollMs:0,view:"timeline"});if(c.loading)return e.jsx("div",{className:"pane-eval pane-loading",children:e.jsx("span",{className:"spinner","aria-label":i("common.loading")})});if(c.error)return e.jsx("div",{className:"pane-eval empty",children:c.error});if(!((d=c.data)!=null&&d.hasEvalFile))return e.jsx("div",{className:"pane-eval empty",children:i("nodeView.eval.noScenarios")});const o=c.data.items||[],u=o.filter(r=>r.filterKind===L.RESULT),x=o.filter(r=>r.filterKind===L.UNMEASURED),j=o.filter(r=>r.filterKind===L.DANGLING),g=ne(c.data,i),w=se(g,n,["section","review","freshness","kind","filer","session"]),b=e.jsx("a",{className:"pane-eval-list-door",href:y(Z("evals",l)),"data-tip":i("score.openList"),"aria-label":i("score.openList"),children:e.jsx($,{name:"chevron-right",size:14})}),N=c.data.sourceTotal>4?e.jsx(X,{value:t.q||"",onChange:r=>n({q:r||null}),summary:{shown:o.length,total:c.data.total},placeholder:i("nodeView.filterScenarios"),searchLabel:i("reviewList.searchEvals"),filterLabel:i("reviewList.filters"),clearLabel:i("reviewList.all"),clearSearchLabel:i("reviewList.clearSearch"),groups:w,trailing:b},"filter"):e.jsx("div",{className:"pane-eval-list-door-row",children:b});return u.length?e.jsx(e.Fragment,{children:e.jsx(ie,{items:u,resetKey:`${c.data.revision}:${JSON.stringify(t)}`,leading:[N,o.length?null:e.jsx("div",{className:"pane-filter-none",children:i("nodeView.filterNone")},"none"),...x.map(r=>e.jsx(_,{s:r},r.name))],trailing:j.map(r=>e.jsx(W,{track:r},r.threadId)),itemKey:(r,h)=>`${r.scenario}-${r.ts}-${h}`,classes:{pane:"pane-eval",row:"eval-row",head:"eval-head",evidence:"eval-shot"},renderAction:r=>e.jsx("a",{className:"eval-open",href:y(Y(s.id,r.scenario)),"data-tip":i("nodeView.eval.openDetail"),"aria-label":i("nodeView.eval.openDetail"),children:e.jsx($,{name:"chevron-right",size:14})}),renderHeader:(r,h,p)=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"eval-top",children:[e.jsx("span",{className:"eval-caret",children:p?"▾":"▸"}),e.jsx("span",{className:"eval-scenario",children:r.scenario}),e.jsx(Oe,{verdict:r.verdict}),e.jsx(ee,{state:ue(r),title:r.fresh?void 0:i("nodeView.eval.staleAxes",{axes:r.staleAxes.join(", ")})})]}),e.jsxs("span",{className:"eval-meta",children:[r.evaluator&&e.jsx("span",{className:"eval-evaluator",children:r.evaluator}),e.jsx("code",{className:"eval-sha",children:r.codeSha.slice(0,7)}),e.jsx("span",{className:"eval-ts",children:r.ts.replace("T"," ").slice(0,16)})]})]}),renderEvidence:r=>e.jsx(Ge,{r})})}):e.jsxs("div",{className:"pane-eval pane-eval-declared",children:[N,e.jsx("div",{className:"eval-todo-note",children:o.length?i("nodeView.eval.noReadings"):i("nodeView.filterNone")}),x.map(r=>e.jsx(_,{s:r},r.name)),j.map(r=>e.jsx(W,{track:r},r.threadId))]})}const _e={spec:"nodeView.paneSpec",history:"nodeView.paneHistory",issues:"nodeView.paneIssues",eval:"nodeView.paneEval",edit:"nodeView.paneEdit"};function Ze({node:s,pane:a,setPane:t,onClose:n,sessions:i=[],graphOnly:l=!1}){var V,T,D,F,P,A,B,H;const c=f(),o=v.useRef(null),[u,x]=v.useState({issues:{},eval:{}}),j=(m,le)=>x(K=>({...K,[m]:Ne(K[m],le)})),g=((T=(V=s.reviewSummary)==null?void 0:V.issues)==null?void 0:T.open)||0,w=((F=(D=s.reviewSummary)==null?void 0:D.issues)==null?void 0:F.closed)||0,b=((A=(P=s.reviewSummary)==null?void 0:P.evals)==null?void 0:A.pass)||0,N=((H=(B=s.reviewSummary)==null?void 0:B.evals)==null?void 0:H.fail)||0,d=(s.overlays||[]).length,r=Ee(s,l),h=r.some(m=>m.key===a)?a:r[0].key,p=Fe(s.id,h==="history");return e.jsx("div",{className:"ov-backdrop","data-focus-overlay":!0,onMouseDown:n,children:e.jsxs("div",{className:"ov-panel",onMouseDown:m=>m.stopPropagation(),children:[e.jsxs("div",{className:"ov-head",children:[e.jsx("span",{className:"ov-title",children:s.title}),e.jsx("div",{className:"ov-tabs",children:r.map(m=>e.jsxs("button",{className:m.key===h?"ov-tab on":"ov-tab",onClick:()=>t(m.key),children:[c(_e[m.key]),m.key==="issues"&&(g>0||w>0)&&e.jsxs("span",{className:"ov-tab-counts",children:[g>0&&e.jsx(k,{kind:"issue",state:"open",cls:"st-open",n:g,label:c("nodeView.openIssues",{n:g})}),w>0&&e.jsx(k,{kind:"issue",state:"closed",cls:"st-closed",n:w,label:c("nodeView.closedIssues",{n:w})})]}),m.key==="eval"&&(b>0||N>0)&&e.jsxs("span",{className:"ov-tab-counts",children:[b>0&&e.jsx(k,{kind:"eval",state:"pass",cls:"st-pass",n:b,label:c("nodeView.eval.passCount",{n:b})}),N>0&&e.jsx(k,{kind:"eval",state:"fail",cls:"st-fail",n:N,label:c("nodeView.eval.failCount",{n:N})})]}),m.key==="edit"&&d>0&&e.jsx("span",{className:"ov-tab-counts",children:e.jsx("span",{className:"ovc st-edit","data-tip":c("nodeView.pendingEdits",{n:d}),children:d})})]},m.key))}),e.jsx("span",{className:"ov-hint",children:c("nodeView.hint")})]}),e.jsxs("div",{className:"ov-body",children:[h==="spec"&&e.jsxs("div",{className:"pane-solo",ref:o,children:[e.jsx(De,{node:s,graphOnly:l}),!l&&e.jsx(ke,{node:s,hostRef:o})]}),h==="history"&&e.jsx(He,{node:s,rows:p}),h==="issues"&&e.jsx(Ke,{node:s,sessions:i,filter:u.issues,onFilter:m=>j("issues",m)}),h==="eval"&&e.jsx(ze,{node:s,sessions:i,filter:u.eval,onFilter:m=>j("eval",m)}),h==="edit"&&e.jsx(Me,{node:s})]})]})})}export{ze as E,He as H,Ke as I,Ze as N,De as S,Me as a,C as b,Se as c,Ee as p,Fe as u};
@@ -0,0 +1 @@
1
+ import{u as q,r,j as e,I as B,a as G,e as J,q as U}from"./index-Co8kmYQY.js";import{o as _,q as K,t as V,C as W,I as D,v as Q,w as X,x as Y,y as H,b as Z,z as ee,A as se,B as te,D as ae,E as oe,F as re,G as A,H as ne,J as ce,K as ie,L as le,M as de}from"./App-BBoP1IyU.js";import{P as pe,M as T}from"./Modal-oF4JAL6H.js";const M=["claude","codex","opencode","pi"];function O({onSet:a,onClear:n,placeholder:t,busy:o,t:c}){const[s,f]=r.useState("");return e.jsxs("form",{className:"proj-drawer proj-pw",onSubmit:j=>{j.preventDefault(),s&&(a(s),f(""))},children:[e.jsx("input",{className:"proj-add-path",type:"password",value:s,onChange:j=>f(j.target.value),placeholder:t,"aria-label":t}),e.jsx("button",{className:"proj-act primary",type:"submit",disabled:!s||o,children:c("projects.passwordSet")}),e.jsx("button",{className:"proj-act",type:"button",disabled:o,onClick:n,children:c("projects.passwordClear")})]})}function je({onAdded:a,onClose:n,t}){const[o,c]=r.useState(""),[s,f]=r.useState(null),[j,h]=r.useState(!0),[d,x]=r.useState(!1),[v,m]=r.useState(null),[E,k]=r.useState(""),[I,F]=r.useState(!1),[S,C]=r.useState(!1),[P,N]=r.useState([]);Z(!d,n);const y=r.useCallback(async u=>{if(d)return;h(!0),m(null),k("");const w=await ee(u);if(h(!1),!w.ok){m(w.error==="network"?t("projects.actionFailed"):w.error);return}f(w),c(w.path),F(!1),C(!1),N([])},[d,t]);r.useEffect(()=>{y("")},[]);const R=!!(s!=null&&s.exists)&&o===s.path,l=!!s&&!s.exists&&o===s.path,g=R&&!s.gitRoot,i=R&&!s.initialized,p=R&&!j&&!d&&!s.cataloged&&(!g||I)&&(!S||!!P.length),b=u=>N(w=>w.includes(u)?w.filter($=>$!==u):[...w,u]),L=async u=>{if(u.preventDefault(),!p)return;x(!0),m(null),k("");const w=await A(s.path,{...g?{initGit:I}:{},...i&&S?{init:{harness:P.join(",")}}:{}});if(x(!1),w.ok){a(w.project);return}m(w.error==="network"?t("projects.actionFailed"):w.error),k(w.output||"")},z=async()=>{if(!l||d)return;x(!0),m(null),k("");const u=await A(s.path,{createDir:!0,initGit:!0});if(x(!1),u.ok){a(u.project);return}m(u.error==="network"?t("projects.actionFailed"):u.error),k(u.output||"")};return e.jsx(T,{title:t("projects.addTitle"),closeLabel:t("common.close"),onClose:()=>{d||n()},className:"proj-add-modal",children:e.jsxs("form",{className:"proj-add-flow",onSubmit:L,children:[e.jsxs("div",{className:"proj-add-pathbar",children:[e.jsx(G,{icon:"arrow-left",size:14,className:"proj-act icon",label:t("projects.browseParent"),disabled:!(s!=null&&s.parent)||j||d,onClick:()=>y(s.parent)}),e.jsx("button",{type:"button",className:"proj-act icon proj-home-btn","data-tip":t("projects.browseHome"),"aria-label":t("projects.browseHome"),disabled:!(s!=null&&s.home)||j||d,onClick:()=>y(s.home),children:"~"}),e.jsx("input",{className:"proj-add-path",value:o,autoFocus:!0,spellCheck:!1,onChange:u=>{c(u.target.value),m(null)},onKeyDown:u=>{u.key!=="Enter"||!o.trim()||(u.preventDefault(),l?z():y(o.trim()))},placeholder:t("projects.addPlaceholder"),"aria-label":t("projects.addPlaceholder"),disabled:d}),e.jsx("button",{className:l?"proj-act primary":"proj-act",type:"button",disabled:!o.trim()||j||d,onClick:()=>{l?z():y(o.trim())},children:t(j?"projects.browseLoading":d&&l?"projects.browseCreating":l?"projects.browseNew":"projects.browseGo")})]}),e.jsxs("div",{className:"proj-folder-list","aria-label":t("projects.folderList"),"aria-busy":j,children:[!j&&(s==null?void 0:s.entries.map(u=>e.jsxs("button",{type:"button",className:"proj-folder-row",onClick:()=>y(u.path),disabled:d,children:[e.jsx(B,{name:"chevron-right",size:13}),e.jsx("span",{className:"proj-folder-name",children:u.name}),u.git&&e.jsx("span",{className:"proj-folder-tag",children:"Git"}),u.initialized&&e.jsx("span",{className:"proj-folder-tag spex",children:"SpexCode"})]},u.path))),!j&&s&&!s.exists&&e.jsx("div",{className:"proj-folder-empty",children:t("projects.folderMissing")}),!j&&(s==null?void 0:s.exists)&&!s.entries.length&&e.jsx("div",{className:"proj-folder-empty",children:t("projects.folderEmpty")}),j&&e.jsx("div",{className:"proj-folder-empty",children:t("projects.browseLoading")})]}),R&&e.jsxs("div",{className:"proj-add-options",children:[e.jsx("div",{className:"proj-add-selected",title:s.path,children:s.path}),s.gitRoot?e.jsxs("div",{className:"proj-add-state",children:[e.jsx(B,{name:"check",size:13})," Git ",e.jsx("code",{children:s.gitRoot})]}):e.jsxs("label",{className:"proj-add-check",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:u=>F(u.target.checked),disabled:d}),e.jsx("span",{children:t("projects.initGit")})]}),s.initialized?e.jsxs("div",{className:"proj-add-state",children:[e.jsx(B,{name:"check",size:13})," ",t("projects.spexInitialized")]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"proj-add-check",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:u=>{C(u.target.checked),k(""),m(null)},disabled:d}),e.jsx("span",{children:t("projects.initSpex")})]}),S&&e.jsxs("fieldset",{className:"proj-add-harnesses",disabled:d,children:[e.jsx("legend",{children:t("projects.harnessTargets")}),M.map(u=>e.jsxs("label",{className:"proj-add-harness",children:[e.jsx("input",{type:"checkbox",checked:P.includes(u),onChange:()=>b(u)}),e.jsx("span",{children:u})]},u))]})]}),s.cataloged&&e.jsx("div",{className:"proj-op-status ok",children:t("projects.alreadyAdded")})]}),(v||E)&&e.jsxs("div",{className:"proj-add-result",children:[v&&e.jsx("div",{className:"proj-err",children:v}),E&&e.jsx("pre",{className:"proj-log",children:E})]}),e.jsxs("div",{className:"proj-add-actions",children:[e.jsx("button",{className:"proj-act",type:"button",disabled:d,onClick:n,children:t("common.cancel")}),e.jsx("button",{className:"proj-act primary",type:"submit",disabled:!p,children:t(d?"projects.addBusy":"projects.addSubmit")})]})]})})}function ue({p:a,onRefresh:n,t}){const[o,c]=r.useState(null),[s,f]=r.useState(""),[j,h]=r.useState(!1),[d,x]=r.useState(null),[v,m]=r.useState(!1),[E,k]=r.useState(0),[I,F]=r.useState(a.identity.icon),[S,C]=r.useState(!1),[P,N]=r.useState(null);r.useEffect(()=>{let i=!0;return c(null),x(null),m(!1),se(a.id).then(p=>{if(i){if(!p.ok){x(p.error==="network"?t("projects.actionFailed"):p.error);return}c({content:p.content,revision:p.revision}),f(p.content),F(a.identity.icon)}}),()=>{i=!1}},[a.id,a.identity.icon,E,t]);let y=!1;try{const i=JSON.parse(s);y=!i||typeof i!="object"||Array.isArray(i)}catch{y=!0}const R=!!o&&s!==o.content,l=async()=>{var p,b;if(!o||y||!R||j)return;h(!0),x(null),m(!1);const i=await ne(a.id,s,o.revision);if(h(!1),!i.ok){x(i.error==="network"?t("projects.actionFailed"):i.error);return}c({content:i.content,revision:i.revision}),f(i.content),m(!0);try{F(((b=(p=JSON.parse(i.content))==null?void 0:p.dashboard)==null?void 0:b.icon)||a.identity.icon)}catch{}n()},g=async i=>{if(!o||S)return!1;const p=I;F(i),C(!0),N(null),m(!1);const b=await ce(a.id,i,o.revision);return C(!1),b.ok?(c({content:b.content,revision:b.revision}),f(b.content),F(b.identity.icon),m(!0),n(),!0):(F(p),N(b.error==="network"?t("projects.actionFailed"):b.error),!1)};return e.jsxs("div",{className:"proj-drawer proj-config",children:[e.jsxs("div",{className:"proj-config-head",children:[e.jsx("code",{children:"spexcode.json"}),v&&e.jsx("span",{className:"proj-op-status ok",children:t("projects.configSaved")})]}),o?e.jsxs(e.Fragment,{children:[e.jsx("textarea",{className:y?"proj-config-editor invalid":"proj-config-editor",value:s,onChange:i=>{f(i.target.value),m(!1),x(null)},"aria-label":t("projects.configEditor"),spellCheck:!1,disabled:j}),e.jsxs("div",{className:"proj-setup-row",children:[e.jsx("button",{className:"proj-act primary",type:"button",disabled:!R||y||j,onClick:l,children:t(j?"projects.configSaving":"projects.configSave")}),e.jsx("button",{className:"proj-act",type:"button",disabled:j,onClick:()=>k(i=>i+1),children:t("projects.configReload")}),y&&e.jsx("span",{className:"proj-err",children:t("projects.configInvalid")}),d&&e.jsx("span",{className:"proj-err",children:d})]}),e.jsx(H,{value:I,onChange:g,label:t("projects.projectIcon"),editLabel:t("projects.editProjectIcon"),name:`project-icon-${a.id}`,disabled:j||S}),P&&e.jsx("span",{className:"proj-err",children:P})]}):e.jsxs("div",{className:"proj-setup-row",children:[!d&&e.jsx("span",{className:"proj-dim",children:t("projects.configLoading")}),d&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"proj-err",children:d}),e.jsx("button",{className:"proj-act",type:"button",onClick:()=>k(i=>i+1),children:t("projects.configReload")})]})]})]})}function me({p:a,busyOp:n,run:t,result:o,t:c}){const[s,f]=r.useState([]),j=h=>f(d=>d.includes(h)?d.filter(x=>x!==h):[...d,h]);return e.jsxs("div",{className:"proj-drawer proj-setup",children:[e.jsxs("div",{className:"proj-setup-row",children:[e.jsx("span",{className:"proj-dim",children:c("projects.harnessLabel")}),M.map(h=>e.jsx("button",{type:"button",className:s.includes(h)?"proj-act on":"proj-act","aria-pressed":s.includes(h),disabled:!!n,onClick:()=>j(h),children:h},h))]}),e.jsxs("div",{className:"proj-setup-row",children:[e.jsx("button",{className:"proj-act primary",type:"button",disabled:!!n||!s.length,title:s.length?void 0:c("projects.harnessRequired"),onClick:()=>t("init",()=>te(a.id,s.join(","))),children:c(n==="init"?"projects.running":"projects.init")}),e.jsx("button",{className:"proj-act",type:"button",disabled:!!n,onClick:()=>t("doctor",()=>ae(a.id)),children:c(n==="doctor"?"projects.running":"projects.doctor")})]}),o&&e.jsxs("div",{className:"proj-op-result proj-full",children:[e.jsx("div",{className:o.ok?"proj-op-status ok":"proj-op-status fail",children:o.ok?c("projects.opOk",{op:c(`projects.${o.op}`)}):c("projects.opFail",{op:c(`projects.${o.op}`),code:o.code??"?"})}),o.output?e.jsx("pre",{className:"proj-log",children:o.output}):null]})]})}function he({project:a,busy:n,error:t,onClose:o,onRemove:c,t:s}){const[f,j]=r.useState(""),[h,d]=r.useState(!1),x=`REMOVE ${a.identity.title}`,v=h&&f===x&&!n;return e.jsx(T,{title:s("projects.removeTitle"),closeLabel:s("common.close"),onClose:()=>{n||o()},className:"proj-remove-modal",children:e.jsxs("div",{className:"proj-remove-copy",children:[e.jsx("p",{className:"proj-remove-warning",children:s("projects.removeWarning")}),e.jsx("p",{children:s("projects.removeKeepsFiles")}),e.jsx("p",{children:s("projects.removeStopsFirst")}),e.jsxs("label",{className:"proj-remove-check",children:[e.jsx("input",{type:"checkbox",checked:h,onChange:m=>d(m.target.checked),disabled:n}),e.jsx("span",{children:s("projects.removeUnderstand")})]}),e.jsxs("label",{className:"proj-remove-confirm",children:[e.jsx("span",{children:s("projects.removeTypePrompt")}),e.jsx("code",{children:x}),e.jsx("input",{value:f,onChange:m=>j(m.target.value),"aria-label":s("projects.removeTypeLabel"),autoComplete:"off",spellCheck:!1,disabled:n})]}),t&&e.jsx("div",{className:"proj-err",children:t}),e.jsxs("div",{className:"proj-remove-actions",children:[e.jsx("button",{className:"proj-act",type:"button",disabled:n,onClick:o,children:s("common.cancel")}),e.jsx("button",{className:"proj-act danger",type:"button",disabled:!v,onClick:()=>c(f),children:s(n?"projects.removeBusy":"projects.removeConfirm")})]})]})})}function xe({p:a,health:n,onRefresh:t,t:o}){const[c,s]=r.useState(null),[f,j]=r.useState(!1),[h,d]=r.useState(null),[x,v]=r.useState(null),[m,E]=r.useState(null),[k,I]=r.useState(!1),[F,S]=r.useState(!1),[C,P]=r.useState(null),N=a.id===J,y=a.online===!1,R=y?"stopped":n||"probing",l=async p=>{j(!0),v(null);const b=await p();j(!1),b.ok?s(null):v(b.error||o("projects.actionFailed")),t()},g=async(p,b)=>{d(p),v(null),E(null);const L=await b();d(null),p!=="serve"?E({op:p,ok:L.ok,code:L.code,output:L.output||(L.ok?"":L.error||"")}):L.ok||v(L.error||o("projects.actionFailed")),t()},i=async p=>{S(!0),P(null);const b=await oe(a.id,p);if(S(!1),!b.ok){P(b.error||o("projects.actionFailed"));return}I(!1),t()};return e.jsxs("li",{className:N?"proj-row current":"proj-row",children:[e.jsxs("div",{className:"proj-row-main",children:[e.jsx("span",{className:`proj-health h-${R}`,"data-tip":o(`projects.health.${R}`)}),e.jsx(D,{icon:a.identity.icon,size:26}),e.jsx("span",{className:"proj-name",children:a.identity.title}),a.gated&&e.jsx(B,{name:"lock",size:12,className:"proj-locked"}),N&&e.jsx("span",{className:"proj-tag",children:o("projects.current")}),e.jsx("span",{className:"proj-path",title:a.id,children:a.root||a.id}),e.jsxs("span",{className:"proj-actions",children:[e.jsx(G,{icon:"settings",label:o("projects.configTitle"),className:c==="config"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{s(p=>p==="config"?null:"config"),v(null)}}),e.jsx(G,{icon:"terminal",label:o("projects.setupTitle"),className:c==="setup"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{s(p=>p==="setup"?null:"setup"),v(null)}}),e.jsx(G,{icon:"lock",label:o("projects.passwordTitle"),className:c==="pw"?"proj-act icon on":"proj-act icon",size:13,onClick:()=>{s(p=>p==="pw"?null:"pw"),v(null)}}),y?e.jsx("button",{className:"proj-act primary",type:"button",disabled:!!h,onClick:()=>g("serve",()=>ie(a.id)),children:o(h==="serve"?"projects.startBusy":"projects.start")}):e.jsx("a",{className:"proj-act primary",href:U(a.id),children:o("projects.open")})]})]}),x&&e.jsx("div",{className:"proj-err",children:x}),c==="pw"&&e.jsx(O,{t:o,busy:f,placeholder:o("projects.passwordPlaceholder"),onSet:p=>l(()=>de(a.id,p)),onClear:()=>l(()=>le(a.id))}),c==="config"&&e.jsx(ue,{p:a,onRefresh:t,t:o}),c==="config"&&e.jsxs("div",{className:"proj-remove-disclosure",children:[e.jsx("button",{className:"proj-remove-link",type:"button",onClick:()=>{P(null),I(!0)},children:o("projects.removeRegistration")}),e.jsx("span",{children:o("projects.removeRegistrationHint")})]}),c==="setup"&&e.jsx(me,{p:a,busyOp:h,run:g,result:m,t:o}),k&&e.jsx(he,{project:a,busy:F,error:C,onClose:()=>I(!1),onRemove:i,t:o})]})}function fe({gateway:a,onRefresh:n,t}){const[o,c]=r.useState(a.identity.icon),[s,f]=r.useState(!1),[j,h]=r.useState(null);r.useEffect(()=>{c(a.identity.icon)},[a.identity.icon]);const d=async x=>{if(s||!a.revision)return!1;const v=o;c(x),f(!0),h(null);const m=await re(x,a.revision);return f(!1),m.ok?(c(m.gateway.identity.icon),n(),!0):(c(v),h(m.error==="network"?t("projects.actionFailed"):m.error),!1)};return e.jsxs("div",{className:"proj-gateway-identity",children:[e.jsx(H,{value:o,onChange:d,label:t("projects.gatewayIcon"),editLabel:t("projects.editGatewayIcon"),name:"gateway-icon",fallback:"gateway",disabled:s||!a.revision}),j&&e.jsx("span",{className:"proj-err",children:j})]})}function Ne(){const a=q(),[n,t]=r.useState({kind:"loading"}),[o,c]=r.useState({}),[s,f]=r.useState(null),[j,h]=r.useState(!1),[d,x]=r.useState(!1),[v,m]=r.useState(null),[E,k]=r.useState(1),[I,F]=r.useState(0),S=r.useRef(0),C=r.useCallback(async()=>{const l=++S.current,g=await _();return l!==S.current?null:(g.state==="ok"?(t({kind:"ok",adminGated:g.adminGated,gateway:g.gateway,projects:g.projects}),g.projects.filter(i=>i.online!==!1).forEach(i=>{K(i.id).then(p=>{l===S.current&&c(b=>({...b,[i.id]:p}))})})):g.state==="denied"?t({kind:"denied",reason:g.reason}):t(i=>i.kind==="ok"?i:{kind:"absent"}),g)},[]);r.useEffect(()=>{let l,g=!0,i=!1;const p=async()=>{const z=await C();return(z==null?void 0:z.state)==="denied"&&(i=!0,l&&(clearInterval(l),l=void 0)),z};(async()=>{const z=await p();g&&(z==null?void 0:z.state)!=="denied"&&(l=setInterval(p,Q))})();const L=()=>{!document.hidden&&!i&&p()};return document.addEventListener("visibilitychange",L),()=>{g=!1,l&&clearInterval(l),document.removeEventListener("visibilitychange",L)}},[C,I]);const P=async l=>{x(!0),m(null);const g=await l();x(!1),g.ok?f(null):m(g.error||a("projects.actionFailed")),C()},N=V(n.kind==="ok"?n.projects:[],E);r.useEffect(()=>{N.page!==E&&k(N.page)},[N.page,E]);const y=n.kind==="loading"?e.jsx("div",{className:"loading",children:a("hud.loading")}):n.kind==="denied"?e.jsx(W,{scope:"admin",locked:n.reason==="locked",onUnlocked:()=>F(l=>l+1)}):n.kind==="absent"?e.jsx("div",{className:"proj-empty",children:e.jsx("p",{children:a("projects.absent")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"proj-head",children:[e.jsx("span",{className:"proj-count",children:a("projects.count",{n:n.projects.length})}),e.jsxs("button",{className:j?"proj-act on":"proj-act",onClick:()=>h(!0),children:[e.jsx(B,{name:"plus",size:12})," ",a("projects.add")]}),e.jsxs("button",{className:s==="admin"?"proj-act on":"proj-act",onClick:()=>{f(l=>l==="admin"?null:"admin"),m(null)},children:[e.jsx(B,{name:"lock",size:12})," ",a("projects.adminPassword")]})]}),!n.adminGated&&e.jsx("div",{className:"proj-hint",children:a("projects.adminUngated")}),s==="admin"&&e.jsxs("div",{className:"proj-admin-pw",children:[e.jsx(O,{t:a,busy:d,placeholder:a("projects.adminPasswordPlaceholder"),onSet:l=>P(()=>Y(l)),onClear:()=>P(()=>X())}),v&&e.jsx("div",{className:"proj-err",children:v})]}),n.projects.length?e.jsx("ul",{className:"proj-list",children:N.items.map(l=>e.jsx(xe,{p:l,health:o[l.id],onRefresh:C,t:a},l.id))}):e.jsx("div",{className:"proj-empty",children:e.jsx("p",{children:a("projects.empty")})}),N.pageCount>1&&e.jsxs("nav",{className:"proj-pagination","aria-label":a("projects.pagination"),children:[e.jsx(G,{icon:"arrow-left",label:a("projects.previousPage"),className:"proj-act icon",size:14,disabled:N.page===1,onClick:()=>k(l=>l-1)}),e.jsx("span",{className:"proj-page-label",children:a("projects.pageOf",{page:N.page,pages:N.pageCount})}),e.jsx(G,{icon:"chevron-right",label:a("projects.nextPage"),className:"proj-act icon",size:14,disabled:N.page===N.pageCount,onClick:()=>k(l=>l+1)})]}),e.jsx("div",{className:"proj-page-details","aria-label":a("projects.gatewaySettings"),children:e.jsx(fe,{gateway:n.gateway,onRefresh:C,t:a})})]}),R=n.kind==="ok"?n.gateway.identity:{icon:"gateway"};return e.jsxs("div",{className:"page-pane page-projects",children:[e.jsx(pe,{className:"page-projects-scroll",children:e.jsxs("div",{className:"proj-body",children:[e.jsxs("div",{className:"cred-brand proj-brand",children:[e.jsx(D,{icon:R.icon,fallback:"gateway",size:30}),e.jsx("span",{children:"$ spexcode"})]}),e.jsx("h1",{className:"page-title",children:a("projects.title")}),y]})}),j&&e.jsx(je,{t:a,onClose:()=>h(!1),onAdded:()=>{h(!1),C()}})]})}export{Ne as default};
@@ -0,0 +1,8 @@
1
+ import{r as f,am as je,al as ke,u as Le,i as Ae,j as t,an as we,ao as Ne,I as G,a as ve}from"./index-Co8kmYQY.js";import{a2 as Ee,aY as Ce,aZ as De,ak as Me,I as ae,a_ as Te,d as Pe,e as $e,aM as me,aO as Ie,aP as ne,ag as Re,ah as de,a$ as ze,b0 as Be,b1 as Oe,b2 as qe,a9 as Ke,aQ as Fe,b3 as He}from"./tabs-C4phsoFs.js";import{e as Ye,b as re,n as pe}from"./App-BBoP1IyU.js";function as(e,n){const s=typeof e=="string"?e:"",c=typeof n=="string"?n:"";if(!s||!c)return null;const i=s.indexOf(c);if(i<0)return null;const o=s.slice(0,i).split(`
2
+ `).length,u=o+c.split(`
3
+ `).length-1;return ee(s,o,u).trim()===c.trim()?{startLine:o,endLine:u}:null}function ee(e,n,s){const c=(typeof e=="string"?e:"").split(`
4
+ `);return!Number.isInteger(n)||!Number.isInteger(s)||n<1||s<n||s>c.length?"":c.slice(n-1,s).join(`
5
+ `)}function fe(e,n){if(!e||!n||e.collapsed)return null;const s=[...n.querySelectorAll("[data-l0]")].filter(u=>{try{return e.intersectsNode(u)}catch{return!1}}),c=s.filter(u=>!s.some(l=>l!==u&&u.contains(l)));let i=1/0,o=-1/0;for(const u of c){const l=Number(u.dataset.l0),x=Number(u.dataset.l1);!Number.isInteger(l)||!Number.isInteger(x)||l<1||x<l||(l<i&&(i=l),x>o&&(o=x))}return o>=i?{startLine:i,endLine:o}:null}function Xe(e,n,s){if(!(e!=null&&e.id)||!(e!=null&&e.path)||!s)return null;const c=ee(n,s.startLine,s.endLine);return c.trim()?{node:e.id,path:e.path,startLine:s.startLine,endLine:s.endLine,text:c}:null}const Ge=["edit","polish","explain"],te=new Map;function Je(e,n,{embedded:s=!1,publicGraph:c=!1}={}){const i=`${c?"public:":""}${e}@${n??""}`,[o,u]=f.useState(()=>te.get(i)??null);return f.useEffect(()=>{if(s||!e)return;const l=te.get(i);if(l){u(l);return}u(null);let x=!0;return(c?je(e):fetch(ke(e,"content")).then(j=>j.ok?j.json():Promise.reject(j.status))).then(j=>{te.set(i,j),x&&u(j)}).catch(()=>{x&&u({body:"",parts:null})}),()=>{x=!1}},[s,e,n,i,c]),o}const Z=8;function se(e,n,s){const c=f.useRef(null),[i,o]=f.useState({left:e,top:n,visibility:"hidden"});return f.useLayoutEffect(()=>{var l;const u=(l=c.current)==null?void 0:l.getBoundingClientRect();u&&o({left:Math.max(Z,Math.min(e,window.innerWidth-u.width-Z)),top:Math.max(Z,Math.min(n,window.innerHeight-u.height-Z)),visibility:"visible"})},[e,n,...s]),[c,i]}const Se=[{key:"send",icon:"send",preset:null,jump:!1},{key:"editSend",icon:"message-square",preset:"edit",jump:!1},{key:"explain",icon:"info",preset:"explain",jump:!0},{key:"manual",icon:"pencil",preset:null,jump:!1}];function Ve(e,n){var i;const s=n?e.filter(o=>o.node===n):[];return((i=[...s.length?s:e].sort((o,u)=>(u.created||0)-(o.created||0))[0])==null?void 0:i.id)||"new"}function rs({node:e,hostRef:n,codeSelection:s=null,onCodeSelectionClear:c}){const i=Le(),{sessions:o=[],specs:u=[]}=Ye(),{launchers:l,launcher:x,pickLauncher:z}=Ee(),{notify:j}=Ae(),C=Je(e==null?void 0:e.id,e==null?void 0:e.version),y=(e==null?void 0:e.body)??(C==null?void 0:C.body)??"",k=!!s||(e==null?void 0:e.body)!=null||C!==null,M=f.useRef(null);s&&(M.current=s);const w=f.useRef(null),[p,I]=f.useState(null),[H,T]=f.useState(!1),[B,O]=f.useState(!1),[m,P]=f.useState(null),[Y,q]=f.useState(""),[R,W]=f.useState(""),[N,K]=f.useState(!1),[_,D]=f.useState(!1),[J,v]=f.useState(null),F=s||(H?M.current:null),r=o.filter(a=>Ce(a)==="live"),L=f.useCallback(()=>{P(null),T(!1),O(!1),v(null),D(!1)},[]),$=f.useCallback(()=>{I(null),T(!1),O(!1),w.current=null,M.current=null,c==null||c(),L()},[L,c]);f.useEffect(()=>{s&&(T(!1),O(!1)),s||(P(null),v(null),D(!1))},[s==null?void 0:s.path,s==null?void 0:s.startLine,s==null?void 0:s.endLine,s==null?void 0:s.text]);const X=f.useRef(!1);X.current=!!m,f.useEffect(()=>{const a=n==null?void 0:n.current;if(!a)return;const h=()=>{if(X.current)return;const b=document.getSelection();if(!b||b.isCollapsed||b.rangeCount===0){I(null),T(!1),w.current=null;return}const A=b.getRangeAt(0);if(!a.contains(A.commonAncestorContainer))return;const E=fe(A,a);if(!E){I(null),T(!1),w.current=null;return}const S=A.getBoundingClientRect(),V={lines:E,x:S.left,y:S.top};I(V),w.current=V,T(!1)},d=b=>{b.type==="mouseup"&&b.button!==0||window.setTimeout(h,0)};return a.addEventListener("mouseup",d),a.addEventListener("keyup",d),()=>{a.removeEventListener("mouseup",d),a.removeEventListener("keyup",d)}},[n]),f.useEffect(()=>{const a=n==null?void 0:n.current;if(!a)return;const h=d=>{var le,ue,oe;if(X.current)return;const b=s||M.current;if(b){d.preventDefault(),P(null),O(!1),T(!0);const ce={lines:{startLine:b.startLine,endLine:b.endLine},x:d.clientX,y:d.clientY+18};I(ce),w.current=ce;return}const A=document.getSelection(),S=(A&&!A.isCollapsed&&A.rangeCount>0?fe(A.getRangeAt(0),a):null)||((le=w.current)==null?void 0:le.lines);if(!S){if(!e||(oe=(ue=d.target).closest)!=null&&oe.call(ue,"a,button,input,textarea,select"))return;d.preventDefault(),P(null),T(!1),O(!0),I({lines:null,x:d.clientX,y:d.clientY+18}),w.current=null;return}d.preventDefault(),P(null),O(!1),T(!0);const V={lines:S,x:d.clientX,y:d.clientY+18};I(V),w.current=V};return a.addEventListener("contextmenu",h,!0),()=>a.removeEventListener("contextmenu",h,!0)},[n,s==null?void 0:s.path,s==null?void 0:s.startLine,s==null?void 0:s.endLine,s==null?void 0:s.text]),re((m==null?void 0:m.kind)==="manual",L),re(!!(p||F||B)&&!m,$),f.useEffect(()=>{if(!m)return;const a=h=>{var d,b;(b=(d=h.target).closest)!=null&&b.call(d,".pa-card")||L()};return document.addEventListener("mousedown",a,!0),()=>document.removeEventListener("mousedown",a,!0)},[m,L]),f.useEffect(()=>{if(!H&&!B||m)return;const a=d=>{var b,A;(A=(b=d.target).closest)!=null&&A.call(b,".pa-group")||$()},h=()=>$();return window.addEventListener("click",a),window.addEventListener("contextmenu",h,!0),()=>{window.removeEventListener("click",a),window.removeEventListener("contextmenu",h,!0)}},[H,B,m,$]);const xe=e&&k?{node:e.id,path:e.path,startLine:1,endLine:Math.max(1,y.split(`
6
+ `).length),text:y}:null,g=F||(p==null?void 0:p.lines)&&(k?Xe(e,y,p.lines):{node:e==null?void 0:e.id,path:e==null?void 0:e.path,startLine:p.lines.startLine,endLine:p.lines.endLine,text:""})||(B?xe:null),Q=!F&&!!(p||B)&&!k,ie=(a,h)=>{const d=(h==null?void 0:h.clientX)??(p==null?void 0:p.x)??(g==null?void 0:g.x)??0,b=((h==null?void 0:h.clientY)??(p==null?void 0:p.y)??(g==null?void 0:g.y)??0)+14;if(v(null),a.key==="manual"&&!F){q(ee(y,p.lines.startLine,p.lines.endLine)),P({kind:"manual",x:d,y:b});return}q(a.preset?i(`proseActions.prompt.${a.preset}`):""),r.some(A=>A.id===R)||W(Ve(r,e==null?void 0:e.id)),K(a.jump),P({kind:"send",x:d,y:b})},ye=({id:a,launcher:h})=>{W(a),a==="new"&&h&&l.some(d=>d.name===h)&&z(h)},ge=async()=>{var A;if(!g)return;const a=R||"new",h=De(Y,[g]);if(a==="new"){D(!0),v(null);const E=await Me(h,x);if(D(!1),!E.ok){v(E.error||i("proseActions.sendFailed"));return}j(i("proseActions.sentTo",{name:ae(E.session)||((A=E.id)==null?void 0:A.slice(0,8))||i("proseActions.newSession")}),{kind:"success"}),$(),E.id&&(Te("sessions",E.id,null),pe("sessions",E.id));return}D(!0),v(null);const d=await we(a,h);if(D(!1),!d.ok){v(d.error||i("proseActions.sendFailed"));return}const b=ae(r.find(E=>E.id===a))||a.slice(0,8);j(i("proseActions.sentTo",{name:b}),{kind:"success"}),$(),N&&pe("sessions",a)},he=async()=>{if(p){D(!0),v(null);try{const a=await Ne(e.id,{startLine:p.lines.startLine,endLine:p.lines.endLine,original:ee(y,p.lines.startLine,p.lines.endLine),replacement:Y});D(!1),j(a.changed?i("proseActions.committed",{sha:(a.commit||"").slice(0,7)}):i("proseActions.noChange"),{kind:a.changed?"success":"info"}),$()}catch(a){D(!1),v(a!=null&&a.current?`${a.message}
7
+
8
+ ${a.current}`:String((a==null?void 0:a.message)||a))}}},be=async()=>{await Pe($e(e.id))&&(O(!1),j(i("proseActions.nodeCopied"),{kind:"success"}))};if(!e&&!F||!g&&!Q&&!B)return null;const U={lines:(p==null?void 0:p.lines)||{startLine:(g==null?void 0:g.startLine)||1,endLine:(g==null?void 0:g.endLine)||1},x:(p==null?void 0:p.x)??(g==null?void 0:g.x)??0,y:(p==null?void 0:p.y)??(g==null?void 0:g.y)??0};return t.jsxs(t.Fragment,{children:[!m&&H&&g&&t.jsx(We,{t:i,hit:U,disabled:Q,manualEnabled:!F,onPick:ie}),!m&&B&&t.jsx(_e,{t:i,hit:U,disabled:Q,onSend:a=>ie({key:"send",preset:null,jump:!1},a),onCopy:be}),!m&&H&&Q&&t.jsx("span",{className:"pa-loading",role:"status",style:{left:U.x,top:U.y},children:t.jsx("span",{className:"spinner","aria-label":i("common.loading")})}),(m==null?void 0:m.kind)==="send"&&t.jsx(Qe,{t:i,panel:m,node:e,selection:g,specs:u,sessions:o,live:r,launchers:l,launcher:x,target:R,onAddress:ye,jump:N,setJump:K,draft:Y,setDraft:q,busy:_,error:J,onSend:ge,onRemove:$,onClose:L}),(m==null?void 0:m.kind)==="manual"&&t.jsx(es,{t:i,panel:m,node:e,lines:p.lines,draft:Y,setDraft:q,busy:_,error:J,onCommit:he,onClose:L})]})}function We({t:e,hit:n,onPick:s,disabled:c=!1,manualEnabled:i=!0}){const[o,u]=se(n.x,n.y-44,[n.lines.startLine,n.lines.endLine]);return t.jsx("div",{ref:o,className:"pa-group",role:"menu","aria-label":e("proseActions.groupLabel"),style:u,children:Se.map(l=>t.jsxs("button",{type:"button",role:"menuitem",className:"pa-act",disabled:c||l.key==="manual"&&!i,onMouseDown:x=>x.preventDefault(),onClick:x=>s(l,x),children:[t.jsx(G,{name:l.icon,size:13,className:"pa-act-icon"}),e(`proseActions.act.${l.key}`)]},l.key))})}function _e({t:e,hit:n,onSend:s,onCopy:c,disabled:i=!1}){const[o,u]=se(n.x,n.y-44,[]);return t.jsxs("div",{ref:o,className:"pa-group pa-node-group",role:"menu","aria-label":e("proseActions.nodeGroupLabel"),style:u,children:[t.jsxs("button",{type:"button",role:"menuitem",className:"pa-act",disabled:i,onMouseDown:l=>l.preventDefault(),onClick:s,children:[t.jsx(G,{name:"send",size:13,className:"pa-act-icon"}),e("proseActions.nodeSend")]}),t.jsxs("button",{type:"button",role:"menuitem",className:"pa-act",onMouseDown:l=>l.preventDefault(),onClick:c,children:[t.jsx(G,{name:"copy",size:13,className:"pa-act-icon"}),e("proseActions.nodeCopy")]})]})}function Qe({t:e,panel:n,node:s,selection:c,specs:i,sessions:o,live:u,launchers:l,launcher:x,target:z,onAddress:j,jump:C,setJump:y,draft:k,setDraft:M,busy:w,error:p,onSend:I,onRemove:H,onClose:T}){const[B,O]=se(n.x,n.y,[]),m=f.useRef(null),P=n.y>window.innerHeight*.55,[Y,q]=f.useState(!1);f.useEffect(()=>{var r;(r=m.current)==null||r.focus()},[]);const R=me({inputRef:m,value:k,setValue:M,specs:i,sessions:o,launchers:l,focusId:s==null?void 0:s.id,up:P}),W=Ge.map(r=>({name:r,description:e(`proseActions.prompt.${r}`),kind:"preset"})),[N,K]=f.useState(null),_=r=>K(r?He(r.value,r.selectionStart,W):null),D=r=>{if(!r||!N)return;const L=e(`proseActions.prompt.${r.name}`);M(k.slice(0,N.start)+L+k.slice(N.end)),K(null);const $=N.start+L.length;requestAnimationFrame(()=>{const X=m.current;X&&(X.focus(),X.setSelectionRange($,$))})},J=r=>{R.sync(r),_(r)},v=r=>Fe(m.current,r,M,J);re(!0,()=>{N?K(null):R.menu?R.dismiss():Y?q(!1):T()});const F=r=>{var L;j(r),q(!1),(L=m.current)==null||L.focus()};return t.jsx(Ie,{ref:B,className:"pa-card pa-send",role:"dialog","aria-label":e("proseActions.sendLabel"),style:O,preview:t.jsx(Oe,{selection:c,onRemove:H}),editor:t.jsxs("div",{className:"fv-tawrap",children:[t.jsx(Re,{ref:m,className:"pa-message",rows:1,value:k,placeholder:e("proseActions.messagePlaceholder"),disabled:w,spellCheck:!1,onChange:r=>{M(r.target.value),J(r.target)},onSelect:r=>J(r.target),onBlur:()=>{R.close(),K(null)},onKeyDown:r=>{de(r)||ze(r,N,K,D)||R.onKeyDown(r)||r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),I())}}),R.menuEl,N&&t.jsx(Be,{menu:N,up:P,head:N.query?`/${N.query}`:e("session.menuPresets"),onPick:D,onHover:r=>K(L=>L&&{...L,index:r})}),p&&t.jsx("div",{className:"pa-error",role:"alert",children:p})]}),footer:t.jsxs("div",{className:"pa-tools",children:[Y?t.jsx(Ze,{t:e,live:u,launchers:l,launcher:x,up:P,onPick:F,onCancel:()=>{var r;q(!1),(r=m.current)==null||r.focus()}}):t.jsx(Ue,{t:e,live:u,launcher:x,target:z,onOpen:()=>q(!0)}),t.jsx(ne,{label:e("thread.mentionActor"),disabled:w,onClick:()=>v("@"),children:"@"}),t.jsx(ne,{label:e("thread.mentionNode"),disabled:w,onClick:()=>v("[["),children:"[["}),t.jsx(ne,{label:e("proseActions.presets"),disabled:w,onClick:()=>v("/"),children:"/"}),t.jsxs("button",{type:"button",className:"pa-jump","aria-pressed":C,"data-tip":e("proseActions.jumpTip"),onMouseDown:r=>r.preventDefault(),onClick:()=>y(!C),children:[t.jsx(G,{name:"check",size:11,className:"pa-jump-mark"}),e("proseActions.sendJump")]}),t.jsx(ve,{icon:"send",size:14,className:"icon-btn primary pa-submit",label:e("proseActions.send"),disabled:w,onMouseDown:r=>r.preventDefault(),onClick:I})]})})}function Ue({t:e,live:n,launcher:s,target:c,onOpen:i}){const o=n.find(l=>l.id===c),u=o?qe(o):null;return t.jsxs("button",{type:"button",className:"pa-address","aria-label":e("proseActions.target"),"data-tip":e("proseActions.addressTip"),onMouseDown:l=>l.preventDefault(),onClick:i,children:[o?t.jsx(Ke,{seed:o.id,status:u.status,size:13}):t.jsx(G,{name:"plus",size:12,className:"pa-address-new"}),t.jsx("span",{className:"pa-address-name",children:o?ae(o)||o.id.slice(0,8):e("proseActions.newWith",{launcher:s||""})}),o&&t.jsx("span",{className:"pa-address-state",style:{color:u.color},"aria-label":e(`status.${u.status}`),children:u.glyph}),t.jsx(G,{name:"chevron-down",size:11,className:"pa-address-caret"})]})}function Ze({t:e,live:n,launchers:s,launcher:c,up:i,onPick:o,onCancel:u}){const l=f.useRef(null),[x,z]=f.useState("@"),j=me({inputRef:l,value:x,setValue:z,sessions:n,launchers:s,up:i});f.useEffect(()=>{const y=l.current;y&&(y.focus(),y.setSelectionRange(1,1),j.sync(y))},[]);const C=y=>{const k=/^@(?:new(?::(\S+))?|(\S+))\s*$/.exec(y);return k?k[2]?n.some(M=>M.id===k[2])?(o({id:k[2]}),!0):!1:(o({id:"new",launcher:k[1]||c}),!0):!1};return f.useEffect(()=>{/\s$/.test(x)&&C(x)},[x]),t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:l,className:"pa-address pa-address-input",value:x,"aria-label":e("proseActions.target"),spellCheck:!1,onChange:y=>{z(y.target.value),j.sync(y.target)},onSelect:y=>j.sync(y.target),onBlur:u,onKeyDown:y=>{de(y)||j.onKeyDown(y)||y.key==="Enter"&&(y.preventDefault(),C(x)||u())}}),j.menuEl]})}function es({t:e,panel:n,node:s,lines:c,draft:i,setDraft:o,busy:u,error:l,onCommit:x,onClose:z}){const[j,C]=se(n.x,n.y,[]),y=f.useRef(null);return f.useEffect(()=>{var k;(k=y.current)==null||k.focus()},[]),t.jsxs("div",{ref:j,className:"pa-card pa-edit",role:"dialog","aria-label":e("proseActions.editLabel"),style:C,children:[t.jsxs("div",{className:"pa-edit-head",children:[t.jsx(G,{name:"pencil",size:12}),t.jsx("span",{className:"pa-edit-where",children:s.path}),t.jsx("span",{className:"pa-edit-lines",children:e("proseActions.lines",{a:c.startLine,b:c.endLine})})]}),t.jsx("textarea",{ref:y,className:"pa-input pa-edit-input",rows:10,value:i,spellCheck:!1,onChange:k=>o(k.target.value)}),l&&t.jsx("div",{className:"pa-error",role:"alert",children:l}),t.jsxs("div",{className:"pa-foot",children:[t.jsx("span",{className:"pa-note",children:e("proseActions.editNote")}),t.jsx("button",{type:"button",className:"pa-btn",onClick:z,children:e("common.cancel")}),t.jsx("button",{type:"button",className:"pa-btn pa-go",disabled:u,onClick:x,children:e(u?"proseActions.committing":"proseActions.commit")})]})]})}export{rs as P,as as l,Je as u};
@@ -0,0 +1 @@
1
+ import{J as k,r as d,j as e,aq as T}from"./index-Co8kmYQY.js";import{d as y}from"./App-BBoP1IyU.js";import{b6 as w,b7 as E,b8 as v,b9 as C,ba as A,bb as F,bc as I,bd as _,be as L,bf as M,V as O,W as R,X as D,Y as P,bg as z,bh as U}from"./tabs-C4phsoFs.js";import{P as G}from"./Modal-oF4JAL6H.js";const m="spexcode.theme",p=[{code:"minimal",label:"Minimal",swatch:{ground:"#1b1b1b",paper:"#262626",ink:"#d1d1d1",accent:"#6c99bb"}},{code:"notion",label:"Notion",swatch:{ground:"#f7f7f5",paper:"#ffffff",ink:"#37352f",accent:"#2383e2"}},{code:"things",label:"Things",swatch:{ground:"#eceef0",paper:"#ffffff",ink:"#555e68",accent:"#2e80f2"}},{code:"tokyonight",label:"Tokyo Night",swatch:{ground:"#101018",paper:"#1a1b26",ink:"#a9b1d6",accent:"#7aa2f7"}},{code:"catppuccin",label:"Catppuccin",swatch:{ground:"#11111b",paper:"#1e1e2e",ink:"#cdd6f4",accent:"#89b4fa"}},{code:"everforest",label:"Everforest",swatch:{ground:"#232a2e",paper:"#333c43",ink:"#d3c6aa",accent:"#7fbbb3"}},{code:"gruvbox",label:"Gruvbox",swatch:{ground:"#151718",paper:"#282828",ink:"#ebdbb2",accent:"#83a598"}},{code:"rosepine",label:"Rosé Pine Dawn",swatch:{ground:"#eee4d9",paper:"#faf4ed",ink:"#575279",accent:"#56949f"}},{code:"dracula",label:"Dracula",swatch:{ground:"#191a21",paper:"#282a36",ink:"#f8f8f2",accent:"#bd93f9"}}],f=new Set(p.map(s=>s.code)),g="minimal";function H(){try{const s=localStorage.getItem(m);if(f.has(s))return s}catch{}return g}function K(s){const a=f.has(s)?s:g;try{document.documentElement.setAttribute("data-theme",a)}catch{}try{localStorage.setItem(m,a)}catch{}return a}function u({title:s,children:a}){return e.jsxs("section",{className:"set-sec",children:[e.jsx("h2",{className:"set-h",children:s}),a]})}function h({label:s,children:a}){return e.jsxs("div",{className:"set-row",children:[e.jsx("span",{className:"set-label",children:s}),e.jsx("div",{className:"set-control",children:a})]})}function b({label:s,value:a,options:l,onPick:i}){return e.jsx("div",{className:"set-seg",role:"group","aria-label":s,children:l.map(c=>e.jsx("button",{type:"button",className:c.value===a?"set-lang on":"set-lang","aria-pressed":c.value===a,onClick:()=>i(c.value),children:c.label},c.value))})}function $({t:s}){const[,a]=d.useState(0),[l,i]=d.useState(null),c=()=>a(t=>t+1);return y(t=>l?(t.preventDefault(),t.stopPropagation(),t.key==="Escape"?(i(null),!0):(["Shift","Control","Alt","Meta"].includes(t.key)||(M(l,{keys:[t.key]}),i(null),c()),!0)):!1,20),e.jsxs(u,{title:s("settings.secShortcuts"),children:[e.jsx("div",{className:"set-keys",children:O.map(t=>e.jsxs("div",{className:"set-key-row",children:[e.jsx("span",{className:"set-key-desc",children:s(t.desc)}),e.jsx("button",{className:`bind-cell${l===t.id?" capturing":""}${t.rebind?"":" fixed"}${z(t.id)?" custom":""}`,disabled:!t.rebind,onClick:()=>t.rebind&&i(t.id),children:l===t.id?e.jsx("span",{className:"bind-hint",children:s("settings.bindPrompt")}):R(t,D(t.id)).map((r,o)=>e.jsx("kbd",{children:P(r)},o))})]},t.id))}),e.jsxs("div",{className:"set-foot",children:[e.jsx("span",{className:"set-hint",children:s("settings.shortcutsHint")}),e.jsx("button",{className:"set-reset",onClick:()=>{U(),i(null),c()},children:s("settings.reset")})]})]})}function B({theme:s,on:a,onPick:l,label:i}){const{ground:c,paper:t,ink:r,accent:o}=s.swatch;return e.jsxs("button",{type:"button",className:a?"set-swatch on":"set-swatch","aria-pressed":a,onClick:l,children:[e.jsx("span",{className:"set-swatch-chip","aria-hidden":"true",style:{background:c},children:e.jsxs("span",{className:"set-swatch-paper",style:{background:t,color:r},children:[e.jsx("span",{className:"set-swatch-line",style:{background:r}}),e.jsx("span",{className:"set-swatch-line short",style:{background:o}})]})}),e.jsx("span",{className:"set-swatch-name",children:i})]})}function J(){const{t:s,lang:a,setLang:l}=k(),[i,c]=d.useState(H),[t,r]=d.useState(w),[o,S]=d.useState(E),x=n=>{K(n),c(n)},j=n=>r(_(n)),N=n=>S(L(n));return e.jsx(G,{className:"page-settings-scroll",children:e.jsxs("div",{className:"settings-body",children:[e.jsx("h1",{className:"page-title",children:s("settings.title")}),e.jsx(u,{title:s("settings.secLanguage"),children:e.jsx(h,{label:s("settings.uiLanguage"),children:e.jsx(b,{label:s("settings.secLanguage"),value:a,onPick:l,options:T.map(n=>({value:n.code,label:n.label}))})})}),e.jsx(u,{title:s("settings.secTheme"),children:e.jsx("div",{className:"set-swatches",role:"group","aria-label":s("settings.secTheme"),children:p.map(n=>e.jsx(B,{theme:n,label:s(n.label),on:n.code===i,onPick:()=>x(n.code)},n.code))})}),e.jsxs(u,{title:s("settings.secTerminal"),children:[e.jsx(h,{label:s("settings.defaultSessionSurface"),children:e.jsx(b,{label:s("settings.defaultSessionSurface"),value:o,onPick:N,options:[{value:v,label:s("session.tabTerminal")},{value:C,label:s("session.tabConversation")}]})}),e.jsx(h,{label:s("settings.terminalFontSize"),children:e.jsxs("label",{className:"set-terminal-font",children:[e.jsx("input",{type:"range",min:I,max:F,step:A,value:t,onChange:n=>j(n.target.value),"aria-label":s("settings.terminalFontSize")}),e.jsxs("output",{children:[t,"px"]})]})})]}),e.jsx($,{t:s})]})})}export{J as default};
@@ -0,0 +1 @@
1
+ import{u as d,r as n,j as s}from"./index-Co8kmYQY.js";import{S as m}from"./NodeView-CZYwYCCu.js";import{P as a}from"./ProseActions-CSG_3k1b.js";import{e as p}from"./App-BBoP1IyU.js";import"./tabs-C4phsoFs.js";import"./Modal-oF4JAL6H.js";import"./Thread-4tohzgUo.js";function w({param:i}){const r=d(),{specs:e}=p(),o=n.useMemo(()=>e==null?void 0:e.find(c=>c.id===i),[e,i]),t=n.useRef(null);return e!=null&&e.length?o?s.jsx("div",{className:"specview",children:s.jsxs("div",{className:"specview-prose",ref:t,children:[s.jsx(m,{node:o}),s.jsx(a,{node:o,hostRef:t})]})}):s.jsx("div",{className:"doc-empty",children:r("specView.missing",{id:i})}):s.jsx("div",{className:"doc-empty",children:r("hud.loading")})}export{w as default};
@@ -0,0 +1,9 @@
1
+ import{u as K,j as n,r as E,I as G,a as Q,ap as W}from"./index-Co8kmYQY.js";import{b4 as J,K as D,aF as X,a2 as Y,aM as Z,ag as ee,ah as se,b0 as te,aP as I,aO as le,aU as ne,aV as F,k as ae,a$ as re,aQ as ie,b5 as oe}from"./tabs-C4phsoFs.js";import{r as ce}from"./App-BBoP1IyU.js";const xe=Object.freeze({RESULT:"result",BLIND:"blind",UNMEASURED:"unmeasured",DEFERRED:"deferred",DANGLING:"dangling"}),ue=e=>{var l;return(l=e==null?void 0:e.evidence)!=null&&l.length?e.evidence:(e==null?void 0:e.blob)!=null?[{hash:e.blob,kind:e.blobKind||"image",state:e.blobState||"present"}]:[]},ke=e=>{const l=ue(e);return l.length?["video","image","transcript","data"].filter(o=>l.some(t=>t.kind===o)):["note"]},je=e=>String(e||"").length>22?`${String(e).slice(0,8)}…`:e;function ge(e,l,o){return o.map(t=>t==="section"?e.section:e.facets[t]).filter(t=>{var u;return(t==null?void 0:t.meaningful)!==!1&&(((u=t==null?void 0:t.options)==null?void 0:u.length)>1||(t==null?void 0:t.value)!=null&&t.value!==""&&t.value!=="all")}).map(t=>({key:t.key,label:t.label,value:t.value,active:t.value!=null&&t.value!==""&&t.value!=="all",options:t.options,clearLabel:t.value==="all"?null:void 0,onChange:u=>l({[t.key]:u||null})}))}const de=/^▶\s*(\d+):([0-5]?\d)(?:\s*·\s*([^\n]*))?/,_=/^!\[frame\]\(\/api\/(?:evidence|yatsu\/blob)\/[0-9a-f]{64}\)\n?/,pe=/\/api\/(?:evidence|yatsu\/blob)\/([0-9a-f]{64})/g,he=e=>{const l=Math.floor(e/1e3);return`${Math.floor(l/60)}:${String(l%60).padStart(2,"0")}`};function U(e){var h;const l=e||"",o=l.split(`
2
+ `,1)[0],t=de.exec(o);return t?{tMs:(parseInt(t[1],10)*60+parseInt(t[2],10))*1e3,step:((h=t[3])==null?void 0:h.trim())||null,label:o.trim(),rest:l.slice(o.length).replace(/^\n/,"")}:null}const H=(e,l)=>`▶${he(e)}${l?` · ${l}`:""}`,q=e=>[...(e||"").matchAll(pe)].map(l=>l[1]);function fe(e,l){if(!e)return null;if(e.step&&(l!=null&&l.length)){const o=l.find(t=>t.step===e.step);return o?{tMs:o.at,step:e.step,label:H(o.at,e.step),seekable:!0,degraded:!1}:{tMs:e.tMs,step:e.step,label:e.label,seekable:!1,degraded:!0}}return{tMs:e.tMs,step:e.step,label:e.label,seekable:!0,degraded:!1}}function Ne({originator:e,sessions:l=[],kind:o="issue",onOpenSession:t=null}){const u=K();if(!e)return null;const h=J(l,e),v=!!h,N=v?D[h.status]||D.working:D.offline,r=u(o==="eval"?"thread.originatorEval":"thread.originatorIssue",{by:e}),f=n.jsx("span",{className:"fv-originator-dot",style:{background:N},"aria-hidden":"true"});return n.jsx(X,{text:e,tip:r,label:r,lead:f,className:`fv-originator ${v?"alive":"offline"}${v&&t?" openable":""}`,onClick:v&&t?()=>t(e):null})}function Se({replies:e,onSeek:l,selIdx:o=null,activeIdx:t=null,onSelect:u=null,events:h=null,threadId:v=null,onRemarkChange:N=null}){const r=K(),[f,x]=E.useState(null),[b,k]=E.useState(null),w=async(c,y)=>{if(!f){x(y),k(null);try{const d=await W(c,y);d!=null&&d.ok?await(N==null?void 0:N()):k({ref:y,msg:(d==null?void 0:d.error)||`${c} failed`})}finally{x(null)}}};return e.map((c,y)=>{const d=c.rid!==void 0,T=d?c.resolved?" remark resolved":" remark open":"",S=`fv-reply${o===y?" sel":""}${t===y?" active":""}${T}`,m=d&&v?`${v}#${c.rid}`:null;return n.jsxs("div",{className:S,children:[n.jsxs("div",{className:"fv-reply-meta",children:[n.jsx("span",{className:"fv-reply-by",children:c.by}),c.at&&n.jsx("span",{className:"fv-reply-at",children:c.at}),d&&(c.resolved?n.jsxs("span",{className:"fv-remark-state resolved","data-tip":c.resolvedBy?r("thread.resolvedBy",{by:c.resolvedBy}):r("thread.resolved"),children:["✓ ",r("thread.resolved")]}):n.jsxs("span",{className:"fv-remark-state open","data-tip":r("thread.openRemark"),children:["● ",r("thread.openRemark")]})),m&&N&&!c.resolved&&(c.by==="human"?n.jsx("button",{type:"button",className:"fv-remark-act retract",disabled:!!f,"data-tip":r("thread.retractTitle"),onClick:()=>w("retract",m),children:r("thread.retract")}):n.jsx("button",{type:"button",className:"fv-remark-act resolve",disabled:!!f,"data-tip":r("thread.resolveTitle"),onClick:()=>w("resolve",m),children:r("thread.resolve")}))]}),b&&b.ref===m&&n.jsx("div",{className:"fv-error",children:b.msg}),c.body&&n.jsx("div",{className:"fvd-body",children:n.jsx(ne,{className:"doc-body",renderSpecRef:(p,A,g)=>{const a=ce("spec",p);return n.jsx("a",{className:"doc-link",href:a,...g,onClick:$=>ae($,a),children:p})},renderTimeAnchor:(p,A,g)=>{const a=fe({tMs:p.tMs,step:p.step,label:p.label},h),$=a!=null&&a.seekable&&l?()=>u?u(y,a.tMs):l(a.tMs):null,L=(a==null?void 0:a.label)||p.label;return $?n.jsx("button",{type:"button",className:"fv-anchor",...g,onClick:$,"data-tip":"seek the clip to this moment",children:L}):n.jsxs("span",{className:`fv-anchor static${a!=null&&a.degraded?" degraded":""}`,...g,"data-tip":a!=null&&a.degraded?r("thread.anchorDegraded"):void 0,children:[L,a!=null&&a.degraded?" ⚠":""]})},renderEvidence:(p,A,g)=>n.jsx("span",{className:"fv-reply-media","data-evidence-hash":p.hash,...g,children:n.jsx(F,{hash:p.hash,alt:p.alt||"evidence"})}),children:c.body})})]},y)})}function ve(e,l,o){const t=e.lastIndexOf(`
3
+ `,l-1)+1,u=/^\/(\S*)$/.exec(e.slice(t,l));if(!u)return null;const h=oe(o,u[1]);return h.length?{items:h,index:0,start:t,end:l,query:u[1]}:null}function Ee({onSend:e,specs:l=[],sessions:o=[],focusId:t=null,onDone:u,anchorNow:h=null,draft:v=null,actionsEnd:N=null,commands:r=null}){const f=K(),[x,b]=E.useState(""),[k,w]=E.useState(!1),[c,y]=E.useState(""),d=E.useRef(null),{launchers:T}=Y(),S=Z({inputRef:d,value:x,setValue:b,specs:l,sessions:o,launchers:T,focusId:t,up:!0}),[m,p]=E.useState(null),A=s=>p(s&&(r!=null&&r.length)?ve(s.value,s.selectionStart,r):null),g=s=>{var C;if(!s||!m)return;const i=x.slice(0,m.start)+x.slice(m.end);if(p(null),s.run){b(i.trim()?i:""),s.run();return}const R=U(i);let M="";if(R){const j=((C=_.exec(R.rest))==null?void 0:C[0])??"";M=`${R.label}
4
+ ${j}`,M.endsWith(`
5
+ `)||(M+=`
6
+ `)}b(M+s.prefill()),requestAnimationFrame(()=>{const j=d.current;j&&(j.focus(),j.setSelectionRange(j.value.length,j.value.length))})},a=s=>re(s,m,p,g),$=q(x);E.useEffect(()=>{var s;if(!v){b("");return}b(v.body||""),(s=d.current)==null||s.focus()},[v==null?void 0:v.seq]);const L=async()=>{var R;const s=await(h==null?void 0:h());if(!s)return;const i=H(s.tMs,s.step)+(s.frame?`
7
+ ![frame](/api/evidence/${s.frame})`:"");b(M=>{const C=U(M),j=(C?C.rest:M).replace(_,"");return j?`${i}
8
+ ${j}`:`${i}
9
+ `}),(R=d.current)==null||R.focus()},B=s=>ie(d.current,s,b,i=>{S.sync(i),A(i)}),O=async()=>{const s=x.trim();if(!(!s||k)){w(!0);try{const i=await e(s,q(s));i!=null&&i.ok?(b(""),y(""),await(u==null?void 0:u(i.outcomes||""))):y((i==null?void 0:i.error)||"reply failed")}finally{w(!1)}}},P=$.length>0?n.jsx("div",{className:"fv-frames",children:$.map(s=>n.jsx(F,{hash:s,alt:"frame"},s))}):null,V=n.jsxs("div",{className:"fv-tawrap",children:[n.jsx(ee,{ref:d,className:"fv-textarea",rows:1,value:x,placeholder:f("session.issuesReplyPlaceholder"),disabled:k,onChange:s=>{b(s.target.value),S.sync(s.target),A(s.target)},onSelect:s=>{S.sync(s.target),A(s.target)},onBlur:()=>{S.close(),p(null)},onKeyDown:s=>{se(s)||a(s)||S.onKeyDown(s)||s.key==="Enter"&&(s.metaKey||s.ctrlKey)&&(s.preventDefault(),O())}}),S.menuEl,m&&n.jsx(te,{menu:m,up:!0,head:m.query?`/${m.query}`:f("annotator.menuReview"),onPick:g,onHover:s=>p(i=>i&&{...i,index:s})})]}),z=n.jsxs("div",{className:"fv-actions",children:[n.jsx(I,{label:f("thread.mentionActor"),disabled:k,onClick:()=>B("@"),children:"@"}),n.jsx(I,{label:f("thread.mentionNode"),disabled:k,onClick:()=>B("[["),children:"[["}),(r==null?void 0:r.length)>0&&n.jsx(I,{label:f("thread.reviewCommands"),disabled:k,onClick:()=>B("/"),children:"/"}),h&&n.jsxs("button",{type:"button",className:"fv-anchor-btn","data-tip":f("thread.anchorTitle"),onMouseDown:s=>s.preventDefault(),onClick:L,children:[n.jsx(G,{name:"clock",size:11})," ",f("thread.anchorNow")]}),c&&n.jsx("span",{className:"fv-error",children:c}),n.jsxs("div",{className:"fv-actions-end",children:[N,n.jsx(Q,{icon:"send",size:14,className:"fv-send",label:f(k?"session.issuesSending":"session.issuesSend"),disabled:k||!x.trim(),onMouseDown:s=>s.preventDefault(),onClick:O})]})]});return n.jsx(le,{className:"fv-compose",preview:P,editor:V,footer:z})}export{xe as E,Ne as O,Ee as R,fe as a,H as b,Se as c,ue as e,ge as f,ke as k,he as m,U as p,je as r};
@@ -0,0 +1,2 @@
1
+ var Ds=Object.defineProperty;var Ts=(s,t,n)=>t in s?Ds(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var Ee=(s,t,n)=>Ts(s,typeof t!="symbol"?t+"":t,n);import{u as D,j as e,I as R,r as h,f as $s,g as Ms,C as Ze,h as Os,b as be,a as Ce,i as es,k as Ps,m as Ls,n as Rs,o as V,S as De,e as Te,q as As,t as $e,V as Ks}from"./index-Co8kmYQY.js";import{i as zs,M as Ws}from"./Modal-oF4JAL6H.js";import{u as H,R as Bs,a as ae,n as M,r as Z,b as ke,c as Fs,d as ss,e as Ne,f as _s,g as Is,h as qs,I as ce,P as ts}from"./App-BBoP1IyU.js";import{f as Me,w as ee,i as Oe,s as Hs,C as Gs,a as Q,b as z,c as Pe,o as W,n as ge,g as Ys,d as Le,e as je,h as ie,j as Vs,k as ns,u as oe,D as U,l as L,S as J,m as X,p as Us,q as Re,r as Ae,t as se,v as Ke,x as Js,y as Qs,z as le,A as Xs,B as Zs,E as et,F as de,G as st,H as tt,I as rs,J as nt,K as ze,L as rt,M as as,N as os,O as at,P as cs,Q as ot,R as ct,T as it,U as lt,V as dt,W as ut,X as pt,Y as ht,Z as ft,_ as te,$ as ne,a0 as mt,a1 as xt,a2 as gt,a3 as jt,a4 as yt,a5 as bt,a6 as is,a7 as kt,a8 as Nt}from"./tabs-C4phsoFs.js";import{n as wt}from"./GraphStats-CxHsXNy-.js";const We=Bs,vt=s=>Z(s),St={evals:["shell.evals"]};function Et(){const s=D(),{dock:t}=ae(),{setDock:n}=H();if(!n)return null;const r=s(t?"dockModes.collapse":"dockModes.expand");return e.jsx("button",{type:"button",className:"rail-btn rail-panel-toggle","data-tip":r,"aria-label":r,"aria-pressed":t,onClick:()=>n(o=>!o),children:e.jsx(R,{name:t?"panel-left":"panel-right",size:18})})}function Ct({page:s,active:t,label:n,disabled:r=!1,onNavigate:o,badge:a=0}){return r?e.jsxs("span",{className:"rail-btn disabled","data-tip":n,"aria-label":n,"aria-disabled":"true",children:[e.jsx(R,{name:Oe(s)||s,size:18}),a>0&&e.jsx("span",{className:"rail-badge","aria-label":`${a} needs you`,children:a>99?"99+":a})]}):e.jsxs("a",{className:t?"rail-btn on":"rail-btn","data-tip":n,"aria-label":n,"aria-current":t?"page":void 0,href:vt(s),onClick:i=>{if(i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;i.preventDefault(),(o==null?void 0:o())===!0||M(s)},children:[e.jsx(R,{name:Oe(s)||s,size:18}),a>0&&e.jsx("span",{className:"rail-badge","aria-label":`${a} needs you`,children:a>99?"99+":a})]})}function Be({page:s,graphOnly:t=!1,needsYou:n=0,hideDockToggle:r=!1}){const o=D(),{setDock:a,setDockMode:i}=H(),d=t?["graph",...We]:We;return e.jsxs("nav",{className:"side-rail","aria-label":o("nav.railLabel"),onMouseDownCapture:zs,children:[!r&&e.jsx(Et,{}),d.map(c=>e.jsx(Ct,{page:c,active:s===c||c==="spec"&&s==="file",label:ee(o(`nav.${c}`),...St[c]||[]),badge:c==="sessions"?n:0,disabled:t&&c!=="graph",onNavigate:()=>c==="sessions"?(a==null||a(!0),i==null||i("sessions"),Me(l=>l.page==="sessions"&&l.param)):c==="spec"?(a==null||a(!0),i==null||i("explorer"),Me(l=>l.page==="spec")):(c==="graph"&&(a==null||a(!0),i==null||i("explorer")),!1)},c)),e.jsx("div",{className:"rail-spacer"})]})}const Dt=400,Tt=80,ue=7,pe=6;function Fe(){const[s,t]=h.useState(null),n=h.useRef(null),r=h.useRef(0),o=h.useRef(null),a=h.useRef(null),i=h.useRef(!1),d=h.useRef(()=>{});return ke(!!s,()=>d.current()),h.useEffect(()=>{const c=()=>{r.current&&(clearTimeout(r.current),r.current=0)},l=()=>{c(),o.current=null,a.current&&(a.current.getAttribute("aria-describedby")==="ui-tip"&&a.current.removeAttribute("aria-describedby"),a.current=null),t(k=>(k&&(i.current=!0,setTimeout(()=>{o.current||(i.current=!1)},300)),null))};d.current=l;const f=k=>{const w=k.getAttribute("data-tip");!w||!k.isConnected||(o.current=k,k.getAttribute("aria-describedby")||(k.setAttribute("aria-describedby","ui-tip"),a.current=k),t({text:w,anchor:k}))},g=(k,w)=>{o.current!==k&&(c(),o.current=k,r.current=setTimeout(()=>{r.current=0,f(k)},w))},j=k=>{var E,C;const w=(C=(E=k.target).closest)==null?void 0:C.call(E,"[data-tip]");w&&g(w,i.current?Tt:Dt)},p=k=>{var E,C;const w=(C=(E=k.target).closest)==null?void 0:C.call(E,"[data-tip]");!w||w!==o.current||w.contains(k.relatedTarget)||l()},u=k=>{var C,N;const w=(N=(C=k.target).closest)==null?void 0:N.call(C,"[data-tip]");if(!w)return;let E=!0;try{E=w.matches(":focus-visible")}catch{}E&&(c(),f(w))},S=k=>{var E,C;const w=(C=(E=k.target).closest)==null?void 0:C.call(E,"[data-tip]");w&&w===o.current&&l()};return document.addEventListener("pointerover",j,!0),document.addEventListener("pointerout",p,!0),document.addEventListener("focusin",u,!0),document.addEventListener("focusout",S,!0),document.addEventListener("pointerdown",l,!0),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{c(),document.removeEventListener("pointerover",j,!0),document.removeEventListener("pointerout",p,!0),document.removeEventListener("focusin",u,!0),document.removeEventListener("focusout",S,!0),document.removeEventListener("pointerdown",l,!0),window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l),d.current=()=>{}}},[]),h.useEffect(()=>{const c=n.current;if(!s||!c)return;if(!s.anchor.isConnected){t(null);return}const l=s.anchor.getBoundingClientRect(),f=c.offsetWidth,g=c.offsetHeight,j=l.top-g-ue>=pe?"top":"bottom",p=j==="top"?l.top-g-ue:l.bottom+ue,u=Math.min(Math.max(l.left+l.width/2-f/2,pe),window.innerWidth-f-pe);c.dataset.place=j,c.style.top=`${Math.round(p)}px`,c.style.left=`${Math.round(u)}px`;const S=c.querySelector(".ui-tip-arrow");S&&(S.style.left=`${Math.round(Math.min(Math.max(l.left+l.width/2-u,10),f-10))-4}px`);const k=requestAnimationFrame(()=>c.classList.add("show"));return()=>cancelAnimationFrame(k)},[s]),s?$s.createPortal(e.jsxs("div",{id:"ui-tip",role:"tooltip",ref:n,className:"ui-tip",children:[s.text,e.jsx("span",{className:"ui-tip-arrow","aria-hidden":"true"})]}),document.body):null}function $t({menu:s,onClose:t,owningNodeOf:n}){const r=D(),[o,a]=h.useState(null);if(h.useEffect(()=>{if(s)return window.addEventListener("click",t),window.addEventListener("contextmenu",t,!0),()=>{window.removeEventListener("click",t),window.removeEventListener("contextmenu",t,!0)}},[s,t]),ke(!!s,t),h.useEffect(()=>{a(null)},[s]),h.useEffect(()=>{if(!o)return;const g=setTimeout(t,900);return()=>clearTimeout(g)},[o,t]),!s)return null;const i=g=>j=>{j.stopPropagation(),t(),g()},d=g=>async j=>{j.stopPropagation(),a(await g()?"copied":"failed")},c=g=>r(o?`explorerMenu.${o}`:g),l=Hs("explorer.openInNewTab"),f=s.kind==="file"?n==null?void 0:n(s.path):null;return e.jsxs(Gs,{x:s.x,y:s.y,anchorKey:s.key,keyboard:s.keyboard,label:r(s.kind==="node"?"explorerMenu.nodeLabel":"explorerMenu.fileLabel"),children:[s.kind==="node"&&e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(z,{icon:"plus",hint:l,onClick:i(()=>W("spec",s.id)),children:r("tabs.openInNewTab")}),e.jsx(z,{icon:"graph",onClick:i(()=>ge(Ys(s.id))),children:r("explorerMenu.revealOnGraph")})]}),e.jsx(Pe,{}),e.jsxs(Q,{children:[e.jsx(z,{icon:"copy",onClick:d(()=>Le(je(s.id))),children:c("explorerMenu.copyLink")}),e.jsx(z,{icon:"copy",onClick:d(()=>ie(s.id)),children:c("explorerMenu.copyNodeId")})]})]}),s.kind==="file"&&e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(z,{icon:"plus",hint:l,onClick:i(()=>W("file",s.path)),children:r("tabs.openInNewTab")}),f&&e.jsx(z,{icon:"node",onClick:i(()=>ge(je(f))),children:r("explorerMenu.revealOwner")})]}),e.jsx(Pe,{}),e.jsxs(Q,{children:[e.jsx(z,{icon:"copy",onClick:d(()=>Le(Vs(Z("file",s.path)))),children:c("explorerMenu.copyLink")}),e.jsx(z,{icon:"copy",onClick:d(()=>ie(s.path)),children:c("explorerMenu.copyPath")})]})]}),s.kind==="dir"&&e.jsx(Q,{children:e.jsx(z,{icon:"copy",onClick:d(()=>ie(s.path)),children:c("explorerMenu.copyPath")})})]})}const ls=s=>{let n={open:(()=>{try{const i=JSON.parse(localStorage.getItem(s)||"[]");return new Set(Array.isArray(i)?i.filter(d=>typeof d=="string"):[])}catch{return new Set}})()};const r=new Set,o=i=>{n={open:i};try{localStorage.setItem(s,JSON.stringify([...i]))}catch{}r.forEach(d=>d())};return{subscribe:i=>(r.add(i),()=>r.delete(i)),get:()=>n,toggle:i=>{if(!i)return;const d=new Set(n.open);d.has(i)?d.delete(i):d.add(i),o(d)},reveal:i=>{const d=i.filter(Boolean);if(!d.length||d.every(l=>n.open.has(l)))return;const c=new Set(n.open);d.forEach(l=>c.add(l)),o(c)},clear:()=>{n.open.size&&o(new Set)}}},_=ls("spex.specTreeOpen"),q=ls("spex.diskTreeOpen"),Mt=()=>h.useSyncExternalStore(_.subscribe,_.get,_.get),Ot=s=>_.toggle(s),Pt=(s=[])=>_.reveal(s),Lt=()=>h.useSyncExternalStore(q.subscribe,q.get,q.get),Rt=s=>q.toggle(s),At=s=>{const t=[_.subscribe(s),q.subscribe(s)];return()=>t.forEach(n=>n())},_e=()=>_.get().open.size===0&&q.get().open.size===0,Kt=()=>h.useSyncExternalStore(At,_e,_e),zt=()=>{_.clear(),q.clear()};function ds(s,t){const[n,r]=h.useState(null);return h.useEffect(()=>{if(!t||n)return;let o=!0;return Ms(s).then(a=>o&&r(a)).catch(a=>o&&r({error:a instanceof Error?a.message:String(a)})),()=>{o=!1}},[t,n,s]),n}function Wt({entry:s,depth:t}){const n=D(),{open:r}=Lt(),o=r.has(s.path),a=ds(s.path,o);return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"ft-row ft-dir",style:{paddingLeft:6+t*11,"--depth":t},"aria-expanded":o,"data-tip":s.path,"data-menu-kind":"dir","data-menu-path":s.path,onClick:()=>Rt(s.path),children:[e.jsx("span",{className:"ft-caret",children:e.jsx(Ze,{open:o})}),e.jsx("span",{className:"ft-label",children:s.name})]}),o&&e.jsx(us,{state:a,depth:t+1,loading:n("diskTree.loading")})]})}function Bt({entry:s,depth:t}){const n=Z("file",s.path);return e.jsxs("a",{className:"ft-row ft-code",style:{paddingLeft:6+t*11,"--depth":t},href:n,"data-tip":s.path,"data-menu-kind":"file","data-menu-path":s.path,onClick:r=>ns(r,n),onDoubleClick:r=>{r.preventDefault(),M("file",s.path)},children:[e.jsx("span",{className:"ft-caret"}),e.jsx("span",{className:"ft-label",children:s.name})]})}function us({state:s,depth:t,loading:n}){return s?s.error?e.jsx("div",{className:"ft-note ft-note-error",style:{paddingLeft:6+t*11},children:s.error}):e.jsxs(e.Fragment,{children:[s.entries.map(r=>r.kind==="dir"?e.jsx(Wt,{entry:r,depth:t},r.path):e.jsx(Bt,{entry:r,depth:t},r.path)),s.truncated&&e.jsx("div",{className:"ft-note",style:{paddingLeft:6+t*11},children:"…"})]}):e.jsx("div",{className:"ft-note",style:{paddingLeft:6+t*11},children:n})}function Ft({onCount:s}){const t=D(),n=ds("",!0);return h.useEffect(()=>{n&&!n.error&&(s==null||s(n.entries.length))},[n,s]),e.jsx("div",{className:"ft-files",children:e.jsx(us,{state:n,depth:0,loading:t("diskTree.loading")})})}const _t=s=>{const t=new Map;for(const n of s){const r=n.parent||"";t.has(r)||t.set(r,[]),t.get(r).push(n)}return t};function he({depth:s,onClick:t,open:n,hasKids:r,dot:o,label:a,kind:i,active:d,subject:c=null}){return e.jsxs("button",{type:"button",className:`ft-row ft-${i}${d?" on":""}`,style:{paddingLeft:6+s*11,"--depth":s},onClick:t,"data-tip":a,"data-menu-kind":c==null?void 0:c.kind,"data-menu-id":c==null?void 0:c.id,"data-menu-path":c==null?void 0:c.path,children:[e.jsx("span",{className:"ft-caret",children:r&&e.jsx(Ze,{open:n})}),o?e.jsx("i",{className:"ft-dot",style:{background:o}}):e.jsx("span",{className:"ft-dot ft-none"}),e.jsx("span",{className:"ft-label",children:a})]})}function ps({node:s,depth:t,kids:n,focusId:r,onOpenFile:o}){var p;const{open:a}=Mt(),i=a.has(s.id),d=u=>{(typeof u=="function"?u(i):u)!==i&&Ot(s.id)},[c,l]=h.useState(null);h.useEffect(()=>{if(!i||c)return;let u=!0;return Os(s.id).then(S=>u&&l(S)).catch(()=>u&&l([])),()=>{u=!1}},[i,c,s.id]);const f=n.get(s.id)||[],g=(s.code||[]).map(u=>u.split("#")[0]).filter((u,S,k)=>k.indexOf(u)===S),j=f.length>0||g.length>0;return e.jsxs(e.Fragment,{children:[e.jsx(he,{depth:t,kind:"node",label:s.title||s.id,active:r===s.id,subject:{kind:"node",id:s.id},dot:(p=J[s.status])==null?void 0:p.color,hasKids:j,open:i,onClick:u=>{d(S=>!S),X(u)?W("spec",s.id):M("spec",s.id)}}),i&&e.jsxs(e.Fragment,{children:[g.map(u=>e.jsx(he,{depth:t+1,kind:"code",label:u.split("/").pop(),subject:{kind:"file",path:u},onClick:S=>(X(S)?W:M)("file",u)},`c:${u}`)),(c||[]).map(u=>e.jsx(he,{depth:t+1,kind:"att",label:u.name,subject:{kind:"file",path:`.spec/${s.id}/${u.name}`},onClick:S=>(X(S)?W:M)("file",`.spec/${s.id}/${u.name}`)},`a:${u.name}`)),f.map(u=>e.jsx(ps,{node:u,depth:t+1,kids:n,focusId:r,onOpenFile:o},u.id))]})]})}function Ie({name:s,count:t,tone:n,children:r}){return e.jsxs("section",{className:"ft-section",children:[e.jsxs("div",{className:`ft-section-head si-zone si-zone-${n}`,role:"heading","aria-level":"2",children:[e.jsx("span",{className:"si-zone-count","aria-hidden":"true",children:t}),e.jsx("span",{className:"si-zone-label ft-section-name",children:s})]}),e.jsx("div",{className:"ft-section-body",children:r})]})}function It({specs:s,focusId:t,onOpenFile:n,embedded:r=!1}){const o=D(),[a,i,d]=oe(U.key,U.initial,U),[c,l]=h.useState(0),f=h.useMemo(()=>_t(s||[]),[s]),g=f.get("")||[],j=h.useMemo(()=>{const m=new Map;for(const y of s||[])m.set(y.id,y.parent||null);return m},[s]);h.useEffect(()=>{if(!t||!j.has(t))return;const m=[];for(let y=j.get(t),v=0;y&&v<64;y=j.get(y),v++)m.push(y);Pt(m)},[t,j]);const p=h.useCallback(m=>n==null?void 0:n(m),[n]),[u,S]=h.useState(null),k=h.useMemo(()=>{const m=new Map;for(const y of s||[])for(const v of y.code||[]){const T=v.split("#")[0];m.has(T)||m.set(T,y.id)}return m},[s]),w=h.useCallback(m=>k.get(m)||null,[k]),E=m=>{var $;const y=($=m==null?void 0:m.closest)==null?void 0:$.call(m,"[data-menu-kind]");if(!y)return null;const{menuKind:v,menuId:T,menuPath:K}=y.dataset;return{kind:v,id:T||null,path:K||null,key:`${v}:${T||K}`,row:y}},C=h.useCallback(()=>{var m,y;u!=null&&u.keyboard&&((y=(m=u.row)==null?void 0:m.focus)==null||y.call(m)),S(null)},[u]),N=m=>{const y=E(m.target);y&&(m.preventDefault(),S({...y,x:m.clientX,y:m.clientY,keyboard:!1}))},O=m=>{const y=L("explorer.menu",m);if(!y&&!L("explorer.openInNewTab",m))return;const v=E(m.target);if(v){if(m.preventDefault(),y){const T=v.row.getBoundingClientRect();S({...v,x:T.left+12,y:T.bottom,keyboard:!0});return}v.kind==="node"?W("spec",v.id):v.kind==="file"&&W("file",v.path)}},A=h.useCallback(m=>l(m),[]),b=()=>{M("spec")};return s!=null&&s.length?e.jsxs("div",{className:"filetree",style:r?{width:"100%"}:{width:a},children:[e.jsxs("div",{className:"ft-body",onContextMenu:N,onKeyDown:O,children:[e.jsx(Ie,{name:o("fileTree.specs"),count:s.length,tone:"specs",children:g.map(m=>e.jsx(ps,{node:m,depth:0,kids:f,focusId:t,onOpenFile:p},m.id))}),e.jsx(Ie,{name:o("fileTree.files"),count:c,tone:"files",children:e.jsx(Ft,{onCount:A})})]}),e.jsx($t,{menu:u,onClose:C,owningNodeOf:w}),e.jsxs("button",{type:"button",className:"ft-graph-entry","data-tip":o("fileTree.graph"),"aria-label":o("fileTree.graph"),onClick:b,children:[e.jsx(R,{name:"graph",size:14}),e.jsx("span",{children:o("fileTree.graph")})]}),!r&&e.jsx("div",{className:"ft-resize",onMouseDown:i,onDoubleClick:d,role:"separator","aria-orientation":"vertical"})]}):null}function qt({sessions:s,activeId:t,suppressRows:n=!1}){const r=D(),{offline:o}=be(),{expanded:a,offlineOpen:i}=Us(),{lockedSource:d}=ae(),{lockGraphTo:c}=H(),{reload:l}=Fs(),{notify:f}=es(),[g,j]=h.useState(null),[p,u]=h.useState(null),[S,k]=h.useState(null),w=h.useRef(null);h.useEffect(()=>()=>{var b;return(b=w.current)==null?void 0:b.call(w)},[]),h.useEffect(()=>{if(!t)return;const b=(s||[]).find(m=>m.id===t);Re(Ae(s||[],t)),b&&se(b)==="offline"&&Ke(!0)},[t,s]);const E=h.useMemo(()=>Js(s||[],b=>a.has(b),{zoneFolded:b=>b==="offline"&&!i,keepVisible:b=>b.id===t}),[s,a,i,t]);ss(b=>{if(n)return!1;const m=Qs(E,t,b);if(!m)return!1;if(b.preventDefault(),m.type==="move")M("sessions",m.id);else if(m.type==="expand"){const y=E.find(v=>v.type==="row"&&v.s.id===m.id);y&&!y.expanded&&le(m.id)}else if(m.type==="collapse"){const y=E.find(v=>v.type==="row"&&v.s.id===m.id);y!=null&&y.expanded&&le(m.id)}return!0},20);const C=h.useCallback(async(b,m)=>{const y=(s||[]).find(v=>v.id===b);if(!(!y||(y.parent||null)===m))try{const v=await Ps("/api/sessions/reparent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({children:[b],parent:m})}),T=await v.json().catch(()=>null);if(!v.ok||(T==null?void 0:T.ok)===!1)throw new Error((T==null?void 0:T.error)||`session parent update refused (HTTP ${v.status})`);m&&Re([m]),l==null||l()}catch(v){f(v instanceof Error?v.message:String(v),{kind:"error"})}},[s,l,f]),N=(b,m)=>{if(de(b.x,b.y,"[data-session-archive-drop]"))return"archive";const y=de(b.x,b.y,"[data-session-drop-id]");if(y){const v=y.dataset.sessionDropId;return v===m.id||v===m.parent||Ae(s||[],v).includes(m.id)?void 0:v}return m.parent&&de(b.x,b.y,"[data-session-root-drop]")?null:void 0},O=(b,m)=>{const y={id:m.id,parent:m.parent||null},v=$=>document.body.classList.toggle("is-session-dragging",$),T=$=>{const B=N($,y);u(G=>G&&G.id===y.id&&G.target===B?G:{...y,target:B})},K=()=>{v(!1),u(null),w.current=null};w.current=et(b,{onStart:$=>{v(!0),T($)},onMove:T,onDrop:$=>{const B=N($,y);K(),B==="archive"?k(m):B!==void 0&&C(y.id,B)},onCancel:K})},A=!!(p!=null&&p.parent);return n?null:e.jsxs("div",{className:"dock-session-body",children:[e.jsx("div",{className:`dock-session-list${A?" root-armed":""}${(p==null?void 0:p.target)===null?" root-on":""}`,...A?{"data-session-root-drop":""}:{},children:E.length?E.map(b=>{if(b.type==="zone"){const y=b.zone==="offline",v=r(`sessionZone.${b.zone}`);return e.jsxs("button",{type:"button",className:`dock-session-zone dock-session-zone-${b.zone}`,"aria-expanded":y?!b.folded:void 0,onClick:y?()=>Ke(b.folded):void 0,children:[e.jsx("span",{children:v}),e.jsxs("span",{className:"dock-session-count",children:[b.count,o&&e.jsx("em",{className:"dock-stale",children:r("backend.stale")})]})]},`zone-${b.zone}`)}const m=!!b.s.source&&b.s.source===d;return e.jsx(Xs,{item:b,activeId:t,dragging:(p==null?void 0:p.id)===b.s.id,dropTarget:(p==null?void 0:p.target)===b.s.id,onToggleFold:()=>le(b.s.id),rowProps:{"data-sid":b.s.id,"data-locked":m?"":void 0,"data-tip":r("dockSessions.rowTip"),"aria-grabbed":(p==null?void 0:p.id)===b.s.id||void 0,onMouseDown:y=>{y.preventDefault(),O(y,b.s)},onClick:y=>{if(y.altKey){y.preventDefault(),c(b.s.source);return}X(y)?W("sessions",b.s.id):M("sessions",b.s.id)},onContextMenu:y=>{y.preventDefault(),j({x:y.clientX,y:y.clientY,session:b.s})}}},b.s.id)}):e.jsx("div",{className:"dock-empty",children:"—"})}),A&&e.jsx("div",{className:"dock-root-hint","aria-hidden":"true",children:r("session.rootDrop")}),e.jsx(Zs,{menu:g,closeRequest:S,onCloseRequestDone:()=>k(null),onClose:()=>j(null),onChanged:l,onError:b=>f(b,{kind:"error"}),onLock:b=>c(b.source,{toggle:!1})})]})}function Ht({mode:s,specs:t,sessions:n}){const r=D(),{offline:o}=be(),{openPalette:a}=H(),i=s==="sessions",d=i?(n==null?void 0:n.length)||0:(t==null?void 0:t.length)||0,c=r(i?"dockModes.searchSessions":"dockModes.searchNodes"),l=Kt();return e.jsxs("div",{className:"dock-head",children:[e.jsx("span",{className:"dock-head-name",children:r(i?"dockModes.sessions":"dockModes.explorer")}),e.jsxs("span",{className:"dock-head-count",children:[d,o&&e.jsx("em",{className:"dock-stale",children:r("backend.stale")})]}),e.jsxs("span",{className:"dock-head-acts",children:[!i&&e.jsx(Ce,{icon:"collapse-all",size:13,className:"dock-head-act",label:r("dockModes.collapseFolders"),disabled:l,onClick:zt}),e.jsx("button",{type:"button",className:"dock-head-act","data-tip":ee(c,"graph.search"),"aria-label":c,onClick:()=>a(i?"sessions":"nodes"),children:e.jsx(R,{name:"search",size:13})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"dock-head-act dock-archive-door","data-session-archive-drop":!0,"data-tip":r("dockSessions.archive"),"aria-label":r("dockSessions.archive"),onClick:()=>M("sessions",null,{query:{archive:"1"}}),children:e.jsx(R,{name:"archive",size:13})}),e.jsx(Ce,{icon:"plus",size:15,className:"dock-head-act dock-head-act-new",label:r("dockSessions.new"),onClick:()=>M("sessions","new")})]})]})]})}function Gt({mode:s,specs:t,sessions:n,focusId:r,activeSessionId:o,suppressSessionRows:a=!1,closing:i=!1,opening:d=!1}){const[c,l,f]=oe(U.key,U.initial,U);return e.jsxs("aside",{className:i?"dock dock-closing":"dock","data-fold":d?"in":void 0,style:{width:c},"aria-hidden":i?"true":void 0,children:[e.jsx(Ht,{mode:s,specs:t,sessions:n}),s==="sessions"?e.jsx(qt,{sessions:n,activeId:o,suppressRows:a}):e.jsx(It,{specs:t,focusId:r,embedded:!0}),e.jsx("div",{className:"ft-resize",onMouseDown:l,onDoubleClick:f,role:"separator","aria-orientation":"vertical"})]})}const hs=8,Yt=5,Vt=2.2,Ut=1,Jt=new Set(["the","a","an","and","or","of","to","in","on","is","it","its","as","at","by","for","how","does","do","what","which","that","this","these","those","with","from","into","are","be","can","just","them","they","their","so","if","not","no","but","vs","us","we","you"]),fs="\\u3400-\\u4dbf\\u4e00-\\u9fff\\uf900-\\ufaff\\u3040-\\u30ff",Qt=new RegExp(`[a-z0-9]+|[${fs}]`,"g"),Xt=new RegExp(`[${fs}]`);function ms(s){return Xt.test(s)}function xs(s){return s.toLowerCase().match(Qt)??[]}function Zt(s){const t=new Set;for(const n of xs(s))(ms(n)||n.length>1&&!Jt.has(n))&&t.add(n);return[...t]}function fe(s){return xs(s)}function we(s){let t=s;return t.length>=4&&t.endsWith("s")&&!t.endsWith("ss")&&(t=t.slice(0,-1)),t.length>=5&&t.endsWith("e")&&(t=t.slice(0,-1)),t}function en(s,t){return t.startsWith(we(s))}function re(s,t){return t.startsWith(we(s))||t.length>=3&&s.startsWith(t)}const sn=.5;function tn(s,t){const n=we(s);let r=0;for(const o of t.nameWords)if(o.startsWith(n)){const a=n.length/o.length;a>r&&(r=a)}return r>0?Math.max(sn,r):0}const qe=1.2,He=.4;function Ge(s,t,n){return s<=0?0:s*(qe+1)/(s+qe*(1-He+He*t/(n||1)))}function nn(s,t,n,r){const o=tn(s,t);if(o>0)return hs*o;if(t.name.includes(s))return Yt;if(t.descWords.some(i=>re(s,i)))return Vt*Ge(1,t.descWords.length,r);const a=t.bodyWords.reduce((i,d)=>i+(re(s,d)?1:0),0);return Ut*Ge(a,t.bodyWords.length,n)}function rn(s,t,n,r=140){const o=s.replace(/\s+/g," ").trim(),a=o.toLowerCase();let i=-1;for(const l of n){const f=ms(l)?a.indexOf(l):a.search(new RegExp("\\b"+l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")));f>=0&&(i<0||f<i)&&(i=f)}if(i<0){const l=(t||o).replace(/\s+/g," ").trim();return l.length>r?l.slice(0,r).trimEnd()+"…":l}const d=Math.max(0,i-Math.floor(r/3));let c=o.slice(d,d+r).trim();return d>0&&(c="…"+c),d+r<o.length&&(c=c+"…"),c}function an(s,t,n={}){const r=n.limit??10,o=Zt(s);if(!o.length)return[];const a=t.map(g=>{const j=g.name.toLowerCase();return{ref:g.ref,name:j,nameWords:fe(j),desc:g.desc.toLowerCase(),descWords:fe(g.desc),bodyWords:fe(g.body),snippetText:`${g.desc}
2
+ ${g.body}`}}),i=a.length,d=a.reduce((g,j)=>g+j.bodyWords.length,0)/(i||1),c=a.reduce((g,j)=>g+j.descWords.length,0)/(i||1),l={};for(const g of o){let j=0;for(const p of a)(p.nameWords.some(u=>en(g,u))||p.descWords.some(u=>re(g,u))||p.bodyWords.some(u=>re(g,u)))&&j++;l[g]=j>0?Math.log(i/j):0}const f=[];for(const g of a){let j=0;for(const p of o)j+=Math.min(nn(p,g,d,c)*l[p],hs);j<=0||f.push({ref:g.ref,score:Math.round(j*100)/100,snippet:rn(g.snippetText,g.desc,o)})}return f.sort((g,j)=>j.score-g.score),f.slice(0,r)}let me=null;function on(s=!0){const[t,n]=h.useState(me),r=h.useRef(!1);return h.useEffect(()=>{!s||r.current||(r.current=!0,fetch(Ls("/api/specs/lite")).then(o=>o.ok?o.json():[]).then(o=>{me={bodies:Object.fromEntries((o||[]).map(a=>[a.id,a.body||""]))},n(me)}).catch(()=>{}))},[s]),t}const Ye=["spec","session"],cn=s=>s?[s,...Ye.filter(t=>t!==s)]:Ye;function ln(s,t,n){const r=n==null?void 0:n.bodies,o=[];for(const a of s){const i=st(a.path);o.push({kind:"spec",key:`spec:${a.id}`,target:a.id,address:je(a.id),color:(J[a.status]||J.pending).color,title:a.title||a.id,sub:i,name:`${a.title||a.id} ${a.id}`,desc:a.desc||"",body:(r==null?void 0:r[a.id])??a.body??""})}for(const a of tt(t)){const i=rs(a),d=nt(a),c=a.status||a.promptPreview||a.note||"";o.push({kind:"session",key:`session:${a.id}`,target:a.id,address:rt(a.id),color:ze[a.status]||ze.offline,title:i,sub:c,name:i||"",desc:a.status||"",body:`${a.promptPreview||a.note||""} ${d}`.trim()})}return o}function dn(s,t,n){const r=Object.fromEntries(n.map((d,c)=>[d,c])),o=(d,c)=>r[d.kind]-r[c.kind];if(!t.trim())return s.slice().sort(o).slice(0,15);const a={};for(const d of n){const c=s.filter(l=>l.kind===d);a[d]=an(t,c.sort((l,f)=>l.name.length-f.name.length||l.key.localeCompare(f.key)).map(l=>({ref:l,name:l.name,desc:l.desc,body:l.body})),{limit:15}).map(l=>l.ref)}const i=[];for(let d=0;i.length<15;d++){let c=!1;for(const l of n)a[l][d]&&i.length<15&&(i.push(a[l][d]),c=!0);if(!c)break}return i}function un({specs:s,sessions:t,onPick:n,onClose:r,boost:o=null}){const a=D(),i=on(),[d,c]=h.useState(""),[l,f]=h.useState("");h.useEffect(()=>{if(!d.trim()){f(d);return}const N=setTimeout(()=>f(d),120);return()=>clearTimeout(N)},[d]);const[g,j]=h.useState(0),p=h.useRef(null),u=h.useRef(null),S=h.useMemo(()=>cn(o),[o]),k=h.useMemo(()=>ln(s,t,i),[s,t,i]),w=h.useMemo(()=>dn(k,l,S),[k,l,S]);h.useEffect(()=>{var N;(N=p.current)==null||N.focus()},[]),h.useEffect(()=>{j(0)},[d]),h.useEffect(()=>{var N,O;(O=(N=u.current)==null?void 0:N.querySelector(".search-item.on"))==null||O.scrollIntoView({block:"nearest"})},[g,w]);const E=(N,O=!1)=>{N&&(n(N,{newTab:O}),r())},C=N=>{N.key==="ArrowDown"?(N.preventDefault(),j(O=>Math.min(w.length-1,O+1))):N.key==="ArrowUp"?(N.preventDefault(),j(O=>Math.max(0,O-1))):N.key==="Enter"?(N.preventDefault(),E(w[g],N.ctrlKey||N.metaKey)):N.key==="Escape"&&(N.preventDefault(),r())};return e.jsx("div",{className:"search-backdrop","data-focus-overlay":!0,onClick:r,children:e.jsxs("div",{className:"search-panel",role:"dialog","aria-modal":"true","aria-label":a("search.title"),onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:"search-bar",children:[e.jsx("span",{className:"search-icon",children:"⌕"}),e.jsx("input",{ref:p,className:"search-input",value:d,placeholder:a("search.placeholder"),onChange:N=>c(N.target.value),onKeyDown:C})]}),e.jsxs("ul",{className:"search-results",ref:u,children:[w.length===0&&e.jsx("li",{className:"search-empty",children:a("search.empty")}),w.map((N,O)=>e.jsxs("li",{className:`search-item${O===g?" on":""}`,"data-kind":N.kind,"data-target":N.target,onMouseEnter:()=>j(O),onClick:A=>E(N,X(A)),children:[e.jsx("span",{className:"node-dot",style:{background:N.color}}),e.jsx("span",{className:`search-kind k-${N.kind}`,children:a(`search.kind.${N.kind}`)}),e.jsx("span",{className:"search-title",children:N.title||N.target}),e.jsx("span",{className:"search-path",children:N.sub})]},N.key))]}),e.jsx("div",{className:"search-foot",children:a("search.hint")})]})})}class pn extends h.Component{constructor(){super(...arguments);Ee(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error(`view crashed (${this.props.resetKey}):`,n,r==null?void 0:r.componentStack)}componentDidUpdate(n){this.state.error&&n.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){const{error:n}=this.state;return n?e.jsx("div",{className:"view-error",children:e.jsxs("div",{className:"view-error-box",children:[e.jsx("p",{className:"view-error-title",children:this.props.t("viewError.title")}),e.jsx("p",{className:"view-error-detail",children:String((n==null?void 0:n.message)||n)}),e.jsx("button",{type:"button",className:"view-error-retry",onClick:()=>this.setState({error:null}),children:this.props.t("viewError.retry")})]})}):this.props.children}}function ve({resetKey:s,children:t}){const n=D();return e.jsx(pn,{resetKey:s,t:n,children:t})}const gs="spexcode.ctxPanels";function hn(){try{const s=JSON.parse(localStorage.getItem(gs)||"null");return{scenarios:(s==null?void 0:s.scenarios)!==!1,issues:(s==null?void 0:s.issues)!==!1}}catch{return{scenarios:!0,issues:!0}}}function js({href:s,children:t}){return e.jsx("a",{className:"ctx-row",href:s,onClick:n=>ns(n,s),children:t})}function fn({id:s}){var d;const t=D(),n=os("evals",_s(s),1,{pollMs:0,view:"timeline"});if(n.loading)return e.jsx("div",{className:"ctx-empty",children:t("contextDock.loading")});if(n.error)return e.jsx("div",{className:"ctx-empty ctx-error",children:n.error});const r=((d=n.data)==null?void 0:d.items)||[],o=[...new Map(r.filter(c=>c==null?void 0:c.scenario).map(c=>[c.scenario,{name:c.scenario}])).values()],a=r.filter(c=>c.filterKind==="result"),i=at(o,a);return i.length?e.jsx("div",{className:"ctx-list",children:i.map(c=>e.jsxs(js,{href:cs(ot(s,c.name)),children:[e.jsx("span",{className:`ctx-score ${c.state}`,"aria-label":t(`contextDock.states.${c.state}`),children:c.state==="pass"||c.state==="stalePass"?"✓":c.state==="fail"||c.state==="staleFail"?"×":"○"}),e.jsx("span",{className:"ctx-row-label",children:c.name}),e.jsx("span",{className:"ctx-state",children:t(`contextDock.states.${c.state}`)})]},c.name))}):e.jsx("div",{className:"ctx-empty",children:t("contextDock.noScenarios")})}function mn({id:s}){var o;const t=D(),n=os("issues",Is(s),1,{pollMs:0});if(n.loading)return e.jsx("div",{className:"ctx-empty",children:t("contextDock.loadingIssues")});if(n.error)return e.jsx("div",{className:"ctx-empty ctx-error",children:n.error});const r=((o=n.data)==null?void 0:o.items)||[];return r.length?e.jsx("div",{className:"ctx-list",children:r.map(a=>e.jsxs(js,{href:cs(it(a.id)),children:[e.jsx(ct,{kind:"issue",state:a.status||"open",size:12,className:"ctx-issue-state"}),e.jsx("span",{className:"ctx-row-label",children:a.concern})]},a.id))}):e.jsx("div",{className:"ctx-empty",children:t("contextDock.noIssues")})}function Ve({title:s,open:t,onToggle:n,children:r}){return e.jsxs("section",{className:"ctx-panel",children:[e.jsxs("button",{type:"button",className:"ctx-panel-head","aria-expanded":t,onClick:n,children:[e.jsx("span",{children:s}),e.jsx(R,{name:t?"chevron-down":"chevron-right",size:12})]}),t&&r]})}function xn({page:s,param:t,open:n=!0,onToggle:r}){const o=D(),{specs:a}=Ne(),[i,d,c]=oe("spex.ctxWidth",276,{min:220,max:460,dir:-1}),[l,f]=h.useState(hn),[g,j]=as(n);if(s!=="spec"||!t||!g)return null;const p=a==null?void 0:a.find(S=>S.id===t);if(!p)return null;const u=S=>f(k=>{const w={...k,[S]:!k[S]};try{localStorage.setItem(gs,JSON.stringify(w))}catch{}return w});return e.jsxs("aside",{className:j?"context-dock dock-closing":"context-dock",style:{width:i},"aria-hidden":j?"true":void 0,"aria-label":o("contextDock.title"),children:[e.jsx("div",{className:"ctx-resize",onMouseDown:d,onDoubleClick:c,role:"separator","aria-orientation":"vertical"}),e.jsxs("div",{className:"ctx-head",children:[e.jsx("span",{children:o("contextDock.title")}),e.jsx("span",{className:"ctx-node-id",children:p.id})]}),e.jsxs("div",{className:"ctx-body",children:[e.jsx(Ve,{title:o("contextDock.scenarios"),open:l.scenarios,onToggle:()=>u("scenarios"),children:e.jsx(fn,{id:t})}),e.jsx(Ve,{title:o("contextDock.issues"),open:l.issues,onToggle:()=>u("issues"),children:e.jsx(mn,{id:t})})]})]})}const gn=new Set(["=","_","I","H","J","K","L"]),jn=(()=>{const s=[];for(const t of dt){const n=ut(t,pt(t.id)).filter(o=>!gn.has(o)).map(ht),r=s[s.length-1];r&&r.desc===t.desc?r.keys.push(...n):s.push({desc:t.desc,keys:n})}return s})(),yn=[[["←","→","h","l","⇥","1","2"],"legend.popup.switch"],[["j","k","↑","↓"],"legend.popup.scroll"],[["⇧h","⇧j","⇧k","⇧l","⇧←↑↓→"],"legend.popup.lens"],[["⏎"],"legend.popup.enter"],[["esc"],"legend.popup.esc"]],bn=["merged","active","drift","pending"],kn=["added","edited","deleted","moved"];function Nn({t:s}){return e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("legend.secBoard")}),jn.map(t=>e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"keymap-keys",children:t.keys.map((n,r)=>e.jsx("kbd",{children:n},r))}),e.jsx("span",{className:"legend-desc",children:s(t.desc)})]},t.desc))]})}function wn({title:s,rows:t,t:n}){return e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s}),t.map(([r,o])=>e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"keymap-keys",children:r.map((a,i)=>e.jsx("kbd",{children:a},i))}),e.jsx("span",{className:"legend-desc",children:n(o)})]},o))]})}function vn({onClose:s}){const t=D();return e.jsxs(Ws,{title:t("legend.title"),closeLabel:ee(t("legend.close"),"graph.help"),onClose:s,children:[e.jsx(Nn,{t}),e.jsx(wn,{title:t("legend.secPopup"),rows:yn,t}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:t("legend.secStatus")}),bn.map(n=>e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"node-dot",style:{background:J[n].color},children:n==="active"&&e.jsx("span",{className:"pulse",style:{background:J[n].color}})}),e.jsx("span",{className:"legend-name",children:t(`status.${n}`)}),e.jsx("span",{className:"legend-desc",children:t(`legend.statusRows.${n}`)})]},n))]}),e.jsxs("section",{className:"legend-sec",children:[e.jsxs("div",{className:"legend-h",children:[t("legend.secOp")," ",e.jsx("span",{className:"legend-sub",children:t("legend.secOpSub")})]}),kn.map(n=>e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:`ov-mark ov-${n}`,children:lt[n]}),e.jsx("span",{className:"legend-desc",children:t(`legend.opRows.${n}`)})]},n))]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:t("legend.secBadges")}),e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"drift-badge",children:"⚠N"}),e.jsx("span",{className:"legend-desc",children:t("legend.badgeDrift")})]}),e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"legend-glyph legend-ver",children:"vN"}),e.jsx("span",{className:"legend-desc",children:t("legend.badgeVer")})]})]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:t("legend.secRing")}),e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"legend-ring ring-dashed"}),e.jsx("span",{className:"legend-desc",children:t("legend.ringDashed")})]}),e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"legend-ring ring-solid"}),e.jsx("span",{className:"legend-desc",children:t("legend.ringSolid")})]}),e.jsxs("div",{className:"legend-row",children:[e.jsx("span",{className:"legend-ring ring-ghost"}),e.jsx("span",{className:"legend-desc",children:t("legend.ringGhost")})]})]})]})}const Sn=/^[a-z][a-z0-9-]*$/,En=/^[A-Za-z0-9_-]+$/,ys=Object.freeze(["open","hold","own-query"]),Cn=Object.freeze({intents:ys,samePage:(s,t)=>I(s,"from").page===I(t,"to").page,assertAddress:s=>I(s)}),bs=s=>{if(s==null||typeof s!="object"||Array.isArray(s))return!1;const t=Object.getPrototypeOf(s);return t===Object.prototype||t===null};function ks(s,t="query"){if(s==null)return null;if(!bs(s))throw new TypeError(`${t} must be a plain object or null`);const n={};for(const[r,o]of Object.entries(s)){if(!En.test(r))throw new TypeError(`${t} key must be URL-safe: ${r}`);if(o!=null&&!["string","number","boolean"].includes(typeof o))throw new TypeError(`${t}.${r} must be a primitive value`);n[r]=o}return Object.freeze(n)}function I(s,t="address"){if(!bs(s))throw new TypeError(`${t} must be an address object`);const{page:n,param:r=null,query:o=null}=s;if(typeof n!="string"||!Sn.test(n))throw new TypeError(`${t}.page must be lowercase kebab-case`);if(r!=null&&typeof r!="string")throw new TypeError(`${t}.param must be a string or null`);return Object.freeze({page:n,param:r,query:ks(o,`${t}.query`)})}function Ue(s,t){return t===void 0?{accepted:!0,intent:s}:t}function Dn({route:s,dispatch:t,active:n=!0,contract:r=Cn,owner:o=null}={}){if(typeof t!="function")throw new TypeError("view scope requires a dispatch function");if(!r||typeof r.assertAddress!="function")throw new TypeError("view scope requires a route contract");if(o!=null&&(typeof o!="object"||o.kind!=="view"||typeof o.page!="string"))throw new TypeError("view scope owner must identify a view");let a=I(s,"route"),i=n!==!1;const d=(f,g,j=null)=>{if(!i)return{accepted:!1,reason:"inactive",type:f};const p=r.assertAddress(g,`${f}.address`),u=Object.freeze({type:f,address:I(p,`${f}.address`),...f==="open"&&(j==null?void 0:j.replace)===!0?{replace:!0}:{}});return Ue(u,t(u))},c={};Object.defineProperties(c,{route:{enumerable:!0,get:()=>a},active:{enumerable:!0,get:()=>i},owner:{enumerable:!0,value:o?Object.freeze({...o}):null}}),c.open=(f,g=null)=>d("open",f,g),c.hold=f=>d("hold",f),c.ownQuery=f=>{if(!i)return{accepted:!1,reason:"inactive",type:"own-query"};const g={page:a.page,param:a.param,query:ks(f,"own-query.query")},j=Object.freeze({type:"own-query",address:I(r.assertAddress(g,"own-query.address"),"own-query.address")});return Ue(j,t(j))};const l=({route:f=a,active:g=i}={})=>{a=I(f,"route"),i=g!==!1};return{scope:Object.freeze(c),update:l,intents:ys}}const Tn=(s,t)=>s==="issues"||s==="evals"||s==="settings"||s==="sessions"?"none":s==="spec"||s==="file"?"explorer":"keep",$n=new Set(["graph","sessions"]),Ns=(s,t)=>$n.has(s)?s:`${s}/${t??""}`,Mn=6;function ws({page:s,param:t,query:n,active:r,children:o}){const{splitTo:a}=H(),i=h.useCallback(c=>{const{page:l,param:f,query:g}=c.address;return c.type==="hold"?(a(c.address),{accepted:!0,intent:c}):(M(l,f,{query:g,replace:c.replace===!0}),{accepted:!0,intent:c})},[a]),d=h.useMemo(()=>Dn({route:{page:s,param:t,query:n},dispatch:i,active:r,contract:Nt,owner:{kind:"view",page:s,param:t??null}}),[]);return h.useEffect(()=>{d.update({route:{page:s,param:t,query:n},active:r})},[d,s,t,n,r]),e.jsx(Ks,{scope:d.scope,children:o})}function On({page:s,param:t,query:n,inactive:r=!1}){const o=Ns(s,t),a=Z(s,t,n),i=h.useRef(0),[d,c]=h.useState(()=>[{key:o,address:a,page:s,param:t,query:n,seq:0}]);return h.useEffect(()=>{c(l=>{const f=++i.current;let j=l.find(p=>p.key===o)?l.map(p=>p.key===o?{...p,address:a,page:s,param:t,query:n,seq:f}:p):[...l,{key:o,address:a,page:s,param:t,query:n,seq:f}];if(j.length>Mn){const p=j.reduce((u,S)=>S.seq<u.seq?S:u);j=j.filter(u=>u!==p)}return j})},[o,a]),d.map(l=>e.jsx(Pn,{entry:l,showing:!r&&l.key===o},l.key))}const Pn=h.memo(function({entry:t,showing:n}){const r=D(),{component:o,className:a}=is(t.page),i=h.useMemo(()=>({address:t.address,active:n}),[t.address,n]);return e.jsx("div",{className:`viewhost ${a}`,"aria-hidden":n?void 0:"true",style:n?void 0:{display:"none"},children:e.jsx(ve,{resetKey:t.address,children:e.jsx(ts,{value:i,children:e.jsx(ws,{page:t.page,param:t.param,query:t.query,active:n,children:e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"loading",children:r("hud.loading")}),children:e.jsx(o,{param:t.param,query:t.query})})})})})})});function ye({page:s,param:t,query:n,inactive:r=!1}){const o=D(),{component:a,className:i}=is(s),d=Z(s,t,n);return e.jsx("div",{className:`viewhost ${i}`,"aria-hidden":r?"true":void 0,style:r?{display:"none"}:void 0,children:e.jsx(ve,{resetKey:d,children:e.jsx(ts,{value:{address:d,active:!r},children:e.jsx(ws,{page:s,param:t,query:n,active:!r,children:e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"loading",children:o("hud.loading")}),children:e.jsx(a,{param:t,query:n},Ns(s,t))})})})})})}function Je(){var p;const s=D(),{identity:t,catalog:n}=Ne(),[r,o]=h.useState(!1);ke(r,()=>o(!1));const a=(n==null?void 0:n.state)==="ok",i=(n==null?void 0:n.state)==="denied",d=a?n.projects:null,c=(t==null?void 0:t.title)||Te||"spexcode",l=i?s("nav.projectChipLogin",{name:c}):s("nav.projectChip",{name:c});h.useEffect(()=>{if(!r)return;const u=S=>{var k,w;(w=(k=S.target).closest)!=null&&w.call(k,"[data-status-project], .status-project-menu")||o(!1)};return document.addEventListener("mousedown",u,!0),()=>{document.removeEventListener("mousedown",u,!0)}},[r]);const f=e.jsxs(e.Fragment,{children:[e.jsx(ce,{icon:t==null?void 0:t.icon,size:14,className:"sb-project-mark"}),e.jsx("span",{className:"sb-project-name",children:c})]}),g=d?e.jsx("button",{type:"button",className:r?"sb-project-trigger open":"sb-project-trigger","data-status-project":"","data-tip":l,"aria-label":l,"aria-haspopup":"menu","aria-expanded":r,"aria-controls":r?"status-project-menu":void 0,onClick:()=>o(u=>!u),children:f}):e.jsx("a",{className:"sb-project-trigger","data-status-project":"","data-tip":l,"aria-label":l,href:$e(),children:f}),j=r&&d?e.jsxs("div",{id:"status-project-menu",className:"proj-menu status-project-menu",role:"menu",onContextMenu:u=>u.stopPropagation(),children:[d.map(u=>{const S=u.online===!1,k=u.id===Te,w=S?s("nav.projectOffline"):u.online===!0?s("nav.projectOnline"):null,E=`proj-menu-item${k?" current":""}${S?" offline":""}`,C=e.jsxs(e.Fragment,{children:[e.jsx(ce,{icon:u.identity.icon,size:16,className:"proj-menu-mark"}),u.gated&&e.jsx(R,{name:"lock",size:11}),e.jsx("span",{className:"proj-menu-name",children:u.identity.title}),w&&e.jsx("span",{className:`proj-menu-status ${S?"offline":"online"}`,"aria-hidden":"true",children:w}),k&&e.jsx(R,{name:"check",size:12})]});return S?e.jsx("div",{role:"menuitem","aria-disabled":"true",className:E,children:C},u.id):e.jsx("a",{role:"menuitem",className:E,href:As(u.id),children:C},u.id)}),e.jsxs("a",{role:"menuitem",className:"proj-menu-item all",href:$e(),children:[e.jsx(ce,{icon:(p=n.gateway.identity)==null?void 0:p.icon,fallback:"gateway",size:16,className:"proj-menu-mark"}),e.jsx("span",{className:"proj-menu-name",children:s("nav.allProjects")})]})]}):null;return V({id:"project",side:"left",priority:1e3,kind:"prominent",overflow:r,node:e.jsxs("span",{className:"sb-project-slot",children:[g,j]})}),null}const Ln=[{state:"pass",always:!0,titleKey:"scorePass"},{state:"fail",always:!0,titleKey:"scoreFail"},{state:"stalePass",titleKey:"scoreStalePass"},{state:"staleFail",titleKey:"scoreStaleFail"},{state:"empty",titleKey:"scoreEmpty"}];function xe({name:s,count:t,title:n,onClick:r,children:o}){return e.jsxs("button",{type:"button",className:"sb-tally-button","data-board-stat":s,"data-tip":n,"aria-label":n,disabled:!r,onClick:r,children:[o,t]})}const Rn=()=>{try{return sessionStorage.getItem("spex.focus")}catch{return null}};function An({launcher:s,sessions:t,onOpen:n,tooltip:r}){const a=kt(s.harness).Glyph,i=t.reduce((d,c)=>{const l=se(c);return l==="run"?d.running+=1:l==="need"?d.needsYou+=1:d.other+=1,d},{running:0,needsYou:0,other:0});return e.jsxs("button",{type:"button",className:"sb-launcher-group","data-launcher":s.name,"data-tip":r,"aria-label":r,onClick:n,children:[e.jsx("span",{className:"sb-launcher-glyph","aria-hidden":"true",children:e.jsx(a,{})}),e.jsx("span",{className:"sb-launcher-name",children:s.name}),e.jsxs("span",{className:"sb-launcher-counts","aria-hidden":"true",children:[e.jsx("span",{className:"sb-launcher-running",children:i.running}),e.jsx("span",{className:"sb-launcher-slash",children:"/"}),e.jsx("span",{className:"sb-launcher-needs",children:i.needsYou}),e.jsx("span",{className:"sb-launcher-slash",children:"/"}),e.jsx("span",{className:"sb-launcher-other",children:i.other})]})]})}function Kn({launchers:s,sessions:t,onOpen:n,tooltip:r}){if(!t.length)return null;const o=t.reduce((a,i)=>{const d=se(i);return d==="run"?a.running+=1:d==="need"?a.needsYou+=1:a.other+=1,a},{running:0,needsYou:0,other:0});return e.jsxs("button",{type:"button",className:"sb-launcher-summary","data-launcher-summary":s.map(a=>a.name).join(","),"data-tip":r,"aria-label":r,onClick:n,children:[e.jsx("span",{className:"sb-launcher-summary-mark","aria-hidden":"true",children:s.length}),e.jsxs("span",{className:"sb-launcher-counts","aria-hidden":"true",children:[e.jsx("span",{className:"sb-launcher-running",children:o.running}),e.jsx("span",{className:"sb-launcher-slash",children:"/"}),e.jsx("span",{className:"sb-launcher-needs",children:o.needsYou}),e.jsx("span",{className:"sb-launcher-slash",children:"/"}),e.jsx("span",{className:"sb-launcher-other",children:o.other})]})]})}function zn(s,t){const n=(s||[]).filter(a=>(t||[]).some(i=>i.launcher===a.name)).map(a=>({...a,sessions:t.filter(i=>i.launcher===a.name)})),r=new Set((s||[]).map(a=>a.name)),o=(t||[]).filter(a=>!r.has(a.launcher));return o.length?[...n,{name:"other",harness:"claude",sessions:o}]:n}function Qe({specs:s,sessions:t,page:n}){const r=D(),{offline:o}=be(),{launchers:a}=gt(),i=h.useMemo(()=>zn(a,t||[]),[a,t]),d=h.useMemo(()=>(t||[]).filter(p=>se(p)==="need").length,[t]),c=o?e.jsx("span",{className:"sb-stale","aria-label":r("backend.stale"),"data-tip":r("backend.stale")}):null,l=h.useMemo(()=>jt(s||[]),[s]),{fail:f}=l.scoreCount,g=p=>{const u=wt(p,Rn());u&&M("graph",u,{replace:n==="graph"})},j=(p,u)=>p.length?n==="graph"?()=>g(p):()=>M(u):null;return V({id:"ledger-nodes",side:"right",priority:41,tooltip:r("statusBar.nodes",{n:l.total}),node:e.jsxs("span",{className:"sb-tally",children:[yt.map(p=>e.jsx(xe,{name:`status-${p}`,count:l.status[p].length,onClick:l.status[p].length?()=>g(l.status[p]):null,title:r("stats.statusTitle",{n:l.status[p].length,status:r(`status.${p}`)}),children:e.jsx("i",{className:"sb-status-dot",style:{background:J[p].color}})},p)),c]})}),V({id:"ledger-evals",side:"right",priority:42,kind:f>0?"error":void 0,tooltip:r("statusBar.evals",l.scoreCount),node:e.jsxs("span",{className:"sb-tally",children:[Ln.map(({state:p,always:u,titleKey:S})=>{const k=l.scoreCount[p];return!k&&!u?null:e.jsx(xe,{name:`eval-${p}`,count:k,onClick:j(l.scoreNodes[p],"evals"),title:n==="graph"?r(`stats.${S}`,{n:k}):`${r(`score.${p}`)} · ${r("statusBar.openEvals")}`,children:e.jsx(bt,{state:p})},p)}),c]})}),V({id:"ledger-issues",side:"right",priority:43,tooltip:r("statusBar.issues",{n:l.issueCount}),node:e.jsxs("span",{className:"sb-tally",children:[e.jsx(xe,{name:"issues",count:l.issueCount,onClick:j(l.issueIds,"issues"),title:n==="graph"?r("stats.issueTitle",{n:l.issueCount}):r("statusBar.issues",{n:l.issueCount}),children:e.jsx(R,{name:"issue-opened",size:13})}),c]})}),V({id:"ledger-sessions",side:"right",priority:44,kind:d>0?"warning":void 0,tooltip:r("statusBar.sessions"),node:e.jsxs("span",{className:"sb-launcher-groups",children:[e.jsx("span",{className:"sb-launcher-list",children:i.map(p=>e.jsx(An,{launcher:p,sessions:p.sessions,tooltip:r("statusBar.launcher",{name:p.name}),onOpen:()=>M("sessions")},p.name))}),e.jsx(Kn,{launchers:i,sessions:t||[],onOpen:()=>M("sessions"),tooltip:r("statusBar.launcherSummary",{n:i.length})}),c]})}),null}function Xe({page:s,param:t,query:n,inactive:r=!1}){const o=D(),{split:a}=ae(),{closeSplit:i}=H(),[d,c,l]=oe("spex.splitWidth",620,{min:320,max:1400,dir:-1});return a?e.jsxs("div",{className:"content-split",children:[e.jsx(ye,{page:s,param:t,query:n,inactive:r}),e.jsx("div",{className:"content-divider",onMouseDown:c,onDoubleClick:l,role:"separator","aria-orientation":"vertical"}),e.jsxs("div",{className:"content-second",style:{width:d},children:[e.jsx("button",{type:"button",className:"content-close",onClick:i,"aria-label":o("tabs.close"),children:e.jsx(R,{name:"x",size:12})}),e.jsx(ye,{page:a.page,param:a.param,query:a.query,inactive:r})]})]}):e.jsx(On,{page:s,param:t,query:n,inactive:r})}function Wn({visible:s,onToggle:t}){const n=D(),r=ee(n(s?"contextDock.close":"contextDock.open"),"shell.contextToggle");return e.jsx("button",{type:"button",className:`context-toggle${s?" on":""}`,onClick:t,"aria-pressed":s,"aria-label":r,"data-tip":r,children:e.jsx(R,{name:"panel-right",size:14})})}function Bn({routeOverride:s=null,inactive:t=!1}){const n=D(),r=qs(),{page:o,param:a,query:i}=s||r,{specs:d,sessions:c,identity:l,graphOnly:f}=Ne(),{notify:g}=es(),j=h.useRef(null),p=h.useMemo(()=>(c||[]).filter(x=>se(x)==="need").length,[c]);h.useEffect(()=>{const x=j.current;if(j.current=new Map((c||[]).map(P=>[P.id,P.status])),!!x)for(const P of c||[])P.status!=="asking"||x.get(P.id)==="asking"||g(`${rs(P)} · ${n("status.asking")}`,{kind:"info",onClick:()=>M("sessions",P.id)})},[c,g,n]);const u=Rs(),{dock:S,dockMode:k,palette:w,helpOpen:E}=ae(),{closePalette:C,openPalette:N,toggleHelp:O,closeHelp:A,setDock:b,setDockMode:m,splitTo:y}=H();V({id:"help",side:"left",priority:-1/0,text:"?",tooltip:ee(n("hud.helpTitle"),"graph.help"),onClick:O});const[v,T]=h.useState(()=>{try{return localStorage.getItem("spexcode.ctxOpen")==="1"}catch{return!1}}),K=()=>T(x=>{const P=!x;try{localStorage.setItem("spexcode.ctxOpen",P?"1":"0")}catch{}return P}),$=Tn(o),B=$!=="none"||o==="sessions",G=`${o}/${a??""}`,[vs,Ss,Es]=as(S);h.useEffect(()=>{($==="sessions"||$==="explorer")&&m($)},[G]);const Se=ft({page:o,param:a,query:i},{specs:d,sessions:c,names:u,t:n});h.useEffect(()=>{document.title=`${p>0?`(${p}) `:""}${Se} · ${(l==null?void 0:l.title)||"spexcode"}`},[Se,l==null?void 0:l.title,p]);const Cs=h.useCallback(x=>{var P,Y;if(t)return!1;if(w)return x.key==="Escape"?(x.preventDefault(),C(),!0):!1;if(E){if(x.key==="Escape"||!x.altKey&&!x.ctrlKey&&!x.metaKey&&te("graph.help",x.key))return x.preventDefault(),A(),!0;if(x.key==="j"||x.key==="k"||x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();const F=document.querySelector(".legend-body");return F&&(F.scrollTop+=x.key==="j"||x.key==="ArrowDown"?120:-120),!0}return!0}if((x.key==="Enter"||x.key===" ")&&((Y=(P=x.target)==null?void 0:P.closest)!=null&&Y.call(P,"button, a[href], input, select, textarea, summary")))return!1;if(!x.altKey&&!x.ctrlKey&&!x.metaKey&&te("graph.help",x.key))return x.preventDefault(),C(),O(),!0;if(x.altKey&&!x.metaKey&&!x.ctrlKey){if(!f&&L("shell.newSession",x))return x.preventDefault(),M("sessions","new"),!0;if(!f&&L("shell.evals",x))return x.preventDefault(),C(),M("evals"),!0;if(!f&&L("shell.search",x))return x.preventDefault(),N("sessions"),!0}if(L("shell.dockToggle",x))return x.preventDefault(),b(F=>!F),!0;if(L("shell.dockMode",x))return x.preventDefault(),m(k==="explorer"?"sessions":"explorer"),!0;if(!f&&L("shell.contextToggle",x))return x.preventDefault(),K(),!0;if(!f&&L("shell.tabClose",x))return x.preventDefault(),ne("closeActive"),!0;if(!f&&L("shell.tabNext",x))return x.preventDefault(),ne("move",1),!0;if(!f&&L("shell.tabPrevious",x))return x.preventDefault(),ne("move",-1),!0;if(!f&&L("shell.tabSplit",x)){x.preventDefault();const F=ne("active");return F&&y(F),!0}return!x.altKey&&!x.ctrlKey&&!x.metaKey&&te("graph.settings",x.key)?(x.preventDefault(),o==="settings"?M("sessions"):M("settings"),!0):!x.altKey&&!x.ctrlKey&&!x.metaKey&&te("graph.search",x.key)?(x.preventDefault(),N(($==="sessions"||$==="explorer"?$:k)==="sessions"?"sessions":"nodes"),!0):!1},[A,C,$,k,f,E,t,N,o,w,b,m,y,O,v]);return ss(Cs,t?-1e3:-100),t?e.jsxs("div",{style:{display:"none"},"aria-hidden":"true",children:[e.jsx(Xe,{page:o,param:a,query:i,inactive:!0}),e.jsx(Je,{}),e.jsx(Qe,{specs:d,sessions:c,page:o})]}):f?e.jsxs("div",{className:"app-shell",children:[e.jsxs("div",{className:"app",children:[e.jsx(Fe,{}),e.jsx(Be,{page:"graph",graphOnly:!0}),e.jsx("div",{className:"app-main",children:e.jsx(ye,{page:"graph",param:a,query:i})})]}),e.jsx(De,{})]}):e.jsxs("div",{className:"app-shell",children:[e.jsxs("div",{className:"app",children:[e.jsx(Fe,{}),E&&e.jsx(vn,{onClose:A}),e.jsx(Be,{page:o,needsYou:p,hideDockToggle:!B}),vs&&$!=="none"&&e.jsx(ve,{resetKey:"dock",children:e.jsx(Gt,{closing:Ss,opening:Es,mode:k,specs:d,sessions:c,focusId:o==="spec"?a:null,activeSessionId:o==="sessions"?a:null,suppressSessionRows:o==="sessions"})}),e.jsxs("div",{className:"app-content-column",children:[e.jsxs("div",{className:"app-content-row",children:[e.jsxs("div",{className:"app-main",children:[o!=="sessions"&&e.jsx(mt,{specs:d,sessions:c,route:{page:o,param:a,query:i},trailing:o==="spec"?e.jsx(Wn,{visible:v,onToggle:K}):null}),e.jsx(Xe,{page:o,param:a,query:i,inactive:t})]}),e.jsx(xn,{page:o,param:a,open:v,onToggle:K})]}),e.jsx(Je,{}),e.jsx(Qe,{specs:d,sessions:c,page:o})]})]}),e.jsx(De,{}),w&&e.jsx(un,{specs:d,sessions:c,boost:w==="sessions"?"session":null,onClose:C,onPick:(x,P)=>{if(C(),!(P!=null&&P.newTab))return ge(x==null?void 0:x.address);const Y=xt(x==null?void 0:x.address);W(Y.page,Y.param,Y.query)}}),e.jsx("span",{className:"sr-only",children:n("nav.railLabel")})]})}function Yn({route:s=null,inactive:t=!1}){return e.jsx(Bn,{routeOverride:s,inactive:t})}export{Yn as default};