spexcode 0.5.6 → 0.5.7

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 (32) hide show
  1. package/package.json +1 -1
  2. package/spec-cli/src/cli.ts +18 -1
  3. package/spec-cli/src/client.ts +21 -0
  4. package/spec-cli/src/git.ts +380 -198
  5. package/spec-cli/src/harness.ts +116 -24
  6. package/spec-cli/src/help.ts +3 -1
  7. package/spec-cli/src/index.ts +41 -7
  8. package/spec-cli/src/layout.ts +2 -0
  9. package/spec-cli/src/mentions.ts +10 -5
  10. package/spec-cli/src/process-identity.ts +20 -0
  11. package/spec-cli/src/session-maintenance.ts +2 -1
  12. package/spec-cli/src/sessions.ts +898 -140
  13. package/spec-cli/src/specs.ts +3 -3
  14. package/spec-dashboard/dist/assets/{App-B72LuS5I.js → App-u2P7KdSg.js} +2 -2
  15. package/spec-dashboard/dist/assets/{Dashboard-C5X4Va3V.js → Dashboard-B8wp5_61.js} +3 -3
  16. package/spec-dashboard/dist/assets/{EvalsPage-BTvJIW8Q.js → EvalsPage-Bq1Tkb8y.js} +1 -1
  17. package/spec-dashboard/dist/assets/{IssuesPage-Bn94h_HQ.js → IssuesPage-BlkPSkmv.js} +1 -1
  18. package/spec-dashboard/dist/assets/{MobileApp-ClbtwZ1e.js → MobileApp-B1GxRZXK.js} +2 -2
  19. package/spec-dashboard/dist/assets/{Modal-6l_QtCKF.js → Modal-bAkq9IIT.js} +1 -1
  20. package/spec-dashboard/dist/assets/{PageScroll-B2kxcqJJ.js → PageScroll-px_rUZVJ.js} +1 -1
  21. package/spec-dashboard/dist/assets/{ProjectsPage-C8IPsMKV.js → ProjectsPage-8uGqYM12.js} +1 -1
  22. package/spec-dashboard/dist/assets/SessionInterface-CswwbewF.js +39 -0
  23. package/spec-dashboard/dist/assets/{SessionWindow-Dag_GiJB.js → SessionWindow-IspcLjFA.js} +1 -1
  24. package/spec-dashboard/dist/assets/{Settings-J3aibcXo.js → Settings-bpAbfnmS.js} +1 -1
  25. package/spec-dashboard/dist/assets/{Thread-Dg35J-Pu.js → Thread-BpL3N3kw.js} +11 -11
  26. package/spec-dashboard/dist/assets/{TimelineChat-f0UF9fXq.js → TimelineChat-Ckmb1Ez2.js} +1 -1
  27. package/spec-dashboard/dist/assets/{data-SNi0AmVT.js → data-CQFbQEMH.js} +1 -1
  28. package/spec-dashboard/dist/assets/index-CixSnz1H.css +1 -0
  29. package/spec-dashboard/dist/assets/{index-BUKLPN_4.js → index-Di1ch5dd.js} +5 -5
  30. package/spec-dashboard/dist/index.html +2 -2
  31. package/spec-dashboard/dist/assets/SessionInterface-B5jf7dW7.js +0 -39
  32. package/spec-dashboard/dist/assets/index-CzutlTDf.css +0 -1
@@ -1 +1 @@
1
- import{j as n,u as p,r as h,I as j}from"./index-BUKLPN_4.js";import{W as S,s as N,K as k,a0 as v,Y as z}from"./Thread-Dg35J-Pu.js";function g(s){let e=2166136261;for(let o=0;o<(s||"").length;o++)e^=s.charCodeAt(o),e=Math.imul(e,16777619);return e>>>0}function m(s){return g(s)%360}function H(s){const e=m(s);return{bg:`hsl(${e} 55% 42%)`,fg:`hsl(${e} 70% 92%)`}}function C(s){return`hsl(${m(s)} 65% 50%)`}const x=["◆","▲","●","■","★","✦","⬟","⬢","❖","◈","✸","⟡","✚","❂","◐","◑","⬣","▰","✶","⬤","✹","◇","⊛","✺"],b=["circle","rounded","square","hex"];function T(s){const e=g(s);return{seed:s,glyph:x[(e>>>9)%x.length],shape:b[(e>>>17)%b.length],...H(s)}}function A({seed:s,status:e,title:o,size:l=16}){const a=T(s),t={width:l,height:l};return n.jsx("span",{className:`avatar av-st-${e||"none"}`,"data-tip":o,"aria-label":o,style:t,children:n.jsx("span",{className:`av-face av-gen av-${a.shape}`,style:{...t,background:a.bg,color:a.fg,fontSize:l*.62},children:a.glyph})})}const M={merged:{color:"#859900"},active:{color:"#cb4b16"},drift:{color:"#b58900"},pending:{color:"#93a1a1"}},F={added:"+",edited:"~",deleted:"✕",moved:"→"},L=({size:s=12})=>n.jsx(j,{name:"lock",size:s});function W(s){if(!(s!=null&&s.length))return null;const e={};return s.forEach(o=>{e[o.op]=(e[o.op]||0)+1}),Object.entries(e).map(([o,l])=>`${F[o]}${l}`).join(" ")}function E({guides:s=[],expandable:e,kin:o=0}){return n.jsxs("span",{className:"sess-lead",children:[s.map((l,a)=>{const t=a===s.length-1?l?"tee":"elbow":l?"rail":"gap";return n.jsx("span",{className:`sess-rail ${t}`,"aria-hidden":"true"},a)}),e&&n.jsx("span",{className:"sess-fold pod sess-fold-slot","aria-hidden":"true",children:o})]})}function O({expanded:s,rollup:e,kin:o,onToggle:l}){const a=`${s?"Hide":"Show"} ${o} nested session${o===1?"":"s"}`;return n.jsx("button",{type:"button",tabIndex:-1,className:`sess-fold pod sess-fold-control${s?" open":""}`,style:s?{color:e,borderColor:e}:{background:e,borderColor:e},"aria-expanded":s,"aria-label":a,"data-tip":a,onMouseDown:t=>t.preventDefault(),onClick:t=>{t.stopPropagation(),l()},children:o})}function P(){const[s,e]=h.useState(()=>new Set),o=a=>e(t=>{const c=new Set(t);return c.has(a)?c.delete(a):c.add(a),c}),l=h.useCallback(a=>e(t=>{const c=a.filter(u=>u&&!t.has(u));if(!c.length)return t;const d=new Set(t);return c.forEach(u=>d.add(u)),d}),[]);return{expanded:s,toggle:o,expand:l}}function D({s,locked:e,showAvatar:o=!0,lead:l=null}){const a=p(),t=W(s.ops),c=N(s),d=a(`status.${s.status}`);return n.jsxs(n.Fragment,{children:[l,o&&n.jsx(A,{seed:s.id,status:s.status,title:`${k(s)} · ${d} — ${s.id.slice(0,8)}`}),n.jsxs("span",{className:"sess-meta",children:[n.jsx("span",{className:"sess-glyph",style:{color:z[s.status]},"data-tip":d,"aria-label":d,children:v[s.status]}),t&&n.jsx("span",{className:"sess-ops",children:t})]}),n.jsx("span",{className:"sess-id","data-tip":c,children:c}),s.archiveHazard&&n.jsx("span",{className:"sess-hazard","data-tip":s.archiveHazard,"aria-label":s.archiveHazard,children:n.jsx(j,{name:"issue-opened",size:13})}),e&&n.jsx("span",{className:"sess-lock","data-tip":a("sessionWindow.lockedTitle"),children:n.jsx(L,{})})]})}function G({item:s,baseClass:e,onToggle:o}){const l=p(),a=`${e} ${e}-${s.zone}${s.zone==="offline"?` si-zone-fold${s.folded?"":" open"}`:""}`;if(s.zone!=="offline")return n.jsx("div",{className:a,children:l(`sessionZone.${s.zone}`)});const t=l(s.folded?"sessionZone.showHistory":"sessionZone.hideHistory",{n:s.count});return n.jsxs("div",{className:a,children:[s.count>0&&n.jsx("button",{type:"button",tabIndex:-1,className:"si-zone-count","aria-expanded":!s.folded,"aria-label":t,"data-tip":t,onMouseDown:c=>c.preventDefault(),onClick:o,children:s.count}),n.jsx("span",{className:"si-zone-label",children:l(`sessionZone.${s.zone}`)})]})}function Y({sessions:s,activeId:e,onPick:o,onOpenSession:l}){const a=p(),{expanded:t,toggle:c}=P(),[d,u]=h.useState(!1),w=h.useMemo(()=>S(s,r=>t.has(r),{zoneFolded:r=>r==="offline"&&!d,keepVisible:r=>r.source===e}),[s,t,d,e]);return n.jsx("div",{className:"sesswin",children:s.length===0?n.jsxs("div",{className:"sesswin-empty",children:[a("sessionWindow.emptyBefore"),n.jsx("kbd",{children:"⏎"}),a("sessionWindow.emptyAfter")]}):w.map(r=>{if(r.type==="zone")return n.jsx(G,{item:r,baseClass:"sesswin-zone",onToggle:()=>u(y=>!y)},`zone-${r.zone}`);const i=r.s,f=i.source===e,$=r.expandable||r.depth?n.jsx(E,{guides:r.guides,expandable:r.expandable,kin:r.kin}):null;return n.jsxs("div",{className:"sess-tree-row sesswin-tree-row",style:{"--sess-fold-indent":`${r.depth*14}px`},children:[n.jsx("button",{type:"button",className:f?"sess-row locked":"sess-row",style:{"--ov":C(i.id)},onClick:()=>o(i),onDoubleClick:()=>l(i.id),"data-tip":a("sessionWindow.rowTitle"),children:n.jsx(D,{s:i,locked:f,lead:$})}),r.expandable&&n.jsx(O,{expanded:r.expanded,rollup:r.rollup,kin:r.kin,onToggle:()=>c(i.id)})]},i.id)})})}export{A,O as F,F as G,L,E as R,G as S,D as a,M as b,Y as c,C as l,P as u};
1
+ import{j as n,u as p,r as h,I as j}from"./index-Di1ch5dd.js";import{W as S,s as N,K as k,a0 as v,Y as z}from"./Thread-BpL3N3kw.js";function g(s){let e=2166136261;for(let o=0;o<(s||"").length;o++)e^=s.charCodeAt(o),e=Math.imul(e,16777619);return e>>>0}function m(s){return g(s)%360}function H(s){const e=m(s);return{bg:`hsl(${e} 55% 42%)`,fg:`hsl(${e} 70% 92%)`}}function C(s){return`hsl(${m(s)} 65% 50%)`}const x=["◆","▲","●","■","★","✦","⬟","⬢","❖","◈","✸","⟡","✚","❂","◐","◑","⬣","▰","✶","⬤","✹","◇","⊛","✺"],b=["circle","rounded","square","hex"];function T(s){const e=g(s);return{seed:s,glyph:x[(e>>>9)%x.length],shape:b[(e>>>17)%b.length],...H(s)}}function A({seed:s,status:e,title:o,size:l=16}){const a=T(s),t={width:l,height:l};return n.jsx("span",{className:`avatar av-st-${e||"none"}`,"data-tip":o,"aria-label":o,style:t,children:n.jsx("span",{className:`av-face av-gen av-${a.shape}`,style:{...t,background:a.bg,color:a.fg,fontSize:l*.62},children:a.glyph})})}const M={merged:{color:"#859900"},active:{color:"#cb4b16"},drift:{color:"#b58900"},pending:{color:"#93a1a1"}},F={added:"+",edited:"~",deleted:"✕",moved:"→"},L=({size:s=12})=>n.jsx(j,{name:"lock",size:s});function W(s){if(!(s!=null&&s.length))return null;const e={};return s.forEach(o=>{e[o.op]=(e[o.op]||0)+1}),Object.entries(e).map(([o,l])=>`${F[o]}${l}`).join(" ")}function E({guides:s=[],expandable:e,kin:o=0}){return n.jsxs("span",{className:"sess-lead",children:[s.map((l,a)=>{const t=a===s.length-1?l?"tee":"elbow":l?"rail":"gap";return n.jsx("span",{className:`sess-rail ${t}`,"aria-hidden":"true"},a)}),e&&n.jsx("span",{className:"sess-fold pod sess-fold-slot","aria-hidden":"true",children:o})]})}function O({expanded:s,rollup:e,kin:o,onToggle:l}){const a=`${s?"Hide":"Show"} ${o} nested session${o===1?"":"s"}`;return n.jsx("button",{type:"button",tabIndex:-1,className:`sess-fold pod sess-fold-control${s?" open":""}`,style:s?{color:e,borderColor:e}:{background:e,borderColor:e},"aria-expanded":s,"aria-label":a,"data-tip":a,onMouseDown:t=>t.preventDefault(),onClick:t=>{t.stopPropagation(),l()},children:o})}function P(){const[s,e]=h.useState(()=>new Set),o=a=>e(t=>{const c=new Set(t);return c.has(a)?c.delete(a):c.add(a),c}),l=h.useCallback(a=>e(t=>{const c=a.filter(u=>u&&!t.has(u));if(!c.length)return t;const d=new Set(t);return c.forEach(u=>d.add(u)),d}),[]);return{expanded:s,toggle:o,expand:l}}function D({s,locked:e,showAvatar:o=!0,lead:l=null}){const a=p(),t=W(s.ops),c=N(s),d=a(`status.${s.status}`);return n.jsxs(n.Fragment,{children:[l,o&&n.jsx(A,{seed:s.id,status:s.status,title:`${k(s)} · ${d} — ${s.id.slice(0,8)}`}),n.jsxs("span",{className:"sess-meta",children:[n.jsx("span",{className:"sess-glyph",style:{color:z[s.status]},"data-tip":d,"aria-label":d,children:v[s.status]}),t&&n.jsx("span",{className:"sess-ops",children:t})]}),n.jsx("span",{className:"sess-id","data-tip":c,children:c}),s.archiveHazard&&n.jsx("span",{className:"sess-hazard","data-tip":s.archiveHazard,"aria-label":s.archiveHazard,children:n.jsx(j,{name:"issue-opened",size:13})}),e&&n.jsx("span",{className:"sess-lock","data-tip":a("sessionWindow.lockedTitle"),children:n.jsx(L,{})})]})}function G({item:s,baseClass:e,onToggle:o}){const l=p(),a=`${e} ${e}-${s.zone}${s.zone==="offline"?` si-zone-fold${s.folded?"":" open"}`:""}`;if(s.zone!=="offline")return n.jsx("div",{className:a,children:l(`sessionZone.${s.zone}`)});const t=l(s.folded?"sessionZone.showHistory":"sessionZone.hideHistory",{n:s.count});return n.jsxs("div",{className:a,children:[s.count>0&&n.jsx("button",{type:"button",tabIndex:-1,className:"si-zone-count","aria-expanded":!s.folded,"aria-label":t,"data-tip":t,onMouseDown:c=>c.preventDefault(),onClick:o,children:s.count}),n.jsx("span",{className:"si-zone-label",children:l(`sessionZone.${s.zone}`)})]})}function Y({sessions:s,activeId:e,onPick:o,onOpenSession:l}){const a=p(),{expanded:t,toggle:c}=P(),[d,u]=h.useState(!1),w=h.useMemo(()=>S(s,r=>t.has(r),{zoneFolded:r=>r==="offline"&&!d,keepVisible:r=>r.source===e}),[s,t,d,e]);return n.jsx("div",{className:"sesswin",children:s.length===0?n.jsxs("div",{className:"sesswin-empty",children:[a("sessionWindow.emptyBefore"),n.jsx("kbd",{children:"⏎"}),a("sessionWindow.emptyAfter")]}):w.map(r=>{if(r.type==="zone")return n.jsx(G,{item:r,baseClass:"sesswin-zone",onToggle:()=>u(y=>!y)},`zone-${r.zone}`);const i=r.s,f=i.source===e,$=r.expandable||r.depth?n.jsx(E,{guides:r.guides,expandable:r.expandable,kin:r.kin}):null;return n.jsxs("div",{className:"sess-tree-row sesswin-tree-row",style:{"--sess-fold-indent":`${r.depth*14}px`},children:[n.jsx("button",{type:"button",className:f?"sess-row locked":"sess-row",style:{"--ov":C(i.id)},onClick:()=>o(i),onDoubleClick:()=>l(i.id),"data-tip":a("sessionWindow.rowTitle"),children:n.jsx(D,{s:i,locked:f,lead:$})}),r.expandable&&n.jsx(O,{expanded:r.expanded,rollup:r.rollup,kin:r.kin,onToggle:()=>c(i.id)})]},i.id)})})}export{A,O as F,F as G,L,E as R,G as S,D as a,M as b,Y as c,C as l,P as u};
@@ -1 +1 @@
1
- import{B as x,r as o,j as e,L as N}from"./index-BUKLPN_4.js";import{A as j,k as b,a as T,i as f,r as S,s as k}from"./bindings-BC9vqpYU.js";import{P as v}from"./PageScroll-B2kxcqJJ.js";import{g as E,T as y,a as C,b as A,s as F}from"./terminalFont-C6oGNKrf.js";const h="spexcode.theme",g=[{code:"minimal",label:"Minimal"},{code:"things",label:"Things"},{code:"tokyonight",label:"Tokyo Night"},{code:"catppuccin",label:"Catppuccin"},{code:"everforest",label:"Everforest"},{code:"gruvbox",label:"Gruvbox"},{code:"rosepine",label:"Rosé Pine Dawn"},{code:"dracula",label:"Dracula"}],u=new Set(g.map(s=>s.code)),p="minimal";function L(){try{const s=localStorage.getItem(h);if(u.has(s))return s}catch{}return p}function w(s){const i=u.has(s)?s:p;try{document.documentElement.setAttribute("data-theme",i)}catch{}try{localStorage.setItem(h,i)}catch{}return i}function M({t:s}){const[i,d]=o.useState(0),[c,l]=o.useState(null),r=()=>d(n=>n+1);return o.useEffect(()=>{if(!c)return;const n=a=>{if(a.preventDefault(),a.stopPropagation(),a.key==="Escape"){l(null);return}["Shift","Control","Alt","Meta"].includes(a.key)||(k(c,{keys:[a.key]}),l(null),r())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[c]),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secShortcuts")}),e.jsx("div",{className:"set-keys",children:j.map(n=>e.jsxs("div",{className:"set-key-row",children:[e.jsx("span",{className:"legend-desc",children:s(n.desc)}),e.jsx("button",{className:`bind-cell${c===n.id?" capturing":""}${n.rebind?"":" fixed"}${f(n.id)?" custom":""}`,disabled:!n.rebind,onClick:()=>n.rebind&&l(n.id),children:c===n.id?e.jsx("span",{className:"bind-hint",children:s("settings.bindPrompt")}):b(n.id).map((a,m)=>e.jsx("kbd",{children:T(a)},m))})]},n.id))}),e.jsxs("div",{className:"set-foot",children:[e.jsx("span",{className:"legend-desc set-hint",children:s("settings.shortcutsHint")}),e.jsx("button",{className:"set-reset",onClick:()=>{S(),l(null),r()},children:s("settings.reset")})]})]})}function D(){const{t:s,lang:i,setLang:d}=x(),[c,l]=o.useState(L),[r,n]=o.useState(E),a=t=>{w(t),l(t)},m=t=>n(F(t));return e.jsx(v,{className:"page-settings-scroll",children:e.jsxs("div",{className:"settings-body",children:[e.jsx("h1",{className:"page-title",children:s("settings.title")}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secLanguage")}),e.jsx("div",{className:"set-langs",children:N.map(t=>e.jsx("button",{className:t.code===i?"set-lang on":"set-lang",onClick:()=>d(t.code),"aria-pressed":t.code===i,children:t.label},t.code))})]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secTheme")}),e.jsx("div",{className:"set-langs",children:g.map(t=>e.jsx("button",{className:t.code===c?"set-lang on":"set-lang",onClick:()=>a(t.code),"aria-pressed":t.code===c,children:s(t.label)},t.code))})]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secTerminal")}),e.jsxs("label",{className:"set-terminal-font",children:[e.jsx("span",{children:s("settings.terminalFontSize")}),e.jsx("input",{type:"range",min:A,max:C,step:y,value:r,onChange:t=>m(t.target.value)}),e.jsxs("output",{children:[r,"px"]})]})]}),e.jsx(M,{t:s})]})})}export{D as default};
1
+ import{B as x,r as o,j as e,L as N}from"./index-Di1ch5dd.js";import{A as j,k as b,a as T,i as f,r as S,s as k}from"./bindings-BC9vqpYU.js";import{P as v}from"./PageScroll-px_rUZVJ.js";import{g as E,T as y,a as C,b as A,s as F}from"./terminalFont-C6oGNKrf.js";const h="spexcode.theme",g=[{code:"minimal",label:"Minimal"},{code:"things",label:"Things"},{code:"tokyonight",label:"Tokyo Night"},{code:"catppuccin",label:"Catppuccin"},{code:"everforest",label:"Everforest"},{code:"gruvbox",label:"Gruvbox"},{code:"rosepine",label:"Rosé Pine Dawn"},{code:"dracula",label:"Dracula"}],u=new Set(g.map(s=>s.code)),p="minimal";function L(){try{const s=localStorage.getItem(h);if(u.has(s))return s}catch{}return p}function w(s){const i=u.has(s)?s:p;try{document.documentElement.setAttribute("data-theme",i)}catch{}try{localStorage.setItem(h,i)}catch{}return i}function M({t:s}){const[i,d]=o.useState(0),[c,l]=o.useState(null),r=()=>d(n=>n+1);return o.useEffect(()=>{if(!c)return;const n=a=>{if(a.preventDefault(),a.stopPropagation(),a.key==="Escape"){l(null);return}["Shift","Control","Alt","Meta"].includes(a.key)||(k(c,{keys:[a.key]}),l(null),r())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[c]),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secShortcuts")}),e.jsx("div",{className:"set-keys",children:j.map(n=>e.jsxs("div",{className:"set-key-row",children:[e.jsx("span",{className:"legend-desc",children:s(n.desc)}),e.jsx("button",{className:`bind-cell${c===n.id?" capturing":""}${n.rebind?"":" fixed"}${f(n.id)?" custom":""}`,disabled:!n.rebind,onClick:()=>n.rebind&&l(n.id),children:c===n.id?e.jsx("span",{className:"bind-hint",children:s("settings.bindPrompt")}):b(n.id).map((a,m)=>e.jsx("kbd",{children:T(a)},m))})]},n.id))}),e.jsxs("div",{className:"set-foot",children:[e.jsx("span",{className:"legend-desc set-hint",children:s("settings.shortcutsHint")}),e.jsx("button",{className:"set-reset",onClick:()=>{S(),l(null),r()},children:s("settings.reset")})]})]})}function D(){const{t:s,lang:i,setLang:d}=x(),[c,l]=o.useState(L),[r,n]=o.useState(E),a=t=>{w(t),l(t)},m=t=>n(F(t));return e.jsx(v,{className:"page-settings-scroll",children:e.jsxs("div",{className:"settings-body",children:[e.jsx("h1",{className:"page-title",children:s("settings.title")}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secLanguage")}),e.jsx("div",{className:"set-langs",children:N.map(t=>e.jsx("button",{className:t.code===i?"set-lang on":"set-lang",onClick:()=>d(t.code),"aria-pressed":t.code===i,children:t.label},t.code))})]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secTheme")}),e.jsx("div",{className:"set-langs",children:g.map(t=>e.jsx("button",{className:t.code===c?"set-lang on":"set-lang",onClick:()=>a(t.code),"aria-pressed":t.code===c,children:s(t.label)},t.code))})]}),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secTerminal")}),e.jsxs("label",{className:"set-terminal-font",children:[e.jsx("span",{children:s("settings.terminalFontSize")}),e.jsx("input",{type:"range",min:A,max:C,step:y,value:r,onChange:t=>m(t.target.value)}),e.jsxs("output",{children:[r,"px"]})]})]}),e.jsx(M,{t:s})]})})}export{D as default};
@@ -1,13 +1,13 @@
1
- import{r as x,j as n,I as R,u as D,e as he,p as ns,t as ts,d as pe,g as P,v as as,w as rs,n as ne,x as ls,E as is,s as ge}from"./index-BUKLPN_4.js";import{P as Z}from"./PageScroll-B2kxcqJJ.js";import{m as cs,n as me,o as os,q as ds,r as us}from"./data-SNi0AmVT.js";const q={working:"var(--green)",parked:"var(--green)",asking:"var(--yellow)",review:"var(--yellow)",done:"var(--yellow)",error:"var(--red)",idle:"var(--muted)",starting:"var(--muted)",queued:"var(--muted)","close-pending":"var(--muted)",offline:"var(--muted)",unknown:"var(--yellow)",corrupt:"var(--red)",retired:"var(--muted)"},Vn={working:"●",parked:"‖",asking:"?",review:"◑",done:"✓",error:"✕",idle:"·",starting:"◌",queued:"⋯","close-pending":"⊘",offline:"○",unknown:"⁇",corrupt:"⚠",retired:"⚑"},Ve=new Set(["asking","review","done","close-pending","error","corrupt"]),ee=e=>(e==null?void 0:e.liveness)==="offline"||(e==null?void 0:e.status)==="offline"?"offline":Ve.has(e==null?void 0:e.status)?"need":"run",je=e=>!!(e!=null&&e.archived),Pn=(e=[])=>({live:e.filter(s=>!je(s)),archived:e.filter(je)}),fs=(e,s)=>{const a=s?(e||[]).find(t=>t.id===s):null;return a&&ee(a)!=="offline"?a:null},we=e=>(e==null?void 0:e.sortKey)!=null?e.sortKey:(e==null?void 0:e.created)??0,ye=e=>{const s={need:0,run:1,offline:2};return[...e].sort((a,t)=>s[ee(a)]-s[ee(t)]||we(t)-we(a))},Fn=e=>(e==null?void 0:e.label)||(e==null?void 0:e.name)||(e==null?void 0:e.node)||(e==null?void 0:e.title)||(e==null?void 0:e.branch)||(e==null?void 0:e.id),hs=e=>(e==null?void 0:e.headline)||(e==null?void 0:e.name)||(e==null?void 0:e.activity)||(e==null?void 0:e.promptPreview)||(e==null?void 0:e.node)||(e==null?void 0:e.title)||(e==null?void 0:e.branch)||(e==null?void 0:e.id);function ps(e){const s=new Set(e.map(r=>r==null?void 0:r.id)),a=new Map,t=[];for(const r of e){const i=r!=null&&r.parent&&r.parent!==r.id&&s.has(r.parent)?r.parent:null;if(i){const l=a.get(i)||[];l.push(r),a.set(i,l)}else t.push(r)}return{roots:t,childrenOf:a}}function qn(e,s){const a=new Map(e.map(l=>[l==null?void 0:l.id,l])),t=[],r=new Set([s]);let i=a.get(s);for(;i!=null&&i.parent&&!r.has(i.parent);){const l=a.get(i.parent);if(!l)break;t.push(l.id),r.add(l.id),i=l}return t}function ms(e,s){let a=!1,t=!1,r=0;const i=(l,c)=>{for(const o of s.get(l)||[])c.has(o.id)||(c.add(o.id),r++,Ve.has(o.status)?a=!0:q[o.status]===q.working&&(t=!0),i(o.id,c))};return i(e,new Set([e])),{color:a?q.asking:t?q.working:q.idle,count:r}}function vs(e,s,{zoneFolded:a=()=>!1,keepVisible:t=()=>!1}={}){const{roots:r,childrenOf:i}=ps(e),l=[],c=(d,j,p,g)=>{const f=i.get(d.id)||[],y=f.length>0,k=y&&!!s(d.id),S=y?ms(d.id,i):null;if(l.push({type:"row",s:d,depth:j,expandable:y,expanded:k,rollup:(S==null?void 0:S.color)??null,kin:(S==null?void 0:S.count)??0,guides:g}),k){const A=ye(f).filter(N=>!p.has(N.id));A.forEach((N,m)=>{p.add(N.id),c(N,j+1,p,[...g,m<A.length-1])})}},o=(d,j)=>{let p=1;for(const g of i.get(d.id)||[])j.has(g.id)||(j.add(g.id),p+=o(g,j));return p},u=new Set;let h=null,v=null;for(const d of ye(r)){if(u.has(d.id))continue;const j=ee(d);if(j!==h&&(v={type:"zone",zone:j,count:0,folded:!!a(j)},l.push(v),h=j),v.count+=o(d,new Set([...u,d.id])),v.folded){const p=[],g=(f,y)=>{t(f)&&!u.has(f.id)&&p.push(f);for(const k of i.get(f.id)||[])y.has(k.id)||(y.add(k.id),g(k,y))};g(d,new Set([d.id]));for(const f of p)u.add(f.id),l.push({type:"row",s:f,depth:0,expandable:!1,expanded:!1,rollup:null,kin:0,guides:[]});u.add(d.id);continue}u.add(d.id),c(d,0,u,[])}return l}const Mn=e=>vs(e,()=>!0).filter(s=>s.type==="row").map(s=>s.s),te=typeof window<"u"?window.__escStack||(window.__escStack=[]):[];typeof window<"u"&&!window.__escStackBound&&(window.__escStackBound=!0,window.addEventListener("keydown",e=>{const s=window.__escStack;e.key!=="Escape"||!s||s.length===0||(e.preventDefault(),e.stopImmediatePropagation(),s[s.length-1].close())},!0));function Pe(e,s){const a=x.useRef(s);a.current=s,x.useEffect(()=>{if(!e)return;const t={close:()=>{var r;return(r=a.current)==null?void 0:r.call(a)}};return te.push(t),()=>{const r=te.indexOf(t);r>=0&&te.splice(r,1)}},[e])}const W=new Map;async function xs(e){if(W.has(e))return W.get(e);const s=cs(e).then(async a=>{const t=await a.json().catch(()=>null);if(!a.ok)throw new Error((t==null?void 0:t.error)||`HTTP ${a.status}`);return t}).finally(()=>W.delete(e));return W.set(e,s),s}const Kn=e=>{const s=typeof e=="string"&&/^\d+$/.test(e)?Number(e):Number.NaN;return Number.isSafeInteger(s)&&s>0?s:1};function gs(e,s){return s<=0?[]:s<=10?Array.from({length:s},(a,t)=>t+1):e<=7?[...Array.from({length:8},(a,t)=>t+1),"gap",s-1,s]:e>=s-6||e>s?[1,2,"gap",...Array.from({length:8},(a,t)=>s-7+t)]:[1,2,"gap",e-2,e-1,e,e+1,e+2,"gap",s-1,s]}function Fe(e,s,a,{enabled:t=!0,refreshKey:r=null,pollMs:i=15e3,view:l=null}={}){const[c,o]=x.useState(null),[u,h]=x.useState(null),[v,d]=x.useState(t),j=x.useRef(0),p=x.useCallback(async({quiet:f=!1}={})=>{if(!t)return null;const y=++j.current;f||d(!0),h(null);const k=new URLSearchParams({q:String(s||""),page:String(a)});l&&k.set("view",l);try{const S=await xs(`/api/${e}?${k}`);return y===j.current&&o(A=>A&&S&&A.revision===S.revision?A:S),S}catch(S){return y===j.current&&h(S instanceof Error?S.message:String(S)),null}finally{y===j.current&&d(!1)}},[e,t,a,s,l]),g=x.useRef(null);return x.useEffect(()=>{if(!t){d(!1);return}const f=`${e}\0${s}\0${a}\0${l||""}`,y=f!==g.current;g.current=f,y&&o(null),p({quiet:!y});const k=i>0?setInterval(()=>p({quiet:!0}),i):null;return()=>{k&&clearInterval(k)}},[e,s,a,l,t,p,i,r]),{data:c,error:u,loading:v,reload:p}}const be={issue:{open:{icon:"issue-opened",tone:"open",label:"reviewState.issueOpen"},closed:{icon:"issue-closed",tone:"closed",label:"reviewState.issueClosed"}},eval:{pass:{icon:"circle-check",tone:"pass",label:"score.pass"},fail:{icon:"circle-x",tone:"fail",label:"score.fail"},stalePass:{icon:"circle-check",tone:"stale",label:"score.stalePass"},staleFail:{icon:"circle-x",tone:"stale",label:"score.staleFail"},review:{icon:"clock",tone:"review",label:"reviewList.needsReview"},empty:{icon:"circle-minus",tone:"empty",label:"score.empty"},missing:{icon:"circle-dashed",tone:"empty",label:"score.missing"},legacy:{icon:"circle-minus",tone:"empty",label:"score.empty"}}},js=(e,s)=>{var t;const a=e==="issue"?s==="open"?"open":"closed":s||"empty";return((t=be[e])==null?void 0:t[a])||be.eval.empty};function ve({kind:e,state:s,showLabel:a=!1,size:t=16,className:r="",title:i}){const l=D(),c=js(e,s),o=i||l(c.label);return n.jsxs("span",{className:`review-state ${e} ${c.tone} ${r}`,"data-tip":o,"aria-label":o,children:[n.jsx("span",{className:"review-state-icon",style:{width:t,height:t},children:n.jsx(R,{name:c.icon,size:t})}),a&&n.jsx("span",{className:"review-state-label",children:o})]})}function ws(e,s){const a={...e,...s};for(const[t,r]of Object.entries(a))(r==null||r==="")&&delete a[t];return a}const ys=e=>e&&typeof e=="object"?e.hasData?e.filtered:e.dataset:e,qe=(e,s,a)=>{const t=Array.isArray(e)?e:[];return!(s!=null&&String(s)!=="")||a==null||t.some(i=>String(i.value)==="")?t:[{value:"",label:a},...t]},bs=(e=[])=>e.reduce((s,a)=>((a.active??(a.value!=null&&String(a.value)!==""))&&(s.mobile+=1,a.mobileOnly||(s.desktop+=1)),s),{desktop:0,mobile:0}),xe=(e,s,a)=>s?a==="Home"?0:a==="End"?s-1:a==="ArrowDown"||a==="ArrowRight"?e<0?0:(e+1)%s:a==="ArrowUp"||a==="ArrowLeft"?e<0?s-1:(e-1+s)%s:e:-1,Ns=(e,s)=>{var t;const a=e==null?void 0:e.tagName;return a==="INPUT"||a==="TEXTAREA"||a==="SELECT"||a==="BUTTON"&&(s==="Enter"||s===" ")||s==="Enter"&&((t=e==null?void 0:e.closest)!=null&&t.call(e,"a[href]"))?!1:s==="j"||s==="k"||s==="Enter"},ae=e=>[...(e==null?void 0:e.querySelectorAll('[role="menuitemradio"]'))||[]].filter(s=>s.getClientRects().length>0),re=(e,s)=>{const a=e[s];if(a){for(const t of e)t.tabIndex=t===a?0:-1;a.focus()}};function Me(){const[e,s]=x.useState(!1),a=x.useRef(null),t=x.useRef(null),r=x.useRef(null),i=x.useRef("checked"),l=(d=!1)=>{var j;d&&((j=r.current)==null||j.focus()),s(!1)},c=(d,j="checked")=>{r.current=d,i.current=j,s(!0)},o=d=>{e?l(!1):c(d)};return Pe(e,()=>l(!0)),x.useEffect(()=>{if(!e)return;const d=j=>{var p;(p=a.current)!=null&&p.contains(j.target)||l(!1)};return window.addEventListener("pointerdown",d,!0),()=>window.removeEventListener("pointerdown",d,!0)},[e]),x.useEffect(()=>{if(!e)return;const d=requestAnimationFrame(()=>{const j=ae(t.current),p=j.findIndex(f=>f.getAttribute("aria-checked")==="true"),g=i.current==="last"?j.length-1:i.current==="first"?0:p>=0?p:0;re(j,g)});return()=>cancelAnimationFrame(d)},[e]),{open:e,ref:a,menuRef:t,close:l,toggle:o,onTriggerKeyDown:d=>{d.key!=="ArrowDown"&&d.key!=="ArrowUp"||(d.preventDefault(),d.stopPropagation(),c(d.currentTarget,d.key==="ArrowUp"?"last":"first"))},onMenuKeyDown:d=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(d.key))return;const j=ae(t.current),p=j.indexOf(document.activeElement);d.preventDefault(),d.stopPropagation(),re(j,xe(p,j.length,d.key))},onItemFocus:d=>{const j=ae(t.current);re(j,j.indexOf(d.currentTarget))}}}function On({label:e,value:s="",options:a=[],onChange:t,mobile:r=!1,clearLabel:i}){const l=Me(),c=qe(a,s,i);if(!c.length)return null;const o=c.find(v=>String(v.value)===String(s)),u=s?(o==null?void 0:o.label)||String(s):"",h=u?`${e}: ${u}`:e;return n.jsxs("div",{className:`rl-facet-wrap ${r?"mobile-stay":""}`,ref:l.ref,children:[n.jsxs("button",{type:"button",className:`rl-facet ${s?"active":""}`,"aria-label":h,"aria-haspopup":"menu","aria-expanded":l.open,onClick:v=>l.toggle(v.currentTarget),onKeyDown:l.onTriggerKeyDown,children:[n.jsx("span",{className:"rl-facet-label",children:h}),r&&n.jsx("span",{className:"rl-facet-label-mobile","aria-hidden":"true",children:u||e}),n.jsx(R,{name:"chevron-down",size:12})]}),l.open&&n.jsx("div",{className:"rl-menu",role:"menu","aria-label":e,ref:l.menuRef,onKeyDown:l.onMenuKeyDown,children:c.map(v=>n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":String(v.value)===String(s),tabIndex:-1,className:"rl-menu-item",onFocus:l.onItemFocus,onClick:()=>{l.close(!0),t(v.value)},children:[n.jsx(R,{name:String(v.value)===String(s)?"check":"blank",size:13}),n.jsx("span",{children:v.label}),v.count!=null&&n.jsx("span",{className:"rl-menu-count",children:v.count})]},String(v.value)))})]})}function ks({label:e,groups:s=[],clearLabel:a,compact:t=!1,className:r=""}){const i=D(),l=x.useId(),c=s.map(d=>({...d,options:qe(d.options,d.value,d.clearLabel===null?null:d.clearLabel||a)})).filter(d=>d.options.length),o=c.some(d=>!d.mobileOnly),u=bs(c),h=Me();if(!c.length)return null;const v=(d,j)=>d>0&&n.jsxs("span",{className:`rl-secondary-filter-count ${j}`,children:[n.jsx("span",{"aria-hidden":"true",children:d}),n.jsx("span",{className:"sr-only",children:i("reviewList.activeFilters",{n:d})})]});return n.jsxs("div",{className:`rl-secondary-filters ${o?"":"mobile-only"} ${u.desktop?"active-desktop":""} ${u.mobile?"active-mobile":""} ${r}`,ref:h.ref,children:[t?n.jsx(he,{icon:"filter",size:16,className:"rl-secondary-filters-trigger compact",label:e,"aria-haspopup":"menu","aria-expanded":h.open,onClick:d=>h.toggle(d.currentTarget),onKeyDown:h.onTriggerKeyDown}):n.jsxs("button",{type:"button",className:"rl-secondary-filters-trigger","aria-haspopup":"menu","aria-expanded":h.open,onClick:d=>h.toggle(d.currentTarget),onKeyDown:h.onTriggerKeyDown,children:[n.jsx(R,{name:"filter",size:14}),n.jsx("span",{children:e}),v(u.desktop,"for-desktop"),v(u.mobile,"for-mobile"),n.jsx(R,{name:"chevron-down",size:12})]}),h.open&&n.jsx("div",{className:"rl-menu rl-secondary-filters-menu",role:"menu","aria-label":e,ref:h.menuRef,onKeyDown:h.onMenuKeyDown,children:c.map((d,j)=>n.jsxs("div",{role:"group","aria-labelledby":`${l}-group-${j}`,className:`rl-menu-group ${d.mobileOnly?"mobile-only":""}`,children:[n.jsx("div",{className:"rl-menu-label",id:`${l}-group-${j}`,children:d.label}),d.options.map(p=>n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":String(p.value)===String(d.value||""),tabIndex:-1,className:"rl-menu-item",onFocus:h.onItemFocus,onClick:()=>{h.close(!0),d.onChange(p.value)},children:[n.jsx(R,{name:String(p.value)===String(d.value||"")?"check":"blank",size:13}),n.jsx("span",{children:p.label}),p.count!=null&&n.jsx("span",{className:"rl-menu-count",children:p.count})]},String(p.value)))]},`${d.label}-${d.mobileOnly?"mobile":"all"}`))})]})}function _n({state:e,title:s,meta:a,aside:t}){return n.jsxs("div",{className:"rl-row-grid",children:[n.jsx("div",{className:"rl-row-state",children:e}),n.jsxs("div",{className:"rl-row-body",children:[n.jsx("div",{className:"rl-row-title",children:s}),a&&n.jsx("div",{className:"rl-row-meta",children:a})]}),t&&n.jsx("div",{className:"rl-row-aside",children:t})]})}const G=e=>{const s=String(e??"").trim();return s?`${s} `:""};function Ss({value:e="",onSubmit:s,placeholder:a,label:t,keys:r=[],suggest:i={}}){const[l,c]=x.useState(()=>G(e)),[o,u]=x.useState(-1),[h,v]=x.useState(-1),d=x.useRef(null),j=x.useRef(null),p=x.useId(),g=x.useRef(null),f=m=>requestAnimationFrame(()=>{const E=d.current;E&&(m&&E.focus(),E.setSelectionRange(E.value.length,E.value.length))});x.useEffect(()=>{c(G(e)),u(-1),v(-1),f(g.current!==null&&g.current!==e),g.current=e},[e]);const y=o>=0?ns(l,o,r,i):{start:0,end:0,items:[]},k=y.items.length>0;Pe(k,()=>u(-1));const S=()=>{j.current&&d.current&&(j.current.scrollLeft=d.current.scrollLeft)};x.useEffect(S);const A=m=>{u(-1),v(-1);const E=m.trim();c(G(E)||G(e)),f(!0),s(E)},N=m=>{const E=`${l.slice(0,y.start)}${m.insert}${l.slice(y.end)}`;if(c(E),m.type==="value"){A(E);return}const C=y.start+m.insert.length;u(C),v(-1),requestAnimationFrame(()=>{var w,$;(w=d.current)==null||w.focus(),($=d.current)==null||$.setSelectionRange(C,C)})};return n.jsxs("form",{className:"rl-query rq",role:"search",onSubmit:m=>{m.preventDefault(),A(l)},children:[n.jsxs("div",{className:"rq-wrap",children:[n.jsx("div",{className:"rq-hl","aria-hidden":"true",ref:j,children:ts(l).map((m,E)=>m.ws||m.key==null||!r.includes(m.key)?n.jsx("span",{children:m.raw},E):n.jsxs("span",{className:"rq-tok",children:[n.jsx("span",{className:"rq-tok-key",children:m.raw.slice(0,m.key.length+1)}),n.jsx("span",{className:"rq-tok-val",children:m.raw.slice(m.key.length+1)})]},E))}),n.jsx("input",{ref:d,role:"combobox","aria-expanded":k,"aria-controls":p,"aria-autocomplete":"list","aria-activedescendant":k&&h>=0?`${p}-o${h}`:void 0,value:l,spellCheck:!1,autoComplete:"off",placeholder:a,"aria-label":t,onChange:m=>{c(m.target.value),u(m.target.selectionStart??m.target.value.length),v(-1)},onScroll:S,onKeyDown:m=>{k&&(m.key==="ArrowDown"||m.key==="ArrowUp"?(m.preventDefault(),v(xe(h,y.items.length,m.key))):m.key==="Enter"&&h>=0&&(m.preventDefault(),N(y.items[h])))},onBlur:()=>u(-1)})]}),k&&n.jsx("div",{className:"rl-menu rq-list",role:"listbox",id:p,"aria-label":t,children:y.items.map((m,E)=>n.jsxs("div",{id:`${p}-o${E}`,role:"option","aria-selected":E===h,className:`rq-opt ${E===h?"active":""}`,onPointerDown:C=>{C.preventDefault(),N(m)},children:[n.jsx("span",{className:"rq-opt-token",children:m.insert.trim()}),m.label&&m.label!==m.value&&n.jsx("span",{className:"rq-opt-label",children:m.label})]},m.insert))}),n.jsx("button",{type:"submit",className:"rl-query-submit","data-tip":t,"aria-label":t,children:n.jsx(R,{name:"search",size:16})})]})}function Ke({value:e="",onChange:s,placeholder:a,searchLabel:t,filterLabel:r,groups:i,clearLabel:l,clearSearchLabel:c,summary:o}){const u=D(),h=n.jsxs("div",{className:"rf-compact",role:"search",children:[n.jsx("span",{className:"rf-search-icon",children:n.jsx(R,{name:"search",size:13})}),n.jsx("input",{value:e,onChange:d=>s(d.target.value),placeholder:a,"aria-label":t}),e&&n.jsx(he,{icon:"x",size:12,className:"rf-clear",label:c,onClick:()=>s("")}),n.jsx(ks,{label:r,clearLabel:l,groups:i,compact:!0,className:"rf-secondary-filters"})]});if(!o)return h;const v=u("reviewList.showing",{shown:o.shown,total:o.total});return n.jsxs("div",{className:"rf-row",children:[n.jsxs("span",{className:"rf-summary","data-tip":v,children:[n.jsx("span",{className:"sr-only",children:v}),n.jsx("span",{className:"rf-summary-full","aria-hidden":"true",children:v}),n.jsxs("span",{className:"rf-summary-compact","aria-hidden":"true",children:[o.shown,"/",o.total]})]}),h]})}function $s({page:e,pageCount:s,prev:a,next:t,hrefFor:r}){const i=D();if(s<=1&&e<=1)return null;const l=(c,o,u,h="")=>c==null?n.jsx("span",{className:`rl-page-link disabled ${h}`,"aria-disabled":"true",children:o}):n.jsx("a",{className:`rl-page-link ${h}`,href:r(c),rel:u,"aria-label":u?i(`reviewList.${u}Page`):i("reviewList.page",{n:c}),children:o});return n.jsxs("nav",{className:"rl-pagination","aria-label":i("reviewList.pagination"),children:[l(a,i("reviewList.previous"),"prev","direction"),gs(e,s).map((c,o)=>c==="gap"?n.jsx("span",{className:"rl-page-gap","aria-hidden":"true",children:"…"},`gap-${o}`):n.jsx("a",{className:"rl-page-link number",href:r(c),"aria-label":i("reviewList.page",{n:c}),"aria-current":c===e?"page":void 0,children:c},c)),l(t,i("reviewList.next"),"next","direction")]})}function Bn({notice:e,leading:s,error:a,loading:t=!1,title:r,action:i,search:l,sections:c=[],sectionMode:o="tabs",facets:u,secondaryFilters:h,rows:v,empty:d,pagination:j,children:p}){const g=D(),[f,y]=x.useState(null),k=x.useId(),S=x.useRef({});S.current={rows:v,cur:f},x.useEffect(()=>{const w=$=>{if($.metaKey||$.ctrlKey||$.altKey||!Ns($.target,$.key))return;const I=S.current.rows.filter(V=>V.href);if(!I.length)return;if($.key==="Enter"){const V=I.find(b=>b.key===S.current.cur);V&&($.preventDefault(),$.stopPropagation(),window.location.hash=V.href);return}$.preventDefault(),$.stopPropagation();const T=I.findIndex(V=>V.key===S.current.cur),_=T<0?$.key==="j"?0:I.length-1:Math.max(0,Math.min(I.length-1,T+($.key==="j"?1:-1)));y(I[_].key)};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[]),x.useEffect(()=>{var w;(w=document.querySelector(".lp-row.cur"))==null||w.scrollIntoView({block:"nearest"})},[f]);const A=ys(d),N=Math.max(0,c.findIndex(w=>w.active)),m=o==="tabs",E=`${k}-panel`,C=w=>`${k}-tab-${w}`;return n.jsxs(Z,{className:"lp-page",children:[e&&n.jsx("div",{className:"fv-notice",children:e}),s,n.jsxs("div",{className:"rl-content",children:[n.jsxs("div",{className:"rl-titlebar",children:[n.jsx("h1",{children:r}),i]}),l&&n.jsx(Ss,{...l}),a&&n.jsx("div",{className:"fv-error lp-error",role:"alert",children:a}),n.jsxs("section",{className:"rl-list",children:[n.jsxs("header",{className:"lp-head",children:[n.jsx("div",{className:"rl-sections",role:m?"tablist":"group","aria-label":r,...m?{"aria-orientation":"horizontal"}:{},children:c.map((w,$)=>n.jsxs("button",{type:"button",role:m?"tab":void 0,"aria-selected":m?w.active:void 0,"aria-pressed":m?void 0:w.active,"aria-controls":m?E:void 0,id:m?C($):void 0,tabIndex:m?$===N?0:-1:void 0,className:`rl-section ${w.active?"active":""}`,onClick:w.onSelect,onKeyDown:I=>{var V,b;if(!m||!["ArrowLeft","ArrowRight","Home","End"].includes(I.key))return;const T=[...I.currentTarget.closest('[role="tablist"]').querySelectorAll('[role="tab"]')],_=xe(T.indexOf(I.currentTarget),T.length,I.key);I.preventDefault(),I.stopPropagation(),(V=T[_])==null||V.focus(),(b=T[_])==null||b.click()},children:[n.jsx("span",{children:w.label}),n.jsx("span",{className:"rl-section-count",children:w.count}),w.countSuffix&&n.jsxs("span",{className:"rl-section-suffix","data-tip":w.countSuffix.text,children:[n.jsx("span",{className:"sr-only",children:w.countSuffix.text}),n.jsx("span",{className:"rl-section-suffix-full","aria-hidden":"true",children:w.countSuffix.text}),n.jsx("span",{className:"rl-section-suffix-compact","aria-hidden":"true",children:w.countSuffix.compact})]})]},w.key))}),n.jsxs("div",{className:"rl-facets",children:[u,h]})]}),n.jsxs("div",{className:"lp-rows",role:m?"tabpanel":"region",id:E,"aria-busy":t||void 0,"aria-labelledby":m?C(N):void 0,"aria-label":m?void 0:r,children:[v.length===0&&n.jsx("div",{className:"lp-empty",children:t?g("common.loading"):A}),v.map(w=>w.href?n.jsx("a",{className:`lp-row ${w.cls||""} ${f===w.key?"cur":""}`,href:w.href,children:w.content},w.key):n.jsx("div",{className:`lp-row inert ${w.cls||""}`,children:w.content},w.key))]})]}),j&&n.jsx($s,{...j})]}),p]})}function zn({title:e,titleMeta:s,status:a,side:t,composer:r,missing:i,failure:l,listHref:c,listLabel:o,backHref:u,backLabel:h,children:v}){return l?n.jsxs(Z,{className:"ds-page ds-missing ds-failed",role:"alert",children:[n.jsx("div",{className:"ds-missing-note",children:l}),c&&n.jsx("a",{className:"ds-backlink",href:c,children:o})]}):i?n.jsxs(Z,{className:"ds-page ds-missing",children:[n.jsx("div",{className:"ds-missing-note",children:i}),c&&n.jsx("a",{className:"ds-backlink",href:c,children:o})]}):n.jsxs(Z,{className:"ds-page",children:[n.jsxs("header",{className:"ds-head",children:[u&&n.jsx("a",{className:"ds-back",href:u,"data-tip":h,"aria-label":h,children:n.jsx(R,{name:"arrow-left",size:16})}),n.jsxs("h1",{className:"ds-title",children:[e,s&&n.jsx("span",{className:"ds-title-meta",children:s})]})]}),a&&n.jsx("div",{className:"ds-status",children:a}),n.jsxs("div",{className:"ds-cols",children:[n.jsxs("div",{className:"ds-main",children:[v,r&&n.jsx("div",{className:"ds-compose",children:r})]}),n.jsx("aside",{className:"ds-side",children:t})]})]})}function Hn({label:e,children:s}){return n.jsxs("div",{className:"ds-side-sec",children:[n.jsx("span",{className:"ds-side-label",children:e}),n.jsx("div",{className:"ds-side-body",children:s})]})}function Es({text:e,tip:s,dim:a=!1,mono:t=!1,href:r=null,external:i=!1,onClick:l=null,className:c="",lead:o=null,trail:u=null,label:h=null}){const v=`ds-val${a?" dim":""}${t?" mono":""}${r||l?" link":""}${c?` ${c}`:""}`,d=s??(typeof e=="string"?e:void 0),j=h?{"aria-label":h}:{},p=n.jsxs(n.Fragment,{children:[o,n.jsx("span",{className:"ds-val-text",children:e}),u]});return r?n.jsx("a",{className:v,href:r,"data-tip":d,...j,...i?{target:"_blank",rel:"noreferrer"}:{},children:p}):l?n.jsx("button",{type:"button",className:v,onClick:l,"data-tip":d,...j,children:p}):n.jsx("span",{className:v,"data-tip":d,children:p})}const le=Object.freeze({RESULT:"result",BLIND:"blind",UNMEASURED:"unmeasured",DANGLING:"dangling"}),Oe=e=>{var s;return(s=e==null?void 0:e.evidence)!=null&&s.length?e.evidence:(e==null?void 0:e.blob)!=null?[{hash:e.blob,kind:e.blobKind||"image",state:e.blobState||"present"}]:[]},Un=e=>{const s=Oe(e);return s.length?["video","image","transcript","data"].filter(a=>s.some(t=>t.kind===a)):["note"]},Wn=e=>String(e||"").length>22?`${String(e).slice(0,8)}…`:e;function _e(e,s,a){return a.map(t=>t==="section"?e.section:e.facets[t]).filter(t=>{var r;return(t==null?void 0:t.meaningful)!==!1&&(((r=t==null?void 0:t.options)==null?void 0:r.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:r=>s({[t.key]:r||null})}))}const z=e=>pe(`/api/evidence/${e}`);function Ls({src:e,alt:s,onClose:a}){return x.useEffect(()=>{const t=r=>{r.key==="Escape"&&(r.preventDefault(),r.stopPropagation(),a())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[a]),n.jsx("div",{className:"lightbox",onClick:a,children:n.jsx("img",{src:e,alt:s})})}function As({hash:e}){const s=D(),[a,t]=x.useState(null);return x.useEffect(()=>{let r=!0;return fetch(z(e)).then(i=>i.ok?i.text():Promise.reject(new Error("miss"))).then(i=>{r&&t(i)}).catch(()=>{r&&t("")}),()=>{r=!1}},[e]),a===null?n.jsx("pre",{className:"eval-transcript loading",children:s("nodeView.eval.loadingTranscript")}):n.jsx("pre",{className:"eval-transcript",children:a})}function Ds({hash:e,collapsed:s=!1}){const a=D(),[t,r]=x.useState(null);if(x.useEffect(()=>{let l=!0;return fetch(z(e)).then(c=>c.ok?c.text():Promise.reject(new Error("miss"))).then(c=>{let o=c,u=!0;try{o=JSON.stringify(JSON.parse(c),null,2)}catch{u=!1}l&&r({text:o,valid:u})}).catch(()=>{l&&r({text:"",valid:!1})}),()=>{l=!1}},[e]),t===null)return n.jsx("pre",{className:"eval-data loading",children:a("nodeView.eval.loadingData")});const i=t.valid?a("nodeView.eval.data"):a("nodeView.eval.dataInvalid");return s?n.jsxs("details",{className:"eval-datawrap eval-datafold",children:[n.jsx("summary",{className:"eval-datahead",children:i}),n.jsx("pre",{className:"eval-data",children:t.text})]}):n.jsxs("div",{className:"eval-datawrap",children:[n.jsx("div",{className:"eval-datahead",children:i}),n.jsx("pre",{className:"eval-data",children:t.text})]})}function Is({hash:e,alt:s}){const[a,t]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx("img",{className:"an-image",src:z(e),alt:s,loading:"lazy",onClick:()=>t(!0)}),a&&n.jsx(Ls,{src:z(e),alt:s,onClose:()=>t(!1)})]})}function Cs({exit:e}){return n.jsx(R,{name:e?"minimize":"maximize",size:15})}function Gn({target:e,className:s=""}){const a=D(),[t,r]=x.useState(!1);x.useEffect(()=>{const l=()=>{const c=document.fullscreenElement,o=e==null?void 0:e.current;r(!!c&&!!o&&(c===o||o.contains(c)))};return document.addEventListener("fullscreenchange",l),()=>document.removeEventListener("fullscreenchange",l)},[e]);const i=()=>{var c,o;const l=e==null?void 0:e.current;l&&(document.fullscreenElement?(c=document.exitFullscreen||document.webkitExitFullscreen)==null||c.call(document):(o=l.requestFullscreen||l.webkitRequestFullscreen)==null||o.call(l))};return n.jsx("button",{type:"button",className:`an-fs ${s}`,onClick:i,"data-tip":a(t?"annotator.exitFullscreen":"annotator.fullscreen"),"aria-label":a(t?"annotator.exitFullscreen":"annotator.fullscreen"),children:n.jsx(Cs,{exit:t})})}function Be({e,alt:s="",collapsed:a=!1}){const t=D();return e.state==="miss"?n.jsx("div",{className:"eval-noimg",children:t("nodeView.eval.miss")}):e.kind==="transcript"?n.jsx(As,{hash:e.hash}):e.kind==="data"?n.jsx(Ds,{hash:e.hash,collapsed:a}):e.kind==="video"?n.jsx("video",{className:"eval-video",src:z(e.hash),controls:!0,preload:"metadata",playsInline:!0}):n.jsx(Is,{hash:e.hash,alt:s})}const Q=new Map;function Ts(e){const[s,a]=x.useState(()=>Q.get(e)??null);return x.useEffect(()=>{if(Q.has(e)){a(Q.get(e));return}let t=!0;return fetch(z(e),{headers:{Range:"bytes=0-0"}}).then(r=>{const i=r.headers.get("content-type")||"",l=r.ok?{kind:i.startsWith("video/")?"video":i.startsWith("image/")?"image":i.startsWith("application/json")?"data":"transcript",state:"present"}:{kind:"image",state:"miss"};Q.set(e,l),t&&a(l)}).catch(()=>{t&&a({kind:"image",state:"miss"})}),()=>{t=!1}},[e]),s}function ze({hash:e,alt:s=""}){const a=Ts(e);return a?n.jsx(Be,{e:{hash:e,...a},alt:s}):null}function Rs(e){var s,a;return((s=e==null?void 0:e.verdict)==null?void 0:s.status)==="pass"?"check":((a=e==null?void 0:e.verdict)==null?void 0:a.status)==="fail"?"cross":null}function He(e){const s=Rs(e);return s?e.fresh?s==="cross"?"fail":"pass":s==="cross"?"staleFail":"stalePass":"empty"}function Vs(e,s){if(!e)return[];const a=new Map;for(const t of s||[])a.has(t.scenario)||a.set(t.scenario,t);return e.map(t=>{const r=a.get(t.name)||null;return{...t,reading:r,state:r?He(r):"missing"}})}function Ps(e){return e.length?e.some(s=>s.state==="fail")?"fail":e.some(s=>s.state==="staleFail")?"staleFail":e.some(s=>s.state==="stalePass")?"stalePass":e.some(s=>s.state==="empty"||s.state==="missing")?"empty":"pass":null}const Fs=e=>e.fail>0?"fail":e.staleFail>0?"staleFail":e.stalePass>0?"stalePass":e.empty>0?"empty":"pass";function qs({scenarios:e,evals:s,summary:a=null,href:t}){const r=D(),i=a?null:Vs(e,s),l=(a==null?void 0:a.total)??i.length;if(!l)return null;const c=a?Fs(a):Ps(i),o=(a==null?void 0:a.pass)??i.filter(d=>d.state==="pass").length,u=r("score.count",{satisfied:o,total:l,outstanding:l-o}),h=n.jsxs(n.Fragment,{children:[n.jsx(R,{name:"check",size:11}),o,"/",l]});if(!t)return n.jsx("span",{className:`scenario-count ${c}`,"data-tip":u,"aria-label":u,children:h});const v=`${u} — ${r("score.openList")}`;return n.jsx("a",{className:`scenario-count ${c}`,href:t,"data-tip":v,"aria-label":v,children:h})}function J({kind:e,state:s,cls:a,n:t,label:r}){return n.jsxs("span",{className:`ovc ${a}`,"data-tip":r,children:[n.jsx(ve,{kind:e,state:s,title:r,size:11}),t]})}function Ms({tags:e}){return e!=null&&e.length?n.jsx("span",{className:"tag-chips",children:e.map(s=>n.jsx("span",{className:"tag-chip",children:s},s))}):null}function Ue({state:e,title:s}){return e?n.jsx(ve,{kind:"eval",state:e,title:s,className:`score-badge ${e}`,size:14}):null}const Qn=e=>({kind:"graph-node",nodeId:e}),Jn=e=>({kind:"session",sessionId:e}),Ks=e=>({kind:"issue",issueId:e}),We=(e,s)=>({kind:"review-list",page:e,query:s}),Ge=(e,s=null)=>({kind:"eval",nodeId:e,scenario:s}),Os=(e,s,a)=>({kind:"session-eval",sessionId:e,nodeId:s,scenario:a});function O(e){if(!e)return P("graph");if(e.kind==="graph-node")return P("graph");if(e.kind==="session")return P("sessions",e.sessionId);if(e.kind==="session-eval"){const s=e.nodeId&&e.scenario?`${e.nodeId}/${e.scenario}`:null;return P("evals",s,{q:s?`scope:${e.sessionId}`:as(e.sessionId)})}return e.kind==="issue"?P("issues",e.issueId):e.kind==="review-list"?P(e.page,null,e.query?{q:e.query}:null):e.kind==="eval"?e.scenario?P("evals",`${e.nodeId}/${e.scenario}`):P("evals",null,{q:rs(e.nodeId)}):P("graph")}function Yn(e,s=null){return e==="issues"?P("issues"):s?O(Os(s)):P("evals")}function Zn(e,{onFocusNode:s,onOpenSession:a}={}){if(e)if(e.kind==="graph-node")s==null||s(e.nodeId),ne("graph");else if(e.kind==="session")a?a(e.sessionId):ne("sessions",e.sessionId);else{const{page:t,param:r,query:i}=ls(O(e));ne(t,r,{query:i})}}function Ne({issue:e,onNavigateAddress:s}){const a=(e==null?void 0:e.store)||"local",t=(e==null?void 0:e.status)||"open",r=Ks(e.id);return n.jsxs("a",{className:"issue-card",href:O(r),"data-tip":e.concern||e.id,onClick:s?i=>{i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),s(r))}:void 0,children:[n.jsxs("span",{className:"issue-card-top",children:[n.jsx("span",{className:"issue-num",children:e.id}),n.jsx("span",{className:`fv-store fv-store-${a==="local"?"local":"forge"}`,children:a}),n.jsx(ve,{kind:"issue",state:t,showLabel:!0,size:12,className:"issue-card-state"})]}),n.jsx("span",{className:"issue-card-title",children:e.concern})]})}const ke=[{key:"spec",label:"spec"},{key:"history",label:"history"},{key:"issues",label:"issues"},{key:"eval",label:"eval"}];function _s(e){var s;return(s=e==null?void 0:e.overlays)!=null&&s.length?[{key:"edit",label:"edit"},...ke]:ke}const Qe=(e,s,a={})=>{let t=`${e==="issue"?"is:issue":is}${a.q?` ${String(a.q).trim()}`:""}`.trim();const r=e==="issue"?{state:"state",author:"author",store:"store",session:"session"}:{verdict:"verdict",review:"state",freshness:"freshness",kind:"evidence",filer:"filer",session:"session"};for(const[i,l]of Object.entries(r))a[i]&&(t=ge(t,l,a[i]));return ge(t,"node",s)},Bs={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"},Je=(e,s)=>{const a=t=>t&&{...t,label:s(Bs[t.key]||t.label||t.key)};return{section:a(e==null?void 0:e.section),facets:Object.fromEntries(Object.entries((e==null?void 0:e.facets)||{}).map(([t,r])=>[t,a(r)]))}},zs={added:"+",edited:"~",deleted:"✕",moved:"→"};function U(e){const s=[],a=/`([^`]+)`|\*\*([^*]+)\*\*|\[\[([^\]]+)\]\]/g;let t=0,r,i=0;for(;r=a.exec(e);)r.index>t&&s.push(e.slice(t,r.index)),r[1]!=null?s.push(n.jsx("code",{children:r[1]},i++)):r[2]!=null?s.push(n.jsx("strong",{children:r[2]},i++)):s.push(n.jsx("span",{className:"doc-link",children:r[3]},i++)),t=a.lastIndex;return t<e.length&&s.push(e.slice(t)),s}function Se(e){const s=e.trim();return s.includes("|")&&/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/.test(s)}function ie(e){let s=e.trim();return s.startsWith("|")&&(s=s.slice(1)),s.endsWith("|")&&(s=s.slice(0,-1)),s.split("|").map(a=>a.trim())}function Hs(e){const s=e.startsWith(":"),a=e.endsWith(":");return s&&a?"center":a?"right":null}function se({body:e}){if(!e)return null;const s=e.replace(/^#\s+[^\n]*\n+/,"").split(`
1
+ import{r as x,j as n,I as R,u as D,e as he,p as ns,t as ts,d as pe,g as P,v as as,w as rs,n as ne,x as ls,E as is,s as ge}from"./index-Di1ch5dd.js";import{P as Z}from"./PageScroll-px_rUZVJ.js";import{m as cs,n as me,o as os,q as ds,r as us}from"./data-CQFbQEMH.js";const F={working:"var(--green)",parked:"var(--green)",asking:"var(--yellow)",review:"var(--yellow)",done:"var(--yellow)",error:"var(--red)",idle:"var(--muted)",starting:"var(--muted)",queued:"var(--muted)","close-pending":"var(--muted)",offline:"var(--muted)",unknown:"var(--yellow)",corrupt:"var(--red)",retired:"var(--muted)"},Vn={working:"●",parked:"‖",asking:"?",review:"◑",done:"✓",error:"✕",idle:"·",starting:"◌",queued:"⋯","close-pending":"⊘",offline:"○",unknown:"⁇",corrupt:"⚠",retired:"⚑"},Ve=new Set(["asking","review","done","close-pending","error","corrupt"]),ee=e=>(e==null?void 0:e.liveness)==="offline"||(e==null?void 0:e.status)==="offline"?"offline":Ve.has(e==null?void 0:e.status)?"need":"run",je=e=>!!(e!=null&&e.archived),Pn=(e=[])=>({live:e.filter(s=>!je(s)),archived:e.filter(je)}),fs=(e,s)=>{const a=s?(e||[]).find(t=>t.id===s):null;return a&&ee(a)!=="offline"?a:null},we=e=>(e==null?void 0:e.sortKey)!=null?e.sortKey:(e==null?void 0:e.created)??0,ye=e=>{const s={need:0,run:1,offline:2};return[...e].sort((a,t)=>s[ee(a)]-s[ee(t)]||we(t)-we(a))},qn=e=>(e==null?void 0:e.label)||(e==null?void 0:e.name)||(e==null?void 0:e.node)||(e==null?void 0:e.title)||(e==null?void 0:e.branch)||(e==null?void 0:e.id),hs=e=>(e==null?void 0:e.headline)||(e==null?void 0:e.name)||(e==null?void 0:e.activity)||(e==null?void 0:e.promptPreview)||(e==null?void 0:e.node)||(e==null?void 0:e.title)||(e==null?void 0:e.branch)||(e==null?void 0:e.id);function ps(e){const s=new Set(e.map(r=>r==null?void 0:r.id)),a=new Map,t=[];for(const r of e){const i=r!=null&&r.parent&&r.parent!==r.id&&s.has(r.parent)?r.parent:null;if(i){const l=a.get(i)||[];l.push(r),a.set(i,l)}else t.push(r)}return{roots:t,childrenOf:a}}function Fn(e,s){const a=new Map(e.map(l=>[l==null?void 0:l.id,l])),t=[],r=new Set([s]);let i=a.get(s);for(;i!=null&&i.parent&&!r.has(i.parent);){const l=a.get(i.parent);if(!l)break;t.push(l.id),r.add(l.id),i=l}return t}function ms(e,s){let a=!1,t=!1,r=0;const i=(l,c)=>{for(const o of s.get(l)||[])c.has(o.id)||(c.add(o.id),r++,Ve.has(o.status)?a=!0:F[o.status]===F.working&&(t=!0),i(o.id,c))};return i(e,new Set([e])),{color:a?F.asking:t?F.working:F.idle,count:r}}function vs(e,s,{zoneFolded:a=()=>!1,keepVisible:t=()=>!1}={}){const{roots:r,childrenOf:i}=ps(e),l=[],c=(d,j,p,g)=>{const f=i.get(d.id)||[],y=f.length>0,k=y&&!!s(d.id),S=y?ms(d.id,i):null;if(l.push({type:"row",s:d,depth:j,expandable:y,expanded:k,rollup:(S==null?void 0:S.color)??null,kin:(S==null?void 0:S.count)??0,guides:g}),k){const A=ye(f).filter(N=>!p.has(N.id));A.forEach((N,m)=>{p.add(N.id),c(N,j+1,p,[...g,m<A.length-1])})}},o=(d,j)=>{let p=1;for(const g of i.get(d.id)||[])j.has(g.id)||(j.add(g.id),p+=o(g,j));return p},u=new Set;let h=null,v=null;for(const d of ye(r)){if(u.has(d.id))continue;const j=ee(d);if(j!==h&&(v={type:"zone",zone:j,count:0,folded:!!a(j)},l.push(v),h=j),v.count+=o(d,new Set([...u,d.id])),v.folded){const p=[],g=(f,y)=>{t(f)&&!u.has(f.id)&&p.push(f);for(const k of i.get(f.id)||[])y.has(k.id)||(y.add(k.id),g(k,y))};g(d,new Set([d.id]));for(const f of p)u.add(f.id),l.push({type:"row",s:f,depth:0,expandable:!1,expanded:!1,rollup:null,kin:0,guides:[]});u.add(d.id);continue}u.add(d.id),c(d,0,u,[])}return l}const Mn=e=>vs(e,()=>!0).filter(s=>s.type==="row").map(s=>s.s),te=typeof window<"u"?window.__escStack||(window.__escStack=[]):[];typeof window<"u"&&!window.__escStackBound&&(window.__escStackBound=!0,window.addEventListener("keydown",e=>{const s=window.__escStack;e.key!=="Escape"||!s||s.length===0||(e.preventDefault(),e.stopImmediatePropagation(),s[s.length-1].close())},!0));function Pe(e,s){const a=x.useRef(s);a.current=s,x.useEffect(()=>{if(!e)return;const t={close:()=>{var r;return(r=a.current)==null?void 0:r.call(a)}};return te.push(t),()=>{const r=te.indexOf(t);r>=0&&te.splice(r,1)}},[e])}const W=new Map;async function xs(e){if(W.has(e))return W.get(e);const s=cs(e).then(async a=>{const t=await a.json().catch(()=>null);if(!a.ok)throw new Error((t==null?void 0:t.error)||`HTTP ${a.status}`);return t}).finally(()=>W.delete(e));return W.set(e,s),s}const Kn=e=>{const s=typeof e=="string"&&/^\d+$/.test(e)?Number(e):Number.NaN;return Number.isSafeInteger(s)&&s>0?s:1};function gs(e,s){return s<=0?[]:s<=10?Array.from({length:s},(a,t)=>t+1):e<=7?[...Array.from({length:8},(a,t)=>t+1),"gap",s-1,s]:e>=s-6||e>s?[1,2,"gap",...Array.from({length:8},(a,t)=>s-7+t)]:[1,2,"gap",e-2,e-1,e,e+1,e+2,"gap",s-1,s]}function qe(e,s,a,{enabled:t=!0,refreshKey:r=null,pollMs:i=15e3,view:l=null}={}){const[c,o]=x.useState(null),[u,h]=x.useState(null),[v,d]=x.useState(t),j=x.useRef(0),p=x.useCallback(async({quiet:f=!1}={})=>{if(!t)return null;const y=++j.current;f||d(!0),h(null);const k=new URLSearchParams({q:String(s||""),page:String(a)});l&&k.set("view",l);try{const S=await xs(`/api/${e}?${k}`);return y===j.current&&o(A=>A&&S&&A.revision===S.revision?A:S),S}catch(S){return y===j.current&&h(S instanceof Error?S.message:String(S)),null}finally{y===j.current&&d(!1)}},[e,t,a,s,l]),g=x.useRef(null);return x.useEffect(()=>{if(!t){d(!1);return}const f=`${e}\0${s}\0${a}\0${l||""}`,y=f!==g.current;g.current=f,y&&o(null),p({quiet:!y});const k=i>0?setInterval(()=>p({quiet:!0}),i):null;return()=>{k&&clearInterval(k)}},[e,s,a,l,t,p,i,r]),{data:c,error:u,loading:v,reload:p}}const be={issue:{open:{icon:"issue-opened",tone:"open",label:"reviewState.issueOpen"},closed:{icon:"issue-closed",tone:"closed",label:"reviewState.issueClosed"}},eval:{pass:{icon:"circle-check",tone:"pass",label:"score.pass"},fail:{icon:"circle-x",tone:"fail",label:"score.fail"},stalePass:{icon:"circle-check",tone:"stale",label:"score.stalePass"},staleFail:{icon:"circle-x",tone:"stale",label:"score.staleFail"},review:{icon:"clock",tone:"review",label:"reviewList.needsReview"},empty:{icon:"circle-minus",tone:"empty",label:"score.empty"},missing:{icon:"circle-dashed",tone:"empty",label:"score.missing"},legacy:{icon:"circle-minus",tone:"empty",label:"score.empty"}}},js=(e,s)=>{var t;const a=e==="issue"?s==="open"?"open":"closed":s||"empty";return((t=be[e])==null?void 0:t[a])||be.eval.empty};function ve({kind:e,state:s,showLabel:a=!1,size:t=16,className:r="",title:i}){const l=D(),c=js(e,s),o=i||l(c.label);return n.jsxs("span",{className:`review-state ${e} ${c.tone} ${r}`,"data-tip":o,"aria-label":o,children:[n.jsx("span",{className:"review-state-icon",style:{width:t,height:t},children:n.jsx(R,{name:c.icon,size:t})}),a&&n.jsx("span",{className:"review-state-label",children:o})]})}function ws(e,s){const a={...e,...s};for(const[t,r]of Object.entries(a))(r==null||r==="")&&delete a[t];return a}const ys=e=>e&&typeof e=="object"?e.hasData?e.filtered:e.dataset:e,Fe=(e,s,a)=>{const t=Array.isArray(e)?e:[];return!(s!=null&&String(s)!=="")||a==null||t.some(i=>String(i.value)==="")?t:[{value:"",label:a},...t]},bs=(e=[])=>e.reduce((s,a)=>((a.active??(a.value!=null&&String(a.value)!==""))&&(s.mobile+=1,a.mobileOnly||(s.desktop+=1)),s),{desktop:0,mobile:0}),xe=(e,s,a)=>s?a==="Home"?0:a==="End"?s-1:a==="ArrowDown"||a==="ArrowRight"?e<0?0:(e+1)%s:a==="ArrowUp"||a==="ArrowLeft"?e<0?s-1:(e-1+s)%s:e:-1,Ns=(e,s)=>{var t;const a=e==null?void 0:e.tagName;return a==="INPUT"||a==="TEXTAREA"||a==="SELECT"||a==="BUTTON"&&(s==="Enter"||s===" ")||s==="Enter"&&((t=e==null?void 0:e.closest)!=null&&t.call(e,"a[href]"))?!1:s==="j"||s==="k"||s==="Enter"},ae=e=>[...(e==null?void 0:e.querySelectorAll('[role="menuitemradio"]'))||[]].filter(s=>s.getClientRects().length>0),re=(e,s)=>{const a=e[s];if(a){for(const t of e)t.tabIndex=t===a?0:-1;a.focus()}};function Me(){const[e,s]=x.useState(!1),a=x.useRef(null),t=x.useRef(null),r=x.useRef(null),i=x.useRef("checked"),l=(d=!1)=>{var j;d&&((j=r.current)==null||j.focus()),s(!1)},c=(d,j="checked")=>{r.current=d,i.current=j,s(!0)},o=d=>{e?l(!1):c(d)};return Pe(e,()=>l(!0)),x.useEffect(()=>{if(!e)return;const d=j=>{var p;(p=a.current)!=null&&p.contains(j.target)||l(!1)};return window.addEventListener("pointerdown",d,!0),()=>window.removeEventListener("pointerdown",d,!0)},[e]),x.useEffect(()=>{if(!e)return;const d=requestAnimationFrame(()=>{const j=ae(t.current),p=j.findIndex(f=>f.getAttribute("aria-checked")==="true"),g=i.current==="last"?j.length-1:i.current==="first"?0:p>=0?p:0;re(j,g)});return()=>cancelAnimationFrame(d)},[e]),{open:e,ref:a,menuRef:t,close:l,toggle:o,onTriggerKeyDown:d=>{d.key!=="ArrowDown"&&d.key!=="ArrowUp"||(d.preventDefault(),d.stopPropagation(),c(d.currentTarget,d.key==="ArrowUp"?"last":"first"))},onMenuKeyDown:d=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(d.key))return;const j=ae(t.current),p=j.indexOf(document.activeElement);d.preventDefault(),d.stopPropagation(),re(j,xe(p,j.length,d.key))},onItemFocus:d=>{const j=ae(t.current);re(j,j.indexOf(d.currentTarget))}}}function On({label:e,value:s="",options:a=[],onChange:t,mobile:r=!1,clearLabel:i}){const l=Me(),c=Fe(a,s,i);if(!c.length)return null;const o=c.find(v=>String(v.value)===String(s)),u=s?(o==null?void 0:o.label)||String(s):"",h=u?`${e}: ${u}`:e;return n.jsxs("div",{className:`rl-facet-wrap ${r?"mobile-stay":""}`,ref:l.ref,children:[n.jsxs("button",{type:"button",className:`rl-facet ${s?"active":""}`,"aria-label":h,"aria-haspopup":"menu","aria-expanded":l.open,onClick:v=>l.toggle(v.currentTarget),onKeyDown:l.onTriggerKeyDown,children:[n.jsx("span",{className:"rl-facet-label",children:h}),r&&n.jsx("span",{className:"rl-facet-label-mobile","aria-hidden":"true",children:u||e}),n.jsx(R,{name:"chevron-down",size:12})]}),l.open&&n.jsx("div",{className:"rl-menu",role:"menu","aria-label":e,ref:l.menuRef,onKeyDown:l.onMenuKeyDown,children:c.map(v=>n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":String(v.value)===String(s),tabIndex:-1,className:"rl-menu-item",onFocus:l.onItemFocus,onClick:()=>{l.close(!0),t(v.value)},children:[n.jsx(R,{name:String(v.value)===String(s)?"check":"blank",size:13}),n.jsx("span",{children:v.label}),v.count!=null&&n.jsx("span",{className:"rl-menu-count",children:v.count})]},String(v.value)))})]})}function ks({label:e,groups:s=[],clearLabel:a,compact:t=!1,className:r=""}){const i=D(),l=x.useId(),c=s.map(d=>({...d,options:Fe(d.options,d.value,d.clearLabel===null?null:d.clearLabel||a)})).filter(d=>d.options.length),o=c.some(d=>!d.mobileOnly),u=bs(c),h=Me();if(!c.length)return null;const v=(d,j)=>d>0&&n.jsxs("span",{className:`rl-secondary-filter-count ${j}`,children:[n.jsx("span",{"aria-hidden":"true",children:d}),n.jsx("span",{className:"sr-only",children:i("reviewList.activeFilters",{n:d})})]});return n.jsxs("div",{className:`rl-secondary-filters ${o?"":"mobile-only"} ${u.desktop?"active-desktop":""} ${u.mobile?"active-mobile":""} ${r}`,ref:h.ref,children:[t?n.jsx(he,{icon:"filter",size:16,className:"rl-secondary-filters-trigger compact",label:e,"aria-haspopup":"menu","aria-expanded":h.open,onClick:d=>h.toggle(d.currentTarget),onKeyDown:h.onTriggerKeyDown}):n.jsxs("button",{type:"button",className:"rl-secondary-filters-trigger","aria-haspopup":"menu","aria-expanded":h.open,onClick:d=>h.toggle(d.currentTarget),onKeyDown:h.onTriggerKeyDown,children:[n.jsx(R,{name:"filter",size:14}),n.jsx("span",{children:e}),v(u.desktop,"for-desktop"),v(u.mobile,"for-mobile"),n.jsx(R,{name:"chevron-down",size:12})]}),h.open&&n.jsx("div",{className:"rl-menu rl-secondary-filters-menu",role:"menu","aria-label":e,ref:h.menuRef,onKeyDown:h.onMenuKeyDown,children:c.map((d,j)=>n.jsxs("div",{role:"group","aria-labelledby":`${l}-group-${j}`,className:`rl-menu-group ${d.mobileOnly?"mobile-only":""}`,children:[n.jsx("div",{className:"rl-menu-label",id:`${l}-group-${j}`,children:d.label}),d.options.map(p=>n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":String(p.value)===String(d.value||""),tabIndex:-1,className:"rl-menu-item",onFocus:h.onItemFocus,onClick:()=>{h.close(!0),d.onChange(p.value)},children:[n.jsx(R,{name:String(p.value)===String(d.value||"")?"check":"blank",size:13}),n.jsx("span",{children:p.label}),p.count!=null&&n.jsx("span",{className:"rl-menu-count",children:p.count})]},String(p.value)))]},`${d.label}-${d.mobileOnly?"mobile":"all"}`))})]})}function _n({state:e,title:s,meta:a,aside:t}){return n.jsxs("div",{className:"rl-row-grid",children:[n.jsx("div",{className:"rl-row-state",children:e}),n.jsxs("div",{className:"rl-row-body",children:[n.jsx("div",{className:"rl-row-title",children:s}),a&&n.jsx("div",{className:"rl-row-meta",children:a})]}),t&&n.jsx("div",{className:"rl-row-aside",children:t})]})}const G=e=>{const s=String(e??"").trim();return s?`${s} `:""};function Ss({value:e="",onSubmit:s,placeholder:a,label:t,keys:r=[],suggest:i={}}){const[l,c]=x.useState(()=>G(e)),[o,u]=x.useState(-1),[h,v]=x.useState(-1),d=x.useRef(null),j=x.useRef(null),p=x.useId(),g=x.useRef(null),f=m=>requestAnimationFrame(()=>{const E=d.current;E&&(m&&E.focus(),E.setSelectionRange(E.value.length,E.value.length))});x.useEffect(()=>{c(G(e)),u(-1),v(-1),f(g.current!==null&&g.current!==e),g.current=e},[e]);const y=o>=0?ns(l,o,r,i):{start:0,end:0,items:[]},k=y.items.length>0;Pe(k,()=>u(-1));const S=()=>{j.current&&d.current&&(j.current.scrollLeft=d.current.scrollLeft)};x.useEffect(S);const A=m=>{u(-1),v(-1);const E=m.trim();c(G(E)||G(e)),f(!0),s(E)},N=m=>{const E=`${l.slice(0,y.start)}${m.insert}${l.slice(y.end)}`;if(c(E),m.type==="value"){A(E);return}const C=y.start+m.insert.length;u(C),v(-1),requestAnimationFrame(()=>{var w,$;(w=d.current)==null||w.focus(),($=d.current)==null||$.setSelectionRange(C,C)})};return n.jsxs("form",{className:"rl-query rq",role:"search",onSubmit:m=>{m.preventDefault(),A(l)},children:[n.jsxs("div",{className:"rq-wrap",children:[n.jsx("div",{className:"rq-hl","aria-hidden":"true",ref:j,children:ts(l).map((m,E)=>m.ws||m.key==null||!r.includes(m.key)?n.jsx("span",{children:m.raw},E):n.jsxs("span",{className:"rq-tok",children:[n.jsx("span",{className:"rq-tok-key",children:m.raw.slice(0,m.key.length+1)}),n.jsx("span",{className:"rq-tok-val",children:m.raw.slice(m.key.length+1)})]},E))}),n.jsx("input",{ref:d,role:"combobox","aria-expanded":k,"aria-controls":p,"aria-autocomplete":"list","aria-activedescendant":k&&h>=0?`${p}-o${h}`:void 0,value:l,spellCheck:!1,autoComplete:"off",placeholder:a,"aria-label":t,onChange:m=>{c(m.target.value),u(m.target.selectionStart??m.target.value.length),v(-1)},onScroll:S,onKeyDown:m=>{k&&(m.key==="ArrowDown"||m.key==="ArrowUp"?(m.preventDefault(),v(xe(h,y.items.length,m.key))):m.key==="Enter"&&h>=0&&(m.preventDefault(),N(y.items[h])))},onBlur:()=>u(-1)})]}),k&&n.jsx("div",{className:"rl-menu rq-list",role:"listbox",id:p,"aria-label":t,children:y.items.map((m,E)=>n.jsxs("div",{id:`${p}-o${E}`,role:"option","aria-selected":E===h,className:`rq-opt ${E===h?"active":""}`,onPointerDown:C=>{C.preventDefault(),N(m)},children:[n.jsx("span",{className:"rq-opt-token",children:m.insert.trim()}),m.label&&m.label!==m.value&&n.jsx("span",{className:"rq-opt-label",children:m.label})]},m.insert))}),n.jsx("button",{type:"submit",className:"rl-query-submit","data-tip":t,"aria-label":t,children:n.jsx(R,{name:"search",size:16})})]})}function Ke({value:e="",onChange:s,placeholder:a,searchLabel:t,filterLabel:r,groups:i,clearLabel:l,clearSearchLabel:c,summary:o}){const u=D(),h=n.jsxs("div",{className:"rf-compact",role:"search",children:[n.jsx("span",{className:"rf-search-icon",children:n.jsx(R,{name:"search",size:13})}),n.jsx("input",{value:e,onChange:d=>s(d.target.value),placeholder:a,"aria-label":t}),e&&n.jsx(he,{icon:"x",size:12,className:"rf-clear",label:c,onClick:()=>s("")}),n.jsx(ks,{label:r,clearLabel:l,groups:i,compact:!0,className:"rf-secondary-filters"})]});if(!o)return h;const v=u("reviewList.showing",{shown:o.shown,total:o.total});return n.jsxs("div",{className:"rf-row",children:[n.jsxs("span",{className:"rf-summary","data-tip":v,children:[n.jsx("span",{className:"sr-only",children:v}),n.jsx("span",{className:"rf-summary-full","aria-hidden":"true",children:v}),n.jsxs("span",{className:"rf-summary-compact","aria-hidden":"true",children:[o.shown,"/",o.total]})]}),h]})}function $s({page:e,pageCount:s,prev:a,next:t,hrefFor:r}){const i=D();if(s<=1&&e<=1)return null;const l=(c,o,u,h="")=>c==null?n.jsx("span",{className:`rl-page-link disabled ${h}`,"aria-disabled":"true",children:o}):n.jsx("a",{className:`rl-page-link ${h}`,href:r(c),rel:u,"aria-label":u?i(`reviewList.${u}Page`):i("reviewList.page",{n:c}),children:o});return n.jsxs("nav",{className:"rl-pagination","aria-label":i("reviewList.pagination"),children:[l(a,i("reviewList.previous"),"prev","direction"),gs(e,s).map((c,o)=>c==="gap"?n.jsx("span",{className:"rl-page-gap","aria-hidden":"true",children:"…"},`gap-${o}`):n.jsx("a",{className:"rl-page-link number",href:r(c),"aria-label":i("reviewList.page",{n:c}),"aria-current":c===e?"page":void 0,children:c},c)),l(t,i("reviewList.next"),"next","direction")]})}function Bn({notice:e,leading:s,error:a,loading:t=!1,title:r,action:i,search:l,sections:c=[],sectionMode:o="tabs",facets:u,secondaryFilters:h,rows:v,empty:d,pagination:j,children:p}){const g=D(),[f,y]=x.useState(null),k=x.useId(),S=x.useRef({});S.current={rows:v,cur:f},x.useEffect(()=>{const w=$=>{if($.metaKey||$.ctrlKey||$.altKey||!Ns($.target,$.key))return;const I=S.current.rows.filter(V=>V.href);if(!I.length)return;if($.key==="Enter"){const V=I.find(b=>b.key===S.current.cur);V&&($.preventDefault(),$.stopPropagation(),window.location.hash=V.href);return}$.preventDefault(),$.stopPropagation();const T=I.findIndex(V=>V.key===S.current.cur),_=T<0?$.key==="j"?0:I.length-1:Math.max(0,Math.min(I.length-1,T+($.key==="j"?1:-1)));y(I[_].key)};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[]),x.useEffect(()=>{var w;(w=document.querySelector(".lp-row.cur"))==null||w.scrollIntoView({block:"nearest"})},[f]);const A=ys(d),N=Math.max(0,c.findIndex(w=>w.active)),m=o==="tabs",E=`${k}-panel`,C=w=>`${k}-tab-${w}`;return n.jsxs(Z,{className:"lp-page",children:[e&&n.jsx("div",{className:"fv-notice",children:e}),s,n.jsxs("div",{className:"rl-content",children:[n.jsxs("div",{className:"rl-titlebar",children:[n.jsx("h1",{children:r}),i]}),l&&n.jsx(Ss,{...l}),a&&n.jsx("div",{className:"fv-error lp-error",role:"alert",children:a}),n.jsxs("section",{className:"rl-list",children:[n.jsxs("header",{className:"lp-head",children:[n.jsx("div",{className:"rl-sections",role:m?"tablist":"group","aria-label":r,...m?{"aria-orientation":"horizontal"}:{},children:c.map((w,$)=>n.jsxs("button",{type:"button",role:m?"tab":void 0,"aria-selected":m?w.active:void 0,"aria-pressed":m?void 0:w.active,"aria-controls":m?E:void 0,id:m?C($):void 0,tabIndex:m?$===N?0:-1:void 0,className:`rl-section ${w.active?"active":""}`,onClick:w.onSelect,onKeyDown:I=>{var V,b;if(!m||!["ArrowLeft","ArrowRight","Home","End"].includes(I.key))return;const T=[...I.currentTarget.closest('[role="tablist"]').querySelectorAll('[role="tab"]')],_=xe(T.indexOf(I.currentTarget),T.length,I.key);I.preventDefault(),I.stopPropagation(),(V=T[_])==null||V.focus(),(b=T[_])==null||b.click()},children:[n.jsx("span",{children:w.label}),n.jsx("span",{className:"rl-section-count",children:w.count}),w.countSuffix&&n.jsxs("span",{className:"rl-section-suffix","data-tip":w.countSuffix.text,children:[n.jsx("span",{className:"sr-only",children:w.countSuffix.text}),n.jsx("span",{className:"rl-section-suffix-full","aria-hidden":"true",children:w.countSuffix.text}),n.jsx("span",{className:"rl-section-suffix-compact","aria-hidden":"true",children:w.countSuffix.compact})]})]},w.key))}),n.jsxs("div",{className:"rl-facets",children:[u,h]})]}),n.jsxs("div",{className:"lp-rows",role:m?"tabpanel":"region",id:E,"aria-busy":t||void 0,"aria-labelledby":m?C(N):void 0,"aria-label":m?void 0:r,children:[v.length===0&&n.jsx("div",{className:"lp-empty",children:t?g("common.loading"):A}),v.map(w=>w.href?n.jsx("a",{className:`lp-row ${w.cls||""} ${f===w.key?"cur":""}`,href:w.href,children:w.content},w.key):n.jsx("div",{className:`lp-row inert ${w.cls||""}`,children:w.content},w.key))]})]}),j&&n.jsx($s,{...j})]}),p]})}function zn({title:e,titleMeta:s,status:a,side:t,composer:r,missing:i,failure:l,listHref:c,listLabel:o,backHref:u,backLabel:h,children:v}){return l?n.jsxs(Z,{className:"ds-page ds-missing ds-failed",role:"alert",children:[n.jsx("div",{className:"ds-missing-note",children:l}),c&&n.jsx("a",{className:"ds-backlink",href:c,children:o})]}):i?n.jsxs(Z,{className:"ds-page ds-missing",children:[n.jsx("div",{className:"ds-missing-note",children:i}),c&&n.jsx("a",{className:"ds-backlink",href:c,children:o})]}):n.jsxs(Z,{className:"ds-page",children:[n.jsxs("header",{className:"ds-head",children:[u&&n.jsx("a",{className:"ds-back",href:u,"data-tip":h,"aria-label":h,children:n.jsx(R,{name:"arrow-left",size:16})}),n.jsxs("h1",{className:"ds-title",children:[e,s&&n.jsx("span",{className:"ds-title-meta",children:s})]})]}),a&&n.jsx("div",{className:"ds-status",children:a}),n.jsxs("div",{className:"ds-cols",children:[n.jsxs("div",{className:"ds-main",children:[v,r&&n.jsx("div",{className:"ds-compose",children:r})]}),n.jsx("aside",{className:"ds-side",children:t})]})]})}function Un({label:e,children:s}){return n.jsxs("div",{className:"ds-side-sec",children:[n.jsx("span",{className:"ds-side-label",children:e}),n.jsx("div",{className:"ds-side-body",children:s})]})}function Es({text:e,tip:s,dim:a=!1,mono:t=!1,href:r=null,external:i=!1,onClick:l=null,className:c="",lead:o=null,trail:u=null,label:h=null}){const v=`ds-val${a?" dim":""}${t?" mono":""}${r||l?" link":""}${c?` ${c}`:""}`,d=s??(typeof e=="string"?e:void 0),j=h?{"aria-label":h}:{},p=n.jsxs(n.Fragment,{children:[o,n.jsx("span",{className:"ds-val-text",children:e}),u]});return r?n.jsx("a",{className:v,href:r,"data-tip":d,...j,...i?{target:"_blank",rel:"noreferrer"}:{},children:p}):l?n.jsx("button",{type:"button",className:v,onClick:l,"data-tip":d,...j,children:p}):n.jsx("span",{className:v,"data-tip":d,children:p})}const le=Object.freeze({RESULT:"result",BLIND:"blind",UNMEASURED:"unmeasured",DANGLING:"dangling"}),Oe=e=>{var s;return(s=e==null?void 0:e.evidence)!=null&&s.length?e.evidence:(e==null?void 0:e.blob)!=null?[{hash:e.blob,kind:e.blobKind||"image",state:e.blobState||"present"}]:[]},Hn=e=>{const s=Oe(e);return s.length?["video","image","transcript","data"].filter(a=>s.some(t=>t.kind===a)):["note"]},Wn=e=>String(e||"").length>22?`${String(e).slice(0,8)}…`:e;function _e(e,s,a){return a.map(t=>t==="section"?e.section:e.facets[t]).filter(t=>{var r;return(t==null?void 0:t.meaningful)!==!1&&(((r=t==null?void 0:t.options)==null?void 0:r.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:r=>s({[t.key]:r||null})}))}const z=e=>pe(`/api/evidence/${e}`);function Ls({src:e,alt:s,onClose:a}){return x.useEffect(()=>{const t=r=>{r.key==="Escape"&&(r.preventDefault(),r.stopPropagation(),a())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[a]),n.jsx("div",{className:"lightbox",onClick:a,children:n.jsx("img",{src:e,alt:s})})}function As({hash:e}){const s=D(),[a,t]=x.useState(null);return x.useEffect(()=>{let r=!0;return fetch(z(e)).then(i=>i.ok?i.text():Promise.reject(new Error("miss"))).then(i=>{r&&t(i)}).catch(()=>{r&&t("")}),()=>{r=!1}},[e]),a===null?n.jsx("pre",{className:"eval-transcript loading",children:s("nodeView.eval.loadingTranscript")}):n.jsx("pre",{className:"eval-transcript",children:a})}function Ds({hash:e,collapsed:s=!1}){const a=D(),[t,r]=x.useState(null);if(x.useEffect(()=>{let l=!0;return fetch(z(e)).then(c=>c.ok?c.text():Promise.reject(new Error("miss"))).then(c=>{let o=c,u=!0;try{o=JSON.stringify(JSON.parse(c),null,2)}catch{u=!1}l&&r({text:o,valid:u})}).catch(()=>{l&&r({text:"",valid:!1})}),()=>{l=!1}},[e]),t===null)return n.jsx("pre",{className:"eval-data loading",children:a("nodeView.eval.loadingData")});const i=t.valid?a("nodeView.eval.data"):a("nodeView.eval.dataInvalid");return s?n.jsxs("details",{className:"eval-datawrap eval-datafold",children:[n.jsx("summary",{className:"eval-datahead",children:i}),n.jsx("pre",{className:"eval-data",children:t.text})]}):n.jsxs("div",{className:"eval-datawrap",children:[n.jsx("div",{className:"eval-datahead",children:i}),n.jsx("pre",{className:"eval-data",children:t.text})]})}function Is({hash:e,alt:s}){const[a,t]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx("img",{className:"an-image",src:z(e),alt:s,loading:"lazy",onClick:()=>t(!0)}),a&&n.jsx(Ls,{src:z(e),alt:s,onClose:()=>t(!1)})]})}function Cs({exit:e}){return n.jsx(R,{name:e?"minimize":"maximize",size:15})}function Gn({target:e,className:s=""}){const a=D(),[t,r]=x.useState(!1);x.useEffect(()=>{const l=()=>{const c=document.fullscreenElement,o=e==null?void 0:e.current;r(!!c&&!!o&&(c===o||o.contains(c)))};return document.addEventListener("fullscreenchange",l),()=>document.removeEventListener("fullscreenchange",l)},[e]);const i=()=>{var c,o;const l=e==null?void 0:e.current;l&&(document.fullscreenElement?(c=document.exitFullscreen||document.webkitExitFullscreen)==null||c.call(document):(o=l.requestFullscreen||l.webkitRequestFullscreen)==null||o.call(l))};return n.jsx("button",{type:"button",className:`an-fs ${s}`,onClick:i,"data-tip":a(t?"annotator.exitFullscreen":"annotator.fullscreen"),"aria-label":a(t?"annotator.exitFullscreen":"annotator.fullscreen"),children:n.jsx(Cs,{exit:t})})}function Be({e,alt:s="",collapsed:a=!1}){const t=D();return e.state==="miss"?n.jsx("div",{className:"eval-noimg",children:t("nodeView.eval.miss")}):e.kind==="transcript"?n.jsx(As,{hash:e.hash}):e.kind==="data"?n.jsx(Ds,{hash:e.hash,collapsed:a}):e.kind==="video"?n.jsx("video",{className:"eval-video",src:z(e.hash),controls:!0,preload:"metadata",playsInline:!0}):n.jsx(Is,{hash:e.hash,alt:s})}const Q=new Map;function Ts(e){const[s,a]=x.useState(()=>Q.get(e)??null);return x.useEffect(()=>{if(Q.has(e)){a(Q.get(e));return}let t=!0;return fetch(z(e),{headers:{Range:"bytes=0-0"}}).then(r=>{const i=r.headers.get("content-type")||"",l=r.ok?{kind:i.startsWith("video/")?"video":i.startsWith("image/")?"image":i.startsWith("application/json")?"data":"transcript",state:"present"}:{kind:"image",state:"miss"};Q.set(e,l),t&&a(l)}).catch(()=>{t&&a({kind:"image",state:"miss"})}),()=>{t=!1}},[e]),s}function ze({hash:e,alt:s=""}){const a=Ts(e);return a?n.jsx(Be,{e:{hash:e,...a},alt:s}):null}function Rs(e){var s,a;return((s=e==null?void 0:e.verdict)==null?void 0:s.status)==="pass"?"check":((a=e==null?void 0:e.verdict)==null?void 0:a.status)==="fail"?"cross":null}function Ue(e){const s=Rs(e);return s?e.fresh?s==="cross"?"fail":"pass":s==="cross"?"staleFail":"stalePass":"empty"}function Vs(e,s){if(!e)return[];const a=new Map;for(const t of s||[])a.has(t.scenario)||a.set(t.scenario,t);return e.map(t=>{const r=a.get(t.name)||null;return{...t,reading:r,state:r?Ue(r):"missing"}})}function Ps(e){return e.length?e.some(s=>s.state==="fail")?"fail":e.some(s=>s.state==="staleFail")?"staleFail":e.some(s=>s.state==="stalePass")?"stalePass":e.some(s=>s.state==="empty"||s.state==="missing")?"empty":"pass":null}const qs=e=>e.fail>0?"fail":e.staleFail>0?"staleFail":e.stalePass>0?"stalePass":e.empty>0?"empty":"pass";function Fs({scenarios:e,evals:s,summary:a=null,href:t}){const r=D(),i=a?null:Vs(e,s),l=(a==null?void 0:a.total)??i.length;if(!l)return null;const c=a?qs(a):Ps(i),o=(a==null?void 0:a.pass)??i.filter(d=>d.state==="pass").length,u=r("score.count",{satisfied:o,total:l,outstanding:l-o}),h=n.jsxs(n.Fragment,{children:[n.jsx(R,{name:"check",size:11}),o,"/",l]});if(!t)return n.jsx("span",{className:`scenario-count ${c}`,"data-tip":u,"aria-label":u,children:h});const v=`${u} — ${r("score.openList")}`;return n.jsx("a",{className:`scenario-count ${c}`,href:t,"data-tip":v,"aria-label":v,children:h})}function J({kind:e,state:s,cls:a,n:t,label:r}){return n.jsxs("span",{className:`ovc ${a}`,"data-tip":r,children:[n.jsx(ve,{kind:e,state:s,title:r,size:11}),t]})}function Ms({tags:e}){return e!=null&&e.length?n.jsx("span",{className:"tag-chips",children:e.map(s=>n.jsx("span",{className:"tag-chip",children:s},s))}):null}function He({state:e,title:s}){return e?n.jsx(ve,{kind:"eval",state:e,title:s,className:`score-badge ${e}`,size:14}):null}const Qn=e=>({kind:"graph-node",nodeId:e}),Jn=e=>({kind:"session",sessionId:e}),Ks=e=>({kind:"issue",issueId:e}),We=(e,s)=>({kind:"review-list",page:e,query:s}),Ge=(e,s=null)=>({kind:"eval",nodeId:e,scenario:s}),Os=(e,s,a)=>({kind:"session-eval",sessionId:e,nodeId:s,scenario:a});function O(e){if(!e)return P("graph");if(e.kind==="graph-node")return P("graph");if(e.kind==="session")return P("sessions",e.sessionId);if(e.kind==="session-eval"){const s=e.nodeId&&e.scenario?`${e.nodeId}/${e.scenario}`:null;return P("evals",s,{q:s?`scope:${e.sessionId}`:as(e.sessionId)})}return e.kind==="issue"?P("issues",e.issueId):e.kind==="review-list"?P(e.page,null,e.query?{q:e.query}:null):e.kind==="eval"?e.scenario?P("evals",`${e.nodeId}/${e.scenario}`):P("evals",null,{q:rs(e.nodeId)}):P("graph")}function Yn(e,s=null){return e==="issues"?P("issues"):s?O(Os(s)):P("evals")}function Zn(e,{onFocusNode:s,onOpenSession:a}={}){if(e)if(e.kind==="graph-node")s==null||s(e.nodeId),ne("graph");else if(e.kind==="session")a?a(e.sessionId):ne("sessions",e.sessionId);else{const{page:t,param:r,query:i}=ls(O(e));ne(t,r,{query:i})}}function Ne({issue:e,onNavigateAddress:s}){const a=(e==null?void 0:e.store)||"local",t=(e==null?void 0:e.status)||"open",r=Ks(e.id);return n.jsxs("a",{className:"issue-card",href:O(r),"data-tip":e.concern||e.id,onClick:s?i=>{i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),s(r))}:void 0,children:[n.jsxs("span",{className:"issue-card-top",children:[n.jsx("span",{className:"issue-num",children:e.id}),n.jsx("span",{className:`fv-store fv-store-${a==="local"?"local":"forge"}`,children:a}),n.jsx(ve,{kind:"issue",state:t,showLabel:!0,size:12,className:"issue-card-state"})]}),n.jsx("span",{className:"issue-card-title",children:e.concern})]})}const ke=[{key:"spec",label:"spec"},{key:"history",label:"history"},{key:"issues",label:"issues"},{key:"eval",label:"eval"}];function _s(e){var s;return(s=e==null?void 0:e.overlays)!=null&&s.length?[{key:"edit",label:"edit"},...ke]:ke}const Qe=(e,s,a={})=>{let t=`${e==="issue"?"is:issue":is}${a.q?` ${String(a.q).trim()}`:""}`.trim();const r=e==="issue"?{state:"state",author:"author",store:"store",session:"session"}:{verdict:"verdict",review:"state",freshness:"freshness",kind:"evidence",filer:"filer",session:"session"};for(const[i,l]of Object.entries(r))a[i]&&(t=ge(t,l,a[i]));return ge(t,"node",s)},Bs={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"},Je=(e,s)=>{const a=t=>t&&{...t,label:s(Bs[t.key]||t.label||t.key)};return{section:a(e==null?void 0:e.section),facets:Object.fromEntries(Object.entries((e==null?void 0:e.facets)||{}).map(([t,r])=>[t,a(r)]))}},zs={added:"+",edited:"~",deleted:"✕",moved:"→"};function H(e){const s=[],a=/`([^`]+)`|\*\*([^*]+)\*\*|\[\[([^\]]+)\]\]/g;let t=0,r,i=0;for(;r=a.exec(e);)r.index>t&&s.push(e.slice(t,r.index)),r[1]!=null?s.push(n.jsx("code",{children:r[1]},i++)):r[2]!=null?s.push(n.jsx("strong",{children:r[2]},i++)):s.push(n.jsx("span",{className:"doc-link",children:r[3]},i++)),t=a.lastIndex;return t<e.length&&s.push(e.slice(t)),s}function Se(e){const s=e.trim();return s.includes("|")&&/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/.test(s)}function ie(e){let s=e.trim();return s.startsWith("|")&&(s=s.slice(1)),s.endsWith("|")&&(s=s.slice(0,-1)),s.split("|").map(a=>a.trim())}function Us(e){const s=e.startsWith(":"),a=e.endsWith(":");return s&&a?"center":a?"right":null}function se({body:e}){if(!e)return null;const s=e.replace(/^#\s+[^\n]*\n+/,"").split(`
2
2
  `),a=[];let t=0,r=0;for(;t<s.length;){const i=s[t].trim();if(/^```/.test(i)){const l=[];for(t++;t<s.length&&!/^```/.test(s[t].trim());)l.push(s[t++]);t++,a.push(n.jsx("pre",{className:"doc-pre",children:n.jsx("code",{children:l.join(`
3
- `)})},r++))}else if(/^#{1,6}\s+/.test(s[t]))a.push(n.jsx("h4",{className:"doc-h",children:U(s[t].replace(/^#+\s+/,""))},r++)),t++;else if(i.includes("|")&&t+1<s.length&&Se(s[t+1])){const l=ie(s[t]),c=ie(s[t+1]).map(Hs);t+=2;const o=[];for(;t<s.length&&s[t].includes("|")&&s[t].trim()!==""&&!/^```/.test(s[t].trim());)o.push(ie(s[t])),t++;a.push(n.jsxs("table",{className:"doc-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:l.map((u,h)=>n.jsx("th",{style:c[h]?{textAlign:c[h]}:void 0,children:U(u)},h))})}),n.jsx("tbody",{children:o.map((u,h)=>n.jsx("tr",{children:l.map((v,d)=>n.jsx("td",{style:c[d]?{textAlign:c[d]}:void 0,children:U(u[d]??"")},d))},h))})]},r++))}else if(/^-\s+/.test(i)){const l=[];for(;t<s.length&&/^-\s+/.test(s[t].trim());)l.push(s[t++].trim().replace(/^-\s+/,""));a.push(n.jsx("ul",{children:l.map((c,o)=>n.jsx("li",{children:U(c)},o))},r++))}else if(i==="")t++;else{const l=[];for(;t<s.length;){const c=s[t];if(c.trim()===""||/^```/.test(c.trim())||/^#{1,6}\s+/.test(c)||/^-\s+/.test(c.trim())||c.includes("|")&&t+1<s.length&&Se(s[t+1]))break;l.push(c),t++}a.push(n.jsx("p",{children:U(l.join(" "))},r++))}}return n.jsx("div",{className:"doc-body",children:a})}function $e({kind:e,title:s,owner:a,ownerLabel:t,note:r,children:i}){return n.jsxs("section",{className:`spec-part part-${e}`,children:[n.jsxs("header",{className:"part-head",children:[n.jsx("span",{className:"part-title",children:s}),n.jsx("span",{className:`part-owner owner-${a}`,children:t}),r&&n.jsx("span",{className:"part-note",children:r})]}),n.jsx("div",{className:"part-body",children:i})]})}function Us({parts:e}){const s=D();return n.jsxs("div",{className:"spec-parts",children:[n.jsx($e,{kind:"raw",title:s("nodeView.rawTitle"),owner:"human",ownerLabel:s("nodeView.rawOwner"),note:s("nodeView.rawNote"),children:n.jsx(se,{body:e.rawSource})}),n.jsx($e,{kind:"expanded",title:s("nodeView.expandedTitle"),owner:"agent",ownerLabel:s("nodeView.expandedOwner"),note:s("nodeView.expandedNote"),children:n.jsx(se,{body:e.expandedSpec})})]})}const ce=new Map;function Ws(e,s){const a=`${e}@${s??""}`,[t,r]=x.useState(()=>ce.get(a)??null);return x.useEffect(()=>{const i=ce.get(a);if(i){r(i);return}r(null);let l=!0;return fetch(me(e,"content")).then(c=>c.ok?c.json():Promise.reject(c.status)).then(c=>{ce.set(a,c),l&&r(c)}).catch(()=>{l&&r({body:"",parts:null})}),()=>{l=!1}},[e,s,a]),t}function Gs({node:e}){var r,i;const s=D(),a=Ws(e.id,e.version),t=(e.driftFiles||[]).map(l=>`${l.file}: ${s("specNode.driftAhead",{n:l.behind})}`).join(`
4
- `);return n.jsxs("div",{className:"pane-doc",children:[n.jsxs("h1",{children:["# ",e.title]}),n.jsx("blockquote",{children:e.desc}),n.jsxs("div",{className:"doc-stat",children:[n.jsxs("span",{className:`stat-status st-${e.status}`,"data-tip":s("nodeView.statusLabel"),children:[n.jsx("i",{className:"stat-dot"}),s(`status.${e.status}`)]}),n.jsxs("span",{className:"stat-chip","data-tip":s("nodeView.versionLabel"),children:["v",e.version||0]}),n.jsx(qs,{summary:(r=e.reviewSummary)==null?void 0:r.evals,href:O(Ge(e.id))}),e.drift>0&&n.jsxs("span",{className:"stat-chip stat-drift","data-tip":t,children:["⚠",e.drift]}),n.jsxs("span",{className:"stat-sess","data-tip":s("nodeView.lastEditedBy"),children:["✎ ",n.jsx("b",{children:e.session||s("common.none")})]})]}),((i=e.code)==null?void 0:i.length)>0?n.jsxs("div",{className:"doc-gov",children:[n.jsxs("span",{className:"doc-gov-h",children:[s("nodeView.governs")," ",n.jsx("b",{children:e.code.length})]}),n.jsx("div",{className:"doc-gov-files",children:e.code.map(l=>n.jsx("code",{className:"gov-f",children:l},l))})]}):n.jsx("div",{className:"doc-gov prose",children:n.jsx("span",{className:"doc-gov-h",children:s("nodeView.proseNode")})}),(()=>{if(a===null&&e.body==null)return n.jsx("div",{className:"pane-loading",children:n.jsx("span",{className:"spinner","aria-label":s("common.loading")})});const l=e.body??(a==null?void 0:a.body)??"",c=e.parts??(a==null?void 0:a.parts)??null;return c?n.jsx(Us,{parts:c}):n.jsx(se,{body:l})})()]})}function Qs(e,s=!0){const[a,t]=x.useState(null);return x.useEffect(()=>{if(!s)return;let r=!0;return fetch(me(e,"history")).then(i=>i.json()).then(i=>{r&&t(i)}).catch(()=>r&&t([])),()=>{r=!1}},[e,s]),a}const oe=new Map;function Js(e,s,a){const t=`${e}/${s}`,[r,i]=x.useState(()=>oe.get(t)??null);return x.useEffect(()=>{const l=oe.get(t);if(l){i(l);return}let c=!0;return fetch(me(e,"diff",s)).then(o=>o.json()).then(o=>{oe.set(t,o),c&&i(o)}).catch(()=>c&&i({patch:""})),()=>{c=!1}},[e,s,a,t]),r}function Ys(e){const s=[];let a=!1;for(const t of e.split(`
5
- `)){if(t.startsWith("@@")){a=!0,s.push({t:"hunk",s:t});continue}!a||t.startsWith("\\")||(t.startsWith("+")?s.push({t:"add",s:t.slice(1)}):t.startsWith("-")?s.push({t:"del",s:t.slice(1)}):s.push({t:"ctx",s:t.slice(1)}))}for(;s.length&&s[s.length-1].t==="ctx"&&s[s.length-1].s==="";)s.pop();return s}function Ye({diff:e}){const s=D();if(e==null)return n.jsx("figcaption",{className:"ev-note",children:s("nodeView.loadingChange")});const a=e.patch?Ys(e.patch):[];return a.length?n.jsxs(n.Fragment,{children:[n.jsx("figcaption",{className:"ev-difflabel",children:s("nodeView.diffLabel")}),n.jsx("pre",{className:"ev-diff",children:a.map((t,r)=>n.jsx("div",{className:`dl dl-${t.t}`,children:t.s||" "},r))})]}):n.jsx("figcaption",{className:"ev-note",children:s("nodeView.noChange")})}function Ze({items:e,itemKey:s,classes:a,rowClass:t,renderHeader:r,renderEvidence:i,renderAction:l,leading:c,trailing:o,resetKey:u}){const h=x.useRef(null),[v,d]=x.useState(()=>new Set([0]));x.useEffect(()=>{u!==void 0&&d(new Set([0]))},[u]);const j=x.useCallback(g=>d(f=>{const y=new Set(f);return y.has(g)?y.delete(g):y.add(g),y}),[]),p=x.useCallback(()=>d(g=>{const f=h.current;if(!f)return g;let y=-1;for(;g.has(y+1);)y++;if(y<0||y>=e.length-1)return g;const k=f.querySelector(`[data-i="${y}"]`);return!k||k.getBoundingClientRect().bottom-f.getBoundingClientRect().top>f.clientHeight+40?g:new Set(g).add(y+1)}),[e]);return x.useEffect(()=>{const g=h.current;if(!g)return;let f=g.scrollTop;const y=()=>{const S=g.scrollTop,A=S>f;f=S,A&&p()},k=S=>{S.key!=="j"&&S.key!=="ArrowDown"||g.scrollHeight-g.clientHeight-g.scrollTop>1||p()};return g.addEventListener("scroll",y,{passive:!0}),window.addEventListener("keydown",k,!0),()=>{g.removeEventListener("scroll",y),window.removeEventListener("keydown",k,!0)}},[p]),n.jsxs("div",{className:a.pane,ref:h,children:[c,e.map((g,f)=>{const y=v.has(f),k=t?t(g,f):"";return n.jsxs("div",{"data-i":f,className:`${a.row}${k?` ${k}`:""}${y?" open":""}`,children:[n.jsx("button",{className:a.head,onClick:()=>j(f),"aria-expanded":y,children:r(g,f,y)}),l==null?void 0:l(g,f),y&&n.jsx("figure",{className:a.evidence,children:i(g,f)})]},s(g,f))}),o]})}function Zs({node:e,r:s,latest:a}){const t=Js(e.id,s.hash,!0);return n.jsx(Ye,{diff:t})}function Xs({node:e,rows:s}){const a=D();return s?s.length?n.jsx(Ze,{items:s,itemKey:t=>t.hash,classes:{pane:"pane-hist",row:"ver-row",head:"rec-toggle",evidence:"rec-evidence"},rowClass:(t,r)=>r===0?"latest":"",renderHeader:(t,r,i)=>n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"rec-head",children:[n.jsx("span",{className:"rec-caret",children:i?"▾":"▸"}),n.jsxs("span",{className:"rec-v",children:["v",s.length-r]}),n.jsx("code",{className:"rec-hash",children:t.hash.slice(0,7)}),n.jsx("span",{className:"rec-date",children:(t.date||"").slice(0,10)}),n.jsxs("span",{className:"rec-diff",children:[n.jsxs("b",{className:"rec-add",children:["+",t.additions??0]}),n.jsxs("b",{className:"rec-del",children:["−",t.deletions??0]})]})]}),n.jsx("div",{className:"rec-msg",children:t.reason}),n.jsxs("div",{className:"rec-sub",children:[a("nodeView.filesChanged",{n:t.files??0})," · ",t.session||a("common.idle")]})]}),renderEvidence:(t,r)=>n.jsx(Zs,{node:e,r:t,latest:r===0})}):n.jsx("div",{className:"pane-hist empty",children:a("common.noVersions")}):n.jsx("div",{className:"pane-hist empty",children:a("nodeView.loadingHistory")})}function en({node:e,sessions:s=[],filter:a={},onFilter:t=()=>{}}){var j,p,g,f,y;const r=D(),i=Qe("issue",e.id,a),l=Fe("issues",i,1,{pollMs:0});if(l.loading)return n.jsx("div",{className:"pane-issues pane-loading",children:n.jsx("span",{className:"spinner","aria-label":r("common.loading")})});if(l.error)return n.jsx("div",{className:"pane-issues empty",children:l.error});const c=((j=l.data)==null?void 0:j.items)||[],o=(((g=(p=e.reviewSummary)==null?void 0:p.issues)==null?void 0:g.open)||0)+(((y=(f=e.reviewSummary)==null?void 0:f.issues)==null?void 0:y.closed)||0);if(!o)return n.jsx("div",{className:"pane-issues empty",children:r("nodeView.noIssues")});const u=Je(l.data,r),h=c.filter(k=>k.status==="open"),v=c.filter(k=>k.status!=="open"),d=_e(u,t,["section","author","store","session"]);return n.jsxs("div",{className:"pane-issues",children:[o>4&&n.jsx(Ke,{value:a.q||"",onChange:k=>t({q:k||null}),summary:{shown:c.length,total:l.data.total},placeholder:r("nodeView.filterIssues"),searchLabel:r("reviewList.searchIssues"),filterLabel:r("reviewList.filters"),clearLabel:r("reviewList.all"),clearSearchLabel:r("reviewList.clearSearch"),groups:d}),!c.length&&n.jsx("div",{className:"pane-filter-none",children:r("nodeView.filterNone")}),h.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"issue-group-head",children:r("nodeView.openIssues",{n:h.length})}),h.map(k=>n.jsx(Ne,{issue:k},k.id))]}),v.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"issue-group-head closed",children:r("nodeView.closedIssues",{n:v.length})}),v.map(k=>n.jsx(Ne,{issue:k},k.id))]}),l.data.total>c.length&&n.jsxs("a",{className:"pane-view-all",href:O(We("issues",i)),children:[r("reviewList.showing",{shown:c.length,total:l.data.total})," ",n.jsx(R,{name:"chevron-right",size:13})]})]})}const de=new Map;function sn(e,s,a){const t=`${e} ${s}`,[r,i]=x.useState(()=>de.get(t)??null);return x.useEffect(()=>{if(!e||!s)return;const l=de.get(t);l&&i(l);let c=!0;return fetch(pe(`/api/edit?source=${encodeURIComponent(e)}&path=${encodeURIComponent(s)}`)).then(o=>o.json()).then(o=>{de.set(t,o),c&&i(o)}).catch(()=>c&&i(o=>o??{patch:""})),()=>{c=!1}},[e,s,a,t]),r}function nn({node:e,ov:s}){const a=D(),t=sn(s.source,e.path,!0);return n.jsxs("figure",{className:"edit-rev",children:[n.jsxs("figcaption",{className:"edit-by",children:[n.jsx("span",{className:`ov-mark ov-${s.op}`,children:zs[s.op]||"•"}),n.jsx("span",{className:"edit-by-label",children:s.label}),n.jsx("span",{className:"edit-state",children:s.committed?a("nodeView.editCommitted"):a("nodeView.editDirty")})]}),n.jsx(Ye,{diff:t})]})}function tn({node:e}){const s=D(),a=e.overlays||[];return a.length?n.jsx("div",{className:"pane-edit",children:a.map((t,r)=>n.jsx(nn,{node:e,ov:t},r))}):n.jsx("div",{className:"pane-edit empty",children:s("nodeView.noEdit")})}function an({verdict:e}){const s=D();return e?e.status==="pass"?n.jsx("span",{className:"eval-verdict pass",children:s("nodeView.eval.pass")}):e.status==="fail"?n.jsx("span",{className:"eval-verdict fail",children:s("nodeView.eval.fail")}):n.jsx("span",{className:"eval-verdict note","data-tip":e.note,children:s("nodeView.eval.note")}):n.jsx("span",{className:"eval-verdict legacy",children:s("nodeView.eval.legacy")})}function rn({r:e}){var t;const s=D(),a=Oe(e);return n.jsxs(n.Fragment,{children:[e.expected&&n.jsxs("div",{className:"eval-expected",children:[n.jsx("span",{className:"eval-expected-label",children:s("nodeView.eval.expected")})," ",e.expected]}),((t=e.verdict)==null?void 0:t.note)&&n.jsxs("div",{className:"eval-note",children:[n.jsx("span",{className:"eval-expected-label",children:s("nodeView.eval.noteLabel")})," ",e.verdict.note]}),a.length>0?n.jsx("div",{className:"eval-gallery",style:{display:"flex",flexDirection:"column",gap:8},children:a.map((r,i)=>n.jsx(Be,{e:r,alt:s("nodeView.eval.shotAlt",{scenario:e.scenario})},`${r.hash}-${i}`))}):n.jsx("figcaption",{className:"eval-noimg",children:e.blobState==="miss"?s("nodeView.eval.miss"):s("nodeView.eval.noImage")})]})}function Ee({s:e}){var a;const s=D();return n.jsxs("div",{className:"eval-row eval-declared-row",children:[n.jsxs("span",{className:"eval-top",children:[n.jsx(Ue,{state:"empty",title:s("score.missing")}),n.jsx("span",{className:"eval-scenario",children:e.name}),n.jsx(Ms,{tags:e.tags}),((a=e.code)==null?void 0:a.length)>0&&n.jsx("code",{className:"eval-tracks",children:e.code.join(", ")})]}),e.expected&&n.jsxs("div",{className:"eval-expected",children:[n.jsx("span",{className:"eval-expected-label",children:s("nodeView.eval.expected")})," ",e.expected]})]})}function Le({track:e}){const s=D();return n.jsxs("div",{className:"eval-row eval-dangling-row",children:[n.jsxs("span",{className:"eval-top",children:[n.jsx("span",{className:"eval-dangling-badge","data-tip":s("nodeView.eval.danglingTitle"),children:"⚠"}),n.jsx("span",{className:"eval-scenario eval-dangling-name",children:e.scenario}),n.jsx("span",{className:"eval-dangling-tag",children:s("nodeView.eval.danglingGone")})]}),n.jsx("div",{className:"eval-dangling-remarks",children:n.jsx(Dn,{replies:e.remarks})})]})}function ln({node:e,sessions:s=[],filter:a={},onFilter:t=()=>{}}){var g;const r=D(),i=Qe("eval",e.id,a),l=Fe("evals",i,1,{pollMs:0,view:"timeline"});if(l.loading)return n.jsx("div",{className:"pane-eval pane-loading",children:n.jsx("span",{className:"spinner","aria-label":r("common.loading")})});if(l.error)return n.jsx("div",{className:"pane-eval empty",children:l.error});if(!((g=l.data)!=null&&g.hasEvalFile))return n.jsx("div",{className:"pane-eval empty",children:r("nodeView.eval.noScenarios")});const c=l.data.items||[],o=c.filter(f=>f.filterKind===le.RESULT),u=c.filter(f=>f.filterKind===le.UNMEASURED),h=c.filter(f=>f.filterKind===le.DANGLING),v=Je(l.data,r),d=_e(v,t,["section","review","freshness","kind","filer","session"]),j=l.data.sourceTotal>4?n.jsx(Ke,{value:a.q||"",onChange:f=>t({q:f||null}),summary:{shown:c.length,total:l.data.total},placeholder:r("nodeView.filterScenarios"),searchLabel:r("reviewList.searchEvals"),filterLabel:r("reviewList.filters"),clearLabel:r("reviewList.all"),clearSearchLabel:r("reviewList.clearSearch"),groups:d},"filter"):null,p=l.data.total>c.length?n.jsxs("a",{className:"pane-view-all",href:O(We("evals",i)),children:[r("reviewList.showing",{shown:c.length,total:l.data.total})," ",n.jsx(R,{name:"chevron-right",size:13})]}):null;return o.length?n.jsxs(n.Fragment,{children:[n.jsx(Ze,{items:o,resetKey:`${l.data.revision}:${JSON.stringify(a)}`,leading:[j,c.length?null:n.jsx("div",{className:"pane-filter-none",children:r("nodeView.filterNone")},"none"),...u.map(f=>n.jsx(Ee,{s:f},f.name))],trailing:h.map(f=>n.jsx(Le,{track:f},f.threadId)),itemKey:(f,y)=>`${f.scenario}-${f.ts}-${y}`,classes:{pane:"pane-eval",row:"eval-row",head:"eval-head",evidence:"eval-shot"},renderAction:f=>n.jsx("a",{className:"eval-open",href:O(Ge(e.id,f.scenario)),"data-tip":r("nodeView.eval.openDetail"),"aria-label":r("nodeView.eval.openDetail"),children:n.jsx(R,{name:"chevron-right",size:14})}),renderHeader:(f,y,k)=>n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"eval-top",children:[n.jsx("span",{className:"eval-caret",children:k?"▾":"▸"}),n.jsx("span",{className:"eval-scenario",children:f.scenario}),n.jsx(an,{verdict:f.verdict}),n.jsx(Ue,{state:He(f),title:f.fresh?void 0:r("nodeView.eval.staleAxes",{axes:f.staleAxes.join(", ")})})]}),n.jsxs("span",{className:"eval-meta",children:[f.evaluator&&n.jsx("span",{className:"eval-evaluator",children:f.evaluator}),n.jsx("code",{className:"eval-sha",children:f.codeSha.slice(0,7)}),n.jsx("span",{className:"eval-ts",children:f.ts.replace("T"," ").slice(0,16)})]})]}),renderEvidence:f=>n.jsx(rn,{r:f})}),p]}):n.jsxs("div",{className:"pane-eval pane-eval-declared",children:[j,n.jsx("div",{className:"eval-todo-note",children:c.length?r("nodeView.eval.noReadings"):r("nodeView.filterNone")}),u.map(f=>n.jsx(Ee,{s:f},f.name)),h.map(f=>n.jsx(Le,{track:f},f.threadId)),p]})}const cn={spec:"nodeView.paneSpec",history:"nodeView.paneHistory",issues:"nodeView.paneIssues",eval:"nodeView.paneEval",edit:"nodeView.paneEdit"};function Xn({node:e,pane:s,setPane:a,onClose:t,sessions:r=[]}){var y,k,S,A,N,m,E,C;const i=D(),[l,c]=x.useState({issues:{},eval:{}}),o=(w,$)=>c(I=>({...I,[w]:ws(I[w],$)})),u=((k=(y=e.reviewSummary)==null?void 0:y.issues)==null?void 0:k.open)||0,h=((A=(S=e.reviewSummary)==null?void 0:S.issues)==null?void 0:A.closed)||0,v=((m=(N=e.reviewSummary)==null?void 0:N.evals)==null?void 0:m.pass)||0,d=((C=(E=e.reviewSummary)==null?void 0:E.evals)==null?void 0:C.fail)||0,j=(e.overlays||[]).length,p=_s(e),g=p.some(w=>w.key===s)?s:p[0].key,f=Qs(e.id,g==="history");return n.jsx("div",{className:"ov-backdrop","data-focus-overlay":!0,onMouseDown:t,children:n.jsxs("div",{className:"ov-panel",onMouseDown:w=>w.stopPropagation(),children:[n.jsxs("div",{className:"ov-head",children:[n.jsx("span",{className:"ov-title",children:e.title}),n.jsx("div",{className:"ov-tabs",children:p.map(w=>n.jsxs("button",{className:w.key===g?"ov-tab on":"ov-tab",onClick:()=>a(w.key),children:[i(cn[w.key]),w.key==="issues"&&(u>0||h>0)&&n.jsxs("span",{className:"ov-tab-counts",children:[u>0&&n.jsx(J,{kind:"issue",state:"open",cls:"st-open",n:u,label:i("nodeView.openIssues",{n:u})}),h>0&&n.jsx(J,{kind:"issue",state:"closed",cls:"st-closed",n:h,label:i("nodeView.closedIssues",{n:h})})]}),w.key==="eval"&&(v>0||d>0)&&n.jsxs("span",{className:"ov-tab-counts",children:[v>0&&n.jsx(J,{kind:"eval",state:"pass",cls:"st-pass",n:v,label:i("nodeView.eval.passCount",{n:v})}),d>0&&n.jsx(J,{kind:"eval",state:"fail",cls:"st-fail",n:d,label:i("nodeView.eval.failCount",{n:d})})]}),w.key==="edit"&&j>0&&n.jsx("span",{className:"ov-tab-counts",children:n.jsx("span",{className:"ovc st-edit","data-tip":i("nodeView.pendingEdits",{n:j}),children:j})})]},w.key))}),n.jsx("span",{className:"ov-hint",children:i("nodeView.hint")})]}),n.jsxs("div",{className:"ov-body",children:[g==="spec"&&n.jsx("div",{className:"pane-solo",children:n.jsx(Gs,{node:e})}),g==="history"&&n.jsx(Xs,{node:e,rows:f}),g==="issues"&&n.jsx(en,{node:e,sessions:r,filter:l.issues,onFilter:w=>o("issues",w)}),g==="eval"&&n.jsx(ln,{node:e,sessions:r,filter:l.eval,onFilter:w=>o("eval",w)}),g==="edit"&&n.jsx(tn,{node:e})]})]})})}const et=/\[\[(\.?[\p{L}\p{N}_-]+)\]\]/gu,Xe=e=>(e||"").replace(/^\.spec\//,"").replace(/\/spec\.md$/,"");function on(e,s,a){const t=s.toLowerCase(),r=[];for(const i of e){const l=i.id.toLowerCase(),c=Xe(i.path).toLowerCase();let o;if(!t)o=3;else if(l.startsWith(t))o=0;else if(l.includes(t))o=1;else if(c.includes(t))o=2;else continue;i.id===a&&(o=-1),r.push({s:i,score:o})}return r.sort((i,l)=>i.score-l.score||i.s.id.length-l.s.id.length||i.s.id.localeCompare(l.s.id)),r.slice(0,8).map(i=>i.s)}function dn(e,s){const a=s.toLowerCase(),t=c=>hs(c)||(c.id||"").slice(0,8),r=[];for(const c of e||[]){if(c.liveness!=="online")continue;const o=(c.id||"").toLowerCase(),u=t(c).toLowerCase();let h;if(!a)h=3;else if(o===a||u===a)h=0;else if(o.startsWith(a)||u.startsWith(a))h=1;else if(o.includes(a)||u.includes(a))h=2;else continue;r.push({s:c,score:h})}r.sort((c,o)=>c.score-o.score||(o.s.created||0)-(c.s.created||0));const i=r.map(c=>({id:c.s.id,label:t(c.s),sub:c.s.node||c.s.status})),l=r.filter(c=>c.score===0).length;return i.splice(l,0,{id:"new",label:"new",sub:"choose a launcher"}),i.slice(0,8)}function un(e,s){const a=s.toLowerCase();return(e||[]).map(t=>{const r=(t.name||"").toLowerCase(),i=a?r.startsWith(a)?0:r.includes(a)?1:-1:1;return{l:t,score:i}}).filter(t=>t.score>=0).sort((t,r)=>t.score-r.score||t.l.name.localeCompare(r.l.name)).slice(0,8).map(({l:t})=>({id:t.name,label:t.name,sub:t.cmd||t.harness||""}))}function X(e,s){if(!s)return e;const a=e.toLowerCase().indexOf(s.toLowerCase());return a<0?e:n.jsxs(n.Fragment,{children:[e.slice(0,a),n.jsx("b",{className:"mention-hit",children:e.slice(a,a+s.length)}),e.slice(a+s.length)]})}function es(e,s){const a=s.toLowerCase(),t=[];for(const r of e){const i=r.name.toLowerCase();let l;if(!a)l=1;else if(i.startsWith(a))l=0;else if(i.includes(a))l=1;else continue;t.push({c:r,score:l})}return t.sort((r,i)=>r.score-i.score),t.slice(0,10).map(r=>r.c)}function st(e,s,a){let t=s;for(;t>0&&!/\s/.test(e[t-1]);)t--;if(e[t]!=="/")return null;const r=e.slice(t+1,s),i=es(a,r);return i.length?{items:i,index:0,start:t,end:s,query:r}:null}const fn=e=>e&&e[0].toUpperCase()+e.slice(1),hn={user:"(user)",project:"(project)",skill:"[skill]","built-in":"built-in",ui:"[ui]",preset:"[preset]",review:"[review]"};function pn({menu:e,up:s,head:a,onPick:t,onHover:r}){const i=D();return n.jsxs("ul",{className:s?"mention-menu up":"mention-menu",role:"listbox",children:[n.jsxs("li",{className:"mention-head",children:["// ",a," — ",i("session.menuHint")]}),e.items.map((l,c)=>{const o=l.ui?"ui":l.source??l.kind,u=l.ui?` sc-${l.color}`:"";return n.jsxs("li",{role:"option","aria-selected":c===e.index,className:`${c===e.index?"mention-item on":"mention-item"}${u}`,onMouseDown:h=>{h.preventDefault(),t(l)},onMouseEnter:()=>r(c),children:[n.jsxs("span",{className:l.ui?"slash-name ui":"slash-name",children:["/",X(l.name,e.query)]}),n.jsx("span",{className:"slash-desc",children:fn(l.description??l.desc)}),n.jsx("span",{className:`slash-src src-${o}`,children:hn[o]||o})]},`${o}:${l.name}`)})]})}function mn(e,s,a,t){let r=s-1;for(;r>=0&&/[\p{L}\p{N}_.\-]/u.test(e[r]);)r--;if(r>=1&&e[r-1]==="["&&e[r]==="["){const i=e.slice(r+1,s),l=on(a,i,t);return l.length?{kind:"mention",items:l,index:0,start:r-1,end:s,query:i}:null}return null}function Ae(e,s,a,t=[]){let r=s-1;for(;r>=0&&/[\p{L}\p{N}_.:\-]/u.test(e[r]);)r--;if(r>=0&&e[r]==="@"&&(r===0||/\s/.test(e[r-1]))){const i=e.slice(r+1,s);if(i.startsWith("new:")){const c=i.slice(4),o=un(t,c);return o.length?{kind:"launcher",items:o,index:0,start:r,end:s,query:c}:null}const l=dn(a,i);return l.length?{kind:"actor",items:l,index:0,start:r,end:s,query:i}:null}return null}function vn({menu:e,up:s,fixedStyle:a,onPick:t,onHover:r}){const i=D(),l=e.kind==="launcher",c=e.kind==="actor"||l,o=l?`@new:${e.query}`:e.query?c?`@${e.query}`:`[[${e.query}]]`:i(c?"session.menuSessions":"session.menuSpecNodes");return n.jsxs("ul",{className:`${s?"mention-menu up":"mention-menu"}${a?" fixed":""}`,style:a||void 0,role:"listbox",children:[n.jsxs("li",{className:"mention-head",children:["// ",o," — ",i("session.menuHint")]}),e.items.map((u,h)=>n.jsxs("li",{role:"option","aria-selected":h===e.index,className:`${h===e.index?"mention-item on":"mention-item"}${l||c&&u.id==="new"?" new":""}`,onMouseDown:v=>{v.preventDefault(),t(u)},onMouseEnter:()=>r(h),children:[!c&&n.jsx("span",{className:"mention-dot",style:{background:q[u.status]||q.offline}}),n.jsx("span",{className:"mention-id",children:l?n.jsxs(n.Fragment,{children:["@new:",X(u.label,e.query)]}):c?n.jsxs(n.Fragment,{children:["@",X(u.label,e.query)]}):X(u.id,e.query)}),n.jsx("span",{className:"mention-path",children:c?u.sub:Xe(u.path)})]},u.id))]})}function xn({inputRef:e,value:s,setValue:a,specs:t=[],sessions:r=[],launchers:i=[],focusId:l=null,up:c=!1,fixedAbove:o=null}){const[u,h]=x.useState(null),[v,d]=x.useState(null),j=x.useRef(null),p=N=>`${N.value}\0${N.selectionStart}`,g=N=>{var T;if(!N){h(null),d(null);return}const m=p(N);if(j.current===m){h(null),d(null);return}j.current=null;const E=N.selectionStart,C=mn(N.value,E,t,l)||Ae(N.value,E,r,i);if(h(C),!C||!o){d(null);return}const w=N.getBoundingClientRect(),$=(T=N.closest(o))==null?void 0:T.getBoundingClientRect(),I=($==null?void 0:$.top)??w.top;d({left:`${w.left}px`,width:`${w.width}px`,right:"auto",bottom:`${Math.max(8,window.innerHeight-I+8)}px`})};x.useEffect(()=>{const N=e.current;i.length&&N&&document.activeElement===N&&g(N)},[i]);const f=N=>h(m=>m&&{...m,index:(m.index+N+m.items.length)%m.items.length}),y=N=>{if(!N||!u)return;j.current=null;const m=s.slice(0,u.start);if(u.kind==="actor"&&N.id==="new"){const w="@new:",$=m+w+s.slice(u.end),I=m.length+w.length;a($),h(Ae($,I,r,i)),requestAnimationFrame(()=>{const T=e.current;T&&(T.focus(),T.setSelectionRange(I,I))});return}const E=u.kind==="actor"?`@${N.id} `:u.kind==="launcher"?`@new:${N.id} `:`[[${N.id}]] `;a(m+E+s.slice(u.end)),h(null),d(null);const C=m.length+E.length;requestAnimationFrame(()=>{const w=e.current;w&&(w.focus(),w.setSelectionRange(C,C))})};return{menu:u,sync:g,onKeyDown:N=>u?N.key==="ArrowDown"?(N.preventDefault(),N.stopPropagation(),f(1),!0):N.key==="ArrowUp"?(N.preventDefault(),N.stopPropagation(),f(-1),!0):N.key==="Enter"||N.key==="Tab"?(N.preventDefault(),N.stopPropagation(),y(u.items[u.index]),!0):N.key==="Escape"?(N.preventDefault(),N.stopPropagation(),e.current&&(j.current=p(e.current)),h(null),d(null),!0):!1:!1,close:()=>{j.current=null,h(null),d(null)},menuEl:u?n.jsx(vn,{menu:u,up:c,fixedStyle:v,onPick:y,onHover:N=>h(m=>m&&{...m,index:N})}):null}}function gn(e,s,a,t=null){if(!e)return;const r=e.selectionStart??e.value.length,i=e.selectionEnd??r;a(e.value.slice(0,r)+s+e.value.slice(i));const l=r+s.length;requestAnimationFrame(()=>{e.isConnected&&(e.focus(),e.setSelectionRange(l,l),t==null||t(e))})}function ue({label:e,onClick:s,disabled:a=!1,children:t}){return n.jsx("button",{type:"button",className:"fv-trigger-btn","data-tip":e,"aria-label":e,disabled:a,onMouseDown:r=>r.preventDefault(),onClick:s,children:t})}async function nt(e,s){try{const a=await fetch(pe("/api/sessions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,...s?{launcher:s}:{}})}),t=await a.json().catch(()=>null);return{ok:a.ok,error:t==null?void 0:t.error}}catch{return{ok:!1}}}let K=null,Y=null;const jn=()=>K?Promise.resolve(K):(Y||(Y=os().then(e=>(K=e,e)).catch(e=>{throw Y=null,e})),Y),De=e=>Array.isArray(e==null?void 0:e.launchers)?e.launchers:[],wn=()=>{try{return localStorage.getItem("si.launcher")||""}catch{return""}},Ie=(e,s,a=wn())=>{var t;return e.some(r=>r.name===a)?a:s&&e.some(r=>r.name===s)?s:((t=e[0])==null?void 0:t.name)||a};function yn(){const e=De(K),[s,a]=x.useState(e),[t,r]=x.useState(()=>Ie(e,K==null?void 0:K.default)),i=l=>{r(l);try{localStorage.setItem("si.launcher",l)}catch{}};return x.useEffect(()=>{jn().then(l=>{const c=De(l);c.length&&(a(c),r(o=>Ie(c,l.default,o)))}).catch(()=>{})},[]),{launchers:s,launcher:t,pickLauncher:i}}function tt(){const[e,s]=x.useState([]);return x.useEffect(()=>{ds().then(a=>{Array.isArray(a)&&s(a)}).catch(()=>{})},[]),e}function bn(e,s,a=0,t){if(!e)return;const r=t||getComputedStyle(e),i=r.boxSizing==="border-box"?(parseFloat(r.borderTopWidth)||0)+(parseFloat(r.borderBottomWidth)||0):0,l=e.placeholder;!e.value&&l&&(e.placeholder=""),e.style.height="auto";const c=e.scrollHeight+i;e.style.overflowY=c>s?"auto":"hidden",e.style.height=`${Math.min(Math.max(c,a),s)}px`,e.placeholder!==l&&(e.placeholder=l)}function Nn(e){var s,a;return e.isComposing||((s=e.nativeEvent)==null?void 0:s.isComposing)||e.keyCode===229||((a=e.nativeEvent)==null?void 0:a.keyCode)===229}const kn=x.forwardRef(function({value:s,className:a="",...t},r){const i=x.useRef(null);return x.useImperativeHandle(r,()=>i.current),x.useLayoutEffect(()=>{const l=i.current;if(!l)return;const c=getComputedStyle(l);bn(l,parseFloat(c.maxHeight)||1/0,parseFloat(c.minHeight)||0,c)},[s]),n.jsx("textarea",{ref:i,value:s,className:`composer-textarea ${a}`.trim(),...t})});function Sn({className:e="",preview:s=null,editor:a,footer:t,...r}){return n.jsxs("div",{className:`composer-surface ${e}`.trim(),...r,children:[s,n.jsx("div",{className:"composer-editor",children:a}),n.jsx("div",{className:"composer-footer",children:t})]})}const $n=/^▶\s*(\d+):([0-5]?\d)(?:\s*·\s*([^\n]*))?/,Ce=/^!\[frame\]\(\/api\/(?:evidence|yatsu\/blob)\/[0-9a-f]{64}\)\n?/,En=/\/api\/(?:evidence|yatsu\/blob)\/([0-9a-f]{64})/g,Te=/!\[[^\]]*\]\(\/api\/(?:evidence|yatsu\/blob)\/([0-9a-f]{64})\)/g,Ln=e=>{const s=Math.floor(e/1e3);return`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`};function fe(e){var i;const s=e||"",a=s.split(`
6
- `,1)[0],t=$n.exec(a);return t?{tMs:(parseInt(t[1],10)*60+parseInt(t[2],10))*1e3,step:((i=t[3])==null?void 0:i.trim())||null,label:a.trim(),rest:s.slice(a.length).replace(/^\n/,"")}:null}const ss=(e,s)=>`▶${Ln(e)}${s?` · ${s}`:""}`,Re=e=>[...(e||"").matchAll(En)].map(s=>s[1]);function An(e,s){if(!e)return null;if(e.step&&(s!=null&&s.length)){const a=s.find(t=>t.step===e.step);return a?{tMs:a.at,step:e.step,label:ss(a.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 at({originator:e,sessions:s=[],kind:a="issue",onOpenSession:t=null}){const r=D();if(!e)return null;const i=fs(s,e),l=!!i,c=l?q[i.status]||q.working:q.offline,o=r(a==="eval"?"thread.originatorEval":"thread.originatorIssue",{by:e}),u=n.jsx("span",{className:"fv-originator-dot",style:{background:c},"aria-hidden":"true"});return n.jsx(Es,{text:e,tip:o,label:o,lead:u,className:`fv-originator ${l?"alive":"offline"}${l&&t?" openable":""}`,onClick:l&&t?()=>t(e):null})}function Dn({replies:e,onSeek:s,selIdx:a=null,activeIdx:t=null,onSelect:r=null,events:i=null,threadId:l=null,onRemarkChange:c=null}){const o=D(),[u,h]=x.useState(null),[v,d]=x.useState(null),j=async(p,g)=>{if(!u){h(g),d(null);try{const f=await us(p,g);f!=null&&f.ok?await(c==null?void 0:c()):d({ref:g,msg:(f==null?void 0:f.error)||`${p} failed`})}finally{h(null)}}};return e.map((p,g)=>{const f=fe(p.body),y=An(f,i),k=f?f.rest:p.body,S=[...k.matchAll(Te)].map($=>$[1]),A=(S.length?k.replace(Te,""):k).trim(),N=p.rid!==void 0,m=N?p.resolved?" remark resolved":" remark open":"",E=`fv-reply${a===g?" sel":""}${t===g?" active":""}${m}`,C=y&&y.seekable&&s?()=>r?r(g,y.tMs):s(y.tMs):null,w=N&&l?`${l}#${p.rid}`:null;return n.jsxs("div",{className:E,children:[n.jsxs("div",{className:"fv-reply-meta",children:[n.jsx("span",{className:"fv-reply-by",children:p.by}),p.at&&n.jsx("span",{className:"fv-reply-at",children:p.at}),y&&(C?n.jsx("button",{type:"button",className:"fv-anchor",onClick:C,"data-tip":"seek the clip to this moment",children:y.label}):n.jsxs("span",{className:`fv-anchor static${y.degraded?" degraded":""}`,"data-tip":y.degraded?o("thread.anchorDegraded"):void 0,children:[y.label,y.degraded?" ⚠":""]})),N&&(p.resolved?n.jsxs("span",{className:"fv-remark-state resolved","data-tip":p.resolvedBy?o("thread.resolvedBy",{by:p.resolvedBy}):o("thread.resolved"),children:["✓ ",o("thread.resolved")]}):n.jsxs("span",{className:"fv-remark-state open","data-tip":o("thread.openRemark"),children:["● ",o("thread.openRemark")]})),w&&c&&!p.resolved&&(p.by==="human"?n.jsx("button",{type:"button",className:"fv-remark-act retract",disabled:!!u,"data-tip":o("thread.retractTitle"),onClick:()=>j("retract",w),children:o("thread.retract")}):n.jsx("button",{type:"button",className:"fv-remark-act resolve",disabled:!!u,"data-tip":o("thread.resolveTitle"),onClick:()=>j("resolve",w),children:o("thread.resolve")}))]}),v&&v.ref===w&&n.jsx("div",{className:"fv-error",children:v.msg}),A&&n.jsx("div",{className:"fvd-body",children:n.jsx(se,{body:A})}),S.length>0&&n.jsx("div",{className:"fv-reply-media",children:S.map(($,I)=>n.jsx(ze,{hash:$,alt:"evidence"},`${$}-${I}`))})]},g)})}function In(e,s,a){const t=e.lastIndexOf(`
7
- `,s-1)+1,r=/^\/(\S*)$/.exec(e.slice(t,s));if(!r)return null;const i=es(a,r[1]);return i.length?{items:i,index:0,start:t,end:s,query:r[1]}:null}function rt({onSend:e,specs:s=[],sessions:a=[],focusId:t=null,onDone:r,anchorNow:i=null,draft:l=null,actionsEnd:c=null,commands:o=null}){const u=D(),[h,v]=x.useState(""),[d,j]=x.useState(!1),[p,g]=x.useState(""),f=x.useRef(null),{launchers:y}=yn(),k=xn({inputRef:f,value:h,setValue:v,specs:s,sessions:a,launchers:y,focusId:t,up:!0}),[S,A]=x.useState(null),N=b=>A(b&&(o!=null&&o.length)?In(b.value,b.selectionStart,o):null),m=b=>{var H;if(!b||!S)return;const L=h.slice(0,S.start)+h.slice(S.end);if(A(null),b.run){v(L.trim()?L:""),b.run();return}const B=fe(L);let M="";if(B){const F=((H=Ce.exec(B.rest))==null?void 0:H[0])??"";M=`${B.label}
8
- ${F}`,M.endsWith(`
3
+ `)})},r++))}else if(/^#{1,6}\s+/.test(s[t]))a.push(n.jsx("h4",{className:"doc-h",children:H(s[t].replace(/^#+\s+/,""))},r++)),t++;else if(i.includes("|")&&t+1<s.length&&Se(s[t+1])){const l=ie(s[t]),c=ie(s[t+1]).map(Us);t+=2;const o=[];for(;t<s.length&&s[t].includes("|")&&s[t].trim()!==""&&!/^```/.test(s[t].trim());)o.push(ie(s[t])),t++;a.push(n.jsxs("table",{className:"doc-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:l.map((u,h)=>n.jsx("th",{style:c[h]?{textAlign:c[h]}:void 0,children:H(u)},h))})}),n.jsx("tbody",{children:o.map((u,h)=>n.jsx("tr",{children:l.map((v,d)=>n.jsx("td",{style:c[d]?{textAlign:c[d]}:void 0,children:H(u[d]??"")},d))},h))})]},r++))}else if(/^-\s+/.test(i)){const l=[];for(;t<s.length&&/^-\s+/.test(s[t].trim());)l.push(s[t++].trim().replace(/^-\s+/,""));a.push(n.jsx("ul",{children:l.map((c,o)=>n.jsx("li",{children:H(c)},o))},r++))}else if(i==="")t++;else{const l=[];for(;t<s.length;){const c=s[t];if(c.trim()===""||/^```/.test(c.trim())||/^#{1,6}\s+/.test(c)||/^-\s+/.test(c.trim())||c.includes("|")&&t+1<s.length&&Se(s[t+1]))break;l.push(c),t++}a.push(n.jsx("p",{children:H(l.join(" "))},r++))}}return n.jsx("div",{className:"doc-body",children:a})}function $e({kind:e,title:s,owner:a,ownerLabel:t,note:r,children:i}){return n.jsxs("section",{className:`spec-part part-${e}`,children:[n.jsxs("header",{className:"part-head",children:[n.jsx("span",{className:"part-title",children:s}),n.jsx("span",{className:`part-owner owner-${a}`,children:t}),r&&n.jsx("span",{className:"part-note",children:r})]}),n.jsx("div",{className:"part-body",children:i})]})}function Hs({parts:e}){const s=D();return n.jsxs("div",{className:"spec-parts",children:[n.jsx($e,{kind:"raw",title:s("nodeView.rawTitle"),owner:"human",ownerLabel:s("nodeView.rawOwner"),note:s("nodeView.rawNote"),children:n.jsx(se,{body:e.rawSource})}),n.jsx($e,{kind:"expanded",title:s("nodeView.expandedTitle"),owner:"agent",ownerLabel:s("nodeView.expandedOwner"),note:s("nodeView.expandedNote"),children:n.jsx(se,{body:e.expandedSpec})})]})}const ce=new Map;function Ws(e,s){const a=`${e}@${s??""}`,[t,r]=x.useState(()=>ce.get(a)??null);return x.useEffect(()=>{const i=ce.get(a);if(i){r(i);return}r(null);let l=!0;return fetch(me(e,"content")).then(c=>c.ok?c.json():Promise.reject(c.status)).then(c=>{ce.set(a,c),l&&r(c)}).catch(()=>{l&&r({body:"",parts:null})}),()=>{l=!1}},[e,s,a]),t}function Gs({node:e}){var r,i;const s=D(),a=Ws(e.id,e.version),t=(e.driftFiles||[]).map(l=>`${l.file}: ${s("specNode.driftAhead",{n:l.behind})}`).join(`
4
+ `);return n.jsxs("div",{className:"pane-doc",children:[n.jsxs("h1",{children:["# ",e.title]}),n.jsx("blockquote",{children:e.desc}),n.jsxs("div",{className:"doc-stat",children:[n.jsxs("span",{className:`stat-status st-${e.status}`,"data-tip":s("nodeView.statusLabel"),children:[n.jsx("i",{className:"stat-dot"}),s(`status.${e.status}`)]}),n.jsxs("span",{className:"stat-chip","data-tip":s("nodeView.versionLabel"),children:["v",e.version||0]}),n.jsx(Fs,{summary:(r=e.reviewSummary)==null?void 0:r.evals,href:O(Ge(e.id))}),e.drift>0&&n.jsxs("span",{className:"stat-chip stat-drift","data-tip":t,children:["⚠",e.drift]}),n.jsxs("span",{className:"stat-sess","data-tip":s("nodeView.lastEditedBy"),children:["✎ ",n.jsx("b",{children:e.session||s("common.none")})]})]}),((i=e.code)==null?void 0:i.length)>0?n.jsxs("div",{className:"doc-gov",children:[n.jsxs("span",{className:"doc-gov-h",children:[s("nodeView.governs")," ",n.jsx("b",{children:e.code.length})]}),n.jsx("div",{className:"doc-gov-files",children:e.code.map(l=>n.jsx("code",{className:"gov-f",children:l},l))})]}):n.jsx("div",{className:"doc-gov prose",children:n.jsx("span",{className:"doc-gov-h",children:s("nodeView.proseNode")})}),(()=>{if(a===null&&e.body==null)return n.jsx("div",{className:"pane-loading",children:n.jsx("span",{className:"spinner","aria-label":s("common.loading")})});const l=e.body??(a==null?void 0:a.body)??"",c=e.parts??(a==null?void 0:a.parts)??null;return c?n.jsx(Hs,{parts:c}):n.jsx(se,{body:l})})()]})}function Qs(e,s=!0){const[a,t]=x.useState(null);return x.useEffect(()=>{if(!s)return;let r=!0;return fetch(me(e,"history")).then(i=>i.json()).then(i=>{r&&t(i)}).catch(()=>r&&t([])),()=>{r=!1}},[e,s]),a}const oe=new Map;function Js(e,s,a){const t=`${e}/${s}`,[r,i]=x.useState(()=>oe.get(t)??null);return x.useEffect(()=>{const l=oe.get(t);if(l){i(l);return}let c=!0;return fetch(me(e,"diff",s)).then(o=>o.json()).then(o=>{oe.set(t,o),c&&i(o)}).catch(()=>c&&i({patch:""})),()=>{c=!1}},[e,s,a,t]),r}function Ys(e){const s=[];let a=!1;for(const t of e.split(`
5
+ `)){if(t.startsWith("@@")){a=!0,s.push({t:"hunk",s:t});continue}!a||t.startsWith("\\")||(t.startsWith("+")?s.push({t:"add",s:t.slice(1)}):t.startsWith("-")?s.push({t:"del",s:t.slice(1)}):s.push({t:"ctx",s:t.slice(1)}))}for(;s.length&&s[s.length-1].t==="ctx"&&s[s.length-1].s==="";)s.pop();return s}function Ye({diff:e}){const s=D();if(e==null)return n.jsx("figcaption",{className:"ev-note",children:s("nodeView.loadingChange")});const a=e.patch?Ys(e.patch):[];return a.length?n.jsxs(n.Fragment,{children:[n.jsx("figcaption",{className:"ev-difflabel",children:s("nodeView.diffLabel")}),n.jsx("pre",{className:"ev-diff",children:a.map((t,r)=>n.jsx("div",{className:`dl dl-${t.t}`,children:t.s||" "},r))})]}):n.jsx("figcaption",{className:"ev-note",children:s("nodeView.noChange")})}function Ze({items:e,itemKey:s,classes:a,rowClass:t,renderHeader:r,renderEvidence:i,renderAction:l,leading:c,trailing:o,resetKey:u}){const h=x.useRef(null),[v,d]=x.useState(()=>new Set([0]));x.useEffect(()=>{u!==void 0&&d(new Set([0]))},[u]);const j=x.useCallback(g=>d(f=>{const y=new Set(f);return y.has(g)?y.delete(g):y.add(g),y}),[]),p=x.useCallback(()=>d(g=>{const f=h.current;if(!f)return g;let y=-1;for(;g.has(y+1);)y++;if(y<0||y>=e.length-1)return g;const k=f.querySelector(`[data-i="${y}"]`);return!k||k.getBoundingClientRect().bottom-f.getBoundingClientRect().top>f.clientHeight+40?g:new Set(g).add(y+1)}),[e]);return x.useEffect(()=>{const g=h.current;if(!g)return;let f=g.scrollTop;const y=()=>{const S=g.scrollTop,A=S>f;f=S,A&&p()},k=S=>{S.key!=="j"&&S.key!=="ArrowDown"||g.scrollHeight-g.clientHeight-g.scrollTop>1||p()};return g.addEventListener("scroll",y,{passive:!0}),window.addEventListener("keydown",k,!0),()=>{g.removeEventListener("scroll",y),window.removeEventListener("keydown",k,!0)}},[p]),n.jsxs("div",{className:a.pane,ref:h,children:[c,e.map((g,f)=>{const y=v.has(f),k=t?t(g,f):"";return n.jsxs("div",{"data-i":f,className:`${a.row}${k?` ${k}`:""}${y?" open":""}`,children:[n.jsx("button",{className:a.head,onClick:()=>j(f),"aria-expanded":y,children:r(g,f,y)}),l==null?void 0:l(g,f),y&&n.jsx("figure",{className:a.evidence,children:i(g,f)})]},s(g,f))}),o]})}function Zs({node:e,r:s,latest:a}){const t=Js(e.id,s.hash,!0);return n.jsx(Ye,{diff:t})}function Xs({node:e,rows:s}){const a=D();return s?s.length?n.jsx(Ze,{items:s,itemKey:t=>t.hash,classes:{pane:"pane-hist",row:"ver-row",head:"rec-toggle",evidence:"rec-evidence"},rowClass:(t,r)=>r===0?"latest":"",renderHeader:(t,r,i)=>n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"rec-head",children:[n.jsx("span",{className:"rec-caret",children:i?"▾":"▸"}),n.jsxs("span",{className:"rec-v",children:["v",s.length-r]}),n.jsx("code",{className:"rec-hash",children:t.hash.slice(0,7)}),n.jsx("span",{className:"rec-date",children:(t.date||"").slice(0,10)}),n.jsxs("span",{className:"rec-diff",children:[n.jsxs("b",{className:"rec-add",children:["+",t.additions??0]}),n.jsxs("b",{className:"rec-del",children:["−",t.deletions??0]})]})]}),n.jsx("div",{className:"rec-msg",children:t.reason}),n.jsxs("div",{className:"rec-sub",children:[a("nodeView.filesChanged",{n:t.files??0})," · ",t.session||a("common.idle")]})]}),renderEvidence:(t,r)=>n.jsx(Zs,{node:e,r:t,latest:r===0})}):n.jsx("div",{className:"pane-hist empty",children:a("common.noVersions")}):n.jsx("div",{className:"pane-hist empty",children:a("nodeView.loadingHistory")})}function en({node:e,sessions:s=[],filter:a={},onFilter:t=()=>{}}){var j,p,g,f,y;const r=D(),i=Qe("issue",e.id,a),l=qe("issues",i,1,{pollMs:0});if(l.loading)return n.jsx("div",{className:"pane-issues pane-loading",children:n.jsx("span",{className:"spinner","aria-label":r("common.loading")})});if(l.error)return n.jsx("div",{className:"pane-issues empty",children:l.error});const c=((j=l.data)==null?void 0:j.items)||[],o=(((g=(p=e.reviewSummary)==null?void 0:p.issues)==null?void 0:g.open)||0)+(((y=(f=e.reviewSummary)==null?void 0:f.issues)==null?void 0:y.closed)||0);if(!o)return n.jsx("div",{className:"pane-issues empty",children:r("nodeView.noIssues")});const u=Je(l.data,r),h=c.filter(k=>k.status==="open"),v=c.filter(k=>k.status!=="open"),d=_e(u,t,["section","author","store","session"]);return n.jsxs("div",{className:"pane-issues",children:[o>4&&n.jsx(Ke,{value:a.q||"",onChange:k=>t({q:k||null}),summary:{shown:c.length,total:l.data.total},placeholder:r("nodeView.filterIssues"),searchLabel:r("reviewList.searchIssues"),filterLabel:r("reviewList.filters"),clearLabel:r("reviewList.all"),clearSearchLabel:r("reviewList.clearSearch"),groups:d}),!c.length&&n.jsx("div",{className:"pane-filter-none",children:r("nodeView.filterNone")}),h.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"issue-group-head",children:r("nodeView.openIssues",{n:h.length})}),h.map(k=>n.jsx(Ne,{issue:k},k.id))]}),v.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"issue-group-head closed",children:r("nodeView.closedIssues",{n:v.length})}),v.map(k=>n.jsx(Ne,{issue:k},k.id))]}),l.data.total>c.length&&n.jsxs("a",{className:"pane-view-all",href:O(We("issues",i)),children:[r("reviewList.showing",{shown:c.length,total:l.data.total})," ",n.jsx(R,{name:"chevron-right",size:13})]})]})}const de=new Map;function sn(e,s,a){const t=`${e} ${s}`,[r,i]=x.useState(()=>de.get(t)??null);return x.useEffect(()=>{if(!e||!s)return;const l=de.get(t);l&&i(l);let c=!0;return fetch(pe(`/api/edit?source=${encodeURIComponent(e)}&path=${encodeURIComponent(s)}`)).then(o=>o.json()).then(o=>{de.set(t,o),c&&i(o)}).catch(()=>c&&i(o=>o??{patch:""})),()=>{c=!1}},[e,s,a,t]),r}function nn({node:e,ov:s}){const a=D(),t=sn(s.source,e.path,!0);return n.jsxs("figure",{className:"edit-rev",children:[n.jsxs("figcaption",{className:"edit-by",children:[n.jsx("span",{className:`ov-mark ov-${s.op}`,children:zs[s.op]||"•"}),n.jsx("span",{className:"edit-by-label",children:s.label}),n.jsx("span",{className:"edit-state",children:s.committed?a("nodeView.editCommitted"):a("nodeView.editDirty")})]}),n.jsx(Ye,{diff:t})]})}function tn({node:e}){const s=D(),a=e.overlays||[];return a.length?n.jsx("div",{className:"pane-edit",children:a.map((t,r)=>n.jsx(nn,{node:e,ov:t},r))}):n.jsx("div",{className:"pane-edit empty",children:s("nodeView.noEdit")})}function an({verdict:e}){const s=D();return e?e.status==="pass"?n.jsx("span",{className:"eval-verdict pass",children:s("nodeView.eval.pass")}):e.status==="fail"?n.jsx("span",{className:"eval-verdict fail",children:s("nodeView.eval.fail")}):n.jsx("span",{className:"eval-verdict note","data-tip":e.note,children:s("nodeView.eval.note")}):n.jsx("span",{className:"eval-verdict legacy",children:s("nodeView.eval.legacy")})}function rn({r:e}){var t;const s=D(),a=Oe(e);return n.jsxs(n.Fragment,{children:[e.expected&&n.jsxs("div",{className:"eval-expected",children:[n.jsx("span",{className:"eval-expected-label",children:s("nodeView.eval.expected")})," ",e.expected]}),((t=e.verdict)==null?void 0:t.note)&&n.jsxs("div",{className:"eval-note",children:[n.jsx("span",{className:"eval-expected-label",children:s("nodeView.eval.noteLabel")})," ",e.verdict.note]}),a.length>0?n.jsx("div",{className:"eval-gallery",style:{display:"flex",flexDirection:"column",gap:8},children:a.map((r,i)=>n.jsx(Be,{e:r,alt:s("nodeView.eval.shotAlt",{scenario:e.scenario})},`${r.hash}-${i}`))}):n.jsx("figcaption",{className:"eval-noimg",children:e.blobState==="miss"?s("nodeView.eval.miss"):s("nodeView.eval.noImage")})]})}function Ee({s:e}){var a;const s=D();return n.jsxs("div",{className:"eval-row eval-declared-row",children:[n.jsxs("span",{className:"eval-top",children:[n.jsx(He,{state:"empty",title:s("score.missing")}),n.jsx("span",{className:"eval-scenario",children:e.name}),n.jsx(Ms,{tags:e.tags}),((a=e.code)==null?void 0:a.length)>0&&n.jsx("code",{className:"eval-tracks",children:e.code.join(", ")})]}),e.expected&&n.jsxs("div",{className:"eval-expected",children:[n.jsx("span",{className:"eval-expected-label",children:s("nodeView.eval.expected")})," ",e.expected]})]})}function Le({track:e}){const s=D();return n.jsxs("div",{className:"eval-row eval-dangling-row",children:[n.jsxs("span",{className:"eval-top",children:[n.jsx("span",{className:"eval-dangling-badge","data-tip":s("nodeView.eval.danglingTitle"),children:"⚠"}),n.jsx("span",{className:"eval-scenario eval-dangling-name",children:e.scenario}),n.jsx("span",{className:"eval-dangling-tag",children:s("nodeView.eval.danglingGone")})]}),n.jsx("div",{className:"eval-dangling-remarks",children:n.jsx(Dn,{replies:e.remarks})})]})}function ln({node:e,sessions:s=[],filter:a={},onFilter:t=()=>{}}){var g;const r=D(),i=Qe("eval",e.id,a),l=qe("evals",i,1,{pollMs:0,view:"timeline"});if(l.loading)return n.jsx("div",{className:"pane-eval pane-loading",children:n.jsx("span",{className:"spinner","aria-label":r("common.loading")})});if(l.error)return n.jsx("div",{className:"pane-eval empty",children:l.error});if(!((g=l.data)!=null&&g.hasEvalFile))return n.jsx("div",{className:"pane-eval empty",children:r("nodeView.eval.noScenarios")});const c=l.data.items||[],o=c.filter(f=>f.filterKind===le.RESULT),u=c.filter(f=>f.filterKind===le.UNMEASURED),h=c.filter(f=>f.filterKind===le.DANGLING),v=Je(l.data,r),d=_e(v,t,["section","review","freshness","kind","filer","session"]),j=l.data.sourceTotal>4?n.jsx(Ke,{value:a.q||"",onChange:f=>t({q:f||null}),summary:{shown:c.length,total:l.data.total},placeholder:r("nodeView.filterScenarios"),searchLabel:r("reviewList.searchEvals"),filterLabel:r("reviewList.filters"),clearLabel:r("reviewList.all"),clearSearchLabel:r("reviewList.clearSearch"),groups:d},"filter"):null,p=l.data.total>c.length?n.jsxs("a",{className:"pane-view-all",href:O(We("evals",i)),children:[r("reviewList.showing",{shown:c.length,total:l.data.total})," ",n.jsx(R,{name:"chevron-right",size:13})]}):null;return o.length?n.jsxs(n.Fragment,{children:[n.jsx(Ze,{items:o,resetKey:`${l.data.revision}:${JSON.stringify(a)}`,leading:[j,c.length?null:n.jsx("div",{className:"pane-filter-none",children:r("nodeView.filterNone")},"none"),...u.map(f=>n.jsx(Ee,{s:f},f.name))],trailing:h.map(f=>n.jsx(Le,{track:f},f.threadId)),itemKey:(f,y)=>`${f.scenario}-${f.ts}-${y}`,classes:{pane:"pane-eval",row:"eval-row",head:"eval-head",evidence:"eval-shot"},renderAction:f=>n.jsx("a",{className:"eval-open",href:O(Ge(e.id,f.scenario)),"data-tip":r("nodeView.eval.openDetail"),"aria-label":r("nodeView.eval.openDetail"),children:n.jsx(R,{name:"chevron-right",size:14})}),renderHeader:(f,y,k)=>n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"eval-top",children:[n.jsx("span",{className:"eval-caret",children:k?"▾":"▸"}),n.jsx("span",{className:"eval-scenario",children:f.scenario}),n.jsx(an,{verdict:f.verdict}),n.jsx(He,{state:Ue(f),title:f.fresh?void 0:r("nodeView.eval.staleAxes",{axes:f.staleAxes.join(", ")})})]}),n.jsxs("span",{className:"eval-meta",children:[f.evaluator&&n.jsx("span",{className:"eval-evaluator",children:f.evaluator}),n.jsx("code",{className:"eval-sha",children:f.codeSha.slice(0,7)}),n.jsx("span",{className:"eval-ts",children:f.ts.replace("T"," ").slice(0,16)})]})]}),renderEvidence:f=>n.jsx(rn,{r:f})}),p]}):n.jsxs("div",{className:"pane-eval pane-eval-declared",children:[j,n.jsx("div",{className:"eval-todo-note",children:c.length?r("nodeView.eval.noReadings"):r("nodeView.filterNone")}),u.map(f=>n.jsx(Ee,{s:f},f.name)),h.map(f=>n.jsx(Le,{track:f},f.threadId)),p]})}const cn={spec:"nodeView.paneSpec",history:"nodeView.paneHistory",issues:"nodeView.paneIssues",eval:"nodeView.paneEval",edit:"nodeView.paneEdit"};function Xn({node:e,pane:s,setPane:a,onClose:t,sessions:r=[]}){var y,k,S,A,N,m,E,C;const i=D(),[l,c]=x.useState({issues:{},eval:{}}),o=(w,$)=>c(I=>({...I,[w]:ws(I[w],$)})),u=((k=(y=e.reviewSummary)==null?void 0:y.issues)==null?void 0:k.open)||0,h=((A=(S=e.reviewSummary)==null?void 0:S.issues)==null?void 0:A.closed)||0,v=((m=(N=e.reviewSummary)==null?void 0:N.evals)==null?void 0:m.pass)||0,d=((C=(E=e.reviewSummary)==null?void 0:E.evals)==null?void 0:C.fail)||0,j=(e.overlays||[]).length,p=_s(e),g=p.some(w=>w.key===s)?s:p[0].key,f=Qs(e.id,g==="history");return n.jsx("div",{className:"ov-backdrop","data-focus-overlay":!0,onMouseDown:t,children:n.jsxs("div",{className:"ov-panel",onMouseDown:w=>w.stopPropagation(),children:[n.jsxs("div",{className:"ov-head",children:[n.jsx("span",{className:"ov-title",children:e.title}),n.jsx("div",{className:"ov-tabs",children:p.map(w=>n.jsxs("button",{className:w.key===g?"ov-tab on":"ov-tab",onClick:()=>a(w.key),children:[i(cn[w.key]),w.key==="issues"&&(u>0||h>0)&&n.jsxs("span",{className:"ov-tab-counts",children:[u>0&&n.jsx(J,{kind:"issue",state:"open",cls:"st-open",n:u,label:i("nodeView.openIssues",{n:u})}),h>0&&n.jsx(J,{kind:"issue",state:"closed",cls:"st-closed",n:h,label:i("nodeView.closedIssues",{n:h})})]}),w.key==="eval"&&(v>0||d>0)&&n.jsxs("span",{className:"ov-tab-counts",children:[v>0&&n.jsx(J,{kind:"eval",state:"pass",cls:"st-pass",n:v,label:i("nodeView.eval.passCount",{n:v})}),d>0&&n.jsx(J,{kind:"eval",state:"fail",cls:"st-fail",n:d,label:i("nodeView.eval.failCount",{n:d})})]}),w.key==="edit"&&j>0&&n.jsx("span",{className:"ov-tab-counts",children:n.jsx("span",{className:"ovc st-edit","data-tip":i("nodeView.pendingEdits",{n:j}),children:j})})]},w.key))}),n.jsx("span",{className:"ov-hint",children:i("nodeView.hint")})]}),n.jsxs("div",{className:"ov-body",children:[g==="spec"&&n.jsx("div",{className:"pane-solo",children:n.jsx(Gs,{node:e})}),g==="history"&&n.jsx(Xs,{node:e,rows:f}),g==="issues"&&n.jsx(en,{node:e,sessions:r,filter:l.issues,onFilter:w=>o("issues",w)}),g==="eval"&&n.jsx(ln,{node:e,sessions:r,filter:l.eval,onFilter:w=>o("eval",w)}),g==="edit"&&n.jsx(tn,{node:e})]})]})})}const et=/\[\[(\.?[\p{L}\p{N}_-]+)\]\]/gu,Xe=e=>(e||"").replace(/^\.spec\//,"").replace(/\/spec\.md$/,"");function on(e,s,a){const t=s.toLowerCase(),r=[];for(const i of e){const l=i.id.toLowerCase(),c=Xe(i.path).toLowerCase();let o;if(!t)o=3;else if(l.startsWith(t))o=0;else if(l.includes(t))o=1;else if(c.includes(t))o=2;else continue;i.id===a&&(o=-1),r.push({s:i,score:o})}return r.sort((i,l)=>i.score-l.score||i.s.id.length-l.s.id.length||i.s.id.localeCompare(l.s.id)),r.slice(0,8).map(i=>i.s)}function dn(e,s){const a=s.toLowerCase(),t=c=>hs(c)||(c.id||"").slice(0,8),r=[];for(const c of e||[]){if(c.liveness!=="online")continue;const o=(c.id||"").toLowerCase(),u=t(c).toLowerCase();let h;if(!a)h=3;else if(o===a||u===a)h=0;else if(o.startsWith(a)||u.startsWith(a))h=1;else if(o.includes(a)||u.includes(a))h=2;else continue;r.push({s:c,score:h})}r.sort((c,o)=>c.score-o.score||(o.s.created||0)-(c.s.created||0));const i=r.map(c=>({id:c.s.id,label:t(c.s),sub:c.s.node||c.s.status})),l=r.filter(c=>c.score===0).length;return i.splice(l,0,{id:"new",label:"new",sub:"choose a launcher"}),i.slice(0,8)}function un(e,s){const a=s.toLowerCase();return(e||[]).map(t=>{const r=(t.name||"").toLowerCase(),i=a?r.startsWith(a)?0:r.includes(a)?1:-1:1;return{l:t,score:i}}).filter(t=>t.score>=0).sort((t,r)=>t.score-r.score||t.l.name.localeCompare(r.l.name)).slice(0,8).map(({l:t})=>({id:t.name,label:t.name,sub:t.cmd||t.harness||""}))}function X(e,s){if(!s)return e;const a=e.toLowerCase().indexOf(s.toLowerCase());return a<0?e:n.jsxs(n.Fragment,{children:[e.slice(0,a),n.jsx("b",{className:"mention-hit",children:e.slice(a,a+s.length)}),e.slice(a+s.length)]})}function es(e,s){const a=s.toLowerCase(),t=[];for(const r of e){const i=r.name.toLowerCase();let l;if(!a)l=1;else if(i.startsWith(a))l=0;else if(i.includes(a))l=1;else continue;t.push({c:r,score:l})}return t.sort((r,i)=>r.score-i.score),t.slice(0,10).map(r=>r.c)}function st(e,s,a){let t=s;for(;t>0&&!/\s/.test(e[t-1]);)t--;if(e[t]!=="/")return null;const r=e.slice(t+1,s),i=es(a,r);return i.length?{items:i,index:0,start:t,end:s,query:r}:null}const fn=e=>e&&e[0].toUpperCase()+e.slice(1),hn={user:"(user)",project:"(project)",skill:"[skill]","built-in":"built-in",ui:"[ui]",preset:"[preset]",review:"[review]"};function pn({menu:e,up:s,head:a,onPick:t,onHover:r}){const i=D();return n.jsxs("ul",{className:s?"mention-menu up":"mention-menu",role:"listbox",children:[n.jsxs("li",{className:"mention-head",children:["// ",a," — ",i("session.menuHint")]}),e.items.map((l,c)=>{const o=l.ui?"ui":l.source??l.kind,u=l.ui?` sc-${l.color}`:"";return n.jsxs("li",{role:"option","aria-selected":c===e.index,className:`${c===e.index?"mention-item on":"mention-item"}${u}`,onMouseDown:h=>{h.preventDefault(),t(l)},onMouseEnter:()=>r(c),children:[n.jsxs("span",{className:l.ui?"slash-name ui":"slash-name",children:["/",X(l.name,e.query)]}),n.jsx("span",{className:"slash-desc",children:fn(l.description??l.desc)}),n.jsx("span",{className:`slash-src src-${o}`,children:hn[o]||o})]},`${o}:${l.name}`)})]})}function mn(e,s,a,t){let r=s-1;for(;r>=0&&/[\p{L}\p{N}_.\-]/u.test(e[r]);)r--;if(r>=1&&e[r-1]==="["&&e[r]==="["){const i=e.slice(r+1,s),l=on(a,i,t);return l.length?{kind:"mention",items:l,index:0,start:r-1,end:s,query:i}:null}return null}function Ae(e,s,a,t=[]){let r=s-1;for(;r>=0&&/[\p{L}\p{N}_.:\-]/u.test(e[r]);)r--;if(r>=0&&e[r]==="@"&&(r===0||/\s/.test(e[r-1]))){const i=e.slice(r+1,s);if(i.startsWith("new:")){const c=i.slice(4),o=un(t,c);return o.length?{kind:"launcher",items:o,index:0,start:r,end:s,query:c}:null}const l=dn(a,i);return l.length?{kind:"actor",items:l,index:0,start:r,end:s,query:i}:null}return null}function vn({menu:e,up:s,fixedStyle:a,onPick:t,onHover:r}){const i=D(),l=e.kind==="launcher",c=e.kind==="actor"||l,o=l?`@new:${e.query}`:e.query?c?`@${e.query}`:`[[${e.query}]]`:i(c?"session.menuSessions":"session.menuSpecNodes");return n.jsxs("ul",{className:`${s?"mention-menu up":"mention-menu"}${a?" fixed":""}`,style:a||void 0,role:"listbox",children:[n.jsxs("li",{className:"mention-head",children:["// ",o," — ",i("session.menuHint")]}),e.items.map((u,h)=>n.jsxs("li",{role:"option","aria-selected":h===e.index,className:`${h===e.index?"mention-item on":"mention-item"}${l||c&&u.id==="new"?" new":""}`,onMouseDown:v=>{v.preventDefault(),t(u)},onMouseEnter:()=>r(h),children:[!c&&n.jsx("span",{className:"mention-dot",style:{background:F[u.status]||F.offline}}),n.jsx("span",{className:"mention-id",children:l?n.jsxs(n.Fragment,{children:["@new:",X(u.label,e.query)]}):c?n.jsxs(n.Fragment,{children:["@",X(u.label,e.query)]}):X(u.id,e.query)}),n.jsx("span",{className:"mention-path",children:c?u.sub:Xe(u.path)})]},u.id))]})}function xn({inputRef:e,value:s,setValue:a,specs:t=[],sessions:r=[],launchers:i=[],focusId:l=null,up:c=!1,fixedAbove:o=null}){const[u,h]=x.useState(null),[v,d]=x.useState(null),j=x.useRef(null),p=N=>`${N.value}\0${N.selectionStart}`,g=N=>{var T;if(!N){h(null),d(null);return}const m=p(N);if(j.current===m){h(null),d(null);return}j.current=null;const E=N.selectionStart,C=mn(N.value,E,t,l)||Ae(N.value,E,r,i);if(h(C),!C||!o){d(null);return}const w=N.getBoundingClientRect(),$=(T=N.closest(o))==null?void 0:T.getBoundingClientRect(),I=($==null?void 0:$.top)??w.top;d({left:`${w.left}px`,width:`${w.width}px`,right:"auto",bottom:`${Math.max(8,window.innerHeight-I+8)}px`})};x.useEffect(()=>{const N=e.current;i.length&&N&&document.activeElement===N&&g(N)},[i]);const f=N=>h(m=>m&&{...m,index:(m.index+N+m.items.length)%m.items.length}),y=N=>{if(!N||!u)return;j.current=null;const m=s.slice(0,u.start);if(u.kind==="actor"&&N.id==="new"){const w="@new:",$=m+w+s.slice(u.end),I=m.length+w.length;a($),h(Ae($,I,r,i)),requestAnimationFrame(()=>{const T=e.current;T&&(T.focus(),T.setSelectionRange(I,I))});return}const E=u.kind==="actor"?`@${N.id} `:u.kind==="launcher"?`@new:${N.id} `:`[[${N.id}]] `;a(m+E+s.slice(u.end)),h(null),d(null);const C=m.length+E.length;requestAnimationFrame(()=>{const w=e.current;w&&(w.focus(),w.setSelectionRange(C,C))})};return{menu:u,sync:g,onKeyDown:N=>u?N.key==="ArrowDown"?(N.preventDefault(),N.stopPropagation(),f(1),!0):N.key==="ArrowUp"?(N.preventDefault(),N.stopPropagation(),f(-1),!0):N.key==="Enter"||N.key==="Tab"?(N.preventDefault(),N.stopPropagation(),y(u.items[u.index]),!0):N.key==="Escape"?(N.preventDefault(),N.stopPropagation(),e.current&&(j.current=p(e.current)),h(null),d(null),!0):!1:!1,close:()=>{j.current=null,h(null),d(null)},menuEl:u?n.jsx(vn,{menu:u,up:c,fixedStyle:v,onPick:y,onHover:N=>h(m=>m&&{...m,index:N})}):null}}function gn(e,s,a,t=null){if(!e)return;const r=e.selectionStart??e.value.length,i=e.selectionEnd??r;a(e.value.slice(0,r)+s+e.value.slice(i));const l=r+s.length;requestAnimationFrame(()=>{e.isConnected&&(e.focus(),e.setSelectionRange(l,l),t==null||t(e))})}function ue({label:e,onClick:s,disabled:a=!1,children:t}){return n.jsx("button",{type:"button",className:"fv-trigger-btn","data-tip":e,"aria-label":e,disabled:a,onMouseDown:r=>r.preventDefault(),onClick:s,children:t})}async function nt(e,s){var a,t;try{const r=((t=(a=globalThis.crypto)==null?void 0:a.randomUUID)==null?void 0:t.call(a))||`session-create-${Date.now()}-${Math.random().toString(16).slice(2)}`,i=await fetch(pe("/api/sessions"),{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":r},body:JSON.stringify({prompt:e,...s?{launcher:s}:{}})}),l=await i.json().catch(()=>null);return{ok:i.ok,error:l==null?void 0:l.error}}catch{return{ok:!1}}}let K=null,Y=null;const jn=()=>K?Promise.resolve(K):(Y||(Y=os().then(e=>(K=e,e)).catch(e=>{throw Y=null,e})),Y),De=e=>Array.isArray(e==null?void 0:e.launchers)?e.launchers:[],wn=()=>{try{return localStorage.getItem("si.launcher")||""}catch{return""}},Ie=(e,s,a=wn())=>{var t;return e.some(r=>r.name===a)?a:s&&e.some(r=>r.name===s)?s:((t=e[0])==null?void 0:t.name)||a};function yn(){const e=De(K),[s,a]=x.useState(e),[t,r]=x.useState(()=>Ie(e,K==null?void 0:K.default)),i=l=>{r(l);try{localStorage.setItem("si.launcher",l)}catch{}};return x.useEffect(()=>{jn().then(l=>{const c=De(l);c.length&&(a(c),r(o=>Ie(c,l.default,o)))}).catch(()=>{})},[]),{launchers:s,launcher:t,pickLauncher:i}}function tt(){const[e,s]=x.useState([]);return x.useEffect(()=>{ds().then(a=>{Array.isArray(a)&&s(a)}).catch(()=>{})},[]),e}function bn(e,s,a=0,t){if(!e)return;const r=t||getComputedStyle(e),i=r.boxSizing==="border-box"?(parseFloat(r.borderTopWidth)||0)+(parseFloat(r.borderBottomWidth)||0):0,l=e.placeholder;!e.value&&l&&(e.placeholder=""),e.style.height="auto";const c=e.scrollHeight+i;e.style.overflowY=c>s?"auto":"hidden",e.style.height=`${Math.min(Math.max(c,a),s)}px`,e.placeholder!==l&&(e.placeholder=l)}function Nn(e){var s,a;return e.isComposing||((s=e.nativeEvent)==null?void 0:s.isComposing)||e.keyCode===229||((a=e.nativeEvent)==null?void 0:a.keyCode)===229}const kn=x.forwardRef(function({value:s,className:a="",...t},r){const i=x.useRef(null);return x.useImperativeHandle(r,()=>i.current),x.useLayoutEffect(()=>{const l=i.current;if(!l)return;const c=getComputedStyle(l);bn(l,parseFloat(c.maxHeight)||1/0,parseFloat(c.minHeight)||0,c)},[s]),n.jsx("textarea",{ref:i,value:s,className:`composer-textarea ${a}`.trim(),...t})});function Sn({className:e="",preview:s=null,editor:a,footer:t,...r}){return n.jsxs("div",{className:`composer-surface ${e}`.trim(),...r,children:[s,n.jsx("div",{className:"composer-editor",children:a}),n.jsx("div",{className:"composer-footer",children:t})]})}const $n=/^▶\s*(\d+):([0-5]?\d)(?:\s*·\s*([^\n]*))?/,Ce=/^!\[frame\]\(\/api\/(?:evidence|yatsu\/blob)\/[0-9a-f]{64}\)\n?/,En=/\/api\/(?:evidence|yatsu\/blob)\/([0-9a-f]{64})/g,Te=/!\[[^\]]*\]\(\/api\/(?:evidence|yatsu\/blob)\/([0-9a-f]{64})\)/g,Ln=e=>{const s=Math.floor(e/1e3);return`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`};function fe(e){var i;const s=e||"",a=s.split(`
6
+ `,1)[0],t=$n.exec(a);return t?{tMs:(parseInt(t[1],10)*60+parseInt(t[2],10))*1e3,step:((i=t[3])==null?void 0:i.trim())||null,label:a.trim(),rest:s.slice(a.length).replace(/^\n/,"")}:null}const ss=(e,s)=>`▶${Ln(e)}${s?` · ${s}`:""}`,Re=e=>[...(e||"").matchAll(En)].map(s=>s[1]);function An(e,s){if(!e)return null;if(e.step&&(s!=null&&s.length)){const a=s.find(t=>t.step===e.step);return a?{tMs:a.at,step:e.step,label:ss(a.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 at({originator:e,sessions:s=[],kind:a="issue",onOpenSession:t=null}){const r=D();if(!e)return null;const i=fs(s,e),l=!!i,c=l?F[i.status]||F.working:F.offline,o=r(a==="eval"?"thread.originatorEval":"thread.originatorIssue",{by:e}),u=n.jsx("span",{className:"fv-originator-dot",style:{background:c},"aria-hidden":"true"});return n.jsx(Es,{text:e,tip:o,label:o,lead:u,className:`fv-originator ${l?"alive":"offline"}${l&&t?" openable":""}`,onClick:l&&t?()=>t(e):null})}function Dn({replies:e,onSeek:s,selIdx:a=null,activeIdx:t=null,onSelect:r=null,events:i=null,threadId:l=null,onRemarkChange:c=null}){const o=D(),[u,h]=x.useState(null),[v,d]=x.useState(null),j=async(p,g)=>{if(!u){h(g),d(null);try{const f=await us(p,g);f!=null&&f.ok?await(c==null?void 0:c()):d({ref:g,msg:(f==null?void 0:f.error)||`${p} failed`})}finally{h(null)}}};return e.map((p,g)=>{const f=fe(p.body),y=An(f,i),k=f?f.rest:p.body,S=[...k.matchAll(Te)].map($=>$[1]),A=(S.length?k.replace(Te,""):k).trim(),N=p.rid!==void 0,m=N?p.resolved?" remark resolved":" remark open":"",E=`fv-reply${a===g?" sel":""}${t===g?" active":""}${m}`,C=y&&y.seekable&&s?()=>r?r(g,y.tMs):s(y.tMs):null,w=N&&l?`${l}#${p.rid}`:null;return n.jsxs("div",{className:E,children:[n.jsxs("div",{className:"fv-reply-meta",children:[n.jsx("span",{className:"fv-reply-by",children:p.by}),p.at&&n.jsx("span",{className:"fv-reply-at",children:p.at}),y&&(C?n.jsx("button",{type:"button",className:"fv-anchor",onClick:C,"data-tip":"seek the clip to this moment",children:y.label}):n.jsxs("span",{className:`fv-anchor static${y.degraded?" degraded":""}`,"data-tip":y.degraded?o("thread.anchorDegraded"):void 0,children:[y.label,y.degraded?" ⚠":""]})),N&&(p.resolved?n.jsxs("span",{className:"fv-remark-state resolved","data-tip":p.resolvedBy?o("thread.resolvedBy",{by:p.resolvedBy}):o("thread.resolved"),children:["✓ ",o("thread.resolved")]}):n.jsxs("span",{className:"fv-remark-state open","data-tip":o("thread.openRemark"),children:["● ",o("thread.openRemark")]})),w&&c&&!p.resolved&&(p.by==="human"?n.jsx("button",{type:"button",className:"fv-remark-act retract",disabled:!!u,"data-tip":o("thread.retractTitle"),onClick:()=>j("retract",w),children:o("thread.retract")}):n.jsx("button",{type:"button",className:"fv-remark-act resolve",disabled:!!u,"data-tip":o("thread.resolveTitle"),onClick:()=>j("resolve",w),children:o("thread.resolve")}))]}),v&&v.ref===w&&n.jsx("div",{className:"fv-error",children:v.msg}),A&&n.jsx("div",{className:"fvd-body",children:n.jsx(se,{body:A})}),S.length>0&&n.jsx("div",{className:"fv-reply-media",children:S.map(($,I)=>n.jsx(ze,{hash:$,alt:"evidence"},`${$}-${I}`))})]},g)})}function In(e,s,a){const t=e.lastIndexOf(`
7
+ `,s-1)+1,r=/^\/(\S*)$/.exec(e.slice(t,s));if(!r)return null;const i=es(a,r[1]);return i.length?{items:i,index:0,start:t,end:s,query:r[1]}:null}function rt({onSend:e,specs:s=[],sessions:a=[],focusId:t=null,onDone:r,anchorNow:i=null,draft:l=null,actionsEnd:c=null,commands:o=null}){const u=D(),[h,v]=x.useState(""),[d,j]=x.useState(!1),[p,g]=x.useState(""),f=x.useRef(null),{launchers:y}=yn(),k=xn({inputRef:f,value:h,setValue:v,specs:s,sessions:a,launchers:y,focusId:t,up:!0}),[S,A]=x.useState(null),N=b=>A(b&&(o!=null&&o.length)?In(b.value,b.selectionStart,o):null),m=b=>{var U;if(!b||!S)return;const L=h.slice(0,S.start)+h.slice(S.end);if(A(null),b.run){v(L.trim()?L:""),b.run();return}const B=fe(L);let M="";if(B){const q=((U=Ce.exec(B.rest))==null?void 0:U[0])??"";M=`${B.label}
8
+ ${q}`,M.endsWith(`
9
9
  `)||(M+=`
10
- `)}v(M+b.prefill()),requestAnimationFrame(()=>{const F=f.current;F&&(F.focus(),F.setSelectionRange(F.value.length,F.value.length))})},E=b=>S?b.key==="ArrowDown"?(b.preventDefault(),b.stopPropagation(),A(L=>({...L,index:(L.index+1)%L.items.length})),!0):b.key==="ArrowUp"?(b.preventDefault(),b.stopPropagation(),A(L=>({...L,index:(L.index-1+L.items.length)%L.items.length})),!0):b.key==="Enter"||b.key==="Tab"?(b.preventDefault(),b.stopPropagation(),m(S.items[S.index]),!0):b.key==="Escape"?(b.preventDefault(),b.stopPropagation(),A(null),!0):!1:!1,C=Re(h);x.useEffect(()=>{var b;if(!l){v("");return}v(l.body||""),(b=f.current)==null||b.focus()},[l==null?void 0:l.seq]);const w=async()=>{var B;const b=await(i==null?void 0:i());if(!b)return;const L=ss(b.tMs,b.step)+(b.frame?`
11
- ![frame](/api/evidence/${b.frame})`:"");v(M=>{const H=fe(M),F=(H?H.rest:M).replace(Ce,"");return F?`${L}
12
- ${F}`:`${L}
13
- `}),(B=f.current)==null||B.focus()},$=b=>gn(f.current,b,v,L=>{k.sync(L),N(L)}),I=async()=>{const b=h.trim();if(!(!b||d)){j(!0);try{const L=await e(b,Re(b));L!=null&&L.ok?(v(""),g(""),await(r==null?void 0:r(L.outcomes||""))):g((L==null?void 0:L.error)||"reply failed")}finally{j(!1)}}},T=C.length>0?n.jsx("div",{className:"fv-frames",children:C.map(b=>n.jsx(ze,{hash:b,alt:"frame"},b))}):null,_=n.jsxs("div",{className:"fv-tawrap",children:[n.jsx(kn,{ref:f,className:"fv-textarea",rows:1,value:h,placeholder:u("session.issuesReplyPlaceholder"),disabled:d,onChange:b=>{v(b.target.value),k.sync(b.target),N(b.target)},onSelect:b=>{k.sync(b.target),N(b.target)},onBlur:()=>{k.close(),A(null)},onKeyDown:b=>{Nn(b)||E(b)||k.onKeyDown(b)||b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),I())}}),k.menuEl,S&&n.jsx(pn,{menu:S,up:!0,head:S.query?`/${S.query}`:u("annotator.menuReview"),onPick:m,onHover:b=>A(L=>L&&{...L,index:b})})]}),V=n.jsxs("div",{className:"fv-actions",children:[n.jsx(ue,{label:u("thread.mentionActor"),disabled:d,onClick:()=>$("@"),children:"@"}),n.jsx(ue,{label:u("thread.mentionNode"),disabled:d,onClick:()=>$("[["),children:"[["}),(o==null?void 0:o.length)>0&&n.jsx(ue,{label:u("thread.reviewCommands"),disabled:d,onClick:()=>$("/"),children:"/"}),i&&n.jsxs("button",{type:"button",className:"fv-anchor-btn","data-tip":u("thread.anchorTitle"),onMouseDown:b=>b.preventDefault(),onClick:w,children:[n.jsx(R,{name:"clock",size:11})," ",u("thread.anchorNow")]}),p&&n.jsx("span",{className:"fv-error",children:p}),n.jsxs("div",{className:"fv-actions-end",children:[c,n.jsx(he,{icon:"send",size:14,className:"fv-send",label:u(d?"session.issuesSending":"session.issuesSend"),disabled:d||!h.trim(),onMouseDown:b=>b.preventDefault(),onClick:I})]})]});return n.jsx(Sn,{className:"fv-compose",preview:T,editor:_,footer:V})}export{Pe as $,xn as A,Nn as B,Sn as C,zn as D,le as E,On as F,gn as G,kn as H,_s as I,Qs as J,Fn as K,Bn as L,et as M,Gs as N,at as O,Xs as P,en as Q,_n as R,ks as S,ue as T,ln as U,tn as V,vs as W,ws as X,q as Y,nt as Z,qs as _,ve as a,Vn as a0,Ms as a1,Qn as a2,Ks as a3,Mn as a4,Ue as a5,Zn as a6,Xn as a7,Pn as a8,qn as a9,tt as aa,pn as ab,vn as ac,J as ad,mn as ae,Ae as af,st as ag,es as ah,ss as b,He as c,Hn as d,Oe as e,Es as f,rt as g,Gn as h,Be as i,Dn as j,Un as k,Kn as l,Ln as m,Fe as n,O as o,fe as p,Yn as q,An as r,hs as s,Os as t,Me as u,Ge as v,Jn as w,se as x,Wn as y,yn as z};
10
+ `)}v(M+b.prefill()),requestAnimationFrame(()=>{const q=f.current;q&&(q.focus(),q.setSelectionRange(q.value.length,q.value.length))})},E=b=>S?b.key==="ArrowDown"?(b.preventDefault(),b.stopPropagation(),A(L=>({...L,index:(L.index+1)%L.items.length})),!0):b.key==="ArrowUp"?(b.preventDefault(),b.stopPropagation(),A(L=>({...L,index:(L.index-1+L.items.length)%L.items.length})),!0):b.key==="Enter"||b.key==="Tab"?(b.preventDefault(),b.stopPropagation(),m(S.items[S.index]),!0):b.key==="Escape"?(b.preventDefault(),b.stopPropagation(),A(null),!0):!1:!1,C=Re(h);x.useEffect(()=>{var b;if(!l){v("");return}v(l.body||""),(b=f.current)==null||b.focus()},[l==null?void 0:l.seq]);const w=async()=>{var B;const b=await(i==null?void 0:i());if(!b)return;const L=ss(b.tMs,b.step)+(b.frame?`
11
+ ![frame](/api/evidence/${b.frame})`:"");v(M=>{const U=fe(M),q=(U?U.rest:M).replace(Ce,"");return q?`${L}
12
+ ${q}`:`${L}
13
+ `}),(B=f.current)==null||B.focus()},$=b=>gn(f.current,b,v,L=>{k.sync(L),N(L)}),I=async()=>{const b=h.trim();if(!(!b||d)){j(!0);try{const L=await e(b,Re(b));L!=null&&L.ok?(v(""),g(""),await(r==null?void 0:r(L.outcomes||""))):g((L==null?void 0:L.error)||"reply failed")}finally{j(!1)}}},T=C.length>0?n.jsx("div",{className:"fv-frames",children:C.map(b=>n.jsx(ze,{hash:b,alt:"frame"},b))}):null,_=n.jsxs("div",{className:"fv-tawrap",children:[n.jsx(kn,{ref:f,className:"fv-textarea",rows:1,value:h,placeholder:u("session.issuesReplyPlaceholder"),disabled:d,onChange:b=>{v(b.target.value),k.sync(b.target),N(b.target)},onSelect:b=>{k.sync(b.target),N(b.target)},onBlur:()=>{k.close(),A(null)},onKeyDown:b=>{Nn(b)||E(b)||k.onKeyDown(b)||b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),I())}}),k.menuEl,S&&n.jsx(pn,{menu:S,up:!0,head:S.query?`/${S.query}`:u("annotator.menuReview"),onPick:m,onHover:b=>A(L=>L&&{...L,index:b})})]}),V=n.jsxs("div",{className:"fv-actions",children:[n.jsx(ue,{label:u("thread.mentionActor"),disabled:d,onClick:()=>$("@"),children:"@"}),n.jsx(ue,{label:u("thread.mentionNode"),disabled:d,onClick:()=>$("[["),children:"[["}),(o==null?void 0:o.length)>0&&n.jsx(ue,{label:u("thread.reviewCommands"),disabled:d,onClick:()=>$("/"),children:"/"}),i&&n.jsxs("button",{type:"button",className:"fv-anchor-btn","data-tip":u("thread.anchorTitle"),onMouseDown:b=>b.preventDefault(),onClick:w,children:[n.jsx(R,{name:"clock",size:11})," ",u("thread.anchorNow")]}),p&&n.jsx("span",{className:"fv-error",children:p}),n.jsxs("div",{className:"fv-actions-end",children:[c,n.jsx(he,{icon:"send",size:14,className:"fv-send",label:u(d?"session.issuesSending":"session.issuesSend"),disabled:d||!h.trim(),onMouseDown:b=>b.preventDefault(),onClick:I})]})]});return n.jsx(Sn,{className:"fv-compose",preview:T,editor:_,footer:V})}export{Pe as $,xn as A,Nn as B,Sn as C,zn as D,le as E,On as F,gn as G,kn as H,_s as I,Qs as J,qn as K,Bn as L,et as M,Gs as N,at as O,Xs as P,en as Q,_n as R,ks as S,ue as T,ln as U,tn as V,vs as W,ws as X,F as Y,nt as Z,Fs as _,ve as a,Vn as a0,Ms as a1,Qn as a2,Ks as a3,Mn as a4,He as a5,Zn as a6,Xn as a7,Pn as a8,Fn as a9,tt as aa,pn as ab,vn as ac,J as ad,mn as ae,Ae as af,st as ag,es as ah,ss as b,Ue as c,Un as d,Oe as e,Es as f,rt as g,Gn as h,Be as i,Dn as j,Hn as k,Kn as l,Ln as m,qe as n,O as o,fe as p,Yn as q,An as r,hs as s,Os as t,Me as u,Ge as v,Jn as w,se as x,Wn as y,yn as z};