@spexcode/spec-dashboard 0.7.0-next.5 → 0.7.0-next.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.
- package/dist/assets/{App-CLBephD0.js → App-CgqiczQU.js} +2 -2
- package/{dist-public/assets/EmptyView-3cd-Qka8.js → dist/assets/EmptyView-BoZpYngO.js} +1 -1
- package/{dist-public/assets/EvalsPage-g6ePUcoF.js → dist/assets/EvalsPage-C589qwY-.js} +1 -1
- package/dist/assets/{FileView-Bj5kgfsJ.js → FileView-Cv9PwOe9.js} +2 -2
- package/dist/assets/{GraphView-6N90uqqA.js → GraphView-DJsYIawj.js} +3 -3
- package/dist/assets/{IssuesPage-B9rIGP0u.js → IssuesPage-CSzeNfdJ.js} +1 -1
- package/dist/assets/{MobileApp-D_uT9zos.js → MobileApp-SMfj4uYR.js} +2 -2
- package/dist/assets/{Modal-DvlvxJOY.js → Modal-ByQRzOqM.js} +1 -1
- package/dist/assets/{NodeView-Dj8M9ErH.js → NodeView-CEEKTA7o.js} +1 -1
- package/{dist-public/assets/ProjectsPage-BxpnvHxu.js → dist/assets/ProjectsPage-DHAuS8_X.js} +1 -1
- package/dist/assets/{ProseActions-81JCN4TL.js → ProseActions-C-bJtCW1.js} +1 -1
- package/dist/assets/{Settings-DATSlER3.js → Settings-CWK6ZLUk.js} +1 -1
- package/dist/assets/{SpecView-BEkgRAQg.js → SpecView-fHCntk65.js} +1 -1
- package/dist/assets/{Thread-DKGlbWE6.js → Thread-DsQYxUwv.js} +1 -1
- package/dist/assets/{WorkspaceSurface-B7MYY74h.js → WorkspaceSurface-8ATlQvk9.js} +1 -1
- package/{dist-public/assets/index-CV4Crm4u.js → dist/assets/index-C9sSKtKD.js} +1 -1
- package/dist/assets/index-CjNin6fF.css +1 -0
- package/dist/assets/{index-Gf6Wit6X.js → index-DWjEd9Wj.js} +1 -1
- package/dist/assets/{tabs-Dyh4ltQM.js → tabs-OpePwMY6.js} +35 -35
- package/dist/index.html +2 -2
- package/dist-public/assets/{App-Ca4rD0l6.js → App-3JGnClSw.js} +2 -2
- package/{dist/assets/EmptyView-BaVFZV0p.js → dist-public/assets/EmptyView-mbUwzcHs.js} +1 -1
- package/{dist/assets/EvalsPage-C6TwBtpU.js → dist-public/assets/EvalsPage-BeOAOo_5.js} +1 -1
- package/dist-public/assets/{FileView-CnoTb555.js → FileView-COLZ_BGl.js} +2 -2
- package/dist-public/assets/{GraphView-Da_dzcwl.js → GraphView-a7jPEWZk.js} +3 -3
- package/dist-public/assets/{IssuesPage-B_dUE82p.js → IssuesPage-DNBzN27P.js} +1 -1
- package/dist-public/assets/{MobileApp-BOX9KS1W.js → MobileApp-iDXXWSru.js} +2 -2
- package/dist-public/assets/{Modal-BGWxLjyp.js → Modal-Ad9WLLpE.js} +1 -1
- package/dist-public/assets/{NodeView-BkrqHVId.js → NodeView-BGMmOGnz.js} +1 -1
- package/{dist/assets/ProjectsPage-e257fgBn.js → dist-public/assets/ProjectsPage-DYYj103n.js} +1 -1
- package/dist-public/assets/{ProseActions-Dg5811-x.js → ProseActions-CtsaOmOH.js} +1 -1
- package/dist-public/assets/{Settings-BJyujQT2.js → Settings-PPqYk0On.js} +1 -1
- package/dist-public/assets/{SpecView-D6VVSnj5.js → SpecView-C0dMuBMI.js} +1 -1
- package/dist-public/assets/{Thread-CMk3239q.js → Thread-D8UYH4Pd.js} +1 -1
- package/dist-public/assets/{WorkspaceSurface-nI92VHVO.js → WorkspaceSurface-BtDKJCEB.js} +1 -1
- package/dist-public/assets/{index-CqFflSD2.js → index-Ci7vTowK.js} +1 -1
- package/dist-public/assets/index-CjNin6fF.css +1 -0
- package/{dist/assets/index-CKu8PILr.js → dist-public/assets/index-DFVns2nY.js} +1 -1
- package/dist-public/assets/{tabs-hNUMIEYw.js → tabs-8BxPl2CU.js} +35 -35
- package/dist-public/index.html +2 -2
- package/package.json +6 -6
- package/dist/assets/index-DL_PG3iP.css +0 -1
- package/dist-public/assets/index-DL_PG3iP.css +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkspaceSurface-
|
|
2
|
-
import{u as ee,r as o,j as c,I as ke,a as Ue,P as _,b as De,_ as K,c as Be,l as ze,d as Fe,e as $,s as qe,p as He}from"./index-Gf6Wit6X.js";const L=async e=>(e.headers.get("content-type")||"").includes("json")?e.json().catch(()=>null):null,We=5e3,xe=(e,t,s)=>({title:typeof(e==null?void 0:e.title)=="string"&&e.title?e.title:t,icon:typeof(e==null?void 0:e.icon)=="string"&&e.icon?e.icon:s});function H(e){if(!e||typeof e!="object")return null;const t=e.id??e.projectId;return t?{id:String(t),identity:xe(e.identity||{title:e.name,icon:e.icon},e.name||String(t),"spexcode"),root:typeof e.root=="string"?e.root:"",online:typeof e.online=="boolean"?e.online:null,url:e.url||"",port:e.port??null,gated:!!(e.gated??e.locked??e.hasPassword),configRevision:typeof e.configRevision=="string"?e.configRevision:""}:null}const Ge=e=>{const t=Array.isArray(e)?e:Array.isArray(e==null?void 0:e.projects)?e.projects:null;return t?t.map(H).filter(Boolean):null},Ke=10;function Pt(e,t,s=Ke){const n=Array.isArray(e)?e:[],r=Math.max(1,Math.ceil(n.length/s)),a=Math.min(Math.max(1,Number.isInteger(t)?t:1),r);return{items:n.slice((a-1)*s,a*s),page:a,pageCount:r}}function Qe(e,t,s){var n;if(!e)return s;if(!t)return null;if(t.state==="ok"){const r=(n=t.projects)==null?void 0:n.find(a=>a.id===e);return(r==null?void 0:r.identity)||{title:e,icon:"spexcode"}}return{title:(s==null?void 0:s.title)||e,icon:(s==null?void 0:s.icon)||"spexcode"}}const Ye=e=>(e==null?void 0:e.state)==="ok"?e.gateway.identity:{title:"Projects",icon:"gateway"},Ze=e=>(e==null?void 0:e.title)||"SpexCode",ae=(e,t)=>(t==null?void 0:t.state)==="absent"&&e&&e.state!=="absent"?e:t;async function Je(){let e;try{e=await fetch("/projects",{cache:"no-store",headers:{Accept:"application/json"}})}catch{return{state:"absent"}}if(e.status===401)return{state:"denied",reason:"admin-login"};if(e.status===403)return{state:"denied",reason:"locked"};if(!e.ok)return{state:"absent"};const t=await L(e),s=Ge(t);if(!s)return{state:"absent"};const n=t!=null&&t.gateway&&typeof t.gateway=="object"?{identity:xe(t.gateway,"Projects","gateway"),revision:typeof t.gateway.revision=="string"?t.gateway.revision:""}:{identity:{title:"Projects",icon:"gateway"},revision:""};return{state:"ok",adminGated:!!(t!=null&&t.adminGated),gateway:n,projects:s}}async function Lt(e,{timeoutMs:t=2500}={}){try{const s=await fetch(`/p/${encodeURIComponent(e)}/health`,{cache:"no-store",signal:AbortSignal.timeout(t)});return!s.ok||s.redirected?"unreachable":(await s.text()).trim()==="ok"?"running":"unreachable"}catch{return"unreachable"}}async function Q(e,t,s){let n;try{n=await fetch(e,{method:t,headers:{"Content-Type":"application/json",Accept:"application/json"},...t==="PUT"?{body:JSON.stringify({password:s})}:{}})}catch{return{ok:!1,error:"network"}}const r=await L(n)||{};return{ok:n.ok&&r.ok!==!1,status:n.status,...r.error?{error:r.error}:{}}}const It=(e,t)=>Q(`/projects/${encodeURIComponent(e)}/password`,"PUT",t),At=e=>Q(`/projects/${encodeURIComponent(e)}/password`,"DELETE"),Rt=e=>Q("/projects/admin-password","PUT",e),$t=()=>Q("/projects/admin-password","DELETE");async function Ve(e,t){const s=e==="admin"?"/login":`/p/${encodeURIComponent(e.projectId)}/login`;let n;try{n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:t})})}catch{return{ok:!1,error:"network"}}return n.status===401?{ok:!1,error:"wrong-password"}:n.status===403?{ok:!1,error:"locked"}:n.ok||n.redirected?{ok:!0}:{ok:!1,error:`http-${n.status}`}}async function _t(e=""){let t;try{const n=e?`?path=${encodeURIComponent(e)}`:"";t=await fetch(`/projects/browse${n}`,{cache:"no-store",headers:{Accept:"application/json"}})}catch{return{ok:!1,error:"network"}}const s=await L(t);return t.ok?typeof(s==null?void 0:s.path)!="string"||!Array.isArray(s==null?void 0:s.entries)?{ok:!1,error:"unexpected answer"}:{ok:!0,path:s.path,exists:s.exists!==!1,parent:typeof s.parent=="string"?s.parent:null,home:typeof s.home=="string"?s.home:s.path,gitRoot:typeof s.gitRoot=="string"?s.gitRoot:null,initialized:!!s.initialized,cataloged:!!s.cataloged,entries:s.entries.filter(n=>n&&typeof n.name=="string"&&typeof n.path=="string").map(n=>({name:n.name,path:n.path,git:!!n.git,initialized:!!n.initialized}))}:{ok:!1,status:t.status,error:(s==null?void 0:s.error)||`http-${t.status}`}}async function Tt(e,t={}){let s;try{s=await fetch("/projects",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({root:e,...t})})}catch{return{ok:!1,error:"network"}}const n=await L(s);if(!s.ok)return{ok:!1,status:s.status,error:(n==null?void 0:n.error)||`http-${s.status}`,...n!=null&&n.init&&typeof n.init=="object"?{code:n.init.code??null,output:String(n.init.output??"")}:{}};const r=H(n);return r?{ok:!0,project:r,setup:n.setup??null}:{ok:!1,error:"unexpected answer"}}async function Ot(e,t){let s;try{s=await fetch(`/projects/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({confirmation:t})})}catch{return{ok:!1,error:"network"}}const n=await L(s);return s.ok?{ok:(n==null?void 0:n.ok)===!0,...n||{}}:{ok:!1,status:s.status,error:(n==null?void 0:n.error)||`http-${s.status}`}}async function Nt(e){let t;try{t=await fetch(`/projects/${encodeURIComponent(e)}/config`,{cache:"no-store",headers:{Accept:"application/json"}})}catch{return{ok:!1,error:"network"}}const s=await L(t);return t.ok?typeof(s==null?void 0:s.content)!="string"||typeof(s==null?void 0:s.revision)!="string"?{ok:!1,error:"unexpected answer"}:{ok:!0,content:s.content,revision:s.revision}:{ok:!1,status:t.status,error:(s==null?void 0:s.error)||`http-${t.status}`}}async function Mt(e,t,s){let n;try{n=await fetch(`/projects/${encodeURIComponent(e)}/config`,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:t,revision:s})})}catch{return{ok:!1,error:"network"}}const r=await L(n);return n.ok?typeof(r==null?void 0:r.content)!="string"||typeof(r==null?void 0:r.revision)!="string"?{ok:!1,error:"unexpected answer"}:{ok:!0,content:r.content,revision:r.revision}:{ok:!1,status:n.status,error:(r==null?void 0:r.error)||`http-${n.status}`}}async function Se(e,t,s){let n;try{n=await fetch(e,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({icon:t,revision:s})})}catch{return{ok:!1,error:"network"}}const r=await L(n);return n.ok?{ok:!0,...r}:{ok:!1,status:n.status,error:(r==null?void 0:r.error)||`http-${n.status}`}}const Ut=(e,t)=>Se("/projects/icon",e,t),Dt=(e,t,s)=>Se(`/projects/${encodeURIComponent(e)}/icon`,t,s);async function ve(e,t,s={}){let n;try{n=await fetch(`/projects/${encodeURIComponent(e)}/${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(s)})}catch{return{ok:!1,error:"network"}}const r=await L(n);return n.ok?!r||typeof r!="object"?{ok:!1,error:"unexpected answer"}:{ok:r.ok===!0,code:r.code??null,output:String(r.output??"")}:{ok:!1,status:n.status,error:(r==null?void 0:r.error)||`http-${n.status}`}}const Bt=(e,t)=>ve(e,"init",{harness:t}),zt=e=>ve(e,"doctor");async function Ft(e){let t;try{t=await fetch(`/projects/${encodeURIComponent(e)}/serve`,{method:"POST",headers:{Accept:"application/json"}})}catch{return{ok:!1,error:"network"}}const s=await L(t);return t.status===409?{ok:!0,already:!0,project:H(s==null?void 0:s.project)}:t.ok?{ok:!0,project:H(s==null?void 0:s.project)}:{ok:!1,status:t.status,error:(s==null?void 0:s.error)||`http-${t.status}`}}function J({scope:e,projectLabel:t,locked:s,onUnlocked:n}){const r=ee(),[a,i]=o.useState(""),[u,f]=o.useState(!1),[k,E]=o.useState(null),v=e==="admin",b=async p=>{if(p.preventDefault(),!a||u)return;f(!0),E(null);const j=await Ve(v?"admin":{projectId:e.projectId},a);f(!1),j.ok?(i(""),n()):E(j.error==="wrong-password"?r("credential.wrong"):r("credential.failed"))};return c.jsx("div",{className:"cred-wrap",children:c.jsxs("form",{className:"cred-card",onSubmit:b,children:[c.jsx("div",{className:"cred-brand",children:"$ spexcode"}),c.jsxs("div",{className:"cred-title",children:[c.jsx(ke,{name:"lock",size:14,className:"cred-lock"}),s?r("credential.lockedTitle"):v?r("credential.adminTitle"):r("credential.projectTitle",{name:t||e&&e.projectId||""})]}),s?c.jsx("p",{className:"cred-sub",children:r("credential.lockedBody")}):c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"cred-sub",children:r(v?"credential.adminBody":"credential.projectBody")}),k&&c.jsx("div",{className:"cred-err",children:k}),c.jsx("input",{className:"cred-input",type:"password",autoFocus:!0,required:!0,placeholder:"••••••••••","aria-label":r("credential.passwordLabel"),value:a,onChange:p=>i(p.target.value)}),c.jsx("button",{className:"cred-submit",type:"submit",disabled:u||!a,children:r(u?"credential.checking":"credential.unlock")})]})]})})}const ce="(max-width: 640px)";function Xe(){const[e,t]=o.useState(()=>typeof window<"u"&&window.matchMedia(ce).matches);return o.useEffect(()=>{const s=window.matchMedia(ce),n=()=>t(s.matches);return s.addEventListener("change",n),()=>s.removeEventListener("change",n)},[]),e}const D="spexcode",et="gateway",te=Object.freeze([{id:"spexcode",label:"SpexCode",bg:"#12161C",fg:"#EFE8D8",shapes:[{tag:"path",d:"M 4.500,4.500 L 9.750,4.500 L 9.750,6.656 L 6.656,6.656 L 6.656,17.344 L 9.750,17.344 L 9.750,19.500 L 4.500,19.500 Z",fill:"#EFE8D8",stroke:"none"},{tag:"path",d:"M 19.500,4.500 L 14.250,4.500 L 14.250,6.656 L 17.344,6.656 L 17.344,17.344 L 14.250,17.344 L 14.250,19.500 L 19.500,19.500 Z",fill:"#EFE8D8",stroke:"none"},{tag:"path",d:"M 15.281,15.281 L 11.731,13.057 L 12.269,10.943 L 8.719,8.719 L 8.719,15.281 Z",fill:"#327D95",stroke:"none"},{tag:"path",d:"M 8.719,8.719 L 12.269,10.943 L 11.731,13.057 L 15.281,15.281 L 15.281,12.000 L 12.000,8.719 Z",fill:"#82C3D6",stroke:"none"},{tag:"path",d:"M 8.569,8.957 L 11.946,11.073 L 11.408,13.186 L 15.132,15.520 L 15.431,15.043 L 12.054,12.927 L 12.592,10.814 L 8.868,8.480 Z",fill:"#E4F7FD",stroke:"none"}]},{id:"gateway",label:"Gateway",bg:"#155e75",fg:"#ecfeff",shapes:[{tag:"path",d:"m12 3 8 4.2-8 4.2-8-4.2Z"},{tag:"path",d:"m4 11.2 8 4.2 8-4.2"},{tag:"path",d:"m4 15.2 8 4.2 8-4.2"}]},{id:"mdi:rocket-launch",label:"Rocket",bg:"#9f1239",fg:"#fff1f2",shapes:[{tag:"path",d:"M14.5 5.2c2.2-2.2 4.8-2 5.3-1.8.2.5.4 3.1-1.8 5.3l-5.5 5.5-4.2-4.2Z"},{tag:"path",d:"m11.2 6.8-4.1.6-2.5 2.5 4.1.7"},{tag:"path",d:"m16.4 12-1 4.7-2.5 2.5-.7-4.1"},{tag:"circle",cx:16.1,cy:7.1,r:1.2},{tag:"path",d:"M7.6 14.6c-2.2.4-3.4 1.6-3.6 3.8 2.2-.2 3.4-1.4 3.8-3.6"}]},{id:"compass",label:"Compass",bg:"#1d4ed8",fg:"#eff6ff",shapes:[{tag:"circle",cx:12,cy:12,r:8.5},{tag:"path",d:"m15.2 8.8-1.8 4.6-4.6 1.8 1.8-4.6Z"}]},{id:"terminal",label:"Terminal",bg:"#3f3f46",fg:"#fafafa",shapes:[{tag:"rect",x:3.5,y:4.5,width:17,height:15,rx:2},{tag:"path",d:"m7 9 3 3-3 3"},{tag:"path",d:"M12.5 15H17"}]},{id:"package",label:"Package",bg:"#6d28d9",fg:"#f5f3ff",shapes:[{tag:"path",d:"m12 3 8 4.5v9L12 21l-8-4.5v-9Z"},{tag:"path",d:"m4.3 7.7 7.7 4.4 7.7-4.4"},{tag:"path",d:"M12 12.1V21"}]},{id:"database",label:"Database",bg:"#a16207",fg:"#fefce8",shapes:[{tag:"ellipse",cx:12,cy:6,rx:7.5,ry:3},{tag:"path",d:"M4.5 6v6c0 1.7 3.4 3 7.5 3s7.5-1.3 7.5-3V6"},{tag:"path",d:"M4.5 12v6c0 1.7 3.4 3 7.5 3s7.5-1.3 7.5-3v-6"}]},{id:"spark",label:"Spark",bg:"#c2410c",fg:"#fff7ed",shapes:[{tag:"path",d:"m12 3 1.5 5.2L19 10l-5.5 1.8L12 17l-1.5-5.2L5 10l5.5-1.8Z"},{tag:"path",d:"m18.5 15 .7 2.2 2.3.8-2.3.8-.7 2.2-.7-2.2-2.3-.8 2.3-.8Z"}]}]),tt=new Map(te.map(e=>[e.id,e])),st=/^[a-z0-9-]+[:/][a-z0-9-]+$/i,be=new Map([["rocket","mdi:rocket-launch"],["mdi/rocket-launch","mdi:rocket-launch"],["layers","gateway"],["default","spexcode"]]);Object.freeze(te.map(e=>e.id));function nt(e,t=D){const s=typeof e=="string"?e.trim():"";return be.get(s)||s||t}function z(e){const t=typeof e=="string"?e.trim():"";return tt.get(be.get(t)||t)||null}function W(e){return st.test(typeof e=="string"?e.trim():"")}function rt(e){return Object.entries(e).filter(([t])=>t!=="tag").map(([t,s])=>`${t==="className"?"class":t}="${String(s).replaceAll("&","&").replaceAll('"',""")}"`).join(" ")}function ot(e,t=D){const s=z(e)||z(t),n=s.shapes.map(r=>`<${r.tag} ${rt(r)}/>`).join("");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="1" y="1" width="22" height="22" rx="5" fill="${s.bg}"/><g fill="none" stroke="${s.fg}" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">${n}</g></svg>`}function F(e,t=D){const s=nt(e,t);if(z(s))return`data:image/svg+xml,${encodeURIComponent(ot(s,t))}`;if(/^https?:\/\//.test(s))return s;if(W(s))return`https://api.iconify.design/${s.replace(":","/")}.svg`;const n=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text x="50" y=".86em" font-size="82" text-anchor="middle">${s.replaceAll("&","&").replaceAll("<","<")}</text></svg>`;return`data:image/svg+xml,${encodeURIComponent(n)}`}const at=F,V=[{id:"featured",label:"projects.iconSourceFeatured"},{id:"material",label:"projects.iconSourceMaterial",prefixes:"mdi,material-symbols"},{id:"lucide",label:"projects.iconSourceLucide",prefixes:"lucide"},{id:"tabler",label:"projects.iconSourceTabler",prefixes:"tabler"},{id:"phosphor",label:"projects.iconSourcePhosphor",prefixes:"ph"},{id:"brands",label:"projects.iconSourceBrands",prefixes:"simple-icons"}],ct=e=>e.split("-").filter(Boolean).map(t=>{var s;return((s=t[0])==null?void 0:s.toUpperCase())+t.slice(1)}).join(" ");function ie(e,t={}){var a;const s=e.replace("/",":"),[n,r]=s.split(":");return{id:s,label:ct(r),source:((a=t[n])==null?void 0:a.name)||n}}function le({icon:e,fallback:t=D,size:s=24,className:n,label:r}){const a=z(e);return!a&&W(e)?c.jsx("span",{className:n?`identity-iconify ${n}`:"identity-iconify",style:{width:s,height:s,maskImage:`url("${F(e,t)}")`,WebkitMaskImage:`url("${F(e,t)}")`},role:r?"img":void 0,"aria-label":r||void 0,"aria-hidden":r?void 0:!0}):a?c.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",className:n,role:r?"img":void 0,"aria-label":r||void 0,"aria-hidden":r?void 0:!0,children:[c.jsx("rect",{x:"1",y:"1",width:"22",height:"22",rx:"5",fill:a.bg}),c.jsx("g",{fill:"none",stroke:a.fg,strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:a.shapes.map(({tag:i,...u},f)=>c.jsx(i,{...u},f))})]}):c.jsx("img",{width:s,height:s,src:F(e,t),className:n,alt:r||"","aria-hidden":r?void 0:!0})}function qt({value:e,onChange:t,label:s,editLabel:n,name:r,fallback:a=D,disabled:i=!1}){const u=ee(),[f,k]=o.useState(!1),[E,v]=o.useState(""),[b,p]=o.useState("featured"),[j,x]=o.useState({state:"idle",choices:[]}),O=o.useId(),l=z(e),h=V.find(d=>d.id===b)||V[0];o.useEffect(()=>{if(!f)return;const d=E.trim(),y=d.length>=2?d:b==="featured"?"":"project";if(!y){x({state:"idle",choices:[]});return}const B=new AbortController;x({state:"loading",choices:[]});const oe=setTimeout(async()=>{try{const N=new URLSearchParams({query:y,limit:"48"});h.prefixes&&N.set("prefixes",h.prefixes);const g=await fetch(`https://api.iconify.design/search?${N}`,{signal:B.signal});if(!g.ok)throw new Error(`Iconify search answered ${g.status}`);const m=await g.json();if(!Array.isArray(m.icons))throw new Error("Iconify search returned an invalid response");x({state:"ready",choices:m.icons.filter(W).map(S=>ie(S,m.collections))})}catch(N){N.name!=="AbortError"&&x({state:"error",choices:[]})}},220);return()=>{clearTimeout(oe),B.abort()}},[f,E,b,h.prefixes]);const C=()=>{k(!1),v(""),p("featured"),x({state:"idle",choices:[]})},I=async d=>{await t(d)!==!1&&C()},w=E.trim().toLowerCase(),A=te.filter(d=>!w||d.label.toLowerCase().includes(w)||d.id.includes(w)).map(d=>({id:d.id,label:d.label,source:""}));let R=j.state==="ready"?j.choices:b==="featured"?A:[];return W(e)&&!R.some(d=>d.id===e.replace("/",":"))&&(R=[ie(e),...R]),c.jsxs("div",{className:f?"identity-control open":"identity-control",children:[c.jsxs("div",{className:"identity-disclosure",children:[c.jsx(le,{icon:e,fallback:a,size:26,label:`${s}: ${(l==null?void 0:l.label)||e||a}`}),c.jsx(Ue,{icon:"pencil",label:n,className:"proj-act icon identity-edit",size:13,disabled:i,"aria-expanded":f,"aria-controls":O,onClick:()=>{f?C():k(!0)}})]}),f&&c.jsxs("fieldset",{id:O,className:"identity-picker",disabled:i,children:[c.jsx("legend",{children:s}),c.jsxs("div",{className:"identity-search",children:[c.jsx(ke,{name:"search",size:14}),c.jsx("input",{type:"search",value:E,onChange:d=>v(d.target.value),placeholder:u("projects.iconSearch"),"aria-label":u("projects.iconSearch"),spellCheck:!1})]}),c.jsx("div",{className:"identity-sources",role:"group","aria-label":u("projects.iconSources"),children:V.map(d=>c.jsx("button",{type:"button",className:b===d.id?"identity-source on":"identity-source","aria-pressed":b===d.id,onClick:()=>p(d.id),children:u(d.label)},d.id))}),c.jsx("div",{className:"identity-options",children:R.map(d=>c.jsxs("label",{className:"identity-choice",children:[c.jsx("input",{type:"radio",name:r,value:d.id,checked:e.replace("/",":")===d.id,onChange:()=>I(d.id)}),c.jsx(le,{icon:d.id,size:28}),c.jsx("span",{className:"identity-choice-name",children:d.label}),d.source&&c.jsx("span",{className:"identity-choice-source",children:d.source})]},d.id))}),j.state==="loading"&&c.jsx("div",{className:"identity-search-status",role:"status",children:u("projects.iconSearching")}),j.state==="ready"&&!R.length&&c.jsx("div",{className:"identity-search-status",children:u("projects.iconSearchEmpty")}),j.state==="error"&&c.jsx("div",{className:"identity-search-status error",role:"alert",children:u("projects.iconSearchFailed")})]})]})}const G=o.createContext(null),Ee=o.createContext(null);function ue({value:e,reload:t,children:s}){const n=o.useMemo(()=>({reload:t}),[t]);return c.jsx(Ee.Provider,{value:n,children:c.jsx(G.Provider,{value:e,children:s})})}const Ht=()=>o.useContext(G)||{},Wt=()=>o.useContext(Ee)||{},Ce=o.createContext(null),Pe=o.createContext(null),de="spexcode.dock",pe="spexcode.dockMode",X="spexcode.split";function fe({children:e}){const[t,s]=o.useState(()=>{try{return localStorage.getItem(de)!=="0"}catch{return!0}}),[n,r]=o.useState(()=>{try{return localStorage.getItem(pe)==="sessions"?"sessions":"explorer"}catch{return"explorer"}}),[a,i]=o.useState(null),[u,f]=o.useState(()=>{try{const l=JSON.parse(localStorage.getItem(X)||"null");return l!=null&&l.page?l:null}catch{return null}}),[k,E]=o.useState(null),[v,b]=o.useState(!1),p=o.useRef(null),j=o.useRef(new Set),x=o.useMemo(()=>({setDock:l=>s(h=>{const C=typeof l=="function"?l(h):l;try{localStorage.setItem(de,C?"1":"0")}catch{}return C}),setDockMode:l=>r(h=>{const C=l==="sessions"?"sessions":"explorer";try{localStorage.setItem(pe,C)}catch{}return C===h?h:C}),openPalette:l=>i(l),closePalette:()=>i(null),toggleHelp:()=>b(l=>!l),closeHelp:()=>b(!1),setCompose:l=>{p.current=l;for(const h of[...j.current])h()},takeCompose:()=>{const l=p.current;return p.current=null,l},watchCompose:l=>(j.current.add(l),()=>{j.current.delete(l)}),splitTo:l=>f(()=>{const h=l!=null&&l.page?{page:l.page,param:l.param??null,query:l.query??null}:null;try{localStorage.setItem(X,JSON.stringify(h))}catch{}return h}),closeSplit:()=>f(()=>{try{localStorage.removeItem(X)}catch{}return null}),lockGraphTo:(l,{toggle:h=!0}={})=>E(C=>h&&C===l?null:l||null)}),[]),O=o.useMemo(()=>({dock:t,dockMode:n,palette:a,split:u,lockedSource:k,helpOpen:v}),[t,n,a,u,k,v]);return c.jsx(Pe.Provider,{value:x,children:c.jsx(Ce.Provider,{value:O,children:e})})}const Gt=()=>o.useContext(Ce)||{},Kt=()=>o.useContext(Pe)||{},se=o.createContext(null);function Qt({value:e,children:t}){const s=o.useContext(G),n=o.useRef(s);return e.active&&(n.current=s),c.jsx(se.Provider,{value:e,children:c.jsx(G.Provider,{value:e.active?s:n.current,children:t})})}const it=()=>{var e;return((e=o.useContext(se))==null?void 0:e.active)!==!1},Yt=()=>{var e;return((e=o.useContext(se))==null?void 0:e.address)??null},q=typeof window<"u"?window.__escStack||(window.__escStack=[]):[];function lt(e){const t=typeof window<"u"?window.__escStack:q;return(e==null?void 0:e.key)!=="Escape"||!t||t.length===0?!1:(e.preventDefault(),t[t.length-1].close(),!0)}function Zt(e,t){const s=o.useRef(t);s.current=t,o.useEffect(()=>{if(!e)return;const n={close:()=>{var r;return(r=s.current)==null?void 0:r.call(s)}};return q.push(n),()=>{const r=q.indexOf(n);r>=0&&q.splice(r,1)}},[e])}const Le=o.createContext(null);function ut(e){var t;return e?e.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(e.tagName)?!0:!!((t=e.closest)!=null&&t.call(e,'input, textarea, select, [contenteditable=""], [contenteditable="true"]')):!1}function dt(e,t=!1){return t||e!=null&&e.altKey||e!=null&&e.ctrlKey||e!=null&&e.metaKey?!0:!ut(e==null?void 0:e.target)}function he({children:e}){const t=o.useRef(new Map),s=o.useRef(0),n=o.useCallback((a,i=0)=>{const u=++s.current;return t.current.set(u,{handler:a,priority:i}),()=>t.current.delete(u)},[]),r=o.useMemo(()=>({register:n}),[n]);return o.useEffect(()=>{const a=i=>{if(lt(i)){i.stopPropagation();return}const u=[...t.current.entries()].sort((f,k)=>k[1].priority-f[1].priority||k[0]-f[0]);for(const[,f]of u)if(f.handler(i)||i.cancelBubble){i.stopPropagation();return}};return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[]),c.jsx(Le.Provider,{value:r,children:e})}function Jt(e,t=0,{allowTyping:s=!1}={}){const{register:n}=o.useContext(Le)||{},r=it(),a=o.useRef(e);a.current=e,o.useEffect(()=>{if(!(!n||!r))return n(i=>dt(i,s)&&a.current(i),t)},[n,t,r,s])}const Ie="is:issue state:open",ne="is:eval",Ae=e=>Y(ne,"scope",e),Vt=e=>Y(ne,"node",e),Xt=e=>Y(Ie,"node",e),Re=/^([A-Za-z][A-Za-z0-9-]*):(.*)$/s,ge=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e,$e=e=>/\s/.test(String(e))?`"${e}"`:String(e);function _e(e){const t=String(e??""),s=[];let n=0;for(;n<t.length;){let r=n;if(/\s/.test(t[n])){for(;r<t.length&&/\s/.test(t[r]);)r++;s.push({ws:!0,raw:t.slice(n,r),start:n,end:r})}else{for(;r<t.length&&!/\s/.test(t[r]);)if(t[r]==='"'){for(r++;r<t.length&&t[r]!=='"';)r++;r<t.length&&r++}else r++;const a=t.slice(n,r),i=Re.exec(a);s.push(i?{ws:!1,raw:a,start:n,end:r,key:i[1].toLowerCase(),value:ge(i[2])}:{ws:!1,raw:a,start:n,end:r,key:null,value:ge(a)})}n=r}return s}const re=e=>_e(e).filter(t=>!t.ws),Te=e=>e.map(t=>t.raw).join(" "),me=e=>Te(re(e)),Oe=(e,t)=>me(e)===me(t),es=(e,t)=>{const s=re(e);for(let n=s.length-1;n>=0;n--)if(s[n].key===t)return s[n].value;return""};function Y(e,t,s){const n=s==null||String(s)===""?null:{ws:!1,raw:`${t}:${$e(s)}`,key:t,value:String(s)},r=[];let a=!1;for(const i of re(e)){if(i.key===t){n&&!a&&(r.push(n),a=!0);continue}r.push(i)}return n&&!a&&r.push(n),Te(r)}const pt=(e,t)=>{const s=String(e??"").trim();return!s||Oe(s,t)?null:{q:s}},ts=(e,t,s=null)=>{const n=pt(e,t)||{};return s!=null&&(n.page=String(s)),Object.keys(n).length?n:null},Ne={state:e=>["state",e],concluded:e=>e==="1"?["state","closed"]:null,ok:e=>e==="1"?["state","reviewed"]:null,verdict:e=>["verdict",e],freshness:e=>["freshness",e],kind:e=>e==="all"?null:["evidence",e],store:e=>["store",e],author:e=>["author",e],node:e=>["node",e],filer:e=>["filer",e],live:e=>e==="1"?["session","present"]:null,session:e=>["scope",e]},Me=e=>Object.keys(Ne).some(t=>(e==null?void 0:e[t])!=null&&e[t]!==""),ft=e=>/[\s:"]/.test(e)?`"${e.replace(/"/g,"")}"`:e;function ht(e,t){if(!Me(t))return null;let s=e;for(const[r,a]of Object.entries(Ne)){const i=t[r];if(i==null||i==="")continue;const u=a(String(i));u&&(s=Y(s,u[0],u[1]))}const n=String(t.q??"").trim();return n&&(s=`${s} ${ft(n)}`.trim()),s}function ss(e,t,s=[],n={}){const r=String(e??""),a=Math.max(0,Math.min(t??r.length,r.length)),i=_e(r).find(p=>!p.ws&&p.start<a&&a<=p.end);if(!i)return{start:a,end:a,items:[]};const u=r.slice(i.start,a),f=Re.exec(u);if(!f){const p=u.toLowerCase();if(!p||p.includes('"'))return{start:i.start,end:i.end,items:[]};const j=s.filter(x=>x.startsWith(p)).slice(0,8).map(x=>({type:"key",key:x,insert:`${x}:`}));return{start:i.start,end:i.end,items:j}}const k=f[1].toLowerCase(),E=f[2].replace(/^"/,"").replace(/"$/,"").toLowerCase(),b=(n[k]||[]).filter(p=>String(p.value).toLowerCase().startsWith(E)&&String(p.value).toLowerCase()!==E).slice(0,8).map(p=>({type:"value",key:k,value:String(p.value),label:p.label||null,insert:`${k}:${$e(p.value)} `}));return{start:i.start,end:i.end,items:b}}const gt=["graph","spec","file","sessions","evals","issues","settings","empty"],ns=["spec","sessions","evals","issues","settings"],we=["q","page"];function mt(e){if(!e)return"";const t=new URLSearchParams;for(const n of we)e[n]!=null&&e[n]!==""&&t.set(n,e[n]);for(const n of Object.keys(e).filter(r=>!we.includes(r)).sort())e[n]!=null&&e[n]!==""&&t.set(n,e[n]);const s=t.toString().replace(/\+/g,"%20");return s?`?${s}`:""}function T(e){const t=(e||"").replace(/^#\/?/,""),s=t.indexOf("?"),n=s>=0?t.slice(0,s):t,r=Object.fromEntries(new URLSearchParams(s>=0?t.slice(s+1):"")),a=n.split("/").filter(Boolean),i=gt.includes(a[0]),u=i?a[0]:"sessions",f=!i||u==="settings"||u==="empty"?null:a.length>1?a.slice(1).map(decodeURIComponent).join("/"):null;return{page:u,param:f,query:r}}function wt(e){const n=(e||"").replace(/^#\/?/,"").split("?")[0].split("/").filter(Boolean);if(n[0]!=="sessions"||n[2]!=="eval")return null;const r=decodeURIComponent(n[1]||"");if(!r)return null;const a=n[3]?decodeURIComponent(n[3]):null,i=n.length>4?n.slice(4).map(decodeURIComponent).join("/"):null,u=a&&i?`${a}/${i}`:null;return U("evals",u,{q:u?`scope:${r}`:Ae(r)})}function yt(e){const{page:t,param:s,query:n}=T(e);if(t!=="sessions"||!s||!n.surface)return null;if(n.surface==="evals")return U("evals",null,{q:Ae(s)});const r=typeof n.surface=="string"&&n.surface.startsWith("resource:")&&n.surface.length>9;return n.surface!=="conversation"&&n.surface!=="terminal"&&n.surface!=="diff"&&!r,null}function jt(e){const{page:t,param:s,query:n}=T(e);if(t!=="evals"&&t!=="issues"||!Me(n))return null;if(s!=null)return U(t,s,n.session?{q:`scope:${n.session}`}:null);const r=t==="issues"?Ie:ne,a=ht(r,n);return U(t,null,Oe(a,r)?null:{q:a})}function kt(e){const{page:t,param:s,query:n}=T(e);if(t!=="evals"&&t!=="issues"||s!=null||n.page==null||/^[1-9]\d*$/.test(n.page)&&Number.isSafeInteger(Number(n.page)))return null;const{page:r,...a}=n;return U(t,null,a)}const U=(e,t,s=null)=>`#/${e}${t?`/${String(t).split("/").map(encodeURIComponent).join("/")}`:""}${mt(s)}`;function rs(e,t=null,{replace:s=!1,query:n=null}={}){const r=U(e,t,n);window.location.hash!==r&&(s?(window.history.replaceState(null,"",r),window.dispatchEvent(new HashChangeEvent("hashchange"))):window.location.hash=r)}const ye=()=>{if(_&&window.location.hash!=="#/graph")return window.history.replaceState(null,"","#/graph"),T("#/graph");const e=wt(window.location.hash)||yt(window.location.hash)||jt(window.location.hash)||kt(window.location.hash);if(e)return window.history.replaceState(null,"",e),T(e);const t=T(window.location.hash);return t.page==="sessions"&&!/^#\/sessions(?:\/|\?|$)/.test(window.location.hash||"")?(window.history.replaceState(null,"","#/sessions"),T("#/sessions")):t};function xt(){const[e,t]=o.useState(ye);return o.useEffect(()=>{const s=()=>t(ye());return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]),e}const je=o.lazy(()=>K(()=>import("./WorkspaceSurface-B7MYY74h.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),St=o.lazy(()=>K(()=>import("./MobileApp-D_uT9zos.js"),__vite__mapDeps([7,1,2,4,3,5,8,9,10]))),vt=o.lazy(()=>K(()=>import("./ProjectsPage-e257fgBn.js"),__vite__mapDeps([11,1,2,3])));window.addEventListener("vite:preloadError",e=>{const t=String(e.payload);sessionStorage.getItem("spexcode.chunkReload")!==t&&(sessionStorage.setItem("spexcode.chunkReload",t),e.preventDefault(),location.reload())});function bt({surface:e="workspace"}){const t=ee(),s=xt(),n=o.useRef(null);e==="workspace"&&(n.current=s);const r=De(),a=Xe();o.useEffect(()=>{_||a||K(()=>import("./WorkspaceSurface-B7MYY74h.js"),__vite__mapDeps([0,1,2,3,4,5,6]))},[a]);const[i,u]=o.useState(null),[f,k]=o.useState(!1),E=o.useRef(new Map),v=o.useCallback((g,m)=>{u(Be(g,E.current,m))},[]),[b,p]=o.useState(!1),[j,x]=o.useState(null),[O,l]=o.useState(0),[h,C]=o.useState(null);o.useEffect(()=>{if(_)return;let g=!0;const m=()=>Je().then(P=>(g&&C(Z=>ae(Z,P)),P)).catch(()=>{const P={state:"absent"};return g&&C(Z=>ae(Z,P)),P});let S;const M=async()=>{const P=await m();return(P==null?void 0:P.state)==="denied"&&S&&(clearInterval(S),S=void 0),P};return(async()=>{const P=await M();g&&(P==null?void 0:P.state)!=="denied"&&(S=setInterval(M,We))})(),()=>{g=!1,S&&clearInterval(S)}},[O]);const I=o.useRef(0),w=o.useCallback(()=>{const g=++I.current;return _?ze().then(m=>{g===I.current&&(p(!1),v(m,!0))}).catch(()=>{g===I.current&&p(!0)}):Fe().then(m=>{if(!(g!==I.current||!m)){if(m.authRequired){x(m.authRequired);return}x(null),p(!1),v(m.board,!0),m.seal()}}).catch(()=>{g===I.current&&p(!0)})},[v]);o.useEffect(()=>{r.retryKey&&w()},[r.retryKey,w]);const A=!$&&!i&&!!h&&h.state!=="absent",R=!$&&!i&&h===null;o.useEffect(()=>{_&&w()},[w]),o.useEffect(()=>{if(_||A||R)return;w();const g=qe({onBoard:(S,M)=>{I.current++,p(!1),v(S,!!(M!=null&&M.authoritative))},onLegacyChange:()=>{w()},onStatus:k}),m=setInterval(()=>{w()},15e3);return()=>{g(),clearInterval(m)}},[w,v,A,R]);const d=i?He(i):null,y=$?Qe($,h,d):A?Ye(h):d,B=!!i&&!a;if(o.useEffect(()=>{!y||B||(document.title=Ze(y))},[y==null?void 0:y.title,B]),o.useEffect(()=>{if(!y)return;const g=A?et:D,m=at(y.icon,g);let S=document.querySelector("link[rel~='icon']");S||(S=document.createElement("link"),S.rel="icon",document.head.appendChild(S)),S.getAttribute("href")!==m&&S.setAttribute("href",m)},[y==null?void 0:y.icon,A]),j&&$)return c.jsx(J,{scope:{projectId:$},projectLabel:(y==null?void 0:y.title)||$,onUnlocked:()=>{x(null),l(g=>g+1),w()}});if(!i)return A?h.state==="denied"?c.jsx(J,{scope:"admin",locked:h.reason==="locked",onUnlocked:()=>{l(g=>g+1),w()}}):c.jsx(o.Suspense,{fallback:c.jsx("div",{className:"loading",children:t("hud.loading")}),children:c.jsx(vt,{})}):j?c.jsx(J,{scope:"admin",locked:j==="locked",onUnlocked:()=>{x(null),l(g=>g+1),w()}}):b&&($||h&&h.state==="absent")?c.jsxs("div",{className:"loading load-error",children:[c.jsx("span",{children:t("hud.loadError")}),c.jsx("button",{className:"load-retry",onClick:()=>{p(!1),w()},children:t("hud.retry")})]}):c.jsx("div",{className:"loading",children:t("hud.loading")});const N=a?c.jsx(St,{specs:i.nodes,sessions:i.sessions,issuesStamp:i.issuesStamp,reloadBoard:w,route:s}):c.jsx(je,{route:n.current||{page:"graph",param:null,query:null}});return c.jsx(o.Suspense,{fallback:c.jsx("div",{className:"loading",children:t("hud.loading")}),children:_?c.jsx(ue,{reload:w,value:{specs:i.nodes,sessions:[],issuesStamp:null,identity:y,catalog:null,boardLive:!1,graphOnly:!0},children:c.jsx(he,{children:c.jsx(fe,{children:c.jsx(je,{route:s})})})}):c.jsx(ue,{reload:w,value:{specs:i.nodes,sessions:i.sessions,issuesStamp:i.issuesStamp,identity:y,catalog:h,boardLive:f,graphOnly:!1},children:c.jsx(he,{children:c.jsx(fe,{children:N})})})})}const os=Object.freeze(Object.defineProperty({__proto__:null,default:bt},Symbol.toStringTag,{value:"Module"}));export{Nt as A,Bt as B,J as C,zt as D,Ot as E,Ut as F,Tt as G,Mt as H,le as I,Dt as J,Ft as K,At as L,It as M,Yt as N,ne as O,Qt as P,es as Q,ns as R,Y as S,pt as T,ts as U,Ie as V,os as W,Gt as a,Zt as b,Wt as c,Jt as d,Ht as e,Vt as f,Xt as g,xt as h,Xe as i,ss as j,_e as k,it as l,ut as m,rs as n,Je as o,T as p,Lt as q,U as r,Ae as s,Pt as t,Kt as u,We as v,$t as w,Rt as x,qt as y,_t as z};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkspaceSurface-8ATlQvk9.js","assets/index-DWjEd9Wj.js","assets/index-CjNin6fF.css","assets/Modal-ByQRzOqM.js","assets/tabs-OpePwMY6.js","assets/tabs-Brk4lg7l.css","assets/GraphStats-CxHsXNy-.js","assets/MobileApp-SMfj4uYR.js","assets/NodeView-CEEKTA7o.js","assets/Thread-DsQYxUwv.js","assets/ProseActions-C-bJtCW1.js","assets/ProjectsPage-DHAuS8_X.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as ee,r as o,j as c,I as ke,a as Ue,P as _,b as De,_ as K,c as Be,l as ze,d as Fe,e as $,s as qe,p as He}from"./index-DWjEd9Wj.js";const L=async e=>(e.headers.get("content-type")||"").includes("json")?e.json().catch(()=>null):null,We=5e3,xe=(e,t,s)=>({title:typeof(e==null?void 0:e.title)=="string"&&e.title?e.title:t,icon:typeof(e==null?void 0:e.icon)=="string"&&e.icon?e.icon:s});function H(e){if(!e||typeof e!="object")return null;const t=e.id??e.projectId;return t?{id:String(t),identity:xe(e.identity||{title:e.name,icon:e.icon},e.name||String(t),"spexcode"),root:typeof e.root=="string"?e.root:"",online:typeof e.online=="boolean"?e.online:null,url:e.url||"",port:e.port??null,gated:!!(e.gated??e.locked??e.hasPassword),configRevision:typeof e.configRevision=="string"?e.configRevision:""}:null}const Ge=e=>{const t=Array.isArray(e)?e:Array.isArray(e==null?void 0:e.projects)?e.projects:null;return t?t.map(H).filter(Boolean):null},Ke=10;function Pt(e,t,s=Ke){const n=Array.isArray(e)?e:[],r=Math.max(1,Math.ceil(n.length/s)),a=Math.min(Math.max(1,Number.isInteger(t)?t:1),r);return{items:n.slice((a-1)*s,a*s),page:a,pageCount:r}}function Qe(e,t,s){var n;if(!e)return s;if(!t)return null;if(t.state==="ok"){const r=(n=t.projects)==null?void 0:n.find(a=>a.id===e);return(r==null?void 0:r.identity)||{title:e,icon:"spexcode"}}return{title:(s==null?void 0:s.title)||e,icon:(s==null?void 0:s.icon)||"spexcode"}}const Ye=e=>(e==null?void 0:e.state)==="ok"?e.gateway.identity:{title:"Projects",icon:"gateway"},Ze=e=>(e==null?void 0:e.title)||"SpexCode",ae=(e,t)=>(t==null?void 0:t.state)==="absent"&&e&&e.state!=="absent"?e:t;async function Je(){let e;try{e=await fetch("/projects",{cache:"no-store",headers:{Accept:"application/json"}})}catch{return{state:"absent"}}if(e.status===401)return{state:"denied",reason:"admin-login"};if(e.status===403)return{state:"denied",reason:"locked"};if(!e.ok)return{state:"absent"};const t=await L(e),s=Ge(t);if(!s)return{state:"absent"};const n=t!=null&&t.gateway&&typeof t.gateway=="object"?{identity:xe(t.gateway,"Projects","gateway"),revision:typeof t.gateway.revision=="string"?t.gateway.revision:""}:{identity:{title:"Projects",icon:"gateway"},revision:""};return{state:"ok",adminGated:!!(t!=null&&t.adminGated),gateway:n,projects:s}}async function Lt(e,{timeoutMs:t=2500}={}){try{const s=await fetch(`/p/${encodeURIComponent(e)}/health`,{cache:"no-store",signal:AbortSignal.timeout(t)});return!s.ok||s.redirected?"unreachable":(await s.text()).trim()==="ok"?"running":"unreachable"}catch{return"unreachable"}}async function Q(e,t,s){let n;try{n=await fetch(e,{method:t,headers:{"Content-Type":"application/json",Accept:"application/json"},...t==="PUT"?{body:JSON.stringify({password:s})}:{}})}catch{return{ok:!1,error:"network"}}const r=await L(n)||{};return{ok:n.ok&&r.ok!==!1,status:n.status,...r.error?{error:r.error}:{}}}const It=(e,t)=>Q(`/projects/${encodeURIComponent(e)}/password`,"PUT",t),At=e=>Q(`/projects/${encodeURIComponent(e)}/password`,"DELETE"),Rt=e=>Q("/projects/admin-password","PUT",e),$t=()=>Q("/projects/admin-password","DELETE");async function Ve(e,t){const s=e==="admin"?"/login":`/p/${encodeURIComponent(e.projectId)}/login`;let n;try{n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:t})})}catch{return{ok:!1,error:"network"}}return n.status===401?{ok:!1,error:"wrong-password"}:n.status===403?{ok:!1,error:"locked"}:n.ok||n.redirected?{ok:!0}:{ok:!1,error:`http-${n.status}`}}async function _t(e=""){let t;try{const n=e?`?path=${encodeURIComponent(e)}`:"";t=await fetch(`/projects/browse${n}`,{cache:"no-store",headers:{Accept:"application/json"}})}catch{return{ok:!1,error:"network"}}const s=await L(t);return t.ok?typeof(s==null?void 0:s.path)!="string"||!Array.isArray(s==null?void 0:s.entries)?{ok:!1,error:"unexpected answer"}:{ok:!0,path:s.path,exists:s.exists!==!1,parent:typeof s.parent=="string"?s.parent:null,home:typeof s.home=="string"?s.home:s.path,gitRoot:typeof s.gitRoot=="string"?s.gitRoot:null,initialized:!!s.initialized,cataloged:!!s.cataloged,entries:s.entries.filter(n=>n&&typeof n.name=="string"&&typeof n.path=="string").map(n=>({name:n.name,path:n.path,git:!!n.git,initialized:!!n.initialized}))}:{ok:!1,status:t.status,error:(s==null?void 0:s.error)||`http-${t.status}`}}async function Tt(e,t={}){let s;try{s=await fetch("/projects",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({root:e,...t})})}catch{return{ok:!1,error:"network"}}const n=await L(s);if(!s.ok)return{ok:!1,status:s.status,error:(n==null?void 0:n.error)||`http-${s.status}`,...n!=null&&n.init&&typeof n.init=="object"?{code:n.init.code??null,output:String(n.init.output??"")}:{}};const r=H(n);return r?{ok:!0,project:r,setup:n.setup??null}:{ok:!1,error:"unexpected answer"}}async function Ot(e,t){let s;try{s=await fetch(`/projects/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({confirmation:t})})}catch{return{ok:!1,error:"network"}}const n=await L(s);return s.ok?{ok:(n==null?void 0:n.ok)===!0,...n||{}}:{ok:!1,status:s.status,error:(n==null?void 0:n.error)||`http-${s.status}`}}async function Nt(e){let t;try{t=await fetch(`/projects/${encodeURIComponent(e)}/config`,{cache:"no-store",headers:{Accept:"application/json"}})}catch{return{ok:!1,error:"network"}}const s=await L(t);return t.ok?typeof(s==null?void 0:s.content)!="string"||typeof(s==null?void 0:s.revision)!="string"?{ok:!1,error:"unexpected answer"}:{ok:!0,content:s.content,revision:s.revision}:{ok:!1,status:t.status,error:(s==null?void 0:s.error)||`http-${t.status}`}}async function Mt(e,t,s){let n;try{n=await fetch(`/projects/${encodeURIComponent(e)}/config`,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:t,revision:s})})}catch{return{ok:!1,error:"network"}}const r=await L(n);return n.ok?typeof(r==null?void 0:r.content)!="string"||typeof(r==null?void 0:r.revision)!="string"?{ok:!1,error:"unexpected answer"}:{ok:!0,content:r.content,revision:r.revision}:{ok:!1,status:n.status,error:(r==null?void 0:r.error)||`http-${n.status}`}}async function Se(e,t,s){let n;try{n=await fetch(e,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({icon:t,revision:s})})}catch{return{ok:!1,error:"network"}}const r=await L(n);return n.ok?{ok:!0,...r}:{ok:!1,status:n.status,error:(r==null?void 0:r.error)||`http-${n.status}`}}const Ut=(e,t)=>Se("/projects/icon",e,t),Dt=(e,t,s)=>Se(`/projects/${encodeURIComponent(e)}/icon`,t,s);async function ve(e,t,s={}){let n;try{n=await fetch(`/projects/${encodeURIComponent(e)}/${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(s)})}catch{return{ok:!1,error:"network"}}const r=await L(n);return n.ok?!r||typeof r!="object"?{ok:!1,error:"unexpected answer"}:{ok:r.ok===!0,code:r.code??null,output:String(r.output??"")}:{ok:!1,status:n.status,error:(r==null?void 0:r.error)||`http-${n.status}`}}const Bt=(e,t)=>ve(e,"init",{harness:t}),zt=e=>ve(e,"doctor");async function Ft(e){let t;try{t=await fetch(`/projects/${encodeURIComponent(e)}/serve`,{method:"POST",headers:{Accept:"application/json"}})}catch{return{ok:!1,error:"network"}}const s=await L(t);return t.status===409?{ok:!0,already:!0,project:H(s==null?void 0:s.project)}:t.ok?{ok:!0,project:H(s==null?void 0:s.project)}:{ok:!1,status:t.status,error:(s==null?void 0:s.error)||`http-${t.status}`}}function J({scope:e,projectLabel:t,locked:s,onUnlocked:n}){const r=ee(),[a,i]=o.useState(""),[u,f]=o.useState(!1),[k,E]=o.useState(null),v=e==="admin",b=async p=>{if(p.preventDefault(),!a||u)return;f(!0),E(null);const j=await Ve(v?"admin":{projectId:e.projectId},a);f(!1),j.ok?(i(""),n()):E(j.error==="wrong-password"?r("credential.wrong"):r("credential.failed"))};return c.jsx("div",{className:"cred-wrap",children:c.jsxs("form",{className:"cred-card",onSubmit:b,children:[c.jsx("div",{className:"cred-brand",children:"$ spexcode"}),c.jsxs("div",{className:"cred-title",children:[c.jsx(ke,{name:"lock",size:14,className:"cred-lock"}),s?r("credential.lockedTitle"):v?r("credential.adminTitle"):r("credential.projectTitle",{name:t||e&&e.projectId||""})]}),s?c.jsx("p",{className:"cred-sub",children:r("credential.lockedBody")}):c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"cred-sub",children:r(v?"credential.adminBody":"credential.projectBody")}),k&&c.jsx("div",{className:"cred-err",children:k}),c.jsx("input",{className:"cred-input",type:"password",autoFocus:!0,required:!0,placeholder:"••••••••••","aria-label":r("credential.passwordLabel"),value:a,onChange:p=>i(p.target.value)}),c.jsx("button",{className:"cred-submit",type:"submit",disabled:u||!a,children:r(u?"credential.checking":"credential.unlock")})]})]})})}const ce="(max-width: 640px)";function Xe(){const[e,t]=o.useState(()=>typeof window<"u"&&window.matchMedia(ce).matches);return o.useEffect(()=>{const s=window.matchMedia(ce),n=()=>t(s.matches);return s.addEventListener("change",n),()=>s.removeEventListener("change",n)},[]),e}const D="spexcode",et="gateway",te=Object.freeze([{id:"spexcode",label:"SpexCode",bg:"#12161C",fg:"#EFE8D8",shapes:[{tag:"path",d:"M 4.500,4.500 L 9.750,4.500 L 9.750,6.656 L 6.656,6.656 L 6.656,17.344 L 9.750,17.344 L 9.750,19.500 L 4.500,19.500 Z",fill:"#EFE8D8",stroke:"none"},{tag:"path",d:"M 19.500,4.500 L 14.250,4.500 L 14.250,6.656 L 17.344,6.656 L 17.344,17.344 L 14.250,17.344 L 14.250,19.500 L 19.500,19.500 Z",fill:"#EFE8D8",stroke:"none"},{tag:"path",d:"M 15.281,15.281 L 11.731,13.057 L 12.269,10.943 L 8.719,8.719 L 8.719,15.281 Z",fill:"#327D95",stroke:"none"},{tag:"path",d:"M 8.719,8.719 L 12.269,10.943 L 11.731,13.057 L 15.281,15.281 L 15.281,12.000 L 12.000,8.719 Z",fill:"#82C3D6",stroke:"none"},{tag:"path",d:"M 8.569,8.957 L 11.946,11.073 L 11.408,13.186 L 15.132,15.520 L 15.431,15.043 L 12.054,12.927 L 12.592,10.814 L 8.868,8.480 Z",fill:"#E4F7FD",stroke:"none"}]},{id:"gateway",label:"Gateway",bg:"#155e75",fg:"#ecfeff",shapes:[{tag:"path",d:"m12 3 8 4.2-8 4.2-8-4.2Z"},{tag:"path",d:"m4 11.2 8 4.2 8-4.2"},{tag:"path",d:"m4 15.2 8 4.2 8-4.2"}]},{id:"mdi:rocket-launch",label:"Rocket",bg:"#9f1239",fg:"#fff1f2",shapes:[{tag:"path",d:"M14.5 5.2c2.2-2.2 4.8-2 5.3-1.8.2.5.4 3.1-1.8 5.3l-5.5 5.5-4.2-4.2Z"},{tag:"path",d:"m11.2 6.8-4.1.6-2.5 2.5 4.1.7"},{tag:"path",d:"m16.4 12-1 4.7-2.5 2.5-.7-4.1"},{tag:"circle",cx:16.1,cy:7.1,r:1.2},{tag:"path",d:"M7.6 14.6c-2.2.4-3.4 1.6-3.6 3.8 2.2-.2 3.4-1.4 3.8-3.6"}]},{id:"compass",label:"Compass",bg:"#1d4ed8",fg:"#eff6ff",shapes:[{tag:"circle",cx:12,cy:12,r:8.5},{tag:"path",d:"m15.2 8.8-1.8 4.6-4.6 1.8 1.8-4.6Z"}]},{id:"terminal",label:"Terminal",bg:"#3f3f46",fg:"#fafafa",shapes:[{tag:"rect",x:3.5,y:4.5,width:17,height:15,rx:2},{tag:"path",d:"m7 9 3 3-3 3"},{tag:"path",d:"M12.5 15H17"}]},{id:"package",label:"Package",bg:"#6d28d9",fg:"#f5f3ff",shapes:[{tag:"path",d:"m12 3 8 4.5v9L12 21l-8-4.5v-9Z"},{tag:"path",d:"m4.3 7.7 7.7 4.4 7.7-4.4"},{tag:"path",d:"M12 12.1V21"}]},{id:"database",label:"Database",bg:"#a16207",fg:"#fefce8",shapes:[{tag:"ellipse",cx:12,cy:6,rx:7.5,ry:3},{tag:"path",d:"M4.5 6v6c0 1.7 3.4 3 7.5 3s7.5-1.3 7.5-3V6"},{tag:"path",d:"M4.5 12v6c0 1.7 3.4 3 7.5 3s7.5-1.3 7.5-3v-6"}]},{id:"spark",label:"Spark",bg:"#c2410c",fg:"#fff7ed",shapes:[{tag:"path",d:"m12 3 1.5 5.2L19 10l-5.5 1.8L12 17l-1.5-5.2L5 10l5.5-1.8Z"},{tag:"path",d:"m18.5 15 .7 2.2 2.3.8-2.3.8-.7 2.2-.7-2.2-2.3-.8 2.3-.8Z"}]}]),tt=new Map(te.map(e=>[e.id,e])),st=/^[a-z0-9-]+[:/][a-z0-9-]+$/i,be=new Map([["rocket","mdi:rocket-launch"],["mdi/rocket-launch","mdi:rocket-launch"],["layers","gateway"],["default","spexcode"]]);Object.freeze(te.map(e=>e.id));function nt(e,t=D){const s=typeof e=="string"?e.trim():"";return be.get(s)||s||t}function z(e){const t=typeof e=="string"?e.trim():"";return tt.get(be.get(t)||t)||null}function W(e){return st.test(typeof e=="string"?e.trim():"")}function rt(e){return Object.entries(e).filter(([t])=>t!=="tag").map(([t,s])=>`${t==="className"?"class":t}="${String(s).replaceAll("&","&").replaceAll('"',""")}"`).join(" ")}function ot(e,t=D){const s=z(e)||z(t),n=s.shapes.map(r=>`<${r.tag} ${rt(r)}/>`).join("");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="1" y="1" width="22" height="22" rx="5" fill="${s.bg}"/><g fill="none" stroke="${s.fg}" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">${n}</g></svg>`}function F(e,t=D){const s=nt(e,t);if(z(s))return`data:image/svg+xml,${encodeURIComponent(ot(s,t))}`;if(/^https?:\/\//.test(s))return s;if(W(s))return`https://api.iconify.design/${s.replace(":","/")}.svg`;const n=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text x="50" y=".86em" font-size="82" text-anchor="middle">${s.replaceAll("&","&").replaceAll("<","<")}</text></svg>`;return`data:image/svg+xml,${encodeURIComponent(n)}`}const at=F,V=[{id:"featured",label:"projects.iconSourceFeatured"},{id:"material",label:"projects.iconSourceMaterial",prefixes:"mdi,material-symbols"},{id:"lucide",label:"projects.iconSourceLucide",prefixes:"lucide"},{id:"tabler",label:"projects.iconSourceTabler",prefixes:"tabler"},{id:"phosphor",label:"projects.iconSourcePhosphor",prefixes:"ph"},{id:"brands",label:"projects.iconSourceBrands",prefixes:"simple-icons"}],ct=e=>e.split("-").filter(Boolean).map(t=>{var s;return((s=t[0])==null?void 0:s.toUpperCase())+t.slice(1)}).join(" ");function ie(e,t={}){var a;const s=e.replace("/",":"),[n,r]=s.split(":");return{id:s,label:ct(r),source:((a=t[n])==null?void 0:a.name)||n}}function le({icon:e,fallback:t=D,size:s=24,className:n,label:r}){const a=z(e);return!a&&W(e)?c.jsx("span",{className:n?`identity-iconify ${n}`:"identity-iconify",style:{width:s,height:s,maskImage:`url("${F(e,t)}")`,WebkitMaskImage:`url("${F(e,t)}")`},role:r?"img":void 0,"aria-label":r||void 0,"aria-hidden":r?void 0:!0}):a?c.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",className:n,role:r?"img":void 0,"aria-label":r||void 0,"aria-hidden":r?void 0:!0,children:[c.jsx("rect",{x:"1",y:"1",width:"22",height:"22",rx:"5",fill:a.bg}),c.jsx("g",{fill:"none",stroke:a.fg,strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:a.shapes.map(({tag:i,...u},f)=>c.jsx(i,{...u},f))})]}):c.jsx("img",{width:s,height:s,src:F(e,t),className:n,alt:r||"","aria-hidden":r?void 0:!0})}function qt({value:e,onChange:t,label:s,editLabel:n,name:r,fallback:a=D,disabled:i=!1}){const u=ee(),[f,k]=o.useState(!1),[E,v]=o.useState(""),[b,p]=o.useState("featured"),[j,x]=o.useState({state:"idle",choices:[]}),O=o.useId(),l=z(e),h=V.find(d=>d.id===b)||V[0];o.useEffect(()=>{if(!f)return;const d=E.trim(),y=d.length>=2?d:b==="featured"?"":"project";if(!y){x({state:"idle",choices:[]});return}const B=new AbortController;x({state:"loading",choices:[]});const oe=setTimeout(async()=>{try{const N=new URLSearchParams({query:y,limit:"48"});h.prefixes&&N.set("prefixes",h.prefixes);const g=await fetch(`https://api.iconify.design/search?${N}`,{signal:B.signal});if(!g.ok)throw new Error(`Iconify search answered ${g.status}`);const m=await g.json();if(!Array.isArray(m.icons))throw new Error("Iconify search returned an invalid response");x({state:"ready",choices:m.icons.filter(W).map(S=>ie(S,m.collections))})}catch(N){N.name!=="AbortError"&&x({state:"error",choices:[]})}},220);return()=>{clearTimeout(oe),B.abort()}},[f,E,b,h.prefixes]);const C=()=>{k(!1),v(""),p("featured"),x({state:"idle",choices:[]})},I=async d=>{await t(d)!==!1&&C()},w=E.trim().toLowerCase(),A=te.filter(d=>!w||d.label.toLowerCase().includes(w)||d.id.includes(w)).map(d=>({id:d.id,label:d.label,source:""}));let R=j.state==="ready"?j.choices:b==="featured"?A:[];return W(e)&&!R.some(d=>d.id===e.replace("/",":"))&&(R=[ie(e),...R]),c.jsxs("div",{className:f?"identity-control open":"identity-control",children:[c.jsxs("div",{className:"identity-disclosure",children:[c.jsx(le,{icon:e,fallback:a,size:26,label:`${s}: ${(l==null?void 0:l.label)||e||a}`}),c.jsx(Ue,{icon:"pencil",label:n,className:"proj-act icon identity-edit",size:13,disabled:i,"aria-expanded":f,"aria-controls":O,onClick:()=>{f?C():k(!0)}})]}),f&&c.jsxs("fieldset",{id:O,className:"identity-picker",disabled:i,children:[c.jsx("legend",{children:s}),c.jsxs("div",{className:"identity-search",children:[c.jsx(ke,{name:"search",size:14}),c.jsx("input",{type:"search",value:E,onChange:d=>v(d.target.value),placeholder:u("projects.iconSearch"),"aria-label":u("projects.iconSearch"),spellCheck:!1})]}),c.jsx("div",{className:"identity-sources",role:"group","aria-label":u("projects.iconSources"),children:V.map(d=>c.jsx("button",{type:"button",className:b===d.id?"identity-source on":"identity-source","aria-pressed":b===d.id,onClick:()=>p(d.id),children:u(d.label)},d.id))}),c.jsx("div",{className:"identity-options",children:R.map(d=>c.jsxs("label",{className:"identity-choice",children:[c.jsx("input",{type:"radio",name:r,value:d.id,checked:e.replace("/",":")===d.id,onChange:()=>I(d.id)}),c.jsx(le,{icon:d.id,size:28}),c.jsx("span",{className:"identity-choice-name",children:d.label}),d.source&&c.jsx("span",{className:"identity-choice-source",children:d.source})]},d.id))}),j.state==="loading"&&c.jsx("div",{className:"identity-search-status",role:"status",children:u("projects.iconSearching")}),j.state==="ready"&&!R.length&&c.jsx("div",{className:"identity-search-status",children:u("projects.iconSearchEmpty")}),j.state==="error"&&c.jsx("div",{className:"identity-search-status error",role:"alert",children:u("projects.iconSearchFailed")})]})]})}const G=o.createContext(null),Ee=o.createContext(null);function ue({value:e,reload:t,children:s}){const n=o.useMemo(()=>({reload:t}),[t]);return c.jsx(Ee.Provider,{value:n,children:c.jsx(G.Provider,{value:e,children:s})})}const Ht=()=>o.useContext(G)||{},Wt=()=>o.useContext(Ee)||{},Ce=o.createContext(null),Pe=o.createContext(null),de="spexcode.dock",pe="spexcode.dockMode",X="spexcode.split";function fe({children:e}){const[t,s]=o.useState(()=>{try{return localStorage.getItem(de)!=="0"}catch{return!0}}),[n,r]=o.useState(()=>{try{return localStorage.getItem(pe)==="sessions"?"sessions":"explorer"}catch{return"explorer"}}),[a,i]=o.useState(null),[u,f]=o.useState(()=>{try{const l=JSON.parse(localStorage.getItem(X)||"null");return l!=null&&l.page?l:null}catch{return null}}),[k,E]=o.useState(null),[v,b]=o.useState(!1),p=o.useRef(null),j=o.useRef(new Set),x=o.useMemo(()=>({setDock:l=>s(h=>{const C=typeof l=="function"?l(h):l;try{localStorage.setItem(de,C?"1":"0")}catch{}return C}),setDockMode:l=>r(h=>{const C=l==="sessions"?"sessions":"explorer";try{localStorage.setItem(pe,C)}catch{}return C===h?h:C}),openPalette:l=>i(l),closePalette:()=>i(null),toggleHelp:()=>b(l=>!l),closeHelp:()=>b(!1),setCompose:l=>{p.current=l;for(const h of[...j.current])h()},takeCompose:()=>{const l=p.current;return p.current=null,l},watchCompose:l=>(j.current.add(l),()=>{j.current.delete(l)}),splitTo:l=>f(()=>{const h=l!=null&&l.page?{page:l.page,param:l.param??null,query:l.query??null}:null;try{localStorage.setItem(X,JSON.stringify(h))}catch{}return h}),closeSplit:()=>f(()=>{try{localStorage.removeItem(X)}catch{}return null}),lockGraphTo:(l,{toggle:h=!0}={})=>E(C=>h&&C===l?null:l||null)}),[]),O=o.useMemo(()=>({dock:t,dockMode:n,palette:a,split:u,lockedSource:k,helpOpen:v}),[t,n,a,u,k,v]);return c.jsx(Pe.Provider,{value:x,children:c.jsx(Ce.Provider,{value:O,children:e})})}const Gt=()=>o.useContext(Ce)||{},Kt=()=>o.useContext(Pe)||{},se=o.createContext(null);function Qt({value:e,children:t}){const s=o.useContext(G),n=o.useRef(s);return e.active&&(n.current=s),c.jsx(se.Provider,{value:e,children:c.jsx(G.Provider,{value:e.active?s:n.current,children:t})})}const it=()=>{var e;return((e=o.useContext(se))==null?void 0:e.active)!==!1},Yt=()=>{var e;return((e=o.useContext(se))==null?void 0:e.address)??null},q=typeof window<"u"?window.__escStack||(window.__escStack=[]):[];function lt(e){const t=typeof window<"u"?window.__escStack:q;return(e==null?void 0:e.key)!=="Escape"||!t||t.length===0?!1:(e.preventDefault(),t[t.length-1].close(),!0)}function Zt(e,t){const s=o.useRef(t);s.current=t,o.useEffect(()=>{if(!e)return;const n={close:()=>{var r;return(r=s.current)==null?void 0:r.call(s)}};return q.push(n),()=>{const r=q.indexOf(n);r>=0&&q.splice(r,1)}},[e])}const Le=o.createContext(null);function ut(e){var t;return e?e.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(e.tagName)?!0:!!((t=e.closest)!=null&&t.call(e,'input, textarea, select, [contenteditable=""], [contenteditable="true"]')):!1}function dt(e,t=!1){return t||e!=null&&e.altKey||e!=null&&e.ctrlKey||e!=null&&e.metaKey?!0:!ut(e==null?void 0:e.target)}function he({children:e}){const t=o.useRef(new Map),s=o.useRef(0),n=o.useCallback((a,i=0)=>{const u=++s.current;return t.current.set(u,{handler:a,priority:i}),()=>t.current.delete(u)},[]),r=o.useMemo(()=>({register:n}),[n]);return o.useEffect(()=>{const a=i=>{if(lt(i)){i.stopPropagation();return}const u=[...t.current.entries()].sort((f,k)=>k[1].priority-f[1].priority||k[0]-f[0]);for(const[,f]of u)if(f.handler(i)||i.cancelBubble){i.stopPropagation();return}};return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[]),c.jsx(Le.Provider,{value:r,children:e})}function Jt(e,t=0,{allowTyping:s=!1}={}){const{register:n}=o.useContext(Le)||{},r=it(),a=o.useRef(e);a.current=e,o.useEffect(()=>{if(!(!n||!r))return n(i=>dt(i,s)&&a.current(i),t)},[n,t,r,s])}const Ie="is:issue state:open",ne="is:eval",Ae=e=>Y(ne,"scope",e),Vt=e=>Y(ne,"node",e),Xt=e=>Y(Ie,"node",e),Re=/^([A-Za-z][A-Za-z0-9-]*):(.*)$/s,ge=e=>e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e,$e=e=>/\s/.test(String(e))?`"${e}"`:String(e);function _e(e){const t=String(e??""),s=[];let n=0;for(;n<t.length;){let r=n;if(/\s/.test(t[n])){for(;r<t.length&&/\s/.test(t[r]);)r++;s.push({ws:!0,raw:t.slice(n,r),start:n,end:r})}else{for(;r<t.length&&!/\s/.test(t[r]);)if(t[r]==='"'){for(r++;r<t.length&&t[r]!=='"';)r++;r<t.length&&r++}else r++;const a=t.slice(n,r),i=Re.exec(a);s.push(i?{ws:!1,raw:a,start:n,end:r,key:i[1].toLowerCase(),value:ge(i[2])}:{ws:!1,raw:a,start:n,end:r,key:null,value:ge(a)})}n=r}return s}const re=e=>_e(e).filter(t=>!t.ws),Te=e=>e.map(t=>t.raw).join(" "),me=e=>Te(re(e)),Oe=(e,t)=>me(e)===me(t),es=(e,t)=>{const s=re(e);for(let n=s.length-1;n>=0;n--)if(s[n].key===t)return s[n].value;return""};function Y(e,t,s){const n=s==null||String(s)===""?null:{ws:!1,raw:`${t}:${$e(s)}`,key:t,value:String(s)},r=[];let a=!1;for(const i of re(e)){if(i.key===t){n&&!a&&(r.push(n),a=!0);continue}r.push(i)}return n&&!a&&r.push(n),Te(r)}const pt=(e,t)=>{const s=String(e??"").trim();return!s||Oe(s,t)?null:{q:s}},ts=(e,t,s=null)=>{const n=pt(e,t)||{};return s!=null&&(n.page=String(s)),Object.keys(n).length?n:null},Ne={state:e=>["state",e],concluded:e=>e==="1"?["state","closed"]:null,ok:e=>e==="1"?["state","reviewed"]:null,verdict:e=>["verdict",e],freshness:e=>["freshness",e],kind:e=>e==="all"?null:["evidence",e],store:e=>["store",e],author:e=>["author",e],node:e=>["node",e],filer:e=>["filer",e],live:e=>e==="1"?["session","present"]:null,session:e=>["scope",e]},Me=e=>Object.keys(Ne).some(t=>(e==null?void 0:e[t])!=null&&e[t]!==""),ft=e=>/[\s:"]/.test(e)?`"${e.replace(/"/g,"")}"`:e;function ht(e,t){if(!Me(t))return null;let s=e;for(const[r,a]of Object.entries(Ne)){const i=t[r];if(i==null||i==="")continue;const u=a(String(i));u&&(s=Y(s,u[0],u[1]))}const n=String(t.q??"").trim();return n&&(s=`${s} ${ft(n)}`.trim()),s}function ss(e,t,s=[],n={}){const r=String(e??""),a=Math.max(0,Math.min(t??r.length,r.length)),i=_e(r).find(p=>!p.ws&&p.start<a&&a<=p.end);if(!i)return{start:a,end:a,items:[]};const u=r.slice(i.start,a),f=Re.exec(u);if(!f){const p=u.toLowerCase();if(!p||p.includes('"'))return{start:i.start,end:i.end,items:[]};const j=s.filter(x=>x.startsWith(p)).slice(0,8).map(x=>({type:"key",key:x,insert:`${x}:`}));return{start:i.start,end:i.end,items:j}}const k=f[1].toLowerCase(),E=f[2].replace(/^"/,"").replace(/"$/,"").toLowerCase(),b=(n[k]||[]).filter(p=>String(p.value).toLowerCase().startsWith(E)&&String(p.value).toLowerCase()!==E).slice(0,8).map(p=>({type:"value",key:k,value:String(p.value),label:p.label||null,insert:`${k}:${$e(p.value)} `}));return{start:i.start,end:i.end,items:b}}const gt=["graph","spec","file","sessions","evals","issues","settings","empty"],ns=["spec","sessions","evals","issues","settings"],we=["q","page"];function mt(e){if(!e)return"";const t=new URLSearchParams;for(const n of we)e[n]!=null&&e[n]!==""&&t.set(n,e[n]);for(const n of Object.keys(e).filter(r=>!we.includes(r)).sort())e[n]!=null&&e[n]!==""&&t.set(n,e[n]);const s=t.toString().replace(/\+/g,"%20");return s?`?${s}`:""}function T(e){const t=(e||"").replace(/^#\/?/,""),s=t.indexOf("?"),n=s>=0?t.slice(0,s):t,r=Object.fromEntries(new URLSearchParams(s>=0?t.slice(s+1):"")),a=n.split("/").filter(Boolean),i=gt.includes(a[0]),u=i?a[0]:"sessions",f=!i||u==="settings"||u==="empty"?null:a.length>1?a.slice(1).map(decodeURIComponent).join("/"):null;return{page:u,param:f,query:r}}function wt(e){const n=(e||"").replace(/^#\/?/,"").split("?")[0].split("/").filter(Boolean);if(n[0]!=="sessions"||n[2]!=="eval")return null;const r=decodeURIComponent(n[1]||"");if(!r)return null;const a=n[3]?decodeURIComponent(n[3]):null,i=n.length>4?n.slice(4).map(decodeURIComponent).join("/"):null,u=a&&i?`${a}/${i}`:null;return U("evals",u,{q:u?`scope:${r}`:Ae(r)})}function yt(e){const{page:t,param:s,query:n}=T(e);if(t!=="sessions"||!s||!n.surface)return null;if(n.surface==="evals")return U("evals",null,{q:Ae(s)});const r=typeof n.surface=="string"&&n.surface.startsWith("resource:")&&n.surface.length>9;return n.surface!=="conversation"&&n.surface!=="terminal"&&n.surface!=="diff"&&!r,null}function jt(e){const{page:t,param:s,query:n}=T(e);if(t!=="evals"&&t!=="issues"||!Me(n))return null;if(s!=null)return U(t,s,n.session?{q:`scope:${n.session}`}:null);const r=t==="issues"?Ie:ne,a=ht(r,n);return U(t,null,Oe(a,r)?null:{q:a})}function kt(e){const{page:t,param:s,query:n}=T(e);if(t!=="evals"&&t!=="issues"||s!=null||n.page==null||/^[1-9]\d*$/.test(n.page)&&Number.isSafeInteger(Number(n.page)))return null;const{page:r,...a}=n;return U(t,null,a)}const U=(e,t,s=null)=>`#/${e}${t?`/${String(t).split("/").map(encodeURIComponent).join("/")}`:""}${mt(s)}`;function rs(e,t=null,{replace:s=!1,query:n=null}={}){const r=U(e,t,n);window.location.hash!==r&&(s?(window.history.replaceState(null,"",r),window.dispatchEvent(new HashChangeEvent("hashchange"))):window.location.hash=r)}const ye=()=>{if(_&&window.location.hash!=="#/graph")return window.history.replaceState(null,"","#/graph"),T("#/graph");const e=wt(window.location.hash)||yt(window.location.hash)||jt(window.location.hash)||kt(window.location.hash);if(e)return window.history.replaceState(null,"",e),T(e);const t=T(window.location.hash);return t.page==="sessions"&&!/^#\/sessions(?:\/|\?|$)/.test(window.location.hash||"")?(window.history.replaceState(null,"","#/sessions"),T("#/sessions")):t};function xt(){const[e,t]=o.useState(ye);return o.useEffect(()=>{const s=()=>t(ye());return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]),e}const je=o.lazy(()=>K(()=>import("./WorkspaceSurface-8ATlQvk9.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),St=o.lazy(()=>K(()=>import("./MobileApp-SMfj4uYR.js"),__vite__mapDeps([7,1,2,4,3,5,8,9,10]))),vt=o.lazy(()=>K(()=>import("./ProjectsPage-DHAuS8_X.js"),__vite__mapDeps([11,1,2,3])));window.addEventListener("vite:preloadError",e=>{const t=String(e.payload);sessionStorage.getItem("spexcode.chunkReload")!==t&&(sessionStorage.setItem("spexcode.chunkReload",t),e.preventDefault(),location.reload())});function bt({surface:e="workspace"}){const t=ee(),s=xt(),n=o.useRef(null);e==="workspace"&&(n.current=s);const r=De(),a=Xe();o.useEffect(()=>{_||a||K(()=>import("./WorkspaceSurface-8ATlQvk9.js"),__vite__mapDeps([0,1,2,3,4,5,6]))},[a]);const[i,u]=o.useState(null),[f,k]=o.useState(!1),E=o.useRef(new Map),v=o.useCallback((g,m)=>{u(Be(g,E.current,m))},[]),[b,p]=o.useState(!1),[j,x]=o.useState(null),[O,l]=o.useState(0),[h,C]=o.useState(null);o.useEffect(()=>{if(_)return;let g=!0;const m=()=>Je().then(P=>(g&&C(Z=>ae(Z,P)),P)).catch(()=>{const P={state:"absent"};return g&&C(Z=>ae(Z,P)),P});let S;const M=async()=>{const P=await m();return(P==null?void 0:P.state)==="denied"&&S&&(clearInterval(S),S=void 0),P};return(async()=>{const P=await M();g&&(P==null?void 0:P.state)!=="denied"&&(S=setInterval(M,We))})(),()=>{g=!1,S&&clearInterval(S)}},[O]);const I=o.useRef(0),w=o.useCallback(()=>{const g=++I.current;return _?ze().then(m=>{g===I.current&&(p(!1),v(m,!0))}).catch(()=>{g===I.current&&p(!0)}):Fe().then(m=>{if(!(g!==I.current||!m)){if(m.authRequired){x(m.authRequired);return}x(null),p(!1),v(m.board,!0),m.seal()}}).catch(()=>{g===I.current&&p(!0)})},[v]);o.useEffect(()=>{r.retryKey&&w()},[r.retryKey,w]);const A=!$&&!i&&!!h&&h.state!=="absent",R=!$&&!i&&h===null;o.useEffect(()=>{_&&w()},[w]),o.useEffect(()=>{if(_||A||R)return;w();const g=qe({onBoard:(S,M)=>{I.current++,p(!1),v(S,!!(M!=null&&M.authoritative))},onLegacyChange:()=>{w()},onStatus:k}),m=setInterval(()=>{w()},15e3);return()=>{g(),clearInterval(m)}},[w,v,A,R]);const d=i?He(i):null,y=$?Qe($,h,d):A?Ye(h):d,B=!!i&&!a;if(o.useEffect(()=>{!y||B||(document.title=Ze(y))},[y==null?void 0:y.title,B]),o.useEffect(()=>{if(!y)return;const g=A?et:D,m=at(y.icon,g);let S=document.querySelector("link[rel~='icon']");S||(S=document.createElement("link"),S.rel="icon",document.head.appendChild(S)),S.getAttribute("href")!==m&&S.setAttribute("href",m)},[y==null?void 0:y.icon,A]),j&&$)return c.jsx(J,{scope:{projectId:$},projectLabel:(y==null?void 0:y.title)||$,onUnlocked:()=>{x(null),l(g=>g+1),w()}});if(!i)return A?h.state==="denied"?c.jsx(J,{scope:"admin",locked:h.reason==="locked",onUnlocked:()=>{l(g=>g+1),w()}}):c.jsx(o.Suspense,{fallback:c.jsx("div",{className:"loading",children:t("hud.loading")}),children:c.jsx(vt,{})}):j?c.jsx(J,{scope:"admin",locked:j==="locked",onUnlocked:()=>{x(null),l(g=>g+1),w()}}):b&&($||h&&h.state==="absent")?c.jsxs("div",{className:"loading load-error",children:[c.jsx("span",{children:t("hud.loadError")}),c.jsx("button",{className:"load-retry",onClick:()=>{p(!1),w()},children:t("hud.retry")})]}):c.jsx("div",{className:"loading",children:t("hud.loading")});const N=a?c.jsx(St,{specs:i.nodes,sessions:i.sessions,issuesStamp:i.issuesStamp,reloadBoard:w,route:s}):c.jsx(je,{route:n.current||{page:"graph",param:null,query:null}});return c.jsx(o.Suspense,{fallback:c.jsx("div",{className:"loading",children:t("hud.loading")}),children:_?c.jsx(ue,{reload:w,value:{specs:i.nodes,sessions:[],issuesStamp:null,identity:y,catalog:null,boardLive:!1,graphOnly:!0},children:c.jsx(he,{children:c.jsx(fe,{children:c.jsx(je,{route:s})})})}):c.jsx(ue,{reload:w,value:{specs:i.nodes,sessions:i.sessions,issuesStamp:i.issuesStamp,identity:y,catalog:h,boardLive:f,graphOnly:!1},children:c.jsx(he,{children:c.jsx(fe,{children:N})})})})}const os=Object.freeze(Object.defineProperty({__proto__:null,default:bt},Symbol.toStringTag,{value:"Module"}));export{Nt as A,Bt as B,J as C,zt as D,Ot as E,Ut as F,Tt as G,Mt as H,le as I,Dt as J,Ft as K,At as L,It as M,Yt as N,ne as O,Qt as P,es as Q,ns as R,Y as S,pt as T,ts as U,Ie as V,os as W,Gt as a,Zt as b,Wt as c,Jt as d,Ht as e,Vt as f,Xt as g,xt as h,Xe as i,ss as j,_e as k,it as l,ut as m,rs as n,Je as o,T as p,Lt as q,U as r,Ae as s,Pt as t,Kt as u,We as v,$t as w,Rt as x,qt as y,_t as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as c,j as e,I as t}from"./index-
|
|
1
|
+
import{u as c,j as e,I as t}from"./index-DWjEd9Wj.js";import{u as i}from"./App-CgqiczQU.js";function m(){const s=c(),{openPalette:o,setDock:n,setDockMode:r}=i(),a=()=>{r("explorer"),n(!0)};return e.jsx("div",{className:"empty-view",children:e.jsxs("div",{className:"empty-card",children:[e.jsx("h1",{className:"empty-title",children:s("empty.title")}),e.jsx("p",{className:"empty-hint",children:s("empty.hint")}),e.jsxs("div",{className:"empty-doors",children:[e.jsxs("button",{type:"button",className:"empty-door",onClick:()=>o("nodes"),children:[e.jsx(t,{name:"search",size:14}),e.jsx("span",{children:s("empty.search")})]}),e.jsxs("button",{type:"button",className:"empty-door",onClick:a,children:[e.jsx(t,{name:"files",size:14}),e.jsx("span",{children:s("empty.explorer")})]})]})]})})}export{m as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as H,j as n,I as ne,r as c,ab as Fs,m as ye,ac as Cs,a as we,ad as Ts,ae as As,T as Ps,i as Ks,b as Os,k as Is}from"./index-CqFflSD2.js";import{E as Re,k as ns,r as zs,e as Bs,a as _s,p as Us,b as Vs,O as Hs,R as Qs,m as ke,c as Ys}from"./Thread-CMk3239q.js";import{O as ie,Q as J,S as qs,d as Xs,l as Gs,r as ts,T as Js,U as Zs}from"./App-Ca4rD0l6.js";import{az as Fe,P as V,g as ce,R as I,aA as Ds,aB as Ws,aC as as,I as rs,aD as Ce,aE as ee,aF as G,aG as Te,aH as en,aI as ls,aJ as sn,aK as nn,N as tn,ai as Ae,aL as an,L as rn,Q as hs}from"./tabs-hNUMIEYw.js";import"./Modal-BGWxLjyp.js";const os={video:"vid",image:"img",transcript:"txt",data:"data"},ln=["is","state","verdict","freshness","evidence","node","filer","session","scope"],fs=s=>`eval:${s.node}·${s.scenario}`;function on({e:s}){const a=H(),l=s.humanOk&&a("evalsFeed.okdTip",{by:s.humanOk.by,at:new Date(s.humanOk.ts).toLocaleString()});return n.jsx(Fe,{state:n.jsx(I,{kind:"eval",state:s.state}),title:s.scenario,meta:n.jsxs(n.Fragment,{children:[n.jsx("a",{className:"ef-node",href:V(ce(s.node)),style:{color:`hsl(${s.hue??210} 60% 70%)`},"data-tip":s.node,children:s.node}),s.by&&n.jsx("span",{"data-tip":s.by,children:a("evalsFeed.filedBy",{by:zs(s.by)})}),n.jsx("span",{children:a("evalsFeed.filedAt",{at:cn(s.ts)})})]}),aside:n.jsxs(n.Fragment,{children:[s.inSession&&n.jsx("span",{className:"rl-tag in-session",children:a("evalsFeed.sessionTag")}),ns(s).some(i=>os[i])&&n.jsx("span",{className:"rl-tag",children:ns(s).map(i=>os[i]).filter(Boolean).join("·")}),s.humanOk&&n.jsx("span",{role:"img",className:"ef-okd","data-tip":l,"aria-label":l,children:n.jsx(ne,{name:"check",size:11})})]})})}const cn=s=>{const a=Math.max(0,(Date.now()-new Date(s).getTime())/1e3);return a<3600?`${Math.max(1,Math.floor(a/60))}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`},se=(s,a,l,i=p=>p)=>{var p,f;return(((f=(p=s==null?void 0:s.facets)==null?void 0:p[a])==null?void 0:f.options)??[]).map(x=>({value:x.value,label:x.value===""?l:i(x.value)}))};function un({pageData:s,loading:a=!1,sessions:l=[],queryText:i="",onQueryText:p,hrefFor:f,leading:x=null,error:m=null,empty:S=null,pagination:E=null}){var Q,Z,U,L;const u=H(),d=String(i??"").trim()||ie,h=(r,z)=>p(qs(d,r,z)),C=Array.isArray(s==null?void 0:s.items)?s.items:[],P=((Q=s==null?void 0:s.counts)==null?void 0:Q.fail)||{},N=((Z=s==null?void 0:s.counts)==null?void 0:Z.pass)||{},$=((U=s==null?void 0:s.counts)==null?void 0:U.unmeasured)||0,k=((L=s==null?void 0:s.counts)==null?void 0:L.deferred)||0,R=r=>r>0?{text:`+${r} ${u("reviewList.freshness.stale")}`,compact:`+${r}`}:null,j=J(d,"verdict"),_=C.flatMap(r=>r.filterKind===Re.BLIND?[{key:`blind:${r.node}·${r.scenario}`,cls:"se-blind",content:n.jsx(Fe,{state:n.jsx(I,{kind:"eval",state:"missing"}),title:r.scenario,meta:n.jsxs(n.Fragment,{children:[n.jsx("a",{className:"ef-node",href:V(ce(r.node)),style:{color:`hsl(${r.hue??210} 60% 70%)`},"data-tip":r.node,children:r.node}),n.jsx("span",{children:u("sessionEval.unmeasured")})]})})}]:r.filterKind===Re.RESULT?[{key:fs(r),label:r.scenario,href:f(r),content:n.jsx(on,{e:r})}]:r.filterKind===Re.DEFERRED?[{key:`deferred:${r.node}·${r.scenario}`,label:r.scenario,content:n.jsx(Fe,{state:n.jsx(I,{kind:"eval",state:"empty",title:u("reviewList.verdict.deferred")}),title:r.scenario,meta:n.jsxs(n.Fragment,{children:[n.jsx("a",{className:"ef-node",href:V(ce(r.node)),style:{color:`hsl(${r.hue??210} 60% 70%)`},"data-tip":r.node,children:r.node}),n.jsx("span",{children:u("evalsFeed.freshnessDeferred")})]})})}]:[]),v={label:u("reviewList.facetReview"),value:J(d,"state"),options:se(s,"review",u("reviewList.all"),r=>u(r==="reviewed"?"reviewList.reviewed":"reviewList.needsReview"))},F={label:u("reviewList.facetFreshness"),value:J(d,"freshness"),options:se(s,"freshness",u("reviewList.all"),r=>u(`reviewList.freshness.${r}`))},K={label:u("reviewList.facetKind"),value:J(d,"evidence")||"all",options:se(s,"kind",u("evalsFeed.kind.all"),r=>u(`evalsFeed.kind.${r}`))},O={label:u("reviewList.facetSession"),value:J(d,"session"),options:se(s,"session",u("reviewList.all"),r=>u(r==="present"?"reviewList.sessionPresent":"reviewList.sessionMissing"))},te=J(d,"evidence");return n.jsx(Ds,{leading:x,error:m,loading:a,title:u("evalsFeed.title"),search:{value:String(i??"").trim()?i:ie,onSubmit:p,placeholder:u("reviewList.searchEvals"),label:u("reviewList.search"),keys:ln,suggest:{node:se(s,"node",u("reviewList.all")).filter(r=>r.value),filer:se(s,"filer",u("reviewList.all")).filter(r=>r.value).map(({value:r})=>{const z=l.find(ae=>ae.id===r);return{value:r,label:z?rs(z):null}}),scope:l.map(r=>({value:r.id,label:rs(r)}))}},sections:[{key:"fail",label:n.jsx(I,{kind:"eval",state:"fail",title:u("reviewList.verdict.fail"),showLabel:!0}),count:P.fresh||0,countSuffix:R(P.stale||0),active:j==="fail",onSelect:()=>h("verdict",j==="fail"?"":"fail")},{key:"pass",label:n.jsx(I,{kind:"eval",state:"pass",title:u("reviewList.verdict.pass"),showLabel:!0}),count:N.fresh||0,countSuffix:R(N.stale||0),active:j==="pass",onSelect:()=>h("verdict",j==="pass"?"":"pass")},{key:"unmeasured",label:n.jsx(I,{kind:"eval",state:"missing",title:u("reviewList.verdict.unmeasured"),showLabel:!0}),count:$,active:j==="unmeasured",onSelect:()=>h("verdict",j==="unmeasured"?"":"unmeasured")},{key:"deferred",label:n.jsx(I,{kind:"eval",state:"empty",title:u("reviewList.verdict.deferred"),showLabel:!0}),count:k,active:j==="deferred",onSelect:()=>h("verdict",j==="deferred"?"":"deferred")}],sectionMode:"filters",facets:n.jsxs(n.Fragment,{children:[n.jsx(as,{label:F.label,value:F.value,options:F.options,clearLabel:u("reviewList.all"),onChange:r=>h("freshness",r)}),n.jsx(as,{label:K.label,value:K.value,options:K.options,onChange:r=>h("evidence",r==="all"?"":r)})]}),secondaryFilters:n.jsx(Ws,{label:u("reviewList.filters"),clearLabel:u("reviewList.all"),groups:[{label:v.label,value:v.value,active:!!v.value,options:v.options,onChange:r=>h("state",r)},{label:O.label,value:O.value,active:!!O.value,options:O.options,onChange:r=>h("session",r)},{label:F.label,value:F.value,active:!!F.value,options:F.options,onChange:r=>h("freshness",r),mobileOnly:!0},{label:K.label,value:K.value,active:!!te,options:K.options,clearLabel:null,onChange:r=>h("evidence",r==="all"?"":r),mobileOnly:!0}]}),rows:_,pagination:E,empty:S||{hasData:((s==null?void 0:s.sourceTotal)??0)>0,dataset:u("evalsFeed.datasetEmpty"),filtered:u("evalsFeed.noMatches")}})}const dn=[{name:"ok",color:"green",when:s=>!s.okd&&s.isLatest,descKey:"annotator.cmd.okDesc"}];function hn(s,a){return dn.filter(l=>l.when(s)).map(l=>({...l,run:a[l.name]}))}function fn(s,a){return(s||"").replace(/\{(\w+)\}/g,(l,i)=>a[i]!=null?String(a[i]):l)}const is=(s,a)=>{let l=null;for(const i of s)if(i.at<=a)l=i;else break;return l},vn=s=>{if(!s||!Array.isArray(s.events))return null;const a=s.v===1?"time":typeof s.axis=="string"?s.axis:"time",l=s.v===1?i=>i.tMs:i=>i.at;return{axis:a,events:s.events.map(i=>({at:l(i),step:i.step,...i.node?{node:i.node}:{}}))}},mn=(s,a,l)=>s==="time"?ke(a):s==="frame"?`#${a}`:s==="line"?`L${a}`:s==="index"?l?`${a}/${l}`:`${a}`:String(a);function cs({events:s,axis:a,extent:l,activeStepIdx:i,onSeek:p}){return n.jsx("div",{className:"an-ruler",children:s.map((f,x)=>n.jsxs("button",{className:`an-step ${i===x?"on":""}`,onClick:()=>p(f.at),"data-tip":f.node?`→ ${f.node}`:void 0,children:[mn(a,f.at,l)," ",f.step]},x))})}const pe=8;function xn({hidden:s,total:a,histIdx:l,onPick:i}){const p=H(),f=sn(),x=p("annotator.abMore",{n:s.length});return n.jsxs("div",{className:"an-ab-more",ref:f.ref,children:[n.jsx(we,{icon:"ellipsis",size:14,className:"an-ab-morebtn",label:x,"aria-haspopup":"menu","aria-expanded":f.open,onClick:m=>f.toggle(m.currentTarget),onKeyDown:f.onTriggerKeyDown}),f.open&&n.jsx("div",{className:"rl-menu an-ab-menu",role:"menu","aria-label":x,ref:f.menuRef,onKeyDown:f.onMenuKeyDown,children:s.map(m=>{const S=Ce(m);return n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":m.idx===l,tabIndex:-1,className:"rl-menu-item an-ab-menuitem",onFocus:f.onItemFocus,onClick:()=>{f.close(!0),i(m.idx)},children:[n.jsx(I,{kind:"eval",state:S,size:13}),n.jsxs("span",{className:"an-ab-menupos",children:[a-m.idx,"/",a]}),n.jsx("span",{className:"an-ab-menudate",children:new Date(m.ts).toLocaleString()})]},`${m.ts}-${m.idx}`)})})]})}function pn({entry:s,history:a,sourceKey:l="project",specs:i=[],sessions:p=[],onWrite:f,onOpenSession:x,listHref:m=null,backHref:S=null,backLabel:E=null,queue:u={prev:[],next:[]}}){var Je,Ze,De,We,es,ss;const d=H(),h=c.useRef(null),C=c.useRef(null),P=c.useRef(null),N=c.useRef(null),$=c.useRef(0),[k,R]=c.useState([]),[j,_]=c.useState("time"),[v,F]=c.useState(null),[K,O]=c.useState(""),[te,Q]=c.useState(!1),[Z,U]=c.useState(null),L=c.useRef(null),r=c.useRef(null),z=c.useRef(null),ae=c.useRef(0),[vs,Pe]=c.useState(0),[ge,Ke]=c.useState(-1),[Oe,Ie]=c.useState(null),[ue,je]=c.useState(!1),[ze,Le]=c.useState(!1),[Se,$e]=c.useState(null),[de,Ee]=c.useState(null),[T,Be]=c.useState(null),[A,re]=c.useState(0),b=T&&T[A]||s,ms=`${A}:${b.ts||b.codeSha||b.blob||"reading"}`,xs=`${l}·${s.node}·${s.scenario}·${ms}`,[ps,bs]=c.useState([]);c.useEffect(()=>{let e=!0;return Fs().then(t=>{e&&Array.isArray(t)&&bs(t)}).catch(()=>{}),()=>{e=!1}},[]),c.useEffect(()=>{F(null),O(""),R([]),U(null),re(0),Be(null),Be(Array.isArray(a)?a:[s])},[s.node,s.scenario,s.ts,s.blob,(Je=s.humanOk)==null?void 0:Je.ts,a]),c.useEffect(()=>{F(null),U(null)},[A]);const le=Bs(b),Y=le.find(e=>e.kind==="video"&&e.state==="present"),he=le.filter(e=>e.kind==="image"),ws=le.filter(e=>e.kind!=="video"&&e.kind!=="image"),D=!!Y,fe=s.thread??null,Me=c.useMemo(()=>((fe==null?void 0:fe.replies)??[]).filter(e=>e.rid!==void 0),[fe]),_e=T&&((Ze=T[0])==null?void 0:Ze.by)||s.by||null,B=c.useMemo(()=>Me.map((e,t)=>{const o=_s(Us(e.body),k);return o&&o.seekable?{i:t,tMs:o.tMs,step:o.step,label:o.label}:null}).filter(Boolean).sort((e,t)=>e.tMs-t.tMs),[Me,k]),Ue=c.useRef(k);Ue.current=k;const Ve=c.useRef(B);Ve.current=B;const ve=c.useCallback(()=>{const e=ae.current,t=Ue.current;let o=-1;for(let g=0;g<t.length&&t[g].at<=e;g++)o=g;Ke(g=>g===o?g:o);let w=null;for(const g of Ve.current)if(g.tMs<=e)w=g.i;else break;Ie(g=>g===w?g:w)},[]);c.useEffect(()=>{ve()},[B,k,ve]),c.useEffect(()=>{ae.current=0,L.current&&(L.current.style.width="0%"),r.current&&(r.current.style.left="0%"),z.current&&(z.current.textContent=""),Ke(-1),Ie(null),Pe(0),je(!1),Le(!1),$e(null),Ee(null)},[s.blob,s.scenario,s.node]),c.useEffect(()=>{if(R([]),_("time"),!b.timelineBlob)return;let e=!0;return fetch(ye(`/api/evidence/${b.timelineBlob}`)).then(t=>t.ok?t.json():null).then(t=>{const o=e&&vn(t);o&&(R(o.events),_(o.axis))}).catch(()=>{}),()=>{e=!1}},[b.timelineBlob]),c.useEffect(()=>{const e=h.current;if(!e)return;const t=()=>{const y=Math.round((e.currentTime||0)*1e3),M=Math.round((e.duration||0)*1e3);ae.current=y;const X=M?y/M*100:0;L.current&&(L.current.style.width=`${X}%`),r.current&&(r.current.style.left=`${X}%`),z.current&&(z.current.textContent=`${ke(y)} / ${ke(M)}`),ve()},o=()=>{Pe(e.duration||0),t()},w=()=>je(!0),g=()=>je(!1);return e.addEventListener("timeupdate",t),e.addEventListener("seeked",t),e.addEventListener("loadedmetadata",o),e.addEventListener("durationchange",o),e.addEventListener("play",w),e.addEventListener("pause",g),o(),()=>{e.removeEventListener("timeupdate",t),e.removeEventListener("seeked",t),e.removeEventListener("loadedmetadata",o),e.removeEventListener("durationchange",o),e.removeEventListener("play",w),e.removeEventListener("pause",g)}},[Y==null?void 0:Y.hash,s.node,s.scenario,A,ve]);const q=Math.round(vs*1e3),me=k[ge]||null,He=j==="time"?q:j==="frame"?he.length:j==="index"?k.length:0,W=c.useCallback(e=>{const t=h.current;t&&(t.currentTime=e/1e3)},[]),Ne=c.useCallback(()=>{const e=h.current;e&&(e.paused?e.play():e.pause())},[]),Qe=(e,t)=>{Ee(e),t!=null&&W(t)},xe=c.useCallback(async e=>{const t=h.current;if(!(t!=null&&t.videoWidth))return null;Q(!0),O(d("annotator.capturing"));try{t.seeking&&await new Promise(M=>t.addEventListener("seeked",M,{once:!0}));const o=document.createElement("canvas");o.width=t.videoWidth,o.height=t.videoHeight;const w=o.getContext("2d");w.drawImage(t,0,0,o.width,o.height),e&&(w.strokeStyle="#ff9a3c",w.lineWidth=Math.max(2,o.width/300),w.strokeRect(e.x/100*o.width,e.y/100*o.height,e.w/100*o.width,e.h/100*o.height));const g=await new Promise(M=>o.toBlob(M,"image/png")),{hash:y}=await Cs(g);if(!y)throw new Error("no hash");return O(""),y}catch{return O(d("annotator.failed")),null}finally{Q(!1)}},[d]),ks=c.useCallback(async()=>{var o;const e=h.current;if(!e)return null;e.pause();const t=Math.round((e.currentTime??0)*1e3);return{tMs:t,step:((o=is(k,t))==null?void 0:o.step)??null,frame:await xe(null)}},[k,xe]),Ye=c.useCallback(async e=>{const t=h.current;if(!t)return;t.pause();const o=Math.round((t.currentTime||0)*1e3),w=is(k,o),g=await xe(e),y=[Vs(o,w==null?void 0:w.step)];g&&y.push(``),w!=null&&w.node&&w.node!==s.node&&y.push(`re: [[${w.node}]]`),y.push(""),U({seq:++$.current,body:y.join(`
|
|
1
|
+
import{u as H,j as n,I as ne,r as c,ab as Fs,m as ye,ac as Cs,a as we,ad as Ts,ae as As,T as Ps,i as Ks,b as Os,k as Is}from"./index-DWjEd9Wj.js";import{E as Re,k as ns,r as zs,e as Bs,a as _s,p as Us,b as Vs,O as Hs,R as Qs,m as ke,c as Ys}from"./Thread-DsQYxUwv.js";import{O as ie,Q as J,S as qs,d as Xs,l as Gs,r as ts,T as Js,U as Zs}from"./App-CgqiczQU.js";import{az as Fe,P as V,g as ce,R as I,aA as Ds,aB as Ws,aC as as,I as rs,aD as Ce,aE as ee,aF as G,aG as Te,aH as en,aI as ls,aJ as sn,aK as nn,N as tn,ai as Ae,aL as an,L as rn,Q as hs}from"./tabs-OpePwMY6.js";import"./Modal-ByQRzOqM.js";const os={video:"vid",image:"img",transcript:"txt",data:"data"},ln=["is","state","verdict","freshness","evidence","node","filer","session","scope"],fs=s=>`eval:${s.node}·${s.scenario}`;function on({e:s}){const a=H(),l=s.humanOk&&a("evalsFeed.okdTip",{by:s.humanOk.by,at:new Date(s.humanOk.ts).toLocaleString()});return n.jsx(Fe,{state:n.jsx(I,{kind:"eval",state:s.state}),title:s.scenario,meta:n.jsxs(n.Fragment,{children:[n.jsx("a",{className:"ef-node",href:V(ce(s.node)),style:{color:`hsl(${s.hue??210} 60% 70%)`},"data-tip":s.node,children:s.node}),s.by&&n.jsx("span",{"data-tip":s.by,children:a("evalsFeed.filedBy",{by:zs(s.by)})}),n.jsx("span",{children:a("evalsFeed.filedAt",{at:cn(s.ts)})})]}),aside:n.jsxs(n.Fragment,{children:[s.inSession&&n.jsx("span",{className:"rl-tag in-session",children:a("evalsFeed.sessionTag")}),ns(s).some(i=>os[i])&&n.jsx("span",{className:"rl-tag",children:ns(s).map(i=>os[i]).filter(Boolean).join("·")}),s.humanOk&&n.jsx("span",{role:"img",className:"ef-okd","data-tip":l,"aria-label":l,children:n.jsx(ne,{name:"check",size:11})})]})})}const cn=s=>{const a=Math.max(0,(Date.now()-new Date(s).getTime())/1e3);return a<3600?`${Math.max(1,Math.floor(a/60))}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`},se=(s,a,l,i=p=>p)=>{var p,f;return(((f=(p=s==null?void 0:s.facets)==null?void 0:p[a])==null?void 0:f.options)??[]).map(x=>({value:x.value,label:x.value===""?l:i(x.value)}))};function un({pageData:s,loading:a=!1,sessions:l=[],queryText:i="",onQueryText:p,hrefFor:f,leading:x=null,error:m=null,empty:S=null,pagination:E=null}){var Q,Z,U,L;const u=H(),d=String(i??"").trim()||ie,h=(r,z)=>p(qs(d,r,z)),C=Array.isArray(s==null?void 0:s.items)?s.items:[],P=((Q=s==null?void 0:s.counts)==null?void 0:Q.fail)||{},N=((Z=s==null?void 0:s.counts)==null?void 0:Z.pass)||{},$=((U=s==null?void 0:s.counts)==null?void 0:U.unmeasured)||0,k=((L=s==null?void 0:s.counts)==null?void 0:L.deferred)||0,R=r=>r>0?{text:`+${r} ${u("reviewList.freshness.stale")}`,compact:`+${r}`}:null,j=J(d,"verdict"),_=C.flatMap(r=>r.filterKind===Re.BLIND?[{key:`blind:${r.node}·${r.scenario}`,cls:"se-blind",content:n.jsx(Fe,{state:n.jsx(I,{kind:"eval",state:"missing"}),title:r.scenario,meta:n.jsxs(n.Fragment,{children:[n.jsx("a",{className:"ef-node",href:V(ce(r.node)),style:{color:`hsl(${r.hue??210} 60% 70%)`},"data-tip":r.node,children:r.node}),n.jsx("span",{children:u("sessionEval.unmeasured")})]})})}]:r.filterKind===Re.RESULT?[{key:fs(r),label:r.scenario,href:f(r),content:n.jsx(on,{e:r})}]:r.filterKind===Re.DEFERRED?[{key:`deferred:${r.node}·${r.scenario}`,label:r.scenario,content:n.jsx(Fe,{state:n.jsx(I,{kind:"eval",state:"empty",title:u("reviewList.verdict.deferred")}),title:r.scenario,meta:n.jsxs(n.Fragment,{children:[n.jsx("a",{className:"ef-node",href:V(ce(r.node)),style:{color:`hsl(${r.hue??210} 60% 70%)`},"data-tip":r.node,children:r.node}),n.jsx("span",{children:u("evalsFeed.freshnessDeferred")})]})})}]:[]),v={label:u("reviewList.facetReview"),value:J(d,"state"),options:se(s,"review",u("reviewList.all"),r=>u(r==="reviewed"?"reviewList.reviewed":"reviewList.needsReview"))},F={label:u("reviewList.facetFreshness"),value:J(d,"freshness"),options:se(s,"freshness",u("reviewList.all"),r=>u(`reviewList.freshness.${r}`))},K={label:u("reviewList.facetKind"),value:J(d,"evidence")||"all",options:se(s,"kind",u("evalsFeed.kind.all"),r=>u(`evalsFeed.kind.${r}`))},O={label:u("reviewList.facetSession"),value:J(d,"session"),options:se(s,"session",u("reviewList.all"),r=>u(r==="present"?"reviewList.sessionPresent":"reviewList.sessionMissing"))},te=J(d,"evidence");return n.jsx(Ds,{leading:x,error:m,loading:a,title:u("evalsFeed.title"),search:{value:String(i??"").trim()?i:ie,onSubmit:p,placeholder:u("reviewList.searchEvals"),label:u("reviewList.search"),keys:ln,suggest:{node:se(s,"node",u("reviewList.all")).filter(r=>r.value),filer:se(s,"filer",u("reviewList.all")).filter(r=>r.value).map(({value:r})=>{const z=l.find(ae=>ae.id===r);return{value:r,label:z?rs(z):null}}),scope:l.map(r=>({value:r.id,label:rs(r)}))}},sections:[{key:"fail",label:n.jsx(I,{kind:"eval",state:"fail",title:u("reviewList.verdict.fail"),showLabel:!0}),count:P.fresh||0,countSuffix:R(P.stale||0),active:j==="fail",onSelect:()=>h("verdict",j==="fail"?"":"fail")},{key:"pass",label:n.jsx(I,{kind:"eval",state:"pass",title:u("reviewList.verdict.pass"),showLabel:!0}),count:N.fresh||0,countSuffix:R(N.stale||0),active:j==="pass",onSelect:()=>h("verdict",j==="pass"?"":"pass")},{key:"unmeasured",label:n.jsx(I,{kind:"eval",state:"missing",title:u("reviewList.verdict.unmeasured"),showLabel:!0}),count:$,active:j==="unmeasured",onSelect:()=>h("verdict",j==="unmeasured"?"":"unmeasured")},{key:"deferred",label:n.jsx(I,{kind:"eval",state:"empty",title:u("reviewList.verdict.deferred"),showLabel:!0}),count:k,active:j==="deferred",onSelect:()=>h("verdict",j==="deferred"?"":"deferred")}],sectionMode:"filters",facets:n.jsxs(n.Fragment,{children:[n.jsx(as,{label:F.label,value:F.value,options:F.options,clearLabel:u("reviewList.all"),onChange:r=>h("freshness",r)}),n.jsx(as,{label:K.label,value:K.value,options:K.options,onChange:r=>h("evidence",r==="all"?"":r)})]}),secondaryFilters:n.jsx(Ws,{label:u("reviewList.filters"),clearLabel:u("reviewList.all"),groups:[{label:v.label,value:v.value,active:!!v.value,options:v.options,onChange:r=>h("state",r)},{label:O.label,value:O.value,active:!!O.value,options:O.options,onChange:r=>h("session",r)},{label:F.label,value:F.value,active:!!F.value,options:F.options,onChange:r=>h("freshness",r),mobileOnly:!0},{label:K.label,value:K.value,active:!!te,options:K.options,clearLabel:null,onChange:r=>h("evidence",r==="all"?"":r),mobileOnly:!0}]}),rows:_,pagination:E,empty:S||{hasData:((s==null?void 0:s.sourceTotal)??0)>0,dataset:u("evalsFeed.datasetEmpty"),filtered:u("evalsFeed.noMatches")}})}const dn=[{name:"ok",color:"green",when:s=>!s.okd&&s.isLatest,descKey:"annotator.cmd.okDesc"}];function hn(s,a){return dn.filter(l=>l.when(s)).map(l=>({...l,run:a[l.name]}))}function fn(s,a){return(s||"").replace(/\{(\w+)\}/g,(l,i)=>a[i]!=null?String(a[i]):l)}const is=(s,a)=>{let l=null;for(const i of s)if(i.at<=a)l=i;else break;return l},vn=s=>{if(!s||!Array.isArray(s.events))return null;const a=s.v===1?"time":typeof s.axis=="string"?s.axis:"time",l=s.v===1?i=>i.tMs:i=>i.at;return{axis:a,events:s.events.map(i=>({at:l(i),step:i.step,...i.node?{node:i.node}:{}}))}},mn=(s,a,l)=>s==="time"?ke(a):s==="frame"?`#${a}`:s==="line"?`L${a}`:s==="index"?l?`${a}/${l}`:`${a}`:String(a);function cs({events:s,axis:a,extent:l,activeStepIdx:i,onSeek:p}){return n.jsx("div",{className:"an-ruler",children:s.map((f,x)=>n.jsxs("button",{className:`an-step ${i===x?"on":""}`,onClick:()=>p(f.at),"data-tip":f.node?`→ ${f.node}`:void 0,children:[mn(a,f.at,l)," ",f.step]},x))})}const pe=8;function xn({hidden:s,total:a,histIdx:l,onPick:i}){const p=H(),f=sn(),x=p("annotator.abMore",{n:s.length});return n.jsxs("div",{className:"an-ab-more",ref:f.ref,children:[n.jsx(we,{icon:"ellipsis",size:14,className:"an-ab-morebtn",label:x,"aria-haspopup":"menu","aria-expanded":f.open,onClick:m=>f.toggle(m.currentTarget),onKeyDown:f.onTriggerKeyDown}),f.open&&n.jsx("div",{className:"rl-menu an-ab-menu",role:"menu","aria-label":x,ref:f.menuRef,onKeyDown:f.onMenuKeyDown,children:s.map(m=>{const S=Ce(m);return n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":m.idx===l,tabIndex:-1,className:"rl-menu-item an-ab-menuitem",onFocus:f.onItemFocus,onClick:()=>{f.close(!0),i(m.idx)},children:[n.jsx(I,{kind:"eval",state:S,size:13}),n.jsxs("span",{className:"an-ab-menupos",children:[a-m.idx,"/",a]}),n.jsx("span",{className:"an-ab-menudate",children:new Date(m.ts).toLocaleString()})]},`${m.ts}-${m.idx}`)})})]})}function pn({entry:s,history:a,sourceKey:l="project",specs:i=[],sessions:p=[],onWrite:f,onOpenSession:x,listHref:m=null,backHref:S=null,backLabel:E=null,queue:u={prev:[],next:[]}}){var Je,Ze,De,We,es,ss;const d=H(),h=c.useRef(null),C=c.useRef(null),P=c.useRef(null),N=c.useRef(null),$=c.useRef(0),[k,R]=c.useState([]),[j,_]=c.useState("time"),[v,F]=c.useState(null),[K,O]=c.useState(""),[te,Q]=c.useState(!1),[Z,U]=c.useState(null),L=c.useRef(null),r=c.useRef(null),z=c.useRef(null),ae=c.useRef(0),[vs,Pe]=c.useState(0),[ge,Ke]=c.useState(-1),[Oe,Ie]=c.useState(null),[ue,je]=c.useState(!1),[ze,Le]=c.useState(!1),[Se,$e]=c.useState(null),[de,Ee]=c.useState(null),[T,Be]=c.useState(null),[A,re]=c.useState(0),b=T&&T[A]||s,ms=`${A}:${b.ts||b.codeSha||b.blob||"reading"}`,xs=`${l}·${s.node}·${s.scenario}·${ms}`,[ps,bs]=c.useState([]);c.useEffect(()=>{let e=!0;return Fs().then(t=>{e&&Array.isArray(t)&&bs(t)}).catch(()=>{}),()=>{e=!1}},[]),c.useEffect(()=>{F(null),O(""),R([]),U(null),re(0),Be(null),Be(Array.isArray(a)?a:[s])},[s.node,s.scenario,s.ts,s.blob,(Je=s.humanOk)==null?void 0:Je.ts,a]),c.useEffect(()=>{F(null),U(null)},[A]);const le=Bs(b),Y=le.find(e=>e.kind==="video"&&e.state==="present"),he=le.filter(e=>e.kind==="image"),ws=le.filter(e=>e.kind!=="video"&&e.kind!=="image"),D=!!Y,fe=s.thread??null,Me=c.useMemo(()=>((fe==null?void 0:fe.replies)??[]).filter(e=>e.rid!==void 0),[fe]),_e=T&&((Ze=T[0])==null?void 0:Ze.by)||s.by||null,B=c.useMemo(()=>Me.map((e,t)=>{const o=_s(Us(e.body),k);return o&&o.seekable?{i:t,tMs:o.tMs,step:o.step,label:o.label}:null}).filter(Boolean).sort((e,t)=>e.tMs-t.tMs),[Me,k]),Ue=c.useRef(k);Ue.current=k;const Ve=c.useRef(B);Ve.current=B;const ve=c.useCallback(()=>{const e=ae.current,t=Ue.current;let o=-1;for(let g=0;g<t.length&&t[g].at<=e;g++)o=g;Ke(g=>g===o?g:o);let w=null;for(const g of Ve.current)if(g.tMs<=e)w=g.i;else break;Ie(g=>g===w?g:w)},[]);c.useEffect(()=>{ve()},[B,k,ve]),c.useEffect(()=>{ae.current=0,L.current&&(L.current.style.width="0%"),r.current&&(r.current.style.left="0%"),z.current&&(z.current.textContent=""),Ke(-1),Ie(null),Pe(0),je(!1),Le(!1),$e(null),Ee(null)},[s.blob,s.scenario,s.node]),c.useEffect(()=>{if(R([]),_("time"),!b.timelineBlob)return;let e=!0;return fetch(ye(`/api/evidence/${b.timelineBlob}`)).then(t=>t.ok?t.json():null).then(t=>{const o=e&&vn(t);o&&(R(o.events),_(o.axis))}).catch(()=>{}),()=>{e=!1}},[b.timelineBlob]),c.useEffect(()=>{const e=h.current;if(!e)return;const t=()=>{const y=Math.round((e.currentTime||0)*1e3),M=Math.round((e.duration||0)*1e3);ae.current=y;const X=M?y/M*100:0;L.current&&(L.current.style.width=`${X}%`),r.current&&(r.current.style.left=`${X}%`),z.current&&(z.current.textContent=`${ke(y)} / ${ke(M)}`),ve()},o=()=>{Pe(e.duration||0),t()},w=()=>je(!0),g=()=>je(!1);return e.addEventListener("timeupdate",t),e.addEventListener("seeked",t),e.addEventListener("loadedmetadata",o),e.addEventListener("durationchange",o),e.addEventListener("play",w),e.addEventListener("pause",g),o(),()=>{e.removeEventListener("timeupdate",t),e.removeEventListener("seeked",t),e.removeEventListener("loadedmetadata",o),e.removeEventListener("durationchange",o),e.removeEventListener("play",w),e.removeEventListener("pause",g)}},[Y==null?void 0:Y.hash,s.node,s.scenario,A,ve]);const q=Math.round(vs*1e3),me=k[ge]||null,He=j==="time"?q:j==="frame"?he.length:j==="index"?k.length:0,W=c.useCallback(e=>{const t=h.current;t&&(t.currentTime=e/1e3)},[]),Ne=c.useCallback(()=>{const e=h.current;e&&(e.paused?e.play():e.pause())},[]),Qe=(e,t)=>{Ee(e),t!=null&&W(t)},xe=c.useCallback(async e=>{const t=h.current;if(!(t!=null&&t.videoWidth))return null;Q(!0),O(d("annotator.capturing"));try{t.seeking&&await new Promise(M=>t.addEventListener("seeked",M,{once:!0}));const o=document.createElement("canvas");o.width=t.videoWidth,o.height=t.videoHeight;const w=o.getContext("2d");w.drawImage(t,0,0,o.width,o.height),e&&(w.strokeStyle="#ff9a3c",w.lineWidth=Math.max(2,o.width/300),w.strokeRect(e.x/100*o.width,e.y/100*o.height,e.w/100*o.width,e.h/100*o.height));const g=await new Promise(M=>o.toBlob(M,"image/png")),{hash:y}=await Cs(g);if(!y)throw new Error("no hash");return O(""),y}catch{return O(d("annotator.failed")),null}finally{Q(!1)}},[d]),ks=c.useCallback(async()=>{var o;const e=h.current;if(!e)return null;e.pause();const t=Math.round((e.currentTime??0)*1e3);return{tMs:t,step:((o=is(k,t))==null?void 0:o.step)??null,frame:await xe(null)}},[k,xe]),Ye=c.useCallback(async e=>{const t=h.current;if(!t)return;t.pause();const o=Math.round((t.currentTime||0)*1e3),w=is(k,o),g=await xe(e),y=[Vs(o,w==null?void 0:w.step)];g&&y.push(``),w!=null&&w.node&&w.node!==s.node&&y.push(`re: [[${w.node}]]`),y.push(""),U({seq:++$.current,body:y.join(`
|
|
2
2
|
`)})},[k,s.node,xe]),qe=c.useCallback(e=>{var w;if(!B.length)return;let t=B.findIndex(g=>g.i===de);if(t<0){const g=Math.round((((w=h.current)==null?void 0:w.currentTime)||0)*1e3);t=B.reduce((y,M,X)=>M.tMs<=g?X:y,-1)}t=Math.min(B.length-1,Math.max(0,t+e));const o=B[t];Ee(o.i),W(o.tMs)},[B,de,W]);Xs(e=>{if(!D||e.metaKey||e.ctrlKey||e.altKey)return!1;const t=h.current;return t?e.key===" "?(e.preventDefault(),Ne(),!0):e.key==="ArrowRight"?(e.preventDefault(),t.currentTime=Math.min(t.duration||t.currentTime,t.currentTime+(e.shiftKey?1:5)),!0):e.key==="ArrowLeft"?(e.preventDefault(),t.currentTime=Math.max(0,t.currentTime-(e.shiftKey?1:5)),!0):e.key===","?(e.preventDefault(),t.currentTime=Math.max(0,t.currentTime-1/30),!0):e.key==="."?(e.preventDefault(),t.duration&&(t.currentTime=Math.min(t.duration,t.currentTime+1/30)),!0):e.key==="ArrowDown"?(e.preventDefault(),qe(1),!0):e.key==="ArrowUp"?(e.preventDefault(),qe(-1),!0):e.key==="a"||e.key==="A"?(e.preventDefault(),Ye(null),!0):!1:!1});const Xe=e=>{var w;const t=(w=P.current)==null?void 0:w.getBoundingClientRect(),o=h.current;!t||!t.width||!o||!o.duration||(o.currentTime=Math.min(1,Math.max(0,(e-t.left)/t.width))*o.duration)},ys=e=>{e.preventDefault(),Le(!0),Xe(e.clientX)},gs=e=>{var o;const t=(o=P.current)==null?void 0:o.getBoundingClientRect();t!=null&&t.width&&$e(Math.min(100,Math.max(0,(e.clientX-t.left)/t.width*100)))};c.useEffect(()=>{if(!ze)return;const e=o=>Xe(o.clientX),t=()=>Le(!1);return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[ze]);const Ge=e=>{const t=C.current.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width*100,y:(e.clientY-t.top)/t.height*100}},js=e=>{if(e.button!==0||te)return;const t=Ge(e);F({x0:t.x,y0:t.y,x:t.x,y:t.y})},Ls=e=>{var o,w;if(!v)return;const t=Ge(e);!((o=h.current)!=null&&o.paused)&&(Math.abs(t.x-v.x0)>1||Math.abs(t.y-v.y0)>1)&&((w=h.current)==null||w.pause()),F({...v,x:t.x,y:t.y})},Ss=()=>{if(!v)return;const e={x:Math.min(v.x0,v.x),y:Math.min(v.y0,v.y),w:Math.abs(v.x-v.x0),h:Math.abs(v.y-v.y0)};if(F(null),e.w<1&&e.h<1){Ne();return}Ye(e)},oe=v&&{x:Math.min(v.x0,v.x),y:Math.min(v.y0,v.y),w:Math.abs(v.x-v.x0),h:Math.abs(v.y-v.y0)},$s=async()=>{const e=await As(s.node,s.scenario).catch(t=>({error:String(t)}));f==null||f((e==null?void 0:e.error)||"")},Es=[...hn({okd:!!b.humanOk,isLatest:!T||A===0},{ok:$s}).map(e=>({name:e.name,description:d(e.descKey),ui:!0,color:e.color,run:e.run})),...ps.map(e=>({name:e.name,description:e.desc||e.title,source:"review",prefill:()=>fn(e.body,{node:s.node,scenario:s.scenario,expected:b.expected||""})}))],Ms=n.jsxs(n.Fragment,{children:[n.jsx(I,{kind:"eval",state:Ce(b),showLabel:!0,className:"an-verdict-badge",size:16}),b.humanOk&&n.jsxs("span",{className:"an-okd","data-tip":d("annotator.okBy",{by:b.humanOk.by,at:new Date(b.humanOk.ts).toLocaleString()}),children:[n.jsx(ne,{name:"circle-check",size:14})," ",d("annotator.okd")]}),T&&T.length>1&&(()=>{const e=T.length,t=Math.min(pe,e),o=A<pe?Array.from({length:t},(y,M)=>t-1-M):[A,...Array.from({length:pe-1},(y,M)=>pe-2-M)],w=new Set(o),g=T.map((y,M)=>({...y,idx:M})).filter(y=>!w.has(y.idx));return n.jsxs("div",{className:"an-ab",children:[n.jsx(we,{icon:"chevron-left",size:13,className:"an-ab-nav",disabled:A>=T.length-1,onClick:()=>re(y=>Math.min(T.length-1,y+1)),label:d("annotator.abOlder")}),g.length>0&&n.jsx(xn,{hidden:g,total:e,histIdx:A,onPick:re}),n.jsx("div",{className:"an-ab-track",children:o.map(y=>{const M=T[y],X=Ce(M);return n.jsx("button",{type:"button",className:`an-ab-pip ${y===A?"on":""}`,"aria-current":y===A?"true":void 0,onClick:()=>re(y),"aria-label":`${e-y}/${e} · ${d(`score.${X}`)} · ${new Date(M.ts).toLocaleString()}`,children:n.jsx(I,{kind:"eval",state:X,size:13})},`${M.ts}-${y}`)})}),n.jsx(we,{icon:"chevron-right",size:13,className:"an-ab-nav",disabled:A<=0,onClick:()=>re(y=>Math.max(0,y-1)),label:d("annotator.abNewer")}),n.jsx("span",{className:"an-ab-pos",children:A===0?d("annotator.abLatest"):d("annotator.abPos",{i:T.length-A,n:T.length})})]})})()]}),Ns=n.jsxs(n.Fragment,{children:[n.jsxs(ee,{label:d("detail.sideReading"),children:[b.evaluator&&n.jsx(G,{text:b.evaluator}),n.jsx(G,{text:new Date(b.ts).toLocaleString()})]}),n.jsx(ee,{label:d("detail.sideNode"),children:n.jsx(G,{text:s.node,mono:!0,tip:d("session.issuesFocusNode"),href:V(ce(s.node))})}),_e&&n.jsx(ee,{label:d("detail.sideFiler"),children:n.jsx(Hs,{originator:_e,sessions:p,kind:"eval",onOpenSession:x})}),b.humanOk&&n.jsxs(ee,{label:d("detail.sideOk"),children:[n.jsx(G,{text:`☑ ${b.humanOk.by}`}),n.jsx(G,{text:new Date(b.humanOk.ts).toLocaleString(),dim:!0})]}),!b.fresh&&(((De=b.staleAxes)==null?void 0:De.length)??0)>0&&n.jsxs(ee,{label:d("nodeView.eval.staleLabel"),children:[n.jsx(G,{text:b.staleAxes.join(" · "),tip:d("nodeView.eval.staleReadoutTitle")}),(((We=b.codeDrift)==null?void 0:We.length)??0)>0&&n.jsx(G,{text:b.codeDrift.map(e=>`${e.file.split("/").pop()} +${e.behind}`).join(", "),dim:!0})]}),(u.prev.length>0||u.next.length>0)&&n.jsx(ee,{label:d("detail.sideQueue"),children:[["prev",d("detail.queuePrev")],["next",d("detail.queueNext")]].map(([e,t])=>u[e].length>0&&n.jsxs("div",{className:"ds-queue-group",children:[n.jsx("span",{className:"ds-queue-group-label",children:t}),u[e].map(o=>n.jsxs("a",{className:"ds-queue-row",href:o.href,"data-tip":`${o.node} · ${o.scenario}`,children:[n.jsx(I,{kind:"eval",state:o.state,size:13}),n.jsx("span",{className:"ds-queue-scenario",children:o.scenario}),n.jsx("span",{className:"ds-queue-node",children:o.node})]},o.key))]},e))})]}),Rs=n.jsx(Qs,{onSend:(e,t)=>Ts({node:s.node,scenario:s.scenario,body:e,codeSha:b.codeSha,evidence:t}),specs:i,sessions:p,focusId:s.node,onDone:f,anchorNow:D?ks:null,draft:Z,commands:Es},xs);return n.jsxs(Te,{title:s.scenario,titleMeta:n.jsx("a",{className:"an-node",href:V(ce(s.node)),children:s.node}),status:Ms,side:Ns,composer:Rs,listHref:m,backHref:S,backLabel:E,children:[b.expected&&n.jsxs("div",{className:"an-expected",children:[n.jsx("b",{children:d("nodeView.eval.expected")})," ",b.expected]}),le.length>0&&((es=b.verdict)==null?void 0:es.note)&&n.jsxs("div",{className:"an-expected an-prior-note",children:[n.jsx("b",{children:d("nodeView.eval.noteLabel")})," ",b.verdict.note]}),Y&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"an-player",ref:N,children:[n.jsxs("div",{className:`an-stage ${ue?"playing":"paused"}`,ref:C,onMouseDown:js,onMouseMove:Ls,onMouseUp:Ss,children:[n.jsx("video",{className:"an-video",ref:h,src:ye(`/api/evidence/${Y.hash}`),preload:"metadata",playsInline:!0}),oe&&n.jsx("div",{className:"an-rect live",style:{left:`${oe.x}%`,top:`${oe.y}%`,width:`${oe.w}%`,height:`${oe.h}%`}}),!ue&&!v&&n.jsx("div",{className:"an-bigplay","aria-hidden":!0,children:n.jsx(ne,{name:"play",size:22})})]}),n.jsxs("div",{className:"an-bar",children:[n.jsx(we,{icon:ue?"pause":"play",size:14,className:"an-play",label:d(ue?"annotator.pause":"annotator.play"),onClick:Ne}),n.jsxs("div",{className:"an-seek",ref:P,onMouseDown:ys,onMouseMove:gs,onMouseLeave:()=>$e(null),children:[n.jsx("div",{className:"an-seek-trk"}),q>0&&j==="time"&&k.map((e,t)=>n.jsx("div",{className:"an-band",style:{left:`${e.at/q*100}%`},"data-tip":e.step},`band-${t}`)),n.jsx("div",{className:"an-seek-play",ref:L}),q>0&&B.map(e=>n.jsx("button",{type:"button",className:`an-mk ${de===e.i?"on":""} ${Oe===e.i?"active":""}`,style:{left:`${e.tMs/q*100}%`},"data-tip":e.label,onMouseDown:t=>t.stopPropagation(),onClick:t=>{t.stopPropagation(),Qe(e.i,e.tMs)}},`mk-${e.i}`)),n.jsx("div",{className:"an-knob",ref:r}),Se!=null&&q>0&&n.jsx("div",{className:"an-seek-hov",style:{left:`${Se}%`},children:ke(Se/100*q)})]}),n.jsx("span",{className:"an-time",ref:z}),me&&n.jsx("span",{className:"an-curstep","data-tip":me.node?`→ ${me.node}`:void 0,children:me.step}),n.jsx(en,{target:N})]})]}),k.length>0&&n.jsx(cs,{events:k,axis:j,extent:He,activeStepIdx:ge,onSeek:W}),K&&n.jsx("div",{className:"an-flash",children:K})]}),!Y&&k.length>0&&n.jsx(cs,{events:k,axis:j,extent:He,activeStepIdx:ge,onSeek:W}),he.length>0&&n.jsx("div",{className:"an-gallery",children:he.map((e,t)=>n.jsx(ls,{e,alt:s.scenario},`${e.hash}-${t}`))}),ws.map((e,t)=>n.jsx(ls,{e,alt:s.scenario,collapsed:D||he.length>0},`${e.hash}-${t}`)),le.length===0&&((ss=b.verdict)!=null&&ss.note?n.jsx("pre",{className:"eval-transcript",children:b.verdict.note}):n.jsx("div",{className:"an-hint",children:d("nodeView.eval.noImage")})),n.jsx(bn,{entry:s,comments:Me,seekMs:D?W:null,selIdx:de,activeIdx:Oe,onSelect:D?Qe:null,events:D?k:null,onWrite:f})]})}function bn({entry:s,comments:a,seekMs:l,selIdx:i,activeIdx:p,onSelect:f,events:x,onWrite:m}){var E;const S=H();return n.jsxs("section",{className:"an-thread",children:[n.jsx("div",{className:"an-comments-head",children:n.jsx("span",{children:S("annotator.comments",{n:a.length})})}),n.jsx(Ys,{replies:a,onSeek:l,selIdx:i,activeIdx:p,onSelect:f,events:x,threadId:((E=s.thread)==null?void 0:E.id)??null,onRemarkChange:()=>m==null?void 0:m("")})]})}const be=new Map,wn=[],kn={};function us(s,a){if(!(s!=null&&s.evalRevision)||!(a!=null&&a.epoch))return!0;const l=s.evalRevision;return l.epoch!==a.epoch||l.generation<a.generation?!1:l.generation!==a.generation?!0:!(a.revision&&l.content!==a.revision||a.value&&s.summary&&["measured","total","pass","fail","review","blind","unknown"].some(p=>s.summary[p]!==a.value[p]))}function ds(s,a,l){const i=`${l||""}\0${s}\0${a}`;if(be.has(i))return be.get(i);const p=new URLSearchParams({node:s,scenario:a});l&&p.set("scope",l);const f=Is(ye(`/api/evals/detail?${p}`),{cache:"no-store"}).then(x=>x.ok?x.json():x.status===404?!1:x.json().catch(()=>null).then(m=>{throw new Error((m==null?void 0:m.error)||`HTTP ${x.status}`)})).finally(()=>be.delete(i));return be.set(i,f),f}function yn(s,a,l,i=!0,p=null){const f=String(s||"").indexOf("/"),x=f>0?s.slice(0,f):s,m=f>0?s.slice(f+1):"",S=`${a||""}\0${x}\0${m}`,[E,u]=c.useState({identity:"",data:null,error:null}),d=c.useRef(0),h=c.useRef(l);h.current=l;const C=c.useCallback(()=>{if(!i||!x||!m)return Promise.resolve();const N=++d.current;return u($=>$.identity===S?{...$,error:null}:{identity:S,data:null,error:null}),ds(x,m,a).then(async $=>{if(N===d.current){if($&&!us($,h.current)){const k=await ds(x,m,a);if(N!==d.current)return;if(k&&!us(k,h.current))throw new Error("stale session eval detail");$=k}u({identity:S,data:$,error:null})}}).catch($=>{if(N!==d.current)return;const k=$ instanceof Error?$.message:String($);u(R=>({identity:S,data:R.identity===S&&R.data?R.data:!1,error:k}))})},[i,S,x,m,a]);c.useEffect(()=>{i&&C()},[i,x,m,a,p,l==null?void 0:l.epoch,l==null?void 0:l.generation,l==null?void 0:l.revision]);const P=E.identity===S?E:{data:null,error:null};return{data:P.data,error:P.error,reload:C}}function gn({sessionId:s}){const l=H()("sessionEval.scopeDoor");return n.jsx("a",{className:"se-door",href:V(rn(s)),"data-tip":l,"aria-label":l,children:n.jsx(ne,{name:"arrow-left",size:16})})}function jn({sessionId:s,pageData:a,loading:l,error:i,sessions:p,queryText:f,onQueryText:x,hrefFor:m,hrefForPage:S}){const E=H(),u=(a==null?void 0:a.unknown)||0,d=s&&!l&&!i&&((a==null?void 0:a.sourceTotal)??0)===0?E("sessionEval.none"):null,h=s?n.jsxs("div",{className:"se-gates",children:[n.jsx(gn,{sessionId:s}),u>0&&n.jsxs("span",{className:"se-gate bad se-unknown","data-tip":E("sessionEval.unknownCoverage",{n:u}),children:[n.jsx(ne,{name:"info",size:11})," ",u]}),a&&n.jsx("span",{className:"se-acts",children:n.jsx("a",{className:"se-export",href:ye(`/api/sessions/${encodeURIComponent(s)}/evals?format=html`),target:"_blank",rel:"noreferrer","data-tip":E("sessionEval.exportTitle"),"aria-label":E("sessionEval.export"),children:n.jsx(ne,{name:"download",size:13})})})]}):null;return n.jsx(un,{pageData:a,loading:l,sessions:p,queryText:f,onQueryText:x,hrefFor:m,leading:h,error:i?E("sessionEval.loadFailed",{reason:i}):null,empty:d,pagination:a?{page:a.page,pageCount:a.pageCount,prev:a.prev,next:a.next,hrefFor:S}:null})}function Ln({param:s,detail:a,sessionId:l,loading:i=!1,error:p,specs:f,sessions:x,listHref:m,backHref:S,backLabel:E,onOpenSession:u,onWrite:d}){const h=H(),C=s.indexOf("/"),P=C>0?s.slice(0,C):s,N=C>0?s.slice(C+1):null,$=c.useMemo(()=>{const j=v=>({key:fs(v),node:v.node,scenario:v.scenario,state:v.state,href:V(l?Ae(l,v.node,v.scenario):hs(v.node,v.scenario))}),_=(a==null?void 0:a.neighbors)||{prev:[],next:[]};return{prev:_.prev.map(j),next:_.next.map(j)}},[a==null?void 0:a.neighbors,l]);if(p)return n.jsx(Te,{failure:h("sessionEval.loadFailed",{reason:p}),listHref:m,listLabel:h("reviewShell.backToEvals")});if(i)return n.jsx("div",{className:"fv-note",children:h("common.loading")});const k=(a==null?void 0:a.selected)||null,R=(a==null?void 0:a.scopeFallback)==="trunk"?h("reviewShell.scopeFallback"):null;if(!k){const j=(a==null?void 0:a.availability)==="unmeasured"?h("reviewShell.evalUnmeasured"):h("reviewShell.evalNotFound",{node:P,scenario:N||""});return n.jsx(Te,{missing:R?n.jsxs(n.Fragment,{children:[R,n.jsx("br",{}),j]}):j,listHref:m,listLabel:h("reviewShell.backToEvals")})}return n.jsxs("div",{className:"page-detail-stack",children:[R&&n.jsx("div",{className:"fv-source-notice",role:"status",children:R}),n.jsx(pn,{entry:k,history:a.history,sourceKey:a.scope||"project",specs:f,sessions:x,onOpenSession:u,onWrite:d,listHref:m,backHref:S,backLabel:E,queue:$})]})}function Fn({param:s=null,query:a=kn,specs:l=wn,sessions:i=[],issuesStamp:p=null,reloadBoard:f,onOpenSession:x}){var U;const m=H(),S=Ps(),E=Gs(),{notify:u}=Ks(),d=Os(),h=J(a.q||"","scope")||null,C=((U=i.find(L=>L.id===h))==null?void 0:U.evalSummary)||null,P=`${p??""}|${d.retryKey}`,N=yn(s,h,C,!!s,P),$=String(a.q??"").trim()||ie,k=nn(a.page),R=c.useMemo(()=>({specs:l,retryKey:d.retryKey}),[l,d.retryKey]),j=tn("evals",$,k,{enabled:!s&&E,refreshKey:R}),_=L=>{L&&u(L)},v=async L=>{_(L),await(f==null?void 0:f()),await N.reload()},F=L=>V(h?Ae(h,L.node,L.scenario):hs(L.node,L.scenario)),K=h?V(Ae(h)):ts("evals"),O=an("evals",h),te=m("detail.backToEvals"),Q=L=>S.ownQuery(Js(L,ie)),Z=L=>ts("evals",null,Zs($,ie,L));return s?n.jsx(Ln,{param:s,detail:N.data&&N.data!==!1?N.data:null,sessionId:h,loading:N.data===null,error:N.error,specs:l,sessions:i,listHref:K,backHref:O,backLabel:te,onOpenSession:x,onWrite:v}):n.jsx(jn,{sessionId:h,pageData:j.data,loading:j.loading,error:j.error,sessions:i,queryText:a.q||"",onQueryText:Q,hrefFor:F,hrefForPage:Z})}export{Ln as EvalDetailPage,gn as EvalScopeDoor,jn as EvalsListPage,Fn as default,us as detailMatchesProjection};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{u as C,r as l,j as u,a9 as A,_ as M,aa as P}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C9sSKtKD.js","assets/tabs-OpePwMY6.js","assets/index-DWjEd9Wj.js","assets/index-CjNin6fF.css","assets/App-CgqiczQU.js","assets/Modal-ByQRzOqM.js","assets/tabs-Brk4lg7l.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as C,r as l,j as u,a9 as A,_ as M,aa as P}from"./index-DWjEd9Wj.js";import{ar as v,as as N,at as T,au as F,av as I,aw as W,ax as S,ay as t}from"./tabs-OpePwMY6.js";import{P as V}from"./ProseActions-C-bJtCW1.js";import"./App-CgqiczQU.js";import"./Modal-ByQRzOqM.js";const G=S.define([{tag:[t.keyword,t.modifier,t.controlKeyword],color:"var(--magenta)"},{tag:[t.function(t.variableName),t.function(t.propertyName)],color:"var(--blue)"},{tag:[t.string,t.special(t.string)],color:"var(--green)"},{tag:[t.comment,t.lineComment,t.blockComment],color:"var(--muted)",fontStyle:"italic"},{tag:[t.number,t.bool,t.null],color:"var(--orange)"},{tag:[t.typeName,t.className,t.tagName],color:"var(--yellow)"},{tag:[t.propertyName,t.attributeName],color:"var(--cyan)"},{tag:[t.operator,t.punctuation],color:"var(--ink)"},{tag:[t.invalid],color:"var(--red)"}]),D=v.theme({"&":{backgroundColor:"var(--paper)",color:"var(--ink)",fontSize:"var(--type-meta)",height:"100%"},".cm-content":{fontFamily:"var(--mono)",padding:"6px 0"},".cm-scroller":{fontFamily:"var(--mono)",lineHeight:"1.62",overflow:"auto"},".cm-gutters":{backgroundColor:"var(--paper)",color:"var(--muted)",border:"none",opacity:".55"},".cm-lineNumbers .cm-gutterElement":{padding:"0 9px 0 12px"},".cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--line) 30%, transparent)"},".cm-activeLineGutter":{backgroundColor:"transparent",color:"var(--ink)",opacity:"1"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground, ::selection":{backgroundColor:"color-mix(in srgb, var(--blue) 28%, transparent)"},".cm-cursor":{borderLeftColor:"var(--blue)"}},{dark:!0}),O=new Set(["js","jsx","mjs","cjs","ts","tsx","mts","cts"]);async function $(s){const i=(s.split(".").pop()||"").toLowerCase();if(!O.has(i))return[];try{const{javascript:f}=await M(async()=>{const{javascript:o}=await import("./index-C9sSKtKD.js");return{javascript:o}},__vite__mapDeps([0,1,2,3,4,5,6]));return f({jsx:i.endsWith("sx"),typescript:i.startsWith("t")||i.startsWith("mt")||i.startsWith("ct")})}catch{return[]}}const B=900;function X({path:s,read:i,className:f="",onSelection:o}){const p=C(),d=l.useRef(null),a=l.useRef(null),h=l.useRef({offset:0,eof:!1,size:0,busy:!1}),[n,x]=l.useState({phase:"loading",size:0,loaded:0,error:null});l.useEffect(()=>{let y=!0;h.current={offset:0,eof:!1,size:0,busy:!1},x({phase:"loading",size:0,loaded:0,error:null});const j=async()=>{const e=h.current;if(!(e.busy||e.eof)){e.busy=!0;try{const r=await(i?i(e.offset):A(s,e.offset));if(!y)return;e.offset+=r.bytes,e.eof=r.eof,e.size=r.size;const c=a.current;c&&r.text&&c.dispatch({changes:{from:c.state.doc.length,insert:r.text}}),x({phase:"ready",size:r.size,loaded:e.offset,error:null})}catch(r){y&&x(c=>({...c,phase:"error",error:String((r==null?void 0:r.message)||r)}))}finally{e.busy=!1}}},E=v.updateListener.of(e=>{if(e.selectionSet){const{from:c,to:b}=e.state.selection.main;if(c===b)o==null||o(null);else{const z=e.state.doc.lineAt(c).number,H=e.state.doc.lineAt(Math.max(c,b-1)).number,m=e.view.coordsAtPos(c),g=e.view.coordsAtPos(b),L=m?Math.min(m.left,(g==null?void 0:g.left)??m.left):0,_=m?Math.max(m.bottom,(g==null?void 0:g.bottom)??m.bottom):0,R={path:s,startLine:z,endLine:H,text:e.state.sliceDoc(c,b),x:L,y:_};o==null||o(R)}}if(!e.geometryChanged&&!e.docChanged)return;const r=e.view.scrollDOM;r.scrollHeight-r.scrollTop-r.clientHeight<B&&j()});return(async()=>{const e=await $(s);!y||!d.current||(a.current=new v({parent:d.current,state:N.create({doc:"",extensions:[T(),F(),I(),W(G),v.editable.of(!1),N.readOnly.of(!0),v.lineWrapping,D,E,e]})}),await j())})(),()=>{var e;y=!1,o==null||o(null),(e=a.current)==null||e.destroy(),a.current=null}},[s,i,o]);const w=n.size>0?Math.min(100,Math.round(n.loaded/n.size*100)):0,k=!n.error&&(n.phase==="loading"||n.size>0&&w<100);return u.jsx("div",{className:`srcview ${f}`.trim(),children:u.jsxs("div",{className:"srcview-body",children:[u.jsx("div",{className:"srcview-cm",ref:d}),(n.error||k)&&u.jsx("div",{className:`srcview-progress${n.error?" is-error":""}`,role:"status",children:n.error||(n.phase==="loading"?p("common.loading"):`${w}%`)})]})})}function Z({param:s}){const i=C(),f=l.useRef(null),[o,p]=l.useState(null),d=s!=null&&s.startsWith(".spec/")?s.slice(6).split("/"):[],a=d.length>=2?{nodeId:d[0],name:d.slice(1).join("/")}:null,h=l.useMemo(()=>a?n=>P(a.nodeId,a.name,n):void 0,[a==null?void 0:a.nodeId,a==null?void 0:a.name]);return s?u.jsxs("div",{className:"fileview",ref:f,children:[u.jsx(X,{path:s,read:h,onSelection:p},s),u.jsx(V,{hostRef:f,codeSelection:o,onCodeSelectionClear:()=>p(null)})]}):u.jsx("div",{className:"doc-empty",children:i("fileView.none")})}export{Z as default};
|