spexcode 0.2.5 → 0.2.6

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 (36) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/spec-cli/hooks/dispatch.sh +28 -40
  4. package/spec-cli/hooks/harness.sh +29 -19
  5. package/spec-cli/src/cli.ts +21 -11
  6. package/spec-cli/src/commit-surgery.ts +81 -0
  7. package/spec-cli/src/contract-filter.ts +16 -14
  8. package/spec-cli/src/doctor.ts +11 -5
  9. package/spec-cli/src/guide.ts +61 -58
  10. package/spec-cli/src/harness-select.ts +2 -2
  11. package/spec-cli/src/harness.ts +5 -5
  12. package/spec-cli/src/help.ts +20 -17
  13. package/spec-cli/src/init.ts +5 -40
  14. package/spec-cli/src/layout.ts +26 -20
  15. package/spec-cli/src/materialize.ts +102 -126
  16. package/spec-cli/src/mentions.ts +5 -3
  17. package/spec-cli/src/plugin-harness.ts +10 -9
  18. package/spec-cli/src/sessions.ts +22 -13
  19. package/spec-cli/src/specs.ts +9 -4
  20. package/spec-cli/src/uninstall.ts +6 -5
  21. package/spec-cli/src/worktree-sources.ts +6 -4
  22. package/spec-cli/templates/hooks/post-checkout +22 -0
  23. package/spec-cli/templates/hooks/post-merge +15 -9
  24. package/spec-cli/templates/hooks/pre-commit +10 -0
  25. package/spec-cli/templates/spec/project/.config/distill/digest.mjs +136 -0
  26. package/spec-cli/templates/spec/project/.config/distill/spec.md +74 -0
  27. package/spec-dashboard/dist/assets/{Dashboard-CMRJGfYI.js → Dashboard-BlRRsxE7.js} +7 -7
  28. package/spec-dashboard/dist/assets/{EvalsPage-Dj2mxcfW.js → EvalsPage-BzVE38-Z.js} +1 -1
  29. package/spec-dashboard/dist/assets/{FoldToggle-BfNpeyRQ.js → FoldToggle-DFuLVOeu.js} +1 -1
  30. package/spec-dashboard/dist/assets/{IssuesPage-DfY315kt.js → IssuesPage-CzDaazhe.js} +1 -1
  31. package/spec-dashboard/dist/assets/{MobileApp-BGdC0A0P.js → MobileApp-CXQrQCNp.js} +1 -1
  32. package/spec-dashboard/dist/assets/{SessionInterface-BOBCAR0t.js → SessionInterface-D1pUBl6q.js} +8 -8
  33. package/spec-dashboard/dist/assets/{SessionWindow-D7YmjV0i.js → SessionWindow-Y25Bwg1e.js} +5 -5
  34. package/spec-dashboard/dist/assets/{Settings-BlSNmpH_.js → Settings-R610Vbzd.js} +1 -1
  35. package/spec-dashboard/dist/assets/{index-BFdzpd_O.js → index-BO0Zuweu.js} +2 -2
  36. package/spec-dashboard/dist/index.html +1 -1
@@ -1,9 +1,9 @@
1
- import{j as s,u as b,r as f,p as Ee,s as z}from"./index-BFdzpd_O.js";function ue(e){let n=2166136261;for(let a=0;a<(e||"").length;a++)n^=e.charCodeAt(a),n=Math.imul(n,16777619);return n>>>0}function he(e){return ue(e)%360}function Me(e){const n=he(e);return{bg:`hsl(${n} 55% 42%)`,fg:`hsl(${n} 70% 92%)`}}function Ce(e){return`hsl(${he(e)} 65% 50%)`}const Q=["◆","▲","●","■","★","✦","⬟","⬢","❖","◈","✸","⟡","✚","❂","◐","◑","⬣","▰","✶","⬤","✹","◇","⊛","✺"],X=["circle","rounded","square","hex"];function Ve(e){const n=ue(e);return{seed:e,glyph:Q[(n>>>9)%Q.length],shape:X[(n>>>17)%X.length],...Me(e)}}function Le({seed:e,status:n,title:a,size:t=16}){const l=Ve(e),i={width:t,height:t};return s.jsx("span",{className:`avatar av-st-${n||"none"}`,"data-tip":a,"aria-label":a,style:i,children:s.jsx("span",{className:`av-face av-gen av-${l.shape}`,style:{...i,background:l.bg,color:l.fg,fontSize:t*.62},children:l.glyph})})}function Ae(e){var n,a;return((n=e==null?void 0:e.verdict)==null?void 0:n.status)==="pass"?"check":((a=e==null?void 0:e.verdict)==null?void 0:a.status)==="fail"?"cross":null}const Fe={pass:"✓",fail:"✗",stalePass:"✓",staleFail:"✗",empty:""};function pe(e){const n=Ae(e);return n?e.fresh?n==="cross"?"fail":"pass":n==="cross"?"staleFail":"stalePass":"empty"}function Z(e,n){if(!e)return[];const a=new Map;for(const t of n||[])a.has(t.scenario)||a.set(t.scenario,t);return e.map(t=>{const l=a.get(t.name)||null;return{...t,reading:l,state:l?pe(l):"missing"}})}function De(e){return e.length?e.some(n=>n.state==="fail")?"fail":e.some(n=>n.state==="staleFail")?"staleFail":e.some(n=>n.state==="stalePass")?"stalePass":e.some(n=>n.state==="empty"||n.state==="missing")?"empty":"pass":null}function Ie({scenarios:e,evals:n}){const a=b(),t=Z(e,n);if(!t.length)return null;const l=De(t),i=t.filter(r=>r.state==="pass").length,c=t.length,o=a("score.count",{satisfied:i,total:c,outstanding:c-i});return s.jsxs("span",{className:`scenario-count ${l}`,"data-tip":o,"aria-label":o,children:["✓",i,"/",c]})}function Pe({tags:e}){return e!=null&&e.length?s.jsx("span",{className:"tag-chips",children:e.map(n=>s.jsx("span",{className:"tag-chip",children:n},n))}):null}function Y({state:e,title:n}){const a=b();if(!e)return null;const t=n??a(`score.${e}`);return s.jsx("span",{className:`score-badge ${e}`,"data-tip":t,"aria-label":t,children:Fe[e]})}const zs={merged:{color:"#859900"},active:{color:"#cb4b16"},drift:{color:"#b58900"},pending:{color:"#93a1a1"}},He={added:"+",edited:"~",deleted:"✕",moved:"→"},M={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)"},Te={working:"●",parked:"‖",asking:"?",review:"◑",done:"✓",error:"✕",idle:"·",starting:"◌",queued:"⋯","close-pending":"⊘",offline:"○",unknown:"⁇"},fe=new Set(["asking","review","done","close-pending","error"]),B=e=>(e==null?void 0:e.liveness)==="offline"||(e==null?void 0:e.status)==="offline"?"offline":fe.has(e==null?void 0:e.status)?"need":"run",me=(e,n)=>{const a=n?(e||[]).find(t=>t.id===n):null;return a&&B(a)!=="offline"?a:null},ee=e=>(e==null?void 0:e.sortKey)!=null?e.sortKey:(e==null?void 0:e.created)??0,se=e=>{const n={need:0,run:1,offline:2};return[...e].sort((a,t)=>n[B(a)]-n[B(t)]||ee(t)-ee(a))},Be=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),xe=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 Re(e){const n=new Set(e.map(l=>l==null?void 0:l.id)),a=new Map,t=[];for(const l of e){const i=l!=null&&l.parent&&l.parent!==l.id&&n.has(l.parent)?l.parent:null;if(i){const c=a.get(i)||[];c.push(l),a.set(i,c)}else t.push(l)}return{roots:t,childrenOf:a}}function ze(e,n){let a=!1,t=!1,l=0;const i=(c,o)=>{for(const r of n.get(c)||[])o.has(r.id)||(o.add(r.id),l++,fe.has(r.status)?a=!0:M[r.status]===M.working&&(t=!0),i(r.id,o))};return i(e,new Set([e])),{color:a?M.asking:t?M.working:M.idle,count:l}}function Oe(e,n){const{roots:a,childrenOf:t}=Re(e),l=[],i=(r,u,p,N)=>{const x=t.get(r.id)||[],k=x.length>0,y=k&&!!n(r.id),m=k?ze(r.id,t):null;if(l.push({type:"row",s:r,depth:u,expandable:k,expanded:y,rollup:(m==null?void 0:m.color)??null,kin:(m==null?void 0:m.count)??0,guides:N}),y){const v=se(x).filter(d=>!p.has(d.id));v.forEach((d,h)=>{p.add(d.id),i(d,u+1,p,[...N,h<v.length-1])})}},c=new Set;let o=null;for(const r of se(a)){if(c.has(r.id))continue;c.add(r.id);const u=B(r);u!==o&&(l.push({type:"zone",zone:u}),o=u),i(r,0,c,[])}return l}function Ke({value:e,onChange:n,options:a}){return s.jsx("select",{className:"fv-filter",value:e,onChange:t=>n(t.target.value),children:a.map(t=>s.jsx("option",{value:t.value,children:t.label},t.value))})}const We={video:"vid",image:"img",transcript:"txt",data:"data"},ve=e=>{var n;return(n=e.evidence)!=null&&n.length?e.evidence:e.blob!=null?[{hash:e.blob,kind:e.blobKind||"image",state:e.blobState||"present"}]:[]},T=e=>{const n=ve(e);return n.length?["video","image","transcript","data"].filter(a=>n.some(t=>t.kind===a)):["note"]};function qe(e){var a;const n=[];for(const t of e)if((a=t.evals)!=null&&a.length)for(const l of Z(t.scenarios,t.evals))l.reading&&n.push({...l.reading,expected:l.expected??l.reading.expected,state:l.state,node:t.id,hue:t.hue});return n.sort((t,l)=>t.ts<l.ts?1:-1),n}const F=e=>`eval:${e.node}·${e.scenario}`;function _e({e,selected:n,onClick:a}){return s.jsxs("button",{className:`ef-row ${n?"sel":""}`,onClick:a,children:[s.jsx(Y,{state:e.state}),e.inSession&&s.jsx("span",{className:"ef-insession","data-tip":"measured by this session",children:"✦"}),s.jsx("span",{className:"ef-scenario","data-tip":e.scenario,children:e.scenario}),s.jsx("span",{className:"ef-node",style:{color:`hsl(${e.hue??210} 60% 70%)`},children:e.node}),s.jsx("span",{className:"ef-kind",children:T(e).map(t=>We[t]).filter(Boolean).join("·")}),s.jsx("span",{className:"ef-time",children:Ue(e.ts)})]})}const Ue=e=>{const n=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return n<3600?`${Math.max(1,Math.floor(n/60))}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`};function Os({nodes:e=[],sessions:n=[],sel:a,onSel:t,onRows:l,mustShow:i=null,lead:c=null}){const o=b(),[r,u]=f.useState(null),[p,N]=f.useState(!1),x=f.useMemo(()=>qe(e),[e]),k=x.some(w=>T(w).includes("video")),y=x.some(w=>T(w).includes("image")),m=r??(k?"video":y?"image":"all"),v=f.useMemo(()=>x.filter(w=>m==="all"||T(w).includes(m)),[x,m]),d=w=>!!me(n,w.by),h=f.useMemo(()=>v.filter(d).length,[v,n]),g=f.useMemo(()=>p?v.filter(d):v,[v,p,n]);return f.useEffect(()=>{l==null||l(g)},[g,l]),f.useEffect(()=>{i&&(g.some(w=>F(w)===i)||x.some(w=>F(w)===i)&&(u("all"),N(!1)))},[i,g,x]),s.jsxs("section",{className:"fv-group",children:[s.jsxs("header",{className:"fv-group-head",children:[s.jsxs("span",{className:"fv-head-row",children:[c,s.jsx(Ke,{value:m,onChange:u,options:["video","image","all"].map(w=>({value:w,label:o(`evalsFeed.kind.${w}`)}))})]}),(p||h>0)&&s.jsx("span",{className:"ef-chipbar",children:s.jsx("button",{type:"button",className:`ef-chip fv-live ${p?"on":""}`,onClick:()=>N(w=>!w),"data-tip":o("masterList.liveChipTitle"),children:o("masterList.liveChip",{n:h})})})]}),g.length===0&&s.jsx("div",{className:"ef-empty",children:o("evalsFeed.empty")}),g.map(w=>s.jsx(_e,{e:w,selected:a===F(w),onClick:()=>t(F(w),w)},F(w)))]})}const Ge={plus:{node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 12h14"}),s.jsx("path",{d:"M12 5v14"})]})},x:{node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M18 6 6 18"}),s.jsx("path",{d:"m6 6 12 12"})]})},"chevron-left":{node:s.jsx("path",{d:"m15 18-6-6 6-6"}),sw:2},"chevron-right":{node:s.jsx("path",{d:"m9 18 6-6-6-6"}),sw:2},download:{node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 15V3"}),s.jsx("path",{d:"m7 10 5 5 5-5"}),s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})},clock:{node:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 6v6l4 2"})]})},search:{node:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("path",{d:"m21 21-4.3-4.3"})]})},play:{node:s.jsx("path",{d:"M6 3.5 19.5 12 6 20.5Z"})},pause:{node:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),s.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})},"panel-left":{sw:2,node:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"1",y:"2",width:"22",height:"20",rx:"4"}),s.jsx("rect",{x:"4",y:"5",width:"2",height:"14",rx:"2",fill:"currentColor",stroke:"none"})]})},settings:{node:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})},graph:{vb:18,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"1.5",y:"6.5",width:"5",height:"4.4",rx:"1"}),s.jsx("rect",{x:"11.5",y:"1.8",width:"5",height:"4.4",rx:"1"}),s.jsx("rect",{x:"11.5",y:"11.8",width:"5",height:"4.4",rx:"1"}),s.jsx("path",{d:"M6.5 8.7 h2.2 M11.5 4 h-1.3 q-1.5 0-1.5 1.5 v7 q0 1.5 1.5 1.5 h1.3"})]})},sessions:{vb:18,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"1.5",y:"2.5",width:"15",height:"13",rx:"1.6"}),s.jsx("path",{d:"M4.6 6.5 l2.6 2.3 -2.6 2.3 M9 12.4 h4"})]})},evals:{vb:18,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.5 15.5 v-11"}),s.jsx("path",{d:"M2.5 15.5 h13"}),s.jsx("rect",{x:"4.6",y:"10",width:"2.6",height:"3.5",rx:"0.5"}),s.jsx("rect",{x:"8.7",y:"7",width:"2.6",height:"6.5",rx:"0.5"}),s.jsx("path",{d:"M13 6 l1.4 1.4 L16.5 3.6"})]})},issues:{vb:18,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.5 3.5 h13 v8.4 h-7 l-3.6 3 v-3 h-2.4 z"}),s.jsx("path",{d:"M5.4 6.7 h7.2 M5.4 9.2 h4.8"})]})},lock:{vb:16,sw:1.3,node:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1.2"}),s.jsx("path",{d:"M5.5 7 V5 a2.5 2.5 0 0 1 5 0 V7"})]})},paperclip:{vb:16,sw:1.3,node:s.jsx("path",{d:"M12.5 7.2 L7 12.6 a2.6 2.6 0 0 1-3.7-3.7 L9 3.2 a1.7 1.7 0 0 1 2.4 2.4 L5.8 11.2 a0.8 0.8 0 0 1-1.2-1.2 L9.7 5"})},loader:{vb:16,sw:1.5,node:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"8",cy:"8",r:"5.5",opacity:"0.3"}),s.jsx("path",{d:"M8 2.5 a5.5 5.5 0 0 1 5.5 5.5"})]})},maximize:{vb:16,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2 6V2h4"}),s.jsx("path",{d:"M14 6V2h-4"}),s.jsx("path",{d:"M2 10v4h4"}),s.jsx("path",{d:"M14 10v4h-4"})]})},minimize:{vb:16,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6 2v4H2"}),s.jsx("path",{d:"M10 2v4h4"}),s.jsx("path",{d:"M6 14v-4H2"}),s.jsx("path",{d:"M10 14v-4h4"})]})}};function O({name:e,size:n=16,strokeWidth:a,className:t,style:l}){const i=Ge[e];if(!i)throw new Error(`unknown icon: ${e}`);const c=i.vb||24;return s.jsx("svg",{width:n,height:n,viewBox:`0 0 ${c} ${c}`,fill:"none",stroke:"currentColor",strokeWidth:a??i.sw??1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:t,style:l,children:i.node})}function Ks({icon:e,label:n,onClick:a,className:t,size:l,iconClassName:i,...c}){return s.jsx("button",{type:"button",className:t,"data-tip":n,"aria-label":n,onClick:a,...c,children:s.jsx(O,{name:e,size:l,className:i})})}const Ws=()=>s.jsx("svg",{className:"si-agent-glyph",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"})}),qs=()=>s.jsx("svg",{className:"si-agent-glyph",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M22.282 9.821a6 6 0 0 0-.516-4.91a6.05 6.05 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a6 6 0 0 0-3.998 2.9a6.05 6.05 0 0 0 .743 7.097a5.98 5.98 0 0 0 .51 4.911a6.05 6.05 0 0 0 6.515 2.9A6 6 0 0 0 13.26 24a6.06 6.06 0 0 0 5.772-4.206a6 6 0 0 0 3.997-2.9a6.06 6.06 0 0 0-.747-7.073M13.26 22.43a4.48 4.48 0 0 1-2.876-1.04l.141-.081l4.779-2.758a.8.8 0 0 0 .392-.681v-6.737l2.02 1.168a.07.07 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494M3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085l4.783 2.759a.77.77 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646M2.34 7.896a4.5 4.5 0 0 1 2.366-1.973V11.6a.77.77 0 0 0 .388.677l5.815 3.354l-2.02 1.168a.08.08 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.08.08 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667m2.01-3.023l-.141-.085l-4.774-2.782a.78.78 0 0 0-.785 0L9.409 9.23V6.897a.07.07 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.8.8 0 0 0-.393.681zm1.097-2.365l2.602-1.5l2.607 1.5v2.999l-2.597 1.5l-2.607-1.5Z"})}),A=e=>`/api/yatsu/blob/${e}`;function Ze({src:e,alt:n,onClose:a}){return f.useEffect(()=>{const t=l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),a())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[a]),s.jsx("div",{className:"lightbox",onClick:a,children:s.jsx("img",{src:e,alt:n})})}function Ye({hash:e}){const n=b(),[a,t]=f.useState(null);return f.useEffect(()=>{let l=!0;return fetch(A(e)).then(i=>i.ok?i.text():Promise.reject(new Error("miss"))).then(i=>{l&&t(i)}).catch(()=>{l&&t("")}),()=>{l=!1}},[e]),a===null?s.jsx("pre",{className:"eval-transcript loading",children:n("nodeView.eval.loadingTranscript")}):s.jsx("pre",{className:"eval-transcript",children:a})}function Je({hash:e}){const n=b(),[a,t]=f.useState(null);return f.useEffect(()=>{let l=!0;return fetch(A(e)).then(i=>i.ok?i.text():Promise.reject(new Error("miss"))).then(i=>{let c=i,o=!0;try{c=JSON.stringify(JSON.parse(i),null,2)}catch{o=!1}l&&t({text:c,valid:o})}).catch(()=>{l&&t({text:"",valid:!1})}),()=>{l=!1}},[e]),a===null?s.jsx("pre",{className:"eval-data loading",children:n("nodeView.eval.loadingData")}):s.jsxs("div",{className:"eval-datawrap",children:[s.jsx("div",{className:"eval-datahead",children:a.valid?n("nodeView.eval.data"):n("nodeView.eval.dataInvalid")}),s.jsx("pre",{className:"eval-data",children:a.text})]})}function Qe({hash:e,alt:n}){const[a,t]=f.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx("img",{className:"an-image",src:A(e),alt:n,loading:"lazy",onClick:()=>t(!0)}),a&&s.jsx(Ze,{src:A(e),alt:n,onClose:()=>t(!1)})]})}function Xe({exit:e}){return s.jsx(O,{name:e?"minimize":"maximize",size:15})}function _s({target:e,className:n=""}){const a=b(),[t,l]=f.useState(!1);f.useEffect(()=>{const c=()=>{const o=document.fullscreenElement,r=e==null?void 0:e.current;l(!!o&&!!r&&(o===r||r.contains(o)))};return document.addEventListener("fullscreenchange",c),()=>document.removeEventListener("fullscreenchange",c)},[e]);const i=()=>{var o,r;const c=e==null?void 0:e.current;c&&(document.fullscreenElement?(o=document.exitFullscreen||document.webkitExitFullscreen)==null||o.call(document):(r=c.requestFullscreen||c.webkitRequestFullscreen)==null||r.call(c))};return s.jsx("button",{type:"button",className:`an-fs ${n}`,onClick:i,"data-tip":a(t?"annotator.exitFullscreen":"annotator.fullscreen"),"aria-label":a(t?"annotator.exitFullscreen":"annotator.fullscreen"),children:s.jsx(Xe,{exit:t})})}function ge({e,alt:n=""}){const a=b();return e.state==="miss"?s.jsx("div",{className:"eval-noimg",children:a("nodeView.eval.miss")}):e.kind==="transcript"?s.jsx(Ye,{hash:e.hash}):e.kind==="data"?s.jsx(Je,{hash:e.hash}):e.kind==="video"?s.jsx("video",{className:"eval-video",src:A(e.hash),controls:!0,preload:"metadata",playsInline:!0}):s.jsx(Qe,{hash:e.hash,alt:n})}const P=new Map;function es(e){const[n,a]=f.useState(()=>P.get(e)??null);return f.useEffect(()=>{if(P.has(e)){a(P.get(e));return}let t=!0;return fetch(A(e),{headers:{Range:"bytes=0-0"}}).then(l=>{const i=l.headers.get("content-type")||"",c=l.ok?{kind:i.startsWith("video/")?"video":i.startsWith("image/")?"image":i.startsWith("application/json")?"data":"transcript",state:"present"}:{kind:"image",state:"miss"};P.set(e,c),t&&a(c)}).catch(()=>{t&&a({kind:"image",state:"miss"})}),()=>{t=!1}},[e]),n}function je({hash:e,alt:n=""}){const a=es(e);return a?s.jsx(ge,{e:{hash:e,...a},alt:n}):null}const Us=/\[\[(\.?[A-Za-z0-9_-]+)\]\]/g,we=e=>(e||"").replace(/^\.spec\//,"").replace(/\/spec\.md$/,"");function ss(e,n,a){const t=n.toLowerCase(),l=[];for(const i of e){const c=i.id.toLowerCase(),o=we(i.path).toLowerCase();let r;if(!t)r=3;else if(c.startsWith(t))r=0;else if(c.includes(t))r=1;else if(o.includes(t))r=2;else continue;i.id===a&&(r=-1),l.push({s:i,score:r})}return l.sort((i,c)=>i.score-c.score||i.s.id.length-c.s.id.length||i.s.id.localeCompare(c.s.id)),l.slice(0,8).map(i=>i.s)}function ns(e,n){const a=n.toLowerCase(),t=o=>xe(o)||(o.id||"").slice(0,8),l=[];for(const o of e||[]){if(o.liveness!=="online")continue;const r=(o.id||"").toLowerCase(),u=t(o).toLowerCase();let p;if(!a)p=3;else if(r===a||u===a)p=0;else if(r.startsWith(a)||u.startsWith(a))p=1;else if(r.includes(a)||u.includes(a))p=2;else continue;l.push({s:o,score:p})}l.sort((o,r)=>o.score-r.score||(r.s.created||0)-(o.s.created||0));const i=l.map(o=>({id:o.s.id,label:t(o.s),sub:o.s.node||o.s.status})),c=l.filter(o=>o.score===0).length;return i.splice(c,0,{id:"new",label:"new",sub:"spawn a fresh worker"}),i.slice(0,8)}function ne(e,n){if(!n)return e;const a=e.toLowerCase().indexOf(n.toLowerCase());return a<0?e:s.jsxs(s.Fragment,{children:[e.slice(0,a),s.jsx("b",{className:"mention-hit",children:e.slice(a,a+n.length)}),e.slice(a+n.length)]})}function ts(e,n,a,t){let l=n-1;for(;l>=0&&/[A-Za-z0-9_.\-]/.test(e[l]);)l--;if(l>=1&&e[l-1]==="["&&e[l]==="["){const i=e.slice(l+1,n),c=ss(a,i,t);return c.length?{kind:"mention",items:c,index:0,start:l-1,end:n,query:i}:null}return null}function as(e,n,a){let t=n-1;for(;t>=0&&/[A-Za-z0-9_.\-]/.test(e[t]);)t--;if(t>=0&&e[t]==="@"&&(t===0||/\s/.test(e[t-1]))){const l=e.slice(t+1,n),i=ns(a,l);return i.length?{kind:"actor",items:i,index:0,start:t,end:n,query:l}:null}return null}function ls({menu:e,up:n,fixedStyle:a,onPick:t,onHover:l}){const i=b(),c=e.kind==="actor",o=e.query?c?`@${e.query}`:`[[${e.query}]]`:i(c?"session.menuSessions":"session.menuSpecNodes");return s.jsxs("ul",{className:`${n?"mention-menu up":"mention-menu"}${a?" fixed":""}`,style:a||void 0,role:"listbox",children:[s.jsxs("li",{className:"mention-head",children:["// ",o," — ",i("session.menuHint")]}),e.items.map((r,u)=>s.jsxs("li",{role:"option","aria-selected":u===e.index,className:`${u===e.index?"mention-item on":"mention-item"}${c&&r.id==="new"?" new":""}`,onMouseDown:p=>{p.preventDefault(),t(r)},onMouseEnter:()=>l(u),children:[!c&&s.jsx("span",{className:"mention-dot",style:{background:M[r.status]||M.offline}}),s.jsx("span",{className:"mention-id",children:c?s.jsxs(s.Fragment,{children:["@",ne(r.label,e.query)]}):ne(r.id,e.query)}),s.jsx("span",{className:"mention-path",children:c?r.sub:we(r.path)})]},r.id))]})}function is({inputRef:e,value:n,setValue:a,specs:t=[],sessions:l=[],focusId:i=null,up:c=!1,fixedAbove:o=null}){const[r,u]=f.useState(null),[p,N]=f.useState(null),x=h=>{var $;if(!h){u(null),N(null);return}const g=h.selectionStart,w=ts(h.value,g,t,i)||as(h.value,g,l);if(u(w),!w||!o){N(null);return}const S=h.getBoundingClientRect(),E=($=h.closest(o))==null?void 0:$.getBoundingClientRect(),j=(E==null?void 0:E.top)??S.top;N({left:`${S.left}px`,width:`${S.width}px`,right:"auto",bottom:`${Math.max(8,window.innerHeight-j+8)}px`})},k=h=>u(g=>g&&{...g,index:(g.index+h+g.items.length)%g.items.length}),y=h=>{if(!h||!r)return;const g=r.kind==="actor"?`@${h.id} `:`[[${h.id}]] `,w=n.slice(0,r.start);a(w+g+n.slice(r.end)),u(null),N(null);const S=w.length+g.length;requestAnimationFrame(()=>{const E=e.current;E&&(E.focus(),E.setSelectionRange(S,S))})};return{menu:r,sync:x,onKeyDown:h=>r?h.key==="ArrowDown"?(h.preventDefault(),h.stopPropagation(),k(1),!0):h.key==="ArrowUp"?(h.preventDefault(),h.stopPropagation(),k(-1),!0):h.key==="Enter"||h.key==="Tab"?(h.preventDefault(),h.stopPropagation(),y(r.items[r.index]),!0):h.key==="Escape"?(h.preventDefault(),h.stopPropagation(),u(null),N(null),!0):!1:!1,close:()=>{u(null),N(null)},menuEl:r?s.jsx(ls,{menu:r,up:c,fixedStyle:p,onPick:y,onHover:h=>u(g=>g&&{...g,index:h})}):null}}function rs(e,n,a=0){e&&(e.style.height="auto",e.style.overflowY=e.scrollHeight>n?"auto":"hidden",e.style.height=`${Math.min(Math.max(e.scrollHeight,a),n)}px`)}const cs=/^▶\s*(\d+):([0-5]?\d)(?:\s*·\s*([^\n]*))?/,os=/^!\[frame\]\(\/api\/yatsu\/blob\/[0-9a-f]{64}\)\n?/,ds=/\/api\/yatsu\/blob\/([0-9a-f]{64})/g,te=/!\[[^\]]*\]\(\/api\/yatsu\/blob\/([0-9a-f]{64})\)/g,us=e=>{const n=Math.floor(e/1e3);return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`};function ye(e){var i;const n=e||"",a=n.split(`
1
+ import{j as s,u as b,r as f,p as Ee,s as O}from"./index-BO0Zuweu.js";function ue(e){let n=2166136261;for(let a=0;a<(e||"").length;a++)n^=e.charCodeAt(a),n=Math.imul(n,16777619);return n>>>0}function he(e){return ue(e)%360}function Me(e){const n=he(e);return{bg:`hsl(${n} 55% 42%)`,fg:`hsl(${n} 70% 92%)`}}function Ce(e){return`hsl(${he(e)} 65% 50%)`}const Q=["◆","▲","●","■","★","✦","⬟","⬢","❖","◈","✸","⟡","✚","❂","◐","◑","⬣","▰","✶","⬤","✹","◇","⊛","✺"],X=["circle","rounded","square","hex"];function Ve(e){const n=ue(e);return{seed:e,glyph:Q[(n>>>9)%Q.length],shape:X[(n>>>17)%X.length],...Me(e)}}function Le({seed:e,status:n,title:a,size:t=16}){const l=Ve(e),i={width:t,height:t};return s.jsx("span",{className:`avatar av-st-${n||"none"}`,"data-tip":a,"aria-label":a,style:i,children:s.jsx("span",{className:`av-face av-gen av-${l.shape}`,style:{...i,background:l.bg,color:l.fg,fontSize:t*.62},children:l.glyph})})}function Fe(e){var n,a;return((n=e==null?void 0:e.verdict)==null?void 0:n.status)==="pass"?"check":((a=e==null?void 0:e.verdict)==null?void 0:a.status)==="fail"?"cross":null}const Ae={pass:"✓",fail:"✗",stalePass:"✓",staleFail:"✗",empty:""};function pe(e){const n=Fe(e);return n?e.fresh?n==="cross"?"fail":"pass":n==="cross"?"staleFail":"stalePass":"empty"}function Z(e,n){if(!e)return[];const a=new Map;for(const t of n||[])a.has(t.scenario)||a.set(t.scenario,t);return e.map(t=>{const l=a.get(t.name)||null;return{...t,reading:l,state:l?pe(l):"missing"}})}function De(e){return e.length?e.some(n=>n.state==="fail")?"fail":e.some(n=>n.state==="staleFail")?"staleFail":e.some(n=>n.state==="stalePass")?"stalePass":e.some(n=>n.state==="empty"||n.state==="missing")?"empty":"pass":null}function Ie({scenarios:e,evals:n}){const a=b(),t=Z(e,n);if(!t.length)return null;const l=De(t),i=t.filter(r=>r.state==="pass").length,c=t.length,o=a("score.count",{satisfied:i,total:c,outstanding:c-i});return s.jsxs("span",{className:`scenario-count ${l}`,"data-tip":o,"aria-label":o,children:["✓",i,"/",c]})}function Pe({tags:e}){return e!=null&&e.length?s.jsx("span",{className:"tag-chips",children:e.map(n=>s.jsx("span",{className:"tag-chip",children:n},n))}):null}function Y({state:e,title:n}){const a=b();if(!e)return null;const t=n??a(`score.${e}`);return s.jsx("span",{className:`score-badge ${e}`,"data-tip":t,"aria-label":t,children:Ae[e]})}const Os={merged:{color:"#859900"},active:{color:"#cb4b16"},drift:{color:"#b58900"},pending:{color:"#93a1a1"}},He={added:"+",edited:"~",deleted:"✕",moved:"→"},M={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)"},Te={working:"●",parked:"‖",asking:"?",review:"◑",done:"✓",error:"✕",idle:"·",starting:"◌",queued:"⋯","close-pending":"⊘",offline:"○",unknown:"⁇"},fe=new Set(["asking","review","done","close-pending","error"]),B=e=>(e==null?void 0:e.liveness)==="offline"||(e==null?void 0:e.status)==="offline"?"offline":fe.has(e==null?void 0:e.status)?"need":"run",me=(e,n)=>{const a=n?(e||[]).find(t=>t.id===n):null;return a&&B(a)!=="offline"?a:null},ee=e=>(e==null?void 0:e.sortKey)!=null?e.sortKey:(e==null?void 0:e.created)??0,se=e=>{const n={need:0,run:1,offline:2};return[...e].sort((a,t)=>n[B(a)]-n[B(t)]||ee(t)-ee(a))},Be=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),xe=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 Re(e){const n=new Set(e.map(l=>l==null?void 0:l.id)),a=new Map,t=[];for(const l of e){const i=l!=null&&l.parent&&l.parent!==l.id&&n.has(l.parent)?l.parent:null;if(i){const c=a.get(i)||[];c.push(l),a.set(i,c)}else t.push(l)}return{roots:t,childrenOf:a}}function Oe(e,n){let a=!1,t=!1,l=0;const i=(c,o)=>{for(const r of n.get(c)||[])o.has(r.id)||(o.add(r.id),l++,fe.has(r.status)?a=!0:M[r.status]===M.working&&(t=!0),i(r.id,o))};return i(e,new Set([e])),{color:a?M.asking:t?M.working:M.idle,count:l}}function ze(e,n){const{roots:a,childrenOf:t}=Re(e),l=[],i=(r,u,p,N)=>{const x=t.get(r.id)||[],k=x.length>0,y=k&&!!n(r.id),m=k?Oe(r.id,t):null;if(l.push({type:"row",s:r,depth:u,expandable:k,expanded:y,rollup:(m==null?void 0:m.color)??null,kin:(m==null?void 0:m.count)??0,guides:N}),y){const v=se(x).filter(d=>!p.has(d.id));v.forEach((d,h)=>{p.add(d.id),i(d,u+1,p,[...N,h<v.length-1])})}},c=new Set;let o=null;for(const r of se(a)){if(c.has(r.id))continue;c.add(r.id);const u=B(r);u!==o&&(l.push({type:"zone",zone:u}),o=u),i(r,0,c,[])}return l}function Ke({value:e,onChange:n,options:a}){return s.jsx("select",{className:"fv-filter",value:e,onChange:t=>n(t.target.value),children:a.map(t=>s.jsx("option",{value:t.value,children:t.label},t.value))})}const We={video:"vid",image:"img",transcript:"txt",data:"data"},ve=e=>{var n;return(n=e.evidence)!=null&&n.length?e.evidence:e.blob!=null?[{hash:e.blob,kind:e.blobKind||"image",state:e.blobState||"present"}]:[]},T=e=>{const n=ve(e);return n.length?["video","image","transcript","data"].filter(a=>n.some(t=>t.kind===a)):["note"]};function qe(e){var a;const n=[];for(const t of e)if((a=t.evals)!=null&&a.length)for(const l of Z(t.scenarios,t.evals))l.reading&&n.push({...l.reading,expected:l.expected??l.reading.expected,state:l.state,node:t.id,hue:t.hue});return n.sort((t,l)=>t.ts<l.ts?1:-1),n}const A=e=>`eval:${e.node}·${e.scenario}`;function _e({e,selected:n,onClick:a}){return s.jsxs("button",{className:`ef-row ${n?"sel":""}`,onClick:a,children:[s.jsx(Y,{state:e.state}),e.inSession&&s.jsx("span",{className:"ef-insession","data-tip":"measured by this session",children:"✦"}),s.jsx("span",{className:"ef-scenario","data-tip":e.scenario,children:e.scenario}),s.jsx("span",{className:"ef-node",style:{color:`hsl(${e.hue??210} 60% 70%)`},children:e.node}),s.jsx("span",{className:"ef-kind",children:T(e).map(t=>We[t]).filter(Boolean).join("·")}),s.jsx("span",{className:"ef-time",children:Ue(e.ts)})]})}const Ue=e=>{const n=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return n<3600?`${Math.max(1,Math.floor(n/60))}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`};function zs({nodes:e=[],sessions:n=[],sel:a,onSel:t,onRows:l,mustShow:i=null,lead:c=null}){const o=b(),[r,u]=f.useState(null),[p,N]=f.useState(!1),x=f.useMemo(()=>qe(e),[e]),k=x.some(w=>T(w).includes("video")),y=x.some(w=>T(w).includes("image")),m=r??(k?"video":y?"image":"all"),v=f.useMemo(()=>x.filter(w=>m==="all"||T(w).includes(m)),[x,m]),d=w=>!!me(n,w.by),h=f.useMemo(()=>v.filter(d).length,[v,n]),g=f.useMemo(()=>p?v.filter(d):v,[v,p,n]);return f.useEffect(()=>{l==null||l(g)},[g,l]),f.useEffect(()=>{i&&(g.some(w=>A(w)===i)||x.some(w=>A(w)===i)&&(u("all"),N(!1)))},[i,g,x]),s.jsxs("section",{className:"fv-group",children:[s.jsxs("header",{className:"fv-group-head",children:[s.jsxs("span",{className:"fv-head-row",children:[c,s.jsx(Ke,{value:m,onChange:u,options:["video","image","all"].map(w=>({value:w,label:o(`evalsFeed.kind.${w}`)}))})]}),(p||h>0)&&s.jsx("span",{className:"ef-chipbar",children:s.jsx("button",{type:"button",className:`ef-chip fv-live ${p?"on":""}`,onClick:()=>N(w=>!w),"data-tip":o("masterList.liveChipTitle"),children:o("masterList.liveChip",{n:h})})})]}),g.length===0&&s.jsx("div",{className:"ef-empty",children:o("evalsFeed.empty")}),g.map(w=>s.jsx(_e,{e:w,selected:a===A(w),onClick:()=>t(A(w),w)},A(w)))]})}const Ge={plus:{node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 12h14"}),s.jsx("path",{d:"M12 5v14"})]})},x:{node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M18 6 6 18"}),s.jsx("path",{d:"m6 6 12 12"})]})},"chevron-left":{node:s.jsx("path",{d:"m15 18-6-6 6-6"}),sw:2},"chevron-right":{node:s.jsx("path",{d:"m9 18 6-6-6-6"}),sw:2},download:{node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 15V3"}),s.jsx("path",{d:"m7 10 5 5 5-5"}),s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})},clock:{node:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 6v6l4 2"})]})},search:{node:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("path",{d:"m21 21-4.3-4.3"})]})},play:{node:s.jsx("path",{d:"M6 3.5 19.5 12 6 20.5Z"})},pause:{node:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),s.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})},"panel-left":{sw:2,node:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"1",y:"2",width:"22",height:"20",rx:"4"}),s.jsx("rect",{x:"4",y:"5",width:"2",height:"14",rx:"2",fill:"currentColor",stroke:"none"})]})},settings:{node:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})},graph:{vb:18,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"1.5",y:"6.5",width:"5",height:"4.4",rx:"1"}),s.jsx("rect",{x:"11.5",y:"1.8",width:"5",height:"4.4",rx:"1"}),s.jsx("rect",{x:"11.5",y:"11.8",width:"5",height:"4.4",rx:"1"}),s.jsx("path",{d:"M6.5 8.7 h2.2 M11.5 4 h-1.3 q-1.5 0-1.5 1.5 v7 q0 1.5 1.5 1.5 h1.3"})]})},sessions:{vb:18,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"1.5",y:"2.5",width:"15",height:"13",rx:"1.6"}),s.jsx("path",{d:"M4.6 6.5 l2.6 2.3 -2.6 2.3 M9 12.4 h4"})]})},evals:{vb:18,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.5 15.5 v-11"}),s.jsx("path",{d:"M2.5 15.5 h13"}),s.jsx("rect",{x:"4.6",y:"10",width:"2.6",height:"3.5",rx:"0.5"}),s.jsx("rect",{x:"8.7",y:"7",width:"2.6",height:"6.5",rx:"0.5"}),s.jsx("path",{d:"M13 6 l1.4 1.4 L16.5 3.6"})]})},issues:{vb:18,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.5 3.5 h13 v8.4 h-7 l-3.6 3 v-3 h-2.4 z"}),s.jsx("path",{d:"M5.4 6.7 h7.2 M5.4 9.2 h4.8"})]})},lock:{vb:16,sw:1.3,node:s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3.5",y:"7",width:"9",height:"6.5",rx:"1.2"}),s.jsx("path",{d:"M5.5 7 V5 a2.5 2.5 0 0 1 5 0 V7"})]})},paperclip:{vb:16,sw:1.3,node:s.jsx("path",{d:"M12.5 7.2 L7 12.6 a2.6 2.6 0 0 1-3.7-3.7 L9 3.2 a1.7 1.7 0 0 1 2.4 2.4 L5.8 11.2 a0.8 0.8 0 0 1-1.2-1.2 L9.7 5"})},loader:{vb:16,sw:1.5,node:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"8",cy:"8",r:"5.5",opacity:"0.3"}),s.jsx("path",{d:"M8 2.5 a5.5 5.5 0 0 1 5.5 5.5"})]})},maximize:{vb:16,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2 6V2h4"}),s.jsx("path",{d:"M14 6V2h-4"}),s.jsx("path",{d:"M2 10v4h4"}),s.jsx("path",{d:"M14 10v4h-4"})]})},minimize:{vb:16,sw:1.4,node:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6 2v4H2"}),s.jsx("path",{d:"M10 2v4h4"}),s.jsx("path",{d:"M6 14v-4H2"}),s.jsx("path",{d:"M10 14v-4h4"})]})}};function z({name:e,size:n=16,strokeWidth:a,className:t,style:l}){const i=Ge[e];if(!i)throw new Error(`unknown icon: ${e}`);const c=i.vb||24;return s.jsx("svg",{width:n,height:n,viewBox:`0 0 ${c} ${c}`,fill:"none",stroke:"currentColor",strokeWidth:a??i.sw??1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:t,style:l,children:i.node})}function Ks({icon:e,label:n,onClick:a,className:t,size:l,iconClassName:i,...c}){return s.jsx("button",{type:"button",className:t,"data-tip":n,"aria-label":n,onClick:a,...c,children:s.jsx(z,{name:e,size:l,className:i})})}const Ws=()=>s.jsx("svg",{className:"si-agent-glyph",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"})}),qs=()=>s.jsx("svg",{className:"si-agent-glyph",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M22.282 9.821a6 6 0 0 0-.516-4.91a6.05 6.05 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a6 6 0 0 0-3.998 2.9a6.05 6.05 0 0 0 .743 7.097a5.98 5.98 0 0 0 .51 4.911a6.05 6.05 0 0 0 6.515 2.9A6 6 0 0 0 13.26 24a6.06 6.06 0 0 0 5.772-4.206a6 6 0 0 0 3.997-2.9a6.06 6.06 0 0 0-.747-7.073M13.26 22.43a4.48 4.48 0 0 1-2.876-1.04l.141-.081l4.779-2.758a.8.8 0 0 0 .392-.681v-6.737l2.02 1.168a.07.07 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494M3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085l4.783 2.759a.77.77 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646M2.34 7.896a4.5 4.5 0 0 1 2.366-1.973V11.6a.77.77 0 0 0 .388.677l5.815 3.354l-2.02 1.168a.08.08 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.08.08 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667m2.01-3.023l-.141-.085l-4.774-2.782a.78.78 0 0 0-.785 0L9.409 9.23V6.897a.07.07 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.8.8 0 0 0-.393.681zm1.097-2.365l2.602-1.5l2.607 1.5v2.999l-2.597 1.5l-2.607-1.5Z"})}),F=e=>`/api/yatsu/blob/${e}`;function Ze({src:e,alt:n,onClose:a}){return f.useEffect(()=>{const t=l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),a())};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[a]),s.jsx("div",{className:"lightbox",onClick:a,children:s.jsx("img",{src:e,alt:n})})}function Ye({hash:e}){const n=b(),[a,t]=f.useState(null);return f.useEffect(()=>{let l=!0;return fetch(F(e)).then(i=>i.ok?i.text():Promise.reject(new Error("miss"))).then(i=>{l&&t(i)}).catch(()=>{l&&t("")}),()=>{l=!1}},[e]),a===null?s.jsx("pre",{className:"eval-transcript loading",children:n("nodeView.eval.loadingTranscript")}):s.jsx("pre",{className:"eval-transcript",children:a})}function Je({hash:e}){const n=b(),[a,t]=f.useState(null);return f.useEffect(()=>{let l=!0;return fetch(F(e)).then(i=>i.ok?i.text():Promise.reject(new Error("miss"))).then(i=>{let c=i,o=!0;try{c=JSON.stringify(JSON.parse(i),null,2)}catch{o=!1}l&&t({text:c,valid:o})}).catch(()=>{l&&t({text:"",valid:!1})}),()=>{l=!1}},[e]),a===null?s.jsx("pre",{className:"eval-data loading",children:n("nodeView.eval.loadingData")}):s.jsxs("div",{className:"eval-datawrap",children:[s.jsx("div",{className:"eval-datahead",children:a.valid?n("nodeView.eval.data"):n("nodeView.eval.dataInvalid")}),s.jsx("pre",{className:"eval-data",children:a.text})]})}function Qe({hash:e,alt:n}){const[a,t]=f.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx("img",{className:"an-image",src:F(e),alt:n,loading:"lazy",onClick:()=>t(!0)}),a&&s.jsx(Ze,{src:F(e),alt:n,onClose:()=>t(!1)})]})}function Xe({exit:e}){return s.jsx(z,{name:e?"minimize":"maximize",size:15})}function _s({target:e,className:n=""}){const a=b(),[t,l]=f.useState(!1);f.useEffect(()=>{const c=()=>{const o=document.fullscreenElement,r=e==null?void 0:e.current;l(!!o&&!!r&&(o===r||r.contains(o)))};return document.addEventListener("fullscreenchange",c),()=>document.removeEventListener("fullscreenchange",c)},[e]);const i=()=>{var o,r;const c=e==null?void 0:e.current;c&&(document.fullscreenElement?(o=document.exitFullscreen||document.webkitExitFullscreen)==null||o.call(document):(r=c.requestFullscreen||c.webkitRequestFullscreen)==null||r.call(c))};return s.jsx("button",{type:"button",className:`an-fs ${n}`,onClick:i,"data-tip":a(t?"annotator.exitFullscreen":"annotator.fullscreen"),"aria-label":a(t?"annotator.exitFullscreen":"annotator.fullscreen"),children:s.jsx(Xe,{exit:t})})}function ge({e,alt:n=""}){const a=b();return e.state==="miss"?s.jsx("div",{className:"eval-noimg",children:a("nodeView.eval.miss")}):e.kind==="transcript"?s.jsx(Ye,{hash:e.hash}):e.kind==="data"?s.jsx(Je,{hash:e.hash}):e.kind==="video"?s.jsx("video",{className:"eval-video",src:F(e.hash),controls:!0,preload:"metadata",playsInline:!0}):s.jsx(Qe,{hash:e.hash,alt:n})}const P=new Map;function es(e){const[n,a]=f.useState(()=>P.get(e)??null);return f.useEffect(()=>{if(P.has(e)){a(P.get(e));return}let t=!0;return fetch(F(e),{headers:{Range:"bytes=0-0"}}).then(l=>{const i=l.headers.get("content-type")||"",c=l.ok?{kind:i.startsWith("video/")?"video":i.startsWith("image/")?"image":i.startsWith("application/json")?"data":"transcript",state:"present"}:{kind:"image",state:"miss"};P.set(e,c),t&&a(c)}).catch(()=>{t&&a({kind:"image",state:"miss"})}),()=>{t=!1}},[e]),n}function je({hash:e,alt:n=""}){const a=es(e);return a?s.jsx(ge,{e:{hash:e,...a},alt:n}):null}const Us=/\[\[(\.?[\p{L}\p{N}_-]+)\]\]/gu,we=e=>(e||"").replace(/^\.spec\//,"").replace(/\/spec\.md$/,"");function ss(e,n,a){const t=n.toLowerCase(),l=[];for(const i of e){const c=i.id.toLowerCase(),o=we(i.path).toLowerCase();let r;if(!t)r=3;else if(c.startsWith(t))r=0;else if(c.includes(t))r=1;else if(o.includes(t))r=2;else continue;i.id===a&&(r=-1),l.push({s:i,score:r})}return l.sort((i,c)=>i.score-c.score||i.s.id.length-c.s.id.length||i.s.id.localeCompare(c.s.id)),l.slice(0,8).map(i=>i.s)}function ns(e,n){const a=n.toLowerCase(),t=o=>xe(o)||(o.id||"").slice(0,8),l=[];for(const o of e||[]){if(o.liveness!=="online")continue;const r=(o.id||"").toLowerCase(),u=t(o).toLowerCase();let p;if(!a)p=3;else if(r===a||u===a)p=0;else if(r.startsWith(a)||u.startsWith(a))p=1;else if(r.includes(a)||u.includes(a))p=2;else continue;l.push({s:o,score:p})}l.sort((o,r)=>o.score-r.score||(r.s.created||0)-(o.s.created||0));const i=l.map(o=>({id:o.s.id,label:t(o.s),sub:o.s.node||o.s.status})),c=l.filter(o=>o.score===0).length;return i.splice(c,0,{id:"new",label:"new",sub:"spawn a fresh worker"}),i.slice(0,8)}function ne(e,n){if(!n)return e;const a=e.toLowerCase().indexOf(n.toLowerCase());return a<0?e:s.jsxs(s.Fragment,{children:[e.slice(0,a),s.jsx("b",{className:"mention-hit",children:e.slice(a,a+n.length)}),e.slice(a+n.length)]})}function ts(e,n,a,t){let l=n-1;for(;l>=0&&/[\p{L}\p{N}_.\-]/u.test(e[l]);)l--;if(l>=1&&e[l-1]==="["&&e[l]==="["){const i=e.slice(l+1,n),c=ss(a,i,t);return c.length?{kind:"mention",items:c,index:0,start:l-1,end:n,query:i}:null}return null}function as(e,n,a){let t=n-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 l=e.slice(t+1,n),i=ns(a,l);return i.length?{kind:"actor",items:i,index:0,start:t,end:n,query:l}:null}return null}function ls({menu:e,up:n,fixedStyle:a,onPick:t,onHover:l}){const i=b(),c=e.kind==="actor",o=e.query?c?`@${e.query}`:`[[${e.query}]]`:i(c?"session.menuSessions":"session.menuSpecNodes");return s.jsxs("ul",{className:`${n?"mention-menu up":"mention-menu"}${a?" fixed":""}`,style:a||void 0,role:"listbox",children:[s.jsxs("li",{className:"mention-head",children:["// ",o," — ",i("session.menuHint")]}),e.items.map((r,u)=>s.jsxs("li",{role:"option","aria-selected":u===e.index,className:`${u===e.index?"mention-item on":"mention-item"}${c&&r.id==="new"?" new":""}`,onMouseDown:p=>{p.preventDefault(),t(r)},onMouseEnter:()=>l(u),children:[!c&&s.jsx("span",{className:"mention-dot",style:{background:M[r.status]||M.offline}}),s.jsx("span",{className:"mention-id",children:c?s.jsxs(s.Fragment,{children:["@",ne(r.label,e.query)]}):ne(r.id,e.query)}),s.jsx("span",{className:"mention-path",children:c?r.sub:we(r.path)})]},r.id))]})}function is({inputRef:e,value:n,setValue:a,specs:t=[],sessions:l=[],focusId:i=null,up:c=!1,fixedAbove:o=null}){const[r,u]=f.useState(null),[p,N]=f.useState(null),x=h=>{var $;if(!h){u(null),N(null);return}const g=h.selectionStart,w=ts(h.value,g,t,i)||as(h.value,g,l);if(u(w),!w||!o){N(null);return}const S=h.getBoundingClientRect(),E=($=h.closest(o))==null?void 0:$.getBoundingClientRect(),j=(E==null?void 0:E.top)??S.top;N({left:`${S.left}px`,width:`${S.width}px`,right:"auto",bottom:`${Math.max(8,window.innerHeight-j+8)}px`})},k=h=>u(g=>g&&{...g,index:(g.index+h+g.items.length)%g.items.length}),y=h=>{if(!h||!r)return;const g=r.kind==="actor"?`@${h.id} `:`[[${h.id}]] `,w=n.slice(0,r.start);a(w+g+n.slice(r.end)),u(null),N(null);const S=w.length+g.length;requestAnimationFrame(()=>{const E=e.current;E&&(E.focus(),E.setSelectionRange(S,S))})};return{menu:r,sync:x,onKeyDown:h=>r?h.key==="ArrowDown"?(h.preventDefault(),h.stopPropagation(),k(1),!0):h.key==="ArrowUp"?(h.preventDefault(),h.stopPropagation(),k(-1),!0):h.key==="Enter"||h.key==="Tab"?(h.preventDefault(),h.stopPropagation(),y(r.items[r.index]),!0):h.key==="Escape"?(h.preventDefault(),h.stopPropagation(),u(null),N(null),!0):!1:!1,close:()=>{u(null),N(null)},menuEl:r?s.jsx(ls,{menu:r,up:c,fixedStyle:p,onPick:y,onHover:h=>u(g=>g&&{...g,index:h})}):null}}function rs(e,n,a=0){e&&(e.style.height="auto",e.style.overflowY=e.scrollHeight>n?"auto":"hidden",e.style.height=`${Math.min(Math.max(e.scrollHeight,a),n)}px`)}const cs=/^▶\s*(\d+):([0-5]?\d)(?:\s*·\s*([^\n]*))?/,os=/^!\[frame\]\(\/api\/yatsu\/blob\/[0-9a-f]{64}\)\n?/,ds=/\/api\/yatsu\/blob\/([0-9a-f]{64})/g,te=/!\[[^\]]*\]\(\/api\/yatsu\/blob\/([0-9a-f]{64})\)/g,us=e=>{const n=Math.floor(e/1e3);return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`};function ye(e){var i;const n=e||"",a=n.split(`
2
2
  `,1)[0],t=cs.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:n.slice(a.length).replace(/^\n/,"")}:null}const Ne=(e,n)=>`▶${us(e)}${n?` · ${n}`:""}`,ae=e=>[...(e||"").matchAll(ds)].map(n=>n[1]);function hs(e,n){if(!e)return null;if(e.step&&(n!=null&&n.length)){const a=n.find(t=>t.step===e.step);return a?{tMs:a.at,step:e.step,label:Ne(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 Gs({originator:e,sessions:n=[],kind:a="issue",onOpenSession:t=null}){const l=b();if(!e)return null;const i=me(n,e),c=!!i,o=c?M[i.status]||M.working:M.offline,r=l(a==="eval"?"thread.originatorEval":"thread.originatorIssue",{by:e}),u=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"fv-originator-dot",style:{background:o},"aria-hidden":"true"}),s.jsx("span",{className:"fv-originator-who",children:e})]});return c&&t?s.jsx("button",{type:"button",className:"fv-originator alive openable","data-tip":r,"aria-label":r,onClick:()=>t(e),children:u}):s.jsx("span",{className:`fv-originator ${c?"alive":"offline"}`,"data-tip":r,children:u})}function ps({replies:e,onSeek:n,selIdx:a=null,activeIdx:t=null,onSelect:l=null,events:i=null,threadId:c=null,onRemarkChange:o=null}){const r=b(),[u,p]=f.useState(null),[N,x]=f.useState(null),k=async(y,m)=>{if(!u){p(m),x(null);try{const v=await Ee(y,m);v!=null&&v.ok?await(o==null?void 0:o()):x({ref:m,msg:(v==null?void 0:v.error)||`${y} failed`})}finally{p(null)}}};return e.map((y,m)=>{const v=ye(y.body),d=hs(v,i),h=v?v.rest:y.body,g=[...h.matchAll(te)].map(V=>V[1]),w=(g.length?h.replace(te,""):h).trim(),S=y.rid!==void 0,E=S?y.resolved?" remark resolved":" remark open":"",j=`fv-reply${a===m?" sel":""}${t===m?" active":""}${E}`,$=d&&d.seekable&&n?()=>l?l(m,d.tMs):n(d.tMs):null,C=S&&c?`${c}#${y.rid}`:null;return s.jsxs("div",{className:j,children:[s.jsxs("div",{className:"fv-reply-meta",children:[s.jsx("span",{className:"fv-reply-by",children:y.by}),y.at&&s.jsx("span",{className:"fv-reply-at",children:y.at}),d&&($?s.jsx("button",{type:"button",className:"fv-anchor",onClick:$,"data-tip":"seek the clip to this moment",children:d.label}):s.jsxs("span",{className:`fv-anchor static${d.degraded?" degraded":""}`,"data-tip":d.degraded?r("thread.anchorDegraded"):void 0,children:[d.label,d.degraded?" ⚠":""]})),S&&(y.resolved?s.jsxs("span",{className:"fv-remark-state resolved","data-tip":y.resolvedBy?r("thread.resolvedBy",{by:y.resolvedBy}):r("thread.resolved"),children:["✓ ",r("thread.resolved")]}):s.jsxs("span",{className:"fv-remark-state open","data-tip":r("thread.openRemark"),children:["● ",r("thread.openRemark")]})),C&&o&&!y.resolved&&(y.by==="human"?s.jsx("button",{type:"button",className:"fv-remark-act retract",disabled:!!u,"data-tip":r("thread.retractTitle"),onClick:()=>k("retract",C),children:r("thread.retract")}):s.jsx("button",{type:"button",className:"fv-remark-act resolve",disabled:!!u,"data-tip":r("thread.resolveTitle"),onClick:()=>k("resolve",C),children:r("thread.resolve")}))]}),N&&N.ref===C&&s.jsx("div",{className:"fv-error",children:N.msg}),w&&s.jsx("div",{className:"fvd-body",children:s.jsx(R,{body:w})}),g.length>0&&s.jsx("div",{className:"fv-reply-media",children:g.map((V,I)=>s.jsx(je,{hash:V,alt:"evidence"},`${V}-${I}`))})]},m)})}function Zs({onSend:e,specs:n=[],sessions:a=[],focusId:t=null,onDone:l,anchorNow:i=null,draft:c=null,actionsEnd:o=null}){const r=b(),[u,p]=f.useState(""),[N,x]=f.useState(!1),[k,y]=f.useState(""),[m,v]=f.useState(!1),d=f.useRef(null),h=is({inputRef:d,value:u,setValue:p,specs:n,sessions:a,focusId:t,up:!0}),g=ae(u),w=m||!!u||g.length>0||!!k;f.useEffect(()=>{const j=d.current;if(!j)return;const $=getComputedStyle(j);rs(j,parseFloat($.maxHeight)||1/0,parseFloat($.minHeight)||0)},[u]),f.useEffect(()=>{var j;if(!c){p("");return}p(c.body||""),(j=d.current)==null||j.focus()},[c==null?void 0:c.seq]);const S=async()=>{var C;const j=await(i==null?void 0:i());if(!j)return;const $=Ne(j.tMs,j.step)+(j.frame?`
3
3
  ![frame](/api/yatsu/blob/${j.frame})`:"");p(V=>{const I=ye(V),J=(I?I.rest:V).replace(os,"");return J?`${$}
4
4
  ${J}`:`${$}
5
- `}),(C=d.current)==null||C.focus()},E=async()=>{const j=u.trim();if(!(!j||N)){x(!0);try{const $=await e(j,ae(j));$!=null&&$.ok?(p(""),y(""),await(l==null?void 0:l($.outcomes||""))):y(($==null?void 0:$.error)||"reply failed")}finally{x(!1)}}};return s.jsxs("div",{className:`fv-compose${w?" engaged":""}`,children:[g.length>0&&s.jsx("div",{className:"fv-frames",children:g.map(j=>s.jsx(je,{hash:j,alt:"frame"},j))}),s.jsxs("div",{className:"fv-tawrap",children:[s.jsx("textarea",{ref:d,className:"fv-textarea",rows:1,value:u,placeholder:r("session.issuesReplyPlaceholder"),disabled:N,onChange:j=>{p(j.target.value),h.sync(j.target)},onSelect:j=>h.sync(j.target),onFocus:()=>v(!0),onBlur:()=>{v(!1),h.close()},onKeyDown:j=>{h.onKeyDown(j)||j.key==="Enter"&&(j.metaKey||j.ctrlKey)&&(j.preventDefault(),E())}}),h.menuEl]}),s.jsxs("div",{className:"fv-actions",children:[i&&s.jsxs("button",{type:"button",className:"fv-anchor-btn","data-tip":r("thread.anchorTitle"),onMouseDown:j=>j.preventDefault(),onClick:S,children:[s.jsx(O,{name:"clock",size:11})," ",r("thread.anchorNow")]}),s.jsx("span",{className:"fv-hint",children:k||r("session.issuesMentionHint")}),s.jsx("button",{type:"button",className:"fv-send",disabled:N||!u.trim(),onMouseDown:j=>j.preventDefault(),onClick:E,children:r(N?"session.issuesSending":"session.issuesSend")}),o]})]})}const fs=["graph","sessions","evals","issues","settings"];function G(e){const n=(e||"").replace(/^#\/?/,"").split("/").filter(Boolean),a=fs.includes(n[0])?n[0]:"graph",t=a==="sessions"?n[1]||null:a==="evals"?n.length>1?n.slice(1).map(decodeURIComponent).join("/"):null:a==="issues"&&n.length>1?n.slice(1).map(decodeURIComponent).join("/"):null;return{page:a,param:t}}const L=(e,n)=>`#/${e}${n?`/${String(n).split("/").map(encodeURIComponent).join("/")}`:""}`;function K(e,n=null,{replace:a=!1}={}){const t=L(e,n);window.location.hash!==t&&(a?window.history.replaceState(null,"",t):window.location.hash=t)}function Ys(){const[e,n]=f.useState(()=>G(window.location.hash));return f.useEffect(()=>{const a=()=>n(G(window.location.hash));return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),e}const Js=e=>({kind:"graph-node",nodeId:e}),Qs=e=>({kind:"session",sessionId:e}),ms=e=>({kind:"issue",issueId:e}),Xs=(e,n)=>({kind:"eval",nodeId:e,scenario:n});function be(e){return!e||e.kind==="graph-node"?L("graph"):e.kind==="session"?L("sessions",e.sessionId):e.kind==="issue"?L("issues",e.issueId):e.kind==="eval"?L("evals",`${e.nodeId}/${e.scenario}`):L("graph")}function en(e,{onFocusNode:n,onOpenSession:a}={}){if(e)if(e.kind==="graph-node")n==null||n(e.nodeId),K("graph");else if(e.kind==="session")a?a(e.sessionId):K("sessions",e.sessionId);else{const{page:t,param:l}=G(be(e));K(t,l)}}function le({issue:e,onNavigateAddress:n}){const a=(e==null?void 0:e.store)||"local",t=(e==null?void 0:e.status)||"open",l=ms(e.id);return s.jsxs("a",{className:"issue-card",href:be(l),"data-tip":e.concern||e.id,onClick:n?i=>{i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),n(l))}:void 0,children:[s.jsxs("span",{className:"issue-card-top",children:[s.jsx("span",{className:"issue-num",children:e.id}),s.jsx("span",{className:`fv-store fv-store-${a==="local"?"local":"forge"}`,children:a}),s.jsx("span",{className:`issue-state st-${t}`,children:t})]}),s.jsx("span",{className:"issue-card-title",children:e.concern})]})}const ie=[{key:"spec",label:"spec"},{key:"history",label:"history"},{key:"issues",label:"issues"},{key:"eval",label:"eval"}];function xs(e){var n;return(n=e==null?void 0:e.overlays)!=null&&n.length?[{key:"edit",label:"edit"},...ie]:ie}const vs={added:"+",edited:"~",deleted:"✕",moved:"→"};function D(e){const n=[],a=/`([^`]+)`|\*\*([^*]+)\*\*|\[\[([^\]]+)\]\]/g;let t=0,l,i=0;for(;l=a.exec(e);)l.index>t&&n.push(e.slice(t,l.index)),l[1]!=null?n.push(s.jsx("code",{children:l[1]},i++)):l[2]!=null?n.push(s.jsx("strong",{children:l[2]},i++)):n.push(s.jsx("span",{className:"doc-link",children:l[3]},i++)),t=a.lastIndex;return t<e.length&&n.push(e.slice(t)),n}function re(e){const n=e.trim();return n.includes("|")&&/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/.test(n)}function W(e){let n=e.trim();return n.startsWith("|")&&(n=n.slice(1)),n.endsWith("|")&&(n=n.slice(0,-1)),n.split("|").map(a=>a.trim())}function gs(e){const n=e.startsWith(":"),a=e.endsWith(":");return n&&a?"center":a?"right":null}function R({body:e}){if(!e)return null;const n=e.replace(/^#\s+[^\n]*\n+/,"").split(`
5
+ `}),(C=d.current)==null||C.focus()},E=async()=>{const j=u.trim();if(!(!j||N)){x(!0);try{const $=await e(j,ae(j));$!=null&&$.ok?(p(""),y(""),await(l==null?void 0:l($.outcomes||""))):y(($==null?void 0:$.error)||"reply failed")}finally{x(!1)}}};return s.jsxs("div",{className:`fv-compose${w?" engaged":""}`,children:[g.length>0&&s.jsx("div",{className:"fv-frames",children:g.map(j=>s.jsx(je,{hash:j,alt:"frame"},j))}),s.jsxs("div",{className:"fv-tawrap",children:[s.jsx("textarea",{ref:d,className:"fv-textarea",rows:1,value:u,placeholder:r("session.issuesReplyPlaceholder"),disabled:N,onChange:j=>{p(j.target.value),h.sync(j.target)},onSelect:j=>h.sync(j.target),onFocus:()=>v(!0),onBlur:()=>{v(!1),h.close()},onKeyDown:j=>{h.onKeyDown(j)||j.key==="Enter"&&(j.metaKey||j.ctrlKey)&&(j.preventDefault(),E())}}),h.menuEl]}),s.jsxs("div",{className:"fv-actions",children:[i&&s.jsxs("button",{type:"button",className:"fv-anchor-btn","data-tip":r("thread.anchorTitle"),onMouseDown:j=>j.preventDefault(),onClick:S,children:[s.jsx(z,{name:"clock",size:11})," ",r("thread.anchorNow")]}),s.jsx("span",{className:"fv-hint",children:k||r("session.issuesMentionHint")}),s.jsx("button",{type:"button",className:"fv-send",disabled:N||!u.trim(),onMouseDown:j=>j.preventDefault(),onClick:E,children:r(N?"session.issuesSending":"session.issuesSend")}),o]})]})}const fs=["graph","sessions","evals","issues","settings"];function G(e){const n=(e||"").replace(/^#\/?/,"").split("/").filter(Boolean),a=fs.includes(n[0])?n[0]:"graph",t=a==="sessions"?n[1]||null:a==="evals"?n.length>1?n.slice(1).map(decodeURIComponent).join("/"):null:a==="issues"&&n.length>1?n.slice(1).map(decodeURIComponent).join("/"):null;return{page:a,param:t}}const L=(e,n)=>`#/${e}${n?`/${String(n).split("/").map(encodeURIComponent).join("/")}`:""}`;function K(e,n=null,{replace:a=!1}={}){const t=L(e,n);window.location.hash!==t&&(a?window.history.replaceState(null,"",t):window.location.hash=t)}function Ys(){const[e,n]=f.useState(()=>G(window.location.hash));return f.useEffect(()=>{const a=()=>n(G(window.location.hash));return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[]),e}const Js=e=>({kind:"graph-node",nodeId:e}),Qs=e=>({kind:"session",sessionId:e}),ms=e=>({kind:"issue",issueId:e}),Xs=(e,n)=>({kind:"eval",nodeId:e,scenario:n});function be(e){return!e||e.kind==="graph-node"?L("graph"):e.kind==="session"?L("sessions",e.sessionId):e.kind==="issue"?L("issues",e.issueId):e.kind==="eval"?L("evals",`${e.nodeId}/${e.scenario}`):L("graph")}function en(e,{onFocusNode:n,onOpenSession:a}={}){if(e)if(e.kind==="graph-node")n==null||n(e.nodeId),K("graph");else if(e.kind==="session")a?a(e.sessionId):K("sessions",e.sessionId);else{const{page:t,param:l}=G(be(e));K(t,l)}}function le({issue:e,onNavigateAddress:n}){const a=(e==null?void 0:e.store)||"local",t=(e==null?void 0:e.status)||"open",l=ms(e.id);return s.jsxs("a",{className:"issue-card",href:be(l),"data-tip":e.concern||e.id,onClick:n?i=>{i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),n(l))}:void 0,children:[s.jsxs("span",{className:"issue-card-top",children:[s.jsx("span",{className:"issue-num",children:e.id}),s.jsx("span",{className:`fv-store fv-store-${a==="local"?"local":"forge"}`,children:a}),s.jsx("span",{className:`issue-state st-${t}`,children:t})]}),s.jsx("span",{className:"issue-card-title",children:e.concern})]})}const ie=[{key:"spec",label:"spec"},{key:"history",label:"history"},{key:"issues",label:"issues"},{key:"eval",label:"eval"}];function xs(e){var n;return(n=e==null?void 0:e.overlays)!=null&&n.length?[{key:"edit",label:"edit"},...ie]:ie}const vs={added:"+",edited:"~",deleted:"✕",moved:"→"};function D(e){const n=[],a=/`([^`]+)`|\*\*([^*]+)\*\*|\[\[([^\]]+)\]\]/g;let t=0,l,i=0;for(;l=a.exec(e);)l.index>t&&n.push(e.slice(t,l.index)),l[1]!=null?n.push(s.jsx("code",{children:l[1]},i++)):l[2]!=null?n.push(s.jsx("strong",{children:l[2]},i++)):n.push(s.jsx("span",{className:"doc-link",children:l[3]},i++)),t=a.lastIndex;return t<e.length&&n.push(e.slice(t)),n}function re(e){const n=e.trim();return n.includes("|")&&/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/.test(n)}function W(e){let n=e.trim();return n.startsWith("|")&&(n=n.slice(1)),n.endsWith("|")&&(n=n.slice(0,-1)),n.split("|").map(a=>a.trim())}function gs(e){const n=e.startsWith(":"),a=e.endsWith(":");return n&&a?"center":a?"right":null}function R({body:e}){if(!e)return null;const n=e.replace(/^#\s+[^\n]*\n+/,"").split(`
6
6
  `),a=[];let t=0,l=0;for(;t<n.length;){const i=n[t].trim();if(/^```/.test(i)){const c=[];for(t++;t<n.length&&!/^```/.test(n[t].trim());)c.push(n[t++]);t++,a.push(s.jsx("pre",{className:"doc-pre",children:s.jsx("code",{children:c.join(`
7
- `)})},l++))}else if(/^#{1,6}\s+/.test(n[t]))a.push(s.jsx("h4",{className:"doc-h",children:D(n[t].replace(/^#+\s+/,""))},l++)),t++;else if(i.includes("|")&&t+1<n.length&&re(n[t+1])){const c=W(n[t]),o=W(n[t+1]).map(gs);t+=2;const r=[];for(;t<n.length&&n[t].includes("|")&&n[t].trim()!==""&&!/^```/.test(n[t].trim());)r.push(W(n[t])),t++;a.push(s.jsxs("table",{className:"doc-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:c.map((u,p)=>s.jsx("th",{style:o[p]?{textAlign:o[p]}:void 0,children:D(u)},p))})}),s.jsx("tbody",{children:r.map((u,p)=>s.jsx("tr",{children:c.map((N,x)=>s.jsx("td",{style:o[x]?{textAlign:o[x]}:void 0,children:D(u[x]??"")},x))},p))})]},l++))}else if(/^-\s+/.test(i)){const c=[];for(;t<n.length&&/^-\s+/.test(n[t].trim());)c.push(n[t++].trim().replace(/^-\s+/,""));a.push(s.jsx("ul",{children:c.map((o,r)=>s.jsx("li",{children:D(o)},r))},l++))}else if(i==="")t++;else{const c=[];for(;t<n.length;){const o=n[t];if(o.trim()===""||/^```/.test(o.trim())||/^#{1,6}\s+/.test(o)||/^-\s+/.test(o.trim())||o.includes("|")&&t+1<n.length&&re(n[t+1]))break;c.push(o),t++}a.push(s.jsx("p",{children:D(c.join(" "))},l++))}}return s.jsx("div",{className:"doc-body",children:a})}function ce({kind:e,title:n,owner:a,ownerLabel:t,note:l,children:i}){return s.jsxs("section",{className:`spec-part part-${e}`,children:[s.jsxs("header",{className:"part-head",children:[s.jsx("span",{className:"part-title",children:n}),s.jsx("span",{className:`part-owner owner-${a}`,children:t}),l&&s.jsx("span",{className:"part-note",children:l})]}),s.jsx("div",{className:"part-body",children:i})]})}function js({parts:e}){const n=b();return s.jsxs("div",{className:"spec-parts",children:[s.jsx(ce,{kind:"raw",title:n("nodeView.rawTitle"),owner:"human",ownerLabel:n("nodeView.rawOwner"),note:n("nodeView.rawNote"),children:s.jsx(R,{body:e.rawSource})}),s.jsx(ce,{kind:"expanded",title:n("nodeView.expandedTitle"),owner:"agent",ownerLabel:n("nodeView.expandedOwner"),note:n("nodeView.expandedNote"),children:s.jsx(R,{body:e.expandedSpec})})]})}const q=new Map;function ws(e,n){const a=`${e}@${n??""}`,[t,l]=f.useState(()=>q.get(a)??null);return f.useEffect(()=>{const i=q.get(a);if(i){l(i);return}l(null);let c=!0;return fetch(z(e,"content")).then(o=>o.ok?o.json():Promise.reject(o.status)).then(o=>{q.set(a,o),c&&l(o)}).catch(()=>{c&&l({body:"",parts:null})}),()=>{c=!1}},[e,n,a]),t}function ys({node:e}){var l;const n=b(),a=ws(e.id,e.version),t=(e.driftFiles||[]).map(i=>`${i.file}: ${n("specNode.driftAhead",{n:i.behind})}`).join(`
8
- `);return s.jsxs("div",{className:"pane-doc",children:[s.jsxs("h1",{children:["# ",e.title]}),s.jsx("blockquote",{children:e.desc}),s.jsxs("div",{className:"doc-stat",children:[s.jsxs("span",{className:`stat-status st-${e.status}`,"data-tip":n("nodeView.statusLabel"),children:[s.jsx("i",{className:"stat-dot"}),n(`status.${e.status}`)]}),s.jsxs("span",{className:"stat-chip","data-tip":n("nodeView.versionLabel"),children:["v",e.version||0]}),s.jsx(Ie,{scenarios:e.scenarios,evals:e.evals}),e.drift>0&&s.jsxs("span",{className:"stat-chip stat-drift","data-tip":t,children:["⚠",e.drift]}),s.jsxs("span",{className:"stat-sess","data-tip":n("nodeView.lastEditedBy"),children:["✎ ",s.jsx("b",{children:e.session||n("common.none")})]})]}),((l=e.code)==null?void 0:l.length)>0?s.jsxs("div",{className:"doc-gov",children:[s.jsxs("span",{className:"doc-gov-h",children:[n("nodeView.governs")," ",s.jsx("b",{children:e.code.length})]}),s.jsx("div",{className:"doc-gov-files",children:e.code.map(i=>s.jsx("code",{className:"gov-f",children:i},i))})]}):s.jsx("div",{className:"doc-gov prose",children:s.jsx("span",{className:"doc-gov-h",children:n("nodeView.proseNode")})}),(()=>{if(a===null&&e.body==null)return s.jsx("div",{className:"pane-loading",children:s.jsx("span",{className:"spinner","aria-label":n("common.loading")})});const i=e.body??(a==null?void 0:a.body)??"",c=e.parts??(a==null?void 0:a.parts)??null;return c?s.jsx(js,{parts:c}):s.jsx(R,{body:i})})()]})}function Ns(e,n=!0){const[a,t]=f.useState(null);return f.useEffect(()=>{if(!n)return;let l=!0;return fetch(z(e,"history")).then(i=>i.json()).then(i=>{l&&t(i)}).catch(()=>l&&t([])),()=>{l=!1}},[e,n]),a}const _=new Map;function bs(e,n,a){const t=`${e}/${n}`,[l,i]=f.useState(()=>_.get(t)??null);return f.useEffect(()=>{const c=_.get(t);if(c){i(c);return}let o=!0;return fetch(z(e,"diff",n)).then(r=>r.json()).then(r=>{_.set(t,r),o&&i(r)}).catch(()=>o&&i({patch:""})),()=>{o=!1}},[e,n,a,t]),l}function ks(e){const n=[];let a=!1;for(const t of e.split(`
9
- `)){if(t.startsWith("@@")){a=!0,n.push({t:"hunk",s:t});continue}!a||t.startsWith("\\")||(t.startsWith("+")?n.push({t:"add",s:t.slice(1)}):t.startsWith("-")?n.push({t:"del",s:t.slice(1)}):n.push({t:"ctx",s:t.slice(1)}))}for(;n.length&&n[n.length-1].t==="ctx"&&n[n.length-1].s==="";)n.pop();return n}function ke({diff:e}){const n=b();if(e==null)return s.jsx("figcaption",{className:"ev-note",children:n("nodeView.loadingChange")});const a=e.patch?ks(e.patch):[];return a.length?s.jsxs(s.Fragment,{children:[s.jsx("figcaption",{className:"ev-difflabel",children:n("nodeView.diffLabel")}),s.jsx("pre",{className:"ev-diff",children:a.map((t,l)=>s.jsx("div",{className:`dl dl-${t.t}`,children:t.s||" "},l))})]}):s.jsx("figcaption",{className:"ev-note",children:n("nodeView.noChange")})}function $e({items:e,itemKey:n,classes:a,rowClass:t,renderHeader:l,renderEvidence:i,leading:c,trailing:o,resetKey:r}){const u=b(),p=f.useRef(null),[N,x]=f.useState(()=>new Set([0]));f.useEffect(()=>{r!==void 0&&x(new Set([0]))},[r]);const k=f.useCallback(m=>x(v=>{const d=new Set(v);return d.has(m)?d.delete(m):d.add(m),d}),[]),y=f.useCallback(()=>x(m=>{const v=p.current;if(!v)return m;let d=-1;for(;m.has(d+1);)d++;if(d<0||d>=e.length-1)return m;const h=v.querySelector(`[data-i="${d}"]`);return!h||h.getBoundingClientRect().bottom-v.getBoundingClientRect().top>v.clientHeight+40?m:new Set(m).add(d+1)}),[e]);return f.useEffect(()=>{const m=p.current;if(!m)return;let v=m.scrollTop;const d=()=>{const g=m.scrollTop,w=g>v;v=g,w&&y()},h=g=>{g.key!=="j"&&g.key!=="ArrowDown"||m.scrollHeight-m.clientHeight-m.scrollTop>1||y()};return m.addEventListener("scroll",d,{passive:!0}),window.addEventListener("keydown",h,!0),()=>{m.removeEventListener("scroll",d),window.removeEventListener("keydown",h,!0)}},[y]),s.jsxs("div",{className:a.pane,ref:p,children:[e.length>1&&N.size<e.length&&s.jsx("div",{className:"chrono-tools",children:s.jsx("button",{className:"chrono-all",onClick:()=>x(new Set(e.keys())),children:u("nodeView.expandAll",{n:e.length})})}),c,e.map((m,v)=>{const d=N.has(v),h=t?t(m,v):"";return s.jsxs("div",{"data-i":v,className:`${a.row}${h?` ${h}`:""}${d?" open":""}`,children:[s.jsx("button",{className:a.head,onClick:()=>k(v),"aria-expanded":d,children:l(m,v,d)}),d&&s.jsx("figure",{className:a.evidence,children:i(m,v)})]},n(m,v))}),o]})}function $s({node:e,r:n,latest:a}){const t=bs(e.id,n.hash,!0);return s.jsx(ke,{diff:t})}function Ss({node:e,rows:n}){const a=b();return n?n.length?s.jsx($e,{items:n,itemKey:t=>t.hash,classes:{pane:"pane-hist",row:"ver-row",head:"rec-toggle",evidence:"rec-evidence"},rowClass:(t,l)=>l===0?"latest":"",renderHeader:(t,l,i)=>s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rec-head",children:[s.jsx("span",{className:"rec-caret",children:i?"▾":"▸"}),s.jsxs("span",{className:"rec-v",children:["v",n.length-l]}),s.jsx("code",{className:"rec-hash",children:t.hash.slice(0,7)}),s.jsx("span",{className:"rec-date",children:(t.date||"").slice(0,10)}),s.jsxs("span",{className:"rec-diff",children:[s.jsxs("b",{className:"rec-add",children:["+",t.additions??0]}),s.jsxs("b",{className:"rec-del",children:["−",t.deletions??0]})]})]}),s.jsx("div",{className:"rec-msg",children:t.reason}),s.jsxs("div",{className:"rec-sub",children:[a("nodeView.filesChanged",{n:t.files??0})," · ",t.session||a("common.idle")]})]}),renderEvidence:(t,l)=>s.jsx($s,{node:e,r:t,latest:l===0})}):s.jsx("div",{className:"pane-hist empty",children:a("common.noVersions")}):s.jsx("div",{className:"pane-hist empty",children:a("nodeView.loadingHistory")})}function Se({q:e,setQ:n,placeholder:a}){return s.jsx("div",{className:"pane-filter",children:s.jsx("input",{className:"pane-filter-input",value:e,placeholder:a,onChange:t=>n(t.target.value)})})}function Es({node:e}){const n=b(),[a,t]=f.useState(""),l=e.issues||[];if(!l.length)return s.jsx("div",{className:"pane-issues empty",children:n("nodeView.noIssues")});const i=a.trim().toLowerCase(),c=i?l.filter(u=>`${u.id} ${u.concern||""}`.toLowerCase().includes(i)):l,o=c.filter(u=>u.status==="open"),r=c.filter(u=>u.status!=="open");return s.jsxs("div",{className:"pane-issues",children:[l.length>5&&s.jsx(Se,{q:a,setQ:t,placeholder:n("nodeView.filterIssues")}),i&&!c.length&&s.jsx("div",{className:"pane-filter-none",children:n("nodeView.filterNone")}),o.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"issue-group-head",children:n("nodeView.openIssues",{n:o.length})}),o.map(u=>s.jsx(le,{issue:u},u.id))]}),r.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"issue-group-head closed",children:n("nodeView.closedIssues",{n:r.length})}),r.map(u=>s.jsx(le,{issue:u},u.id))]})]})}const U=new Map;function Ms(e,n,a){const t=`${e} ${n}`,[l,i]=f.useState(()=>U.get(t)??null);return f.useEffect(()=>{if(!e||!n)return;const c=U.get(t);c&&i(c);let o=!0;return fetch(`/api/edit?source=${encodeURIComponent(e)}&path=${encodeURIComponent(n)}`).then(r=>r.json()).then(r=>{U.set(t,r),o&&i(r)}).catch(()=>o&&i(r=>r??{patch:""})),()=>{o=!1}},[e,n,a,t]),l}function Cs({node:e,ov:n}){const a=b(),t=Ms(n.source,e.path,!0);return s.jsxs("figure",{className:"edit-rev",children:[s.jsxs("figcaption",{className:"edit-by",children:[s.jsx("span",{className:`ov-mark ov-${n.op}`,children:vs[n.op]||"•"}),s.jsx("span",{className:"edit-by-label",children:n.label}),s.jsx("span",{className:"edit-state",children:n.committed?a("nodeView.editCommitted"):a("nodeView.editDirty")})]}),s.jsx(ke,{diff:t})]})}function Vs({node:e}){const n=b(),a=e.overlays||[];return a.length?s.jsx("div",{className:"pane-edit",children:a.map((t,l)=>s.jsx(Cs,{node:e,ov:t},l))}):s.jsx("div",{className:"pane-edit empty",children:n("nodeView.noEdit")})}function Ls({verdict:e}){const n=b();return e?e.status==="pass"?s.jsx("span",{className:"eval-verdict pass",children:n("nodeView.eval.pass")}):e.status==="fail"?s.jsx("span",{className:"eval-verdict fail",children:n("nodeView.eval.fail")}):s.jsx("span",{className:"eval-verdict note","data-tip":e.note,children:n("nodeView.eval.note")}):s.jsx("span",{className:"eval-verdict legacy",children:n("nodeView.eval.legacy")})}function As({r:e}){var t;const n=b(),a=ve(e);return s.jsxs(s.Fragment,{children:[e.expected&&s.jsxs("div",{className:"eval-expected",children:[s.jsx("span",{className:"eval-expected-label",children:n("nodeView.eval.expected")})," ",e.expected]}),((t=e.verdict)==null?void 0:t.note)&&s.jsxs("div",{className:"eval-note",children:[s.jsx("span",{className:"eval-expected-label",children:n("nodeView.eval.noteLabel")})," ",e.verdict.note]}),a.length>0?s.jsx("div",{className:"eval-gallery",style:{display:"flex",flexDirection:"column",gap:8},children:a.map((l,i)=>s.jsx(ge,{e:l,alt:n("nodeView.eval.shotAlt",{scenario:e.scenario})},`${l.hash}-${i}`))}):s.jsx("figcaption",{className:"eval-noimg",children:e.blobState==="miss"?n("nodeView.eval.miss"):n("nodeView.eval.noImage")})]})}function oe({s:e}){var a;const n=b();return s.jsxs("div",{className:"eval-row eval-declared-row",children:[s.jsxs("span",{className:"eval-top",children:[s.jsx(Y,{state:"empty",title:n("score.missing")}),s.jsx("span",{className:"eval-scenario",children:e.name}),s.jsx(Pe,{tags:e.tags}),((a=e.code)==null?void 0:a.length)>0&&s.jsx("code",{className:"eval-tracks",children:e.code.join(", ")})]}),e.expected&&s.jsxs("div",{className:"eval-expected",children:[s.jsx("span",{className:"eval-expected-label",children:n("nodeView.eval.expected")})," ",e.expected]})]})}function de({track:e}){const n=b();return s.jsxs("div",{className:"eval-row eval-dangling-row",children:[s.jsxs("span",{className:"eval-top",children:[s.jsx("span",{className:"eval-dangling-badge","data-tip":n("nodeView.eval.danglingTitle"),children:"⚠"}),s.jsx("span",{className:"eval-scenario eval-dangling-name",children:e.scenario}),s.jsx("span",{className:"eval-dangling-tag",children:n("nodeView.eval.danglingGone")})]}),s.jsx("div",{className:"eval-dangling-remarks",children:s.jsx(ps,{replies:e.remarks})})]})}const H=new Map;function Fs({node:e}){var y,m,v;const n=b(),[a,t]=f.useState(""),l=`${e.id}@${((m=(y=e.evals)==null?void 0:y[0])==null?void 0:m.ts)||""}:${((v=e.evals)==null?void 0:v.length)||0}`,[i,c]=f.useState(()=>H.get(l)??null);if(f.useEffect(()=>{if(H.has(l)){c(H.get(l));return}let d=!0;return c(null),fetch(z(e.id,"evals")).then(h=>h.ok?h.json():Promise.reject(h.status)).then(h=>{const g={scenarios:h.scenarios||e.scenarios||[],readings:h.readings||[],dangling:h.dangling||[]};H.set(l,g),d&&c(g)}).catch(()=>{d&&c({scenarios:e.scenarios||[],readings:e.evals||[],dangling:[]})}),()=>{d=!1}},[l,e.id]),!e.evals)return s.jsx("div",{className:"pane-eval empty",children:n("nodeView.eval.noScenarios")});if(i===null)return s.jsx("div",{className:"pane-eval pane-loading",children:s.jsx("span",{className:"spinner","aria-label":n("common.loading")})});const o=i.readings,r=a.trim().toLowerCase(),u=d=>!r||(d||"").toLowerCase().includes(r),p=r?o.filter(d=>u(d.scenario)):o,N=(i.dangling||[]).filter(d=>u(d.scenario)),x=Z(i.scenarios,o).filter(d=>!d.reading&&u(d.name)),k=i.readings.length+i.scenarios.length>5?s.jsx(Se,{q:a,setQ:t,placeholder:n("nodeView.filterScenarios")},"filter"):null;return o.length?s.jsx($e,{items:p,resetKey:r,leading:[k,r&&!p.length&&!x.length&&!N.length?s.jsx("div",{className:"pane-filter-none",children:n("nodeView.filterNone")},"none"):null,...x.map(d=>s.jsx(oe,{s:d},d.name))],trailing:N.map(d=>s.jsx(de,{track:d},d.threadId)),itemKey:(d,h)=>`${d.scenario}-${d.ts}-${h}`,classes:{pane:"pane-eval",row:"eval-row",head:"eval-head",evidence:"eval-shot"},renderHeader:(d,h,g)=>s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"eval-top",children:[s.jsx("span",{className:"eval-caret",children:g?"▾":"▸"}),s.jsx("span",{className:"eval-scenario",children:d.scenario}),s.jsx(Ls,{verdict:d.verdict}),s.jsx(Y,{state:pe(d),title:d.fresh?void 0:n("nodeView.eval.staleAxes",{axes:d.staleAxes.join(", ")})})]}),s.jsxs("span",{className:"eval-meta",children:[s.jsx("span",{className:"eval-evaluator",children:d.evaluator}),s.jsx("code",{className:"eval-sha",children:d.codeSha.slice(0,7)}),s.jsx("span",{className:"eval-ts",children:d.ts.replace("T"," ").slice(0,16)})]})]}),renderEvidence:d=>s.jsx(As,{r:d})}):s.jsxs("div",{className:"pane-eval pane-eval-declared",children:[k,s.jsx("div",{className:"eval-todo-note",children:r&&!x.length?n("nodeView.filterNone"):n("nodeView.eval.noReadings")}),x.map(d=>s.jsx(oe,{s:d},d.name)),N.map(d=>s.jsx(de,{track:d},d.threadId))]})}const Ds={spec:"nodeView.paneSpec",history:"nodeView.paneHistory",issues:"nodeView.paneIssues",eval:"nodeView.paneEval",edit:"nodeView.paneEdit"};function sn({node:e,pane:n,setPane:a,onClose:t}){const l=b(),i=e.issues||[],c=i.filter(x=>x.status==="open").length,o=i.length-c,r=(e.overlays||[]).length,u=xs(e),p=u.some(x=>x.key===n)?n:u[0].key,N=Ns(e.id,p==="history");return s.jsx("div",{className:"ov-backdrop","data-focus-overlay":!0,onMouseDown:t,children:s.jsxs("div",{className:"ov-panel",onMouseDown:x=>x.stopPropagation(),children:[s.jsxs("div",{className:"ov-head",children:[s.jsx("span",{className:"ov-title",children:e.title}),s.jsx("div",{className:"ov-tabs",children:u.map((x,k)=>s.jsxs("button",{className:x.key===p?"ov-tab on":"ov-tab",onClick:()=>a(x.key),children:[s.jsx("kbd",{children:k+1})," ",l(Ds[x.key]),x.key==="issues"&&(c>0||o>0)&&s.jsxs("span",{className:"ov-tab-counts",children:[c>0&&s.jsx("span",{className:"ovc st-open","data-tip":l("nodeView.openIssues",{n:c}),children:c}),o>0&&s.jsx("span",{className:"ovc st-closed","data-tip":l("nodeView.closedIssues",{n:o}),children:o})]}),x.key==="edit"&&r>0&&s.jsx("span",{className:"ov-tab-counts",children:s.jsx("span",{className:"ovc st-edit","data-tip":l("nodeView.pendingEdits",{n:r}),children:r})})]},x.key))}),s.jsx("span",{className:"ov-hint",children:l("nodeView.hint")})]}),s.jsxs("div",{className:"ov-body",children:[p==="spec"&&s.jsx("div",{className:"pane-solo",children:s.jsx(ys,{node:e})}),p==="history"&&s.jsx(Ss,{node:e,rows:N}),p==="issues"&&s.jsx(Es,{node:e}),p==="eval"&&s.jsx(Fs,{node:e}),p==="edit"&&s.jsx(Vs,{node:e})]})]})})}const Is=({size:e=12})=>s.jsx(O,{name:"lock",size:e});function Ps(e){if(!e.length)return null;const n={};return e.forEach(a=>{n[a.op]=(n[a.op]||0)+1}),Object.entries(n).map(([a,t])=>`${He[a]}${t}`).join(" ")}function Hs({guides:e=[],expandable:n,expanded:a,rollup:t,kin:l=0,onToggle:i}){return s.jsxs("span",{className:"sess-lead",children:[e.map((c,o)=>{const r=o===e.length-1?c?"tee":"elbow":c?"rail":"gap";return s.jsx("span",{className:`sess-rail ${r}`,"aria-hidden":"true"},o)}),n&&s.jsx("span",{className:`sess-fold pod${a?" open":""}`,role:"button",tabIndex:-1,style:a?{color:t,borderColor:t}:{background:t,borderColor:t},"data-tip":`${l} nested session${l===1?"":"s"} — click to ${a?"collapse":"expand"}`,onClick:c=>{c.stopPropagation(),i==null||i()},onMouseDown:c=>c.stopPropagation(),children:l})]})}function Ts(){const[e,n]=f.useState(()=>new Set);return{expanded:e,toggle:t=>n(l=>{const i=new Set(l);return i.has(t)?i.delete(t):i.add(t),i})}}function Bs({s:e,locked:n,showAvatar:a=!0,compact:t=!1,lead:l=null}){const i=b(),c=Ps(e.ops),o=xe(e),r=i(`status.${e.status}`);return s.jsxs(s.Fragment,{children:[l,a&&s.jsx(Le,{seed:e.id,status:e.status,title:`${Be(e)} · ${r} — ${e.id.slice(0,8)}`}),s.jsxs("span",{className:"sess-meta",children:[t?s.jsx("span",{className:"sess-glyph",style:{color:M[e.status]},"data-tip":r,"aria-label":r,children:Te[e.status]}):s.jsx("span",{className:"sess-status",style:{color:M[e.status]},children:r}),c&&s.jsx("span",{className:"sess-ops",children:c})]}),s.jsx("span",{className:"sess-id","data-tip":o,children:o}),n&&s.jsx("span",{className:"sess-lock","data-tip":i("sessionWindow.lockedTitle"),children:s.jsx(Is,{})})]})}function nn({sessions:e,activeId:n,onPick:a,onOpenSession:t}){const l=b(),{expanded:i,toggle:c}=Ts(),o=f.useMemo(()=>Oe(e,r=>i.has(r)),[e,i]);return s.jsx("div",{className:"sesswin",children:e.length===0?s.jsxs("div",{className:"sesswin-empty",children:[l("sessionWindow.emptyBefore"),s.jsx("kbd",{children:"⏎"}),l("sessionWindow.emptyAfter")]}):o.map(r=>{if(r.type==="zone")return s.jsx("div",{className:`sesswin-zone sesswin-zone-${r.zone}`,children:l(`sessionZone.${r.zone}`)},`zone-${r.zone}`);const u=r.s,p=u.source===n,N=r.expandable||r.depth?s.jsx(Hs,{guides:r.guides,expandable:r.expandable,expanded:r.expanded,rollup:r.rollup,kin:r.kin,onToggle:()=>c(u.id)}):null;return s.jsx("button",{className:p?"sess-row locked":"sess-row",style:{"--ov":Ce(u.id)},onClick:()=>a(u),onDoubleClick:()=>t(u.id),"data-tip":l("sessionWindow.rowTitle"),children:s.jsx(Bs,{s:u,locked:p,compact:!0,lead:N})},u.id)})})}export{_s as $,Le as A,_e as B,Ts as C,Oe as D,Vs as E,rs as F,He as G,Ss as H,le as I,ne as J,Us as K,Is as L,ls as M,sn as N,qs as O,we as P,ts as Q,Hs as R,zs as S,Pe as T,as as U,ve as V,hs as W,ye as X,Ne as Y,Gs as Z,us as _,Ie as a,ge as a0,ps as a1,Zs as a2,qe as a3,Os as a4,me as a5,Ke as a6,R as a7,is as a8,Te as b,M as c,Z as d,De as e,Xs as f,Ks as g,Js as h,ms as i,Be as j,Qs as k,Ce as l,Y as m,O as n,K as o,en as p,xs as q,nn as r,xe as s,Ns as t,Ys as u,ys as v,Es as w,Bs as x,Ws as y,F as z};
7
+ `)})},l++))}else if(/^#{1,6}\s+/.test(n[t]))a.push(s.jsx("h4",{className:"doc-h",children:D(n[t].replace(/^#+\s+/,""))},l++)),t++;else if(i.includes("|")&&t+1<n.length&&re(n[t+1])){const c=W(n[t]),o=W(n[t+1]).map(gs);t+=2;const r=[];for(;t<n.length&&n[t].includes("|")&&n[t].trim()!==""&&!/^```/.test(n[t].trim());)r.push(W(n[t])),t++;a.push(s.jsxs("table",{className:"doc-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:c.map((u,p)=>s.jsx("th",{style:o[p]?{textAlign:o[p]}:void 0,children:D(u)},p))})}),s.jsx("tbody",{children:r.map((u,p)=>s.jsx("tr",{children:c.map((N,x)=>s.jsx("td",{style:o[x]?{textAlign:o[x]}:void 0,children:D(u[x]??"")},x))},p))})]},l++))}else if(/^-\s+/.test(i)){const c=[];for(;t<n.length&&/^-\s+/.test(n[t].trim());)c.push(n[t++].trim().replace(/^-\s+/,""));a.push(s.jsx("ul",{children:c.map((o,r)=>s.jsx("li",{children:D(o)},r))},l++))}else if(i==="")t++;else{const c=[];for(;t<n.length;){const o=n[t];if(o.trim()===""||/^```/.test(o.trim())||/^#{1,6}\s+/.test(o)||/^-\s+/.test(o.trim())||o.includes("|")&&t+1<n.length&&re(n[t+1]))break;c.push(o),t++}a.push(s.jsx("p",{children:D(c.join(" "))},l++))}}return s.jsx("div",{className:"doc-body",children:a})}function ce({kind:e,title:n,owner:a,ownerLabel:t,note:l,children:i}){return s.jsxs("section",{className:`spec-part part-${e}`,children:[s.jsxs("header",{className:"part-head",children:[s.jsx("span",{className:"part-title",children:n}),s.jsx("span",{className:`part-owner owner-${a}`,children:t}),l&&s.jsx("span",{className:"part-note",children:l})]}),s.jsx("div",{className:"part-body",children:i})]})}function js({parts:e}){const n=b();return s.jsxs("div",{className:"spec-parts",children:[s.jsx(ce,{kind:"raw",title:n("nodeView.rawTitle"),owner:"human",ownerLabel:n("nodeView.rawOwner"),note:n("nodeView.rawNote"),children:s.jsx(R,{body:e.rawSource})}),s.jsx(ce,{kind:"expanded",title:n("nodeView.expandedTitle"),owner:"agent",ownerLabel:n("nodeView.expandedOwner"),note:n("nodeView.expandedNote"),children:s.jsx(R,{body:e.expandedSpec})})]})}const q=new Map;function ws(e,n){const a=`${e}@${n??""}`,[t,l]=f.useState(()=>q.get(a)??null);return f.useEffect(()=>{const i=q.get(a);if(i){l(i);return}l(null);let c=!0;return fetch(O(e,"content")).then(o=>o.ok?o.json():Promise.reject(o.status)).then(o=>{q.set(a,o),c&&l(o)}).catch(()=>{c&&l({body:"",parts:null})}),()=>{c=!1}},[e,n,a]),t}function ys({node:e}){var l;const n=b(),a=ws(e.id,e.version),t=(e.driftFiles||[]).map(i=>`${i.file}: ${n("specNode.driftAhead",{n:i.behind})}`).join(`
8
+ `);return s.jsxs("div",{className:"pane-doc",children:[s.jsxs("h1",{children:["# ",e.title]}),s.jsx("blockquote",{children:e.desc}),s.jsxs("div",{className:"doc-stat",children:[s.jsxs("span",{className:`stat-status st-${e.status}`,"data-tip":n("nodeView.statusLabel"),children:[s.jsx("i",{className:"stat-dot"}),n(`status.${e.status}`)]}),s.jsxs("span",{className:"stat-chip","data-tip":n("nodeView.versionLabel"),children:["v",e.version||0]}),s.jsx(Ie,{scenarios:e.scenarios,evals:e.evals}),e.drift>0&&s.jsxs("span",{className:"stat-chip stat-drift","data-tip":t,children:["⚠",e.drift]}),s.jsxs("span",{className:"stat-sess","data-tip":n("nodeView.lastEditedBy"),children:["✎ ",s.jsx("b",{children:e.session||n("common.none")})]})]}),((l=e.code)==null?void 0:l.length)>0?s.jsxs("div",{className:"doc-gov",children:[s.jsxs("span",{className:"doc-gov-h",children:[n("nodeView.governs")," ",s.jsx("b",{children:e.code.length})]}),s.jsx("div",{className:"doc-gov-files",children:e.code.map(i=>s.jsx("code",{className:"gov-f",children:i},i))})]}):s.jsx("div",{className:"doc-gov prose",children:s.jsx("span",{className:"doc-gov-h",children:n("nodeView.proseNode")})}),(()=>{if(a===null&&e.body==null)return s.jsx("div",{className:"pane-loading",children:s.jsx("span",{className:"spinner","aria-label":n("common.loading")})});const i=e.body??(a==null?void 0:a.body)??"",c=e.parts??(a==null?void 0:a.parts)??null;return c?s.jsx(js,{parts:c}):s.jsx(R,{body:i})})()]})}function Ns(e,n=!0){const[a,t]=f.useState(null);return f.useEffect(()=>{if(!n)return;let l=!0;return fetch(O(e,"history")).then(i=>i.json()).then(i=>{l&&t(i)}).catch(()=>l&&t([])),()=>{l=!1}},[e,n]),a}const _=new Map;function bs(e,n,a){const t=`${e}/${n}`,[l,i]=f.useState(()=>_.get(t)??null);return f.useEffect(()=>{const c=_.get(t);if(c){i(c);return}let o=!0;return fetch(O(e,"diff",n)).then(r=>r.json()).then(r=>{_.set(t,r),o&&i(r)}).catch(()=>o&&i({patch:""})),()=>{o=!1}},[e,n,a,t]),l}function ks(e){const n=[];let a=!1;for(const t of e.split(`
9
+ `)){if(t.startsWith("@@")){a=!0,n.push({t:"hunk",s:t});continue}!a||t.startsWith("\\")||(t.startsWith("+")?n.push({t:"add",s:t.slice(1)}):t.startsWith("-")?n.push({t:"del",s:t.slice(1)}):n.push({t:"ctx",s:t.slice(1)}))}for(;n.length&&n[n.length-1].t==="ctx"&&n[n.length-1].s==="";)n.pop();return n}function ke({diff:e}){const n=b();if(e==null)return s.jsx("figcaption",{className:"ev-note",children:n("nodeView.loadingChange")});const a=e.patch?ks(e.patch):[];return a.length?s.jsxs(s.Fragment,{children:[s.jsx("figcaption",{className:"ev-difflabel",children:n("nodeView.diffLabel")}),s.jsx("pre",{className:"ev-diff",children:a.map((t,l)=>s.jsx("div",{className:`dl dl-${t.t}`,children:t.s||" "},l))})]}):s.jsx("figcaption",{className:"ev-note",children:n("nodeView.noChange")})}function $e({items:e,itemKey:n,classes:a,rowClass:t,renderHeader:l,renderEvidence:i,leading:c,trailing:o,resetKey:r}){const u=b(),p=f.useRef(null),[N,x]=f.useState(()=>new Set([0]));f.useEffect(()=>{r!==void 0&&x(new Set([0]))},[r]);const k=f.useCallback(m=>x(v=>{const d=new Set(v);return d.has(m)?d.delete(m):d.add(m),d}),[]),y=f.useCallback(()=>x(m=>{const v=p.current;if(!v)return m;let d=-1;for(;m.has(d+1);)d++;if(d<0||d>=e.length-1)return m;const h=v.querySelector(`[data-i="${d}"]`);return!h||h.getBoundingClientRect().bottom-v.getBoundingClientRect().top>v.clientHeight+40?m:new Set(m).add(d+1)}),[e]);return f.useEffect(()=>{const m=p.current;if(!m)return;let v=m.scrollTop;const d=()=>{const g=m.scrollTop,w=g>v;v=g,w&&y()},h=g=>{g.key!=="j"&&g.key!=="ArrowDown"||m.scrollHeight-m.clientHeight-m.scrollTop>1||y()};return m.addEventListener("scroll",d,{passive:!0}),window.addEventListener("keydown",h,!0),()=>{m.removeEventListener("scroll",d),window.removeEventListener("keydown",h,!0)}},[y]),s.jsxs("div",{className:a.pane,ref:p,children:[e.length>1&&N.size<e.length&&s.jsx("div",{className:"chrono-tools",children:s.jsx("button",{className:"chrono-all",onClick:()=>x(new Set(e.keys())),children:u("nodeView.expandAll",{n:e.length})})}),c,e.map((m,v)=>{const d=N.has(v),h=t?t(m,v):"";return s.jsxs("div",{"data-i":v,className:`${a.row}${h?` ${h}`:""}${d?" open":""}`,children:[s.jsx("button",{className:a.head,onClick:()=>k(v),"aria-expanded":d,children:l(m,v,d)}),d&&s.jsx("figure",{className:a.evidence,children:i(m,v)})]},n(m,v))}),o]})}function $s({node:e,r:n,latest:a}){const t=bs(e.id,n.hash,!0);return s.jsx(ke,{diff:t})}function Ss({node:e,rows:n}){const a=b();return n?n.length?s.jsx($e,{items:n,itemKey:t=>t.hash,classes:{pane:"pane-hist",row:"ver-row",head:"rec-toggle",evidence:"rec-evidence"},rowClass:(t,l)=>l===0?"latest":"",renderHeader:(t,l,i)=>s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rec-head",children:[s.jsx("span",{className:"rec-caret",children:i?"▾":"▸"}),s.jsxs("span",{className:"rec-v",children:["v",n.length-l]}),s.jsx("code",{className:"rec-hash",children:t.hash.slice(0,7)}),s.jsx("span",{className:"rec-date",children:(t.date||"").slice(0,10)}),s.jsxs("span",{className:"rec-diff",children:[s.jsxs("b",{className:"rec-add",children:["+",t.additions??0]}),s.jsxs("b",{className:"rec-del",children:["−",t.deletions??0]})]})]}),s.jsx("div",{className:"rec-msg",children:t.reason}),s.jsxs("div",{className:"rec-sub",children:[a("nodeView.filesChanged",{n:t.files??0})," · ",t.session||a("common.idle")]})]}),renderEvidence:(t,l)=>s.jsx($s,{node:e,r:t,latest:l===0})}):s.jsx("div",{className:"pane-hist empty",children:a("common.noVersions")}):s.jsx("div",{className:"pane-hist empty",children:a("nodeView.loadingHistory")})}function Se({q:e,setQ:n,placeholder:a}){return s.jsx("div",{className:"pane-filter",children:s.jsx("input",{className:"pane-filter-input",value:e,placeholder:a,onChange:t=>n(t.target.value)})})}function Es({node:e}){const n=b(),[a,t]=f.useState(""),l=e.issues||[];if(!l.length)return s.jsx("div",{className:"pane-issues empty",children:n("nodeView.noIssues")});const i=a.trim().toLowerCase(),c=i?l.filter(u=>`${u.id} ${u.concern||""}`.toLowerCase().includes(i)):l,o=c.filter(u=>u.status==="open"),r=c.filter(u=>u.status!=="open");return s.jsxs("div",{className:"pane-issues",children:[l.length>5&&s.jsx(Se,{q:a,setQ:t,placeholder:n("nodeView.filterIssues")}),i&&!c.length&&s.jsx("div",{className:"pane-filter-none",children:n("nodeView.filterNone")}),o.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"issue-group-head",children:n("nodeView.openIssues",{n:o.length})}),o.map(u=>s.jsx(le,{issue:u},u.id))]}),r.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"issue-group-head closed",children:n("nodeView.closedIssues",{n:r.length})}),r.map(u=>s.jsx(le,{issue:u},u.id))]})]})}const U=new Map;function Ms(e,n,a){const t=`${e} ${n}`,[l,i]=f.useState(()=>U.get(t)??null);return f.useEffect(()=>{if(!e||!n)return;const c=U.get(t);c&&i(c);let o=!0;return fetch(`/api/edit?source=${encodeURIComponent(e)}&path=${encodeURIComponent(n)}`).then(r=>r.json()).then(r=>{U.set(t,r),o&&i(r)}).catch(()=>o&&i(r=>r??{patch:""})),()=>{o=!1}},[e,n,a,t]),l}function Cs({node:e,ov:n}){const a=b(),t=Ms(n.source,e.path,!0);return s.jsxs("figure",{className:"edit-rev",children:[s.jsxs("figcaption",{className:"edit-by",children:[s.jsx("span",{className:`ov-mark ov-${n.op}`,children:vs[n.op]||"•"}),s.jsx("span",{className:"edit-by-label",children:n.label}),s.jsx("span",{className:"edit-state",children:n.committed?a("nodeView.editCommitted"):a("nodeView.editDirty")})]}),s.jsx(ke,{diff:t})]})}function Vs({node:e}){const n=b(),a=e.overlays||[];return a.length?s.jsx("div",{className:"pane-edit",children:a.map((t,l)=>s.jsx(Cs,{node:e,ov:t},l))}):s.jsx("div",{className:"pane-edit empty",children:n("nodeView.noEdit")})}function Ls({verdict:e}){const n=b();return e?e.status==="pass"?s.jsx("span",{className:"eval-verdict pass",children:n("nodeView.eval.pass")}):e.status==="fail"?s.jsx("span",{className:"eval-verdict fail",children:n("nodeView.eval.fail")}):s.jsx("span",{className:"eval-verdict note","data-tip":e.note,children:n("nodeView.eval.note")}):s.jsx("span",{className:"eval-verdict legacy",children:n("nodeView.eval.legacy")})}function Fs({r:e}){var t;const n=b(),a=ve(e);return s.jsxs(s.Fragment,{children:[e.expected&&s.jsxs("div",{className:"eval-expected",children:[s.jsx("span",{className:"eval-expected-label",children:n("nodeView.eval.expected")})," ",e.expected]}),((t=e.verdict)==null?void 0:t.note)&&s.jsxs("div",{className:"eval-note",children:[s.jsx("span",{className:"eval-expected-label",children:n("nodeView.eval.noteLabel")})," ",e.verdict.note]}),a.length>0?s.jsx("div",{className:"eval-gallery",style:{display:"flex",flexDirection:"column",gap:8},children:a.map((l,i)=>s.jsx(ge,{e:l,alt:n("nodeView.eval.shotAlt",{scenario:e.scenario})},`${l.hash}-${i}`))}):s.jsx("figcaption",{className:"eval-noimg",children:e.blobState==="miss"?n("nodeView.eval.miss"):n("nodeView.eval.noImage")})]})}function oe({s:e}){var a;const n=b();return s.jsxs("div",{className:"eval-row eval-declared-row",children:[s.jsxs("span",{className:"eval-top",children:[s.jsx(Y,{state:"empty",title:n("score.missing")}),s.jsx("span",{className:"eval-scenario",children:e.name}),s.jsx(Pe,{tags:e.tags}),((a=e.code)==null?void 0:a.length)>0&&s.jsx("code",{className:"eval-tracks",children:e.code.join(", ")})]}),e.expected&&s.jsxs("div",{className:"eval-expected",children:[s.jsx("span",{className:"eval-expected-label",children:n("nodeView.eval.expected")})," ",e.expected]})]})}function de({track:e}){const n=b();return s.jsxs("div",{className:"eval-row eval-dangling-row",children:[s.jsxs("span",{className:"eval-top",children:[s.jsx("span",{className:"eval-dangling-badge","data-tip":n("nodeView.eval.danglingTitle"),children:"⚠"}),s.jsx("span",{className:"eval-scenario eval-dangling-name",children:e.scenario}),s.jsx("span",{className:"eval-dangling-tag",children:n("nodeView.eval.danglingGone")})]}),s.jsx("div",{className:"eval-dangling-remarks",children:s.jsx(ps,{replies:e.remarks})})]})}const H=new Map;function As({node:e}){var y,m,v;const n=b(),[a,t]=f.useState(""),l=`${e.id}@${((m=(y=e.evals)==null?void 0:y[0])==null?void 0:m.ts)||""}:${((v=e.evals)==null?void 0:v.length)||0}`,[i,c]=f.useState(()=>H.get(l)??null);if(f.useEffect(()=>{if(H.has(l)){c(H.get(l));return}let d=!0;return c(null),fetch(O(e.id,"evals")).then(h=>h.ok?h.json():Promise.reject(h.status)).then(h=>{const g={scenarios:h.scenarios||e.scenarios||[],readings:h.readings||[],dangling:h.dangling||[]};H.set(l,g),d&&c(g)}).catch(()=>{d&&c({scenarios:e.scenarios||[],readings:e.evals||[],dangling:[]})}),()=>{d=!1}},[l,e.id]),!e.evals)return s.jsx("div",{className:"pane-eval empty",children:n("nodeView.eval.noScenarios")});if(i===null)return s.jsx("div",{className:"pane-eval pane-loading",children:s.jsx("span",{className:"spinner","aria-label":n("common.loading")})});const o=i.readings,r=a.trim().toLowerCase(),u=d=>!r||(d||"").toLowerCase().includes(r),p=r?o.filter(d=>u(d.scenario)):o,N=(i.dangling||[]).filter(d=>u(d.scenario)),x=Z(i.scenarios,o).filter(d=>!d.reading&&u(d.name)),k=i.readings.length+i.scenarios.length>5?s.jsx(Se,{q:a,setQ:t,placeholder:n("nodeView.filterScenarios")},"filter"):null;return o.length?s.jsx($e,{items:p,resetKey:r,leading:[k,r&&!p.length&&!x.length&&!N.length?s.jsx("div",{className:"pane-filter-none",children:n("nodeView.filterNone")},"none"):null,...x.map(d=>s.jsx(oe,{s:d},d.name))],trailing:N.map(d=>s.jsx(de,{track:d},d.threadId)),itemKey:(d,h)=>`${d.scenario}-${d.ts}-${h}`,classes:{pane:"pane-eval",row:"eval-row",head:"eval-head",evidence:"eval-shot"},renderHeader:(d,h,g)=>s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"eval-top",children:[s.jsx("span",{className:"eval-caret",children:g?"▾":"▸"}),s.jsx("span",{className:"eval-scenario",children:d.scenario}),s.jsx(Ls,{verdict:d.verdict}),s.jsx(Y,{state:pe(d),title:d.fresh?void 0:n("nodeView.eval.staleAxes",{axes:d.staleAxes.join(", ")})})]}),s.jsxs("span",{className:"eval-meta",children:[s.jsx("span",{className:"eval-evaluator",children:d.evaluator}),s.jsx("code",{className:"eval-sha",children:d.codeSha.slice(0,7)}),s.jsx("span",{className:"eval-ts",children:d.ts.replace("T"," ").slice(0,16)})]})]}),renderEvidence:d=>s.jsx(Fs,{r:d})}):s.jsxs("div",{className:"pane-eval pane-eval-declared",children:[k,s.jsx("div",{className:"eval-todo-note",children:r&&!x.length?n("nodeView.filterNone"):n("nodeView.eval.noReadings")}),x.map(d=>s.jsx(oe,{s:d},d.name)),N.map(d=>s.jsx(de,{track:d},d.threadId))]})}const Ds={spec:"nodeView.paneSpec",history:"nodeView.paneHistory",issues:"nodeView.paneIssues",eval:"nodeView.paneEval",edit:"nodeView.paneEdit"};function sn({node:e,pane:n,setPane:a,onClose:t}){const l=b(),i=e.issues||[],c=i.filter(x=>x.status==="open").length,o=i.length-c,r=(e.overlays||[]).length,u=xs(e),p=u.some(x=>x.key===n)?n:u[0].key,N=Ns(e.id,p==="history");return s.jsx("div",{className:"ov-backdrop","data-focus-overlay":!0,onMouseDown:t,children:s.jsxs("div",{className:"ov-panel",onMouseDown:x=>x.stopPropagation(),children:[s.jsxs("div",{className:"ov-head",children:[s.jsx("span",{className:"ov-title",children:e.title}),s.jsx("div",{className:"ov-tabs",children:u.map((x,k)=>s.jsxs("button",{className:x.key===p?"ov-tab on":"ov-tab",onClick:()=>a(x.key),children:[s.jsx("kbd",{children:k+1})," ",l(Ds[x.key]),x.key==="issues"&&(c>0||o>0)&&s.jsxs("span",{className:"ov-tab-counts",children:[c>0&&s.jsx("span",{className:"ovc st-open","data-tip":l("nodeView.openIssues",{n:c}),children:c}),o>0&&s.jsx("span",{className:"ovc st-closed","data-tip":l("nodeView.closedIssues",{n:o}),children:o})]}),x.key==="edit"&&r>0&&s.jsx("span",{className:"ov-tab-counts",children:s.jsx("span",{className:"ovc st-edit","data-tip":l("nodeView.pendingEdits",{n:r}),children:r})})]},x.key))}),s.jsx("span",{className:"ov-hint",children:l("nodeView.hint")})]}),s.jsxs("div",{className:"ov-body",children:[p==="spec"&&s.jsx("div",{className:"pane-solo",children:s.jsx(ys,{node:e})}),p==="history"&&s.jsx(Ss,{node:e,rows:N}),p==="issues"&&s.jsx(Es,{node:e}),p==="eval"&&s.jsx(As,{node:e}),p==="edit"&&s.jsx(Vs,{node:e})]})]})})}const Is=({size:e=12})=>s.jsx(z,{name:"lock",size:e});function Ps(e){if(!e.length)return null;const n={};return e.forEach(a=>{n[a.op]=(n[a.op]||0)+1}),Object.entries(n).map(([a,t])=>`${He[a]}${t}`).join(" ")}function Hs({guides:e=[],expandable:n,expanded:a,rollup:t,kin:l=0,onToggle:i}){return s.jsxs("span",{className:"sess-lead",children:[e.map((c,o)=>{const r=o===e.length-1?c?"tee":"elbow":c?"rail":"gap";return s.jsx("span",{className:`sess-rail ${r}`,"aria-hidden":"true"},o)}),n&&s.jsx("span",{className:`sess-fold pod${a?" open":""}`,role:"button",tabIndex:-1,style:a?{color:t,borderColor:t}:{background:t,borderColor:t},"data-tip":`${l} nested session${l===1?"":"s"} — click to ${a?"collapse":"expand"}`,onClick:c=>{c.stopPropagation(),i==null||i()},onMouseDown:c=>c.stopPropagation(),children:l})]})}function Ts(){const[e,n]=f.useState(()=>new Set);return{expanded:e,toggle:t=>n(l=>{const i=new Set(l);return i.has(t)?i.delete(t):i.add(t),i})}}function Bs({s:e,locked:n,showAvatar:a=!0,compact:t=!1,lead:l=null}){const i=b(),c=Ps(e.ops),o=xe(e),r=i(`status.${e.status}`);return s.jsxs(s.Fragment,{children:[l,a&&s.jsx(Le,{seed:e.id,status:e.status,title:`${Be(e)} · ${r} — ${e.id.slice(0,8)}`}),s.jsxs("span",{className:"sess-meta",children:[t?s.jsx("span",{className:"sess-glyph",style:{color:M[e.status]},"data-tip":r,"aria-label":r,children:Te[e.status]}):s.jsx("span",{className:"sess-status",style:{color:M[e.status]},children:r}),c&&s.jsx("span",{className:"sess-ops",children:c})]}),s.jsx("span",{className:"sess-id","data-tip":o,children:o}),n&&s.jsx("span",{className:"sess-lock","data-tip":i("sessionWindow.lockedTitle"),children:s.jsx(Is,{})})]})}function nn({sessions:e,activeId:n,onPick:a,onOpenSession:t}){const l=b(),{expanded:i,toggle:c}=Ts(),o=f.useMemo(()=>ze(e,r=>i.has(r)),[e,i]);return s.jsx("div",{className:"sesswin",children:e.length===0?s.jsxs("div",{className:"sesswin-empty",children:[l("sessionWindow.emptyBefore"),s.jsx("kbd",{children:"⏎"}),l("sessionWindow.emptyAfter")]}):o.map(r=>{if(r.type==="zone")return s.jsx("div",{className:`sesswin-zone sesswin-zone-${r.zone}`,children:l(`sessionZone.${r.zone}`)},`zone-${r.zone}`);const u=r.s,p=u.source===n,N=r.expandable||r.depth?s.jsx(Hs,{guides:r.guides,expandable:r.expandable,expanded:r.expanded,rollup:r.rollup,kin:r.kin,onToggle:()=>c(u.id)}):null;return s.jsx("button",{className:p?"sess-row locked":"sess-row",style:{"--ov":Ce(u.id)},onClick:()=>a(u),onDoubleClick:()=>t(u.id),"data-tip":l("sessionWindow.rowTitle"),children:s.jsx(Bs,{s:u,locked:p,compact:!0,lead:N})},u.id)})})}export{_s as $,Le as A,_e as B,Ts as C,ze as D,Vs as E,rs as F,He as G,Ss as H,le as I,ne as J,Us as K,Is as L,ls as M,sn as N,qs as O,we as P,ts as Q,Hs as R,Os as S,Pe as T,as as U,ve as V,hs as W,ye as X,Ne as Y,Gs as Z,us as _,Ie as a,ge as a0,ps as a1,Zs as a2,qe as a3,zs as a4,me as a5,Ke as a6,R as a7,is as a8,Te as b,M as c,Z as d,De as e,Xs as f,Ks as g,Js as h,ms as i,Be as j,Qs as k,Ce as l,Y as m,z as n,K as o,en as p,xs as q,nn as r,xe as s,Ns as t,Ys as u,ys as v,Es as w,Bs as x,Ws as y,A as z};
@@ -1 +1 @@
1
- import{n as g,r,j as s,L as u}from"./index-BFdzpd_O.js";import{A as p,k as x,b as j,i as k,r as f,s as N}from"./Dashboard-CMRJGfYI.js";import"./SessionWindow-D7YmjV0i.js";const o="spexcode.theme",b=[{code:"light",label:"settings.theme.light"},{code:"dark",label:"settings.theme.dark"}];function m(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function y(){try{const t=localStorage.getItem(o);if(t==="light"||t==="dark")return t}catch{}return m()}function v(t){const c=t==="light"||t==="dark"?t:m();try{document.documentElement.setAttribute("data-theme",c)}catch{}try{localStorage.setItem(o,c)}catch{}return c}function E({t}){const[c,d]=r.useState(0),[n,i]=r.useState(null),l=()=>d(e=>e+1);return r.useEffect(()=>{if(!n)return;const e=a=>{if(a.preventDefault(),a.stopPropagation(),a.key==="Escape"){i(null);return}["Shift","Control","Alt","Meta"].includes(a.key)||(N(n,{keys:[a.key]}),i(null),l())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n]),s.jsxs("section",{className:"legend-sec",children:[s.jsx("div",{className:"legend-h",children:t("settings.secShortcuts")}),s.jsx("div",{className:"set-keys",children:p.map(e=>s.jsxs("div",{className:"set-key-row",children:[s.jsx("span",{className:"legend-desc",children:t(e.desc)}),s.jsx("button",{className:`bind-cell${n===e.id?" capturing":""}${e.rebind?"":" fixed"}${k(e.id)?" custom":""}`,disabled:!e.rebind,onClick:()=>e.rebind&&i(e.id),children:n===e.id?s.jsx("span",{className:"bind-hint",children:t("settings.bindPrompt")}):x(e.id).map((a,h)=>s.jsx("kbd",{children:j(a)},h))})]},e.id))}),s.jsxs("div",{className:"set-foot",children:[s.jsx("span",{className:"legend-desc set-hint",children:t("settings.shortcutsHint")}),s.jsx("button",{className:"set-reset",onClick:()=>{f(),i(null),l()},children:t("settings.reset")})]})]})}function w(){const{t,lang:c,setLang:d}=g(),[n,i]=r.useState(y),l=e=>{v(e),i(e)};return s.jsx("div",{className:"page-pane page-settings",children:s.jsxs("div",{className:"settings-body",children:[s.jsx("h1",{className:"page-title",children:t("settings.title")}),s.jsxs("section",{className:"legend-sec",children:[s.jsx("div",{className:"legend-h",children:t("settings.secLanguage")}),s.jsx("div",{className:"set-langs",children:u.map(e=>s.jsx("button",{className:e.code===c?"set-lang on":"set-lang",onClick:()=>d(e.code),"aria-pressed":e.code===c,children:e.label},e.code))})]}),s.jsxs("section",{className:"legend-sec",children:[s.jsx("div",{className:"legend-h",children:t("settings.secTheme")}),s.jsx("div",{className:"set-langs",children:b.map(e=>s.jsx("button",{className:e.code===n?"set-lang on":"set-lang",onClick:()=>l(e.code),"aria-pressed":e.code===n,children:t(e.label)},e.code))})]}),s.jsx(E,{t})]})})}export{w as default};
1
+ import{n as g,r,j as s,L as u}from"./index-BO0Zuweu.js";import{A as p,k as x,b as j,i as k,r as f,s as N}from"./Dashboard-BlRRsxE7.js";import"./SessionWindow-Y25Bwg1e.js";const o="spexcode.theme",b=[{code:"light",label:"settings.theme.light"},{code:"dark",label:"settings.theme.dark"}];function m(){try{if(typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function y(){try{const t=localStorage.getItem(o);if(t==="light"||t==="dark")return t}catch{}return m()}function v(t){const c=t==="light"||t==="dark"?t:m();try{document.documentElement.setAttribute("data-theme",c)}catch{}try{localStorage.setItem(o,c)}catch{}return c}function E({t}){const[c,d]=r.useState(0),[n,i]=r.useState(null),l=()=>d(e=>e+1);return r.useEffect(()=>{if(!n)return;const e=a=>{if(a.preventDefault(),a.stopPropagation(),a.key==="Escape"){i(null);return}["Shift","Control","Alt","Meta"].includes(a.key)||(N(n,{keys:[a.key]}),i(null),l())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n]),s.jsxs("section",{className:"legend-sec",children:[s.jsx("div",{className:"legend-h",children:t("settings.secShortcuts")}),s.jsx("div",{className:"set-keys",children:p.map(e=>s.jsxs("div",{className:"set-key-row",children:[s.jsx("span",{className:"legend-desc",children:t(e.desc)}),s.jsx("button",{className:`bind-cell${n===e.id?" capturing":""}${e.rebind?"":" fixed"}${k(e.id)?" custom":""}`,disabled:!e.rebind,onClick:()=>e.rebind&&i(e.id),children:n===e.id?s.jsx("span",{className:"bind-hint",children:t("settings.bindPrompt")}):x(e.id).map((a,h)=>s.jsx("kbd",{children:j(a)},h))})]},e.id))}),s.jsxs("div",{className:"set-foot",children:[s.jsx("span",{className:"legend-desc set-hint",children:t("settings.shortcutsHint")}),s.jsx("button",{className:"set-reset",onClick:()=>{f(),i(null),l()},children:t("settings.reset")})]})]})}function w(){const{t,lang:c,setLang:d}=g(),[n,i]=r.useState(y),l=e=>{v(e),i(e)};return s.jsx("div",{className:"page-pane page-settings",children:s.jsxs("div",{className:"settings-body",children:[s.jsx("h1",{className:"page-title",children:t("settings.title")}),s.jsxs("section",{className:"legend-sec",children:[s.jsx("div",{className:"legend-h",children:t("settings.secLanguage")}),s.jsx("div",{className:"set-langs",children:u.map(e=>s.jsx("button",{className:e.code===c?"set-lang on":"set-lang",onClick:()=>d(e.code),"aria-pressed":e.code===c,children:e.label},e.code))})]}),s.jsxs("section",{className:"legend-sec",children:[s.jsx("div",{className:"legend-h",children:t("settings.secTheme")}),s.jsx("div",{className:"set-langs",children:b.map(e=>s.jsx("button",{className:e.code===n?"set-lang on":"set-lang",onClick:()=>l(e.code),"aria-pressed":e.code===n,children:t(e.label)},e.code))})]}),s.jsx(E,{t})]})})}export{w as default};