spexcode 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -149
- package/package.json +1 -1
- package/spec-cli/hooks/harness.sh +26 -6
- package/spec-cli/src/anchors.ts +27 -5
- package/spec-cli/src/cli.ts +171 -28
- package/spec-cli/src/client.ts +112 -13
- package/spec-cli/src/delivery-queue.ts +62 -4
- package/spec-cli/src/execution-trace.ts +444 -0
- package/spec-cli/src/gateway-hub.ts +10 -8
- package/spec-cli/src/gateway.ts +99 -6
- package/spec-cli/src/git.ts +477 -101
- package/spec-cli/src/graph.ts +56 -6
- package/spec-cli/src/graphCache.ts +86 -17
- package/spec-cli/src/graphStream.ts +1 -1
- package/spec-cli/src/guide.ts +93 -4
- package/spec-cli/src/harness-select.ts +2 -2
- package/spec-cli/src/harness.ts +344 -66
- package/spec-cli/src/help.ts +22 -10
- package/spec-cli/src/host-resources.ts +62 -7
- package/spec-cli/src/identity-presets.js +16 -6
- package/spec-cli/src/index.ts +101 -13
- package/spec-cli/src/layout.ts +116 -33
- package/spec-cli/src/lint.ts +37 -7
- package/spec-cli/src/materialize.ts +10 -5
- package/spec-cli/src/plugin-harness.ts +10 -10
- package/spec-cli/src/reviews.ts +57 -28
- package/spec-cli/src/session-execution.ts +68 -0
- package/spec-cli/src/session-files.ts +121 -0
- package/spec-cli/src/session-follow.ts +4 -4
- package/spec-cli/src/session-reparent.ts +33 -0
- package/spec-cli/src/session-timeline.ts +163 -14
- package/spec-cli/src/session-web.ts +135 -0
- package/spec-cli/src/sessions.ts +584 -104
- package/spec-cli/src/uninstall.ts +1 -1
- package/spec-cli/templates/spec/project/.plugins/core/comment-altitude/spec.md +2 -21
- package/spec-cli/templates/spec/project/.plugins/core/spec.md +12 -13
- package/spec-cli/templates/spec/project/.plugins/prompts/atomic-landing/spec.md +5 -22
- package/spec-cli/templates/spec/project/.plugins/prompts/forge-link/spec.md +2 -1
- package/spec-cli/templates/spec/project/.plugins/prompts/memory-hygiene/spec.md +4 -6
- package/spec-cli/templates/spec/project/.plugins/prompts/reproduce-before-fix/spec.md +3 -9
- package/spec-dashboard/dist/assets/{App-F9uaAVcH.js → App-B6IbFbGu.js} +2 -2
- package/spec-dashboard/dist/assets/Dashboard-_sDk7Rcg.js +27 -0
- package/spec-dashboard/dist/assets/EvalsPage-BT357Lyt.js +2 -0
- package/spec-dashboard/dist/assets/{IssuesPage-CuKLFhH3.js → IssuesPage-BG9rNOgV.js} +1 -1
- package/spec-dashboard/dist/assets/MobileApp-D9yPMR3A.js +2 -0
- package/spec-dashboard/dist/assets/{Modal-CQgYymmr.js → Modal-B3EcgeA3.js} +1 -1
- package/spec-dashboard/dist/assets/{PageScroll-hT7UTLvD.js → PageScroll-CNZOugWV.js} +1 -1
- package/spec-dashboard/dist/assets/{ProjectsPage-CtXxakF9.js → ProjectsPage-C2CRHmvs.js} +1 -1
- package/spec-dashboard/dist/assets/SessionInterface-DOEjuT3l.js +40 -0
- package/spec-dashboard/dist/assets/{SessionWindow-CixDi4PI.js → SessionWindow-1nYgZ4CL.js} +1 -1
- package/spec-dashboard/dist/assets/Settings-7WeTJn0V.js +1 -0
- package/spec-dashboard/dist/assets/Thread-CEbzAFQn.js +13 -0
- package/spec-dashboard/dist/assets/data-SlvxNA2r.js +1 -0
- package/spec-dashboard/dist/assets/{index-DrVao0Ep.js → index-DLVeOHL-.js} +10 -10
- package/spec-dashboard/dist/assets/index-DYLGfPjx.css +1 -0
- package/spec-dashboard/dist/assets/{launch-BBH02b1v.js → launch-yxCYr64x.js} +29 -29
- package/spec-dashboard/dist/assets/sessionSurface--7l69h4F.js +1 -0
- package/spec-dashboard/dist/index.html +2 -2
- package/spec-eval/src/cli.ts +6 -1
- package/spec-eval/src/evaltab.ts +7 -5
- package/spec-eval/src/freshness.ts +383 -104
- package/spec-eval/src/scenariofresh.ts +2 -2
- package/spec-eval/src/sessioneval.ts +126 -132
- package/spec-dashboard/dist/assets/Dashboard-Ba_jhxp1.js +0 -27
- package/spec-dashboard/dist/assets/EvalsPage-FixoOg_n.js +0 -2
- package/spec-dashboard/dist/assets/MobileApp-CHgEHORJ.js +0 -2
- package/spec-dashboard/dist/assets/SessionInterface-Bpie-9fs.js +0 -39
- package/spec-dashboard/dist/assets/Settings-C2MsucfE.js +0 -1
- package/spec-dashboard/dist/assets/Thread-C6Go8HRh.js +0 -13
- package/spec-dashboard/dist/assets/data-B-RQmit6.js +0 -1
- package/spec-dashboard/dist/assets/index-CsI8DElI.css +0 -1
- package/spec-dashboard/dist/assets/terminalFont-C6oGNKrf.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n,u as p,r as h,I as j}from"./index-
|
|
1
|
+
import{j as n,u as p,r as h,I as j}from"./index-DLVeOHL-.js";import{V as S,s as N,J as k,_ as v,X as z}from"./Thread-CEbzAFQn.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 E(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 O({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 P({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 W(){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=E(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 U({sessions:s,activeId:e,onPick:o,onOpenSession:l}){const a=p(),{expanded:t,toggle:c}=W(),[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(O,{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(P,{expanded:r.expanded,rollup:r.rollup,kin:r.kin,onToggle:()=>c(i.id)})]},i.id)})})}export{A,P as F,F as G,L,O as R,G as S,D as a,M as b,U as c,C as l,W as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as b,r,j as e,L as T}from"./index-DLVeOHL-.js";import{A as E,k,a as v,i as y,r as C,s as A}from"./bindings-BC9vqpYU.js";import{P as F}from"./PageScroll-CNZOugWV.js";import{g as I,a as L,S as u,b as g,T as _,c as M,d as w,s as D,e as O}from"./sessionSurface--7l69h4F.js";const S="spexcode.theme",p=[{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"}],x=new Set(p.map(s=>s.code)),N="minimal";function R(){try{const s=localStorage.getItem(S);if(x.has(s))return s}catch{}return N}function z(s){const c=x.has(s)?s:N;try{document.documentElement.setAttribute("data-theme",c)}catch{}try{localStorage.setItem(S,c)}catch{}return c}function P({t:s}){const[c,d]=r.useState(0),[i,l]=r.useState(null),o=()=>d(n=>n+1);return r.useEffect(()=>{if(!i)return;const n=a=>{if(a.preventDefault(),a.stopPropagation(),a.key==="Escape"){l(null);return}["Shift","Control","Alt","Meta"].includes(a.key)||(A(i,{keys:[a.key]}),l(null),o())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[i]),e.jsxs("section",{className:"legend-sec",children:[e.jsx("div",{className:"legend-h",children:s("settings.secShortcuts")}),e.jsx("div",{className:"set-keys",children:E.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${i===n.id?" capturing":""}${n.rebind?"":" fixed"}${y(n.id)?" custom":""}`,disabled:!n.rebind,onClick:()=>n.rebind&&l(n.id),children:i===n.id?e.jsx("span",{className:"bind-hint",children:s("settings.bindPrompt")}):k(n.id).map((a,m)=>e.jsx("kbd",{children:v(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:()=>{C(),l(null),o()},children:s("settings.reset")})]})]})}function $(){const{t:s,lang:c,setLang:d}=b(),[i,l]=r.useState(R),[o,n]=r.useState(I),[a,m]=r.useState(L),f=t=>{z(t),l(t)},j=t=>n(D(t)),h=t=>m(O(t));return e.jsx(F,{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:T.map(t=>e.jsx("button",{className:t.code===c?"set-lang on":"set-lang",onClick:()=>d(t.code),"aria-pressed":t.code===c,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:p.map(t=>e.jsx("button",{className:t.code===i?"set-lang on":"set-lang",onClick:()=>f(t.code),"aria-pressed":t.code===i,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("div",{className:"set-terminal-surface",children:[e.jsx("span",{children:s("settings.defaultSessionSurface")}),e.jsxs("div",{className:"set-langs",role:"group","aria-label":s("settings.defaultSessionSurface"),children:[e.jsx("button",{className:a===u?"set-lang on":"set-lang",onClick:()=>h(u),"aria-pressed":a===u,children:s("session.tabTerminal")}),e.jsx("button",{className:a===g?"set-lang on":"set-lang",onClick:()=>h(g),"aria-pressed":a===g,children:s("session.tabConversation")})]})]}),e.jsxs("label",{className:"set-terminal-font",children:[e.jsx("span",{children:s("settings.terminalFontSize")}),e.jsx("input",{type:"range",min:w,max:M,step:_,value:o,onChange:t=>j(t.target.value)}),e.jsxs("output",{children:[o,"px"]})]})]}),e.jsx(P,{t:s})]})})}export{$ as default};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{r as w,j as n,I as T,u as A,e as oe,p as Ye,t as Je,d as Le,g as R,v as Ze,w as Xe,n as he,x as es,E as ss,s as pe}from"./index-DLVeOHL-.js";import{P as Q}from"./PageScroll-CNZOugWV.js";import{m as ns,n as de,o as ts}from"./data-SlvxNA2r.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)"},$n={working:"●",parked:"‖",asking:"?",review:"◑",done:"✓",error:"✕",idle:"·",starting:"◌",queued:"⋯","close-pending":"⊘",offline:"○",unknown:"⁇",corrupt:"⚠",retired:"⚑"},De=new Set(["asking","review","done","close-pending","error","corrupt"]),Y=e=>(e==null?void 0:e.liveness)==="offline"||(e==null?void 0:e.status)==="offline"?"offline":De.has(e==null?void 0:e.status)?"need":"run",me=e=>!!(e!=null&&e.archived),En=(e=[])=>({live:e.filter(s=>!me(s)),archived:e.filter(me)}),as=(e,s)=>{const a=s?(e||[]).find(t=>t.id===s):null;return a&&Y(a)!=="offline"?a:null},ve=e=>(e==null?void 0:e.sortKey)!=null?e.sortKey:(e==null?void 0:e.created)??0,xe=e=>{const s={need:0,run:1,offline:2};return[...e].sort((a,t)=>s[Y(a)]-s[Y(t)]||ve(t)-ve(a))},Ln=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),rs=e=>{var s;return(e==null?void 0:e.title)||(e==null?void 0:e.headline)||(e==null?void 0:e.name)||(e==null?void 0:e.activity)||(e==null?void 0:e.note)||(e==null?void 0:e.promptPreview)||(e==null?void 0:e.node)||((s=e==null?void 0:e.raw)==null?void 0:s.title)||(e==null?void 0:e.branch)||(e==null?void 0:e.id)};function ls(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 Dn(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 is(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++,De.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 cs(e,s,{zoneFolded:a=()=>!1,keepVisible:t=()=>!1}={}){const{roots:r,childrenOf:i}=ls(e),l=[],c=(d,x,m,v)=>{const u=i.get(d.id)||[],j=u.length>0,N=j&&!!s(d.id),S=j?is(d.id,i):null;if(l.push({type:"row",s:d,depth:x,expandable:j,expanded:N,rollup:(S==null?void 0:S.color)??null,kin:(S==null?void 0:S.count)??0,guides:v}),N){const k=xe(u).filter($=>!m.has($.id));k.forEach(($,b)=>{m.add($.id),c($,x+1,m,[...v,b<k.length-1])})}},o=(d,x)=>{let m=1;for(const v of i.get(d.id)||[])x.has(v.id)||(x.add(v.id),m+=o(v,x));return m},f=new Set;let h=null,p=null;for(const d of xe(r)){if(f.has(d.id))continue;const x=Y(d);if(x!==h&&(p={type:"zone",zone:x,count:0,folded:!!a(x)},l.push(p),h=x),p.count+=o(d,new Set([...f,d.id])),p.folded){const m=[],v=(u,j)=>{t(u)&&!f.has(u.id)&&m.push(u);for(const N of i.get(u.id)||[])j.has(N.id)||(j.add(N.id),v(N,j))};v(d,new Set([d.id]));for(const u of m)f.add(u.id),l.push({type:"row",s:u,depth:0,expandable:!1,expanded:!1,rollup:null,kin:0,guides:[]});f.add(d.id);continue}f.add(d.id),c(d,0,f,[])}return l}const An=e=>cs(e,()=>!0).filter(s=>s.type==="row").map(s=>s.s),Z=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 Ae(e,s){const a=w.useRef(s);a.current=s,w.useEffect(()=>{if(!e)return;const t={close:()=>{var r;return(r=a.current)==null?void 0:r.call(a)}};return Z.push(t),()=>{const r=Z.indexOf(t);r>=0&&Z.splice(r,1)}},[e])}const U=new Map;async function os(e){if(U.has(e))return U.get(e);const s=ns(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(()=>U.delete(e));return U.set(e,s),s}const In=e=>{const s=typeof e=="string"&&/^\d+$/.test(e)?Number(e):Number.NaN;return Number.isSafeInteger(s)&&s>0?s:1};function ds(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 Ie(e,s,a,{enabled:t=!0,refreshKey:r=null,pollMs:i=15e3,view:l=null}={}){const[c,o]=w.useState(null),[f,h]=w.useState(null),[p,d]=w.useState(t),x=w.useRef(0),m=w.useCallback(async({quiet:u=!1}={})=>{if(!t)return null;const j=++x.current;u||d(!0),h(null);const N=new URLSearchParams({q:String(s||""),page:String(a)});l&&N.set("view",l);try{const S=await os(`/api/${e}?${N}`);return j===x.current&&o(k=>k&&S&&k.revision===S.revision?k:S),S}catch(S){return j===x.current&&h(S instanceof Error?S.message:String(S)),null}finally{j===x.current&&d(!1)}},[e,t,a,s,l]),v=w.useRef(null);return w.useEffect(()=>{if(!t){d(!1);return}const u=`${e}\0${s}\0${a}\0${l||""}`,j=u!==v.current;v.current=u,j&&o(null),m({quiet:!j});const N=i>0?setInterval(()=>m({quiet:!0}),i):null;return()=>{N&&clearInterval(N)}},[e,s,a,l,t,m,i,r]),{data:c,error:f,loading:p,reload:m}}const je={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"}}},us=(e,s)=>{var t;const a=e==="issue"?s==="open"?"open":"closed":s||"empty";return((t=je[e])==null?void 0:t[a])||je.eval.empty};function ue({kind:e,state:s,showLabel:a=!1,size:t=16,className:r="",title:i}){const l=A(),c=us(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(T,{name:c.icon,size:t})}),a&&n.jsx("span",{className:"review-state-label",children:o})]})}function fs(e,s){const a={...e,...s};for(const[t,r]of Object.entries(a))(r==null||r==="")&&delete a[t];return a}const hs=e=>e&&typeof e=="object"?e.hasData?e.filtered:e.dataset:e,Ce=(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]},ps=(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}),fe=(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,ms=(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"},X=e=>[...(e==null?void 0:e.querySelectorAll('[role="menuitemradio"]'))||[]].filter(s=>s.getClientRects().length>0),ee=(e,s)=>{const a=e[s];if(a){for(const t of e)t.tabIndex=t===a?0:-1;a.focus()}};function Te(){const[e,s]=w.useState(!1),a=w.useRef(null),t=w.useRef(null),r=w.useRef(null),i=w.useRef("checked"),l=(d=!1)=>{var x;d&&((x=r.current)==null||x.focus()),s(!1)},c=(d,x="checked")=>{r.current=d,i.current=x,s(!0)},o=d=>{e?l(!1):c(d)};return Ae(e,()=>l(!0)),w.useEffect(()=>{if(!e)return;const d=x=>{var m;(m=a.current)!=null&&m.contains(x.target)||l(!1)};return window.addEventListener("pointerdown",d,!0),()=>window.removeEventListener("pointerdown",d,!0)},[e]),w.useEffect(()=>{if(!e)return;const d=requestAnimationFrame(()=>{const x=X(t.current),m=x.findIndex(u=>u.getAttribute("aria-checked")==="true"),v=i.current==="last"?x.length-1:i.current==="first"?0:m>=0?m:0;ee(x,v)});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 x=X(t.current),m=x.indexOf(document.activeElement);d.preventDefault(),d.stopPropagation(),ee(x,fe(m,x.length,d.key))},onItemFocus:d=>{const x=X(t.current);ee(x,x.indexOf(d.currentTarget))}}}function Cn({label:e,value:s="",options:a=[],onChange:t,mobile:r=!1,clearLabel:i}){const l=Te(),c=Ce(a,s,i);if(!c.length)return null;const o=c.find(p=>String(p.value)===String(s)),f=s?(o==null?void 0:o.label)||String(s):"",h=f?`${e}: ${f}`: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:p=>l.toggle(p.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:f||e}),n.jsx(T,{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(p=>n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":String(p.value)===String(s),tabIndex:-1,className:"rl-menu-item",onFocus:l.onItemFocus,onClick:()=>{l.close(!0),t(p.value)},children:[n.jsx(T,{name:String(p.value)===String(s)?"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)))})]})}function vs({label:e,groups:s=[],clearLabel:a,compact:t=!1,className:r=""}){const i=A(),l=w.useId(),c=s.map(d=>({...d,options:Ce(d.options,d.value,d.clearLabel===null?null:d.clearLabel||a)})).filter(d=>d.options.length),o=c.some(d=>!d.mobileOnly),f=ps(c),h=Te();if(!c.length)return null;const p=(d,x)=>d>0&&n.jsxs("span",{className:`rl-secondary-filter-count ${x}`,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"} ${f.desktop?"active-desktop":""} ${f.mobile?"active-mobile":""} ${r}`,ref:h.ref,children:[t?n.jsx(oe,{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(T,{name:"filter",size:14}),n.jsx("span",{children:e}),p(f.desktop,"for-desktop"),p(f.mobile,"for-mobile"),n.jsx(T,{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,x)=>n.jsxs("div",{role:"group","aria-labelledby":`${l}-group-${x}`,className:`rl-menu-group ${d.mobileOnly?"mobile-only":""}`,children:[n.jsx("div",{className:"rl-menu-label",id:`${l}-group-${x}`,children:d.label}),d.options.map(m=>n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":String(m.value)===String(d.value||""),tabIndex:-1,className:"rl-menu-item",onFocus:h.onItemFocus,onClick:()=>{h.close(!0),d.onChange(m.value)},children:[n.jsx(T,{name:String(m.value)===String(d.value||"")?"check":"blank",size:13}),n.jsx("span",{children:m.label}),m.count!=null&&n.jsx("span",{className:"rl-menu-count",children:m.count})]},String(m.value)))]},`${d.label}-${d.mobileOnly?"mobile":"all"}`))})]})}function Tn({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 H=e=>{const s=String(e??"").trim();return s?`${s} `:""};function xs({value:e="",onSubmit:s,placeholder:a,label:t,keys:r=[],suggest:i={}}){const[l,c]=w.useState(()=>H(e)),[o,f]=w.useState(-1),[h,p]=w.useState(-1),d=w.useRef(null),x=w.useRef(null),m=w.useId(),v=w.useRef(null),u=b=>requestAnimationFrame(()=>{const E=d.current;E&&(b&&E.focus(),E.setSelectionRange(E.value.length,E.value.length))});w.useEffect(()=>{c(H(e)),f(-1),p(-1),u(v.current!==null&&v.current!==e),v.current=e},[e]);const j=o>=0?Ye(l,o,r,i):{start:0,end:0,items:[]},N=j.items.length>0;Ae(N,()=>f(-1));const S=()=>{x.current&&d.current&&(x.current.scrollLeft=d.current.scrollLeft)};w.useEffect(S);const k=b=>{f(-1),p(-1);const E=b.trim();c(H(E)||H(e)),u(!0),s(E)},$=b=>{const E=`${l.slice(0,j.start)}${b.insert}${l.slice(j.end)}`;if(c(E),b.type==="value"){k(E);return}const I=j.start+b.insert.length;f(I),p(-1),requestAnimationFrame(()=>{var y,D;(y=d.current)==null||y.focus(),(D=d.current)==null||D.setSelectionRange(I,I)})};return n.jsxs("form",{className:"rl-query rq",role:"search",onSubmit:b=>{b.preventDefault(),k(l)},children:[n.jsxs("div",{className:"rq-wrap",children:[n.jsx("div",{className:"rq-hl","aria-hidden":"true",ref:x,children:Je(l).map((b,E)=>b.ws||b.key==null||!r.includes(b.key)?n.jsx("span",{children:b.raw},E):n.jsxs("span",{className:"rq-tok",children:[n.jsx("span",{className:"rq-tok-key",children:b.raw.slice(0,b.key.length+1)}),n.jsx("span",{className:"rq-tok-val",children:b.raw.slice(b.key.length+1)})]},E))}),n.jsx("input",{ref:d,role:"combobox","aria-expanded":N,"aria-controls":m,"aria-autocomplete":"list","aria-activedescendant":N&&h>=0?`${m}-o${h}`:void 0,value:l,spellCheck:!1,autoComplete:"off",placeholder:a,"aria-label":t,onChange:b=>{c(b.target.value),f(b.target.selectionStart??b.target.value.length),p(-1)},onScroll:S,onKeyDown:b=>{N&&(b.key==="ArrowDown"||b.key==="ArrowUp"?(b.preventDefault(),p(fe(h,j.items.length,b.key))):b.key==="Enter"&&h>=0&&(b.preventDefault(),$(j.items[h])))},onBlur:()=>f(-1)})]}),N&&n.jsx("div",{className:"rl-menu rq-list",role:"listbox",id:m,"aria-label":t,children:j.items.map((b,E)=>n.jsxs("div",{id:`${m}-o${E}`,role:"option","aria-selected":E===h,className:`rq-opt ${E===h?"active":""}`,onPointerDown:I=>{I.preventDefault(),$(b)},children:[n.jsx("span",{className:"rq-opt-token",children:b.insert.trim()}),b.label&&b.label!==b.value&&n.jsx("span",{className:"rq-opt-label",children:b.label})]},b.insert))}),n.jsx("button",{type:"submit",className:"rl-query-submit","data-tip":t,"aria-label":t,children:n.jsx(T,{name:"search",size:16})})]})}function Re({value:e="",onChange:s,placeholder:a,searchLabel:t,filterLabel:r,groups:i,clearLabel:l,clearSearchLabel:c,summary:o,trailing:f=null}){const h=A(),p=n.jsxs("div",{className:"rf-compact",role:"search",children:[n.jsx("span",{className:"rf-search-icon",children:n.jsx(T,{name:"search",size:13})}),n.jsx("input",{value:e,onChange:x=>s(x.target.value),placeholder:a,"aria-label":t}),e&&n.jsx(oe,{icon:"x",size:12,className:"rf-clear",label:c,onClick:()=>s("")}),n.jsx(vs,{label:r,clearLabel:l,groups:i,compact:!0,className:"rf-secondary-filters"})]});if(!o)return p;const d=h("reviewList.showing",{shown:o.shown,total:o.total});return n.jsxs("div",{className:"rf-row",children:[n.jsxs("span",{className:"rf-summary","data-tip":d,children:[n.jsx("span",{className:"sr-only",children:d}),n.jsx("span",{className:"rf-summary-full","aria-hidden":"true",children:d}),n.jsxs("span",{className:"rf-summary-compact","aria-hidden":"true",children:[o.shown,"/",o.total]})]}),p,f]})}function js({page:e,pageCount:s,prev:a,next:t,hrefFor:r}){const i=A();if(s<=1&&e<=1)return null;const l=(c,o,f,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:f,"aria-label":f?i(`reviewList.${f}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"),ds(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 Rn({notice:e,leading:s,error:a,loading:t=!1,title:r,action:i,search:l,sections:c=[],sectionMode:o="tabs",facets:f,secondaryFilters:h,rows:p,empty:d,pagination:x,children:m}){const v=A(),[u,j]=w.useState(null),N=w.useId(),S=w.useRef({});S.current={rows:p,cur:u},w.useEffect(()=>{const y=D=>{if(D.metaKey||D.ctrlKey||D.altKey||!ms(D.target,D.key))return;const C=S.current.rows.filter(g=>g.href);if(!C.length)return;if(D.key==="Enter"){const g=C.find(L=>L.key===S.current.cur);g&&(D.preventDefault(),D.stopPropagation(),window.location.hash=g.href);return}D.preventDefault(),D.stopPropagation();const P=C.findIndex(g=>g.key===S.current.cur),K=P<0?D.key==="j"?0:C.length-1:Math.max(0,Math.min(C.length-1,P+(D.key==="j"?1:-1)));j(C[K].key)};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[]),w.useEffect(()=>{var y;(y=document.querySelector(".lp-row.cur"))==null||y.scrollIntoView({block:"nearest"})},[u]);const k=hs(d),$=Math.max(0,c.findIndex(y=>y.active)),b=o==="tabs",E=`${N}-panel`,I=y=>`${N}-tab-${y}`;return n.jsxs(Q,{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(xs,{...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:b?"tablist":"group","aria-label":r,...b?{"aria-orientation":"horizontal"}:{},children:c.map((y,D)=>n.jsxs("button",{type:"button",role:b?"tab":void 0,"aria-selected":b?y.active:void 0,"aria-pressed":b?void 0:y.active,"aria-controls":b?E:void 0,id:b?I(D):void 0,tabIndex:b?D===$?0:-1:void 0,className:`rl-section ${y.active?"active":""}`,onClick:y.onSelect,onKeyDown:C=>{var g,L;if(!b||!["ArrowLeft","ArrowRight","Home","End"].includes(C.key))return;const P=[...C.currentTarget.closest('[role="tablist"]').querySelectorAll('[role="tab"]')],K=fe(P.indexOf(C.currentTarget),P.length,C.key);C.preventDefault(),C.stopPropagation(),(g=P[K])==null||g.focus(),(L=P[K])==null||L.click()},children:[n.jsx("span",{children:y.label}),n.jsx("span",{className:"rl-section-count",children:y.count}),y.countSuffix&&n.jsxs("span",{className:"rl-section-suffix","data-tip":y.countSuffix.text,children:[n.jsx("span",{className:"sr-only",children:y.countSuffix.text}),n.jsx("span",{className:"rl-section-suffix-full","aria-hidden":"true",children:y.countSuffix.text}),n.jsx("span",{className:"rl-section-suffix-compact","aria-hidden":"true",children:y.countSuffix.compact})]})]},y.key))}),n.jsxs("div",{className:"rl-facets",children:[f,h]})]}),n.jsxs("div",{className:"lp-rows",role:b?"tabpanel":"region",id:E,"aria-busy":t||void 0,"aria-labelledby":b?I($):void 0,"aria-label":b?void 0:r,children:[p.length===0&&n.jsx("div",{className:"lp-empty",children:t?v("common.loading"):k}),p.map(y=>y.href?n.jsx("a",{className:`lp-row ${y.cls||""} ${u===y.key?"cur":""}`,href:y.href,children:y.content},y.key):n.jsx("div",{className:`lp-row inert ${y.cls||""}`,children:y.content},y.key))]})]}),x&&n.jsx(js,{...x})]}),m]})}function Vn({title:e,titleMeta:s,status:a,side:t,composer:r,missing:i,failure:l,listHref:c,listLabel:o,backHref:f,backLabel:h,children:p}){return l?n.jsxs(Q,{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(Q,{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(Q,{className:"ds-page",children:[n.jsxs("header",{className:"ds-head",children:[f&&n.jsx("a",{className:"ds-back",href:f,"data-tip":h,"aria-label":h,children:n.jsx(T,{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:[p,r&&n.jsx("div",{className:"ds-compose",children:r})]}),n.jsx("aside",{className:"ds-side",children:t})]})]})}function Fn({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 gs({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:f=null,label:h=null}){const p=`ds-val${a?" dim":""}${t?" mono":""}${r||l?" link":""}${c?` ${c}`:""}`,d=s??(typeof e=="string"?e:void 0),x=h?{"aria-label":h}:{},m=n.jsxs(n.Fragment,{children:[o,n.jsx("span",{className:"ds-val-text",children:e}),f]});return r?n.jsx("a",{className:p,href:r,"data-tip":d,...x,...i?{target:"_blank",rel:"noreferrer"}:{},children:m}):l?n.jsx("button",{type:"button",className:p,onClick:l,"data-tip":d,...x,children:m}):n.jsx("span",{className:p,"data-tip":d,children:m})}const se=Object.freeze({RESULT:"result",BLIND:"blind",UNMEASURED:"unmeasured",DANGLING:"dangling"}),Ve=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"}]:[]},Pn=e=>{const s=Ve(e);return s.length?["video","image","transcript","data"].filter(a=>s.some(t=>t.kind===a)):["note"]},Mn=e=>String(e||"").length>22?`${String(e).slice(0,8)}…`:e;function Fe(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 _=e=>Le(`/api/evidence/${e}`);function ws({src:e,alt:s,onClose:a}){return w.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 ys({hash:e}){const s=A(),[a,t]=w.useState(null);return w.useEffect(()=>{let r=!0;return fetch(_(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 bs({hash:e,collapsed:s=!1}){const a=A(),[t,r]=w.useState(null);if(w.useEffect(()=>{let l=!0;return fetch(_(e)).then(c=>c.ok?c.text():Promise.reject(new Error("miss"))).then(c=>{let o=c,f=!0;try{o=JSON.stringify(JSON.parse(c),null,2)}catch{f=!1}l&&r({text:o,valid:f})}).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 Ns({hash:e,alt:s}){const[a,t]=w.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx("img",{className:"an-image",src:_(e),alt:s,loading:"lazy",onClick:()=>t(!0)}),a&&n.jsx(ws,{src:_(e),alt:s,onClose:()=>t(!1)})]})}function ks({exit:e}){return n.jsx(T,{name:e?"minimize":"maximize",size:15})}function qn({target:e,className:s=""}){const a=A(),[t,r]=w.useState(!1);w.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(ks,{exit:t})})}function Pe({e,alt:s="",collapsed:a=!1}){const t=A();return e.state==="miss"?n.jsx("div",{className:"eval-noimg",children:t("nodeView.eval.miss")}):e.kind==="transcript"?n.jsx(ys,{hash:e.hash}):e.kind==="data"?n.jsx(bs,{hash:e.hash,collapsed:a}):e.kind==="video"?n.jsx("video",{className:"eval-video",src:_(e.hash),controls:!0,preload:"metadata",playsInline:!0}):n.jsx(Ns,{hash:e.hash,alt:s})}const W=new Map;function Ss(e){const[s,a]=w.useState(()=>W.get(e)??null);return w.useEffect(()=>{if(W.has(e)){a(W.get(e));return}let t=!0;return fetch(_(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"};W.set(e,l),t&&a(l)}).catch(()=>{t&&a({kind:"image",state:"miss"})}),()=>{t=!1}},[e]),s}function Me({hash:e,alt:s=""}){const a=Ss(e);return a?n.jsx(Pe,{e:{hash:e,...a},alt:s}):null}function $s(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 qe(e){const s=$s(e);return s?e.fresh?s==="cross"?"fail":"pass":s==="cross"?"staleFail":"stalePass":"empty"}function Es(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?qe(r):"missing"}})}function Ls(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 Ds=e=>e.fail>0?"fail":e.staleFail>0?"staleFail":e.stalePass>0?"stalePass":e.empty>0?"empty":"pass";function As({scenarios:e,evals:s,summary:a=null,href:t}){const r=A(),i=a?null:Es(e,s),l=(a==null?void 0:a.total)??i.length;if(!l)return null;const c=a?Ds(a):Ls(i),o=(a==null?void 0:a.pass)??i.filter(d=>d.state==="pass").length,f=r("score.count",{satisfied:o,total:l,outstanding:l-o}),h=n.jsxs(n.Fragment,{children:[n.jsx(T,{name:"check",size:11}),o,"/",l]});if(!t)return n.jsx("span",{className:`scenario-count ${c}`,"data-tip":f,"aria-label":f,children:h});const p=`${f} — ${r("score.openList")}`;return n.jsx("a",{className:`scenario-count ${c}`,href:t,"data-tip":p,"aria-label":p,children:h})}function G({kind:e,state:s,cls:a,n:t,label:r}){return n.jsxs("span",{className:`ovc ${a}`,"data-tip":r,children:[n.jsx(ue,{kind:e,state:s,title:r,size:11}),t]})}function Is({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 Ke({state:e,title:s}){return e?n.jsx(ue,{kind:"eval",state:e,title:s,className:`score-badge ${e}`,size:14}):null}const Kn=e=>({kind:"graph-node",nodeId:e}),On=e=>({kind:"session",sessionId:e}),Cs=e=>({kind:"issue",issueId:e}),Oe=(e,s)=>({kind:"review-list",page:e,query:s}),_e=(e,s=null)=>({kind:"eval",nodeId:e,scenario:s}),Ts=(e,s,a)=>({kind:"session-eval",sessionId:e,nodeId:s,scenario:a});function M(e){if(!e)return R("graph");if(e.kind==="graph-node")return R("graph",e.nodeId);if(e.kind==="session")return R("sessions",e.sessionId);if(e.kind==="session-eval"){const s=e.nodeId&&e.scenario?`${e.nodeId}/${e.scenario}`:null;return R("evals",s,{q:s?`scope:${e.sessionId}`:Ze(e.sessionId)})}return e.kind==="issue"?R("issues",e.issueId):e.kind==="review-list"?R(e.page,null,e.query?{q:e.query}:null):e.kind==="eval"?e.scenario?R("evals",`${e.nodeId}/${e.scenario}`):R("evals",null,{q:Xe(e.nodeId)}):R("graph")}const Rs=(e,s=window.location.href)=>new URL(M(e),s).href;function Vs(e){var r;const s=document.activeElement,a=document.createElement("textarea");a.value=e,a.style.cssText="position:fixed;left:-9999px;top:0",document.body.append(a),a.select();let t=!1;try{t=document.execCommand("copy")}catch{}return a.remove(),(r=s==null?void 0:s.focus)==null||r.call(s),t}async function _n(e){var a;const s=Rs(e);try{if((a=navigator.clipboard)!=null&&a.writeText)return await navigator.clipboard.writeText(s),!0}catch{}return Vs(s)}function Bn(e,s=null){return e==="issues"?R("issues"):s?M(Ts(s)):R("evals")}function zn(e,{onOpenSession:s}={}){if(e)if(e.kind==="session")s?s(e.sessionId):he("sessions",e.sessionId);else{const{page:a,param:t,query:r}=es(M(e));he(a,t,{query:r})}}function ge({issue:e,onNavigateAddress:s}){const a=(e==null?void 0:e.store)||"local",t=(e==null?void 0:e.status)||"open",r=Cs(e.id);return n.jsxs("a",{className:"issue-card",href:M(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(ue,{kind:"issue",state:t,showLabel:!0,size:12,className:"issue-card-state"})]}),n.jsx("span",{className:"issue-card-title",children:e.concern})]})}const we=[{key:"spec",label:"spec"},{key:"history",label:"history"},{key:"issues",label:"issues"},{key:"eval",label:"eval"}];function Fs(e){var s;return(s=e==null?void 0:e.overlays)!=null&&s.length?[{key:"edit",label:"edit"},...we]:we}const Be=(e,s,a={})=>{let t=`${e==="issue"?"is:issue":ss}${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=pe(t,l,a[i]));return pe(t,"node",s)},Ps={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"},ze=(e,s)=>{const a=t=>t&&{...t,label:s(Ps[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)]))}},Ms={added:"+",edited:"~",deleted:"✕",moved:"→"};function z(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 ye(e){const s=e.trim();return s.includes("|")&&/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/.test(s)}function ne(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 qs(e){const s=e.startsWith(":"),a=e.endsWith(":");return s&&a?"center":a?"right":null}function J({body:e}){if(!e)return null;const s=e.replace(/^#\s+[^\n]*\n+/,"").split(`
|
|
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:z(s[t].replace(/^#+\s+/,""))},r++)),t++;else if(i.includes("|")&&t+1<s.length&&ye(s[t+1])){const l=ne(s[t]),c=ne(s[t+1]).map(qs);t+=2;const o=[];for(;t<s.length&&s[t].includes("|")&&s[t].trim()!==""&&!/^```/.test(s[t].trim());)o.push(ne(s[t])),t++;a.push(n.jsxs("table",{className:"doc-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:l.map((f,h)=>n.jsx("th",{style:c[h]?{textAlign:c[h]}:void 0,children:z(f)},h))})}),n.jsx("tbody",{children:o.map((f,h)=>n.jsx("tr",{children:l.map((p,d)=>n.jsx("td",{style:c[d]?{textAlign:c[d]}:void 0,children:z(f[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:z(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&&ye(s[t+1]))break;l.push(c),t++}a.push(n.jsx("p",{children:z(l.join(" "))},r++))}}return n.jsx("div",{className:"doc-body",children:a})}function be({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 Ks({parts:e}){const s=A();return n.jsxs("div",{className:"spec-parts",children:[n.jsx(be,{kind:"raw",title:s("nodeView.rawTitle"),owner:"human",ownerLabel:s("nodeView.rawOwner"),note:s("nodeView.rawNote"),children:n.jsx(J,{body:e.rawSource})}),n.jsx(be,{kind:"expanded",title:s("nodeView.expandedTitle"),owner:"agent",ownerLabel:s("nodeView.expandedOwner"),note:s("nodeView.expandedNote"),children:n.jsx(J,{body:e.expandedSpec})})]})}const te=new Map;function Os(e,s){const a=`${e}@${s??""}`,[t,r]=w.useState(()=>te.get(a)??null);return w.useEffect(()=>{const i=te.get(a);if(i){r(i);return}r(null);let l=!0;return fetch(de(e,"content")).then(c=>c.ok?c.json():Promise.reject(c.status)).then(c=>{te.set(a,c),l&&r(c)}).catch(()=>{l&&r({body:"",parts:null})}),()=>{l=!1}},[e,s,a]),t}function _s({node:e}){var r,i;const s=A(),a=Os(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(As,{summary:(r=e.reviewSummary)==null?void 0:r.evals,href:M(_e(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(Ks,{parts:c}):n.jsx(J,{body:l})})()]})}function Bs(e,s=!0){const[a,t]=w.useState(null);return w.useEffect(()=>{if(!s)return;let r=!0;return fetch(de(e,"history")).then(i=>i.json()).then(i=>{r&&t(i)}).catch(()=>r&&t([])),()=>{r=!1}},[e,s]),a}const ae=new Map;function zs(e,s,a){const t=`${e}/${s}`,[r,i]=w.useState(()=>ae.get(t)??null);return w.useEffect(()=>{const l=ae.get(t);if(l){i(l);return}let c=!0;return fetch(de(e,"diff",s)).then(o=>o.json()).then(o=>{ae.set(t,o),c&&i(o)}).catch(()=>c&&i({patch:""})),()=>{c=!1}},[e,s,a,t]),r}function Us(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 Ue({diff:e}){const s=A();if(e==null)return n.jsx("figcaption",{className:"ev-note",children:s("nodeView.loadingChange")});const a=e.patch?Us(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 He({items:e,itemKey:s,classes:a,rowClass:t,renderHeader:r,renderEvidence:i,renderAction:l,leading:c,trailing:o,resetKey:f}){const h=w.useRef(null),[p,d]=w.useState(()=>new Set([0]));w.useEffect(()=>{f!==void 0&&d(new Set([0]))},[f]);const x=w.useCallback(v=>d(u=>{const j=new Set(u);return j.has(v)?j.delete(v):j.add(v),j}),[]),m=w.useCallback(()=>d(v=>{const u=h.current;if(!u)return v;let j=-1;for(;v.has(j+1);)j++;if(j<0||j>=e.length-1)return v;const N=u.querySelector(`[data-i="${j}"]`);return!N||N.getBoundingClientRect().bottom-u.getBoundingClientRect().top>u.clientHeight+40?v:new Set(v).add(j+1)}),[e]);return w.useEffect(()=>{const v=h.current;if(!v)return;let u=v.scrollTop;const j=()=>{const S=v.scrollTop,k=S>u;u=S,k&&m()},N=S=>{S.key!=="j"&&S.key!=="ArrowDown"||v.scrollHeight-v.clientHeight-v.scrollTop>1||m()};return v.addEventListener("scroll",j,{passive:!0}),window.addEventListener("keydown",N,!0),()=>{v.removeEventListener("scroll",j),window.removeEventListener("keydown",N,!0)}},[m]),n.jsxs("div",{className:a.pane,ref:h,children:[c,e.map((v,u)=>{const j=p.has(u),N=t?t(v,u):"";return n.jsxs("div",{"data-i":u,className:`${a.row}${N?` ${N}`:""}${j?" open":""}`,children:[n.jsx("button",{className:a.head,onClick:()=>x(u),"aria-expanded":j,children:r(v,u,j)}),l==null?void 0:l(v,u),j&&n.jsx("figure",{className:a.evidence,children:i(v,u)})]},s(v,u))}),o]})}function Hs({node:e,r:s,latest:a}){const t=zs(e.id,s.hash,!0);return n.jsx(Ue,{diff:t})}function Ws({node:e,rows:s}){const a=A();return s?s.length?n.jsx(He,{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(Hs,{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 Gs({node:e,sessions:s=[],filter:a={},onFilter:t=()=>{}}){var x,m,v,u,j;const r=A(),i=Be("issue",e.id,a),l=Ie("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=((x=l.data)==null?void 0:x.items)||[],o=(((v=(m=e.reviewSummary)==null?void 0:m.issues)==null?void 0:v.open)||0)+(((j=(u=e.reviewSummary)==null?void 0:u.issues)==null?void 0:j.closed)||0);if(!o)return n.jsx("div",{className:"pane-issues empty",children:r("nodeView.noIssues")});const f=ze(l.data,r),h=c.filter(N=>N.status==="open"),p=c.filter(N=>N.status!=="open"),d=Fe(f,t,["section","author","store","session"]);return n.jsxs("div",{className:"pane-issues",children:[o>4&&n.jsx(Re,{value:a.q||"",onChange:N=>t({q:N||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(N=>n.jsx(ge,{issue:N},N.id))]}),p.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"issue-group-head closed",children:r("nodeView.closedIssues",{n:p.length})}),p.map(N=>n.jsx(ge,{issue:N},N.id))]}),l.data.total>c.length&&n.jsxs("a",{className:"pane-view-all",href:M(Oe("issues",i)),children:[r("reviewList.showing",{shown:c.length,total:l.data.total})," ",n.jsx(T,{name:"chevron-right",size:13})]})]})}const re=new Map;function Qs(e,s,a){const t=`${e} ${s}`,[r,i]=w.useState(()=>re.get(t)??null);return w.useEffect(()=>{if(!e||!s)return;const l=re.get(t);l&&i(l);let c=!0;return fetch(Le(`/api/edit?source=${encodeURIComponent(e)}&path=${encodeURIComponent(s)}`)).then(o=>o.json()).then(o=>{re.set(t,o),c&&i(o)}).catch(()=>c&&i(o=>o??{patch:""})),()=>{c=!1}},[e,s,a,t]),r}function Ys({node:e,ov:s}){const a=A(),t=Qs(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:Ms[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(Ue,{diff:t})]})}function Js({node:e}){const s=A(),a=e.overlays||[];return a.length?n.jsx("div",{className:"pane-edit",children:a.map((t,r)=>n.jsx(Ys,{node:e,ov:t},r))}):n.jsx("div",{className:"pane-edit empty",children:s("nodeView.noEdit")})}function Zs({verdict:e}){const s=A();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 Xs({r:e}){var t;const s=A(),a=Ve(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(Pe,{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 Ne({s:e}){var a;const s=A();return n.jsxs("div",{className:"eval-row eval-declared-row",children:[n.jsxs("span",{className:"eval-top",children:[n.jsx(Ke,{state:"empty",title:s("score.missing")}),n.jsx("span",{className:"eval-scenario",children:e.name}),n.jsx(Is,{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 ke({track:e}){const s=A();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(yn,{replies:e.remarks})})]})}function en({node:e,sessions:s=[],filter:a={},onFilter:t=()=>{}}){var v;const r=A(),i=Be("eval",e.id,a),l=Ie("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(!((v=l.data)!=null&&v.hasEvalFile))return n.jsx("div",{className:"pane-eval empty",children:r("nodeView.eval.noScenarios")});const c=l.data.items||[],o=c.filter(u=>u.filterKind===se.RESULT),f=c.filter(u=>u.filterKind===se.UNMEASURED),h=c.filter(u=>u.filterKind===se.DANGLING),p=ze(l.data,r),d=Fe(p,t,["section","review","freshness","kind","filer","session"]),x=n.jsx("a",{className:"pane-eval-list-door",href:M(Oe("evals",i)),"data-tip":r("score.openList"),"aria-label":r("score.openList"),children:n.jsx(T,{name:"chevron-right",size:14})}),m=l.data.sourceTotal>4?n.jsx(Re,{value:a.q||"",onChange:u=>t({q:u||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,trailing:x},"filter"):n.jsx("div",{className:"pane-eval-list-door-row",children:x});return o.length?n.jsx(n.Fragment,{children:n.jsx(He,{items:o,resetKey:`${l.data.revision}:${JSON.stringify(a)}`,leading:[m,c.length?null:n.jsx("div",{className:"pane-filter-none",children:r("nodeView.filterNone")},"none"),...f.map(u=>n.jsx(Ne,{s:u},u.name))],trailing:h.map(u=>n.jsx(ke,{track:u},u.threadId)),itemKey:(u,j)=>`${u.scenario}-${u.ts}-${j}`,classes:{pane:"pane-eval",row:"eval-row",head:"eval-head",evidence:"eval-shot"},renderAction:u=>n.jsx("a",{className:"eval-open",href:M(_e(e.id,u.scenario)),"data-tip":r("nodeView.eval.openDetail"),"aria-label":r("nodeView.eval.openDetail"),children:n.jsx(T,{name:"chevron-right",size:14})}),renderHeader:(u,j,N)=>n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"eval-top",children:[n.jsx("span",{className:"eval-caret",children:N?"▾":"▸"}),n.jsx("span",{className:"eval-scenario",children:u.scenario}),n.jsx(Zs,{verdict:u.verdict}),n.jsx(Ke,{state:qe(u),title:u.fresh?void 0:r("nodeView.eval.staleAxes",{axes:u.staleAxes.join(", ")})})]}),n.jsxs("span",{className:"eval-meta",children:[u.evaluator&&n.jsx("span",{className:"eval-evaluator",children:u.evaluator}),n.jsx("code",{className:"eval-sha",children:u.codeSha.slice(0,7)}),n.jsx("span",{className:"eval-ts",children:u.ts.replace("T"," ").slice(0,16)})]})]}),renderEvidence:u=>n.jsx(Xs,{r:u})})}):n.jsxs("div",{className:"pane-eval pane-eval-declared",children:[m,n.jsx("div",{className:"eval-todo-note",children:c.length?r("nodeView.eval.noReadings"):r("nodeView.filterNone")}),f.map(u=>n.jsx(Ne,{s:u},u.name)),h.map(u=>n.jsx(ke,{track:u},u.threadId))]})}const sn={spec:"nodeView.paneSpec",history:"nodeView.paneHistory",issues:"nodeView.paneIssues",eval:"nodeView.paneEval",edit:"nodeView.paneEdit"};function Un({node:e,pane:s,setPane:a,onClose:t,sessions:r=[]}){var j,N,S,k,$,b,E,I;const i=A(),[l,c]=w.useState({issues:{},eval:{}}),o=(y,D)=>c(C=>({...C,[y]:fs(C[y],D)})),f=((N=(j=e.reviewSummary)==null?void 0:j.issues)==null?void 0:N.open)||0,h=((k=(S=e.reviewSummary)==null?void 0:S.issues)==null?void 0:k.closed)||0,p=((b=($=e.reviewSummary)==null?void 0:$.evals)==null?void 0:b.pass)||0,d=((I=(E=e.reviewSummary)==null?void 0:E.evals)==null?void 0:I.fail)||0,x=(e.overlays||[]).length,m=Fs(e),v=m.some(y=>y.key===s)?s:m[0].key,u=Bs(e.id,v==="history");return n.jsx("div",{className:"ov-backdrop","data-focus-overlay":!0,onMouseDown:t,children:n.jsxs("div",{className:"ov-panel",onMouseDown:y=>y.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:m.map(y=>n.jsxs("button",{className:y.key===v?"ov-tab on":"ov-tab",onClick:()=>a(y.key),children:[i(sn[y.key]),y.key==="issues"&&(f>0||h>0)&&n.jsxs("span",{className:"ov-tab-counts",children:[f>0&&n.jsx(G,{kind:"issue",state:"open",cls:"st-open",n:f,label:i("nodeView.openIssues",{n:f})}),h>0&&n.jsx(G,{kind:"issue",state:"closed",cls:"st-closed",n:h,label:i("nodeView.closedIssues",{n:h})})]}),y.key==="eval"&&(p>0||d>0)&&n.jsxs("span",{className:"ov-tab-counts",children:[p>0&&n.jsx(G,{kind:"eval",state:"pass",cls:"st-pass",n:p,label:i("nodeView.eval.passCount",{n:p})}),d>0&&n.jsx(G,{kind:"eval",state:"fail",cls:"st-fail",n:d,label:i("nodeView.eval.failCount",{n:d})})]}),y.key==="edit"&&x>0&&n.jsx("span",{className:"ov-tab-counts",children:n.jsx("span",{className:"ovc st-edit","data-tip":i("nodeView.pendingEdits",{n:x}),children:x})})]},y.key))}),n.jsx("span",{className:"ov-hint",children:i("nodeView.hint")})]}),n.jsxs("div",{className:"ov-body",children:[v==="spec"&&n.jsx("div",{className:"pane-solo",children:n.jsx(_s,{node:e})}),v==="history"&&n.jsx(Ws,{node:e,rows:u}),v==="issues"&&n.jsx(Gs,{node:e,sessions:r,filter:l.issues,onFilter:y=>o("issues",y)}),v==="eval"&&n.jsx(en,{node:e,sessions:r,filter:l.eval,onFilter:y=>o("eval",y)}),v==="edit"&&n.jsx(Js,{node:e})]})]})})}const Hn=/\[\[(\.?[\p{L}\p{N}_-]+)\]\]/gu,We=e=>(e||"").replace(/^\.spec\//,"").replace(/\/spec\.md$/,"");function nn(e,s,a){const t=s.toLowerCase(),r=[];for(const i of e){const l=i.id.toLowerCase(),c=We(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 tn(e,s){const a=s.toLowerCase(),t=l=>rs(l)||(l.id||"").slice(0,8),r=l=>{var c,o;return[l==null?void 0:l.title,l==null?void 0:l.label,(c=l==null?void 0:l.raw)==null?void 0:c.name,(o=l==null?void 0:l.raw)==null?void 0:o.title,l==null?void 0:l.activity,l==null?void 0:l.promptPreview,l==null?void 0:l.note].filter(f=>typeof f=="string"&&f.trim()).map(f=>f.toLowerCase())},i=[];for(const l of e||[]){const c=(l.id||"").toLowerCase(),o=r(l);let f;if(!a)f=3;else if(c===a||o.some(h=>h===a))f=0;else if(c.startsWith(a)||o.some(h=>h.startsWith(a)))f=1;else if(c.includes(a)||o.some(h=>h.includes(a)))f=2;else continue;i.push({s:l,score:f})}return i.sort((l,c)=>l.score-c.score||(c.s.created||0)-(l.s.created||0)),i.slice(0,8).map(l=>({id:l.s.id,label:t(l.s),sub:l.s.node||l.s.status}))}function ie(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 Ge(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 Wn(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=Ge(a,r);return i.length?{items:i,index:0,start:t,end:s,query:r}:null}const an=e=>e&&e[0].toUpperCase()+e.slice(1),rn={user:"(user)",project:"(project)",skill:"[skill]","built-in":"built-in",ui:"[ui]",preset:"[preset]",review:"[review]"};function ln({menu:e,up:s,head:a,onPick:t,onHover:r}){const i=A();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,f=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"}${f}`,onMouseDown:h=>{h.preventDefault(),t(l)},onMouseEnter:()=>r(c),children:[n.jsxs("span",{className:l.ui?"slash-name ui":"slash-name",children:["/",ie(l.name,e.query)]}),n.jsx("span",{className:"slash-desc",children:an(l.description??l.desc)}),n.jsx("span",{className:`slash-src src-${o}`,children:rn[o]||o})]},`${o}:${l.name}`)})]})}function cn(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=nn(a,i,t);return l.length?{kind:"mention",items:l,index:0,start:r-1,end:s,query:i}:null}return null}function on(e,s,a){let t=s-1;for(;t>=0&&/[\p{L}\p{N}_.:\-]/u.test(e[t]);)t--;if(t>=0&&e[t]==="@"&&(t===0||/\s/.test(e[t-1]))){const r=e.slice(t+1,s),i=tn(a,r);return i.length?{kind:"session",items:i,index:0,start:t,end:s,query:r}:null}return null}function dn({menu:e,up:s,fixedStyle:a,onPick:t,onHover:r}){const i=A(),l=e.kind==="session",c=e.query?l?`@${e.query}`:`[[${e.query}]]`:i(l?"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:["// ",c," — ",i("session.menuHint")]}),e.items.map((o,f)=>n.jsxs("li",{role:"option","aria-selected":f===e.index,className:f===e.index?"mention-item on":"mention-item",onMouseDown:h=>{h.preventDefault(),t(o)},onMouseEnter:()=>r(f),children:[!l&&n.jsx("span",{className:"mention-dot",style:{background:F[o.status]||F.offline}}),n.jsx("span",{className:"mention-id",children:l?n.jsxs(n.Fragment,{children:["@",ie(o.label,e.query)]}):ie(o.id,e.query)}),n.jsx("span",{className:"mention-path",children:l?o.sub:We(o.path)})]},o.id))]})}function un({inputRef:e,value:s,setValue:a,specs:t=[],sessions:r=[],focusId:i=null,up:l=!1,fixedAbove:c=null}){const[o,f]=w.useState(null),[h,p]=w.useState(null),d=w.useRef(null),x=k=>`${k.value}\0${k.selectionStart}`,m=k=>{var C;if(!k){f(null),p(null);return}const $=x(k);if(d.current===$){f(null),p(null);return}d.current=null;const b=k.selectionStart,E=cn(k.value,b,t,i)||on(k.value,b,r);if(f(E),!E||!c){p(null);return}const I=k.getBoundingClientRect(),y=(C=k.closest(c))==null?void 0:C.getBoundingClientRect(),D=(y==null?void 0:y.top)??I.top;p({left:`${I.left}px`,width:`${I.width}px`,right:"auto",bottom:`${Math.max(8,window.innerHeight-D+8)}px`})},v=k=>f($=>$&&{...$,index:($.index+k+$.items.length)%$.items.length}),u=k=>{if(!k||!o)return;d.current=null;const $=s.slice(0,o.start),b=o.kind==="session"?`@${k.id} `:`[[${k.id}]] `;a($+b+s.slice(o.end)),f(null),p(null);const E=$.length+b.length;requestAnimationFrame(()=>{const I=e.current;I&&(I.focus(),I.setSelectionRange(E,E))})};return{menu:o,sync:m,onKeyDown:k=>o?k.key==="ArrowDown"?(k.preventDefault(),k.stopPropagation(),v(1),!0):k.key==="ArrowUp"?(k.preventDefault(),k.stopPropagation(),v(-1),!0):k.key==="Enter"||k.key==="Tab"?(k.preventDefault(),k.stopPropagation(),u(o.items[o.index]),!0):k.key==="Escape"?(k.preventDefault(),k.stopPropagation(),e.current&&(d.current=x(e.current)),f(null),p(null),!0):!1:!1,close:()=>{d.current=null,f(null),p(null)},menuEl:o?n.jsx(dn,{menu:o,up:l,fixedStyle:h,onPick:u,onHover:k=>f($=>$&&{...$,index:k})}):null}}function fn(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 le({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})}function hn(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 pn(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 mn=w.forwardRef(function({value:s,className:a="",...t},r){const i=w.useRef(null);return w.useImperativeHandle(r,()=>i.current),w.useLayoutEffect(()=>{const l=i.current;if(!l)return;const c=getComputedStyle(l);hn(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 vn({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 xn=/^▶\s*(\d+):([0-5]?\d)(?:\s*·\s*([^\n]*))?/,Se=/^!\[frame\]\(\/api\/(?:evidence|yatsu\/blob)\/[0-9a-f]{64}\)\n?/,jn=/\/api\/(?:evidence|yatsu\/blob)\/([0-9a-f]{64})/g,$e=/!\[[^\]]*\]\(\/api\/(?:evidence|yatsu\/blob)\/([0-9a-f]{64})\)/g,gn=e=>{const s=Math.floor(e/1e3);return`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`};function ce(e){var i;const s=e||"",a=s.split(`
|
|
6
|
+
`,1)[0],t=xn.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 Qe=(e,s)=>`▶${gn(e)}${s?` · ${s}`:""}`,Ee=e=>[...(e||"").matchAll(jn)].map(s=>s[1]);function wn(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:Qe(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 Gn({originator:e,sessions:s=[],kind:a="issue",onOpenSession:t=null}){const r=A();if(!e)return null;const i=as(s,e),l=!!i,c=l?F[i.status]||F.working:F.offline,o=r(a==="eval"?"thread.originatorEval":"thread.originatorIssue",{by:e}),f=n.jsx("span",{className:"fv-originator-dot",style:{background:c},"aria-hidden":"true"});return n.jsx(gs,{text:e,tip:o,label:o,lead:f,className:`fv-originator ${l?"alive":"offline"}${l&&t?" openable":""}`,onClick:l&&t?()=>t(e):null})}function yn({replies:e,onSeek:s,selIdx:a=null,activeIdx:t=null,onSelect:r=null,events:i=null,threadId:l=null,onRemarkChange:c=null}){const o=A(),[f,h]=w.useState(null),[p,d]=w.useState(null),x=async(m,v)=>{if(!f){h(v),d(null);try{const u=await ts(m,v);u!=null&&u.ok?await(c==null?void 0:c()):d({ref:v,msg:(u==null?void 0:u.error)||`${m} failed`})}finally{h(null)}}};return e.map((m,v)=>{const u=ce(m.body),j=wn(u,i),N=u?u.rest:m.body,S=[...N.matchAll($e)].map(D=>D[1]),k=(S.length?N.replace($e,""):N).trim(),$=m.rid!==void 0,b=$?m.resolved?" remark resolved":" remark open":"",E=`fv-reply${a===v?" sel":""}${t===v?" active":""}${b}`,I=j&&j.seekable&&s?()=>r?r(v,j.tMs):s(j.tMs):null,y=$&&l?`${l}#${m.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:m.by}),m.at&&n.jsx("span",{className:"fv-reply-at",children:m.at}),j&&(I?n.jsx("button",{type:"button",className:"fv-anchor",onClick:I,"data-tip":"seek the clip to this moment",children:j.label}):n.jsxs("span",{className:`fv-anchor static${j.degraded?" degraded":""}`,"data-tip":j.degraded?o("thread.anchorDegraded"):void 0,children:[j.label,j.degraded?" ⚠":""]})),$&&(m.resolved?n.jsxs("span",{className:"fv-remark-state resolved","data-tip":m.resolvedBy?o("thread.resolvedBy",{by:m.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")]})),y&&c&&!m.resolved&&(m.by==="human"?n.jsx("button",{type:"button",className:"fv-remark-act retract",disabled:!!f,"data-tip":o("thread.retractTitle"),onClick:()=>x("retract",y),children:o("thread.retract")}):n.jsx("button",{type:"button",className:"fv-remark-act resolve",disabled:!!f,"data-tip":o("thread.resolveTitle"),onClick:()=>x("resolve",y),children:o("thread.resolve")}))]}),p&&p.ref===y&&n.jsx("div",{className:"fv-error",children:p.msg}),k&&n.jsx("div",{className:"fvd-body",children:n.jsx(J,{body:k})}),S.length>0&&n.jsx("div",{className:"fv-reply-media",children:S.map((D,C)=>n.jsx(Me,{hash:D,alt:"evidence"},`${D}-${C}`))})]},v)})}function bn(e,s,a){const t=e.lastIndexOf(`
|
|
7
|
+
`,s-1)+1,r=/^\/(\S*)$/.exec(e.slice(t,s));if(!r)return null;const i=Ge(a,r[1]);return i.length?{items:i,index:0,start:t,end:s,query:r[1]}:null}function Qn({onSend:e,specs:s=[],sessions:a=[],focusId:t=null,onDone:r,anchorNow:i=null,draft:l=null,actionsEnd:c=null,commands:o=null}){const f=A(),[h,p]=w.useState(""),[d,x]=w.useState(!1),[m,v]=w.useState(""),u=w.useRef(null),j=un({inputRef:u,value:h,setValue:p,specs:s,sessions:a,focusId:t,up:!0}),[N,S]=w.useState(null),k=g=>S(g&&(o!=null&&o.length)?bn(g.value,g.selectionStart,o):null),$=g=>{var B;if(!g||!N)return;const L=h.slice(0,N.start)+h.slice(N.end);if(S(null),g.run){p(L.trim()?L:""),g.run();return}const O=ce(L);let q="";if(O){const V=((B=Se.exec(O.rest))==null?void 0:B[0])??"";q=`${O.label}
|
|
8
|
+
${V}`,q.endsWith(`
|
|
9
|
+
`)||(q+=`
|
|
10
|
+
`)}p(q+g.prefill()),requestAnimationFrame(()=>{const V=u.current;V&&(V.focus(),V.setSelectionRange(V.value.length,V.value.length))})},b=g=>N?g.key==="ArrowDown"?(g.preventDefault(),g.stopPropagation(),S(L=>({...L,index:(L.index+1)%L.items.length})),!0):g.key==="ArrowUp"?(g.preventDefault(),g.stopPropagation(),S(L=>({...L,index:(L.index-1+L.items.length)%L.items.length})),!0):g.key==="Enter"||g.key==="Tab"?(g.preventDefault(),g.stopPropagation(),$(N.items[N.index]),!0):g.key==="Escape"?(g.preventDefault(),g.stopPropagation(),S(null),!0):!1:!1,E=Ee(h);w.useEffect(()=>{var g;if(!l){p("");return}p(l.body||""),(g=u.current)==null||g.focus()},[l==null?void 0:l.seq]);const I=async()=>{var O;const g=await(i==null?void 0:i());if(!g)return;const L=Qe(g.tMs,g.step)+(g.frame?`
|
|
11
|
+
`:"");p(q=>{const B=ce(q),V=(B?B.rest:q).replace(Se,"");return V?`${L}
|
|
12
|
+
${V}`:`${L}
|
|
13
|
+
`}),(O=u.current)==null||O.focus()},y=g=>fn(u.current,g,p,L=>{j.sync(L),k(L)}),D=async()=>{const g=h.trim();if(!(!g||d)){x(!0);try{const L=await e(g,Ee(g));L!=null&&L.ok?(p(""),v(""),await(r==null?void 0:r(L.outcomes||""))):v((L==null?void 0:L.error)||"reply failed")}finally{x(!1)}}},C=E.length>0?n.jsx("div",{className:"fv-frames",children:E.map(g=>n.jsx(Me,{hash:g,alt:"frame"},g))}):null,P=n.jsxs("div",{className:"fv-tawrap",children:[n.jsx(mn,{ref:u,className:"fv-textarea",rows:1,value:h,placeholder:f("session.issuesReplyPlaceholder"),disabled:d,onChange:g=>{p(g.target.value),j.sync(g.target),k(g.target)},onSelect:g=>{j.sync(g.target),k(g.target)},onBlur:()=>{j.close(),S(null)},onKeyDown:g=>{pn(g)||b(g)||j.onKeyDown(g)||g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&(g.preventDefault(),D())}}),j.menuEl,N&&n.jsx(ln,{menu:N,up:!0,head:N.query?`/${N.query}`:f("annotator.menuReview"),onPick:$,onHover:g=>S(L=>L&&{...L,index:g})})]}),K=n.jsxs("div",{className:"fv-actions",children:[n.jsx(le,{label:f("thread.mentionActor"),disabled:d,onClick:()=>y("@"),children:"@"}),n.jsx(le,{label:f("thread.mentionNode"),disabled:d,onClick:()=>y("[["),children:"[["}),(o==null?void 0:o.length)>0&&n.jsx(le,{label:f("thread.reviewCommands"),disabled:d,onClick:()=>y("/"),children:"/"}),i&&n.jsxs("button",{type:"button",className:"fv-anchor-btn","data-tip":f("thread.anchorTitle"),onMouseDown:g=>g.preventDefault(),onClick:I,children:[n.jsx(T,{name:"clock",size:11})," ",f("thread.anchorNow")]}),m&&n.jsx("span",{className:"fv-error",children:m}),n.jsxs("div",{className:"fv-actions-end",children:[c,n.jsx(oe,{icon:"send",size:14,className:"fv-send",label:f(d?"session.issuesSending":"session.issuesSend"),disabled:d||!h.trim(),onMouseDown:g=>g.preventDefault(),onClick:D})]})]});return n.jsx(vn,{className:"fv-compose",preview:C,editor:P,footer:K})}export{_n as $,pn as A,fn as B,vn as C,Vn as D,se as E,Cn as F,mn as G,Fs as H,Bs as I,Ln as J,_s as K,Rn as L,Hn as M,Ws as N,Gn as O,Gs as P,en as Q,Tn as R,vs as S,le as T,Js as U,cs as V,fs as W,F as X,As as Y,Ae as Z,$n as _,ue as a,Kn as a0,Is as a1,Cs as a2,An as a3,Ke as a4,zn as a5,Un as a6,En as a7,Dn as a8,ln as a9,dn as aa,G as ab,cn as ac,on as ad,Wn as ae,Ge as af,Qe as b,qe as c,Fn as d,Ve as e,gs as f,Qn as g,qn as h,Pe as i,yn as j,Pn as k,In as l,gn as m,Ie as n,M as o,ce as p,Bn as q,wn as r,rs as s,Ts as t,Te as u,_e as v,On as w,J as x,Mn as y,un as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as E}from"./index-DLVeOHL-.js";const R=1e4,N=2.5*R;function P(e,{deadMs:n=N,setTimeoutImpl:t=setTimeout,clearTimeoutImpl:s=clearTimeout}={}){let o=0;const r=()=>{o&&(s(o),o=0)};return{arm:()=>{r(),o=t(()=>{o=0,e()},n)},disarm:r}}const $=280,k=54;function x(e,n){const t={};e.forEach(r=>{var a;r.parent&&(t[a=r.parent]??(t[a]=[])).push(r.id)});const s={},o=(r,a,p)=>{s[r]={x:a*$,y:p};const i=n.has(r)?t[r]||[]:[];if(!i.length)return;const h=p-(i.length-1)/2*k;i.forEach((y,f)=>o(y,a+1,h+f*k))};return e.filter(r=>!r.parent).forEach((r,a)=>o(r.id,0,a*k)),s}const v=[150,350,600,900];async function l(e,n){const t=typeof e=="string"?E(e):e;for(let s=0;;s++)try{return await fetch(t,n)}catch(o){if(s>=v.length)throw o;await new Promise(r=>setTimeout(r,v[s]))}}let T="";const I=()=>{T=""};async function J(){const e=await l("/api/graph",{cache:"no-store",headers:T?{"If-None-Match":T}:{}});if(e.status===304)return null;if(e.status===401||e.status===403){const s=await e.json().catch(()=>null);return{authRequired:(s==null?void 0:s.reason)||"project-login"}}const n=e.headers.get("etag")||"";return{board:await e.json(),seal:()=>{T=n}}}const S=(e,...n)=>E(`/api/specs/${encodeURIComponent(e)}${n.map(t=>"/"+t).join("")}`);function C({onBoard:e,onLegacyChange:n,onStatus:t}){let s=null,o=!1,r=null,a="";const p=u=>{const{nodes:c=[],sessions:m=[],...w}=u,g=new Map([["meta",w],["nodes#order",c.map(d=>d.id)],["sess#order",m.map(d=>d.id)]]);return c.forEach(d=>g.set("node:"+d.id,d)),m.forEach(d=>g.set("sess:"+d.id,d)),g},i=u=>{const c=(m,w)=>(u.get(w)||[]).map(g=>u.get(m+g));return{...u.get("meta")||{},nodes:c("node:","nodes#order"),sessions:c("sess:","sess#order")}},h=()=>{try{s==null||s.close()}catch{}r=null,a="",j()},y=P(()=>{!s||o||(t==null||t(!1),h(),y.arm(),n==null||n())}),f=()=>y.arm(),j=()=>{if(!o){try{s=new EventSource(E("/api/graph/stream?mode=delta"))}catch{s=null;return}s.addEventListener("graph-full",u=>{f();const{to:c,graph:m}=JSON.parse(u.data);r=p(m),a=c,I(),e(m,{authoritative:!0,tag:c}),t==null||t(!0)}),s.addEventListener("graph-delta",u=>{f();const c=JSON.parse(u.data);if(!r||a!==c.from){h();return}for(const m of c.del||[])r.delete(m);for(const[m,w]of Object.entries(c.set||{}))r.set(m,w);a=c.to,I(),e(i(r),{authoritative:!1,tag:c.to}),t==null||t(!0)}),s.addEventListener("graph-changed",()=>{f(),n==null||n()}),s.addEventListener("error",()=>t==null?void 0:t(!1)),s.addEventListener("ping",f),s.addEventListener("ready",f)}};return j(),t==null||t(!1),f(),()=>{o=!0,y.disarm();try{s==null||s.close()}catch{}}}function A(e,n,t=!1){if(!(e!=null&&e.sessions))return e;const s=new Set(e.sessions.map(a=>a.id));if(t)for(const a of n.keys())s.has(a)||n.delete(a);let o=!1;const r=e.sessions.map(a=>{var f,j;const p=a.evalSummary;if(!p||!Number.isInteger(p.generation)||!p.epoch)return a;const i=n.get(a.id),h=i&&i.epoch!==p.epoch;if(!i||(h?t:p.generation>=i.generation)){const u=((f=i==null?void 0:i.projection)==null?void 0:f.phase)==="ready"&&i.projection.value?{generation:i.projection.generation,revision:i.projection.revision,value:i.projection.value}:(j=i==null?void 0:i.projection)==null?void 0:j.lastKnown,c=h&&!p.value&&!p.lastKnown&&u?{...p,lastKnown:u}:p;return n.set(a.id,{epoch:c.epoch,generation:c.generation,projection:c}),c!==p?(o=!0,{...a,evalSummary:c}):a}return o=!0,{...a,evalSummary:i.projection}});return o?{...e,sessions:r}:e}const F=e=>{var n,t;return{title:((n=e==null?void 0:e.identity)==null?void 0:n.title)||(e==null?void 0:e.project)||"",icon:((t=e==null?void 0:e.identity)==null?void 0:t.icon)||(e==null?void 0:e.projectIcon)||"spexcode"}},O=(e,...n)=>E(`/api/sessions/${encodeURIComponent(e)}${n.map(t=>"/"+t).join("")}`);async function _(e){const n=await l(O(e,"timeline"),{cache:"no-store"});return n.ok?n.json():null}function B(e,n){let t=null,s=!1;const o=()=>{try{t==null||t.close()}catch{}p()},r=P(()=>{s||(o(),r.arm())}),a=i=>{r.arm();try{n(JSON.parse(i.data))}catch{}},p=()=>{if(!s){try{t=new EventSource(O(e,"execution","stream"))}catch{t=null;return}t.addEventListener("execution",a),t.addEventListener("ping",()=>r.arm())}};return p(),r.arm(),()=>{s=!0,r.disarm();try{t==null||t.close()}catch{}}}async function D(e){const n=await l(O(e));return n.ok?n.json():null}async function G(e,n,{replyVia:t}={}){const s=await l(O(e,"input"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"text",text:n,...t?{replyVia:t}:{}})}),o=await s.json().catch(()=>({}));return{ok:s.ok&&(o==null?void 0:o.ok)!==!1,error:o==null?void 0:o.error}}async function K(){return(await l("/api/plugins")).json()}async function M(){return(await l("/api/plugins?surface=review")).json()}async function q(){return(await l("/api/settings")).json()}async function X(e){const n=await l(`/api/issues/${encodeURIComponent(e)}`);if(n.status===404)return!1;if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.json()}async function Y(e,n,t){return(await l(`/api/issues/${encodeURIComponent(e)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:n,...t!=null&&t.length?{evidence:t}:{}})})).json()}async function z(e){return(await l(`/api/issues/${encodeURIComponent(e)}/close`,{method:"POST"})).json()}async function H(e){return(await l(`/api/issues/${encodeURIComponent(e)}/promote`,{method:"POST"})).json()}async function L(e,n){return(await l(`/api/remarks/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ref:n})})).json()}async function Q({concern:e,body:n,evidence:t,store:s}){return(await l("/api/issues",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({concern:e,body:n,store:s,...t!=null&&t.length?{evidence:t}:{}})})).json()}async function V({node:e,scenario:n,issue:t,body:s,codeSha:o,evidence:r}){return(await l("/api/remarks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({node:e,scenario:n,issue:t,body:s,...o?{codeSha:o}:{},...r!=null&&r.length?{evidence:r}:{}})})).json()}async function W(e,n){return(await l(`/api/specs/${encodeURIComponent(e)}/evals/ok`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scenario:n})})).json()}async function Z(e){return(await l("/api/evidence",{method:"POST",headers:{"Content-Type":"image/png"},body:e})).json()}export{$ as X,k as Y,A as a,M as b,Z as c,V as d,W as e,H as f,z as g,Y as h,X as i,Q as j,x as k,J as l,l as m,S as n,L as o,F as p,P as q,q as r,C as s,B as t,_ as u,D as v,G as w,K as x};
|